blob: 720d1f504fc237c33d6a4e9637790a26ee616be1 [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{
1225 struct statsContext context;
1226 hdd_context_t *pHddCtx;
1227 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301228 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 unsigned long rc;
1230
1231 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001232 hdd_warn("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301233 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08001235 if (cds_is_driver_recovering()) {
1236 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
1237 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 /* return a cached value */
1239 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301240 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 }
1242
1243 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1244 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1245
1246 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1247 hdd_err("Not associated!, return last connected AP rssi!");
1248 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301249 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 }
1251
1252 if (pHddStaCtx->hdd_ReassocScenario) {
1253 hdd_info("Roaming in progress, return cached RSSI");
1254 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301255 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 }
1257
1258 init_completion(&context.completion);
1259 context.pAdapter = pAdapter;
1260 context.magic = RSSI_CONTEXT_MAGIC;
1261
1262 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
1263 pHddStaCtx->conn_info.staId[0],
1264 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
1265 &context, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301266 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001267 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 /* we'll returned a cached value below */
1269 } else {
1270 /* request was sent -- wait for the response */
1271 rc = wait_for_completion_timeout(&context.completion,
1272 msecs_to_jiffies
1273 (WLAN_WAIT_TIME_STATS));
1274 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001275 hdd_err("SME timed out while retrieving RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 /* we'll now returned a cached value below */
1277 }
1278 }
1279
1280 /* either we never sent a request, we sent a request and
1281 * received a response or we sent a request and timed out. if
1282 * we never sent a request or if we sent a request and got a
1283 * response, we want to clear the magic out of paranoia. if
1284 * we timed out there is a race condition such that the
1285 * callback function could be executing at the same time we
1286 * are. of primary concern is if the callback function had
1287 * already verified the "magic" but had not yet set the
1288 * completion variable when a timeout occurred. we serialize
1289 * these activities by invalidating the magic while holding a
1290 * shared spinlock which will cause us to block if the
1291 * callback is currently executing
1292 */
1293 spin_lock(&hdd_context_lock);
1294 context.magic = 0;
1295 spin_unlock(&hdd_context_lock);
1296
1297 *rssi_value = pAdapter->rssi;
1298
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301299 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300}
1301
1302/**
1303 * wlan_hdd_get_snr() - Get the current SNR
1304 * @pAdapter: adapter upon which the measurement is requested
1305 * @snr: pointer to where the SNR should be returned
1306 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301307 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301309QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310{
1311 struct statsContext context;
1312 hdd_context_t *pHddCtx;
1313 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301314 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 unsigned long rc;
1316 int valid;
1317
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301318 ENTER();
1319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001321 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301322 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 }
1324
1325 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1326
1327 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301328 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301329 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330
1331 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1332
1333 init_completion(&context.completion);
1334 context.pAdapter = pAdapter;
1335 context.magic = SNR_CONTEXT_MAGIC;
1336
1337 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
1338 pHddStaCtx->conn_info.staId[0],
1339 pHddStaCtx->conn_info.bssId, &context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301340 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001341 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 /* we'll returned a cached value below */
1343 } else {
1344 /* request was sent -- wait for the response */
1345 rc = wait_for_completion_timeout(&context.completion,
1346 msecs_to_jiffies
1347 (WLAN_WAIT_TIME_STATS));
1348 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001349 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350 /* we'll now returned a cached value below */
1351 }
1352 }
1353
1354 /* either we never sent a request, we sent a request and
1355 * received a response or we sent a request and timed out. if
1356 * we never sent a request or if we sent a request and got a
1357 * response, we want to clear the magic out of paranoia. if
1358 * we timed out there is a race condition such that the
1359 * callback function could be executing at the same time we
1360 * are. of primary concern is if the callback function had
1361 * already verified the "magic" but had not yet set the
1362 * completion variable when a timeout occurred. we serialize
1363 * these activities by invalidating the magic while holding a
1364 * shared spinlock which will cause us to block if the
1365 * callback is currently executing
1366 */
1367 spin_lock(&hdd_context_lock);
1368 context.magic = 0;
1369 spin_unlock(&hdd_context_lock);
1370
1371 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301372 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301373 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374}
1375
1376/**
1377 * hdd_get_link_speed_cb() - Get link speed callback function
1378 * @pLinkSpeed: pointer to the link speed record
1379 * @pContext: pointer to the user context passed to SME
1380 *
1381 * This function is passed as the callback function to
1382 * sme_get_link_speed() by wlan_hdd_get_linkspeed_for_peermac(). By
1383 * agreement a &struct linkspeedContext is passed as @pContext. If
1384 * the context is valid, then the contents of @pLinkSpeed are copied
1385 * into the adapter record referenced by @pContext where they can be
1386 * subsequently retrieved. If the context is invalid, then this
1387 * function does nothing since it is assumed the caller has already
1388 * timed-out and destroyed the context.
1389 *
1390 * Return: None.
1391 */
1392static void
1393hdd_get_link_speed_cb(tSirLinkSpeedInfo *pLinkSpeed, void *pContext)
1394{
1395 struct linkspeedContext *pLinkSpeedContext;
1396 hdd_adapter_t *pAdapter;
1397
1398 if ((NULL == pLinkSpeed) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001399 hdd_err("Bad param, pLinkSpeed [%p] pContext [%p]",
1400 pLinkSpeed, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 return;
1402 }
1403 spin_lock(&hdd_context_lock);
1404 pLinkSpeedContext = pContext;
1405 pAdapter = pLinkSpeedContext->pAdapter;
1406
1407 /* there is a race condition that exists between this callback
1408 * function and the caller since the caller could time out either
1409 * before or while this code is executing. we use a spinlock to
1410 * serialize these actions
1411 */
1412
1413 if ((NULL == pAdapter) ||
1414 (LINK_CONTEXT_MAGIC != pLinkSpeedContext->magic)) {
1415 /* the caller presumably timed out so there is nothing
1416 * we can do
1417 */
1418 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07001419 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1420 pAdapter, pLinkSpeedContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421 if (ioctl_debug) {
1422 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1423 __func__, pAdapter, pLinkSpeedContext->magic);
1424 }
1425 return;
1426 }
1427
1428 /* context is valid so caller is still waiting */
1429
1430 /* paranoia: invalidate the magic */
1431 pLinkSpeedContext->magic = 0;
1432
1433 /* copy over the stats. do so as a struct copy */
1434 pAdapter->ls_stats = *pLinkSpeed;
1435
1436 /* notify the caller */
1437 complete(&pLinkSpeedContext->completion);
1438
1439 /* serialization is complete */
1440 spin_unlock(&hdd_context_lock);
1441}
1442
1443/**
1444 * wlan_hdd_get_linkspeed_for_peermac() - Get link speed for a peer
1445 * @pAdapter: adapter upon which the peer is active
1446 * @macAddress: MAC address of the peer
1447 *
1448 * This function will send a query to SME for the linkspeed of the
1449 * given peer, and then wait for the callback to be invoked.
1450 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301451 * Return: QDF_STATUS_SUCCESS if linkspeed data is available,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301452 * otherwise a QDF_STATUS_E_** error.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301454QDF_STATUS wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301455 struct qdf_mac_addr macAddress) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301456 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 unsigned long rc;
1458 struct linkspeedContext context;
1459 tSirLinkSpeedInfo *linkspeed_req;
1460
1461 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001462 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301463 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301465 linkspeed_req = qdf_mem_malloc(sizeof(*linkspeed_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466 if (NULL == linkspeed_req) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001467 hdd_err("Request Buffer Alloc Fail");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301468 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 }
1470 init_completion(&context.completion);
1471 context.pAdapter = pAdapter;
1472 context.magic = LINK_CONTEXT_MAGIC;
1473
Anurag Chouhanc5548422016-02-24 18:33:27 +05301474 qdf_copy_macaddr(&linkspeed_req->peer_macaddr, &macAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(pAdapter),
1476 linkspeed_req,
1477 &context, hdd_get_link_speed_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301478 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001479 hdd_err("Unable to retrieve statistics for link speed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301480 qdf_mem_free(linkspeed_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001481 } else {
1482 rc = wait_for_completion_timeout
1483 (&context.completion,
1484 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
1485 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001486 hdd_err("SME timed out while retrieving link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 }
1488 }
1489
1490 /* either we never sent a request, we sent a request and
1491 * received a response or we sent a request and timed out. if
1492 * we never sent a request or if we sent a request and got a
1493 * response, we want to clear the magic out of paranoia. if
1494 * we timed out there is a race condition such that the
1495 * callback function could be executing at the same time we
1496 * are. of primary concern is if the callback function had
1497 * already verified the "magic" but had not yet set the
1498 * completion variable when a timeout occurred. we serialize
1499 * these activities by invalidating the magic while holding a
1500 * shared spinlock which will cause us to block if the
1501 * callback is currently executing
1502 */
1503 spin_lock(&hdd_context_lock);
1504 context.magic = 0;
1505 spin_unlock(&hdd_context_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301506 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507}
1508
1509/**
1510 * wlan_hdd_get_link_speed() - get link speed
1511 * @pAdapter: pointer to the adapter
1512 * @link_speed: pointer to link speed
1513 *
1514 * This function fetches per bssid link speed.
1515 *
1516 * Return: if associated, link speed shall be returned.
1517 * if not associated, link speed of 0 is returned.
1518 * On error, error number will be returned.
1519 */
1520int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
1521{
1522 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
1523 hdd_station_ctx_t *hdd_stactx =
1524 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
1525 int ret;
1526
1527 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301528 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05301531 /* Linkspeed is allowed only for P2P mode */
1532 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
1533 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
1534 hdd_device_mode_to_string(sta_adapter->device_mode),
1535 sta_adapter->device_mode);
1536 return -ENOTSUPP;
1537 }
1538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
1540 /* we are not connected so we don't have a classAstats */
1541 *link_speed = 0;
1542 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301543 QDF_STATUS status;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301544 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545
Anurag Chouhanc5548422016-02-24 18:33:27 +05301546 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547
1548 status = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301549 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001550 hdd_err("Unable to retrieve SME linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 return -EINVAL;
1552 }
1553 *link_speed = sta_adapter->ls_stats.estLinkSpeed;
1554 /* linkspeed in units of 500 kbps */
1555 *link_speed = (*link_speed) / 500;
1556 }
1557 return 0;
1558}
1559
1560/**
1561 * hdd_statistics_cb() - "Get statistics" callback function
1562 * @pStats: statistics payload
1563 * @pContext: opaque context originally passed to SME. HDD always passes
1564 * a pointer to an adapter
1565 *
1566 * Return: None
1567 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001568static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569{
1570 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
1571 hdd_stats_t *pStatsCache = NULL;
1572 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05301573 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574
1575 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1576 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1577 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1578 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1579 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1580 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1581
1582 if (pAdapter != NULL)
1583 pStatsCache = &pAdapter->hdd_stats;
1584
1585 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
1586 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
1587 pClassBStats = (tCsrGlobalClassBStatsInfo *) (pClassAStats + 1);
1588 pClassCStats = (tCsrGlobalClassCStatsInfo *) (pClassBStats + 1);
1589 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassCStats + 1);
1590 pPerStaStats = (tCsrPerStaStatsInfo *) (pClassDStats + 1);
1591
1592 if (pStatsCache != NULL) {
1593 /* copy the stats into the cache we keep in the
1594 * adapter instance structure
1595 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301596 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301598 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301600 qdf_mem_copy(&pStatsCache->ClassB_stat, pClassBStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601 sizeof(pStatsCache->ClassB_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301602 qdf_mem_copy(&pStatsCache->ClassC_stat, pClassCStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 sizeof(pStatsCache->ClassC_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301604 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 sizeof(pStatsCache->ClassD_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301606 qdf_mem_copy(&pStatsCache->perStaStats, pPerStaStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 sizeof(pStatsCache->perStaStats));
1608 }
1609
1610 if (pAdapter) {
1611 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301612 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05301613 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001614 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 return;
1616 }
1617 }
1618}
1619
1620/**
1621 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
1622 * @pAdapter: adapter who's IEs are to be cleared
1623 *
1624 * Return: None
1625 */
1626void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
1627{
1628 int i = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001629 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07001630
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001631 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632
1633 /* clear WPA/RSN/WSC IE information in the profile */
1634 pWextState->roamProfile.nWPAReqIELength = 0;
1635 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
1636 pWextState->roamProfile.nRSNReqIELength = 0;
1637 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
1638
1639#ifdef FEATURE_WLAN_WAPI
1640 pWextState->roamProfile.nWAPIReqIELength = 0;
1641 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
1642#endif
1643
1644 pWextState->roamProfile.bWPSAssociation = false;
1645 pWextState->roamProfile.bOSENAssociation = false;
1646 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
1647 pWextState->roamProfile.nAddIEScanLength = 0;
1648 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
1649 pWextState->roamProfile.nAddIEAssocLength = 0;
1650
1651 pWextState->roamProfile.EncryptionType.numEntries = 1;
1652 pWextState->roamProfile.EncryptionType.encryptionType[0]
1653 = eCSR_ENCRYPT_TYPE_NONE;
1654
1655 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1656 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1657 = eCSR_ENCRYPT_TYPE_NONE;
1658
1659 pWextState->roamProfile.AuthType.numEntries = 1;
1660 pWextState->roamProfile.AuthType.authType[0] =
1661 eCSR_AUTH_TYPE_OPEN_SYSTEM;
1662
1663#ifdef WLAN_FEATURE_11W
1664 pWextState->roamProfile.MFPEnabled = false;
1665 pWextState->roamProfile.MFPRequired = 0;
1666 pWextState->roamProfile.MFPCapable = 0;
1667#endif
1668
1669 pWextState->authKeyMgmt = 0;
1670
1671 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
1672 if (pWextState->roamProfile.Keys.KeyMaterial[i]) {
1673 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1674 }
1675 }
1676#ifdef FEATURE_WLAN_WAPI
1677 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1678 pAdapter->wapi_info.nWapiMode = 0;
1679#endif
1680
Anurag Chouhanc5548422016-02-24 18:33:27 +05301681 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001682 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683}
1684
1685/**
1686 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
1687 * @oui: The OUI that is being searched for
1688 * @oui_size: The length of @oui
1689 * @ie: The set of IEs within which we're trying to find @oui
1690 * @ie_len: The length of @ie
1691 *
1692 * This function will scan the IEs contained within @ie looking for @oui.
1693 *
1694 * Return: Pointer to @oui embedded within @ie if it is present, NULL
1695 * if @oui is not present within @ie.
1696 */
1697uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
1698 uint8_t *ie, int ie_len)
1699{
1700 int left = ie_len;
1701 uint8_t *ptr = ie;
1702 uint8_t elem_id, elem_len;
1703 uint8_t eid = 0xDD;
1704
1705 if (NULL == ie || 0 == ie_len)
1706 return NULL;
1707
1708 while (left >= 2) {
1709 elem_id = ptr[0];
1710 elem_len = ptr[1];
1711 left -= 2;
1712 if (elem_len > left) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001713 hdd_alert("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 eid, elem_len, left);
1715 return NULL;
1716 }
1717 if (elem_id == eid) {
1718 if (memcmp(&ptr[2], oui, oui_size) == 0)
1719 return ptr;
1720 }
1721
1722 left -= elem_len;
1723 ptr += (elem_len + 2);
1724 }
1725 return NULL;
1726}
1727
1728/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05301729 * hdd_get_ldpc() - Get adapter LDPC
1730 * @adapter: adapter being queried
1731 * @value: where to store the value
1732 *
1733 * Return: 0 on success, negative errno on failure
1734 */
1735int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
1736{
1737 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1738 int ret;
1739
1740 ENTER();
1741 ret = sme_get_ht_config(hal, adapter->sessionId,
1742 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
1743 if (ret < 0) {
1744 hdd_alert("Failed to get LDPC value");
1745 } else {
1746 *value = ret;
1747 ret = 0;
1748 }
1749 return ret;
1750}
1751
1752/**
1753 * hdd_set_ldpc() - Set adapter LDPC
1754 * @adapter: adapter being modified
1755 * @value: new LDPC value
1756 *
1757 * Return: 0 on success, negative errno on failure
1758 */
1759int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
1760{
1761 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1762 int ret;
1763
1764 hdd_alert("%d", value);
1765 if (value) {
1766 /* make sure HT capabilities allow this */
1767 QDF_STATUS status;
1768 uint32_t cfg_value;
1769 union {
1770 uint16_t cfg_value16;
1771 tSirMacHTCapabilityInfo ht_cap_info;
1772 } u;
1773
1774 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1775 if (QDF_STATUS_SUCCESS != status) {
1776 hdd_alert("Failed to get HT capability info");
1777 return -EIO;
1778 }
1779 u.cfg_value16 = cfg_value & 0xFFFF;
1780 if (!u.ht_cap_info.advCodingCap) {
1781 hdd_alert("LDCP not supported");
1782 return -EINVAL;
1783 }
1784 }
1785
1786 ret = sme_update_ht_config(hal, adapter->sessionId,
1787 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
1788 value);
1789 if (ret)
1790 hdd_alert("Failed to set LDPC value");
1791
1792 return ret;
1793}
1794
1795/**
1796 * hdd_get_tx_stbc() - Get adapter TX STBC
1797 * @adapter: adapter being queried
1798 * @value: where to store the value
1799 *
1800 * Return: 0 on success, negative errno on failure
1801 */
1802int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
1803{
1804 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1805 int ret;
1806
1807 ENTER();
1808 ret = sme_get_ht_config(hal, adapter->sessionId,
1809 WNI_CFG_HT_CAP_INFO_TX_STBC);
1810 if (ret < 0) {
1811 hdd_alert("Failed to get TX STBC value");
1812 } else {
1813 *value = ret;
1814 ret = 0;
1815 }
1816
1817 return ret;
1818}
1819
1820/**
1821 * hdd_set_tx_stbc() - Set adapter TX STBC
1822 * @adapter: adapter being modified
1823 * @value: new TX STBC value
1824 *
1825 * Return: 0 on success, negative errno on failure
1826 */
1827int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
1828{
1829 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1830 int ret;
1831
1832 hdd_alert("%d", value);
1833 if (value) {
1834 /* make sure HT capabilities allow this */
1835 QDF_STATUS status;
1836 uint32_t cfg_value;
1837 union {
1838 uint16_t cfg_value16;
1839 tSirMacHTCapabilityInfo ht_cap_info;
1840 } u;
1841
1842 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1843 if (QDF_STATUS_SUCCESS != status) {
1844 hdd_alert("Failed to get HT capability info");
1845 return -EIO;
1846 }
1847 u.cfg_value16 = cfg_value & 0xFFFF;
1848 if (!u.ht_cap_info.txSTBC) {
1849 hdd_alert("TX STBC not supported");
1850 return -EINVAL;
1851 }
1852 }
1853 ret = sme_update_ht_config(hal, adapter->sessionId,
1854 WNI_CFG_HT_CAP_INFO_TX_STBC,
1855 value);
1856 if (ret)
1857 hdd_alert("Failed to set TX STBC value");
1858
1859 return ret;
1860}
1861
1862/**
1863 * hdd_get_rx_stbc() - Get adapter RX STBC
1864 * @adapter: adapter being queried
1865 * @value: where to store the value
1866 *
1867 * Return: 0 on success, negative errno on failure
1868 */
1869int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
1870{
1871 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1872 int ret;
1873
1874 ENTER();
1875 ret = sme_get_ht_config(hal, adapter->sessionId,
1876 WNI_CFG_HT_CAP_INFO_RX_STBC);
1877 if (ret < 0) {
1878 hdd_alert("Failed to get RX STBC value");
1879 } else {
1880 *value = ret;
1881 ret = 0;
1882 }
1883
1884 return ret;
1885}
1886
1887/**
1888 * hdd_set_rx_stbc() - Set adapter RX STBC
1889 * @adapter: adapter being modified
1890 * @value: new RX STBC value
1891 *
1892 * Return: 0 on success, negative errno on failure
1893 */
1894int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
1895{
1896 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1897 int ret;
1898
1899 hdd_alert("%d", value);
1900 if (value) {
1901 /* make sure HT capabilities allow this */
1902 QDF_STATUS status;
1903 uint32_t cfg_value;
1904 union {
1905 uint16_t cfg_value16;
1906 tSirMacHTCapabilityInfo ht_cap_info;
1907 } u;
1908
1909 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1910 if (QDF_STATUS_SUCCESS != status) {
1911 hdd_alert("Failed to get HT capability info");
1912 return -EIO;
1913 }
1914 u.cfg_value16 = cfg_value & 0xFFFF;
1915 if (!u.ht_cap_info.rxSTBC) {
1916 hdd_alert("RX STBC not supported");
1917 return -EINVAL;
1918 }
1919 }
1920 ret = sme_update_ht_config(hal, adapter->sessionId,
1921 WNI_CFG_HT_CAP_INFO_RX_STBC,
1922 value);
1923 if (ret)
1924 hdd_alert("Failed to set RX STBC value");
1925
1926 return ret;
1927}
1928
1929/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
1931 * @dev: device upon which the ioctl was received
1932 * @info: ioctl request information
1933 * @wrqu: ioctl request data
1934 * @extra: ioctl extra data
1935 *
1936 * Return: 0 on success, non-zero on error
1937 */
1938static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1939 union iwreq_data *wrqu, char *extra)
1940{
1941 hdd_adapter_t *adapter;
1942 hdd_context_t *hdd_ctx;
1943 int ret;
1944
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08001945 ENTER_DEV(dev);
1946
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1948 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1949 ret = wlan_hdd_validate_context(hdd_ctx);
1950 if (0 != ret)
1951 return ret;
1952
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 /* Do nothing for now */
1954 return 0;
1955}
1956
1957/**
1958 * iw_set_commit() - SSR wrapper function for __iw_set_commit
1959 * @dev: pointer to net_device
1960 * @info: pointer to iw_request_info
1961 * @wrqu: pointer to iwreq_data
1962 * @extra: extra
1963 *
1964 * Return: 0 on success, error number otherwise
1965 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001966static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967 union iwreq_data *wrqu, char *extra)
1968{
1969 int ret;
1970
1971 cds_ssr_protect(__func__);
1972 ret = __iw_set_commit(dev, info, wrqu, extra);
1973 cds_ssr_unprotect(__func__);
1974
1975 return ret;
1976}
1977
1978/**
1979 * __iw_get_name() - SIOCGIWNAME ioctl handler
1980 * @dev: device upon which the ioctl was received
1981 * @info: ioctl request information
1982 * @wrqu: ioctl request data
1983 * @extra: ioctl extra data
1984 *
1985 * Return: 0 on success, non-zero on error
1986 */
1987static int __iw_get_name(struct net_device *dev,
1988 struct iw_request_info *info, char *wrqu, char *extra)
1989{
1990 hdd_adapter_t *adapter;
1991 hdd_context_t *hdd_ctx;
1992 int ret;
1993
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08001994 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995
1996 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1997 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1998 ret = wlan_hdd_validate_context(hdd_ctx);
1999 if (0 != ret)
2000 return ret;
2001
2002 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
2003 EXIT();
2004 return 0;
2005}
2006
2007/**
2008 * __iw_get_name() - SSR wrapper for __iw_get_name
2009 * @dev: pointer to net_device
2010 * @info: pointer to iw_request_info
2011 * @wrqu: pointer to iwreq_data
2012 * @extra: extra
2013 *
2014 * Return: 0 on success, error number otherwise
2015 */
2016static int iw_get_name(struct net_device *dev,
2017 struct iw_request_info *info,
2018 char *wrqu, char *extra)
2019{
2020 int ret;
2021
2022 cds_ssr_protect(__func__);
2023 ret = __iw_get_name(dev, info, wrqu, extra);
2024 cds_ssr_unprotect(__func__);
2025
2026 return ret;
2027}
2028
2029/**
2030 * __iw_set_mode() - ioctl handler
2031 * @dev: device upon which the ioctl was received
2032 * @info: ioctl request information
2033 * @wrqu: ioctl request data
2034 * @extra: ioctl extra data
2035 *
2036 * Return: 0 on success, non-zero on error
2037 */
2038static int __iw_set_mode(struct net_device *dev,
2039 struct iw_request_info *info,
2040 union iwreq_data *wrqu, char *extra)
2041{
2042 hdd_wext_state_t *pWextState;
2043 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2044 hdd_context_t *hdd_ctx;
2045 tCsrRoamProfile *pRoamProfile;
2046 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 struct hdd_config *pConfig;
2048 struct wireless_dev *wdev;
2049 int ret;
2050
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002051 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052
2053 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2054 ret = wlan_hdd_validate_context(hdd_ctx);
2055 if (0 != ret)
2056 return ret;
2057
2058 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2059 wdev = dev->ieee80211_ptr;
2060 pRoamProfile = &pWextState->roamProfile;
2061 LastBSSType = pRoamProfile->BSSType;
2062
Jeff Johnson99bac312016-06-28 10:38:18 -07002063 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064
2065 switch (wrqu->mode) {
2066 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07002067 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2069 /* Set the phymode correctly for IBSS. */
2070 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
2071 pWextState->roamProfile.phyMode =
2072 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08002073 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 wdev->iftype = NL80211_IFTYPE_ADHOC;
2075 break;
2076 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07002077 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2079 wdev->iftype = NL80211_IFTYPE_STATION;
2080 break;
2081 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07002082 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
2084 break;
2085 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002086 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 return -EOPNOTSUPP;
2088 }
2089
2090 if (LastBSSType != pRoamProfile->BSSType) {
2091 /* the BSS mode changed. We need to issue disconnect
2092 * if connected or in IBSS disconnect state
2093 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07002094 if (hdd_conn_is_connected
2095 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302097 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 /* need to issue a disconnect to CSR. */
2099 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302100 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
2102 pAdapter->sessionId,
2103 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302104 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 unsigned long rc;
2106 rc = wait_for_completion_timeout(&pAdapter->
2107 disconnect_comp_var,
2108 msecs_to_jiffies
2109 (WLAN_WAIT_TIME_DISCONNECT));
2110 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07002111 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 }
2113 }
2114 }
2115
2116 EXIT();
2117 return 0;
2118}
2119
2120/**
2121 * iw_set_mode() - SSR wrapper for __iw_set_mode()
2122 * @dev: pointer to net_device
2123 * @info: pointer to iw_request_info
2124 * @wrqu: pointer to iwreq_data
2125 * @extra: pointer to extra ioctl payload
2126 *
2127 * Return: 0 on success, error number otherwise
2128 */
2129static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
2130 union iwreq_data *wrqu, char *extra)
2131{
2132 int ret;
2133
2134 cds_ssr_protect(__func__);
2135 ret = __iw_set_mode(dev, info, wrqu, extra);
2136 cds_ssr_unprotect(__func__);
2137
2138 return ret;
2139}
2140
2141/**
2142 * __iw_get_mode() - SIOCGIWMODE ioctl handler
2143 * @dev: device upon which the ioctl was received
2144 * @info: ioctl request information
2145 * @wrqu: ioctl request data
2146 * @extra: ioctl extra data
2147 *
2148 * Return: 0 on success, non-zero on error
2149 */
2150static int
2151__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2152 union iwreq_data *wrqu, char *extra)
2153{
2154 hdd_wext_state_t *pWextState;
2155 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2156 hdd_context_t *hdd_ctx;
2157 int ret;
2158
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002159 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160
2161 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2162 ret = wlan_hdd_validate_context(hdd_ctx);
2163 if (0 != ret)
2164 return ret;
2165
2166 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2167
2168 switch (pWextState->roamProfile.BSSType) {
2169 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07002170 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171 wrqu->mode = IW_MODE_INFRA;
2172 break;
2173 case eCSR_BSS_TYPE_IBSS:
2174 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07002175 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 wrqu->mode = IW_MODE_ADHOC;
2177 break;
2178 case eCSR_BSS_TYPE_ANY:
2179 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002180 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 wrqu->mode = IW_MODE_AUTO;
2182 break;
2183 }
2184
2185 EXIT();
2186 return 0;
2187}
2188
2189/**
2190 * iw_get_mode() - SSR wrapper for __iw_get_mode()
2191 * @dev: pointer to net_device
2192 * @info: pointer to iw_request_info
2193 * @wrqu: pointer to iwreq_data
2194 * @extra: pointer to extra ioctl payload
2195 *
2196 * Return: 0 on success, error number otherwise
2197 */
2198static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2199 union iwreq_data *wrqu, char *extra)
2200{
2201 int ret;
2202
2203 cds_ssr_protect(__func__);
2204 ret = __iw_get_mode(dev, info, wrqu, extra);
2205 cds_ssr_unprotect(__func__);
2206
2207 return ret;
2208}
2209
2210/**
2211 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
2212 * @dev: device upon which the ioctl was received
2213 * @info: ioctl request information
2214 * @wrqu: ioctl request data
2215 * @extra: ioctl extra data
2216 *
2217 * Return: 0 on success, non-zero on error
2218 */
2219static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2220 union iwreq_data *wrqu, char *extra)
2221{
2222 uint32_t numChans = 0;
2223 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2224 uint32_t indx = 0;
2225 int ret;
2226 hdd_wext_state_t *pWextState;
2227 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2228 hdd_context_t *hdd_ctx;
2229 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2230 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2231 tCsrRoamProfile *pRoamProfile;
2232
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002233 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234
2235 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2236 ret = wlan_hdd_validate_context(hdd_ctx);
2237 if (0 != ret)
2238 return ret;
2239
2240 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2241
2242 pRoamProfile = &pWextState->roamProfile;
2243
Jeff Johnson99bac312016-06-28 10:38:18 -07002244 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245
2246 /* Link is up then return cant set channel */
2247 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
2248 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002249 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 return -EOPNOTSUPP;
2251 }
2252
2253 /* Settings by Frequency as input */
2254 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
2255 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
2256 uint32_t freq = wrqu->freq.m / 100000;
2257
2258 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
2259 && (freq != freq_chan_map[indx].freq))
2260 indx++;
2261 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
2262 return -EINVAL;
2263 }
2264 wrqu->freq.e = 0;
2265 wrqu->freq.m = freq_chan_map[indx].chan;
2266
2267 }
2268
2269 if (wrqu->freq.e == 0) {
2270 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2271 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002272 hdd_notice("Channel %d is outside valid range from %d to %d",
2273 wrqu->freq.m,
2274 WNI_CFG_CURRENT_CHANNEL_STAMIN,
2275 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 return -EINVAL;
2277 }
2278
2279 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2280
2281 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2282 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302283 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002284 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002285 return -EIO;
2286 }
2287
2288 for (indx = 0; indx < numChans; indx++) {
2289 if (wrqu->freq.m == validChan[indx]) {
2290 break;
2291 }
2292 }
2293 } else {
2294
2295 return -EINVAL;
2296 }
2297
2298 if (indx >= numChans) {
2299 return -EINVAL;
2300 }
2301
2302 /* Set the Operational Channel */
2303 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2304 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2305 pRoamProfile->ChannelInfo.ChannelList =
2306 &pHddStaCtx->conn_info.operationChannel;
2307
Jeff Johnson99bac312016-06-28 10:38:18 -07002308 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309
2310 EXIT();
2311
2312 return ret;
2313}
2314
2315/**
2316 * iw_set_freq() - SSR wrapper for __iw_set_freq()
2317 * @dev: pointer to net_device
2318 * @info: pointer to iw_request_info
2319 * @wrqu: pointer to iwreq_data
2320 * @extra: pointer to extra ioctl payload
2321 *
2322 * Return: 0 on success, error number otherwise
2323 */
2324static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2325 union iwreq_data *wrqu, char *extra)
2326{
2327 int ret;
2328
2329 cds_ssr_protect(__func__);
2330 ret = __iw_set_freq(dev, info, wrqu, extra);
2331 cds_ssr_unprotect(__func__);
2332
2333 return ret;
2334}
2335
2336/**
2337 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
2338 * @dev: device upon which the ioctl was received
2339 * @info: ioctl request information
2340 * @wrqu: ioctl request data
2341 * @extra: ioctl extra data
2342 *
2343 * Return: 0 on success, non-zero on error
2344 */
2345static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2346 struct iw_freq *fwrq, char *extra)
2347{
2348 uint32_t status = false, channel = 0, freq = 0;
2349 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2350 tHalHandle hHal;
2351 hdd_wext_state_t *pWextState;
2352 tCsrRoamProfile *pRoamProfile;
2353 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2354 hdd_context_t *hdd_ctx;
2355 int ret;
2356
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002357 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358
2359 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2360 ret = wlan_hdd_validate_context(hdd_ctx);
2361 if (0 != ret)
2362 return ret;
2363
2364 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2365 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2366
2367 pRoamProfile = &pWextState->roamProfile;
2368
2369 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
2370 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302371 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002372 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373 pAdapter->sessionId);
2374 return -EIO;
2375 } else {
2376 status = hdd_wlan_get_freq(channel, &freq);
2377 if (true == status) {
2378 /* Set Exponent parameter as 6 (MHZ)
2379 * in struct iw_freq iwlist & iwconfig
2380 * command shows frequency into proper
2381 * format (2.412 GHz instead of 246.2
2382 * MHz)
2383 */
2384 fwrq->m = freq;
2385 fwrq->e = MHZ;
2386 }
2387 }
2388 } else {
2389 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2390 * iwlist & iwconfig command shows frequency into proper
2391 * format (2.412 GHz instead of 246.2 MHz)
2392 */
2393 fwrq->m = 0;
2394 fwrq->e = MHZ;
2395 }
2396 return 0;
2397}
2398
2399/**
2400 * iw_get_freq() - SSR wrapper for __iw_get_freq()
2401 * @dev: pointer to net_device
2402 * @info: pointer to iw_request_info
2403 * @fwrq: pointer to frequency data
2404 * @extra: pointer to extra ioctl payload
2405 *
2406 * Return: 0 on success, error number otherwise
2407 */
2408static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2409 struct iw_freq *fwrq, char *extra)
2410{
2411 int ret;
2412
2413 cds_ssr_protect(__func__);
2414 ret = __iw_get_freq(dev, info, fwrq, extra);
2415 cds_ssr_unprotect(__func__);
2416
2417 return ret;
2418}
2419
2420/**
2421 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
2422 * @dev: device upon which the ioctl was received
2423 * @info: ioctl request information
2424 * @wrqu: ioctl request data
2425 * @extra: ioctl extra data
2426 *
2427 * Return: 0 on success, non-zero on error
2428 */
2429static int __iw_get_tx_power(struct net_device *dev,
2430 struct iw_request_info *info,
2431 union iwreq_data *wrqu, char *extra)
2432{
2433
2434 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2435 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2436 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2437 int ret;
2438
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002439 ENTER_DEV(dev);
2440
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 ret = wlan_hdd_validate_context(hdd_ctx);
2442 if (0 != ret)
2443 return ret;
2444
2445 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2446 wrqu->txpower.value = 0;
2447 return 0;
2448 }
2449 wlan_hdd_get_class_astats(pAdapter);
2450 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2451
2452 return 0;
2453}
2454
2455/**
2456 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
2457 * @dev: pointer to net_device
2458 * @info: pointer to iw_request_info
2459 * @wrqu: pointer to iwreq_data
2460 * @extra: pointer to extra ioctl payload
2461 *
2462 * Return: 0 on success, error number otherwise
2463 */
2464static int iw_get_tx_power(struct net_device *dev,
2465 struct iw_request_info *info,
2466 union iwreq_data *wrqu, char *extra)
2467{
2468 int ret;
2469
2470 cds_ssr_protect(__func__);
2471 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2472 cds_ssr_unprotect(__func__);
2473
2474 return ret;
2475}
2476
2477/**
2478 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
2479 * @dev: device upon which the ioctl was received
2480 * @info: ioctl request information
2481 * @wrqu: ioctl request data
2482 * @extra: ioctl extra data
2483 *
2484 * Return: 0 on success, non-zero on error
2485 */
2486static int __iw_set_tx_power(struct net_device *dev,
2487 struct iw_request_info *info,
2488 union iwreq_data *wrqu, char *extra)
2489{
2490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2491 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2492 hdd_context_t *hdd_ctx;
2493 int ret;
2494
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002495 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496
2497 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2498 ret = wlan_hdd_validate_context(hdd_ctx);
2499 if (0 != ret)
2500 return ret;
2501
2502 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302503 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002504 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 return -EIO;
2506 }
2507
2508 EXIT();
2509
2510 return 0;
2511}
2512
2513/**
2514 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
2515 * @dev: pointer to net_device
2516 * @info: pointer to iw_request_info
2517 * @wrqu: pointer to iwreq_data
2518 * @extra: pointer to extra ioctl payload
2519 *
2520 * Return: 0 on success, error number otherwise
2521 */
2522static int iw_set_tx_power(struct net_device *dev,
2523 struct iw_request_info *info,
2524 union iwreq_data *wrqu, char *extra)
2525{
2526 int ret;
2527
2528 cds_ssr_protect(__func__);
2529 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2530 cds_ssr_unprotect(__func__);
2531
2532 return ret;
2533}
2534
2535/**
2536 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
2537 * @dev: device upon which the ioctl was received
2538 * @info: ioctl request information
2539 * @wrqu: ioctl request data
2540 * @extra: ioctl extra data
2541 *
2542 * Return: 0 on success, non-zero on error
2543 */
2544static int __iw_get_bitrate(struct net_device *dev,
2545 struct iw_request_info *info,
2546 union iwreq_data *wrqu, char *extra)
2547{
Anurag Chouhance0dc992016-02-16 18:18:03 +05302548 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302549 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 hdd_wext_state_t *pWextState;
2551 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2552 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2553 hdd_context_t *hdd_ctx;
2554 int ret;
2555
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002556 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557
2558 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2559 ret = wlan_hdd_validate_context(hdd_ctx);
2560 if (0 != ret)
2561 return ret;
2562
Prashanth Bhatta9e143052015-12-04 11:56:47 -08002563 if (cds_is_driver_recovering()) {
2564 hdd_alert("Recovery in Progress. State: 0x%x Ignore!!!",
2565 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002566 return status;
2567 }
2568
2569 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2570 wrqu->bitrate.value = 0;
2571 } else {
2572 status =
2573 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2574 eCSR_HDD,
2575 SME_SUMMARY_STATS |
2576 SME_GLOBAL_CLASSA_STATS |
2577 SME_GLOBAL_CLASSB_STATS |
2578 SME_GLOBAL_CLASSC_STATS |
2579 SME_GLOBAL_CLASSD_STATS |
2580 SME_PER_STA_STATS,
2581 hdd_statistics_cb, 0,
2582 false,
2583 pHddStaCtx->conn_info.staId[0],
2584 pAdapter, pAdapter->sessionId);
2585
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302586 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002587 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 return status;
2589 }
2590
2591 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2592
Anurag Chouhance0dc992016-02-16 18:18:03 +05302593 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302594 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 WLAN_WAIT_TIME_STATS);
2596
Anurag Chouhance0dc992016-02-16 18:18:03 +05302597 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002598 hdd_err("SME timeout while retrieving statistics");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302599 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 }
2601
2602 wrqu->bitrate.value =
2603 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
2604 }
2605
2606 EXIT();
2607
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302608 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609}
2610
2611/**
2612 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
2613 * @dev: pointer to net_device
2614 * @info: pointer to iw_request_info
2615 * @wrqu: pointer to iwreq_data
2616 * @extra: pointer to extra ioctl payload
2617 *
2618 * Return: 0 on success, error number otherwise
2619 */
2620static int iw_get_bitrate(struct net_device *dev,
2621 struct iw_request_info *info,
2622 union iwreq_data *wrqu, char *extra)
2623{
2624 int ret;
2625
2626 cds_ssr_protect(__func__);
2627 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2628 cds_ssr_unprotect(__func__);
2629
2630 return ret;
2631}
2632
2633/**
2634 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
2635 * @dev: device upon which the ioctl was received
2636 * @info: ioctl request information
2637 * @wrqu: ioctl request data
2638 * @extra: ioctl extra data
2639 *
2640 * Return: 0 on success, non-zero on error
2641 */
2642static int __iw_set_bitrate(struct net_device *dev,
2643 struct iw_request_info *info,
2644 union iwreq_data *wrqu, char *extra)
2645{
2646 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2647 hdd_wext_state_t *pWextState;
2648 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2649 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2650 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2651 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2652 uint32_t i, rate;
2653 uint32_t valid_rate = false, active_phy_mode = 0;
2654 hdd_context_t *hdd_ctx;
2655 int ret;
2656
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002657 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658
2659 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2660 ret = wlan_hdd_validate_context(hdd_ctx);
2661 if (0 != ret)
2662 return ret;
2663
2664 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2665
2666 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2667 return -ENXIO;
2668 }
2669
2670 rate = wrqu->bitrate.value;
2671
2672 if (rate == -1) {
2673 rate = WNI_CFG_FIXED_RATE_AUTO;
2674 valid_rate = true;
2675 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
2676 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302677 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
2679 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2680 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
2681 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2682 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302683 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 &&
2685 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2686 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302687 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688 for (i = 0; i < (b_len + a_len); ++i) {
2689 /* supported rates returned is double
2690 * the actual rate so we divide it by 2
2691 */
2692 if ((supp_rates[i] & 0x7F) / 2 ==
2693 rate) {
2694 valid_rate = true;
2695 rate = i +
2696 WNI_CFG_FIXED_RATE_1MBPS;
2697 break;
2698 }
2699 }
2700 }
2701 }
2702 }
2703 if (valid_rate != true) {
2704 return -EINVAL;
2705 }
2706 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302707 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002708 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 return -EIO;
2710 }
2711 return 0;
2712}
2713
2714/**
2715 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
2716 * @dev: pointer to net_device
2717 * @info: pointer to iw_request_info
2718 * @wrqu: pointer to iwreq_data
2719 * @extra: pointer to extra ioctl payload
2720 *
2721 * Return: 0 on success, error number otherwise
2722 */
2723static int iw_set_bitrate(struct net_device *dev,
2724 struct iw_request_info *info,
2725 union iwreq_data *wrqu, char *extra)
2726{
2727 int ret;
2728
2729 cds_ssr_protect(__func__);
2730 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2731 cds_ssr_unprotect(__func__);
2732
2733 return ret;
2734}
2735
2736/**
2737 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
2738 * @dev: device upon which the ioctl was received
2739 * @info: ioctl request information
2740 * @wrqu: ioctl request data
2741 * @extra: ioctl extra data
2742 *
2743 * Return: 0 on success, non-zero on error
2744 */
2745static int __iw_set_genie(struct net_device *dev,
2746 struct iw_request_info *info,
2747 union iwreq_data *wrqu, char *extra)
2748{
2749 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2750 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2751 uint8_t *genie = NULL;
2752 uint8_t *base_genie = NULL;
2753 uint16_t remLen;
2754 hdd_context_t *hdd_ctx;
2755 int ret;
2756
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002757 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758
2759 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2760 ret = wlan_hdd_validate_context(hdd_ctx);
2761 if (0 != ret)
2762 return ret;
2763
2764 if (!wrqu->data.length) {
2765 hdd_clear_roam_profile_ie(pAdapter);
2766 EXIT();
2767 return 0;
2768 }
2769
2770 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2771 wrqu->data.length);
2772 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002773 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 return -ENOMEM;
2775 }
2776
2777 genie = base_genie;
2778
2779 remLen = wrqu->data.length;
2780
Jeff Johnson99bac312016-06-28 10:38:18 -07002781 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 genie[1]);
2783
2784 /* clear any previous genIE before this call */
2785 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
2786
2787 while (remLen >= 2) {
2788 uint16_t eLen = 0;
2789 uint8_t elementId;
2790 elementId = *genie++;
2791 eLen = *genie++;
2792 remLen -= 2;
2793
Jeff Johnson99bac312016-06-28 10:38:18 -07002794 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795
2796 switch (elementId) {
2797 case IE_EID_VENDOR:
2798 if ((IE_LEN_SIZE + IE_EID_SIZE + IE_VENDOR_OUI_SIZE) > eLen) { /* should have at least OUI */
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302799 ret = -EINVAL;
2800 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 }
2802
2803 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
2804 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002805 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2806 genie[0], genie[1], genie[2],
2807 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808
2809 if (SIR_MAC_MAX_IE_LENGTH <
2810 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002811 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302812 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302813 ret = -ENOMEM;
2814 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 }
2816 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2817 memcpy(pWextState->genIE.addIEdata +
2818 curGenIELen, genie - 2, eLen + 2);
2819 pWextState->genIE.length += eLen + 2;
2820 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002821 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302822 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2823 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2824 ret = -EINVAL;
2825 QDF_ASSERT(0);
2826 goto exit;
2827 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 memset(pWextState->WPARSNIE, 0,
2829 MAX_WPA_RSN_IE_LEN);
2830 memcpy(pWextState->WPARSNIE, genie - 2,
2831 (eLen + 2));
2832 pWextState->roamProfile.pWPAReqIE =
2833 pWextState->WPARSNIE;
2834 pWextState->roamProfile.nWPAReqIELength =
2835 eLen + 2;
2836 } else { /* any vendorId except WPA IE should be accumulated to genIE */
2837
2838 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002839 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
2840 genie[0], genie[1], genie[2],
2841 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842
2843 if (SIR_MAC_MAX_IE_LENGTH <
2844 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002845 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302846 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302847 ret = -ENOMEM;
2848 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 }
2850 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2851 memcpy(pWextState->genIE.addIEdata +
2852 curGenIELen, genie - 2, eLen + 2);
2853 pWextState->genIE.length += eLen + 2;
2854 }
2855 break;
2856 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07002857 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302858 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2859 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2860 ret = -EINVAL;
2861 QDF_ASSERT(0);
2862 goto exit;
2863 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
2865 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
2866 pWextState->roamProfile.pRSNReqIE =
2867 pWextState->WPARSNIE;
2868 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2869 break;
2870
2871 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002872 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302873 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 }
2875 genie += eLen;
2876 remLen -= eLen;
2877 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302878exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 EXIT();
2880 kfree(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302881 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882}
2883
2884/**
2885 * iw_set_genie() - SSR wrapper for __iw_set_genie()
2886 * @dev: pointer to net_device
2887 * @info: pointer to iw_request_info
2888 * @wrqu: pointer to iwreq_data
2889 * @extra: pointer to extra ioctl payload
2890 *
2891 * Return: 0 on success, error number otherwise
2892 */
2893static int iw_set_genie(struct net_device *dev,
2894 struct iw_request_info *info,
2895 union iwreq_data *wrqu, char *extra)
2896{
2897 int ret;
2898
2899 cds_ssr_protect(__func__);
2900 ret = __iw_set_genie(dev, info, wrqu, extra);
2901 cds_ssr_unprotect(__func__);
2902
2903 return ret;
2904}
2905
2906/**
2907 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
2908 * @dev: device upon which the ioctl was received
2909 * @info: ioctl request information
2910 * @wrqu: ioctl request data
2911 * @extra: ioctl extra data
2912 *
2913 * Return: 0 on success, non-zero on error
2914 */
2915static int __iw_get_genie(struct net_device *dev,
2916 struct iw_request_info *info,
2917 union iwreq_data *wrqu, char *extra)
2918{
2919 hdd_wext_state_t *pWextState;
2920 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2921 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302922 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
2924 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2925 hdd_context_t *hdd_ctx;
2926 int ret;
2927
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002928 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929
2930 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2931 ret = wlan_hdd_validate_context(hdd_ctx);
2932 if (0 != ret)
2933 return ret;
2934
Jeff Johnson99bac312016-06-28 10:38:18 -07002935 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936
2937 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2938
2939 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
2940 return -ENXIO;
2941 }
2942
2943 /* Return something ONLY if we are associated with an RSN or
2944 * WPA network
2945 */
2946 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
2947 return -ENXIO;
2948 }
2949
2950 /* Actually retrieve the RSN IE from CSR. (We previously sent
2951 * it down in the CSR Roam Profile.)
2952 */
2953 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
2954 pAdapter->sessionId,
2955 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05302956 if (QDF_STATUS_SUCCESS != status) {
2957 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 return -EFAULT;
2959 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05302961 if (length > DOT11F_IE_RSN_MAX_LEN) {
2962 hdd_notice("invalid buffer length length:%d", length);
2963 return -E2BIG;
2964 }
2965 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966
Jeff Johnson99bac312016-06-28 10:38:18 -07002967 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 wrqu->data.length);
2969
2970 EXIT();
2971
2972 return 0;
2973}
2974
2975/**
2976 * iw_get_genie() - SSR wrapper for __iw_get_genie()
2977 * @dev: pointer to net_device
2978 * @info: pointer to iw_request_info
2979 * @wrqu: pointer to iwreq_data
2980 * @extra: pointer to extra ioctl payload
2981 *
2982 * Return: 0 on success, error number otherwise
2983 */
2984static int iw_get_genie(struct net_device *dev,
2985 struct iw_request_info *info,
2986 union iwreq_data *wrqu, char *extra)
2987{
2988 int ret;
2989
2990 cds_ssr_protect(__func__);
2991 ret = __iw_get_genie(dev, info, wrqu, extra);
2992 cds_ssr_unprotect(__func__);
2993
2994 return ret;
2995}
2996
2997/**
2998 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
2999 * @dev: device upon which the ioctl was received
3000 * @info: ioctl request information
3001 * @wrqu: ioctl request data
3002 * @extra: ioctl extra data
3003 *
3004 * Return: 0 on success, non-zero on error
3005 */
3006static int __iw_get_encode(struct net_device *dev,
3007 struct iw_request_info *info,
3008 struct iw_point *dwrq, char *extra)
3009{
3010 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3011 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3012 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3013 int keyId;
3014 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3015 int i;
3016 hdd_context_t *hdd_ctx;
3017 int ret;
3018
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003019 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020
3021 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3022 ret = wlan_hdd_validate_context(hdd_ctx);
3023 if (0 != ret)
3024 return ret;
3025
3026 keyId = pRoamProfile->Keys.defaultIndex;
3027
3028 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003029 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 return -EINVAL;
3031 }
3032
3033 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
3034 dwrq->flags |= IW_ENCODE_ENABLED;
3035 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303036 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 pRoamProfile->Keys.KeyLength[keyId]);
3038
3039 dwrq->flags |= (keyId + 1);
3040
3041 } else {
3042 dwrq->flags |= IW_ENCODE_DISABLED;
3043 }
3044
3045 for (i = 0; i < MAX_WEP_KEYS; i++) {
3046 if (pRoamProfile->Keys.KeyMaterial[i] == NULL) {
3047 continue;
3048 } else {
3049 break;
3050 }
3051 }
3052
3053 if (MAX_WEP_KEYS == i) {
3054 dwrq->flags |= IW_ENCODE_NOKEY;
3055 }
3056
3057 authType =
3058 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
3059 conn_info.authType;
3060
3061 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
3062 dwrq->flags |= IW_ENCODE_OPEN;
3063 } else {
3064 dwrq->flags |= IW_ENCODE_RESTRICTED;
3065 }
3066 EXIT();
3067 return 0;
3068}
3069
3070/**
3071 * iw_get_encode() - SSR wrapper for __iw_get_encode()
3072 * @dev: pointer to net_device
3073 * @info: pointer to iw_request_info
3074 * @dwrq: pointer to encoding information
3075 * @extra: pointer to extra ioctl payload
3076 *
3077 * Return: 0 on success, error number otherwise
3078 */
3079static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
3080 struct iw_point *dwrq, char *extra)
3081{
3082 int ret;
3083
3084 cds_ssr_protect(__func__);
3085 ret = __iw_get_encode(dev, info, dwrq, extra);
3086 cds_ssr_unprotect(__func__);
3087
3088 return ret;
3089}
3090
3091/**
3092 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
3093 * @dev: device upon which the ioctl was received
3094 * @info: ioctl request information
3095 * @wrqu: ioctl request data
3096 * @extra: ioctl extra data
3097 *
3098 * Return: 0 on success, non-zero on error
3099 */
3100static int __iw_get_rts_threshold(struct net_device *dev,
3101 struct iw_request_info *info,
3102 union iwreq_data *wrqu, char *extra)
3103{
3104 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3105 uint32_t status = 0;
3106
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003107 ENTER_DEV(dev);
3108
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 status = hdd_wlan_get_rts_threshold(pAdapter, wrqu);
3110
3111 return status;
3112}
3113
3114/**
3115 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
3116 * @dev: device upon which the ioctl was received
3117 * @info: ioctl request information
3118 * @wrqu: ioctl request data
3119 * @extra: ioctl extra data
3120 *
3121 * Return: 0 on success, non-zero on error
3122 */
3123static int __iw_set_rts_threshold(struct net_device *dev,
3124 struct iw_request_info *info,
3125 union iwreq_data *wrqu, char *extra)
3126{
3127 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3128 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3129 hdd_context_t *hdd_ctx;
3130 int ret;
3131
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003132 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133
3134 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3135 ret = wlan_hdd_validate_context(hdd_ctx);
3136 if (0 != ret)
3137 return ret;
3138
3139 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
3140 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
3141 return -EINVAL;
3142 }
3143
3144 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303145 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003146 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 return -EIO;
3148 }
3149
3150 EXIT();
3151
3152 return 0;
3153}
3154
3155/**
3156 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
3157 * @dev: pointer to net_device
3158 * @info: pointer to iw_request_info
3159 * @wrqu: pointer to iwreq_data
3160 * @extra: pointer to extra ioctl payload
3161 *
3162 * Return: 0 on success, error number otherwise
3163 */
3164static int iw_get_rts_threshold(struct net_device *dev,
3165 struct iw_request_info *info,
3166 union iwreq_data *wrqu, char *extra)
3167{
3168 int ret;
3169
3170 cds_ssr_protect(__func__);
3171 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
3172 cds_ssr_unprotect(__func__);
3173
3174 return ret;
3175}
3176
3177/**
3178 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
3179 * @dev: pointer to net_device
3180 * @info: pointer to iw_request_info
3181 * @wrqu: pointer to iwreq_data
3182 * @extra: pointer to extra ioctl payload
3183 *
3184 * Return: 0 on success, error number otherwise
3185 */
3186static int iw_set_rts_threshold(struct net_device *dev,
3187 struct iw_request_info *info,
3188 union iwreq_data *wrqu, char *extra)
3189{
3190 int ret;
3191
3192 cds_ssr_protect(__func__);
3193 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
3194 cds_ssr_unprotect(__func__);
3195
3196 return ret;
3197}
3198
3199/**
3200 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
3201 * @dev: device upon which the ioctl was received
3202 * @info: ioctl request information
3203 * @wrqu: ioctl request data
3204 * @extra: ioctl extra data
3205 *
3206 * Return: 0 on success, non-zero on error
3207 */
3208static int __iw_get_frag_threshold(struct net_device *dev,
3209 struct iw_request_info *info,
3210 union iwreq_data *wrqu, char *extra)
3211{
3212 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3213 uint32_t status = 0;
3214
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003215 ENTER_DEV(dev);
3216
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 status = hdd_wlan_get_frag_threshold(pAdapter, wrqu);
3218
3219 return status;
3220}
3221
3222/**
3223 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
3224 * @dev: pointer to net_device
3225 * @info: pointer to iw_request_info
3226 * @wrqu: pointer to iwreq_data
3227 * @extra: pointer to extra ioctl payload
3228 *
3229 * Return: 0 on success, error number otherwise
3230 */
3231static int iw_get_frag_threshold(struct net_device *dev,
3232 struct iw_request_info *info,
3233 union iwreq_data *wrqu, char *extra)
3234{
3235 int ret;
3236
3237 cds_ssr_protect(__func__);
3238 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3239 cds_ssr_unprotect(__func__);
3240
3241 return ret;
3242}
3243
3244/**
3245 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
3246 * @dev: device upon which the ioctl was received
3247 * @info: ioctl request information
3248 * @wrqu: ioctl request data
3249 * @extra: ioctl extra data
3250 *
3251 * Return: 0 on success, non-zero on error
3252 */
3253static int __iw_set_frag_threshold(struct net_device *dev,
3254 struct iw_request_info *info,
3255 union iwreq_data *wrqu, char *extra)
3256{
3257 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3258 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3259 hdd_context_t *hdd_ctx;
3260 int ret;
3261
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003262 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263
3264 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3265 ret = wlan_hdd_validate_context(hdd_ctx);
3266 if (0 != ret)
3267 return ret;
3268
3269 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
3270 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
3271 return -EINVAL;
3272 }
3273
3274 if (sme_cfg_set_int
3275 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303276 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003277 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 return -EIO;
3279 }
3280
3281 EXIT();
3282
3283 return 0;
3284}
3285
3286/**
3287 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
3288 * @dev: pointer to net_device
3289 * @info: pointer to iw_request_info
3290 * @wrqu: pointer to iwreq_data
3291 * @extra: pointer to extra ioctl payload
3292 *
3293 * Return: 0 on success, error number otherwise
3294 */
3295static int iw_set_frag_threshold(struct net_device *dev,
3296 struct iw_request_info *info,
3297 union iwreq_data *wrqu, char *extra)
3298{
3299 int ret;
3300
3301 cds_ssr_protect(__func__);
3302 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3303 cds_ssr_unprotect(__func__);
3304
3305 return ret;
3306}
3307
3308/**
3309 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
3310 * @dev: device upon which the ioctl was received
3311 * @info: ioctl request information
3312 * @wrqu: ioctl request data
3313 * @extra: ioctl extra data
3314 *
3315 * Return: 0 on success, non-zero on error
3316 */
3317static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003318 struct iw_request_info *info,
3319 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320{
3321 hdd_adapter_t *adapter;
3322 hdd_context_t *hdd_ctx;
3323 int ret;
3324
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003325 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326
3327 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3328 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3329 ret = wlan_hdd_validate_context(hdd_ctx);
3330 if (0 != ret)
3331 return ret;
3332
3333 return -EOPNOTSUPP;
3334}
3335
3336/**
3337 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
3338 * @dev: pointer to net_device
3339 * @info: pointer to iw_request_info
3340 * @wrqu: pointer to iwreq_data
3341 * @extra: extra
3342 *
3343 * Return: 0 on success, error number otherwise
3344 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003345static int iw_get_power_mode(struct net_device *dev,
3346 struct iw_request_info *info,
3347 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348{
3349 int ret;
3350
3351 cds_ssr_protect(__func__);
3352 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3353 cds_ssr_unprotect(__func__);
3354
3355 return ret;
3356}
3357
3358/**
3359 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
3360 * @dev: device upon which the ioctl was received
3361 * @info: ioctl request information
3362 * @wrqu: ioctl request data
3363 * @extra: ioctl extra data
3364 *
3365 * Return: 0 on success, non-zero on error
3366 */
3367static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003368 struct iw_request_info *info,
3369 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370{
3371 hdd_adapter_t *adapter;
3372 hdd_context_t *hdd_ctx;
3373 int ret;
3374
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003375 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376
3377 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3378 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3379 ret = wlan_hdd_validate_context(hdd_ctx);
3380 if (0 != ret)
3381 return ret;
3382
3383 return -EOPNOTSUPP;
3384}
3385
3386/**
3387 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
3388 * @dev: pointer to net_device
3389 * @info: pointer to iw_request_info
3390 * @wrqu: pointer to iwreq_data
3391 * @extra: extra
3392 *
3393 * Return: 0 on success, error number otherwise
3394 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003395static int iw_set_power_mode(struct net_device *dev,
3396 struct iw_request_info *info,
3397 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398{
3399 int ret;
3400
3401 cds_ssr_protect(__func__);
3402 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3403 cds_ssr_unprotect(__func__);
3404
3405 return ret;
3406}
3407
3408/**
3409 * __iw_get_range() - SIOCGIWRANGE ioctl handler
3410 * @dev: device upon which the ioctl was received
3411 * @info: ioctl request information
3412 * @wrqu: ioctl request data
3413 * @extra: ioctl extra data
3414 *
3415 * Return: 0 on success, non-zero on error
3416 */
3417static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
3418 union iwreq_data *wrqu, char *extra)
3419{
3420 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3421 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3422 struct iw_range *range = (struct iw_range *)extra;
3423
3424 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3425
3426 uint32_t num_channels = sizeof(channels);
3427 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3428 uint32_t a_len;
3429 uint32_t b_len;
3430 uint32_t active_phy_mode = 0;
3431 uint8_t index = 0, i;
3432 hdd_context_t *hdd_ctx;
3433 int ret;
3434
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003435 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436
3437 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3438 ret = wlan_hdd_validate_context(hdd_ctx);
3439 if (0 != ret)
3440 return ret;
3441
3442 wrqu->data.length = sizeof(struct iw_range);
3443 memset(range, 0, sizeof(struct iw_range));
3444
3445
3446 /*Get the phy mode */
3447 if (sme_cfg_get_int(hHal,
3448 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303449 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003450 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003451
3452 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
3453 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
3454 /*Get the supported rates for 11G band */
3455 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3456 if (sme_cfg_get_str(hHal,
3457 WNI_CFG_SUPPORTED_RATES_11A,
3458 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303459 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
3461 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3462 }
3463 for (i = 0; i < a_len; i++) {
3464 range->bitrate[i] =
3465 ((supp_rates[i] & 0x7F) / 2) *
3466 1000000;
3467 }
3468 range->num_bitrates = a_len;
3469 } else {
3470 return -EIO;
3471 }
3472 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
3473 /*Get the supported rates for 11B band */
3474 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3475 if (sme_cfg_get_str(hHal,
3476 WNI_CFG_SUPPORTED_RATES_11B,
3477 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303478 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
3480 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3481 }
3482 for (i = 0; i < b_len; i++) {
3483 range->bitrate[i] =
3484 ((supp_rates[i] & 0x7F) / 2) *
3485 1000000;
3486 }
3487 range->num_bitrates = b_len;
3488 } else {
3489 return -EIO;
3490 }
3491 }
3492 }
3493
3494 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3495 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3496 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3497
3498 range->encoding_size[0] = 5;
3499 range->encoding_size[1] = 13;
3500 range->num_encoding_sizes = 2;
3501 range->max_encoding_tokens = MAX_WEP_KEYS;
3502
3503 /* we support through Wireless Extensions 22 */
3504 range->we_version_compiled = WIRELESS_EXT;
3505 range->we_version_source = 22;
3506
3507 /*Supported Channels and Frequencies */
3508 if (sme_cfg_get_str
3509 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303510 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003511 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 return -EIO;
3513 }
3514 if (num_channels > IW_MAX_FREQUENCIES) {
3515 num_channels = IW_MAX_FREQUENCIES;
3516 }
3517
3518 range->num_channels = num_channels;
3519 range->num_frequency = num_channels;
3520
3521 for (index = 0; index < num_channels; index++) {
3522 uint32_t frq_indx = 0;
3523
3524 range->freq[index].i = channels[index];
3525 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
3526 if (channels[index] == freq_chan_map[frq_indx].chan) {
3527 range->freq[index].m =
3528 freq_chan_map[frq_indx].freq * 100000;
3529 range->freq[index].e = 1;
3530 break;
3531 }
3532 frq_indx++;
3533 }
3534 }
3535
3536 /* Event capability (kernel + driver) */
3537 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3538 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3539 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3540 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3541
3542 /*Encryption capability */
3543 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3544 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3545
3546 /* Txpower capability */
3547 range->txpower_capa = IW_TXPOW_MWATT;
3548
3549 /*Scanning capability */
3550#if WIRELESS_EXT >= 22
3551 range->scan_capa =
3552 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3553#endif
3554
3555 EXIT();
3556 return 0;
3557}
3558
3559/**
3560 * iw_get_range() - SSR wrapper for __iw_get_range()
3561 * @dev: pointer to net_device
3562 * @info: pointer to iw_request_info
3563 * @wrqu: pointer to iwreq_data
3564 * @extra: pointer to extra ioctl payload
3565 *
3566 * Return: 0 on success, error number otherwise
3567 */
3568static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
3569 union iwreq_data *wrqu, char *extra)
3570{
3571 int ret;
3572
3573 cds_ssr_protect(__func__);
3574 ret = __iw_get_range(dev, info, wrqu, extra);
3575 cds_ssr_unprotect(__func__);
3576
3577 return ret;
3578}
3579
3580/**
3581 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
3582 * @pStats: pointer to Class A stats
3583 * @pContext: user context originally registered with SME
3584 *
3585 * Return: None
3586 */
3587static void hdd_get_class_a_statistics_cb(void *pStats, void *pContext)
3588{
3589 struct statsContext *pStatsContext;
3590 tCsrGlobalClassAStatsInfo *pClassAStats;
3591 hdd_adapter_t *pAdapter;
3592
3593 if (ioctl_debug) {
3594 pr_info("%s: pStats [%p] pContext [%p]\n",
3595 __func__, pStats, pContext);
3596 }
3597
3598 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003599 hdd_err("Bad param, pStats [%p] pContext [%p]",
3600 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 return;
3602 }
3603
3604 pClassAStats = pStats;
3605 pStatsContext = pContext;
3606 pAdapter = pStatsContext->pAdapter;
3607
3608 /* there is a race condition that exists between this callback
3609 * function and the caller since the caller could time out
3610 * either before or while this code is executing. we use a
3611 * spinlock to serialize these actions
3612 */
3613 spin_lock(&hdd_context_lock);
3614
3615 if ((NULL == pAdapter) ||
3616 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3617 /* the caller presumably timed out so there is nothing
3618 * we can do
3619 */
3620 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003621 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3622 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623 if (ioctl_debug) {
3624 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3625 __func__, pAdapter, pStatsContext->magic);
3626 }
3627 return;
3628 }
3629
3630 /* context is valid so caller is still waiting */
3631
3632 /* paranoia: invalidate the magic */
3633 pStatsContext->magic = 0;
3634
3635 /* copy over the stats. do so as a struct copy */
3636 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3637
3638 /* notify the caller */
3639 complete(&pStatsContext->completion);
3640
3641 /* serialization is complete */
3642 spin_unlock(&hdd_context_lock);
3643}
3644
3645/**
3646 * wlan_hdd_get_class_astats() - Get Class A statistics
3647 * @pAdapter: adapter for which statistics are desired
3648 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303649 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303651QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652{
3653 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303654 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 unsigned long rc;
3656 struct statsContext context;
3657
3658 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003659 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303660 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003662 if (cds_is_driver_recovering()) {
3663 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3664 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303665 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 }
3667
3668 /* we are connected so prepare our callback context */
3669 init_completion(&context.completion);
3670 context.pAdapter = pAdapter;
3671 context.magic = STATS_CONTEXT_MAGIC;
3672 /* query only for Class A statistics (which include link speed) */
3673 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3674 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
3675 hdd_get_class_a_statistics_cb,
3676 0, /* not periodic */
3677 false, /* non-cached results */
3678 pHddStaCtx->conn_info.staId[0],
3679 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303680 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07003681 hdd_warn("Unable to retrieve Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 /* we'll returned a cached value below */
3683 } else {
3684 /* request was sent -- wait for the response */
3685 rc = wait_for_completion_timeout
3686 (&context.completion,
3687 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3688 if (!rc) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07003689 hdd_warn("SME timed out while retrieving Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 }
3691 }
3692
3693 /* either we never sent a request, we sent a request and
3694 * received a response or we sent a request and timed out. if
3695 * we never sent a request or if we sent a request and got a
3696 * response, we want to clear the magic out of paranoia. if
3697 * we timed out there is a race condition such that the
3698 * callback function could be executing at the same time we
3699 * are. of primary concern is if the callback function had
3700 * already verified the "magic" but had not yet set the
3701 * completion variable when a timeout occurred. we serialize
3702 * these activities by invalidating the magic while holding a
3703 * shared spinlock which will cause us to block if the
3704 * callback is currently executing
3705 */
3706 spin_lock(&hdd_context_lock);
3707 context.magic = 0;
3708 spin_unlock(&hdd_context_lock);
3709
3710 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303711 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712}
3713
3714/**
3715 * hdd_get_station_statistics_cb() - Get stats callback function
3716 * @pStats: pointer to Class A stats
3717 * @pContext: user context originally registered with SME
3718 *
3719 * Return: None
3720 */
3721static void hdd_get_station_statistics_cb(void *pStats, void *pContext)
3722{
3723 struct statsContext *pStatsContext;
3724 tCsrSummaryStatsInfo *pSummaryStats;
3725 tCsrGlobalClassAStatsInfo *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303726 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727 hdd_adapter_t *pAdapter;
3728
3729 if (ioctl_debug) {
3730 pr_info("%s: pStats [%p] pContext [%p]\n",
3731 __func__, pStats, pContext);
3732 }
3733
3734 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003735 hdd_err("Bad param, pStats [%p] pContext [%p]",
3736 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 return;
3738 }
3739
3740 /* there is a race condition that exists between this callback
3741 * function and the caller since the caller could time out
3742 * either before or while this code is executing. we use a
3743 * spinlock to serialize these actions
3744 */
3745 spin_lock(&hdd_context_lock);
3746
3747 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3748 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303749 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
3750 (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003751 pStatsContext = pContext;
3752 pAdapter = pStatsContext->pAdapter;
3753 if ((NULL == pAdapter) ||
3754 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3755 /* the caller presumably timed out so there is nothing
3756 * we can do
3757 */
3758 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003759 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3760 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003761 if (ioctl_debug) {
3762 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3763 __func__, pAdapter, pStatsContext->magic);
3764 }
3765 return;
3766 }
3767
3768 /* context is valid so caller is still waiting */
3769
3770 /* paranoia: invalidate the magic */
3771 pStatsContext->magic = 0;
3772
3773 /* copy over the stats. do so as a struct copy */
3774 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3775 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303776 pAdapter->hdd_stats.per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777
3778 /* notify the caller */
3779 complete(&pStatsContext->completion);
3780
3781 /* serialization is complete */
3782 spin_unlock(&hdd_context_lock);
3783}
3784
3785/**
3786 * wlan_hdd_get_station_stats() - Get station statistics
3787 * @pAdapter: adapter for which statistics are desired
3788 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303789 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303791QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792{
3793 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303794 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 unsigned long rc;
3796 struct statsContext context;
3797
3798 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003799 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303800 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 }
3802
3803 /* we are connected so prepare our callback context */
3804 init_completion(&context.completion);
3805 context.pAdapter = pAdapter;
3806 context.magic = STATS_CONTEXT_MAGIC;
3807
3808 /* query only for Summary & Class A statistics */
3809 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3810 eCSR_HDD,
3811 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303812 SME_GLOBAL_CLASSA_STATS |
3813 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814 hdd_get_station_statistics_cb,
3815 0, /* not periodic */
3816 false, /* non-cached results */
3817 pHddStaCtx->conn_info.staId[0],
3818 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303819 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003820 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821 /* we'll return with cached values */
3822 } else {
3823 /* request was sent -- wait for the response */
3824 rc = wait_for_completion_timeout
3825 (&context.completion,
3826 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3827
3828 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003829 hdd_err("SME timed out while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830 }
3831 }
3832
3833 /* either we never sent a request, we sent a request and
3834 * received a response or we sent a request and timed out. if
3835 * we never sent a request or if we sent a request and got a
3836 * response, we want to clear the magic out of paranoia. if
3837 * we timed out there is a race condition such that the
3838 * callback function could be executing at the same time we
3839 * are. of primary concern is if the callback function had
3840 * already verified the "magic" but had not yet set the
3841 * completion variable when a timeout occurred. we serialize
3842 * these activities by invalidating the magic while holding a
3843 * shared spinlock which will cause us to block if the
3844 * callback is currently executing
3845 */
3846 spin_lock(&hdd_context_lock);
3847 context.magic = 0;
3848 spin_unlock(&hdd_context_lock);
3849
3850 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303851 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003852}
3853
3854/**
3855 * iw_get_linkspeed() - Get current link speed ioctl
3856 * @dev: device upon which the ioctl was received
3857 * @info: ioctl request information
3858 * @wrqu: ioctl request data
3859 * @extra: extra ioctl buffer
3860 *
3861 * Return: 0 on success, non-zero on error
3862 */
3863static int __iw_get_linkspeed(struct net_device *dev,
3864 struct iw_request_info *info,
3865 union iwreq_data *wrqu, char *extra)
3866{
3867 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3868 char *pLinkSpeed = (char *)extra;
3869 int len = sizeof(uint32_t) + 1;
3870 uint32_t link_speed = 0;
3871 hdd_context_t *hdd_ctx;
3872 int rc, valid;
3873
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08003874 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303875
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3877 valid = wlan_hdd_validate_context(hdd_ctx);
3878 if (0 != valid)
3879 return valid;
3880
3881 rc = wlan_hdd_get_link_speed(pAdapter, &link_speed);
3882 if (0 != rc) {
3883 return rc;
3884 }
3885
3886 wrqu->data.length = len;
3887 /* return the linkspeed as a string */
3888 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
3889 if ((rc < 0) || (rc >= len)) {
3890 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07003891 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 return -EIO;
3893 }
3894
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303895 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896 /* a value is being successfully returned */
3897 return 0;
3898}
3899
3900static int iw_get_linkspeed(struct net_device *dev,
3901 struct iw_request_info *info,
3902 union iwreq_data *wrqu, char *extra)
3903{
3904 int ret;
3905
3906 cds_ssr_protect(__func__);
3907 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
3908 cds_ssr_unprotect(__func__);
3909
3910 return ret;
3911}
3912
3913/**
3914 * wlan_hdd_change_country_code_callback() - Change country code callback
3915 * @context: opaque context originally passed to SME. All functions
3916 * which use this callback pass the adapter upon which the country
3917 * code change is active
3918 *
3919 * This function is registered as the callback function when
3920 * sme_change_country_code() is invoked. Callers of
3921 * sme_change_country_code() subsequently wait for the adapter's
3922 * @change_country_code completion variable, so all this function
3923 * needs to do is set that completion variable so that execution can
3924 * continue.
3925 *
3926 * Return: none
3927 */
3928void wlan_hdd_change_country_code_callback(void *context)
3929{
3930
3931 hdd_adapter_t *adapter = context;
3932
3933 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
3934 complete(&adapter->change_country_code);
3935
3936 return;
3937}
3938
3939/**
3940 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
3941 * @dev: device upon which the ioctl was received
3942 * @info: ioctl request information
3943 * @wrqu: ioctl request data
3944 * @extra: ioctl extra data
3945 *
3946 * Return: 0 on success, non-zero on error
3947 */
3948static int __iw_set_nick(struct net_device *dev,
3949 struct iw_request_info *info,
3950 union iwreq_data *wrqu, char *extra)
3951{
3952 hdd_adapter_t *adapter;
3953 hdd_context_t *hdd_ctx;
3954 int ret;
3955
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003956 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957
3958 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3959 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3960 ret = wlan_hdd_validate_context(hdd_ctx);
3961 if (0 != ret)
3962 return ret;
3963
3964 return 0;
3965}
3966
3967/**
3968 * iw_set_nick() - SSR wrapper for __iw_set_nick
3969 * @dev: pointer to net_device
3970 * @info: pointer to iw_request_info
3971 * @wrqu: pointer to iwreq_data
3972 * @extra: extra
3973 *
3974 * Return: 0 on success, error number otherwise
3975 */
3976static int iw_set_nick(struct net_device *dev,
3977 struct iw_request_info *info,
3978 union iwreq_data *wrqu, char *extra)
3979{
3980 int ret;
3981
3982 cds_ssr_protect(__func__);
3983 ret = __iw_set_nick(dev, info, wrqu, extra);
3984 cds_ssr_unprotect(__func__);
3985
3986 return ret;
3987}
3988
3989/**
3990 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
3991 * @dev: device upon which the ioctl was received
3992 * @info: ioctl request information
3993 * @wrqu: ioctl request data
3994 * @extra: ioctl extra data
3995 *
3996 * Return: 0 on success, non-zero on error
3997 */
3998static int __iw_get_nick(struct net_device *dev,
3999 struct iw_request_info *info,
4000 union iwreq_data *wrqu, char *extra)
4001{
4002 hdd_adapter_t *adapter;
4003 hdd_context_t *hdd_ctx;
4004 int ret;
4005
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004006 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007
4008 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4009 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4010 ret = wlan_hdd_validate_context(hdd_ctx);
4011 if (0 != ret)
4012 return ret;
4013
4014 return 0;
4015}
4016
4017/**
4018 * iw_get_nick() - SSR wrapper for __iw_get_nick
4019 * @dev: pointer to net_device
4020 * @info: pointer to iw_request_info
4021 * @wrqu: pointer to iwreq_data
4022 * @extra: extra
4023 *
4024 * Return: 0 on success, error number otherwise
4025 */
4026static int iw_get_nick(struct net_device *dev,
4027 struct iw_request_info *info,
4028 union iwreq_data *wrqu, char *extra)
4029{
4030 int ret;
4031
4032 cds_ssr_protect(__func__);
4033 ret = __iw_get_nick(dev, info, wrqu, extra);
4034 cds_ssr_unprotect(__func__);
4035
4036 return ret;
4037}
4038
4039/**
4040 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
4041 * @dev: device upon which the ioctl was received
4042 * @info: ioctl request information
4043 * @wrqu: ioctl request data
4044 * @extra: ioctl extra data
4045 *
4046 * Return: 0 on success, non-zero on error
4047 */
4048static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4049 union iwreq_data *wrqu, char *extra)
4050{
4051 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4052 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4053 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4054 hdd_context_t *hdd_ctx;
4055 struct iw_point *encoderq = &(wrqu->encoding);
4056 uint32_t keyId;
4057 uint8_t key_length;
4058 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4059 bool fKeyPresent = 0;
4060 int i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304061 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062 int ret;
4063
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004064 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065
4066 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4067 ret = wlan_hdd_validate_context(hdd_ctx);
4068 if (0 != ret)
4069 return ret;
4070
4071 keyId = encoderq->flags & IW_ENCODE_INDEX;
4072
4073 if (keyId) {
4074 if (keyId > MAX_WEP_KEYS) {
4075 return -EINVAL;
4076 }
4077
4078 fKeyPresent = 1;
4079 keyId--;
4080 } else {
4081 fKeyPresent = 0;
4082 }
4083
4084 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004085 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 if (!fKeyPresent) {
4087
4088 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
4089
4090 if (pWextState->roamProfile.Keys.KeyMaterial[i])
4091 pWextState->roamProfile.Keys.
4092 KeyLength[i] = 0;
4093 }
4094 }
4095 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4096 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4097 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4098 eCSR_ENCRYPT_TYPE_NONE;
4099 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4100 eCSR_ENCRYPT_TYPE_NONE;
4101
4102 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4103 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4104
4105 if (eConnectionState_Associated ==
4106 pHddStaCtx->conn_info.connState) {
4107 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4108 status =
4109 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4110 pAdapter->sessionId,
4111 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304112 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 unsigned long rc;
4114 rc = wait_for_completion_timeout(&pAdapter->
4115 disconnect_comp_var,
4116 msecs_to_jiffies
4117 (WLAN_WAIT_TIME_DISCONNECT));
4118 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004119 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 }
4121 }
4122
4123 return status;
4124
4125 }
4126
4127 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004128 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129
4130 pHddStaCtx->conn_info.authType =
4131 (encoderq->
4132 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
4133 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4134
4135 }
4136
4137 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004138 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139
4140 key_length = wrqu->data.length;
4141
4142 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
4143
4144 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004145 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 key_length);
4147
4148 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4149 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4150 pHddStaCtx->conn_info.authType)) {
4151 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4152 } else {
4153 encryptionType =
4154 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4155 }
4156 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004157 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 key_length);
4159
4160 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4161 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4162 pHddStaCtx->conn_info.authType)) {
4163 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4164 } else {
4165 encryptionType =
4166 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4167 }
4168 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004169 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170 key_length);
4171 return -EINVAL;
4172 }
4173
4174 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4175 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4176 pWextState->roamProfile.EncryptionType.numEntries = 1;
4177 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4178 encryptionType;
4179 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4180 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4181 encryptionType;
4182
4183 if ((eConnectionState_NotConnected ==
4184 pHddStaCtx->conn_info.connState)
4185 &&
4186 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4187 pHddStaCtx->conn_info.authType)
4188 || (eCSR_AUTH_TYPE_SHARED_KEY ==
4189 pHddStaCtx->conn_info.authType))) {
4190
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304191 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 KeyMaterial[keyId][0], extra, key_length);
4193
4194 pWextState->roamProfile.Keys.KeyLength[keyId] =
4195 (uint8_t) key_length;
4196 pWextState->roamProfile.Keys.defaultIndex =
4197 (uint8_t) keyId;
4198
4199 return status;
4200 }
4201 }
4202
4203 return 0;
4204}
4205
4206/**
4207 * iw_set_encode() - SSR wrapper for __iw_set_encode()
4208 * @dev: pointer to net_device
4209 * @info: pointer to iw_request_info
4210 * @wrqu: pointer to iwreq_data
4211 * @extra: pointer to extra ioctl payload
4212 *
4213 * Return: 0 on success, error number otherwise
4214 */
4215static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4216 union iwreq_data *wrqu, char *extra)
4217{
4218 int ret;
4219
4220 cds_ssr_protect(__func__);
4221 ret = __iw_set_encode(dev, info, wrqu, extra);
4222 cds_ssr_unprotect(__func__);
4223
4224 return ret;
4225}
4226
4227/**
4228 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
4229 * @dev: device upon which the ioctl was received
4230 * @info: ioctl request information
4231 * @wrqu: ioctl request data
4232 * @extra: ioctl extra data
4233 *
4234 * Return: 0 on success, non-zero on error
4235 */
4236static int __iw_get_encodeext(struct net_device *dev,
4237 struct iw_request_info *info,
4238 struct iw_point *dwrq, char *extra)
4239{
4240 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4241 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4242 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4243 int keyId;
4244 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4245 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4246 int i, ret;
4247 hdd_context_t *hdd_ctx;
4248
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004249 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250
4251 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4252 ret = wlan_hdd_validate_context(hdd_ctx);
4253 if (0 != ret)
4254 return ret;
4255
4256 keyId = pRoamProfile->Keys.defaultIndex;
4257
4258 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004259 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 return -EINVAL;
4261 }
4262
4263 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
4264 dwrq->flags |= IW_ENCODE_ENABLED;
4265 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304266 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 pRoamProfile->Keys.KeyLength[keyId]);
4268 } else {
4269 dwrq->flags |= IW_ENCODE_DISABLED;
4270 }
4271
4272 for (i = 0; i < MAX_WEP_KEYS; i++) {
4273 if (pRoamProfile->Keys.KeyMaterial[i] == NULL) {
4274 continue;
4275 } else {
4276 break;
4277 }
4278 }
4279
4280 if (MAX_WEP_KEYS == i) {
4281 dwrq->flags |= IW_ENCODE_NOKEY;
4282 } else {
4283 dwrq->flags |= IW_ENCODE_ENABLED;
4284 }
4285
4286 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4287
4288 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
4289 dwrq->flags |= IW_ENCODE_DISABLED;
4290 }
4291
4292 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4293
4294 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
4295 dwrq->flags |= IW_ENCODE_OPEN;
4296 } else {
4297 dwrq->flags |= IW_ENCODE_RESTRICTED;
4298 }
4299 EXIT();
4300 return 0;
4301
4302}
4303
4304/**
4305 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
4306 * @dev: pointer to net_device
4307 * @info: pointer to iw_request_info
4308 * @dwrq: pointer to encoding information
4309 * @extra: pointer to extra ioctl payload
4310 *
4311 * Return: 0 on success, error number otherwise
4312 */
4313static int iw_get_encodeext(struct net_device *dev,
4314 struct iw_request_info *info,
4315 struct iw_point *dwrq, char *extra)
4316{
4317 int ret;
4318
4319 cds_ssr_protect(__func__);
4320 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4321 cds_ssr_unprotect(__func__);
4322
4323 return ret;
4324}
4325
4326/**
4327 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
4328 * @dev: device upon which the ioctl was received
4329 * @info: ioctl request information
4330 * @wrqu: ioctl request data
4331 * @extra: ioctl extra data
4332 *
4333 * Return: 0 on success, non-zero on error
4334 */
4335static int __iw_set_encodeext(struct net_device *dev,
4336 struct iw_request_info *info,
4337 union iwreq_data *wrqu, char *extra)
4338{
4339 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4340 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4341 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4342 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304343 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4345 int ret;
4346 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4347 int key_index;
4348 struct iw_point *encoding = &wrqu->encoding;
4349 tCsrRoamSetKey setKey;
4350 uint32_t roamId = 0xFF;
4351
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004352 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353
4354 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4355 ret = wlan_hdd_validate_context(hdd_ctx);
4356 if (0 != ret)
4357 return ret;
4358
4359 key_index = encoding->flags & IW_ENCODE_INDEX;
4360
4361 if (key_index > 0) {
4362
4363 /*Convert from 1-based to 0-based keying */
4364 key_index--;
4365 }
4366 if (!ext->key_len) {
4367
4368 /*Set the encrytion type to NONE */
4369 pRoamProfile->EncryptionType.encryptionType[0] =
4370 eCSR_ENCRYPT_TYPE_NONE;
4371 return ret;
4372 }
4373
4374 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4375 (IW_ENCODE_ALG_WEP == ext->alg)) {
4376 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4377
Jeff Johnson99bac312016-06-28 10:38:18 -07004378 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379 return -EINVAL;
4380 } else {
4381 /*Static wep, update the roam profile with the keys */
4382 if (ext->key
4383 && (ext->key_len <=
4384 eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES)
4385 && key_index < CSR_MAX_NUM_KEY) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304386 qdf_mem_copy(&pRoamProfile->Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387 KeyMaterial[key_index][0],
4388 ext->key, ext->key_len);
4389 pRoamProfile->Keys.KeyLength[key_index] =
4390 (uint8_t) ext->key_len;
4391
4392 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4393 pRoamProfile->Keys.defaultIndex =
4394 (uint8_t) key_index;
4395
4396 }
4397 }
4398 return ret;
4399 }
4400
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304401 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402
4403 setKey.keyId = key_index;
4404 setKey.keyLength = ext->key_len;
4405
4406 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304407 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 }
4409
4410 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4411 /*Key direction for group is RX only */
4412 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05304413 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 } else {
4415
4416 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304417 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304418 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 }
4420
4421 /*For supplicant pae role is zero */
4422 setKey.paeRole = 0;
4423
4424 switch (ext->alg) {
4425 case IW_ENCODE_ALG_NONE:
4426 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4427 break;
4428
4429 case IW_ENCODE_ALG_WEP:
4430 setKey.encType =
4431 (ext->key_len ==
4432 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
4433 break;
4434
4435 case IW_ENCODE_ALG_TKIP:
4436 {
4437 uint8_t *pKey = &setKey.Key[0];
4438
4439 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4440
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304441 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442
4443 /* Supplicant sends the 32bytes key in this order
4444 * |--------------|----------|----------|
4445 * | Tk1 | TX MIC | RX MIC |
4446 * |--------------|----------|----------|
4447 * <---16bytes---><--8bytes--><--8bytes-->
4448 *
4449 *
4450 * Sme expects the 32 bytes key to be in the below order
4451 * |--------------|----------|----------|
4452 * | Tk1 | RX MIC | TX MIC |
4453 * |--------------|----------|----------|
4454 * <---16bytes---><--8bytes--><--8bytes-->
4455 */
4456
4457 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304458 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459
4460 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304461 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462
4463 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304464 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465
4466 }
4467 break;
4468
4469 case IW_ENCODE_ALG_CCMP:
4470 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4471 break;
4472
4473#ifdef FEATURE_WLAN_ESE
4474#define IW_ENCODE_ALG_KRK 6
4475 case IW_ENCODE_ALG_KRK:
4476 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4477 break;
4478#endif /* FEATURE_WLAN_ESE */
4479
4480 default:
4481 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4482 break;
4483 }
4484
Jeff Johnson99bac312016-06-28 10:38:18 -07004485 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
4486 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488 /* The supplicant may attempt to set the PTK once
4489 * pre-authentication is done. Save the key in the UMAC and
4490 * include it in the ADD BSS request
4491 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304492 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304494 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004495 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304497 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004498 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 return -EINVAL;
4500 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501
4502 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4503
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304504 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 pAdapter->sessionId,
4506 &setKey, &roamId);
4507
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304508 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004509 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304510 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511
4512 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4513 }
4514
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304515 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516}
4517
4518/**
4519 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
4520 * @dev: pointer to net_device
4521 * @info: pointer to iw_request_info
4522 * @wrqu: pointer to iwreq_data
4523 * @extra: pointer to extra ioctl payload
4524 *
4525 * Return: 0 on success, error number otherwise
4526 */
4527static int iw_set_encodeext(struct net_device *dev,
4528 struct iw_request_info *info,
4529 union iwreq_data *wrqu, char *extra)
4530{
4531 int ret;
4532
4533 cds_ssr_protect(__func__);
4534 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4535 cds_ssr_unprotect(__func__);
4536
4537 return ret;
4538}
4539
4540/**
4541 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
4542 * @dev: device upon which the ioctl was received
4543 * @info: ioctl request information
4544 * @wrqu: ioctl request data
4545 * @extra: ioctl extra data
4546 *
4547 * Return: 0 on success, non-zero on error
4548 */
4549static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4550 union iwreq_data *wrqu, char *extra)
4551{
4552 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4553 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4554 hdd_context_t *hdd_ctx;
4555 int ret;
4556
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004557 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558
4559 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4560 ret = wlan_hdd_validate_context(hdd_ctx);
4561 if (0 != ret)
4562 return ret;
4563
4564 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4565 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4566
Jeff Johnson99bac312016-06-28 10:38:18 -07004567 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568
4569 return -EINVAL;
4570 }
4571
4572 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
4573
4574 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4575 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
4576 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304577 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004578 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 return -EIO;
4580 }
4581 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4582 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
4583 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304584 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05304585 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 return -EIO;
4587 }
4588 }
4589 } else {
4590 return -EOPNOTSUPP;
4591 }
4592
Jeff Johnson99bac312016-06-28 10:38:18 -07004593 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594
4595 EXIT();
4596
4597 return 0;
4598
4599}
4600
4601/**
4602 * iw_set_retry() - SSR wrapper for __iw_set_retry()
4603 * @dev: pointer to net_device
4604 * @info: pointer to iw_request_info
4605 * @wrqu: pointer to iwreq_data
4606 * @extra: pointer to extra ioctl payload
4607 *
4608 * Return: 0 on success, error number otherwise
4609 */
4610static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4611 union iwreq_data *wrqu, char *extra)
4612{
4613 int ret;
4614
4615 cds_ssr_protect(__func__);
4616 ret = __iw_set_retry(dev, info, wrqu, extra);
4617 cds_ssr_unprotect(__func__);
4618
4619 return ret;
4620}
4621
4622/**
4623 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
4624 * @dev: device upon which the ioctl was received
4625 * @info: ioctl request information
4626 * @wrqu: ioctl request data
4627 * @extra: ioctl extra data
4628 *
4629 * Return: 0 on success, non-zero on error
4630 */
4631static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4632 union iwreq_data *wrqu, char *extra)
4633{
4634 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4635 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4636 uint32_t retry = 0;
4637 hdd_context_t *hdd_ctx;
4638 int ret;
4639
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004640 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641
4642 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4643 ret = wlan_hdd_validate_context(hdd_ctx);
4644 if (0 != ret)
4645 return ret;
4646
4647 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4648 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
4649
4650 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304651 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004652 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 return -EIO;
4654 }
4655
4656 wrqu->retry.value = retry;
4657 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4658 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
4659
4660 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304661 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05304662 hdd_warn("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663 return -EIO;
4664 }
4665
4666 wrqu->retry.value = retry;
4667 } else {
4668 return -EOPNOTSUPP;
4669 }
4670
Jeff Johnson99bac312016-06-28 10:38:18 -07004671 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672
4673 EXIT();
4674
4675 return 0;
4676}
4677
4678/**
4679 * iw_get_retry() - SSR wrapper for __iw_get_retry()
4680 * @dev: pointer to net_device
4681 * @info: pointer to iw_request_info
4682 * @wrqu: pointer to iwreq_data
4683 * @extra: pointer to extra ioctl payload
4684 *
4685 * Return: 0 on success, error number otherwise
4686 */
4687static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4688 union iwreq_data *wrqu, char *extra)
4689{
4690 int ret;
4691
4692 cds_ssr_protect(__func__);
4693 ret = __iw_get_retry(dev, info, wrqu, extra);
4694 cds_ssr_unprotect(__func__);
4695
4696 return ret;
4697}
4698
4699/**
4700 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
4701 * @dev: device upon which the ioctl was received
4702 * @info: ioctl request information
4703 * @wrqu: ioctl request data
4704 * @extra: ioctl extra data
4705 *
4706 * Return: 0 on success, non-zero on error
4707 */
4708static int __iw_set_mlme(struct net_device *dev,
4709 struct iw_request_info *info,
4710 union iwreq_data *wrqu, char *extra)
4711{
4712 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4713 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4714 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304715 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 hdd_context_t *hdd_ctx;
4717 int ret;
4718
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004719 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720
4721 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4722 ret = wlan_hdd_validate_context(hdd_ctx);
4723 if (0 != ret)
4724 return ret;
4725
4726 /* reason_code is unused. By default it is set to
4727 * eCSR_DISCONNECT_REASON_UNSPECIFIED
4728 */
4729 switch (mlme->cmd) {
4730 case IW_MLME_DISASSOC:
4731 case IW_MLME_DEAUTH:
4732
4733 if (pHddStaCtx->conn_info.connState ==
4734 eConnectionState_Associated) {
4735 eCsrRoamDisconnectReason reason =
4736 eCSR_DISCONNECT_REASON_UNSPECIFIED;
4737
4738 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
4739 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4740
4741 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4742 status =
4743 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4744 pAdapter->sessionId, reason);
4745
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304746 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747 unsigned long rc;
4748 rc = wait_for_completion_timeout(&pAdapter->
4749 disconnect_comp_var,
4750 msecs_to_jiffies
4751 (WLAN_WAIT_TIME_DISCONNECT));
4752 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004753 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07004755 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
4756 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757
4758 /* Resetting authKeyMgmt */
4759 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
4760 0;
4761
Jeff Johnson99bac312016-06-28 10:38:18 -07004762 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 wlan_hdd_netif_queue_control(pAdapter,
4764 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4765 WLAN_CONTROL_PATH);
4766
4767 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004768 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
4769 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 }
4771 break;
4772 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004773 hdd_err("%d Command should be Disassociate/Deauthenticate",
4774 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775 return -EINVAL;
4776 } /* end of switch */
4777
4778 EXIT();
4779
4780 return status;
4781
4782}
4783
4784/**
4785 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
4786 * @dev: pointer to net_device
4787 * @info: pointer to iw_request_info
4788 * @wrqu: pointer to iwreq_data
4789 * @extra: pointer to extra ioctl payload
4790 *
4791 * Return: 0 on success, error number otherwise
4792 */
4793static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
4794 union iwreq_data *wrqu, char *extra)
4795{
4796 int ret;
4797
4798 cds_ssr_protect(__func__);
4799 ret = __iw_set_mlme(dev, info, wrqu, extra);
4800 cds_ssr_unprotect(__func__);
4801
4802 return ret;
4803}
4804
4805/**
4806 * wlan_hdd_update_phymode() - handle change in PHY mode
4807 * @net: device upon which PHY mode change was received
4808 * @hal: umac handle for the driver
4809 * @new_phymode: new PHY mode for the device
4810 * @phddctx: pointer to the HDD context
4811 *
4812 * This function is called when the device is set to a new PHY mode.
4813 * It takes a holistic look at the desired PHY mode along with the
4814 * configured capabilities of the driver and the reported capabilities
4815 * of the hardware in order to correctly configure all PHY-related
4816 * parameters.
4817 *
4818 * Return: 0 on success, negative errno value on error
4819 */
4820int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
4821 int new_phymode, hdd_context_t *phddctx)
4822{
4823#ifdef QCA_HT_2040_COEX
4824 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304825 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004826#endif
4827 bool band_24 = false, band_5g = false;
4828 bool ch_bond24 = false, ch_bond5g = false;
4829 tSmeConfigParams smeconfig;
4830 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 eCsrPhyMode phymode = -EIO, old_phymode;
4833 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
4834 eCsrBand curr_band = eCSR_BAND_ALL;
4835
4836 old_phymode = sme_get_phy_mode(hal);
4837
4838 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4839 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4840 nChannelBondingMode24GHz))
4841 ch_bond24 = true;
4842
4843 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4844 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4845 nChannelBondingMode5GHz))
4846 ch_bond5g = true;
4847
4848 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
4849 band_24 = band_5g = true;
4850 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
4851 band_24 = true;
4852 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
4853 band_5g = true;
4854 }
4855
4856 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07004857 hdd_warn("ch_bond24=%d ch_bond5g=%d band_24=%d band_5g=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
4859
4860 switch (new_phymode) {
4861 case IEEE80211_MODE_AUTO:
4862 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4863 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
4864 phymode = eCSR_DOT11_MODE_AUTO;
4865 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4866 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4867 curr_band = eCSR_BAND_ALL;
4868 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4869 } else {
4870 sme_set_phy_mode(hal, old_phymode);
4871 return -EIO;
4872 }
4873 break;
4874 case IEEE80211_MODE_11A:
4875 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
4876 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4877 phymode = eCSR_DOT11_MODE_11a;
4878 hdd_dot11mode = eHDD_DOT11_MODE_11a;
4879 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4880 curr_band = eCSR_BAND_5G;
4881 } else {
4882 sme_set_phy_mode(hal, old_phymode);
4883 return -EIO;
4884 }
4885 break;
4886 case IEEE80211_MODE_11B:
4887 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
4888 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4889 phymode = eCSR_DOT11_MODE_11b;
4890 hdd_dot11mode = eHDD_DOT11_MODE_11b;
4891 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4892 curr_band = eCSR_BAND_24;
4893 } else {
4894 sme_set_phy_mode(hal, old_phymode);
4895 return -EIO;
4896 }
4897 break;
4898 case IEEE80211_MODE_11G:
4899 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
4900 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4901 phymode = eCSR_DOT11_MODE_11g;
4902 hdd_dot11mode = eHDD_DOT11_MODE_11g;
4903 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4904 curr_band = eCSR_BAND_24;
4905 } else {
4906 sme_set_phy_mode(hal, old_phymode);
4907 return -EIO;
4908 }
4909 break;
4910 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
4911 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
4912 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
4913 */
4914 case IEEE80211_MODE_11NA_HT20:
4915 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4916 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4917 phymode = eCSR_DOT11_MODE_11n;
4918 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4919 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4920 curr_band = eCSR_BAND_5G;
4921 } else {
4922 sme_set_phy_mode(hal, old_phymode);
4923 return -EIO;
4924 }
4925 break;
4926 case IEEE80211_MODE_11NA_HT40:
4927 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4928 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4929 phymode = eCSR_DOT11_MODE_11n;
4930 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4931 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4932 curr_band = eCSR_BAND_5G;
4933 } else {
4934 sme_set_phy_mode(hal, old_phymode);
4935 return -EIO;
4936 }
4937 break;
4938 case IEEE80211_MODE_11NG_HT20:
4939 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4940 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4941 phymode = eCSR_DOT11_MODE_11n;
4942 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4943 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4944 curr_band = eCSR_BAND_24;
4945 } else {
4946 sme_set_phy_mode(hal, old_phymode);
4947 return -EIO;
4948 }
4949 break;
4950 case IEEE80211_MODE_11NG_HT40:
4951 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4952 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4953 phymode = eCSR_DOT11_MODE_11n;
4954 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4955 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4956 curr_band = eCSR_BAND_24;
4957 } else {
4958 sme_set_phy_mode(hal, old_phymode);
4959 return -EIO;
4960 }
4961 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962 case IEEE80211_MODE_11AC_VHT20:
4963 case IEEE80211_MODE_11AC_VHT40:
4964 case IEEE80211_MODE_11AC_VHT80:
4965 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
4966 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4967 phymode = eCSR_DOT11_MODE_11ac;
4968 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
4969 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4970 curr_band = eCSR_BAND_5G;
4971 } else {
4972 sme_set_phy_mode(hal, old_phymode);
4973 return -EIO;
4974 }
4975 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 case IEEE80211_MODE_2G_AUTO:
4977 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4978 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4979 phymode = eCSR_DOT11_MODE_AUTO;
4980 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4981 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4982 curr_band = eCSR_BAND_24;
4983 } else {
4984 sme_set_phy_mode(hal, old_phymode);
4985 return -EIO;
4986 }
4987 break;
4988 case IEEE80211_MODE_5G_AUTO:
4989 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4990 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4991 phymode = eCSR_DOT11_MODE_AUTO;
4992 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4993 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4994 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4995 curr_band = eCSR_BAND_5G;
4996 } else {
4997 sme_set_phy_mode(hal, old_phymode);
4998 return -EIO;
4999 }
5000 break;
5001 case IEEE80211_MODE_11AGN:
5002 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5003 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
5004 phymode = eCSR_DOT11_MODE_11n;
5005 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5006 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5007 curr_band = eCSR_BAND_ALL;
5008 } else {
5009 sme_set_phy_mode(hal, old_phymode);
5010 return -EIO;
5011 }
5012 break;
5013 default:
5014 return -EIO;
5015 }
5016
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 switch (new_phymode) {
5018 case IEEE80211_MODE_11AC_VHT20:
5019 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5020 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5021 break;
5022 case IEEE80211_MODE_11AC_VHT40:
5023 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5024 break;
5025 case IEEE80211_MODE_11AC_VHT80:
5026 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5027 break;
5028 default:
5029 vhtchanwidth = phddctx->config->vhtChannelWidth;
5030 break;
5031 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005032
5033 if (phymode != -EIO) {
5034 sme_get_config_param(hal, &smeconfig);
5035 smeconfig.csrConfig.phyMode = phymode;
5036#ifdef QCA_HT_2040_COEX
5037 if (phymode == eCSR_DOT11_MODE_11n &&
5038 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
5039 smeconfig.csrConfig.obssEnabled = false;
5040 halStatus = sme_set_ht2040_mode(hal,
5041 pAdapter->sessionId,
5042 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305043 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005044 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005045 return -EIO;
5046 }
5047 } else if (phymode == eCSR_DOT11_MODE_11n &&
5048 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
5049 smeconfig.csrConfig.obssEnabled = true;
5050 halStatus = sme_set_ht2040_mode(hal,
5051 pAdapter->sessionId,
5052 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305053 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005054 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055 return -EIO;
5056 }
5057 }
5058#endif
5059 smeconfig.csrConfig.eBand = curr_band;
5060 smeconfig.csrConfig.bandCapability = curr_band;
5061 if (curr_band == eCSR_BAND_24)
5062 smeconfig.csrConfig.Is11hSupportEnabled = 0;
5063 else
5064 smeconfig.csrConfig.Is11hSupportEnabled =
5065 phddctx->config->Is11hSupportEnabled;
5066 if (curr_band == eCSR_BAND_24)
5067 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5068 else if (curr_band == eCSR_BAND_24)
5069 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5070 else {
5071 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5072 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5073 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 sme_update_config(hal, &smeconfig);
5076
5077 phddctx->config->dot11Mode = hdd_dot11mode;
5078 phddctx->config->nBandCapability = curr_band;
5079 phddctx->config->nChannelBondingMode24GHz =
5080 smeconfig.csrConfig.channelBondingMode24GHz;
5081 phddctx->config->nChannelBondingMode5GHz =
5082 smeconfig.csrConfig.channelBondingMode5GHz;
5083 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005084 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005085 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086 return -EIO;
5087 }
5088 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07005089 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005090 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5091 else
Dustin Browna30892e2016-10-12 17:28:36 -07005092 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5094
Jeff Johnson99bac312016-06-28 10:38:18 -07005095 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005096 phymode, chwidth, curr_band, vhtchanwidth);
5097 }
5098
5099 return 0;
5100}
5101
5102/**
5103 * hdd_get_temperature_cb() - "Get Temperature" callback function
5104 * @temperature: measured temperature
5105 * @pContext: callback context
5106 *
5107 * This function is passed to sme_get_temperature() as the callback
5108 * function to be invoked when the temperature measurement is
5109 * available.
5110 *
5111 * Return: None
5112 */
5113static void hdd_get_temperature_cb(int temperature, void *pContext)
5114{
5115 struct statsContext *pTempContext;
5116 hdd_adapter_t *pAdapter;
5117 ENTER();
5118 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005119 hdd_err("pContext is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005120 return;
5121 }
5122 pTempContext = pContext;
5123 pAdapter = pTempContext->pAdapter;
5124 spin_lock(&hdd_context_lock);
5125 if ((NULL == pAdapter) || (TEMP_CONTEXT_MAGIC != pTempContext->magic)) {
5126 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07005127 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128 pAdapter, pTempContext->magic);
5129 return;
5130 }
5131 if (temperature != 0) {
5132 pAdapter->temperature = temperature;
5133 }
5134 complete(&pTempContext->completion);
5135 spin_unlock(&hdd_context_lock);
5136 EXIT();
5137}
5138
5139/**
5140 * wlan_hdd_get_temperature() - get current device temperature
5141 * @pAdapter: device upon which the request was made
5142 * @temperature: pointer to where the temperature is to be returned
5143 *
5144 * Return: 0 if a temperature value (either current or cached) was
5145 * returned, otherwise a negative errno is returned.
5146 *
5147 */
5148int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
5149{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305150 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 struct statsContext tempContext;
5152 unsigned long rc;
5153
5154 ENTER();
5155 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005156 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005157 return -EPERM;
5158 }
5159 init_completion(&tempContext.completion);
5160 tempContext.pAdapter = pAdapter;
5161 tempContext.magic = TEMP_CONTEXT_MAGIC;
5162 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
5163 &tempContext, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305164 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005165 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166 } else {
5167 rc = wait_for_completion_timeout(&tempContext.completion,
5168 msecs_to_jiffies
5169 (WLAN_WAIT_TIME_STATS));
5170 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005171 hdd_err("SME timed out while retrieving temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172 }
5173 }
5174 spin_lock(&hdd_context_lock);
5175 tempContext.magic = 0;
5176 spin_unlock(&hdd_context_lock);
5177 *temperature = pAdapter->temperature;
5178 EXIT();
5179 return 0;
5180}
5181
5182/**
5183 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5184 * @dev: device upon which the ioctl was received
5185 * @info: ioctl request information
5186 * @wrqu: ioctl request data
5187 * @extra: ioctl extra data
5188 *
5189 * Return: 0 on success, non-zero on error
5190 */
5191static int __iw_setint_getnone(struct net_device *dev,
5192 struct iw_request_info *info,
5193 union iwreq_data *wrqu, char *extra)
5194{
5195 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5196 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5197 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5198 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5199 hdd_context_t *hdd_ctx;
5200 tSmeConfigParams smeConfig;
5201 int *value = (int *)extra;
5202 int sub_cmd = value[0];
5203 int set_value = value[1];
5204 int ret;
5205 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305206 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005208 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 INIT_COMPLETION(pWextState->completion_var);
Mukul Sharma81661ae2015-10-30 20:26:02 +05305211 memset(&smeConfig, 0x00, sizeof(smeConfig));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005212
5213 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5214 ret = wlan_hdd_validate_context(hdd_ctx);
5215 if (0 != ret)
5216 return ret;
5217
5218 switch (sub_cmd) {
5219 case WE_SET_11D_STATE:
5220 {
5221 if ((ENABLE_11D == set_value)
5222 || (DISABLE_11D == set_value)) {
5223
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224 sme_get_config_param(hHal, &smeConfig);
5225 smeConfig.csrConfig.Is11dSupportEnabled =
5226 (bool) set_value;
5227
Jeff Johnson99bac312016-06-28 10:38:18 -07005228 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229 smeConfig.csrConfig.
5230 Is11dSupportEnabled);
5231
5232 sme_update_config(hHal, &smeConfig);
5233 } else {
5234 return -EINVAL;
5235 }
5236 break;
5237 }
5238
5239 case WE_WOWL:
5240 {
5241 switch (set_value) {
5242 case 0x00:
5243 hdd_exit_wowl(pAdapter);
5244 break;
5245 case 0x01:
5246 case 0x02:
5247 case 0x03:
5248 enable_mp = (set_value & 0x01) ? 1 : 0;
5249 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005250 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 (enable_mp ? "YES" : "NO"),
5252 (enable_pbm ? "YES" : "NO"));
5253 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5254 break;
5255 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005256 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257 set_value);
5258 ret = -EINVAL;
5259 break;
5260 }
5261
5262 break;
5263 }
5264 case WE_SET_POWER:
5265 {
5266 switch (set_value) {
5267 case 1:
5268 /* Enable PowerSave */
5269 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5270 SME_PS_ENABLE);
5271 break;
5272 case 2:
5273 /* Disable PowerSave */
5274 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5275 SME_PS_DISABLE);
5276 break;
5277 case 3: /* Enable UASPD */
5278 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
5279 break;
5280 case 4: /* Disable UASPD */
5281 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
5282 break;
5283 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005284 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005285 set_value);
5286 ret = -EINVAL;
5287 break;
5288 }
5289 break;
5290 }
5291
5292 case WE_SET_MAX_ASSOC:
5293 {
5294 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5295 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5296 ret = -EINVAL;
5297 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5298 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305299 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005300 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005301 ret = -EIO;
5302 }
5303 break;
5304 }
5305
5306 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5307 if (set_value == 0 || set_value == 1)
5308 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
5309 set_value;
5310 else
5311 ret = -EINVAL;
5312 break;
5313
5314 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5316 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5317 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5318 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305319 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005320 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 ret = -EINVAL;
5322 }
5323 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324 case WE_SET_MC_RATE:
5325 {
5326 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
5327 break;
5328 }
5329 case WE_SET_TX_POWER:
5330 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305331 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332
Anurag Chouhanc5548422016-02-24 18:33:27 +05305333 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005334 if (sme_set_tx_power
5335 (hHal, pAdapter->sessionId, bssid,
5336 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305337 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005338 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005339 return -EIO;
5340 }
5341 break;
5342 }
5343 case WE_SET_MAX_TX_POWER:
5344 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305345 struct qdf_mac_addr bssid;
5346 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347
Jeff Johnson99bac312016-06-28 10:38:18 -07005348 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305350 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
5351 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352
5353 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305354 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005355 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356 return -EIO;
5357 }
5358
5359 break;
5360 }
5361 case WE_SET_MAX_TX_POWER_2_4:
5362 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005363 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
5364 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005365 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305366 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005367 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005368 return -EIO;
5369 }
5370
5371 break;
5372 }
5373 case WE_SET_MAX_TX_POWER_5_0:
5374 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005375 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
5376 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005377 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305378 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005379 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005380 return -EIO;
5381 }
5382
5383 break;
5384 }
5385 case WE_SET_HIGHER_DTIM_TRANSITION:
5386 {
5387 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005388 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005389 set_value);
5390 ret = -EINVAL;
5391 } else {
5392 if (pAdapter->higherDtimTransition != set_value) {
5393 pAdapter->higherDtimTransition =
5394 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07005395 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005396 pAdapter->higherDtimTransition);
5397 }
5398 }
5399
5400 break;
5401 }
5402
5403 case WE_SET_TM_LEVEL:
5404 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005405 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406 (void)sme_set_thermal_level(hHal, set_value);
5407 break;
5408 }
5409
5410 case WE_SET_PHYMODE:
5411 {
5412 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5413
5414 ret =
5415 wlan_hdd_update_phymode(dev, hHal, set_value,
5416 phddctx);
5417 break;
5418 }
5419
5420 case WE_SET_NSS:
5421 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005422 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005424 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005425 ret = -EINVAL;
5426 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305427 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
5429 set_value))
5430 ret = -EINVAL;
5431 }
5432 break;
5433 }
5434
5435 case WE_SET_GTX_HT_MCS:
5436 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005437 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 ret = wma_cli_set_command(pAdapter->sessionId,
5439 WMI_VDEV_PARAM_GTX_HT_MCS,
5440 set_value, GTX_CMD);
5441 break;
5442 }
5443
5444 case WE_SET_GTX_VHT_MCS:
5445 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005446 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 set_value);
5448 ret = wma_cli_set_command(pAdapter->sessionId,
5449 WMI_VDEV_PARAM_GTX_VHT_MCS,
5450 set_value, GTX_CMD);
5451 break;
5452 }
5453
5454 case WE_SET_GTX_USRCFG:
5455 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005456 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457 set_value);
5458 ret = wma_cli_set_command(pAdapter->sessionId,
5459 WMI_VDEV_PARAM_GTX_USR_CFG,
5460 set_value, GTX_CMD);
5461 break;
5462 }
5463
5464 case WE_SET_GTX_THRE:
5465 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005466 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005467 ret = wma_cli_set_command(pAdapter->sessionId,
5468 WMI_VDEV_PARAM_GTX_THRE,
5469 set_value, GTX_CMD);
5470 break;
5471 }
5472
5473 case WE_SET_GTX_MARGIN:
5474 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005475 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005476 ret = wma_cli_set_command(pAdapter->sessionId,
5477 WMI_VDEV_PARAM_GTX_MARGIN,
5478 set_value, GTX_CMD);
5479 break;
5480 }
5481
5482 case WE_SET_GTX_STEP:
5483 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005484 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485 ret = wma_cli_set_command(pAdapter->sessionId,
5486 WMI_VDEV_PARAM_GTX_STEP,
5487 set_value, GTX_CMD);
5488 break;
5489 }
5490
5491 case WE_SET_GTX_MINTPC:
5492 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005493 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 ret = wma_cli_set_command(pAdapter->sessionId,
5495 WMI_VDEV_PARAM_GTX_MINTPC,
5496 set_value, GTX_CMD);
5497 break;
5498 }
5499
5500 case WE_SET_GTX_BWMASK:
5501 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005502 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503 ret = wma_cli_set_command(pAdapter->sessionId,
5504 WMI_VDEV_PARAM_GTX_BW_MASK,
5505 set_value, GTX_CMD);
5506 break;
5507 }
5508
5509 case WE_SET_LDPC:
5510 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305511 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512 break;
5513 }
5514
5515 case WE_SET_TX_STBC:
5516 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305517 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005518 break;
5519 }
5520
5521 case WE_SET_RX_STBC:
5522 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305523 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005524 break;
5525 }
5526
5527 case WE_SET_SHORT_GI:
5528 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005529 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
5531 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
5532 set_value);
5533 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07005534 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005535 break;
5536 }
5537
5538 case WE_SET_RTSCTS:
5539 {
5540 uint32_t value;
5541
Jeff Johnson99bac312016-06-28 10:38:18 -07005542 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005543 set_value);
5544
5545 if ((set_value & HDD_RTSCTS_EN_MASK) ==
5546 HDD_RTSCTS_ENABLE)
5547 value =
5548 (WLAN_HDD_GET_CTX(pAdapter))->config->
5549 RTSThreshold;
5550 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
5551 || ((set_value & HDD_RTSCTS_EN_MASK) ==
5552 HDD_CTS_ENABLE))
5553 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
5554 else
5555 return -EIO;
5556
5557 ret = wma_cli_set_command(pAdapter->sessionId,
5558 WMI_VDEV_PARAM_ENABLE_RTSCTS,
5559 set_value, VDEV_CMD);
5560 if (!ret) {
5561 if (sme_cfg_set_int
5562 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305563 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005564 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 return -EIO;
5566 }
5567 }
5568
5569 break;
5570 }
5571
5572 case WE_SET_CHWIDTH:
5573 {
5574 bool chwidth = false;
5575 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5576 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07005577 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 set_value);
5579 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005580 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005581 return -EINVAL;
5582 }
5583
5584 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5585 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
5586 nChannelBondingMode5GHz)))
5587 chwidth = true;
5588
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005589 sme_get_config_param(hHal, &smeConfig);
5590 switch (set_value) {
5591 case eHT_CHANNEL_WIDTH_20MHZ:
5592 smeConfig.csrConfig.channelBondingMode5GHz =
5593 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5594 break;
5595 case eHT_CHANNEL_WIDTH_40MHZ:
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 case eHT_CHANNEL_WIDTH_80MHZ:
5606 if (chwidth)
5607 smeConfig.csrConfig.
5608 channelBondingMode5GHz =
5609 phddctx->config->
5610 nChannelBondingMode5GHz;
5611 else
5612 return -EINVAL;
5613
5614 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615
5616 default:
5617 return -EINVAL;
5618 }
5619
5620 ret = wma_cli_set_command(pAdapter->sessionId,
5621 WMI_VDEV_PARAM_CHWIDTH,
5622 set_value, VDEV_CMD);
5623 if (!ret)
5624 sme_update_config(hHal, &smeConfig);
5625
5626 break;
5627 }
5628
5629 case WE_SET_ANI_EN_DIS:
5630 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005631 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE 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_ENABLE,
5635 set_value, PDEV_CMD);
5636 break;
5637 }
5638
5639 case WE_SET_ANI_POLL_PERIOD:
5640 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005641 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_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_POLL_PERIOD,
5645 set_value, PDEV_CMD);
5646 break;
5647 }
5648
5649 case WE_SET_ANI_LISTEN_PERIOD:
5650 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005651 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD 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_LISTEN_PERIOD,
5655 set_value, PDEV_CMD);
5656 break;
5657 }
5658
5659 case WE_SET_ANI_OFDM_LEVEL:
5660 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005661 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_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_OFDM_LEVEL,
5665 set_value, PDEV_CMD);
5666 break;
5667 }
5668
5669 case WE_SET_ANI_CCK_LEVEL:
5670 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005671 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005672 set_value);
5673 ret = wma_cli_set_command(pAdapter->sessionId,
5674 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
5675 set_value, PDEV_CMD);
5676 break;
5677 }
5678
5679 case WE_SET_DYNAMIC_BW:
5680 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005681 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005682 set_value);
5683 ret = wma_cli_set_command(pAdapter->sessionId,
5684 WMI_PDEV_PARAM_DYNAMIC_BW,
5685 set_value, PDEV_CMD);
5686 break;
5687 }
5688
5689 case WE_SET_CTS_CBW:
5690 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005691 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 ret = wma_cli_set_command(pAdapter->sessionId,
5693 WMI_PDEV_PARAM_CTS_CBW,
5694 set_value, PDEV_CMD);
5695 break;
5696 }
5697
5698 case WE_SET_11N_RATE:
5699 {
5700 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005701 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 set_value);
5703
5704 if (set_value != 0xff) {
5705 rix = RC_2_RATE_IDX(set_value);
5706 if (set_value & 0x80) {
5707 preamble = WMI_RATE_PREAMBLE_HT;
5708 nss = HT_RC_2_STREAMS(set_value) - 1;
5709 } else {
5710 nss = 0;
5711 rix = RC_2_RATE_IDX(set_value);
5712 if (set_value & 0x10) {
5713 preamble =
5714 WMI_RATE_PREAMBLE_CCK;
5715 if (rix != 0x3)
5716 /* Enable Short
5717 * preamble always for
5718 * CCK except 1mbps
5719 */
5720 rix |= 0x4;
5721 } else {
5722 preamble =
5723 WMI_RATE_PREAMBLE_OFDM;
5724 }
5725 }
5726 set_value = (preamble << 6) | (nss << 4) | rix;
5727 }
5728 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5729 set_value, rix, preamble, nss);
5730
5731 ret = wma_cli_set_command(pAdapter->sessionId,
5732 WMI_VDEV_PARAM_FIXED_RATE,
5733 set_value, VDEV_CMD);
5734 break;
5735 }
5736
5737 case WE_SET_VHT_RATE:
5738 {
5739 uint8_t preamble = 0, nss = 0, rix = 0;
5740
5741 if (set_value != 0xff) {
5742 rix = RC_2_RATE_IDX_11AC(set_value);
5743 preamble = WMI_RATE_PREAMBLE_VHT;
5744 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
5745
5746 set_value = (preamble << 6) | (nss << 4) | rix;
5747 }
5748 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5749 set_value, rix, preamble, nss);
5750 ret = wma_cli_set_command(pAdapter->sessionId,
5751 WMI_VDEV_PARAM_FIXED_RATE,
5752 set_value, VDEV_CMD);
5753 break;
5754 }
5755
5756 case WE_SET_AMPDU:
5757 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005758 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005759 ret = wma_cli_set_command(pAdapter->sessionId,
5760 GEN_VDEV_PARAM_AMPDU,
5761 set_value, GEN_CMD);
5762 break;
5763 }
5764
5765 case WE_SET_AMSDU:
5766 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005767 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 ret = wma_cli_set_command(pAdapter->sessionId,
5769 GEN_VDEV_PARAM_AMSDU,
5770 set_value, GEN_CMD);
5771 break;
5772 }
5773
5774 case WE_SET_BURST_ENABLE:
5775 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005776 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005777 if ((set_value == 0) || (set_value == 1)) {
5778 ret = wma_cli_set_command(pAdapter->sessionId,
5779 WMI_PDEV_PARAM_BURST_ENABLE,
5780 set_value, PDEV_CMD);
5781 } else
5782 ret = -EINVAL;
5783 break;
5784 }
5785 case WE_SET_BURST_DUR:
5786 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005787 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07005788 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005789 ret = wma_cli_set_command(pAdapter->sessionId,
5790 WMI_PDEV_PARAM_BURST_DUR,
5791 set_value, PDEV_CMD);
5792 else
5793 ret = -EINVAL;
5794 break;
5795 }
5796
5797 case WE_SET_TX_CHAINMASK:
5798 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005799 hdd_notice("WMI_PDEV_PARAM_TX_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_TX_CHAIN_MASK,
5803 set_value, PDEV_CMD);
5804 break;
5805 }
5806
5807 case WE_SET_RX_CHAINMASK:
5808 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005809 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005810 set_value);
5811 ret = wma_cli_set_command(pAdapter->sessionId,
5812 WMI_PDEV_PARAM_RX_CHAIN_MASK,
5813 set_value, PDEV_CMD);
5814 break;
5815 }
5816
5817 case WE_SET_TXPOW_2G:
5818 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005819 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G 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_LIMIT2G,
5823 set_value, PDEV_CMD);
5824 break;
5825 }
5826
5827 case WE_SET_TXPOW_5G:
5828 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005829 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005830 set_value);
5831 ret = wma_cli_set_command(pAdapter->sessionId,
5832 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
5833 set_value, PDEV_CMD);
5834 break;
5835 }
5836
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005837 /* Firmware debug log */
5838 case WE_DBGLOG_LOG_LEVEL:
5839 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005840 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
5842 ret = wma_cli_set_command(pAdapter->sessionId,
5843 WMI_DBGLOG_LOG_LEVEL,
5844 set_value, DBG_CMD);
5845 break;
5846 }
5847
5848 case WE_DBGLOG_VAP_ENABLE:
5849 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005850 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005851 ret = wma_cli_set_command(pAdapter->sessionId,
5852 WMI_DBGLOG_VAP_ENABLE,
5853 set_value, DBG_CMD);
5854 break;
5855 }
5856
5857 case WE_DBGLOG_VAP_DISABLE:
5858 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005859 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860 ret = wma_cli_set_command(pAdapter->sessionId,
5861 WMI_DBGLOG_VAP_DISABLE,
5862 set_value, DBG_CMD);
5863 break;
5864 }
5865
5866 case WE_DBGLOG_MODULE_ENABLE:
5867 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005868 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005869 set_value);
5870 hdd_ctx->fw_log_settings.enable = set_value;
5871 ret = wma_cli_set_command(pAdapter->sessionId,
5872 WMI_DBGLOG_MODULE_ENABLE,
5873 set_value, DBG_CMD);
5874 break;
5875 }
5876
5877 case WE_DBGLOG_MODULE_DISABLE:
5878 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005879 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005880 set_value);
5881 hdd_ctx->fw_log_settings.enable = set_value;
5882 ret = wma_cli_set_command(pAdapter->sessionId,
5883 WMI_DBGLOG_MODULE_DISABLE,
5884 set_value, DBG_CMD);
5885 break;
5886 }
5887 case WE_DBGLOG_MOD_LOG_LEVEL:
5888 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005889 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005890 set_value);
5891
5892 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
5893 hdd_ctx->fw_log_settings.index = 0;
5894
5895 hdd_ctx->fw_log_settings.
5896 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
5897 set_value;
5898 hdd_ctx->fw_log_settings.index++;
5899
5900 ret = wma_cli_set_command(pAdapter->sessionId,
5901 WMI_DBGLOG_MOD_LOG_LEVEL,
5902 set_value, DBG_CMD);
5903 break;
5904 }
5905
5906 case WE_DBGLOG_TYPE:
5907 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005908 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005909 hdd_ctx->fw_log_settings.dl_type = set_value;
5910 ret = wma_cli_set_command(pAdapter->sessionId,
5911 WMI_DBGLOG_TYPE,
5912 set_value, DBG_CMD);
5913 break;
5914 }
5915 case WE_DBGLOG_REPORT_ENABLE:
5916 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005917 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005918 set_value);
5919 hdd_ctx->fw_log_settings.dl_report = set_value;
5920 ret = wma_cli_set_command(pAdapter->sessionId,
5921 WMI_DBGLOG_REPORT_ENABLE,
5922 set_value, DBG_CMD);
5923 break;
5924 }
5925
5926 case WE_SET_TXRX_FWSTATS:
5927 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005928 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005929 ret = wma_cli_set_command(pAdapter->sessionId,
5930 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
5931 set_value, VDEV_CMD);
5932 break;
5933 }
5934
5935 case WE_TXRX_FWSTATS_RESET:
5936 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005937 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 ret = wma_cli_set_command(pAdapter->sessionId,
5939 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
5940 set_value, VDEV_CMD);
5941 break;
5942 }
5943
5944 case WE_DUMP_STATS:
5945 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005946 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005947 hdd_wlan_dump_stats(pAdapter, set_value);
5948 break;
5949 }
5950
5951 case WE_CLEAR_STATS:
5952 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005953 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005954 switch (set_value) {
5955 case WLAN_HDD_STATS:
5956 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5957 memset(&pAdapter->hdd_stats, 0,
5958 sizeof(pAdapter->hdd_stats));
5959 break;
5960 case WLAN_TXRX_HIST_STATS:
5961 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
5962 break;
5963 case WLAN_HDD_NETIF_OPER_HISTORY:
5964 wlan_hdd_clear_netif_queue_history(hdd_ctx);
5965 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05305966 case WLAN_HIF_STATS:
5967 hdd_clear_hif_stats();
5968 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005969 default:
5970 ol_txrx_clear_stats(set_value);
5971 }
5972 break;
5973 }
5974
5975 case WE_PPS_PAID_MATCH:
5976 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005977 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005978 return EINVAL;
5979
Jeff Johnson99bac312016-06-28 10:38:18 -07005980 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005981 set_value);
5982 ret = wma_cli_set_command(pAdapter->sessionId,
5983 WMI_VDEV_PPS_PAID_MATCH,
5984 set_value, PPS_CMD);
5985 break;
5986 }
5987
5988 case WE_PPS_GID_MATCH:
5989 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005990 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005991 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07005992 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005993 set_value);
5994 ret = wma_cli_set_command(pAdapter->sessionId,
5995 WMI_VDEV_PPS_GID_MATCH,
5996 set_value, PPS_CMD);
5997 break;
5998 }
5999
6000 case WE_PPS_EARLY_TIM_CLEAR:
6001 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006002 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006003 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006004 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006005 set_value);
6006 ret = wma_cli_set_command(pAdapter->sessionId,
6007 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6008 set_value, PPS_CMD);
6009 break;
6010 }
6011
6012 case WE_PPS_EARLY_DTIM_CLEAR:
6013 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006014 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006016 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 set_value);
6018 ret = wma_cli_set_command(pAdapter->sessionId,
6019 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6020 set_value, PPS_CMD);
6021 break;
6022 }
6023
6024 case WE_PPS_EOF_PAD_DELIM:
6025 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006026 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006028 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006029 set_value);
6030 ret = wma_cli_set_command(pAdapter->sessionId,
6031 WMI_VDEV_PPS_EOF_PAD_DELIM,
6032 set_value, PPS_CMD);
6033 break;
6034 }
6035
6036 case WE_PPS_MACADDR_MISMATCH:
6037 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006038 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006039 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006040 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006041 set_value);
6042 ret = wma_cli_set_command(pAdapter->sessionId,
6043 WMI_VDEV_PPS_MACADDR_MISMATCH,
6044 set_value, PPS_CMD);
6045 break;
6046 }
6047
6048 case WE_PPS_DELIM_CRC_FAIL:
6049 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006050 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006052 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006053 set_value);
6054 ret = wma_cli_set_command(pAdapter->sessionId,
6055 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6056 set_value, PPS_CMD);
6057 break;
6058 }
6059
6060 case WE_PPS_GID_NSTS_ZERO:
6061 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006062 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006063 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006064 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006065 set_value);
6066 ret = wma_cli_set_command(pAdapter->sessionId,
6067 WMI_VDEV_PPS_GID_NSTS_ZERO,
6068 set_value, PPS_CMD);
6069 break;
6070 }
6071
6072 case WE_PPS_RSSI_CHECK:
6073 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006074 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006075 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006076 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077 set_value);
6078 ret = wma_cli_set_command(pAdapter->sessionId,
6079 WMI_VDEV_PPS_RSSI_CHECK,
6080 set_value, PPS_CMD);
6081 break;
6082 }
6083
6084 case WE_PPS_5G_EBT:
6085 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006086 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006087 return -EINVAL;
6088
Jeff Johnson99bac312016-06-28 10:38:18 -07006089 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006090 ret = wma_cli_set_command(pAdapter->sessionId,
6091 WMI_VDEV_PPS_5G_EBT,
6092 set_value, PPS_CMD);
6093 break;
6094 }
6095
6096 case WE_SET_HTSMPS:
6097 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006098 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099 ret = wma_cli_set_command(pAdapter->sessionId,
6100 WMI_STA_SMPS_FORCE_MODE_CMDID,
6101 set_value, VDEV_CMD);
6102 break;
6103 }
6104
6105 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6106 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006107 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006108 set_value);
6109 ret = wma_cli_set_command(pAdapter->sessionId,
6110 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6111 set_value, QPOWER_CMD);
6112 break;
6113 }
6114
6115 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6116 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006117 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006118 set_value);
6119 ret = wma_cli_set_command(
6120 pAdapter->sessionId,
6121 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6122 set_value, QPOWER_CMD);
6123 break;
6124 }
6125
6126 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6127 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006128 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006129 set_value);
6130 ret = wma_cli_set_command(
6131 pAdapter->sessionId,
6132 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6133 set_value, QPOWER_CMD);
6134 break;
6135 }
6136
6137 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6138 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006139 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006140 set_value);
6141 ret = wma_cli_set_command(
6142 pAdapter->sessionId,
6143 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6144 set_value, QPOWER_CMD);
6145 break;
6146 }
6147
6148 case WE_MCC_CONFIG_LATENCY:
6149 {
6150 cds_set_mcc_latency(pAdapter, set_value);
6151 break;
6152 }
6153
6154 case WE_MCC_CONFIG_QUOTA:
6155 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006156 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157 set_value);
6158 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
6159 break;
6160 }
6161 case WE_SET_DEBUG_LOG:
6162 {
6163 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05306164
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006165 hdd_ctx->config->gEnableDebugLog = set_value;
6166 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6167 break;
6168 }
6169 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6170 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006171 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006172 if ((set_value == 0) || (set_value == 1))
6173 ret = wma_cli_set_command(
6174 pAdapter->sessionId,
6175 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6176 set_value, VDEV_CMD);
6177 else
6178 ret = -EINVAL;
6179 break;
6180 }
6181 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6182 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006183 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184 ret = wma_cli_set_command(pAdapter->sessionId,
6185 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6186 set_value, VDEV_CMD);
6187 break;
6188 }
6189 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6190 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006191 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006192 set_value);
6193 ret = wma_cli_set_command(
6194 pAdapter->sessionId,
6195 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6196 set_value, VDEV_CMD);
6197 break;
6198 }
6199 case WE_SET_EARLY_RX_SLOP_STEP:
6200 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006201 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006202 set_value);
6203 ret = wma_cli_set_command(pAdapter->sessionId,
6204 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6205 set_value, VDEV_CMD);
6206 break;
6207 }
6208 case WE_SET_EARLY_RX_INIT_SLOP:
6209 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006210 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006211 set_value);
6212 ret = wma_cli_set_command(pAdapter->sessionId,
6213 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6214 set_value, VDEV_CMD);
6215 break;
6216 }
6217 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6218 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006219 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006220 if ((set_value == 0) || (set_value == 1))
6221 ret = wma_cli_set_command(
6222 pAdapter->sessionId,
6223 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6224 set_value, VDEV_CMD);
6225 else
6226 ret = -EINVAL;
6227 break;
6228 }
6229 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6230 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006231 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006232 ret = wma_cli_set_command(pAdapter->sessionId,
6233 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6234 set_value, VDEV_CMD);
6235 break;
6236 }
6237 case WE_SET_SCAN_DISABLE:
6238 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006239 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006240 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
6241 break;
6242 }
Govind Singha471e5e2015-10-12 17:11:14 +05306243 case WE_START_FW_PROFILE:
6244 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006245 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05306246 ret = wma_cli_set_command(pAdapter->sessionId,
6247 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6248 set_value, DBG_CMD);
6249 break;
6250 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306251 case WE_SET_CHANNEL:
6252 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006253 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306254 pAdapter->sessionId, pAdapter->device_mode);
6255
Krunal Sonif07bb382016-03-10 13:02:11 -08006256 if ((QDF_STA_MODE == pAdapter->device_mode) ||
6257 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306258
6259 status = sme_ext_change_channel(hHal,
6260 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306261 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006262 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306263 status);
6264 ret = -EINVAL;
6265 }
6266 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006267 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306268 pAdapter->device_mode);
6269 ret = -EINVAL;
6270 }
6271 break;
6272 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306273 case WE_SET_CONC_SYSTEM_PREF:
6274 {
6275 hdd_info("New preference: %d", set_value);
6276 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6277 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6278 hdd_err("Invalid system preference %d", set_value);
6279 return -EINVAL;
6280 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306281
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306282 /* hdd_ctx, hdd_ctx->config are already checked for null */
6283 hdd_ctx->config->conc_system_pref = set_value;
6284 break;
6285 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006286 default:
6287 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006288 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006289 sub_cmd);
6290 ret = -EINVAL;
6291 break;
6292 }
6293 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306294 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006295 return ret;
6296}
6297
6298static int iw_setint_getnone(struct net_device *dev,
6299 struct iw_request_info *info,
6300 union iwreq_data *wrqu,
6301 char *extra)
6302{
6303 int ret;
6304
6305 cds_ssr_protect(__func__);
6306 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6307 cds_ssr_unprotect(__func__);
6308
6309 return ret;
6310}
6311
6312/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006313 * __iw_setnone_get_threeint() - return three value to up layer.
6314 *
6315 * @dev: pointer of net_device of this wireless card
6316 * @info: meta data about Request sent
6317 * @wrqu: include request info
6318 * @extra: buf used for in/Output
6319 *
6320 * Return: execute result
6321 */
6322static int __iw_setnone_get_threeint(struct net_device *dev,
6323 struct iw_request_info *info,
6324 union iwreq_data *wrqu, char *extra)
6325{
6326 int ret = 0; /* success */
6327 uint32_t *value = (int *)extra;
6328 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6329 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6330
6331 ENTER_DEV(dev);
6332 ret = wlan_hdd_validate_context(hdd_ctx);
6333 if (0 != ret)
6334 return ret;
6335
Jeff Johnson99bac312016-06-28 10:38:18 -07006336 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006337 switch (value[0]) {
6338 case WE_GET_TSF:
6339 ret = hdd_indicate_tsf(adapter, value, 3);
6340 break;
6341 default:
6342 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6343 break;
6344 }
6345 return ret;
6346}
6347
6348/**
6349 * iw_setnone_get_threeint() - return three value to up layer.
6350 *
6351 * @dev: pointer of net_device of this wireless card
6352 * @info: meta data about Request sent
6353 * @wrqu: include request info
6354 * @extra: buf used for in/Output
6355 *
6356 * Return: execute result
6357 */
6358static int iw_setnone_get_threeint(struct net_device *dev,
6359 struct iw_request_info *info,
6360 union iwreq_data *wrqu, char *extra)
6361{
6362 int ret;
6363
6364 cds_ssr_protect(__func__);
6365 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6366 cds_ssr_unprotect(__func__);
6367
6368 return ret;
6369}
6370
6371/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006372 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6373 * @dev: device upon which the ioctl was received
6374 * @info: ioctl request information
6375 * @wrqu: ioctl request data
6376 * @extra: ioctl extra data
6377 *
6378 * Return: 0 on success, non-zero on error
6379 */
6380static int __iw_setchar_getnone(struct net_device *dev,
6381 struct iw_request_info *info,
6382 union iwreq_data *wrqu, char *extra)
6383{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306384 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006385 int sub_cmd;
6386 int ret;
6387 char *pBuffer = NULL;
6388 hdd_adapter_t *pAdapter = (netdev_priv(dev));
6389 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006390 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006391 struct iw_point s_priv_data;
6392
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006393 ENTER_DEV(dev);
6394
Mukul Sharma34777c62015-11-02 20:22:30 +05306395 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006396 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306397 return -EPERM;
6398 }
6399
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006400 ret = wlan_hdd_validate_context(hdd_ctx);
6401 if (0 != ret)
6402 return ret;
6403
6404 /* helper function to get iwreq_data with compat handling. */
6405 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
6406 return -EINVAL;
6407 }
6408
6409 /* make sure all params are correctly passed to function */
6410 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
6411 return -EINVAL;
6412 }
6413
6414 sub_cmd = s_priv_data.flags;
6415
6416 /* ODD number is used for set, copy data using copy_from_user */
6417 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6418 s_priv_data.length);
6419 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006420 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006421 return -ENOMEM;
6422 }
6423
Jeff Johnson99bac312016-06-28 10:38:18 -07006424 hdd_notice("Received length %d", s_priv_data.length);
6425 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006426
6427 switch (sub_cmd) {
6428 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006429 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006430 hdd_add_wowl_ptrn(pAdapter, pBuffer);
6431 break;
6432 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006433 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006434 hdd_del_wowl_ptrn(pAdapter, pBuffer);
6435 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006436 case WE_NEIGHBOR_REPORT_REQUEST:
6437 {
6438 tRrmNeighborReq neighborReq;
6439 tRrmNeighborRspCallbackInfo callbackInfo;
6440
6441 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006442 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006443 neighborReq.no_ssid =
6444 (s_priv_data.length - 1) ? false : true;
6445 if (!neighborReq.no_ssid) {
6446 neighborReq.ssid.length =
6447 (s_priv_data.length - 1) >
6448 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306449 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006450 pBuffer,
6451 neighborReq.ssid.length);
6452 }
6453
6454 callbackInfo.neighborRspCallback = NULL;
6455 callbackInfo.neighborRspCallbackContext = NULL;
6456 callbackInfo.timeout = 5000; /* 5 seconds */
6457 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
6458 (pAdapter),
6459 pAdapter->sessionId,
6460 &neighborReq,
6461 &callbackInfo);
6462 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006463 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006464 ret = -EINVAL;
6465 }
6466 }
6467 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006468 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07006469 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006470 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
6471 s_priv_data.length);
6472 break;
6473 case WE_SET_CONFIG:
6474 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306475 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006476 ret = -EINVAL;
6477 }
6478 break;
6479 default:
6480 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006481 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006482 sub_cmd);
6483 ret = -EINVAL;
6484 break;
6485 }
6486 }
6487 kfree(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306488 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489 return ret;
6490}
6491
6492static int iw_setchar_getnone(struct net_device *dev,
6493 struct iw_request_info *info,
6494 union iwreq_data *wrqu, char *extra)
6495{
6496 int ret;
6497
6498 cds_ssr_protect(__func__);
6499 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6500 cds_ssr_unprotect(__func__);
6501
6502 return ret;
6503}
6504
6505/**
6506 * iw_setnone_getint() - Generic "get integer" private ioctl handler
6507 * @dev: device upon which the ioctl was received
6508 * @info: ioctl request information
6509 * @wrqu: ioctl request data
6510 * @extra: ioctl extra data
6511 *
6512 * Return: 0 on success, non-zero on error
6513 */
6514static int __iw_setnone_getint(struct net_device *dev,
6515 struct iw_request_info *info,
6516 union iwreq_data *wrqu, char *extra)
6517{
6518 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6519 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6520 int *value = (int *)extra;
6521 int ret;
6522 tSmeConfigParams smeConfig;
6523 hdd_context_t *hdd_ctx;
6524
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006525 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006527 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6528 ret = wlan_hdd_validate_context(hdd_ctx);
6529 if (0 != ret)
6530 return ret;
6531
6532 switch (value[0]) {
6533 case WE_GET_11D_STATE:
6534 {
6535 sme_get_config_param(hHal, &smeConfig);
6536
6537 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6538
Jeff Johnson99bac312016-06-28 10:38:18 -07006539 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006540
6541 break;
6542 }
6543
6544 case WE_IBSS_STATUS:
Jeff Johnson99bac312016-06-28 10:38:18 -07006545 hdd_notice("****Return IBSS Status*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006546 break;
6547
6548 case WE_GET_WLAN_DBG:
6549 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306550 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006551 *value = 0;
6552 break;
6553 }
6554 case WE_GET_MAX_ASSOC:
6555 {
6556 if (sme_cfg_get_int
6557 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306558 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006559 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006560 ret = -EIO;
6561 }
6562 break;
6563 }
6564 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6565 *value = (WLAN_HDD_GET_CTX(
6566 pAdapter))->config->force_sap_acs;
6567 break;
6568
6569 case WE_GET_CONCURRENCY_MODE:
6570 {
6571 *value = cds_get_concurrency_mode();
6572
Jeff Johnson99bac312016-06-28 10:38:18 -07006573 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006574 break;
6575 }
6576
6577 case WE_GET_NSS:
6578 {
6579 sme_get_config_param(hHal, &smeConfig);
6580 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07006581 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582 break;
6583 }
6584
6585 case WE_GET_GTX_HT_MCS:
6586 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006587 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006588 *value = wma_cli_get_command(pAdapter->sessionId,
6589 WMI_VDEV_PARAM_GTX_HT_MCS,
6590 GTX_CMD);
6591 break;
6592 }
6593
6594 case WE_GET_GTX_VHT_MCS:
6595 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006596 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006597 *value = wma_cli_get_command(pAdapter->sessionId,
6598 WMI_VDEV_PARAM_GTX_VHT_MCS,
6599 GTX_CMD);
6600 break;
6601 }
6602
6603 case WE_GET_GTX_USRCFG:
6604 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006605 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006606 *value = wma_cli_get_command(pAdapter->sessionId,
6607 WMI_VDEV_PARAM_GTX_USR_CFG,
6608 GTX_CMD);
6609 break;
6610 }
6611
6612 case WE_GET_GTX_THRE:
6613 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006614 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006615 *value = wma_cli_get_command(pAdapter->sessionId,
6616 WMI_VDEV_PARAM_GTX_THRE,
6617 GTX_CMD);
6618 break;
6619 }
6620
6621 case WE_GET_GTX_MARGIN:
6622 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006623 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006624 *value = wma_cli_get_command(pAdapter->sessionId,
6625 WMI_VDEV_PARAM_GTX_MARGIN,
6626 GTX_CMD);
6627 break;
6628 }
6629
6630 case WE_GET_GTX_STEP:
6631 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006632 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006633 *value = wma_cli_get_command(pAdapter->sessionId,
6634 WMI_VDEV_PARAM_GTX_STEP,
6635 GTX_CMD);
6636 break;
6637 }
6638
6639 case WE_GET_GTX_MINTPC:
6640 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006641 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006642 *value = wma_cli_get_command(pAdapter->sessionId,
6643 WMI_VDEV_PARAM_GTX_MINTPC,
6644 GTX_CMD);
6645 break;
6646 }
6647
6648 case WE_GET_GTX_BWMASK:
6649 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006650 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006651 *value = wma_cli_get_command(pAdapter->sessionId,
6652 WMI_VDEV_PARAM_GTX_BW_MASK,
6653 GTX_CMD);
6654 break;
6655 }
6656
6657 case WE_GET_LDPC:
6658 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306659 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006660 break;
6661 }
6662
6663 case WE_GET_TX_STBC:
6664 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306665 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006666 break;
6667 }
6668
6669 case WE_GET_RX_STBC:
6670 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306671 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006672 break;
6673 }
6674
6675 case WE_GET_SHORT_GI:
6676 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006677 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006678 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
6679 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
6680 break;
6681 }
6682
6683 case WE_GET_RTSCTS:
6684 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006685 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006686 *value = wma_cli_get_command(pAdapter->sessionId,
6687 WMI_VDEV_PARAM_ENABLE_RTSCTS,
6688 VDEV_CMD);
6689 break;
6690 }
6691
6692 case WE_GET_CHWIDTH:
6693 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006694 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006695 *value = wma_cli_get_command(pAdapter->sessionId,
6696 WMI_VDEV_PARAM_CHWIDTH,
6697 VDEV_CMD);
6698 break;
6699 }
6700
6701 case WE_GET_ANI_EN_DIS:
6702 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006703 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006704 *value = wma_cli_get_command(pAdapter->sessionId,
6705 WMI_PDEV_PARAM_ANI_ENABLE,
6706 PDEV_CMD);
6707 break;
6708 }
6709
6710 case WE_GET_ANI_POLL_PERIOD:
6711 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006712 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006713 *value = wma_cli_get_command(pAdapter->sessionId,
6714 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6715 PDEV_CMD);
6716 break;
6717 }
6718
6719 case WE_GET_ANI_LISTEN_PERIOD:
6720 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006721 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006722 *value = wma_cli_get_command(pAdapter->sessionId,
6723 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6724 PDEV_CMD);
6725 break;
6726 }
6727
6728 case WE_GET_ANI_OFDM_LEVEL:
6729 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006730 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006731 *value = wma_cli_get_command(pAdapter->sessionId,
6732 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6733 PDEV_CMD);
6734 break;
6735 }
6736
6737 case WE_GET_ANI_CCK_LEVEL:
6738 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006739 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006740 *value = wma_cli_get_command(pAdapter->sessionId,
6741 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6742 PDEV_CMD);
6743 break;
6744 }
6745
6746 case WE_GET_DYNAMIC_BW:
6747 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006748 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006749 *value = wma_cli_get_command(pAdapter->sessionId,
6750 WMI_PDEV_PARAM_DYNAMIC_BW,
6751 PDEV_CMD);
6752 break;
6753 }
6754
6755 case WE_GET_11N_RATE:
6756 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006757 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006758 *value = wma_cli_get_command(pAdapter->sessionId,
6759 WMI_VDEV_PARAM_FIXED_RATE,
6760 VDEV_CMD);
6761 break;
6762 }
6763
6764 case WE_GET_AMPDU:
6765 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006766 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006767 *value = wma_cli_get_command(pAdapter->sessionId,
6768 GEN_VDEV_PARAM_AMPDU,
6769 GEN_CMD);
6770 break;
6771 }
6772
6773 case WE_GET_AMSDU:
6774 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006775 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006776 *value = wma_cli_get_command(pAdapter->sessionId,
6777 GEN_VDEV_PARAM_AMSDU,
6778 GEN_CMD);
6779 break;
6780 }
6781
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006782 case WE_GET_ROAM_SYNCH_DELAY:
6783 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006784 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006785 *value = wma_cli_get_command(pAdapter->sessionId,
6786 GEN_VDEV_ROAM_SYNCH_DELAY,
6787 GEN_CMD);
6788 break;
6789 }
6790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006791 case WE_GET_BURST_ENABLE:
6792 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006793 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006794 *value = wma_cli_get_command(pAdapter->sessionId,
6795 WMI_PDEV_PARAM_BURST_ENABLE,
6796 PDEV_CMD);
6797 break;
6798 }
6799 case WE_GET_BURST_DUR:
6800 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006801 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006802 *value = wma_cli_get_command(pAdapter->sessionId,
6803 WMI_PDEV_PARAM_BURST_DUR,
6804 PDEV_CMD);
6805 break;
6806 }
6807
6808 case WE_GET_TX_CHAINMASK:
6809 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006810 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006811 *value = wma_cli_get_command(pAdapter->sessionId,
6812 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6813 PDEV_CMD);
6814 break;
6815 }
6816
6817 case WE_GET_RX_CHAINMASK:
6818 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006819 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006820 *value = wma_cli_get_command(pAdapter->sessionId,
6821 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6822 PDEV_CMD);
6823 break;
6824 }
6825
6826 case WE_GET_TXPOW_2G:
6827 {
6828 uint32_t txpow2g = 0;
6829 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006830 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006831 *value = wma_cli_get_command(pAdapter->sessionId,
6832 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6833 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306834 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006835 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6836 &txpow2g)) {
6837 return -EIO;
6838 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006839 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006840 break;
6841 }
6842
6843 case WE_GET_TXPOW_5G:
6844 {
6845 uint32_t txpow5g = 0;
6846 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006847 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006848 *value = wma_cli_get_command(pAdapter->sessionId,
6849 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6850 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306851 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006852 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6853 &txpow5g)) {
6854 return -EIO;
6855 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006856 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006857 break;
6858 }
6859
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006860 case WE_GET_PPS_PAID_MATCH:
6861 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006862 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006863 *value = wma_cli_get_command(pAdapter->sessionId,
6864 WMI_VDEV_PPS_PAID_MATCH,
6865 PPS_CMD);
6866 break;
6867 }
6868
6869 case WE_GET_PPS_GID_MATCH:
6870 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006871 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006872 *value = wma_cli_get_command(pAdapter->sessionId,
6873 WMI_VDEV_PPS_GID_MATCH,
6874 PPS_CMD);
6875 break;
6876 }
6877
6878 case WE_GET_PPS_EARLY_TIM_CLEAR:
6879 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006880 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006881 *value = wma_cli_get_command(pAdapter->sessionId,
6882 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6883 PPS_CMD);
6884 break;
6885 }
6886
6887 case WE_GET_PPS_EARLY_DTIM_CLEAR:
6888 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006889 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006890 *value = wma_cli_get_command(pAdapter->sessionId,
6891 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6892 PPS_CMD);
6893 break;
6894 }
6895
6896 case WE_GET_PPS_EOF_PAD_DELIM:
6897 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006898 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899 *value = wma_cli_get_command(pAdapter->sessionId,
6900 WMI_VDEV_PPS_EOF_PAD_DELIM,
6901 PPS_CMD);
6902 break;
6903 }
6904
6905 case WE_GET_PPS_MACADDR_MISMATCH:
6906 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006907 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006908 *value = wma_cli_get_command(pAdapter->sessionId,
6909 WMI_VDEV_PPS_MACADDR_MISMATCH,
6910 PPS_CMD);
6911 break;
6912 }
6913
6914 case WE_GET_PPS_DELIM_CRC_FAIL:
6915 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006916 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006917 *value = wma_cli_get_command(pAdapter->sessionId,
6918 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6919 PPS_CMD);
6920 break;
6921 }
6922
6923 case WE_GET_PPS_GID_NSTS_ZERO:
6924 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006925 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006926 *value = wma_cli_get_command(pAdapter->sessionId,
6927 WMI_VDEV_PPS_GID_NSTS_ZERO,
6928 PPS_CMD);
6929 break;
6930 }
6931
6932 case WE_GET_PPS_RSSI_CHECK:
6933 {
6934
Jeff Johnson99bac312016-06-28 10:38:18 -07006935 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006936 *value = wma_cli_get_command(pAdapter->sessionId,
6937 WMI_VDEV_PPS_RSSI_CHECK,
6938 PPS_CMD);
6939 break;
6940 }
6941
6942 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
6943 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006944 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006945 *value = wma_cli_get_command(pAdapter->sessionId,
6946 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6947 QPOWER_CMD);
6948 break;
6949 }
6950
6951 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
6952 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006953 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006954 *value = wma_cli_get_command(pAdapter->sessionId,
6955 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6956 QPOWER_CMD);
6957 break;
6958 }
6959
6960 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6961 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006962 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006963 *value = wma_cli_get_command(pAdapter->sessionId,
6964 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6965 QPOWER_CMD);
6966 break;
6967 }
6968
6969 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6970 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006971 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006972 *value = wma_cli_get_command(pAdapter->sessionId,
6973 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6974 QPOWER_CMD);
6975 break;
6976 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006977 case WE_CAP_TSF:
6978 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
6979 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006980 case WE_GET_TEMPERATURE:
6981 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006982 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006983 ret = wlan_hdd_get_temperature(pAdapter, value);
6984 break;
6985 }
6986 default:
6987 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006988 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006989 value[0]);
6990 break;
6991 }
6992 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306993 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006994 return ret;
6995}
6996
6997static int iw_setnone_getint(struct net_device *dev,
6998 struct iw_request_info *info,
6999 union iwreq_data *wrqu, char *extra)
7000{
7001 int ret;
7002
7003 cds_ssr_protect(__func__);
7004 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7005 cds_ssr_unprotect(__func__);
7006
7007 return ret;
7008}
7009
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307010static int hdd_set_fwtest(int argc, int cmd, int value)
7011{
7012 struct set_fwtest_params *fw_test;
7013
7014 /* check for max number of arguments */
7015 if (argc > (WMA_MAX_NUM_ARGS) ||
7016 argc != HDD_FWTEST_PARAMS) {
7017 hdd_err("Too Many args %d", argc);
7018 return -EINVAL;
7019 }
7020 /*
7021 * check if number of arguments are 3 then, check
7022 * then set the default value for sounding interval.
7023 */
7024 if (HDD_FWTEST_PARAMS == argc) {
7025 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7026 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7027 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7028 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7029 }
7030 /* check sounding interval value should not exceed to max */
7031 if (value > HDD_FWTEST_MAX_VALUE) {
7032 hdd_err("Invalid arguments value should not exceed max: %d",
7033 value);
7034 return -EINVAL;
7035 }
7036 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7037 if (NULL == fw_test) {
7038 hdd_err("qdf_mem_malloc failed for fw_test");
7039 return -ENOMEM;
7040 }
7041 fw_test->arg = cmd;
7042 fw_test->value = value;
7043 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7044 qdf_mem_free(fw_test);
7045 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7046 return -EINVAL;
7047 }
7048 return 0;
7049}
7050
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007051/**
7052 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7053 * @dev: device upon which the ioctl was received
7054 * @info: ioctl request information
7055 * @wrqu: ioctl request data
7056 * @extra: ioctl extra data
7057 *
7058 * Return: 0 on success, non-zero on error
7059 */
7060static int __iw_set_three_ints_getnone(struct net_device *dev,
7061 struct iw_request_info *info,
7062 union iwreq_data *wrqu, char *extra)
7063{
7064 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7065 int *value = (int *)extra;
7066 int sub_cmd = value[0];
7067 int ret;
7068 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7069
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007070 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307071
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007072 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007073 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007074 return -EPERM;
7075 }
7076
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007077 ret = wlan_hdd_validate_context(hdd_ctx);
7078 if (0 != ret)
7079 return ret;
7080
7081 switch (sub_cmd) {
7082
7083 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307084 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007085 break;
7086 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307087 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007088 break;
7089
7090 /* value[3] the acs band is not required as start and end channels are
7091 * enough but this cmd is maintained under set three ints for historic
7092 * reasons.
7093 */
7094 case WE_SET_SAP_CHANNELS:
7095 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307096 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007097 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307098 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007099 ret = -EINVAL;
7100 } else {
7101 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7102 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7103 }
7104 break;
7105 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7106 hdd_debug("Ioctl to set dual mac scan config");
7107 if (hdd_ctx->config->dual_mac_feature_disable) {
7108 hdd_err("Dual mac feature is disabled from INI");
7109 return -EPERM;
7110 }
7111 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08007112 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007113 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307114 case WE_SET_FW_TEST:
7115 {
7116 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7117 if (ret) {
7118 hdd_err("Not able to set fwtest %d", ret);
7119 return ret;
7120 }
7121 }
7122 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007123 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007124 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007125 break;
7126
7127 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307128 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007129 return ret;
7130}
7131
7132int iw_set_three_ints_getnone(struct net_device *dev,
7133 struct iw_request_info *info,
7134 union iwreq_data *wrqu, char *extra)
7135{
7136 int ret;
7137
7138 cds_ssr_protect(__func__);
7139 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7140 cds_ssr_unprotect(__func__);
7141
7142 return ret;
7143}
7144
7145/**
7146 * hdd_connection_state_string() - Get connection state string
7147 * @connection_state: enum to be converted to a string
7148 *
7149 * Return: the string equivalent of @connection_state
7150 */
7151static const char *
7152hdd_connection_state_string(eConnectionState connection_state)
7153{
7154 switch (connection_state) {
7155 CASE_RETURN_STRING(eConnectionState_NotConnected);
7156 CASE_RETURN_STRING(eConnectionState_Connecting);
7157 CASE_RETURN_STRING(eConnectionState_Associated);
7158 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7159 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7160 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7161 default:
7162 return "UNKNOWN";
7163 }
7164}
7165
7166/**
7167 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7168 * @dev: device upon which the ioctl was received
7169 * @info: ioctl request information
7170 * @wrqu: ioctl request data
7171 * @extra: ioctl extra data
7172 *
7173 * Return: 0 on success, non-zero on error
7174 */
7175static int __iw_get_char_setnone(struct net_device *dev,
7176 struct iw_request_info *info,
7177 union iwreq_data *wrqu, char *extra)
7178{
7179 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7180 int sub_cmd = wrqu->data.flags;
7181 hdd_context_t *hdd_ctx;
7182 int ret;
7183#ifdef WLAN_FEATURE_11W
7184 hdd_wext_state_t *pWextState;
7185#endif
7186
7187#ifdef WLAN_FEATURE_11W
7188 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7189#endif
7190
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007191 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307192
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007193 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7194 ret = wlan_hdd_validate_context(hdd_ctx);
7195 if (0 != ret)
7196 return ret;
7197
7198 switch (sub_cmd) {
7199 case WE_WLAN_VERSION:
7200 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307201 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007202 break;
7203 }
7204
7205 case WE_GET_STATS:
7206 {
7207 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
7208 extra, WE_MAX_STR_LEN);
7209 break;
7210 }
7211
Govind Singha471e5e2015-10-12 17:11:14 +05307212 case WE_LIST_FW_PROFILE:
7213 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7214 extra, WE_MAX_STR_LEN);
7215 break;
7216
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007217 /* The case prints the current state of the HDD, SME, CSR, PE,
7218 * TL it can be extended for WDI Global State as well. And
7219 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7220 * and P2P_GO have not been added as of now.
7221 */
7222 case WE_GET_STATES:
7223 {
7224 int buf = 0, len = 0;
7225 int adapter_num = 0;
7226 int count = 0, check = 1;
7227
7228 tHalHandle hHal = NULL;
7229 tpAniSirGlobal pMac = NULL;
7230 hdd_station_ctx_t *pHddStaCtx = NULL;
7231
7232 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7233 hdd_adapter_t *useAdapter = NULL;
7234
7235 /* Print wlan0 or p2p0 states based on the adapter_num
7236 * by using the correct adapter
7237 */
7238 while (adapter_num < 2) {
7239 if (WLAN_ADAPTER == adapter_num) {
7240 useAdapter = pAdapter;
7241 buf =
7242 scnprintf(extra + len,
7243 WE_MAX_STR_LEN - len,
7244 "\n\n wlan0 States:-");
7245 len += buf;
7246 } else if (P2P_ADAPTER == adapter_num) {
7247 buf =
7248 scnprintf(extra + len,
7249 WE_MAX_STR_LEN - len,
7250 "\n\n p2p0 States:-");
7251 len += buf;
7252
7253 if (!pHddCtx) {
7254 buf =
7255 scnprintf(extra + len,
7256 WE_MAX_STR_LEN -
7257 len,
7258 "\n pHddCtx is NULL");
7259 len += buf;
7260 break;
7261 }
7262
7263 /* Printing p2p0 states only in the
7264 * case when the device is configured
7265 * as a p2p_client
7266 */
7267 useAdapter =
7268 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007269 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007270 if (!useAdapter) {
7271 buf =
7272 scnprintf(extra + len,
7273 WE_MAX_STR_LEN -
7274 len,
7275 "\n Device not configured as P2P_CLIENT.");
7276 len += buf;
7277 break;
7278 }
7279 }
7280
7281 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7282 if (!hHal) {
7283 buf =
7284 scnprintf(extra + len,
7285 WE_MAX_STR_LEN - len,
7286 "\n pMac is NULL");
7287 len += buf;
7288 break;
7289 }
7290 pMac = PMAC_STRUCT(hHal);
7291 if (!pMac) {
7292 buf =
7293 scnprintf(extra + len,
7294 WE_MAX_STR_LEN - len,
7295 "\n pMac is NULL");
7296 len += buf;
7297 break;
7298 }
7299 pHddStaCtx =
7300 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7301
7302
7303 buf =
7304 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7305 "\n HDD Conn State - %s "
7306 "\n \n SME State:"
7307 "\n Neighbour Roam State - %s"
7308 "\n CSR State - %s"
7309 "\n CSR Substate - %s",
7310 hdd_connection_state_string
7311 (pHddStaCtx->conn_info.connState),
7312 mac_trace_get_neighbour_roam_state
7313 (sme_get_neighbor_roam_state
7314 (hHal, useAdapter->sessionId)),
7315 mac_trace_getcsr_roam_state
7316 (sme_get_current_roam_state
7317 (hHal, useAdapter->sessionId)),
7318 mac_trace_getcsr_roam_sub_state
7319 (sme_get_current_roam_sub_state
7320 (hHal, useAdapter->sessionId))
7321 );
7322 len += buf;
7323 adapter_num++;
7324 }
7325
Mukul Sharma81661ae2015-10-30 20:26:02 +05307326 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007327 /* Printing Lim State starting with global lim states */
7328 buf =
7329 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7330 "\n \n LIM STATES:-"
7331 "\n Global Sme State - %s "
7332 "\n Global mlm State - %s " "\n",
7333 mac_trace_get_lim_sme_state
7334 (sme_get_lim_sme_state(hHal)),
7335 mac_trace_get_lim_mlm_state
7336 (sme_get_lim_sme_state(hHal))
7337 );
7338 len += buf;
7339
7340 /* Printing the PE Sme and Mlm states for valid lim sessions */
7341 while (check < 3 && count < 255) {
7342 if (sme_is_lim_session_valid(hHal, count)) {
7343 buf =
7344 scnprintf(extra + len,
7345 WE_MAX_STR_LEN -
7346 len,
7347 "\n Lim Valid Session %d:-"
7348 "\n PE Sme State - %s "
7349 "\n PE Mlm State - %s "
7350 "\n", check,
7351 mac_trace_get_lim_sme_state
7352 (sme_get_lim_sme_session_state
7353 (hHal, count)),
7354 mac_trace_get_lim_mlm_state
7355 (sme_get_lim_mlm_session_state
7356 (hHal, count))
7357 );
7358
7359 len += buf;
7360 check++;
7361 }
7362 count++;
7363 }
7364 }
7365
7366 wrqu->data.length = strlen(extra) + 1;
7367 break;
7368 }
7369
7370 case WE_GET_CFG:
7371 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007372 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007373 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
7374 extra,
7375 QCSAP_IOCTL_MAX_STR_LEN);
7376 wrqu->data.length = strlen(extra) + 1;
7377 break;
7378 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007379 case WE_GET_RSSI:
7380 {
7381 int8_t s7Rssi = 0;
7382 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7383 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7384 wrqu->data.length = strlen(extra) + 1;
7385 break;
7386 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007387
7388 case WE_GET_WMM_STATUS:
7389 {
7390 snprintf(extra, WE_MAX_STR_LEN,
7391 "\nDir: 0=up, 1=down, 3=both\n"
7392 "|------------------------|\n"
7393 "|AC | ACM |Admitted| Dir |\n"
7394 "|------------------------|\n"
7395 "|VO | %d | %3s | %d |\n"
7396 "|VI | %d | %3s | %d |\n"
7397 "|BE | %d | %3s | %d |\n"
7398 "|BK | %d | %3s | %d |\n"
7399 "|------------------------|\n",
7400 pAdapter->hddWmmStatus.
7401 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
7402 pAdapter->hddWmmStatus.
7403 wmmAcStatus[SME_AC_VO].
7404 wmmAcAccessAllowed ? "YES" : "NO",
7405 pAdapter->hddWmmStatus.
7406 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
7407 ts_info.direction,
7408 pAdapter->hddWmmStatus.
7409 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
7410 pAdapter->hddWmmStatus.
7411 wmmAcStatus[SME_AC_VI].
7412 wmmAcAccessAllowed ? "YES" : "NO",
7413 pAdapter->hddWmmStatus.
7414 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
7415 ts_info.direction,
7416 pAdapter->hddWmmStatus.
7417 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
7418 pAdapter->hddWmmStatus.
7419 wmmAcStatus[SME_AC_BE].
7420 wmmAcAccessAllowed ? "YES" : "NO",
7421 pAdapter->hddWmmStatus.
7422 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
7423 ts_info.direction,
7424 pAdapter->hddWmmStatus.
7425 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
7426 pAdapter->hddWmmStatus.
7427 wmmAcStatus[SME_AC_BK].
7428 wmmAcAccessAllowed ? "YES" : "NO",
7429 pAdapter->hddWmmStatus.
7430 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
7431 ts_info.direction);
7432
7433 wrqu->data.length = strlen(extra) + 1;
7434 break;
7435 }
7436 case WE_GET_CHANNEL_LIST:
7437 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307438 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007439 uint8_t i, len;
7440 char *buf;
7441 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
7442 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
7443 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7444
7445 tChannelListInfo channel_list;
7446
7447 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05307448 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007449 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307450 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007451 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007452 return -EINVAL;
7453 }
7454 buf = extra;
7455 /*
7456 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
7457 * Maximum buffer needed = 5 * number of channels.
7458 * Check ifsufficient buffer is available and then
7459 * proceed to fill the buffer.
7460 */
7461 if (WE_MAX_STR_LEN <
7462 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007463 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007464 return -EINVAL;
7465 }
7466 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7467 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307468 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007469 ubuf, &ubuf_len)) {
7470 /* Printing Country code in getChannelList */
7471 for (i = 0; i < (ubuf_len - 1); i++)
7472 len += scnprintf(buf + len,
7473 WE_MAX_STR_LEN - len,
7474 "%c", ubuf[i]);
7475 }
7476 for (i = 0; i < channel_list.num_channels; i++) {
7477 len +=
7478 scnprintf(buf + len, WE_MAX_STR_LEN - len,
7479 " %u", channel_list.channels[i]);
7480 }
7481 wrqu->data.length = strlen(extra) + 1;
7482
7483 break;
7484 }
7485#ifdef FEATURE_WLAN_TDLS
7486 case WE_GET_TDLS_PEERS:
7487 {
7488 wrqu->data.length =
7489 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
7490 WE_MAX_STR_LEN) + 1;
7491 break;
7492 }
7493#endif
7494#ifdef WLAN_FEATURE_11W
7495 case WE_GET_11W_INFO:
7496 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007497 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007498 pWextState->roamProfile.MFPEnabled);
7499
7500 snprintf(extra, WE_MAX_STR_LEN,
7501 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7502 "\n Number of Unprotected Disassocs %d"
7503 "\n Number of Unprotected Deauths %d",
7504 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
7505 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
7506 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
7507 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
7508 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
7509 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
7510 pWextState->roamProfile.MFPEnabled,
7511 pAdapter->hdd_stats.hddPmfStats.
7512 numUnprotDisassocRx,
7513 pAdapter->hdd_stats.hddPmfStats.
7514 numUnprotDeauthRx);
7515
7516 wrqu->data.length = strlen(extra) + 1;
7517 break;
7518 }
7519#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007520 case WE_GET_IBSS_STA_INFO:
7521 {
7522 hdd_station_ctx_t *pHddStaCtx =
7523 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7524 int idx = 0;
7525 int length = 0, buf = 0;
7526
Naveen Rawatc45d1622016-07-05 12:20:09 -07007527 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007528 if (0 != pHddStaCtx->conn_info.staId[idx]) {
7529 buf = snprintf
7530 ((extra + length),
7531 WE_MAX_STR_LEN - length,
7532 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7533 pHddStaCtx->conn_info.staId[idx],
7534 pHddStaCtx->conn_info.
7535 peerMacAddress[idx].bytes[0],
7536 pHddStaCtx->conn_info.
7537 peerMacAddress[idx].bytes[1],
7538 pHddStaCtx->conn_info.
7539 peerMacAddress[idx].bytes[2],
7540 pHddStaCtx->conn_info.
7541 peerMacAddress[idx].bytes[3],
7542 pHddStaCtx->conn_info.
7543 peerMacAddress[idx].bytes[4],
7544 pHddStaCtx->conn_info.
7545 peerMacAddress[idx].bytes[5]
7546 );
7547 length += buf;
7548 }
7549 }
7550 wrqu->data.length = strlen(extra) + 1;
7551 break;
7552 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007553 case WE_GET_PHYMODE:
7554 {
7555 bool ch_bond24 = false, ch_bond5g = false;
7556 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
7557 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7558 eCsrPhyMode phymode;
7559 eCsrBand currBand;
7560 tSmeConfigParams smeconfig;
7561
7562 sme_get_config_param(hal, &smeconfig);
7563 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7564 smeconfig.csrConfig.channelBondingMode24GHz)
7565 ch_bond24 = true;
7566
7567 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7568 smeconfig.csrConfig.channelBondingMode5GHz)
7569 ch_bond5g = true;
7570
7571 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307572 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007573 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007574 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007575 return -EIO;
7576 }
7577
7578 switch (phymode) {
7579 case eCSR_DOT11_MODE_AUTO:
7580 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
7581 break;
7582 case eCSR_DOT11_MODE_11n:
7583 case eCSR_DOT11_MODE_11n_ONLY:
7584 if (currBand == eCSR_BAND_24) {
7585 if (ch_bond24)
7586 snprintf(extra, WE_MAX_STR_LEN,
7587 "11NGHT40");
7588 else
7589 snprintf(extra, WE_MAX_STR_LEN,
7590 "11NGHT20");
7591 } else if (currBand == eCSR_BAND_5G) {
7592 if (ch_bond5g)
7593 snprintf(extra, WE_MAX_STR_LEN,
7594 "11NAHT40");
7595 else
7596 snprintf(extra, WE_MAX_STR_LEN,
7597 "11NAHT20");
7598 } else {
7599 snprintf(extra, WE_MAX_STR_LEN, "11N");
7600 }
7601 break;
7602 case eCSR_DOT11_MODE_abg:
7603 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
7604 break;
7605 case eCSR_DOT11_MODE_11a:
7606 snprintf(extra, WE_MAX_STR_LEN, "11A");
7607 break;
7608 case eCSR_DOT11_MODE_11b:
7609 case eCSR_DOT11_MODE_11b_ONLY:
7610 snprintf(extra, WE_MAX_STR_LEN, "11B");
7611 break;
7612 case eCSR_DOT11_MODE_11g:
7613 case eCSR_DOT11_MODE_11g_ONLY:
7614 snprintf(extra, WE_MAX_STR_LEN, "11G");
7615 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007616 case eCSR_DOT11_MODE_11ac:
7617 case eCSR_DOT11_MODE_11ac_ONLY:
7618 if (hddctx->config->vhtChannelWidth ==
7619 eHT_CHANNEL_WIDTH_20MHZ)
7620 snprintf(extra, WE_MAX_STR_LEN,
7621 "11ACVHT20");
7622 else if (hddctx->config->vhtChannelWidth ==
7623 eHT_CHANNEL_WIDTH_40MHZ)
7624 snprintf(extra, WE_MAX_STR_LEN,
7625 "11ACVHT40");
7626 else if (hddctx->config->vhtChannelWidth ==
7627 eHT_CHANNEL_WIDTH_80MHZ)
7628 snprintf(extra, WE_MAX_STR_LEN,
7629 "11ACVHT80");
7630 else if (hddctx->config->vhtChannelWidth ==
7631 eHT_CHANNEL_WIDTH_160MHZ)
7632 snprintf(extra, WE_MAX_STR_LEN,
7633 "11ACVHT160");
7634 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007635 }
7636
7637 wrqu->data.length = strlen(extra) + 1;
7638 break;
7639 }
7640
7641#ifdef FEATURE_OEM_DATA_SUPPORT
7642 case WE_GET_OEM_DATA_CAP:
7643 {
7644 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7645 }
7646#endif /* FEATURE_OEM_DATA_SUPPORT */
7647 case WE_GET_SNR:
7648 {
7649 int8_t s7snr = 0;
7650 int status = 0;
7651 hdd_context_t *pHddCtx;
7652 hdd_station_ctx_t *pHddStaCtx;
7653 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7654 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307655 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007656 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307657
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007658 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7659 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
7660 eConnectionState_Associated !=
7661 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007662 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007663 pHddCtx->config->fEnableSNRMonitoring,
7664 pHddStaCtx->conn_info.connState);
7665 return -ENONET;
7666 }
7667 wlan_hdd_get_snr(pAdapter, &s7snr);
7668 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
7669 wrqu->data.length = strlen(extra) + 1;
7670 break;
7671 }
7672 default:
7673 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007674 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007675 sub_cmd);
7676 break;
7677 }
7678 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307679 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007680 return 0;
7681}
7682
7683static int iw_get_char_setnone(struct net_device *dev,
7684 struct iw_request_info *info,
7685 union iwreq_data *wrqu, char *extra)
7686{
7687 int ret;
7688
7689 cds_ssr_protect(__func__);
7690 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7691 cds_ssr_unprotect(__func__);
7692
7693 return ret;
7694}
7695
7696/**
7697 * iw_setnone_getnone() - Generic "action" private ioctl handler
7698 * @dev: device upon which the ioctl was received
7699 * @info: ioctl request information
7700 * @wrqu: ioctl request data
7701 * @extra: ioctl extra data
7702 *
7703 * Return: 0 on success, non-zero on error
7704 */
7705static int __iw_setnone_getnone(struct net_device *dev,
7706 struct iw_request_info *info,
7707 union iwreq_data *wrqu, char *extra)
7708{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007709 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007710 hdd_context_t *hdd_ctx;
7711 int ret;
7712 int sub_cmd;
7713
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007714 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307715
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007716 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007717 ret = wlan_hdd_validate_context(hdd_ctx);
7718 if (0 != ret)
7719 return ret;
7720
7721#ifdef CONFIG_COMPAT
7722 /* this ioctl is a special case where a sub-ioctl is used and both
7723 * the number of get and set args is 0. in this specific case the
7724 * logic in iwpriv places the sub_cmd in the data.flags portion of
7725 * the iwreq. unfortunately the location of this field will be
7726 * different between 32-bit and 64-bit userspace, and the standard
7727 * compat support in the kernel does not handle this case. so we
7728 * need to explicitly handle it here.
7729 */
7730 if (is_compat_task()) {
7731 struct compat_iw_point *compat_iw_point =
7732 (struct compat_iw_point *)&wrqu->data;
7733 sub_cmd = compat_iw_point->flags;
7734 } else {
7735 sub_cmd = wrqu->data.flags;
7736 }
7737#else
7738 sub_cmd = wrqu->data.flags;
7739#endif
7740
7741 switch (sub_cmd) {
7742 case WE_GET_RECOVERY_STAT:
7743 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007744 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007745 sme_get_recovery_stats(hal);
7746 break;
7747 }
7748
Govind Singha471e5e2015-10-12 17:11:14 +05307749 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007750 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05307751 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
7752 0, DBG_CMD);
7753 break;
7754
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007755 case WE_IBSS_GET_PEER_INFO_ALL:
7756 {
7757 hdd_wlan_get_ibss_peer_info_all(adapter);
7758 break;
7759 }
7760
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007761 case WE_SET_REASSOC_TRIGGER:
7762 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007763 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7764 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307765 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007766 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307767 uint8_t operating_ch =
7768 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007769 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007770
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007771 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007772 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307773 if (roaming_offload_enabled(hdd_ctx)) {
7774 qdf_mem_copy(bssid,
7775 &adapter->sessionCtx.station.conn_info.bssId,
7776 sizeof(bssid));
7777 hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId,
7778 bssid, operating_ch);
7779 } else {
7780 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
7781 NULL, modProfileFields, &roamId, 1);
7782 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007783 return 0;
7784 }
7785
7786 case WE_DUMP_AGC_START:
7787 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007788 hdd_notice("WE_DUMP_AGC_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007789 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007790 GEN_PARAM_DUMP_AGC_START,
7791 0, GEN_CMD);
7792 break;
7793 }
7794 case WE_DUMP_AGC:
7795 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007796 hdd_notice("WE_DUMP_AGC");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007797 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007798 GEN_PARAM_DUMP_AGC,
7799 0, GEN_CMD);
7800 break;
7801 }
7802
7803 case WE_DUMP_CHANINFO_START:
7804 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007805 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007806 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007807 GEN_PARAM_DUMP_CHANINFO_START,
7808 0, GEN_CMD);
7809 break;
7810 }
7811 case WE_DUMP_CHANINFO:
7812 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007813 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007814 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007815 GEN_PARAM_DUMP_CHANINFO,
7816 0, GEN_CMD);
7817 break;
7818 }
7819 case WE_DUMP_WATCHDOG:
7820 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007821 hdd_notice("WE_DUMP_WATCHDOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007822 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007823 GEN_PARAM_DUMP_WATCHDOG,
7824 0, GEN_CMD);
7825 break;
7826 }
7827#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
7828 case WE_DUMP_PCIE_LOG:
7829 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007830 hdd_err("WE_DUMP_PCIE_LOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007831 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007832 GEN_PARAM_DUMP_PCIE_ACCESS_LOG,
7833 0, GEN_CMD);
7834 break;
7835 }
7836#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007837 case WE_STOP_OBSS_SCAN:
7838 {
7839 /*
7840 * 1.OBSS Scan is mandatory while operating in 2.4GHz
7841 * 2.OBSS scan is stopped by Firmware during the disassociation
7842 * 3.OBSS stop comamnd is added for debugging purpose
7843 */
7844 tHalHandle hal;
7845
7846 hal = WLAN_HDD_GET_HAL_CTX(adapter);
7847 if (hal == NULL) {
7848 hdd_err("hal context is NULL");
7849 return -EINVAL;
7850 }
7851 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
7852 }
7853 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007854 default:
7855 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007856 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007857 break;
7858 }
7859 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307860 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007861 return ret;
7862}
7863
7864static int iw_setnone_getnone(struct net_device *dev,
7865 struct iw_request_info *info,
7866 union iwreq_data *wrqu, char *extra)
7867{
7868 int ret;
7869
7870 cds_ssr_protect(__func__);
7871 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7872 cds_ssr_unprotect(__func__);
7873
7874 return ret;
7875}
7876
7877/**
7878 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
7879 * @dev: device upon which the ioctl was received
7880 * @info: ioctl request information
7881 * @wrqu: ioctl request data
7882 * @extra: ioctl extra data
7883 *
7884 * This is an SSR-protected generic handler for private ioctls which
7885 * take multiple arguments. Note that this implementation is also
7886 * somewhat unique in that it is shared by both STA-mode and SAP-mode
7887 * interfaces.
7888 *
7889 * Return: 0 on success, non-zero on error
7890 */
7891static int __iw_set_var_ints_getnone(struct net_device *dev,
7892 struct iw_request_info *info,
7893 union iwreq_data *wrqu, char *extra)
7894{
7895 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7896 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7897 int sub_cmd;
7898 int *apps_args = (int *) extra;
7899 hdd_context_t *hdd_ctx;
7900 int ret, num_args;
7901
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007902 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307903
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007904 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7905 ret = wlan_hdd_validate_context(hdd_ctx);
7906 if (0 != ret)
7907 return ret;
7908
7909 if (extra == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007910 hdd_err("NULL extra buffer pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007911 return -EINVAL;
7912 }
7913
7914 sub_cmd = wrqu->data.flags;
7915 num_args = wrqu->data.length;
7916
Jeff Johnson99bac312016-06-28 10:38:18 -07007917 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007918
7919 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007920 case WE_IBSS_GET_PEER_INFO:
7921 {
7922 pr_info("Station ID = %d\n", apps_args[0]);
7923 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7924 }
7925 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007926
7927 case WE_P2P_NOA_CMD:
7928 {
7929 p2p_app_setP2pPs_t p2pNoA;
7930
Krunal Sonif07bb382016-03-10 13:02:11 -08007931 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08007932 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
7933 hdd_device_mode_to_string(
7934 pAdapter->device_mode),
7935 pAdapter->device_mode);
7936 return -EINVAL;
7937 }
7938
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007939 p2pNoA.opp_ps = apps_args[0];
7940 p2pNoA.ctWindow = apps_args[1];
7941 p2pNoA.duration = apps_args[2];
7942 p2pNoA.interval = apps_args[3];
7943 p2pNoA.count = apps_args[4];
7944 p2pNoA.single_noa_duration = apps_args[5];
7945 p2pNoA.psSelection = apps_args[6];
7946
Jeff Johnson99bac312016-06-28 10:38:18 -07007947 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
7948 apps_args[0], apps_args[1], apps_args[2],
7949 apps_args[3], apps_args[4],
7950 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007951
7952 hdd_set_p2p_ps(dev, &p2pNoA);
7953
7954 }
7955 break;
7956
7957 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7958 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007959 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7960 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307961 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007962 }
7963 break;
7964
7965 case WE_MTRACE_DUMP_CMD:
7966 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007967 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
7968 apps_args[0], apps_args[1],
7969 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307970 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007971 apps_args[1], apps_args[2],
7972 apps_args[3]);
7973
7974 }
7975 break;
7976
7977 case WE_POLICY_MANAGER_CLIST_CMD:
7978 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007979 hdd_err("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007980 cds_incr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007981 apps_args[1], apps_args[2], apps_args[3],
7982 apps_args[4], apps_args[5], apps_args[6],
7983 apps_args[7]);
7984 }
7985 break;
7986
7987 case WE_POLICY_MANAGER_DLIST_CMD:
7988 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007989 hdd_err("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007990 cds_decr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007991 apps_args[1]);
7992 }
7993 break;
7994
7995 case WE_POLICY_MANAGER_ULIST_CMD:
7996 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007997 hdd_err("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007998 cds_update_connection_info_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007999 apps_args[1], apps_args[2], apps_args[3],
8000 apps_args[4], apps_args[5], apps_args[6],
8001 apps_args[7]);
8002 }
8003 break;
8004
8005 case WE_POLICY_MANAGER_DBS_CMD:
8006 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008007 hdd_err("<iwpriv wlan0 pm_dbs> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008008 if (apps_args[0] == 0)
8009 wma_set_dbs_capability_ut(0);
8010 else
8011 wma_set_dbs_capability_ut(1);
8012
8013 if (apps_args[1] >= CDS_THROUGHPUT &&
8014 apps_args[1] <= CDS_LATENCY) {
8015 pr_info("setting system pref to [%d]\n", apps_args[1]);
8016 hdd_ctx->config->conc_system_pref = apps_args[1];
8017 }
8018 }
8019 break;
8020
8021 case WE_POLICY_MANAGER_PCL_CMD:
8022 {
Manishekar Chandrasekaran1db3abe2016-06-24 03:27:07 +05308023 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8024 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008025 uint32_t pcl_len = 0, i = 0;
8026
Jeff Johnson99bac312016-06-28 10:38:18 -07008027 hdd_err("<iwpriv wlan0 pm_pcl> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008028
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008029 cds_get_pcl(apps_args[0],
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308030 pcl, &pcl_len,
8031 weight_list, QDF_ARRAY_SIZE(weight_list));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008032 pr_info("PCL list for role[%d] is {", apps_args[0]);
8033 for (i = 0 ; i < pcl_len; i++)
8034 pr_info(" %d, ", pcl[i]);
8035 pr_info("}--------->\n");
8036 }
8037 break;
8038
8039 case WE_POLICY_MANAGER_CINFO_CMD:
8040 {
8041 struct cds_conc_connection_info *conn_info;
8042 uint32_t i = 0, len = 0;
8043
Jeff Johnson99bac312016-06-28 10:38:18 -07008044 hdd_err("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008045 conn_info = cds_get_conn_info(&len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008046 pr_info("+-----------------------------+\n");
8047 for (i = 0; i < len; i++) {
8048 pr_info("|table_index[%d]\t\t|\n", i);
8049 pr_info("|\t|vdev_id - %d\t\t|\n", conn_info->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008050 pr_info("|\t|chan - %d\t\t|\n", conn_info->chan);
Tushnim Bhattacharyya7624a182016-03-30 13:30:46 -07008051 pr_info("|\t|bw - %d\t\t|\n", conn_info->bw);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008052 pr_info("|\t|mode - %d\t\t|\n", conn_info->mode);
8053 pr_info("|\t|mac - %d\t\t|\n", conn_info->mac);
8054 pr_info("|\t|in_use - %d\t\t|\n", conn_info->in_use);
8055 pr_info("+-----------------------------+\n");
8056 conn_info++;
8057 }
8058 }
8059 break;
8060
8061 case WE_POLICY_SET_HW_MODE_CMD:
8062 {
8063 if (apps_args[0] == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008064 hdd_err("set hw mode for single mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308065 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308066 pAdapter->sessionId,
8067 HW_MODE_SS_2x2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008068 HW_MODE_80_MHZ,
8069 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8070 HW_MODE_DBS_NONE,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308071 HW_MODE_AGILE_DFS_NONE,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05308072 HW_MODE_SBS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308073 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008074 } else if (apps_args[0] == 1) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008075 hdd_err("set hw mode for dual mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308076 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308077 pAdapter->sessionId,
8078 HW_MODE_SS_1x1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008079 HW_MODE_80_MHZ,
8080 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8081 HW_MODE_DBS,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308082 HW_MODE_AGILE_DFS_NONE,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05308083 HW_MODE_SBS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308084 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008085 }
8086 }
8087 break;
8088
8089 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8090 {
8091 enum cds_conc_next_action action;
Jeff Johnson99bac312016-06-28 10:38:18 -07008092 hdd_err("<iwpriv wlan0 pm_query_action> is called");
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308093 action = cds_current_connections_update(pAdapter->sessionId,
8094 apps_args[0],
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308095 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008096 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8097 }
8098 break;
8099 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8100 {
8101 bool allow;
Jeff Johnson99bac312016-06-28 10:38:18 -07008102 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008103 allow = cds_allow_concurrency(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008104 apps_args[0], apps_args[1], apps_args[2]);
8105 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8106 }
8107 break;
8108
8109 case WE_POLICY_MANAGER_SCENARIO_CMD:
8110 {
8111 clean_report(hdd_ctx);
8112 if (apps_args[0] == 1) {
8113 wlan_hdd_one_connection_scenario(hdd_ctx);
8114 } else if (apps_args[0] == 2) {
8115 wlan_hdd_two_connections_scenario(hdd_ctx,
8116 6, CDS_TWO_TWO);
8117 wlan_hdd_two_connections_scenario(hdd_ctx,
8118 36, CDS_TWO_TWO);
8119 wlan_hdd_two_connections_scenario(hdd_ctx,
8120 6, CDS_ONE_ONE);
8121 wlan_hdd_two_connections_scenario(hdd_ctx,
8122 36, CDS_ONE_ONE);
8123 } else if (apps_args[0] == 3) {
8124 /* MCC on same band with 2x2 same mac*/
8125 wlan_hdd_three_connections_scenario(hdd_ctx,
8126 6, 11, CDS_TWO_TWO, 0);
8127 /* MCC on diff band with 2x2 same mac*/
8128 wlan_hdd_three_connections_scenario(hdd_ctx,
8129 6, 36, CDS_TWO_TWO, 0);
8130 /* MCC on diff band with 1x1 diff mac */
8131 wlan_hdd_three_connections_scenario(hdd_ctx,
8132 36, 6, CDS_ONE_ONE, 0);
8133 /* MCC on diff band with 1x1 same mac */
8134 wlan_hdd_three_connections_scenario(hdd_ctx,
8135 36, 6, CDS_ONE_ONE, 1);
8136 /* SCC on same band with 2x2 same mac */
8137 wlan_hdd_three_connections_scenario(hdd_ctx,
8138 36, 36, CDS_TWO_TWO, 0);
8139 /* SCC on same band with 1x1 same mac */
8140 wlan_hdd_three_connections_scenario(hdd_ctx,
8141 36, 36, CDS_ONE_ONE, 1);
8142 /* MCC on same band with 2x2 same mac */
8143 wlan_hdd_three_connections_scenario(hdd_ctx,
8144 36, 149, CDS_TWO_TWO, 0);
8145 /* MCC on same band with 1x1 same mac */
8146 wlan_hdd_three_connections_scenario(hdd_ctx,
8147 36, 149, CDS_ONE_ONE, 1);
8148 }
8149 print_report(hdd_ctx);
8150 }
8151 break;
8152
8153#ifdef FEATURE_WLAN_TDLS
8154 case WE_TDLS_CONFIG_PARAMS:
8155 {
8156 tdls_config_params_t tdlsParams;
8157
8158 tdlsParams.tdls = apps_args[0];
8159 tdlsParams.tx_period_t = apps_args[1];
8160 tdlsParams.tx_packet_n = apps_args[2];
8161 /* ignore args[3] as discovery_period is not used anymore */
8162 tdlsParams.discovery_tries_n = apps_args[4];
8163 /* ignore args[5] as idle_timeout is not used anymore */
8164 tdlsParams.idle_packet_n = apps_args[6];
8165 /* ignore args[7] as rssi_hysteresis is not used anymore */
8166 tdlsParams.rssi_trigger_threshold = apps_args[8];
8167 tdlsParams.rssi_teardown_threshold = apps_args[9];
8168 tdlsParams.rssi_delta = apps_args[10];
8169
8170 wlan_hdd_tdls_set_params(dev, &tdlsParams);
8171 }
8172 break;
8173#endif
8174 case WE_UNIT_TEST_CMD:
8175 {
8176 t_wma_unit_test_cmd *unitTestArgs;
8177 cds_msg_t msg = { 0 };
8178 int i, j;
8179 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8180 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008181 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008182 apps_args[0]);
8183 return -EINVAL;
8184 }
Anurag Chouhan77564182016-09-03 16:38:01 +05308185 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
8186 (apps_args[1] < 0)) {
8187 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008188 apps_args[1]);
8189 return -EINVAL;
8190 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308191 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008192 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008193 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008194 return -ENOMEM;
8195 }
8196 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
8197 unitTestArgs->module_id = apps_args[0];
8198 unitTestArgs->num_args = apps_args[1];
8199 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
8200 unitTestArgs->args[i] = apps_args[j];
8201 }
8202 msg.type = SIR_HAL_UNIT_TEST_CMD;
8203 msg.reserved = 0;
8204 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308205 if (QDF_STATUS_SUCCESS !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05308206 cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308207 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -07008208 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008209 return -EINVAL;
8210 }
8211 }
8212 break;
8213#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8214 case WE_LED_FLASHING_PARAM:
8215 {
8216 int i;
8217 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008218 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008219 return -EINVAL;
8220 }
8221 for (i = 0; i < num_args; i++) {
8222 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008223 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008224 return -EINVAL;
8225 }
8226 }
8227 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8228 0, apps_args[0], apps_args[1]);
8229 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8230 1, apps_args[2], apps_args[3]);
8231 }
8232 break;
8233#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05308234 case WE_SET_PKTLOG:
8235 {
8236 int ret;
8237
8238 if (num_args < 1 || num_args > 2) {
8239 hdd_err("pktlog: either 1 or 2 parameters are required");
8240 return -EINVAL;
8241 }
8242
8243 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
8244 apps_args[1]);
8245 if (ret)
8246 return ret;
8247 break;
8248 }
8249
Manjeet Singhf82ed072016-07-08 11:40:00 +05308250 case WE_MAC_PWR_DEBUG_CMD:
8251 {
8252 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
8253 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8254 int i, j;
8255
8256 if (num_args < 3) {
8257 hdd_err("number of arguments can't be null %d",
8258 num_args);
8259 return -EINVAL;
8260 }
8261 if (num_args - 3 != apps_args[2]) {
8262 hdd_err("arg list of size %d doesn't match num_args %d",
8263 num_args-3, apps_args[2]);
8264 return -EINVAL;
8265 }
8266 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8267 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8268 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8269 return -EINVAL;
8270 }
8271 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8272 hdd_err("Too Many args %d", apps_args[2]);
8273 return -EINVAL;
8274 }
8275 mac_pwr_dbg_args.pdev_id = apps_args[0];
8276 mac_pwr_dbg_args.module_id = apps_args[1];
8277 mac_pwr_dbg_args.num_args = apps_args[2];
8278
8279 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8280 mac_pwr_dbg_args.args[i] = apps_args[j];
8281
8282 if (QDF_STATUS_SUCCESS !=
8283 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
8284 &mac_pwr_dbg_args)) {
8285 return -EINVAL;
8286 }
8287 }
8288 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008289 default:
8290 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008291 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008292 }
8293 break;
8294 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308295 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008296 return 0;
8297}
8298
8299/**
8300 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8301 * @dev: pointer to net_device structure
8302 * @info: pointer to iw_request_info structure
8303 * @wrqu: pointer to iwreq_data
8304 * @extra; extra
8305 *
8306 * Return: 0 on success, error number otherwise
8307 *
8308 */
8309static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8310 struct iw_request_info *info,
8311 union iwreq_data *wrqu, char *extra)
8312{
8313 union iwreq_data u_priv_wrqu;
8314 int apps_args[MAX_VAR_ARGS] = {0};
8315 int ret, num_args;
8316
Mukul Sharma64a70e82015-11-02 20:05:09 +05308317 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008318 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308319 return -EPERM;
8320 }
8321
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008322 /* Helper function to get iwreq_data with compat handling. */
8323 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8324 return -EINVAL;
8325
8326 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008327 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008328 return -EINVAL;
8329 }
8330
8331 num_args = u_priv_wrqu.data.length;
8332 if (num_args > MAX_VAR_ARGS)
8333 num_args = MAX_VAR_ARGS;
8334
8335 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8336 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008337 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008338 return -EFAULT;
8339 }
8340
8341 cds_ssr_protect(__func__);
8342 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8343 (char *)&apps_args);
8344 cds_ssr_unprotect(__func__);
8345 return ret;
8346}
8347
8348/**
8349 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8350 * @dev: device upon which the ioctl was received
8351 * @info: ioctl request information
8352 * @wrqu: ioctl request data
8353 * @extra: ioctl extra data
8354 *
8355 * This is a generic handler for private ioctls which take multiple
8356 * arguments. Note that this implementation is also somewhat unique
8357 * in that it is shared by both STA-mode and SAP-mode interfaces.
8358 *
8359 * Return: 0 on success, non-zero on error
8360 */
8361int iw_set_var_ints_getnone(struct net_device *dev,
8362 struct iw_request_info *info,
8363 union iwreq_data *wrqu, char *extra)
8364{
8365 int ret;
8366
8367 cds_ssr_protect(__func__);
8368 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8369 cds_ssr_unprotect(__func__);
8370 return ret;
8371}
8372
8373/**
8374 * iw_add_tspec - Add TSpec private ioctl handler
8375 * @dev: device upon which the ioctl was received
8376 * @info: ioctl request information
8377 * @wrqu: ioctl request data
8378 * @extra: ioctl extra data
8379 *
8380 * Return: 0 on success, non-zero on error
8381 */
8382static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
8383 union iwreq_data *wrqu, char *extra)
8384{
8385 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8386 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8387 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8388 int params[HDD_WLAN_WMM_PARAM_COUNT];
8389 sme_QosWmmTspecInfo tSpec;
8390 uint32_t handle;
8391 struct iw_point s_priv_data;
8392 hdd_context_t *hdd_ctx;
8393 int ret;
8394
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008395 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308396
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008397 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8398 ret = wlan_hdd_validate_context(hdd_ctx);
8399 if (0 != ret)
8400 return ret;
8401
8402 /* make sure the application is sufficiently priviledged */
8403 /* note that the kernel will do this for "set" ioctls, but since */
8404 /* this ioctl wants to return status to user space it must be */
8405 /* defined as a "get" ioctl */
8406 if (!capable(CAP_NET_ADMIN)) {
8407 return -EPERM;
8408 }
8409
8410 /* we must be associated in order to add a tspec */
8411 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
8412 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8413 return 0;
8414 }
8415 /* since we are defined to be a "get" ioctl, and since the number */
8416 /* of params exceeds the number of params that wireless extensions */
8417 /* will pass down in the iwreq_data, we must copy the "set" params. */
8418 /* We must handle the compat for iwreq_data in 32U/64K environment. */
8419
8420 /* helper function to get iwreq_data with compat handling. */
8421 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8422 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8423 return 0;
8424 }
8425 /* make sure all params are correctly passed to function */
8426 if ((NULL == s_priv_data.pointer) ||
8427 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
8428 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8429 return 0;
8430 }
8431 /* from user space ourselves */
8432 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
8433 /* hmmm, can't get them */
8434 return -EIO;
8435 }
8436 /* clear the tspec */
8437 memset(&tSpec, 0, sizeof(tSpec));
8438
8439 /* validate the handle */
8440 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8441 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8442 /* that one is reserved */
8443 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8444 return 0;
8445 }
8446 /* validate the TID */
8447 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
8448 /* out of range */
8449 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8450 return 0;
8451 }
8452 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8453
8454 /* validate the direction */
8455 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
8456 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8457 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8458 break;
8459
8460 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8461 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8462 break;
8463
8464 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8465 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8466 break;
8467
8468 default:
8469 /* unknown */
8470 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8471 return 0;
8472 }
8473
8474 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8475
8476 /* validate the user priority */
8477 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
8478 /* out of range */
8479 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8480 return 0;
8481 }
8482 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
8483 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008484 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008485 return 0;
8486 }
8487
Jeff Johnson99bac312016-06-28 10:38:18 -07008488 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008489 tSpec.ts_info.psb, tSpec.ts_info.up);
8490
8491 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8492 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8493 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8494 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8495 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8496 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8497 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8498 tSpec.surplus_bw_allowance =
8499 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8500 tSpec.min_service_interval =
8501 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8502 tSpec.max_service_interval =
8503 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8504 tSpec.suspension_interval =
8505 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8506 tSpec.inactivity_interval =
8507 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8508
8509 tSpec.ts_info.burst_size_defn =
8510 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8511
8512 /* validate the ts info ack policy */
8513 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
8514 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8515 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8516 break;
8517
8518 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8519 tSpec.ts_info.ack_policy =
8520 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8521 break;
8522
8523 default:
8524 /* unknown */
8525 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8526 return 0;
8527 }
8528
8529 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308530 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008531 return 0;
8532}
8533
8534static int iw_add_tspec(struct net_device *dev,
8535 struct iw_request_info *info,
8536 union iwreq_data *wrqu, char *extra)
8537{
8538 int ret;
8539
8540 cds_ssr_protect(__func__);
8541 ret = __iw_add_tspec(dev, info, wrqu, extra);
8542 cds_ssr_unprotect(__func__);
8543
8544 return ret;
8545}
8546
8547/**
8548 * iw_del_tspec - Delete TSpec private ioctl handler
8549 * @dev: device upon which the ioctl was received
8550 * @info: ioctl request information
8551 * @wrqu: ioctl request data
8552 * @extra: ioctl extra data
8553 *
8554 * Return: 0 on success, non-zero on error
8555 */
8556static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
8557 union iwreq_data *wrqu, char *extra)
8558{
8559 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8560 hdd_context_t *hdd_ctx;
8561 int *params = (int *)extra;
8562 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8563 uint32_t handle;
8564 int ret;
8565
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008566 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308567
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008568 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8569 ret = wlan_hdd_validate_context(hdd_ctx);
8570 if (0 != ret)
8571 return ret;
8572
8573 /* make sure the application is sufficiently priviledged */
8574 /* note that the kernel will do this for "set" ioctls, but since */
8575 /* this ioctl wants to return status to user space it must be */
8576 /* defined as a "get" ioctl */
8577 if (!capable(CAP_NET_ADMIN)) {
8578 return -EPERM;
8579 }
8580
8581 /* although we are defined to be a "get" ioctl, the params we require */
8582 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8583 /* is no need to copy the params from user space */
8584
8585 /* validate the handle */
8586 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8587 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8588 /* that one is reserved */
8589 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8590 return 0;
8591 }
8592
8593 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308594 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008595 return 0;
8596}
8597
8598static int iw_del_tspec(struct net_device *dev,
8599 struct iw_request_info *info,
8600 union iwreq_data *wrqu, char *extra)
8601{
8602 int ret;
8603
8604 cds_ssr_protect(__func__);
8605 ret = __iw_del_tspec(dev, info, wrqu, extra);
8606 cds_ssr_unprotect(__func__);
8607
8608 return ret;
8609}
8610
8611/**
8612 * iw_get_tspec - Get TSpec private ioctl handler
8613 * @dev: device upon which the ioctl was received
8614 * @info: ioctl request information
8615 * @wrqu: ioctl request data
8616 * @extra: ioctl extra data
8617 *
8618 * Return: 0 on success, non-zero on error
8619 */
8620static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
8621 union iwreq_data *wrqu, char *extra)
8622{
8623 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8624 hdd_context_t *hdd_ctx;
8625 int *params = (int *)extra;
8626 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8627 uint32_t handle;
8628 int ret;
8629
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008630 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008632 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8633 ret = wlan_hdd_validate_context(hdd_ctx);
8634 if (0 != ret)
8635 return ret;
8636
8637 /* although we are defined to be a "get" ioctl, the params we require */
8638 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8639 /* is no need to copy the params from user space */
8640
8641 /* validate the handle */
8642 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8643 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8644 /* that one is reserved */
8645 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8646 return 0;
8647 }
8648
8649 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308650 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008651 return 0;
8652}
8653
8654static int iw_get_tspec(struct net_device *dev,
8655 struct iw_request_info *info,
8656 union iwreq_data *wrqu, char *extra)
8657{
8658 int ret;
8659
8660 cds_ssr_protect(__func__);
8661 ret = __iw_get_tspec(dev, info, wrqu, extra);
8662 cds_ssr_unprotect(__func__);
8663
8664 return ret;
8665}
8666
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008667/**
8668 * iw_set_fties - Set FT IEs private ioctl handler
8669 * @dev: device upon which the ioctl was received
8670 * @info: ioctl request information
8671 * @wrqu: ioctl request data
8672 * @extra: ioctl extra data
8673 *
8674 * Each time the supplicant has the auth_request or reassoc request
8675 * IEs ready they are pushed to the driver. The driver will in turn
8676 * use it to send out the auth req and reassoc req for 11r FT Assoc.
8677 *
8678 * Return: 0 on success, non-zero on error
8679 */
8680static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
8681 union iwreq_data *wrqu, char *extra)
8682{
8683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8684 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8685 hdd_context_t *hdd_ctx;
8686 int ret;
8687
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008688 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308689
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008690 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8691 ret = wlan_hdd_validate_context(hdd_ctx);
8692 if (0 != ret)
8693 return ret;
8694
8695 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008696 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008697 return -EINVAL;
8698 }
8699 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008700 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008701 return -EINVAL;
8702 }
8703 /* Added for debug on reception of Re-assoc Req. */
8704 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008705 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008706 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -07008707 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008708 }
Jeff Johnson99bac312016-06-28 10:38:18 -07008709 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008710
8711 /* Pass the received FT IEs to SME */
8712 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8713 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308714 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008715 return 0;
8716}
8717
8718static int iw_set_fties(struct net_device *dev,
8719 struct iw_request_info *info,
8720 union iwreq_data *wrqu, char *extra)
8721{
8722 int ret;
8723
8724 cds_ssr_protect(__func__);
8725 ret = __iw_set_fties(dev, info, wrqu, extra);
8726 cds_ssr_unprotect(__func__);
8727
8728 return ret;
8729}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008730
8731/**
8732 * iw_set_host_offload - Set host offload ioctl handler
8733 * @dev: device upon which the ioctl was received
8734 * @info: ioctl request information
8735 * @wrqu: ioctl request data
8736 * @extra: ioctl extra data
8737 *
8738 * Return: 0 on success, non-zero on error
8739 */
8740static int __iw_set_host_offload(struct net_device *dev,
8741 struct iw_request_info *info,
8742 union iwreq_data *wrqu, char *extra)
8743{
8744 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8745 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
8746 tSirHostOffloadReq offloadRequest;
8747 hdd_context_t *hdd_ctx;
8748 int ret;
8749
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008750 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308751
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008752 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8753 ret = wlan_hdd_validate_context(hdd_ctx);
8754 if (0 != ret)
8755 return ret;
8756
8757 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008758 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008759 return -EINVAL;
8760 }
8761
8762 /* Debug display of request components. */
8763 switch (pRequest->offloadType) {
8764 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008765 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008766 switch (pRequest->enableOrDisable) {
8767 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008768 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008769 break;
8770 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008771 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008772 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008773 hdd_warn(" ARP offload enable");
8774 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008775 pRequest->params.hostIpv4Addr[0],
8776 pRequest->params.hostIpv4Addr[1],
8777 pRequest->params.hostIpv4Addr[2],
8778 pRequest->params.hostIpv4Addr[3]);
8779 }
8780 break;
8781
8782 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008783 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008784 switch (pRequest->enableOrDisable) {
8785 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008786 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008787 break;
8788 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008789 hdd_info(" enable");
8790 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008791 *(uint16_t *) (pRequest->params.hostIpv6Addr),
8792 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8793 2),
8794 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8795 4),
8796 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8797 6),
8798 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8799 8),
8800 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8801 10),
8802 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8803 12),
8804 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8805 14));
8806 }
8807 }
8808
8809 /* Execute offload request. The reason that we can copy the
8810 * request information from the ioctl structure to the SME
8811 * structure is that they are laid out exactly the same.
8812 * Otherwise, each piece of information would have to be
8813 * copied individually.
8814 */
8815 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308816 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008817 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8818 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008819 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008820 return -EINVAL;
8821 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308822 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008823 return 0;
8824}
8825
8826static int iw_set_host_offload(struct net_device *dev,
8827 struct iw_request_info *info,
8828 union iwreq_data *wrqu, char *extra)
8829{
8830 int ret;
8831
8832 cds_ssr_protect(__func__);
8833 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8834 cds_ssr_unprotect(__func__);
8835
8836 return ret;
8837}
8838
8839/**
8840 * iw_set_keepalive_params - Set keepalive params ioctl handler
8841 * @dev: device upon which the ioctl was received
8842 * @info: ioctl request information
8843 * @wrqu: ioctl request data
8844 * @extra: ioctl extra data
8845 *
8846 * Return: 0 on success, non-zero on error
8847 */
8848static int __iw_set_keepalive_params(struct net_device *dev,
8849 struct iw_request_info *info,
8850 union iwreq_data *wrqu, char *extra)
8851{
8852 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008853 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008854 hdd_context_t *hdd_ctx;
8855 int ret;
8856
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008857 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308858
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008859 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8860 ret = wlan_hdd_validate_context(hdd_ctx);
8861 if (0 != ret)
8862 return ret;
8863
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008864 if (wrqu->data.length != sizeof(*request)) {
8865 hdd_err("Invalid length %d", wrqu->data.length);
8866 return -EINVAL;
8867 }
8868
8869 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
8870 hdd_err("Value of timePeriod %d exceed Max limit %d",
8871 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008872 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
8873 return -EINVAL;
8874 }
8875
8876 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008877 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
8878 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008879
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008880 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008881 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008882 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008883 break;
8884
8885 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008886 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008887
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008888 hdd_info("Host IP address: %d.%d.%d.%d",
8889 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
8890 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008891
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008892 hdd_info("Dest IP address: %d.%d.%d.%d",
8893 request->destIpv4Addr[0], request->destIpv4Addr[1],
8894 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008895
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08008896 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
8897 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008898 break;
8899 }
8900
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008901 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008902
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308903 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008904 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008905 pAdapter->sessionId, request)) {
8906 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008907 return -EINVAL;
8908 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308909 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008910 return 0;
8911}
8912
8913static int iw_set_keepalive_params(struct net_device *dev,
8914 struct iw_request_info *info,
8915 union iwreq_data *wrqu,
8916 char *extra)
8917{
8918 int ret;
8919
8920 cds_ssr_protect(__func__);
8921 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8922 cds_ssr_unprotect(__func__);
8923
8924 return ret;
8925}
8926
8927#ifdef WLAN_FEATURE_PACKET_FILTERING
8928/**
8929 * wlan_hdd_set_filter() - Set packet filter
8930 * @hdd_ctx: Global HDD context
8931 * @request: Packet filter request struct
8932 * @sessionId: Target session for the request
8933 *
8934 * Return: 0 on success, non-zero on error
8935 */
8936static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
8937 struct pkt_filter_cfg *request,
8938 uint8_t sessionId)
8939{
8940 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8941 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8942 int i = 0;
8943
8944 if (hdd_ctx->config->disablePacketFilter) {
8945 hdd_err("packet filtering disabled in ini returning");
8946 return 0;
8947 }
8948
8949 /* Debug display of request components. */
8950 hdd_info("Packet Filter Request : FA %d params %d",
8951 request->filter_action, request->num_params);
8952
8953 switch (request->filter_action) {
8954 case HDD_RCV_FILTER_SET:
8955 hdd_info("Set Packet Filter Request for Id: %d",
8956 request->filter_id);
8957
8958 packetFilterSetReq.filterId = request->filter_id;
8959 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
8960 hdd_err("Number of Params exceed Max limit %d",
8961 request->num_params);
8962 return -EINVAL;
8963 }
8964 packetFilterSetReq.numFieldParams = request->num_params;
8965 packetFilterSetReq.coalesceTime = 0;
8966 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8967 for (i = 0; i < request->num_params; i++) {
8968 packetFilterSetReq.paramsData[i].protocolLayer =
8969 request->params_data[i].protocol_layer;
8970 packetFilterSetReq.paramsData[i].cmpFlag =
8971 request->params_data[i].compare_flag;
8972 packetFilterSetReq.paramsData[i].dataOffset =
8973 request->params_data[i].data_offset;
8974 packetFilterSetReq.paramsData[i].dataLength =
8975 request->params_data[i].data_length;
8976 packetFilterSetReq.paramsData[i].reserved = 0;
8977
8978 if (request->params_data[i].data_length >
8979 SIR_MAX_FILTER_TEST_DATA_LEN) {
8980 hdd_err("Error invalid data length %d",
8981 request->params_data[i].data_length);
8982 return -EINVAL;
8983 }
8984
8985 hdd_info("Proto %d Comp Flag %d Filter Type %d",
8986 request->params_data[i].protocol_layer,
8987 request->params_data[i].compare_flag,
8988 packetFilterSetReq.filterType);
8989
8990 hdd_info("Data Offset %d Data Len %d",
8991 request->params_data[i].data_offset,
8992 request->params_data[i].data_length);
8993
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07008994 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
8995 < (request->params_data[i].data_length)) {
8996 hdd_err("Error invalid data length %d",
8997 request->params_data[i].data_length);
8998 return -EINVAL;
8999 }
9000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009001 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9002 request->params_data[i].compare_data,
9003 request->params_data[i].data_length);
9004 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9005 request->params_data[i].data_mask,
9006 request->params_data[i].data_length);
9007
9008 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
9009 request->params_data[i].compare_data[0],
9010 request->params_data[i].compare_data[1],
9011 request->params_data[i].compare_data[2],
9012 request->params_data[i].compare_data[3],
9013 request->params_data[i].compare_data[4],
9014 request->params_data[i].compare_data[5]);
9015
9016 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
9017 request->params_data[i].data_mask[0],
9018 request->params_data[i].data_mask[1],
9019 request->params_data[i].data_mask[2],
9020 request->params_data[i].data_mask[3],
9021 request->params_data[i].data_mask[4],
9022 request->params_data[i].data_mask[5]);
9023 }
9024
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309025 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009026 sme_receive_filter_set_filter(hdd_ctx->hHal,
9027 &packetFilterSetReq,
9028 sessionId)) {
9029 hdd_err("Failure to execute Set Filter");
9030 return -EINVAL;
9031 }
9032
9033 break;
9034
9035 case HDD_RCV_FILTER_CLEAR:
9036
9037 hdd_info("Clear Packet Filter Request for Id: %d",
9038 request->filter_id);
9039 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309040 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009041 sme_receive_filter_clear_filter(hdd_ctx->hHal,
9042 &packetFilterClrReq,
9043 sessionId)) {
9044 hdd_err("Failure to execute Clear Filter");
9045 return -EINVAL;
9046 }
9047 break;
9048
9049 default:
9050 hdd_err("Packet Filter Request: Invalid %d",
9051 request->filter_action);
9052 return -EINVAL;
9053 }
9054 return 0;
9055}
9056
9057/**
9058 * __iw_set_packet_filter_params() - set packet filter parameters in target
9059 * @dev: Pointer to netdev
9060 * @info: Pointer to iw request info
9061 * @wrqu: Pointer to data
9062 * @extra: Pointer to extra data
9063 *
9064 * Return: 0 on success, non-zero on error
9065 */
9066static int __iw_set_packet_filter_params(struct net_device *dev,
9067 struct iw_request_info *info,
9068 union iwreq_data *wrqu, char *extra)
9069{
9070 int ret;
9071 hdd_context_t *hdd_ctx;
9072 struct iw_point priv_data;
9073 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9074 struct pkt_filter_cfg *request = NULL;
9075
Mukul Sharma472382f2015-11-02 20:16:31 +05309076 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009077 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309078 return -EPERM;
9079 }
9080
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009081 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309082
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009083 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9084 ret = wlan_hdd_validate_context(hdd_ctx);
9085 if (0 != ret)
9086 return ret;
9087
9088 if (hdd_priv_get_data(&priv_data, wrqu)) {
9089 hdd_err("failed to get priv data");
9090 return -EINVAL;
9091 }
9092
9093 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
9094 hdd_err("invalid priv data %p or invalid priv data length %d",
9095 priv_data.pointer, priv_data.length);
9096 return -EINVAL;
9097 }
9098
9099 /* copy data using copy_from_user */
9100 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9101 priv_data.length);
9102 if (NULL == request) {
9103 hdd_err("mem_alloc_copy_from_user_helper fail");
9104 return -ENOMEM;
9105 }
9106
9107 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
9108
9109 kfree(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309110 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009111 return ret;
9112}
9113
9114/**
9115 * iw_set_packet_filter_params() - set packet filter parameters in target
9116 * @dev: Pointer to netdev
9117 * @info: Pointer to iw request info
9118 * @wrqu: Pointer to data
9119 * @extra: Pointer to extra data
9120 *
9121 * Return: 0 on success, non-zero on error
9122 */
9123static int iw_set_packet_filter_params(struct net_device *dev,
9124 struct iw_request_info *info,
9125 union iwreq_data *wrqu, char *extra)
9126{
9127 int ret;
9128
9129 cds_ssr_protect(__func__);
9130 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9131 cds_ssr_unprotect(__func__);
9132
9133 return ret;
9134}
9135#endif
9136
9137
9138static int __iw_get_statistics(struct net_device *dev,
9139 struct iw_request_info *info,
9140 union iwreq_data *wrqu, char *extra)
9141{
9142
Anurag Chouhance0dc992016-02-16 18:18:03 +05309143 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309144 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009145 hdd_wext_state_t *pWextState;
9146 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9147 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9148 char *p = extra;
9149 int tlen = 0;
9150 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
9151 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
9152 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
9153 int ret;
9154
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009155 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009156
9157 ret = wlan_hdd_validate_context(hdd_ctx);
9158 if (0 != ret)
9159 return ret;
9160
9161 if (eConnectionState_Associated !=
9162 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9163
9164 wrqu->txpower.value = 0;
9165 } else {
9166 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9167 SME_SUMMARY_STATS |
9168 SME_GLOBAL_CLASSA_STATS |
9169 SME_GLOBAL_CLASSB_STATS |
9170 SME_GLOBAL_CLASSC_STATS |
9171 SME_GLOBAL_CLASSD_STATS |
9172 SME_PER_STA_STATS,
9173 hdd_statistics_cb, 0, false,
9174 (WLAN_HDD_GET_STATION_CTX_PTR
9175 (pAdapter))->conn_info.staId[0],
9176 pAdapter, pAdapter->sessionId);
9177
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309178 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009179 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009180 return -EINVAL;
9181 }
9182
9183 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9184
Anurag Chouhance0dc992016-02-16 18:18:03 +05309185 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05309186 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009187 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +05309188 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009189 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009190 /*Remove the SME statistics list by passing NULL in callback argument */
9191 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9192 SME_SUMMARY_STATS |
9193 SME_GLOBAL_CLASSA_STATS |
9194 SME_GLOBAL_CLASSB_STATS |
9195 SME_GLOBAL_CLASSC_STATS |
9196 SME_GLOBAL_CLASSD_STATS |
9197 SME_PER_STA_STATS,
9198 NULL, 0, false,
9199 (WLAN_HDD_GET_STATION_CTX_PTR
9200 (pAdapter))->conn_info.
9201 staId[0], pAdapter,
9202 pAdapter->sessionId);
9203
9204 return -EINVAL;
9205 }
9206 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
9207 (uint8_t) sizeof(pStats->retry_cnt),
9208 (char *)&(pStats->retry_cnt[0]), tlen);
9209
9210 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
9211 (uint8_t) sizeof(pStats->multiple_retry_cnt),
9212 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
9213
9214 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
9215 (uint8_t) sizeof(pStats->tx_frm_cnt),
9216 (char *)&(pStats->tx_frm_cnt[0]), tlen);
9217
9218 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
9219 (uint8_t) sizeof(pStats->rx_frm_cnt),
9220 (char *)&(pStats->rx_frm_cnt), tlen);
9221
9222 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
9223 (uint8_t) sizeof(pStats->frm_dup_cnt),
9224 (char *)&(pStats->frm_dup_cnt), tlen);
9225
9226 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
9227 (uint8_t) sizeof(pStats->fail_cnt),
9228 (char *)&(pStats->fail_cnt[0]), tlen);
9229
9230 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
9231 (uint8_t) sizeof(pStats->rts_fail_cnt),
9232 (char *)&(pStats->rts_fail_cnt), tlen);
9233
9234 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
9235 (uint8_t) sizeof(pStats->ack_fail_cnt),
9236 (char *)&(pStats->ack_fail_cnt), tlen);
9237
9238 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
9239 (uint8_t) sizeof(pStats->rts_succ_cnt),
9240 (char *)&(pStats->rts_succ_cnt), tlen);
9241
9242 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
9243 (uint8_t) sizeof(pStats->rx_discard_cnt),
9244 (char *)&(pStats->rx_discard_cnt), tlen);
9245
9246 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
9247 (uint8_t) sizeof(pStats->rx_error_cnt),
9248 (char *)&(pStats->rx_error_cnt), tlen);
9249
9250 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
9251 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9252 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9253
9254 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
9255 (uint8_t) sizeof(dStats->rx_byte_cnt),
9256 (char *)&(dStats->rx_byte_cnt), tlen);
9257
9258 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
9259 (uint8_t) sizeof(dStats->rx_rate),
9260 (char *)&(dStats->rx_rate), tlen);
9261
9262 /* Transmit rate, in units of 500 kbit/sec */
9263 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
9264 (uint8_t) sizeof(aStats->tx_rate),
9265 (char *)&(aStats->tx_rate), tlen);
9266
9267 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
9268 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
9269 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
9270 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
9271 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
9272 (char *)&(dStats->rx_mc_byte_cnt), tlen);
9273 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
9274 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
9275 (char *)&(dStats->rx_bc_byte_cnt), tlen);
9276 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
9277 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9278 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9279 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
9280 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
9281 (char *)&(dStats->tx_mc_byte_cnt), tlen);
9282 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
9283 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
9284 (char *)&(dStats->tx_bc_byte_cnt), tlen);
9285
9286 wrqu->data.length = tlen;
9287
9288 }
9289
9290 EXIT();
9291
9292 return 0;
9293}
9294
9295static int iw_get_statistics(struct net_device *dev,
9296 struct iw_request_info *info,
9297 union iwreq_data *wrqu, char *extra)
9298{
9299 int ret;
9300
9301 cds_ssr_protect(__func__);
9302 ret = __iw_get_statistics(dev, info, wrqu, extra);
9303 cds_ssr_unprotect(__func__);
9304
9305 return ret;
9306}
9307
9308#ifdef FEATURE_WLAN_SCAN_PNO
9309
9310/*Max Len for PNO notification*/
9311#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07009312static void found_pref_network_cb(void *callbackContext,
9313 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009314{
9315 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
9316 union iwreq_data wrqu;
9317 char buf[MAX_PNO_NOTIFY_LEN + 1];
9318
Jeff Johnson99bac312016-06-28 10:38:18 -07009319 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009320 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9321
9322 /* create the event */
9323 memset(&wrqu, 0, sizeof(wrqu));
9324 memset(buf, 0, sizeof(buf));
9325
9326 snprintf(buf, MAX_PNO_NOTIFY_LEN,
9327 "QCOM: Found preferred network: %s with RSSI of -%u",
9328 pPrefNetworkFoundInd->ssId.ssId,
9329 (unsigned int)pPrefNetworkFoundInd->rssi);
9330
9331 wrqu.data.pointer = buf;
9332 wrqu.data.length = strlen(buf);
9333
9334 /* send the event */
9335
9336 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9337
9338}
9339
9340/**
9341 * __iw_set_pno() - Preferred Network Offload ioctl handler
9342 * @dev: device upon which the ioctl was received
9343 * @info: ioctl request information
9344 * @wrqu: ioctl request data
9345 * @extra: ioctl extra data
9346 *
9347 * This function parses a Preferred Network Offload command
9348 * Input is string based and expected to be of the form:
9349 *
9350 * <enable(1) | disable(0)>
9351 * when enabling:
9352 * <number of networks>
9353 * for each network:
9354 * <ssid_len> <ssid> <authentication> <encryption>
9355 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -07009356 * <scan_time (seconds)>
9357 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009358 * <suspend mode>
9359 *
9360 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -07009361 * 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 -08009362 *
9363 * this translates into:
9364 * -----------------------------
9365 * enable PNO
9366 * 2 networks
9367 * Network 1:
9368 * test - with authentication type 0 and encryption type 0,
9369 * search on 3 channels: 1 6 and 11,
9370 * SSID bcast type is unknown (directed probe will be sent if
9371 * AP not found) and must meet -40dBm RSSI
9372 * Network 2:
9373 * test2 - with authentication type 4 and encryption type 4,
9374 * search on 6 channels 1, 2, 3, 4, 5 and 6
9375 * bcast type is non-bcast (directed probe will be sent)
9376 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009377 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -07009378 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009379 */
9380static int __iw_set_pno(struct net_device *dev,
9381 struct iw_request_info *info,
9382 union iwreq_data *wrqu, char *extra)
9383{
9384 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9385 hdd_context_t *hdd_ctx;
9386 int ret;
9387 int offset;
9388 char *ptr;
9389 uint8_t i, j, params, mode;
9390
9391 /* request is a large struct, so we make it static to avoid
9392 * stack overflow. This API is only invoked via ioctl, so it
9393 * is serialized by the kernel rtnl_lock and hence does not
9394 * need to be reentrant
9395 */
9396 static tSirPNOScanReq request;
9397
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009398 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009399
9400 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9401 ret = wlan_hdd_validate_context(hdd_ctx);
9402 if (ret)
9403 return ret;
9404
9405 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
9406
9407 request.enable = 0;
9408 request.ucNetworksCount = 0;
9409
9410 ptr = extra;
9411
9412 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
9413 hdd_err("PNO enable input is not valid %s", ptr);
9414 return -EINVAL;
9415 }
9416
9417 if (0 == request.enable) {
9418 /* Disable PNO, ignore any other params */
9419 memset(&request, 0, sizeof(request));
9420 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9421 &request, adapter->sessionId,
9422 found_pref_network_cb, adapter);
9423 return 0;
9424 }
9425
9426 ptr += offset;
9427
9428 if (1 !=
9429 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
9430 hdd_err("PNO count input not valid %s", ptr);
9431 return -EINVAL;
9432
9433 }
9434
9435 hdd_info("PNO enable %d networks count %d offset %d",
9436 request.enable, request.ucNetworksCount, offset);
9437
9438 if ((0 == request.ucNetworksCount) ||
9439 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
9440 hdd_err("Network count %d invalid",
9441 request.ucNetworksCount);
9442 return -EINVAL;
9443 }
9444
9445 ptr += offset;
9446
9447 for (i = 0; i < request.ucNetworksCount; i++) {
9448
9449 request.aNetworks[i].ssId.length = 0;
9450
9451 params = sscanf(ptr, "%hhu %n",
9452 &(request.aNetworks[i].ssId.length),
9453 &offset);
9454
9455 if (1 != params) {
9456 hdd_err("PNO ssid length input is not valid %s", ptr);
9457 return -EINVAL;
9458 }
9459
9460 if ((0 == request.aNetworks[i].ssId.length) ||
9461 (request.aNetworks[i].ssId.length > 32)) {
9462 hdd_err("SSID Len %d is not correct for network %d",
9463 request.aNetworks[i].ssId.length, i);
9464 return -EINVAL;
9465 }
9466
9467 /* Advance to SSID */
9468 ptr += offset;
9469
9470 memcpy(request.aNetworks[i].ssId.ssId, ptr,
9471 request.aNetworks[i].ssId.length);
9472 ptr += request.aNetworks[i].ssId.length;
9473
9474 params = sscanf(ptr, "%u %u %hhu %n",
9475 &(request.aNetworks[i].authentication),
9476 &(request.aNetworks[i].encryption),
9477 &(request.aNetworks[i].ucChannelCount),
9478 &offset);
9479
9480 if (3 != params) {
9481 hdd_warn("Incorrect cmd %s", ptr);
9482 return -EINVAL;
9483 }
9484
9485 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
9486 request.aNetworks[i].ssId.length,
9487 request.aNetworks[i].ssId.length,
9488 request.aNetworks[i].ssId.ssId,
9489 request.aNetworks[i].authentication,
9490 request.aNetworks[i].encryption,
9491 request.aNetworks[i].ucChannelCount, offset);
9492
9493 /* Advance to channel list */
9494 ptr += offset;
9495
9496 if (SIR_PNO_MAX_NETW_CHANNELS <
9497 request.aNetworks[i].ucChannelCount) {
9498 hdd_warn("Incorrect number of channels");
9499 return -EINVAL;
9500 }
9501
9502 if (0 != request.aNetworks[i].ucChannelCount) {
9503 for (j = 0; j < request.aNetworks[i].ucChannelCount;
9504 j++) {
9505 if (1 !=
9506 sscanf(ptr, "%hhu %n",
9507 &(request.aNetworks[i].
9508 aChannels[j]), &offset)) {
9509 hdd_err("PNO network channel input is not valid %s",
9510 ptr);
9511 return -EINVAL;
9512 }
9513 /* Advance to next channel number */
9514 ptr += offset;
9515 }
9516 }
9517
9518 if (1 != sscanf(ptr, "%u %n",
9519 &(request.aNetworks[i].bcastNetwType),
9520 &offset)) {
9521 hdd_err("PNO broadcast network type input is not valid %s",
9522 ptr);
9523 return -EINVAL;
9524 }
9525
9526 hdd_notice("PNO bcastNetwType %d offset %d",
9527 request.aNetworks[i].bcastNetwType, offset);
9528
9529 /* Advance to rssi Threshold */
9530 ptr += offset;
9531 if (1 != sscanf(ptr, "%d %n",
9532 &(request.aNetworks[i].rssiThreshold),
9533 &offset)) {
9534 hdd_err("PNO rssi threshold input is not valid %s",
9535 ptr);
9536 return -EINVAL;
9537 }
9538 hdd_notice("PNO rssi %d offset %d",
9539 request.aNetworks[i].rssiThreshold, offset);
9540 /* Advance to next network */
9541 ptr += offset;
9542 } /* For ucNetworkCount */
9543
Dustin Brown43e87292016-10-10 10:38:25 -07009544 request.fast_scan_period = 0;
9545 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
9546 request.fast_scan_period *= MSEC_PER_SEC;
9547 ptr += offset;
9548 }
9549
9550 request.fast_scan_max_cycles = 0;
9551 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
9552 &offset) > 0)
9553 ptr += offset;
9554
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009555 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
9556
9557 request.modePNO = mode;
9558 /* for LA we just expose suspend option */
9559 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
9560 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9561 }
9562
9563 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9564 &request,
9565 adapter->sessionId,
9566 found_pref_network_cb, adapter);
9567
9568 return 0;
9569}
9570
9571static int iw_set_pno(struct net_device *dev,
9572 struct iw_request_info *info,
9573 union iwreq_data *wrqu, char *extra)
9574{
9575 int ret;
9576
9577 cds_ssr_protect(__func__);
9578 ret = __iw_set_pno(dev, info, wrqu, extra);
9579 cds_ssr_unprotect(__func__);
9580
9581 return ret;
9582}
9583#endif /* FEATURE_WLAN_SCAN_PNO */
9584
9585/* Common function to SetBand */
9586int hdd_set_band(struct net_device *dev, u8 ui_band)
9587{
9588 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9589 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9590 eCsrBand band;
9591
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309592 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009593 hdd_context_t *pHddCtx;
9594 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9595 eCsrBand currBand = eCSR_BAND_MAX;
9596 eCsrBand connectedBand;
9597
9598 pAdapterNode = NULL;
9599 pNext = NULL;
9600 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9601
9602 switch (ui_band) {
9603 case WLAN_HDD_UI_BAND_AUTO:
9604 band = eCSR_BAND_ALL;
9605 break;
9606 case WLAN_HDD_UI_BAND_5_GHZ:
9607 band = eCSR_BAND_5G;
9608 break;
9609 case WLAN_HDD_UI_BAND_2_4_GHZ:
9610 band = eCSR_BAND_24;
9611 break;
9612 default:
9613 band = eCSR_BAND_MAX;
9614 }
9615
Jeff Johnson99bac312016-06-28 10:38:18 -07009616 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009617
9618 if (band == eCSR_BAND_MAX) {
9619 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -07009620 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009621 return -EINVAL;
9622 }
9623
9624 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
9625 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009626 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009627 band, pHddCtx->config->nBandCapability);
9628 return -EIO;
9629 }
9630
9631 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009632 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009633 pHddCtx->config->nBandCapability);
9634 band = pHddCtx->config->nBandCapability;
9635 }
9636
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309637 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009638 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009639 return -EIO;
9640 }
9641
9642 if (currBand != band) {
9643 /* Change band request received.
9644 * Abort pending scan requests, flush the existing scan results,
9645 * and change the band capability
9646 */
Jeff Johnson99bac312016-06-28 10:38:18 -07009647 hdd_notice("Current band value = %u, new setting %u ",
9648 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009649
9650 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309651 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009652 pAdapter = pAdapterNode->pAdapter;
9653 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9654 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
9655 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9656 connectedBand =
9657 hdd_conn_get_connected_band
9658 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
9659
9660 /* Handling is done only for STA and P2P */
9661 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -08009662 ((pAdapter->device_mode == QDF_STA_MODE)
9663 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009664 &&
9665 (hdd_conn_is_connected
9666 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
9667 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309668 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009669 long lrc;
9670
9671 /* STA already connected on current band, So issue disconnect
9672 * first, then change the band*/
9673
Jeff Johnson99bac312016-06-28 10:38:18 -07009674 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009675 hdd_device_mode_to_string(pAdapter->device_mode),
9676 pAdapter->device_mode, currBand, band);
9677 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9678
9679 status =
9680 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
9681 (pAdapter),
9682 pAdapter->sessionId,
9683 eCSR_DISCONNECT_REASON_UNSPECIFIED);
9684
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309685 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009686 hdd_err("csr_roam_disconnect failure, returned %d",
9687 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009688 return -EINVAL;
9689 }
9690
9691 lrc =
9692 wait_for_completion_timeout(&pAdapter->
9693 disconnect_comp_var,
9694 msecs_to_jiffies
9695 (WLAN_WAIT_TIME_DISCONNECT));
9696
9697 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009698 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009699 return -ETIMEDOUT;
9700 }
9701 }
9702
9703 sme_scan_flush_result(hHal);
9704
9705 status =
9706 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
9707 pAdapterNode = pNext;
9708 }
9709
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309710 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009711 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009712 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009713 band);
9714 return -EINVAL;
9715 }
9716 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
9717 }
9718 return 0;
9719}
9720
9721int hdd_set_band_helper(struct net_device *dev, const char *command)
9722{
9723 uint8_t band;
9724 int ret;
9725
9726 /* Convert the band value from ascii to integer */
9727 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
9728 ret = kstrtou8(command, 10, &band);
9729 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009730 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009731 return -EINVAL;
9732 }
9733
9734 return hdd_set_band(dev, band);
9735}
9736
9737static int __iw_set_band_config(struct net_device *dev,
9738 struct iw_request_info *info,
9739 union iwreq_data *wrqu, char *extra)
9740{
9741 int *value = (int *)extra;
9742
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009743 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009744
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309745 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009746 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309747 return -EPERM;
9748 }
9749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009750 return hdd_set_band(dev, value[0]);
9751}
9752
9753static int iw_set_band_config(struct net_device *dev,
9754 struct iw_request_info *info,
9755 union iwreq_data *wrqu, char *extra)
9756{
9757 int ret;
9758
9759 cds_ssr_protect(__func__);
9760 ret = __iw_set_band_config(dev, info, wrqu, extra);
9761 cds_ssr_unprotect(__func__);
9762
9763 return ret;
9764}
9765
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009766/**
9767 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
9768 * @adapter: Handle to adapter
9769 * @chan: Monitor mode channel
9770 * @bandwidth: Capture channel bandwidth
9771 *
9772 * Return: 0 on success else error code.
9773 */
9774static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
9775 uint32_t bandwidth)
9776{
9777 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9778 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
9779 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
9780 QDF_STATUS status;
9781 tHalHandle hal_hdl = hdd_ctx->hHal;
9782 struct qdf_mac_addr bssid;
9783 tCsrRoamProfile roam_profile;
9784 struct ch_params_s ch_params;
9785
9786 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
9787 hdd_err("Not supported, device is not in monitor mode");
9788 return -EINVAL;
9789 }
9790
9791 hdd_info("Set monitor mode Channel %d", chan);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009792 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
9793 roam_profile.ChannelInfo.numOfChannels = 1;
9794 roam_profile.phyMode = ch_info->phy_mode;
9795 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -07009796 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009797
9798 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
9799 QDF_MAC_ADDR_SIZE);
9800
9801 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07009802 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009803 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
9804 &roam_profile);
9805 if (status) {
9806 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
9807 status);
9808 }
9809
9810 return qdf_status_to_os_return(status);
9811}
9812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009813static int __iw_set_two_ints_getnone(struct net_device *dev,
9814 struct iw_request_info *info,
9815 union iwreq_data *wrqu, char *extra)
9816{
9817 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9818 int *value = (int *)extra;
9819 int sub_cmd = value[0];
9820 int ret;
9821 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9822
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009823 ENTER_DEV(dev);
9824
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009825 ret = wlan_hdd_validate_context(hdd_ctx);
9826 if (0 != ret)
9827 return ret;
9828
9829 switch (sub_cmd) {
9830 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -07009831 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009832 ret = wma_cli_set_command(pAdapter->sessionId,
9833 WMI_STA_SMPS_PARAM_CMDID,
9834 value[1] << WMA_SMPS_PARAM_VALUE_S
9835 | value[2],
9836 VDEV_CMD);
9837 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -07009838#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009839 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -07009840 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009841 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +05309842 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
9843 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009844 ret = wma_cli_set2_command(pAdapter->sessionId,
9845 GEN_PARAM_CRASH_INJECT,
9846 value[1], value[2], GEN_CMD);
9847 break;
9848#endif
Govind Singha471e5e2015-10-12 17:11:14 +05309849 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009850 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309851 value[1], value[2]);
9852 ret = wma_cli_set2_command(pAdapter->sessionId,
9853 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
9854 value[1], value[2], DBG_CMD);
9855 break;
9856 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -07009857 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309858 value[1], value[2]);
9859 ret = wma_cli_set2_command(pAdapter->sessionId,
9860 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
9861 value[1], value[2], DBG_CMD);
9862 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009863 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
9864 hdd_debug("Ioctl to set dual fw mode config");
9865 if (hdd_ctx->config->dual_mac_feature_disable) {
9866 hdd_err("Dual mac feature is disabled from INI");
9867 return -EPERM;
9868 }
9869 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08009870 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009871 break;
9872 case WE_DUMP_DP_TRACE_LEVEL:
9873 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
9874 value[1], value[2]);
9875 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309876 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +05309877 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
9878 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +05309879 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
9880 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009881 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009882 case WE_SET_MON_MODE_CHAN:
9883 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
9884 break;
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009885 case WE_SET_WLAN_SUSPEND:
Dustin Brownbc81a472016-10-26 16:56:59 -07009886 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009887 break;
9888 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -07009889 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009890 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009891 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009892 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009893 break;
9894 }
9895
9896 return ret;
9897}
9898
9899static int iw_set_two_ints_getnone(struct net_device *dev,
9900 struct iw_request_info *info,
9901 union iwreq_data *wrqu, char *extra)
9902{
9903 int ret;
9904
9905 cds_ssr_protect(__func__);
9906 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
9907 cds_ssr_unprotect(__func__);
9908
9909 return ret;
9910}
9911
9912/* Define the Wireless Extensions to the Linux Network Device structure */
9913/* A number of these routines are NULL (meaning they are not implemented.) */
9914
9915static const iw_handler we_handler[] = {
9916 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9917 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9918 (iw_handler) NULL, /* SIOCSIWNWID */
9919 (iw_handler) NULL, /* SIOCGIWNWID */
9920 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9921 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9922 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9923 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9924 (iw_handler) NULL, /* SIOCSIWSENS */
9925 (iw_handler) NULL, /* SIOCGIWSENS */
9926 (iw_handler) NULL, /* SIOCSIWRANGE */
9927 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9928 (iw_handler) NULL, /* SIOCSIWPRIV */
9929 (iw_handler) NULL, /* SIOCGIWPRIV */
9930 (iw_handler) NULL, /* SIOCSIWSTATS */
9931 (iw_handler) NULL, /* SIOCGIWSTATS */
9932 (iw_handler) NULL, /* SIOCSIWSPY */
9933 (iw_handler) NULL, /* SIOCGIWSPY */
9934 (iw_handler) NULL, /* SIOCSIWTHRSPY */
9935 (iw_handler) NULL, /* SIOCGIWTHRSPY */
9936 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9937 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9938 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9939 (iw_handler) NULL, /* SIOCGIWAPLIST */
9940 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9941 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9942 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9943 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9944 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9945 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9946 (iw_handler) NULL, /* -- hole -- */
9947 (iw_handler) NULL, /* -- hole -- */
9948 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9949 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9950 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
9951 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
9952 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9953 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9954 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9955 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9956 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9957 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9958 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9959 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9960 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9961 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9962 (iw_handler) NULL, /* -- hole -- */
9963 (iw_handler) NULL, /* -- hole -- */
9964 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9965 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9966 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9967 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9968 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9969 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9970 (iw_handler) NULL, /* SIOCSIWPMKSA */
9971};
9972
9973static const iw_handler we_private[] = {
9974
9975 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
9976 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
9977 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
9978 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9979 iw_set_three_ints_getnone,
9980 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9981 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
9982 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9983 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009984 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
9985 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009986 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9987 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9988 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009989 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009990 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9991 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9992 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
9993 iw_set_keepalive_params,
9994#ifdef WLAN_FEATURE_PACKET_FILTERING
9995 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
9996 iw_set_packet_filter_params,
9997#endif
9998#ifdef FEATURE_WLAN_SCAN_PNO
9999 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
10000#endif
10001 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
10002 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
10003 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10004 iw_set_two_ints_getnone,
10005 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
10006 iw_set_dot11p_channel_sched,
10007};
10008
10009/*Maximum command length can be only 15 */
10010static const struct iw_priv_args we_private_args[] = {
10011
10012 /* handlers for main ioctl */
10013 {WLAN_PRIV_SET_INT_GET_NONE,
10014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10015 0,
10016 ""},
10017
10018 /* handlers for sub-ioctl */
10019 {WE_SET_11D_STATE,
10020 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10021 0,
10022 "set11Dstate"},
10023
10024 {WE_WOWL,
10025 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10026 0,
10027 "wowl"},
10028
10029 {WE_SET_POWER,
10030 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10031 0,
10032 "setPower"},
10033
10034 {WE_SET_MAX_ASSOC,
10035 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10036 0,
10037 "setMaxAssoc"},
10038
10039 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10041 "setAutoChannel" },
10042
10043 {WE_SET_SCAN_DISABLE,
10044 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10045 0,
10046 "scan_disable"},
10047
10048 {WE_SET_DATA_INACTIVITY_TO,
10049 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10050 0,
10051 "inactivityTO"},
10052
10053 {WE_SET_MAX_TX_POWER,
10054 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10055 0,
10056 "setMaxTxPower"},
10057
10058 {WE_SET_TX_POWER,
10059 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10060 0,
10061 "setTxPower"},
10062
10063 {WE_SET_MC_RATE,
10064 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10065 0,
10066 "setMcRate"},
10067
10068 {WE_SET_MAX_TX_POWER_2_4,
10069 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10070 0,
10071 "setTxMaxPower2G"},
10072
10073 {WE_SET_MAX_TX_POWER_5_0,
10074 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10075 0,
10076 "setTxMaxPower5G"},
10077
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010078 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010079 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010080 0,
10081 "pktlog"},
10082
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010083 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10084 * as well to keep same syntax as in SAP. Now onwards, STA
10085 * will support both */
10086 {WE_SET_MAX_TX_POWER,
10087 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10088 0,
10089 "setTxMaxPower"},
10090
10091 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10092 * 1 = enable and 0 = disable */
10093 {
10094 WE_SET_HIGHER_DTIM_TRANSITION,
10095 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10096 0,
10097 "setHDtimTransn"
10098 },
10099
10100 {WE_SET_TM_LEVEL,
10101 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10102 0,
10103 "setTmLevel"},
10104
10105 {WE_SET_PHYMODE,
10106 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10107 0,
10108 "setphymode"},
10109
10110 {WE_SET_NSS,
10111 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10112 0,
10113 "nss"},
10114
10115 {WE_SET_LDPC,
10116 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10117 0,
10118 "ldpc"},
10119
10120 {WE_SET_TX_STBC,
10121 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10122 0,
10123 "tx_stbc"},
10124
10125 {WE_SET_RX_STBC,
10126 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10127 0,
10128 "rx_stbc"},
10129
10130 {WE_SET_SHORT_GI,
10131 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10132 0,
10133 "shortgi"},
10134
10135 {WE_SET_RTSCTS,
10136 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10137 0,
10138 "enablertscts"},
10139
10140 {WE_SET_CHWIDTH,
10141 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10142 0,
10143 "chwidth"},
10144
10145 {WE_SET_ANI_EN_DIS,
10146 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10147 0,
10148 "anienable"},
10149
10150 {WE_SET_ANI_POLL_PERIOD,
10151 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10152 0,
10153 "aniplen"},
10154
10155 {WE_SET_ANI_LISTEN_PERIOD,
10156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10157 0,
10158 "anilislen"},
10159
10160 {WE_SET_ANI_OFDM_LEVEL,
10161 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10162 0,
10163 "aniofdmlvl"},
10164
10165 {WE_SET_ANI_CCK_LEVEL,
10166 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10167 0,
10168 "aniccklvl"},
10169
10170 {WE_SET_DYNAMIC_BW,
10171 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10172 0,
10173 "cwmenable"},
10174
10175 {WE_SET_CTS_CBW,
10176 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10177 0,
10178 "cts_cbw" },
10179
10180 {WE_SET_GTX_HT_MCS,
10181 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10182 0,
10183 "gtxHTMcs"},
10184
10185 {WE_SET_GTX_VHT_MCS,
10186 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10187 0,
10188 "gtxVHTMcs"},
10189
10190 {WE_SET_GTX_USRCFG,
10191 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10192 0,
10193 "gtxUsrCfg"},
10194
10195 {WE_SET_GTX_THRE,
10196 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10197 0,
10198 "gtxThre"},
10199
10200 {WE_SET_GTX_MARGIN,
10201 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10202 0,
10203 "gtxMargin"},
10204
10205 {WE_SET_GTX_STEP,
10206 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10207 0,
10208 "gtxStep"},
10209
10210 {WE_SET_GTX_MINTPC,
10211 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10212 0,
10213 "gtxMinTpc"},
10214
10215 {WE_SET_GTX_BWMASK,
10216 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10217 0,
10218 "gtxBWMask"},
10219
10220 {WE_SET_TX_CHAINMASK,
10221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10222 0,
10223 "txchainmask"},
10224
10225 {WE_SET_RX_CHAINMASK,
10226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10227 0,
10228 "rxchainmask"},
10229
10230 {WE_SET_11N_RATE,
10231 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10232 0,
10233 "set11NRates"},
10234
10235 {WE_SET_VHT_RATE,
10236 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10237 0,
10238 "set11ACRates"},
10239
10240 {WE_SET_AMPDU,
10241 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10242 0,
10243 "ampdu"},
10244
10245 {WE_SET_AMSDU,
10246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10247 0,
10248 "amsdu"},
10249
10250 {WE_SET_BURST_ENABLE,
10251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10252 0,
10253 "burst_enable"},
10254
10255 {WE_SET_BURST_DUR,
10256 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10257 0,
10258 "burst_dur"},
10259
10260 {WE_SET_TXPOW_2G,
10261 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10262 0,
10263 "txpow2g"},
10264
10265 {WE_SET_TXPOW_5G,
10266 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10267 0,
10268 "txpow5g"},
10269
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010270 /* Sub-cmds DBGLOG specific commands */
10271 {WE_DBGLOG_LOG_LEVEL,
10272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10273 0,
10274 "dl_loglevel"},
10275
10276 {WE_DBGLOG_VAP_ENABLE,
10277 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10278 0,
10279 "dl_vapon"},
10280
10281 {WE_DBGLOG_VAP_DISABLE,
10282 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10283 0,
10284 "dl_vapoff"},
10285
10286 {WE_DBGLOG_MODULE_ENABLE,
10287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10288 0,
10289 "dl_modon"},
10290
10291 {WE_DBGLOG_MODULE_DISABLE,
10292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10293 0,
10294 "dl_modoff"},
10295
10296 {WE_DBGLOG_MOD_LOG_LEVEL,
10297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10298 0,
10299 "dl_mod_loglevel"},
10300
10301 {WE_DBGLOG_TYPE,
10302 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10303 0,
10304 "dl_type"},
10305 {WE_DBGLOG_REPORT_ENABLE,
10306 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10307 0,
10308 "dl_report"},
10309
10310 {WE_SET_TXRX_FWSTATS,
10311 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10312 0,
10313 "txrx_fw_stats"},
10314
10315 {WE_TXRX_FWSTATS_RESET,
10316 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10317 0,
10318 "txrx_fw_st_rst"},
10319
10320 {WE_PPS_PAID_MATCH,
10321 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10322 0, "paid_match"},
10323
10324 {WE_PPS_GID_MATCH,
10325 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10326 0, "gid_match"},
10327
10328 {WE_PPS_EARLY_TIM_CLEAR,
10329 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10330 0, "tim_clear"},
10331
10332 {WE_PPS_EARLY_DTIM_CLEAR,
10333 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10334 0, "dtim_clear"},
10335
10336 {WE_PPS_EOF_PAD_DELIM,
10337 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10338 0, "eof_delim"},
10339
10340 {WE_PPS_MACADDR_MISMATCH,
10341 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10342 0, "mac_match"},
10343
10344 {WE_PPS_DELIM_CRC_FAIL,
10345 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10346 0, "delim_fail"},
10347
10348 {WE_PPS_GID_NSTS_ZERO,
10349 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10350 0, "nsts_zero"},
10351
10352 {WE_PPS_RSSI_CHECK,
10353 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10354 0, "rssi_chk"},
10355
10356 {WE_PPS_5G_EBT,
10357 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10358 0, "5g_ebt"},
10359
10360 {WE_SET_HTSMPS,
10361 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10362 0, "htsmps"},
10363
10364 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
10365 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10366 0, "set_qpspollcnt"},
10367
10368 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
10369 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10370 0, "set_qtxwake"},
10371
10372 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10373 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10374 0, "set_qwakeintv"},
10375
10376 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10377 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10378 0, "set_qnodatapoll"},
10379
10380 /* handlers for MCC time quota and latency sub ioctls */
10381 {WE_MCC_CONFIG_LATENCY,
10382 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10383 0, "setMccLatency"},
10384
10385 {WE_MCC_CONFIG_QUOTA,
10386 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10387 0, "setMccQuota"},
10388
10389 {WE_SET_DEBUG_LOG,
10390 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10391 0, "setDbgLvl"},
10392
10393 /* handlers for early_rx power save */
10394 {WE_SET_EARLY_RX_ADJUST_ENABLE,
10395 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10396 0, "erx_enable"},
10397
10398 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
10399 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10400 0, "erx_bmiss_val"},
10401
10402 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
10403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10404 0, "erx_bmiss_smpl"},
10405
10406 {WE_SET_EARLY_RX_SLOP_STEP,
10407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10408 0, "erx_slop_step"},
10409
10410 {WE_SET_EARLY_RX_INIT_SLOP,
10411 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10412 0, "erx_init_slop"},
10413
10414 {WE_SET_EARLY_RX_ADJUST_PAUSE,
10415 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10416 0, "erx_adj_pause"},
10417
10418 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
10419 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10420 0, "erx_dri_sample"},
10421
10422 {WE_DUMP_STATS,
10423 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10424 0, "dumpStats"},
10425
10426 {WE_CLEAR_STATS,
10427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10428 0, "clearStats"},
10429
Govind Singha471e5e2015-10-12 17:11:14 +053010430 {WE_START_FW_PROFILE,
10431 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10432 0, "startProfile"},
10433
Abhishek Singh1bdb1572015-10-16 16:24:19 +053010434 {WE_SET_CHANNEL,
10435 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10436 0, "setChanChange" },
10437
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053010438 {WE_SET_CONC_SYSTEM_PREF,
10439 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10440 0, "setConcSysPref" },
10441
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010442 {WLAN_PRIV_SET_NONE_GET_INT,
10443 0,
10444 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10445 ""},
10446
10447 /* handlers for sub-ioctl */
10448 {WE_GET_11D_STATE,
10449 0,
10450 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10451 "get11Dstate"},
10452
10453 {WE_IBSS_STATUS,
10454 0,
10455 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10456 "getAdhocStatus"},
10457
10458 {WE_GET_WLAN_DBG,
10459 0,
10460 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10461 "getwlandbg"},
10462
10463 {WE_GET_MAX_ASSOC,
10464 0,
10465 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10466 "getMaxAssoc"},
10467
10468 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10469 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10470 "getAutoChannel" },
10471
10472 {WE_GET_CONCURRENCY_MODE,
10473 0,
10474 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10475 "getconcurrency"},
10476
10477 {WE_GET_NSS,
10478 0,
10479 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10480 "get_nss"},
10481
10482 {WE_GET_LDPC,
10483 0,
10484 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10485 "get_ldpc"},
10486
10487 {WE_GET_TX_STBC,
10488 0,
10489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10490 "get_tx_stbc"},
10491
10492 {WE_GET_RX_STBC,
10493 0,
10494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10495 "get_rx_stbc"},
10496
10497 {WE_GET_SHORT_GI,
10498 0,
10499 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10500 "get_shortgi"},
10501
10502 {WE_GET_RTSCTS,
10503 0,
10504 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10505 "get_rtscts"},
10506
10507 {WE_GET_CHWIDTH,
10508 0,
10509 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10510 "get_chwidth"},
10511
10512 {WE_GET_ANI_EN_DIS,
10513 0,
10514 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10515 "get_anienable"},
10516
10517 {WE_GET_ANI_POLL_PERIOD,
10518 0,
10519 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10520 "get_aniplen"},
10521
10522 {WE_GET_ANI_LISTEN_PERIOD,
10523 0,
10524 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10525 "get_anilislen"},
10526
10527 {WE_GET_ANI_OFDM_LEVEL,
10528 0,
10529 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10530 "get_aniofdmlvl"},
10531
10532 {WE_GET_ANI_CCK_LEVEL,
10533 0,
10534 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10535 "get_aniccklvl"},
10536
10537 {WE_GET_DYNAMIC_BW,
10538 0,
10539 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10540 "get_cwmenable"},
10541
10542 {WE_GET_GTX_HT_MCS,
10543 0,
10544 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10545 "get_gtxHTMcs"},
10546
10547 {WE_GET_GTX_VHT_MCS,
10548 0,
10549 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10550 "get_gtxVHTMcs"},
10551
10552 {WE_GET_GTX_USRCFG,
10553 0,
10554 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10555 "get_gtxUsrCfg"},
10556
10557 {WE_GET_GTX_THRE,
10558 0,
10559 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10560 "get_gtxThre"},
10561
10562 {WE_GET_GTX_MARGIN,
10563 0,
10564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10565 "get_gtxMargin"},
10566
10567 {WE_GET_GTX_STEP,
10568 0,
10569 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10570 "get_gtxStep"},
10571
10572 {WE_GET_GTX_MINTPC,
10573 0,
10574 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10575 "get_gtxMinTpc"},
10576
10577 {WE_GET_GTX_BWMASK,
10578 0,
10579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10580 "get_gtxBWMask"},
10581
10582 {WE_GET_TX_CHAINMASK,
10583 0,
10584 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10585 "get_txchainmask"},
10586
10587 {WE_GET_RX_CHAINMASK,
10588 0,
10589 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10590 "get_rxchainmask"},
10591
10592 {WE_GET_11N_RATE,
10593 0,
10594 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10595 "get_11nrate"},
10596
10597 {WE_GET_AMPDU,
10598 0,
10599 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10600 "get_ampdu"},
10601
10602 {WE_GET_AMSDU,
10603 0,
10604 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10605 "get_amsdu"},
10606
10607 {WE_GET_BURST_ENABLE,
10608 0,
10609 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10610 "get_burst_en"},
10611
10612 {WE_GET_BURST_DUR,
10613 0,
10614 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10615 "get_burst_dur"},
10616
10617 {WE_GET_TXPOW_2G,
10618 0,
10619 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10620 "get_txpow2g"},
10621
10622 {WE_GET_TXPOW_5G,
10623 0,
10624 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10625 "get_txpow5g"},
10626
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010627 {WE_GET_PPS_PAID_MATCH,
10628 0,
10629 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10630 "get_paid_match"},
10631
10632 {WE_GET_PPS_GID_MATCH,
10633 0,
10634 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10635 "get_gid_match"},
10636
10637 {WE_GET_PPS_EARLY_TIM_CLEAR,
10638 0,
10639 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10640 "get_tim_clear"},
10641
10642 {WE_GET_PPS_EARLY_DTIM_CLEAR,
10643 0,
10644 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10645 "get_dtim_clear"},
10646
10647 {WE_GET_PPS_EOF_PAD_DELIM,
10648 0,
10649 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10650 "get_eof_delim"},
10651
10652 {WE_GET_PPS_MACADDR_MISMATCH,
10653 0,
10654 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10655 "get_mac_match"},
10656
10657 {WE_GET_PPS_DELIM_CRC_FAIL,
10658 0,
10659 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10660 "get_delim_fail"},
10661
10662 {WE_GET_PPS_GID_NSTS_ZERO,
10663 0,
10664 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10665 "get_nsts_zero"},
10666
10667 {WE_GET_PPS_RSSI_CHECK,
10668 0,
10669 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10670 "get_rssi_chk"},
10671
10672 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
10673 0,
10674 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10675 "get_qpspollcnt"},
10676
10677 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
10678 0,
10679 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10680 "get_qtxwake"},
10681
10682 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10683 0,
10684 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10685 "get_qwakeintv"},
10686
10687 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10688 0,
10689 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10690 "get_qnodatapoll"},
10691
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010692 {WE_CAP_TSF,
10693 0,
10694 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10695 "cap_tsf"},
10696
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010697 {WE_GET_TEMPERATURE,
10698 0,
10699 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10700 "get_temp"},
10701 /* handlers for main ioctl */
10702 {WLAN_PRIV_SET_CHAR_GET_NONE,
10703 IW_PRIV_TYPE_CHAR | 512,
10704 0,
10705 ""},
10706
10707 /* handlers for sub-ioctl */
10708 {WE_WOWL_ADD_PTRN,
10709 IW_PRIV_TYPE_CHAR | 512,
10710 0,
10711 "wowlAddPtrn"},
10712
10713 {WE_WOWL_DEL_PTRN,
10714 IW_PRIV_TYPE_CHAR | 512,
10715 0,
10716 "wowlDelPtrn"},
10717
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010718 /* handlers for sub-ioctl */
10719 {WE_NEIGHBOR_REPORT_REQUEST,
10720 IW_PRIV_TYPE_CHAR | 512,
10721 0,
10722 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080010723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010724 {WE_SET_AP_WPS_IE,
10725 IW_PRIV_TYPE_CHAR | 512,
10726 0,
10727 "set_ap_wps_ie"},
10728
10729 {WE_SET_CONFIG,
10730 IW_PRIV_TYPE_CHAR | 512,
10731 0,
10732 "setConfig"},
10733
10734 /* handlers for main ioctl */
10735 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
10736 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10737 0,
10738 ""},
10739
10740 /* handlers for sub-ioctl */
10741 {WE_SET_WLAN_DBG,
10742 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10743 0,
10744 "setwlandbg"},
10745
10746 /* handlers for sub-ioctl */
10747 {WE_SET_DP_TRACE,
10748 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10749 0,
10750 "set_dp_trace"},
10751
10752 {WE_SET_SAP_CHANNELS,
10753 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10754 0,
10755 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053010756
10757 {WE_SET_FW_TEST,
10758 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10759 0, "fw_test"},
10760
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010761 /* handlers for main ioctl */
10762 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
10763 0,
10764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10765 "" },
10766 {WE_GET_TSF,
10767 0,
10768 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10769 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010770
10771 {WE_SET_DUAL_MAC_SCAN_CONFIG,
10772 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10773 0,
10774 "set_scan_cfg"},
10775
10776 /* handlers for main ioctl */
10777 {WLAN_PRIV_GET_CHAR_SET_NONE,
10778 0,
10779 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10780 ""},
10781
10782 /* handlers for sub-ioctl */
10783 {WE_WLAN_VERSION,
10784 0,
10785 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10786 "version"},
10787 {WE_GET_STATS,
10788 0,
10789 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10790 "getStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053010791 {WE_LIST_FW_PROFILE,
10792 0,
10793 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10794 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010795 {WE_GET_STATES,
10796 0,
10797 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10798 "getHostStates"},
10799 {WE_GET_CFG,
10800 0,
10801 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10802 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010803 {WE_GET_RSSI,
10804 0,
10805 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10806 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010807 {WE_GET_WMM_STATUS,
10808 0,
10809 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10810 "getWmmStatus"},
10811 {
10812 WE_GET_CHANNEL_LIST,
10813 0,
10814 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10815 "getChannelList"
10816 },
10817#ifdef FEATURE_WLAN_TDLS
10818 {
10819 WE_GET_TDLS_PEERS,
10820 0,
10821 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10822 "getTdlsPeers"
10823 },
10824#endif
10825#ifdef WLAN_FEATURE_11W
10826 {
10827 WE_GET_11W_INFO,
10828 0,
10829 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10830 "getPMFInfo"
10831 },
10832#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010833 {
10834 WE_GET_IBSS_STA_INFO,
10835 0,
10836 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10837 "getIbssSTAs"
10838 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010839 {WE_GET_PHYMODE,
10840 0,
10841 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10842 "getphymode"},
10843#ifdef FEATURE_OEM_DATA_SUPPORT
10844 {WE_GET_OEM_DATA_CAP,
10845 0,
10846 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10847 "getOemDataCap"},
10848#endif /* FEATURE_OEM_DATA_SUPPORT */
10849 {WE_GET_SNR,
10850 0,
10851 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10852 "getSNR"},
10853
10854 /* handlers for main ioctl */
10855 {WLAN_PRIV_SET_NONE_GET_NONE,
10856 0,
10857 0,
10858 ""},
10859
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010860 /* handlers for sub-ioctl */
10861 {
10862 WE_IBSS_GET_PEER_INFO_ALL,
10863 0,
10864 0,
10865 "ibssPeerInfoAll"
10866 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010867 {WE_GET_RECOVERY_STAT,
10868 0,
10869 0,
10870 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053010871
10872 {WE_GET_FW_PROFILE_DATA,
10873 0,
10874 0,
10875 "getProfileData"},
10876
10877 {WE_SET_REASSOC_TRIGGER,
10878 0,
10879 0,
10880 "reassoc"},
10881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010882 {WE_DUMP_AGC_START,
10883 0,
10884 0,
10885 "dump_agc_start"},
10886
10887 {WE_DUMP_AGC,
10888 0,
10889 0,
10890 "dump_agc"},
10891
10892 {WE_DUMP_CHANINFO_START,
10893 0,
10894 0,
10895 "dump_chninfo_en"},
10896
10897 {WE_DUMP_CHANINFO,
10898 0,
10899 0,
10900 "dump_chninfo"},
10901
10902 {WE_DUMP_WATCHDOG,
10903 0,
10904 0,
10905 "dump_watchdog"},
10906#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
10907 {WE_DUMP_PCIE_LOG,
10908 0,
10909 0,
10910 "dump_pcie_log"},
10911#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010912 {WE_STOP_OBSS_SCAN,
10913 0,
10914 0,
10915 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010916 /* handlers for main ioctl */
10917 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
10918 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10919 0,
10920 ""},
10921
10922 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010923 {WE_IBSS_GET_PEER_INFO,
10924 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10925 0,
10926 "ibssPeerInfo"},
10927
10928 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010929 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10930 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10931 0,
10932 "setdumplog"},
10933
10934 {WE_MTRACE_DUMP_CMD,
10935 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10936 0,
10937 "dumplog"},
10938#ifdef MPC_UT_FRAMEWORK
10939 {WE_POLICY_MANAGER_CLIST_CMD,
10940 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10941 0,
10942 "pm_clist"},
10943
10944 {WE_POLICY_MANAGER_DLIST_CMD,
10945 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10946 0,
10947 "pm_dlist"},
10948
10949 {WE_POLICY_MANAGER_DBS_CMD,
10950 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10951 0,
10952 "pm_dbs"},
10953
10954 {WE_POLICY_MANAGER_PCL_CMD,
10955 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10956 0,
10957 "pm_pcl"},
10958
10959 {WE_POLICY_MANAGER_CINFO_CMD,
10960 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10961 0,
10962 "pm_cinfo"},
10963
10964 {WE_POLICY_MANAGER_ULIST_CMD,
10965 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10966 0,
10967 "pm_ulist"},
10968
10969 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
10970 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10971 0,
10972 "pm_query_action"},
10973
10974 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
10975 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10976 0,
10977 "pm_query_allow"},
10978
10979 {WE_POLICY_MANAGER_SCENARIO_CMD,
10980 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10981 0,
10982 "pm_run_scenario"},
10983
10984 {WE_POLICY_SET_HW_MODE_CMD,
10985 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10986 0,
10987 "pm_set_hw_mode"},
10988#endif
10989#ifdef FEATURE_WLAN_TDLS
10990 /* handlers for sub ioctl */
10991 {
10992 WE_TDLS_CONFIG_PARAMS,
10993 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10994 0,
10995 "setTdlsConfig"
10996 },
10997#endif
10998 {
10999 WE_UNIT_TEST_CMD,
11000 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11001 0,
11002 "setUnitTestCmd"
11003 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053011004 {
11005 WE_MAC_PWR_DEBUG_CMD,
11006 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11007 0,
11008 "halPwrDebug"
11009 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011010
11011#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11012 {WE_LED_FLASHING_PARAM,
11013 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11014 0,
11015 "gpio_control"},
11016#endif
11017 /* handlers for main ioctl */
11018 {WLAN_PRIV_ADD_TSPEC,
11019 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11020 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11021 "addTspec"},
11022
11023 /* handlers for main ioctl */
11024 {WLAN_PRIV_DEL_TSPEC,
11025 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11026 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11027 "delTspec"},
11028
11029 /* handlers for main ioctl */
11030 {WLAN_PRIV_GET_TSPEC,
11031 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11033 "getTspec"},
11034
11035 /* handlers for main ioctl - host offload */
11036 {
11037 WLAN_PRIV_SET_HOST_OFFLOAD,
11038 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11039 0,
11040 "setHostOffload"
11041 }
11042 ,
11043
11044 {
11045 WLAN_GET_WLAN_STATISTICS,
11046 0,
11047 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11048 "getWlanStats"
11049 }
11050 ,
11051
11052 {
11053 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011054 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11055 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011056 0,
11057 "setKeepAlive"
11058 }
11059 ,
11060#ifdef WLAN_FEATURE_PACKET_FILTERING
11061 {
11062 WLAN_SET_PACKET_FILTER_PARAMS,
11063 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED |
11064 sizeof(struct pkt_filter_cfg),
11065 0,
11066 "setPktFilter"
11067 }
11068 ,
11069#endif
11070#ifdef FEATURE_WLAN_SCAN_PNO
11071 {
11072 WLAN_SET_PNO,
11073 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11074 0,
11075 "setpno"
11076 }
11077 ,
11078#endif
11079 {
11080 WLAN_SET_BAND_CONFIG,
11081 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11082 0,
11083 "SETBAND"
11084 }
11085 ,
11086 {
11087 WLAN_GET_LINK_SPEED,
11088 IW_PRIV_TYPE_CHAR | 18,
11089 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11090 }
11091 ,
11092
11093 /* handlers for main ioctl */
11094 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
11095 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11096 0,
11097 ""}
11098 ,
11099 {WE_SET_SMPS_PARAM,
11100 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11101 0, "set_smps_param"}
11102 ,
11103 {WLAN_SET_DOT11P_CHANNEL_SCHED,
11104 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
11105 0, "set_dot11p" }
11106 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070011107#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011108 {WE_SET_FW_CRASH_INJECT,
11109 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11110 0, "crash_inject"}
11111 ,
11112#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070011113#ifdef WLAN_SUSPEND_RESUME_TEST
11114 {WE_SET_WLAN_SUSPEND,
11115 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11116 0, "wlan_suspend"}
11117 ,
11118 {WE_SET_WLAN_RESUME,
11119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11120 0, "wlan_resume"}
11121 ,
11122#endif
Govind Singha471e5e2015-10-12 17:11:14 +053011123 {WE_ENABLE_FW_PROFILE,
11124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11125 0, "enableProfile"}
11126 ,
11127 {WE_SET_FW_PROFILE_HIST_INTVL,
11128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11129 0, "set_hist_intvl"}
11130 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011131 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
11132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11133 0, "set_fw_mode_cfg"}
11134 ,
11135 {WE_DUMP_DP_TRACE_LEVEL,
11136 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11137 0, "dump_dp_trace"}
11138 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011139 {WE_SET_MON_MODE_CHAN,
11140 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11141 0, "setMonChan"}
11142 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070011143
11144 {WE_GET_ROAM_SYNCH_DELAY,
11145 0,
11146 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11147 "hostroamdelay"}
11148 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011149};
11150
11151const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053011152 .num_standard = QDF_ARRAY_SIZE(we_handler),
11153 .num_private = QDF_ARRAY_SIZE(we_private),
11154 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011155
11156 .standard = (iw_handler *) we_handler,
11157 .private = (iw_handler *) we_private,
11158 .private_args = we_private_args,
11159 .get_wireless_stats = NULL,
11160};
11161
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011162/* hdd_set_wext() - configures bss parameters
11163 * @pAdapter: handle to adapter context
11164 *
11165 * Returns: none
11166 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011167static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011168{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011169 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11170 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011171
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011172 ENTER();
11173
11174 if (!pwextBuf) {
11175 hdd_err("ERROR: pwextBuf is NULL");
11176 return QDF_STATUS_E_FAILURE;
11177 }
11178
11179 if (!pHddStaCtx) {
11180 hdd_err("ERROR: pHddStaCtx is NULL");
11181 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011182 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011183
11184 /* Now configure the roaming profile links. To SSID and bssid. */
11185 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011186 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011187
11188 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011189 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011190
11191 /*Set the numOfChannels to zero to scan all the channels */
11192 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11193 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11194
11195 /* Default is no encryption */
11196 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11197 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
11198 eCSR_ENCRYPT_TYPE_NONE;
11199
11200 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11201 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
11202 eCSR_ENCRYPT_TYPE_NONE;
11203
11204 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11205
11206 /* Default is no authentication */
11207 pwextBuf->roamProfile.AuthType.numEntries = 1;
11208 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11209
11210 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
11211 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11212
11213 /*Set the default scan mode */
11214 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
11215
11216 hdd_clear_roam_profile_ie(pAdapter);
11217
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011218 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011219 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011220
11221}
11222
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011223/**
11224 * hdd_register_wext() - register wext context
11225 * @dev: net device handle
11226 *
11227 * Registers wext interface context for a given net device
11228 *
11229 * Returns: 0 on success, errno on failure
11230 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011231int hdd_register_wext(struct net_device *dev)
11232{
11233 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011234 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011235 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011236
11237 ENTER();
11238
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011239 if (!pwextBuf) {
11240 hdd_err(FL("ERROR: pwextBuf is NULL"));
11241 return QDF_STATUS_E_FAILURE;
11242 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011243
11244 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011245 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
11246
11247 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->
11248 completion_var);
11249
11250 status = hdd_set_wext(pAdapter);
11251
Anurag Chouhance0dc992016-02-16 18:18:03 +053011252 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011253
Jeff Johnson99bac312016-06-28 10:38:18 -070011254 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011255 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011256 }
11257
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011258 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011259 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011260 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011261 }
11262
Anurag Chouhance0dc992016-02-16 18:18:03 +053011263 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->scanevent))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011264 hdd_err("ERROR: HDD scan event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011265 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011266 }
11267 /* Register as a wireless device */
11268 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11269
11270 EXIT();
11271 return 0;
11272}
11273
11274int hdd_unregister_wext(struct net_device *dev)
11275{
Jeff Johnson99bac312016-06-28 10:38:18 -070011276 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011277
11278 if (dev != NULL) {
11279 rtnl_lock();
11280 dev->wireless_handlers = NULL;
11281 rtnl_unlock();
11282 }
11283
11284 return 0;
11285}