blob: 8d176a9ddb3d9962db85dd28c818911d34f73000 [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"
95#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097#define HDD_FINISH_ULA_TIME_OUT 800
98#define HDD_SET_MCBC_FILTERS_TO_FW 1
99#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
100
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101static int ioctl_debug;
102module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
103
104/* To Validate Channel against the Frequency and Vice-Versa */
105static const hdd_freq_chan_map_t freq_chan_map[] = {
106 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
107 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
108 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
109 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
110 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
111 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
112 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
113 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
114 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
115 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
116 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
117 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
118
119#define FREQ_CHAN_MAP_TABLE_SIZE \
120 (sizeof(freq_chan_map) / sizeof(freq_chan_map[0]))
121
122/* Private ioctls and their sub-ioctls */
123#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
124#define WE_SET_11D_STATE 1
125#define WE_WOWL 2
126#define WE_SET_POWER 3
127#define WE_SET_MAX_ASSOC 4
128#define WE_SET_SCAN_DISABLE 5
129#define WE_SET_DATA_INACTIVITY_TO 6
130#define WE_SET_MAX_TX_POWER 7
131#define WE_SET_HIGHER_DTIM_TRANSITION 8
132#define WE_SET_TM_LEVEL 9
133#define WE_SET_PHYMODE 10
134#define WE_SET_NSS 11
135#define WE_SET_LDPC 12
136#define WE_SET_TX_STBC 13
137#define WE_SET_RX_STBC 14
138#define WE_SET_SHORT_GI 15
139#define WE_SET_RTSCTS 16
140#define WE_SET_CHWIDTH 17
141#define WE_SET_ANI_EN_DIS 18
142#define WE_SET_ANI_POLL_PERIOD 19
143#define WE_SET_ANI_LISTEN_PERIOD 20
144#define WE_SET_ANI_OFDM_LEVEL 21
145#define WE_SET_ANI_CCK_LEVEL 22
146#define WE_SET_DYNAMIC_BW 23
147#define WE_SET_TX_CHAINMASK 24
148#define WE_SET_RX_CHAINMASK 25
149#define WE_SET_11N_RATE 26
150#define WE_SET_AMPDU 27
151#define WE_SET_AMSDU 28
152#define WE_SET_TXPOW_2G 29
153#define WE_SET_TXPOW_5G 30
154/* Private ioctl for firmware debug log */
155#define WE_DBGLOG_LOG_LEVEL 31
156#define WE_DBGLOG_VAP_ENABLE 32
157#define WE_DBGLOG_VAP_DISABLE 33
158#define WE_DBGLOG_MODULE_ENABLE 34
159#define WE_DBGLOG_MODULE_DISABLE 35
160#define WE_DBGLOG_MOD_LOG_LEVEL 36
161#define WE_DBGLOG_TYPE 37
162#define WE_SET_TXRX_FWSTATS 38
163#define WE_SET_VHT_RATE 39
164#define WE_DBGLOG_REPORT_ENABLE 40
165#define WE_TXRX_FWSTATS_RESET 41
166#define WE_SET_MAX_TX_POWER_2_4 42
167#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800168#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169/* Private ioctl for packet powe save */
170#define WE_PPS_PAID_MATCH 45
171#define WE_PPS_GID_MATCH 46
172#define WE_PPS_EARLY_TIM_CLEAR 47
173#define WE_PPS_EARLY_DTIM_CLEAR 48
174#define WE_PPS_EOF_PAD_DELIM 49
175#define WE_PPS_MACADDR_MISMATCH 50
176#define WE_PPS_DELIM_CRC_FAIL 51
177#define WE_PPS_GID_NSTS_ZERO 52
178#define WE_PPS_RSSI_CHECK 53
179#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
180#define WE_SET_HTSMPS 55
181/* Private ioctl for QPower */
182#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
183#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
184#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
185#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
186
187#define WE_SET_BURST_ENABLE 60
188#define WE_SET_BURST_DUR 61
189/* GTX Commands */
190#define WE_SET_GTX_HT_MCS 62
191#define WE_SET_GTX_VHT_MCS 63
192#define WE_SET_GTX_USRCFG 64
193#define WE_SET_GTX_THRE 65
194#define WE_SET_GTX_MARGIN 66
195#define WE_SET_GTX_STEP 67
196#define WE_SET_GTX_MINTPC 68
197#define WE_SET_GTX_BWMASK 69
198/* Private ioctl to configure MCC home channels time quota and latency */
199#define WE_MCC_CONFIG_LATENCY 70
200#define WE_MCC_CONFIG_QUOTA 71
201/* Private IOCTL for debug connection issues */
202#define WE_SET_DEBUG_LOG 72
203#ifdef WE_SET_TX_POWER
204#undef WE_SET_TX_POWER
205#endif
206#define WE_SET_TX_POWER 74
207/* Private ioctl for earlyrx power save feature */
208#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
209#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
210#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
211#define WE_SET_EARLY_RX_SLOP_STEP 78
212#define WE_SET_EARLY_RX_INIT_SLOP 79
213#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
214#define WE_SET_MC_RATE 81
215#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
216/* Private ioctl for packet power save */
217#define WE_PPS_5G_EBT 83
218#define WE_SET_CTS_CBW 84
219#define WE_DUMP_STATS 85
220#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530221/* Private sub ioctl for starting/stopping the profiling */
222#define WE_START_FW_PROFILE 87
Abhishek Singh1bdb1572015-10-16 16:24:19 +0530223#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +0530224#define WE_SET_CONC_SYSTEM_PREF 89
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225
226/* Private ioctls and their sub-ioctls */
227#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
228#define WE_GET_11D_STATE 1
229#define WE_IBSS_STATUS 2
230#define WE_SET_SAP_CHANNELS 3
231#define WE_GET_WLAN_DBG 4
232#define WE_GET_MAX_ASSOC 6
233/* 7 is unused */
234#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
235#define WE_GET_CONCURRENCY_MODE 9
236#define WE_GET_NSS 11
237#define WE_GET_LDPC 12
238#define WE_GET_TX_STBC 13
239#define WE_GET_RX_STBC 14
240#define WE_GET_SHORT_GI 15
241#define WE_GET_RTSCTS 16
242#define WE_GET_CHWIDTH 17
243#define WE_GET_ANI_EN_DIS 18
244#define WE_GET_ANI_POLL_PERIOD 19
245#define WE_GET_ANI_LISTEN_PERIOD 20
246#define WE_GET_ANI_OFDM_LEVEL 21
247#define WE_GET_ANI_CCK_LEVEL 22
248#define WE_GET_DYNAMIC_BW 23
249#define WE_GET_TX_CHAINMASK 24
250#define WE_GET_RX_CHAINMASK 25
251#define WE_GET_11N_RATE 26
252#define WE_GET_AMPDU 27
253#define WE_GET_AMSDU 28
254#define WE_GET_TXPOW_2G 29
255#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -0800256/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257#define WE_GET_PPS_PAID_MATCH 32
258#define WE_GET_PPS_GID_MATCH 33
259#define WE_GET_PPS_EARLY_TIM_CLEAR 34
260#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
261#define WE_GET_PPS_EOF_PAD_DELIM 36
262#define WE_GET_PPS_MACADDR_MISMATCH 37
263#define WE_GET_PPS_DELIM_CRC_FAIL 38
264#define WE_GET_PPS_GID_NSTS_ZERO 39
265#define WE_GET_PPS_RSSI_CHECK 40
266/* Private ioctl for QPower */
267#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
268#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
269#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
270#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
271#define WE_GET_BURST_ENABLE 45
272#define WE_GET_BURST_DUR 46
273/* GTX Commands */
274#define WE_GET_GTX_HT_MCS 47
275#define WE_GET_GTX_VHT_MCS 48
276#define WE_GET_GTX_USRCFG 49
277#define WE_GET_GTX_THRE 50
278#define WE_GET_GTX_MARGIN 51
279#define WE_GET_GTX_STEP 52
280#define WE_GET_GTX_MINTPC 53
281#define WE_GET_GTX_BWMASK 54
282#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700283#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700284#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800285
286/* Private ioctls and their sub-ioctls */
287#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
288
289/* Private ioctls and their sub-ioctls */
290#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
291#define WE_WOWL_ADD_PTRN 1
292#define WE_WOWL_DEL_PTRN 2
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800293#define WE_NEIGHBOR_REPORT_REQUEST 3
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294#define WE_SET_AP_WPS_IE 4 /* This is called in station mode to set probe rsp ie. */
295#define WE_SET_CONFIG 5
296
297/* Private ioctls and their sub-ioctls */
298#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
299#define WE_SET_WLAN_DBG 1
300#define WE_SET_DP_TRACE 2
301#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +0530302#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303
304/* Private ioctls and their sub-ioctls */
305#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
306#define WE_WLAN_VERSION 1
307#define WE_GET_STATS 2
308#define WE_GET_CFG 3
309#define WE_GET_WMM_STATUS 4
310#define WE_GET_CHANNEL_LIST 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311#define WE_GET_RSSI 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312#ifdef FEATURE_WLAN_TDLS
313#define WE_GET_TDLS_PEERS 8
314#endif
315#ifdef WLAN_FEATURE_11W
316#define WE_GET_11W_INFO 9
317#endif
318#define WE_GET_STATES 10
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800319#define WE_GET_IBSS_STA_INFO 11
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320#define WE_GET_PHYMODE 12
321#ifdef FEATURE_OEM_DATA_SUPPORT
322#define WE_GET_OEM_DATA_CAP 13
323#endif
324#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +0530325#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326
327/* Private ioctls and their sub-ioctls */
328#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
329#define WE_SET_REASSOC_TRIGGER 8
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800330#define WE_IBSS_GET_PEER_INFO_ALL 10
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331#define WE_DUMP_AGC_START 11
332#define WE_DUMP_AGC 12
333#define WE_DUMP_CHANINFO_START 13
334#define WE_DUMP_CHANINFO 14
335#define WE_DUMP_WATCHDOG 15
336#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
337#define WE_DUMP_PCIE_LOG 16
338#endif
339#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -0800340#define WE_GET_FW_PROFILE_DATA 18
341#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342
343/* Private ioctls and their sub-ioctls */
344#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
345
346#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +0530347/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348
Manjeet Singhf82ed072016-07-08 11:40:00 +0530349#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350
351#ifdef FEATURE_WLAN_TDLS
352#define WE_TDLS_CONFIG_PARAMS 5
353#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800354#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355#define WE_UNIT_TEST_CMD 7
356
357#define WE_MTRACE_DUMP_CMD 8
358#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
359
360
361#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
362#define WE_LED_FLASHING_PARAM 10
363#endif
364
365#define WE_POLICY_MANAGER_CLIST_CMD 11
366#define WE_POLICY_MANAGER_DLIST_CMD 12
367#define WE_POLICY_MANAGER_DBS_CMD 13
368#define WE_POLICY_MANAGER_PCL_CMD 14
369#define WE_POLICY_MANAGER_CINFO_CMD 15
370#define WE_POLICY_MANAGER_ULIST_CMD 16
371#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
372#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
373#define WE_POLICY_MANAGER_SCENARIO_CMD 19
374#define WE_POLICY_SET_HW_MODE_CMD 20
375
376#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
377#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -0700378#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379
380#ifdef FEATURE_WLAN_TDLS
381#undef MAX_VAR_ARGS
382#define MAX_VAR_ARGS 11
383#else
384#undef MAX_VAR_ARGS
385#define MAX_VAR_ARGS 9
386#endif
387
388/* Private ioctls (with no sub-ioctls) */
389/* note that they must be odd so that they have "get" semantics */
390#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
391#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
392#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
393
394/* (SIOCIWFIRSTPRIV + 8) is currently unused */
395/* (SIOCIWFIRSTPRIV + 10) is currently unused */
396/* (SIOCIWFIRSTPRIV + 12) is currently unused */
397/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700398#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
399#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400/* (SIOCIWFIRSTPRIV + 16) is currently unused */
401/* (SIOCIWFIRSTPRIV + 17) is currently unused */
402/* (SIOCIWFIRSTPRIV + 19) is currently unused */
403
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405
406/* Private ioctl for setting the host offload feature */
407#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
408
409/* Private ioctl to get the statistics */
410#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
411
412/* Private ioctl to set the Keep Alive Params */
413#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
414
415#ifdef WLAN_FEATURE_PACKET_FILTERING
416/* Private ioctl to set the packet filtering params */
417#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
418#endif
419
420
421#ifdef FEATURE_WLAN_SCAN_PNO
422/* Private ioctl to get the statistics */
423#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
424#endif
425
426#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
427
428/* (SIOCIWFIRSTPRIV + 26) is currently unused */
429/* (SIOCIWFIRSTPRIV + 27) is currently unused */
430
431/* Private ioctls and their sub-ioctls */
432#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
433#define WE_SET_SMPS_PARAM 1
434#ifdef DEBUG
435#define WE_SET_FW_CRASH_INJECT 2
436#endif
437#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +0530438/* Private sub ioctl for enabling and setting histogram interval of profiling */
439#define WE_ENABLE_FW_PROFILE 4
440#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700442#ifdef WLAN_SUSPEND_RESUME_TEST
443#define WE_SET_WLAN_SUSPEND 6
444#define WE_SET_WLAN_RESUME 7
445#endif
446
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447/* (SIOCIWFIRSTPRIV + 29) is currently unused */
448
449/* 802.11p IOCTL */
450#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
451
452#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
453
454#define WLAN_STATS_INVALID 0
455#define WLAN_STATS_RETRY_CNT 1
456#define WLAN_STATS_MUL_RETRY_CNT 2
457#define WLAN_STATS_TX_FRM_CNT 3
458#define WLAN_STATS_RX_FRM_CNT 4
459#define WLAN_STATS_FRM_DUP_CNT 5
460#define WLAN_STATS_FAIL_CNT 6
461#define WLAN_STATS_RTS_FAIL_CNT 7
462#define WLAN_STATS_ACK_FAIL_CNT 8
463#define WLAN_STATS_RTS_SUC_CNT 9
464#define WLAN_STATS_RX_DISCARD_CNT 10
465#define WLAN_STATS_RX_ERROR_CNT 11
466#define WLAN_STATS_TX_BYTE_CNT 12
467
468#define WLAN_STATS_RX_BYTE_CNT 13
469#define WLAN_STATS_RX_RATE 14
470#define WLAN_STATS_TX_RATE 15
471
472#define WLAN_STATS_RX_UC_BYTE_CNT 16
473#define WLAN_STATS_RX_MC_BYTE_CNT 17
474#define WLAN_STATS_RX_BC_BYTE_CNT 18
475#define WLAN_STATS_TX_UC_BYTE_CNT 19
476#define WLAN_STATS_TX_MC_BYTE_CNT 20
477#define WLAN_STATS_TX_BC_BYTE_CNT 21
478
479#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
480 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
481 *__p++ = __type; \
482 *__p++ = __size; \
483 memcpy(__p, __val, __size); \
484 __p += __size; \
485 __tlen += __size + 2; \
486 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -0700487 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488 } \
489 } while (0)
490
491#define VERSION_VALUE_MAX_LEN 32
492
493#define TX_PER_TRACKING_DEFAULT_RATIO 5
494#define TX_PER_TRACKING_MAX_RATIO 10
495#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
496
497#define WLAN_ADAPTER 0
498#define P2P_ADAPTER 1
499
500/**
501 * mem_alloc_copy_from_user_helper - copy from user helper
502 * @wrqu_data: wireless extensions request data
503 * @len: length of @wrqu_data
504 *
505 * Helper function to allocate buffer and copy user data.
506 *
507 * Return: On success return a pointer to a kernel buffer containing a
508 * copy of the userspace data (with an additional NUL character
509 * appended for safety). On failure return %NULL.
510 */
511void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
512{
513 u8 *ptr = NULL;
514
515 /* in order to protect the code, an extra byte is post
516 * appended to the buffer and the null termination is added.
517 * However, when allocating (len+1) byte of memory, we need to
518 * make sure that there is no uint overflow when doing
519 * addition. In theory check len < UINT_MAX protects the uint
520 * overflow. For wlan private ioctl, the buffer size is much
521 * less than UINT_MAX, as a good guess, now, it is assumed
522 * that the private command buffer size is no greater than 4K
523 * (4096 bytes). So we use 4096 as the upper boundary for now.
524 */
525 if (len > MAX_USER_COMMAND_SIZE) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700526 hdd_err("Invalid length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 return NULL;
528 }
529
530 ptr = kmalloc(len + 1, GFP_KERNEL);
531 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700532 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533 return NULL;
534 }
535
536 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700537 hdd_err("failed to copy data to user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800538 kfree(ptr);
539 return NULL;
540 }
541 ptr[len] = '\0';
542 return ptr;
543}
544
545/**
546 * hdd_priv_get_data() - Get pointer to ioctl private data
547 * @p_priv_data: pointer to iw_point struct to be filled
548 * @wrqu: Pointer to IOCTL Data received from userspace
549 *
550 * Helper function to get compatible struct iw_point passed to ioctl
551 *
552 * Return - 0 if p_priv_data successfully filled, error otherwise
553 */
554int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
555{
556 if ((NULL == p_priv_data) || (NULL == wrqu)) {
557 return -EINVAL;
558 }
559#ifdef CONFIG_COMPAT
560 if (is_compat_task()) {
561 struct compat_iw_point *p_compat_priv_data;
562
563 /* Compat task:
564 * typecast to compat structure and copy the members.
565 */
566 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
567
568 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
569 p_priv_data->length = p_compat_priv_data->length;
570 p_priv_data->flags = p_compat_priv_data->flags;
571 } else {
572#endif /* #ifdef CONFIG_COMPAT */
573
574 /* Non compat task: directly copy the structure. */
575 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
576
577#ifdef CONFIG_COMPAT
578 }
579#endif /* #ifdef CONFIG_COMPAT */
580
581 return 0;
582}
583
584
585/**
586 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
587 * @pAdapter: Pointer to the hdd adapter.
588 * @length: Size of the data copied
589 * @buffer: Pointer to char buffer.
590 * @buf_len: Length of the char buffer.
591 *
592 * This function called when the "iwpriv wlan0 get_stats" command is given.
593 * It used to collect the txrx stats when the device is configured in SAP mode.
594 *
595 * Return - none
596 */
597void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
598 char *buffer, uint16_t buf_len)
599{
600 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
601 uint32_t len = 0;
602 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
603 uint32_t total_rx_delv = 0, total_rx_refused = 0;
604 int i = 0;
605
606 for (; i < NUM_CPUS; i++) {
607 total_rx_pkt += pStats->rxPackets[i];
608 total_rx_dropped += pStats->rxDropped[i];
609 total_rx_delv += pStats->rxDelivered[i];
610 total_rx_refused += pStats->rxRefused[i];
611 }
612
613 len = scnprintf(buffer, buf_len,
614 "\nTransmit"
615 "\ncalled %u, dropped %u,"
616 "\n dropped BK %u, BE %u, VI %u, VO %u"
617 "\n classified BK %u, BE %u, VI %u, VO %u"
618 "\ncompleted %u,"
619 "\n\nReceive Total"
620 "\n packets %u, dropped %u, delivered %u, refused %u"
621 "\n",
622 pStats->txXmitCalled,
623 pStats->txXmitDropped,
624
625 pStats->txXmitDroppedAC[SME_AC_BK],
626 pStats->txXmitDroppedAC[SME_AC_BE],
627 pStats->txXmitDroppedAC[SME_AC_VI],
628 pStats->txXmitDroppedAC[SME_AC_VO],
629
630 pStats->txXmitClassifiedAC[SME_AC_BK],
631 pStats->txXmitClassifiedAC[SME_AC_BE],
632 pStats->txXmitClassifiedAC[SME_AC_VI],
633 pStats->txXmitClassifiedAC[SME_AC_VO],
634
635 pStats->txCompleted,
636 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
637 );
638
639 for (i = 0; i < NUM_CPUS; i++) {
640 len += scnprintf(buffer + len, buf_len - len,
641 "\nReceive CPU: %d"
642 "\n packets %u, dropped %u, delivered %u, refused %u",
643 i, pStats->rxPackets[i], pStats->rxDropped[i],
644 pStats->rxDelivered[i], pStats->rxRefused[i]);
645 }
646
647 len += scnprintf(buffer + len, buf_len - len,
648 "\n\nTX_FLOW"
649 "\nCurrent status: %s"
650 "\ntx-flow timer start count %u"
651 "\npause count %u, unpause count %u",
652 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
653 pStats->txflow_timer_cnt,
654 pStats->txflow_pause_cnt,
655 pStats->txflow_unpause_cnt);
656
657 len += ol_txrx_stats(pAdapter->sessionId,
658 &buffer[len], (buf_len - len));
659
660 len += hdd_napi_stats(buffer + len, buf_len - len,
661 NULL, hdd_napi_get_all());
662
663 *length = len + 1;
664}
665
666/**
Govind Singha471e5e2015-10-12 17:11:14 +0530667 * hdd_wlan_list_fw_profile() - Get fw profiling points
668 * @length: Size of the data copied
669 * @buffer: Pointer to char buffer.
670 * @buf_len: Length of the char buffer.
671 *
672 * This function called when the "iwpriv wlan0 listProfile" command is given.
673 * It is used to get the supported profiling points in FW.
674 *
675 * Return - none
676 */
677void hdd_wlan_list_fw_profile(uint16_t *length,
678 char *buffer, uint16_t buf_len)
679{
680 uint32_t len = 0;
681
682 len = scnprintf(buffer, buf_len,
683 "PROF_CPU_IDLE: %u\n"
684 "PROF_PPDU_PROC: %u\n"
685 "PROF_PPDU_POST: %u\n"
686 "PROF_HTT_TX_INPUT: %u\n"
687 "PROF_MSDU_ENQ: %u\n"
688 "PROF_PPDU_POST_HAL: %u\n"
689 "PROF_COMPUTE_TX_TIME: %u\n",
690 PROF_CPU_IDLE,
691 PROF_PPDU_PROC,
692 PROF_PPDU_POST,
693 PROF_HTT_TX_INPUT,
694 PROF_MSDU_ENQ,
695 PROF_PPDU_POST_HAL,
696 PROF_COMPUTE_TX_TIME);
697
698 *length = len + 1;
699}
700
701/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 * hdd_wlan_dump_stats() - display dump Stats
703 * @adapter: adapter handle
704 * @value: value from user
705 *
706 * Return: none
707 */
708void hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value)
709{
710 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
711
712 switch (value) {
713
714 case WLAN_TXRX_HIST_STATS:
715 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
716 break;
717 case WLAN_HDD_NETIF_OPER_HISTORY:
718 wlan_hdd_display_netif_queue_history(hdd_ctx);
719 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +0530720 case WLAN_HIF_STATS:
721 hdd_display_hif_stats();
722 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723 default:
724 ol_txrx_display_stats(value);
725 break;
726 }
727}
728
729/**
730 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530731 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 * @wrqu: Pointer to IOCTL REQUEST Data.
733 * @extra: Pointer to destination buffer
734 *
735 * This function is used to get Wlan Driver, Firmware, & Hardware
736 * Version information. If @wrqu and @extra are specified, then the
737 * version string is returned. Otherwise it is simply printed to the
738 * kernel log.
739 *
740 * Return: none
741 */
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530742void hdd_wlan_get_version(hdd_context_t *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 char *extra)
744{
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530745 tSirVersionString wcnss_sw_version;
746 const char *swversion;
747 const char *hwversion;
748 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530750 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700751 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 goto error;
753 }
754
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530755 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
756 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530758 swversion = wcnss_sw_version;
759 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
760 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
761 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
762 crmid = hdd_ctx->target_fw_version & 0x7fff;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530764 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765
766 if (wrqu && extra) {
767 wrqu->data.length =
768 scnprintf(extra, WE_MAX_STR_LEN,
769 "Host SW:%s, FW:%d.%d.%d.%d, HW:%s",
770 QWLAN_VERSIONSTR,
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530771 msp_id, mspid, siid, crmid, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772 } else {
773 pr_info("Host SW:%s, FW:%d.%d.%d.%d, HW:%s\n",
774 QWLAN_VERSIONSTR,
Arun Khandavallia96c2c02016-05-17 19:15:34 +0530775 msp_id, mspid, siid, crmid, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776 }
777error:
778 return;
779}
780
781/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800782 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
783 * @pAdapter: Adapter upon which the IBSS client is active
784 * @staIdx: Station index of the IBSS peer
785 *
786 * Return: a pointer to the MAC address of the IBSS peer if the peer is
787 * found, otherwise %NULL.
788 */
789struct qdf_mac_addr *
790hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
791 uint8_t staIdx)
792{
793 uint8_t idx;
794 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
795
Naveen Rawatc45d1622016-07-05 12:20:09 -0700796 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800797 if (0 != pHddStaCtx->conn_info.staId[idx] &&
798 staIdx == pHddStaCtx->conn_info.staId[idx]) {
799 return &pHddStaCtx->conn_info.peerMacAddress[idx];
800 }
801 }
802 return NULL;
803}
804
805/**
806 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
807 * @pAdapter: Adapter upon which the IBSS client is active
808 * @staIdx: Station index of the IBSS peer
809 *
810 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
811 * otherwise an appropriate QDF_STATUS_E_* failure code.
812 */
813QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter, uint8_t staIdx)
814{
815 QDF_STATUS status = QDF_STATUS_E_FAILURE;
816 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
817 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700818 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800819
820 status =
821 sme_request_ibss_peer_info(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
822 false, staIdx);
823
824 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
825
826 if (QDF_STATUS_SUCCESS == status) {
827 unsigned long rc;
828 rc = wait_for_completion_timeout
829 (&pAdapter->ibss_peer_info_comp,
830 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
831 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700832 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800833 return QDF_STATUS_E_FAILURE;
834 }
835
836 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700837 hdd_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800838 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700839 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
840 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800841
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700842 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
843 mac_addr, sizeof(mac_addr));
844 hdd_info("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
845 mac_addr, (int)tx_rate,
846 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800847 }
848 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -0700849 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800850 }
851
852 return status;
853}
854
855/**
856 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
857 * @pAdapter: Adapter upon which the IBSS clients are active
858 *
859 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
860 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
861 */
862QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
863{
864 QDF_STATUS status = QDF_STATUS_E_FAILURE;
865 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
866 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700867 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800868 int i;
869
870 status =
871 sme_request_ibss_peer_info(hHal, pAdapter, hdd_get_ibss_peer_info_cb,
872 true, 0xFF);
873 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
874
875 if (QDF_STATUS_SUCCESS == status) {
876 unsigned long rc;
877 rc = wait_for_completion_timeout
878 (&pAdapter->ibss_peer_info_comp,
879 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
880 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700881 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800882 return QDF_STATUS_E_FAILURE;
883 }
884
885 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700886 hdd_info("pPeerInfo->numIBSSPeers = %d ",
887 (int)pPeerInfo->numPeers);
888 for (i = 0; i < pPeerInfo->numPeers; i++) {
889 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
890 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800891
Rajeev Kumar94c9b452016-03-24 12:58:47 -0700892 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
893 qdf_mem_copy(mac_addr,
894 pPeerInfo->peerInfoParams[i].mac_addr,
895 sizeof(mac_addr));
896
897 hdd_info(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
898 mac_addr, (int)tx_rate,
899 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800900 }
901 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -0700902 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800903 }
904
905 return status;
906}
907
908/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 * hdd_wlan_get_rts_threshold() - Get RTS threshold
910 * @pAdapter: adapter upon which the request was received
911 * @wrqu: pointer to the ioctl request
912 *
913 * This function retrieves the current RTS threshold value and stores
914 * it in the ioctl request structure
915 *
916 * Return: 0 if valid data was returned, non-zero on error
917 */
918int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
919{
920 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
921 uint32_t threshold = 0;
922 hdd_context_t *hdd_ctx;
923 int ret = 0;
924
925 ENTER();
926
927 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700928 hdd_err("Adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 return -EINVAL;
930 }
931
932 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
933 ret = wlan_hdd_validate_context(hdd_ctx);
934 if (0 != ret)
935 return ret;
936
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530937 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 sme_cfg_get_int(hHal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700939 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940 return -EIO;
941 }
942 wrqu->rts.value = threshold;
943
Jeff Johnson99bac312016-06-28 10:38:18 -0700944 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945
946 EXIT();
947
948 return 0;
949}
950
951/**
952 * hdd_wlan_get_frag_threshold() - Get fragmentation threshold
953 * @pAdapter: adapter upon which the request was received
954 * @wrqu: pointer to the ioctl request
955 *
956 * This function retrieves the current fragmentation threshold value
957 * and stores it in the ioctl request structure
958 *
959 * Return: 0 if valid data was returned, non-zero on error
960 */
961int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter,
962 union iwreq_data *wrqu)
963{
964 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
965 uint32_t threshold = 0, status = 0;
966 hdd_context_t *hdd_ctx;
967
968 ENTER();
969
970 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700971 hdd_err("Adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 return -EINVAL;
973 }
974
975 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
976 status = wlan_hdd_validate_context(hdd_ctx);
977 if (0 != status)
978 return status;
979
980 if (sme_cfg_get_int(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530981 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -0700982 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983 return -EIO;
984 }
985 wrqu->frag.value = threshold;
986
Jeff Johnson99bac312016-06-28 10:38:18 -0700987 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988
989 EXIT();
990
991 return 0;
992}
993
994/**
995 * hdd_wlan_get_freq() - Convert channel to frequency
996 * @channel: channel to be converted
997 * @pfreq: where to store the frequency
998 *
999 * Return: 1 on success, otherwise a negative errno
1000 */
1001int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
1002{
1003 int i;
1004 if (channel > 0) {
1005 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
1006 if (channel == freq_chan_map[i].chan) {
1007 *pfreq = freq_chan_map[i].freq;
1008 return 1;
1009 }
1010 }
1011 }
Jeff Johnson99bac312016-06-28 10:38:18 -07001012 hdd_notice("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 return -EINVAL;
1014}
1015
1016/**
1017 * hdd_is_auth_type_rsn() - RSN authentication type check
1018 * @authType: authentication type to be checked
1019 *
1020 * Return: true if @authType is an RSN authentication type,
1021 * false if it is not
1022 */
1023static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
1024{
1025 bool rsnType = false;
1026 /* is the authType supported? */
1027 switch (authType) {
1028 case eCSR_AUTH_TYPE_NONE: /* never used */
1029 rsnType = false;
1030 break;
1031 /* MAC layer authentication types */
1032 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
1033 rsnType = false;
1034 break;
1035 case eCSR_AUTH_TYPE_SHARED_KEY:
1036 rsnType = false;
1037 break;
1038 case eCSR_AUTH_TYPE_AUTOSWITCH:
1039 rsnType = false;
1040 break;
1041
1042 /* Upper layer authentication types */
1043 case eCSR_AUTH_TYPE_WPA:
1044 rsnType = true;
1045 break;
1046 case eCSR_AUTH_TYPE_WPA_PSK:
1047 rsnType = true;
1048 break;
1049 case eCSR_AUTH_TYPE_WPA_NONE:
1050 rsnType = true;
1051 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 case eCSR_AUTH_TYPE_RSN:
1054 rsnType = true;
1055 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 case eCSR_AUTH_TYPE_RSN_PSK:
1058#ifdef WLAN_FEATURE_11W
1059 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
1060 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
1061#endif
1062 rsnType = true;
1063 break;
1064 /* case eCSR_AUTH_TYPE_FAILED: */
1065 case eCSR_AUTH_TYPE_UNKNOWN:
1066 rsnType = false;
1067 break;
1068 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07001069 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 authType);
1071 rsnType = false;
1072 break;
1073 }
Jeff Johnson99bac312016-06-28 10:38:18 -07001074 hdd_notice("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 authType, rsnType);
1076 return rsnType;
1077}
1078
1079/**
1080 * hdd_get_rssi_cb() - "Get RSSI" callback function
1081 * @rssi: Current RSSI of the station
1082 * @staId: ID of the station
1083 * @pContext: opaque context originally passed to SME. HDD always passes
1084 * a &struct statsContext
1085 *
1086 * Return: None
1087 */
1088static void hdd_get_rssi_cb(int8_t rssi, uint32_t staId, void *pContext)
1089{
1090 struct statsContext *pStatsContext;
1091 hdd_adapter_t *pAdapter;
1092
1093 if (ioctl_debug) {
1094 pr_info("%s: rssi [%d] STA [%d] pContext [%p]\n",
1095 __func__, (int)rssi, (int)staId, pContext);
1096 }
1097
1098 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001099 hdd_err("Bad param");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001100 return;
1101 }
1102
1103 pStatsContext = pContext;
1104 pAdapter = pStatsContext->pAdapter;
1105
1106 /* there is a race condition that exists between this callback
1107 * function and the caller since the caller could time out
1108 * either before or while this code is executing. we use a
1109 * spinlock to serialize these actions
1110 */
1111 spin_lock(&hdd_context_lock);
1112
1113 if ((NULL == pAdapter) ||
1114 (RSSI_CONTEXT_MAGIC != pStatsContext->magic)) {
1115 /* the caller presumably timed out so there is nothing
1116 * we can do
1117 */
1118 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07001119 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1120 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 if (ioctl_debug) {
1122 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1123 __func__, pAdapter, pStatsContext->magic);
1124 }
1125 return;
1126 }
1127
1128 /* context is valid so caller is still waiting */
1129
1130 /* paranoia: invalidate the magic */
1131 pStatsContext->magic = 0;
1132
1133 /* copy over the rssi */
1134 pAdapter->rssi = rssi;
1135
Sachin Ahujabef8c102015-11-16 15:15:49 +05301136 if (pAdapter->rssi > 0)
1137 pAdapter->rssi = 0;
1138
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139 /* notify the caller */
1140 complete(&pStatsContext->completion);
1141
1142 /* serialization is complete */
1143 spin_unlock(&hdd_context_lock);
1144}
1145
1146/**
1147 * hdd_get_snr_cb() - "Get SNR" callback function
1148 * @snr: Current SNR of the station
1149 * @staId: ID of the station
1150 * @pContext: opaque context originally passed to SME. HDD always passes
1151 * a &struct statsContext
1152 *
1153 * Return: None
1154 */
1155static void hdd_get_snr_cb(int8_t snr, uint32_t staId, void *pContext)
1156{
1157 struct statsContext *pStatsContext;
1158 hdd_adapter_t *pAdapter;
1159
1160 if (ioctl_debug) {
1161 pr_info("%s: snr [%d] STA [%d] pContext [%p]\n",
1162 __func__, (int)snr, (int)staId, pContext);
1163 }
1164
1165 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001166 hdd_err("Bad param");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001167 return;
1168 }
1169
1170 pStatsContext = pContext;
1171 pAdapter = pStatsContext->pAdapter;
1172
1173 /* there is a race condition that exists between this callback
1174 * function and the caller since the caller could time out
1175 * either before or while this code is executing. we use a
1176 * spinlock to serialize these actions
1177 */
1178 spin_lock(&hdd_context_lock);
1179
1180 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic)) {
1181 /* the caller presumably timed out so there is nothing
1182 * we can do
1183 */
1184 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07001185 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1186 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001187 if (ioctl_debug) {
1188 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1189 __func__, pAdapter, pStatsContext->magic);
1190 }
1191 return;
1192 }
1193
1194 /* context is valid so caller is still waiting */
1195
1196 /* paranoia: invalidate the magic */
1197 pStatsContext->magic = 0;
1198
1199 /* copy over the snr */
1200 pAdapter->snr = snr;
1201
1202 /* notify the caller */
1203 complete(&pStatsContext->completion);
1204
1205 /* serialization is complete */
1206 spin_unlock(&hdd_context_lock);
1207}
1208
1209/**
1210 * wlan_hdd_get_rssi() - Get the current RSSI
1211 * @pAdapter: adapter upon which the measurement is requested
1212 * @rssi_value: pointer to where the RSSI should be returned
1213 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301214 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301216QDF_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217{
1218 struct statsContext context;
1219 hdd_context_t *pHddCtx;
1220 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301221 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 unsigned long rc;
1223
1224 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001225 hdd_warn("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301226 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08001228 if (cds_is_driver_recovering()) {
1229 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
1230 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231 /* return a cached value */
1232 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301233 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 }
1235
1236 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1237 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1238
1239 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
1240 hdd_err("Not associated!, return last connected AP rssi!");
1241 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301242 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 }
1244
1245 if (pHddStaCtx->hdd_ReassocScenario) {
1246 hdd_info("Roaming in progress, return cached RSSI");
1247 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301248 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249 }
1250
1251 init_completion(&context.completion);
1252 context.pAdapter = pAdapter;
1253 context.magic = RSSI_CONTEXT_MAGIC;
1254
1255 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
1256 pHddStaCtx->conn_info.staId[0],
1257 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
1258 &context, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301259 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001260 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 /* we'll returned a cached value below */
1262 } else {
1263 /* request was sent -- wait for the response */
1264 rc = wait_for_completion_timeout(&context.completion,
1265 msecs_to_jiffies
1266 (WLAN_WAIT_TIME_STATS));
1267 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001268 hdd_err("SME timed out while retrieving RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 /* we'll now returned a cached value below */
1270 }
1271 }
1272
1273 /* either we never sent a request, we sent a request and
1274 * received a response or we sent a request and timed out. if
1275 * we never sent a request or if we sent a request and got a
1276 * response, we want to clear the magic out of paranoia. if
1277 * we timed out there is a race condition such that the
1278 * callback function could be executing at the same time we
1279 * are. of primary concern is if the callback function had
1280 * already verified the "magic" but had not yet set the
1281 * completion variable when a timeout occurred. we serialize
1282 * these activities by invalidating the magic while holding a
1283 * shared spinlock which will cause us to block if the
1284 * callback is currently executing
1285 */
1286 spin_lock(&hdd_context_lock);
1287 context.magic = 0;
1288 spin_unlock(&hdd_context_lock);
1289
1290 *rssi_value = pAdapter->rssi;
1291
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301292 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293}
1294
1295/**
1296 * wlan_hdd_get_snr() - Get the current SNR
1297 * @pAdapter: adapter upon which the measurement is requested
1298 * @snr: pointer to where the SNR should be returned
1299 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301300 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301302QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303{
1304 struct statsContext context;
1305 hdd_context_t *pHddCtx;
1306 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301307 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 unsigned long rc;
1309 int valid;
1310
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301311 ENTER();
1312
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001313 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001314 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301315 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001316 }
1317
1318 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1319
1320 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301321 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301322 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323
1324 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1325
1326 init_completion(&context.completion);
1327 context.pAdapter = pAdapter;
1328 context.magic = SNR_CONTEXT_MAGIC;
1329
1330 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
1331 pHddStaCtx->conn_info.staId[0],
1332 pHddStaCtx->conn_info.bssId, &context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301333 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001334 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 /* we'll returned a cached value below */
1336 } else {
1337 /* request was sent -- wait for the response */
1338 rc = wait_for_completion_timeout(&context.completion,
1339 msecs_to_jiffies
1340 (WLAN_WAIT_TIME_STATS));
1341 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001342 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 /* we'll now returned a cached value below */
1344 }
1345 }
1346
1347 /* either we never sent a request, we sent a request and
1348 * received a response or we sent a request and timed out. if
1349 * we never sent a request or if we sent a request and got a
1350 * response, we want to clear the magic out of paranoia. if
1351 * we timed out there is a race condition such that the
1352 * callback function could be executing at the same time we
1353 * are. of primary concern is if the callback function had
1354 * already verified the "magic" but had not yet set the
1355 * completion variable when a timeout occurred. we serialize
1356 * these activities by invalidating the magic while holding a
1357 * shared spinlock which will cause us to block if the
1358 * callback is currently executing
1359 */
1360 spin_lock(&hdd_context_lock);
1361 context.magic = 0;
1362 spin_unlock(&hdd_context_lock);
1363
1364 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301365 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301366 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367}
1368
1369/**
1370 * hdd_get_link_speed_cb() - Get link speed callback function
1371 * @pLinkSpeed: pointer to the link speed record
1372 * @pContext: pointer to the user context passed to SME
1373 *
1374 * This function is passed as the callback function to
1375 * sme_get_link_speed() by wlan_hdd_get_linkspeed_for_peermac(). By
1376 * agreement a &struct linkspeedContext is passed as @pContext. If
1377 * the context is valid, then the contents of @pLinkSpeed are copied
1378 * into the adapter record referenced by @pContext where they can be
1379 * subsequently retrieved. If the context is invalid, then this
1380 * function does nothing since it is assumed the caller has already
1381 * timed-out and destroyed the context.
1382 *
1383 * Return: None.
1384 */
1385static void
1386hdd_get_link_speed_cb(tSirLinkSpeedInfo *pLinkSpeed, void *pContext)
1387{
1388 struct linkspeedContext *pLinkSpeedContext;
1389 hdd_adapter_t *pAdapter;
1390
1391 if ((NULL == pLinkSpeed) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001392 hdd_err("Bad param, pLinkSpeed [%p] pContext [%p]",
1393 pLinkSpeed, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 return;
1395 }
1396 spin_lock(&hdd_context_lock);
1397 pLinkSpeedContext = pContext;
1398 pAdapter = pLinkSpeedContext->pAdapter;
1399
1400 /* there is a race condition that exists between this callback
1401 * function and the caller since the caller could time out either
1402 * before or while this code is executing. we use a spinlock to
1403 * serialize these actions
1404 */
1405
1406 if ((NULL == pAdapter) ||
1407 (LINK_CONTEXT_MAGIC != pLinkSpeedContext->magic)) {
1408 /* the caller presumably timed out so there is nothing
1409 * we can do
1410 */
1411 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07001412 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1413 pAdapter, pLinkSpeedContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 if (ioctl_debug) {
1415 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
1416 __func__, pAdapter, pLinkSpeedContext->magic);
1417 }
1418 return;
1419 }
1420
1421 /* context is valid so caller is still waiting */
1422
1423 /* paranoia: invalidate the magic */
1424 pLinkSpeedContext->magic = 0;
1425
1426 /* copy over the stats. do so as a struct copy */
1427 pAdapter->ls_stats = *pLinkSpeed;
1428
1429 /* notify the caller */
1430 complete(&pLinkSpeedContext->completion);
1431
1432 /* serialization is complete */
1433 spin_unlock(&hdd_context_lock);
1434}
1435
1436/**
1437 * wlan_hdd_get_linkspeed_for_peermac() - Get link speed for a peer
1438 * @pAdapter: adapter upon which the peer is active
1439 * @macAddress: MAC address of the peer
1440 *
1441 * This function will send a query to SME for the linkspeed of the
1442 * given peer, and then wait for the callback to be invoked.
1443 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301444 * Return: QDF_STATUS_SUCCESS if linkspeed data is available,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301445 * otherwise a QDF_STATUS_E_** error.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301447QDF_STATUS wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301448 struct qdf_mac_addr macAddress) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301449 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450 unsigned long rc;
1451 struct linkspeedContext context;
1452 tSirLinkSpeedInfo *linkspeed_req;
1453
1454 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001455 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301456 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301458 linkspeed_req = qdf_mem_malloc(sizeof(*linkspeed_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 if (NULL == linkspeed_req) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001460 hdd_err("Request Buffer Alloc Fail");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301461 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 }
1463 init_completion(&context.completion);
1464 context.pAdapter = pAdapter;
1465 context.magic = LINK_CONTEXT_MAGIC;
1466
Anurag Chouhanc5548422016-02-24 18:33:27 +05301467 qdf_copy_macaddr(&linkspeed_req->peer_macaddr, &macAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001468 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(pAdapter),
1469 linkspeed_req,
1470 &context, hdd_get_link_speed_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301471 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001472 hdd_err("Unable to retrieve statistics for link speed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301473 qdf_mem_free(linkspeed_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 } else {
1475 rc = wait_for_completion_timeout
1476 (&context.completion,
1477 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
1478 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001479 hdd_err("SME timed out while retrieving link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480 }
1481 }
1482
1483 /* either we never sent a request, we sent a request and
1484 * received a response or we sent a request and timed out. if
1485 * we never sent a request or if we sent a request and got a
1486 * response, we want to clear the magic out of paranoia. if
1487 * we timed out there is a race condition such that the
1488 * callback function could be executing at the same time we
1489 * are. of primary concern is if the callback function had
1490 * already verified the "magic" but had not yet set the
1491 * completion variable when a timeout occurred. we serialize
1492 * these activities by invalidating the magic while holding a
1493 * shared spinlock which will cause us to block if the
1494 * callback is currently executing
1495 */
1496 spin_lock(&hdd_context_lock);
1497 context.magic = 0;
1498 spin_unlock(&hdd_context_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301499 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500}
1501
1502/**
1503 * wlan_hdd_get_link_speed() - get link speed
1504 * @pAdapter: pointer to the adapter
1505 * @link_speed: pointer to link speed
1506 *
1507 * This function fetches per bssid link speed.
1508 *
1509 * Return: if associated, link speed shall be returned.
1510 * if not associated, link speed of 0 is returned.
1511 * On error, error number will be returned.
1512 */
1513int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
1514{
1515 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
1516 hdd_station_ctx_t *hdd_stactx =
1517 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
1518 int ret;
1519
1520 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301521 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05301524 /* Linkspeed is allowed only for P2P mode */
1525 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
1526 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
1527 hdd_device_mode_to_string(sta_adapter->device_mode),
1528 sta_adapter->device_mode);
1529 return -ENOTSUPP;
1530 }
1531
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
1533 /* we are not connected so we don't have a classAstats */
1534 *link_speed = 0;
1535 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301536 QDF_STATUS status;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301537 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538
Anurag Chouhanc5548422016-02-24 18:33:27 +05301539 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540
1541 status = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301542 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001543 hdd_err("Unable to retrieve SME linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 return -EINVAL;
1545 }
1546 *link_speed = sta_adapter->ls_stats.estLinkSpeed;
1547 /* linkspeed in units of 500 kbps */
1548 *link_speed = (*link_speed) / 500;
1549 }
1550 return 0;
1551}
1552
1553/**
1554 * hdd_statistics_cb() - "Get statistics" callback function
1555 * @pStats: statistics payload
1556 * @pContext: opaque context originally passed to SME. HDD always passes
1557 * a pointer to an adapter
1558 *
1559 * Return: None
1560 */
1561void hdd_statistics_cb(void *pStats, void *pContext)
1562{
1563 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
1564 hdd_stats_t *pStatsCache = NULL;
1565 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05301566 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567
1568 tCsrSummaryStatsInfo *pSummaryStats = NULL;
1569 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
1570 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
1571 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
1572 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
1573 tCsrPerStaStatsInfo *pPerStaStats = NULL;
1574
1575 if (pAdapter != NULL)
1576 pStatsCache = &pAdapter->hdd_stats;
1577
1578 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
1579 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
1580 pClassBStats = (tCsrGlobalClassBStatsInfo *) (pClassAStats + 1);
1581 pClassCStats = (tCsrGlobalClassCStatsInfo *) (pClassBStats + 1);
1582 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassCStats + 1);
1583 pPerStaStats = (tCsrPerStaStatsInfo *) (pClassDStats + 1);
1584
1585 if (pStatsCache != NULL) {
1586 /* copy the stats into the cache we keep in the
1587 * adapter instance structure
1588 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301589 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301591 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301593 qdf_mem_copy(&pStatsCache->ClassB_stat, pClassBStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 sizeof(pStatsCache->ClassB_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301595 qdf_mem_copy(&pStatsCache->ClassC_stat, pClassCStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 sizeof(pStatsCache->ClassC_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301597 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 sizeof(pStatsCache->ClassD_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301599 qdf_mem_copy(&pStatsCache->perStaStats, pPerStaStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 sizeof(pStatsCache->perStaStats));
1601 }
1602
1603 if (pAdapter) {
1604 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301605 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05301606 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001607 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 return;
1609 }
1610 }
1611}
1612
1613/**
1614 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
1615 * @pAdapter: adapter who's IEs are to be cleared
1616 *
1617 * Return: None
1618 */
1619void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
1620{
1621 int i = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001622 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07001623
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001624 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625
1626 /* clear WPA/RSN/WSC IE information in the profile */
1627 pWextState->roamProfile.nWPAReqIELength = 0;
1628 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
1629 pWextState->roamProfile.nRSNReqIELength = 0;
1630 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
1631
1632#ifdef FEATURE_WLAN_WAPI
1633 pWextState->roamProfile.nWAPIReqIELength = 0;
1634 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
1635#endif
1636
1637 pWextState->roamProfile.bWPSAssociation = false;
1638 pWextState->roamProfile.bOSENAssociation = false;
1639 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
1640 pWextState->roamProfile.nAddIEScanLength = 0;
1641 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
1642 pWextState->roamProfile.nAddIEAssocLength = 0;
1643
1644 pWextState->roamProfile.EncryptionType.numEntries = 1;
1645 pWextState->roamProfile.EncryptionType.encryptionType[0]
1646 = eCSR_ENCRYPT_TYPE_NONE;
1647
1648 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
1649 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
1650 = eCSR_ENCRYPT_TYPE_NONE;
1651
1652 pWextState->roamProfile.AuthType.numEntries = 1;
1653 pWextState->roamProfile.AuthType.authType[0] =
1654 eCSR_AUTH_TYPE_OPEN_SYSTEM;
1655
1656#ifdef WLAN_FEATURE_11W
1657 pWextState->roamProfile.MFPEnabled = false;
1658 pWextState->roamProfile.MFPRequired = 0;
1659 pWextState->roamProfile.MFPCapable = 0;
1660#endif
1661
1662 pWextState->authKeyMgmt = 0;
1663
1664 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
1665 if (pWextState->roamProfile.Keys.KeyMaterial[i]) {
1666 pWextState->roamProfile.Keys.KeyLength[i] = 0;
1667 }
1668 }
1669#ifdef FEATURE_WLAN_WAPI
1670 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
1671 pAdapter->wapi_info.nWapiMode = 0;
1672#endif
1673
Anurag Chouhanc5548422016-02-24 18:33:27 +05301674 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07001675 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676}
1677
1678/**
1679 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
1680 * @oui: The OUI that is being searched for
1681 * @oui_size: The length of @oui
1682 * @ie: The set of IEs within which we're trying to find @oui
1683 * @ie_len: The length of @ie
1684 *
1685 * This function will scan the IEs contained within @ie looking for @oui.
1686 *
1687 * Return: Pointer to @oui embedded within @ie if it is present, NULL
1688 * if @oui is not present within @ie.
1689 */
1690uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
1691 uint8_t *ie, int ie_len)
1692{
1693 int left = ie_len;
1694 uint8_t *ptr = ie;
1695 uint8_t elem_id, elem_len;
1696 uint8_t eid = 0xDD;
1697
1698 if (NULL == ie || 0 == ie_len)
1699 return NULL;
1700
1701 while (left >= 2) {
1702 elem_id = ptr[0];
1703 elem_len = ptr[1];
1704 left -= 2;
1705 if (elem_len > left) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001706 hdd_alert("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 eid, elem_len, left);
1708 return NULL;
1709 }
1710 if (elem_id == eid) {
1711 if (memcmp(&ptr[2], oui, oui_size) == 0)
1712 return ptr;
1713 }
1714
1715 left -= elem_len;
1716 ptr += (elem_len + 2);
1717 }
1718 return NULL;
1719}
1720
1721/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05301722 * hdd_get_ldpc() - Get adapter LDPC
1723 * @adapter: adapter being queried
1724 * @value: where to store the value
1725 *
1726 * Return: 0 on success, negative errno on failure
1727 */
1728int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
1729{
1730 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1731 int ret;
1732
1733 ENTER();
1734 ret = sme_get_ht_config(hal, adapter->sessionId,
1735 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
1736 if (ret < 0) {
1737 hdd_alert("Failed to get LDPC value");
1738 } else {
1739 *value = ret;
1740 ret = 0;
1741 }
1742 return ret;
1743}
1744
1745/**
1746 * hdd_set_ldpc() - Set adapter LDPC
1747 * @adapter: adapter being modified
1748 * @value: new LDPC value
1749 *
1750 * Return: 0 on success, negative errno on failure
1751 */
1752int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
1753{
1754 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1755 int ret;
1756
1757 hdd_alert("%d", value);
1758 if (value) {
1759 /* make sure HT capabilities allow this */
1760 QDF_STATUS status;
1761 uint32_t cfg_value;
1762 union {
1763 uint16_t cfg_value16;
1764 tSirMacHTCapabilityInfo ht_cap_info;
1765 } u;
1766
1767 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1768 if (QDF_STATUS_SUCCESS != status) {
1769 hdd_alert("Failed to get HT capability info");
1770 return -EIO;
1771 }
1772 u.cfg_value16 = cfg_value & 0xFFFF;
1773 if (!u.ht_cap_info.advCodingCap) {
1774 hdd_alert("LDCP not supported");
1775 return -EINVAL;
1776 }
1777 }
1778
1779 ret = sme_update_ht_config(hal, adapter->sessionId,
1780 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
1781 value);
1782 if (ret)
1783 hdd_alert("Failed to set LDPC value");
1784
1785 return ret;
1786}
1787
1788/**
1789 * hdd_get_tx_stbc() - Get adapter TX STBC
1790 * @adapter: adapter being queried
1791 * @value: where to store the value
1792 *
1793 * Return: 0 on success, negative errno on failure
1794 */
1795int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
1796{
1797 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1798 int ret;
1799
1800 ENTER();
1801 ret = sme_get_ht_config(hal, adapter->sessionId,
1802 WNI_CFG_HT_CAP_INFO_TX_STBC);
1803 if (ret < 0) {
1804 hdd_alert("Failed to get TX STBC value");
1805 } else {
1806 *value = ret;
1807 ret = 0;
1808 }
1809
1810 return ret;
1811}
1812
1813/**
1814 * hdd_set_tx_stbc() - Set adapter TX STBC
1815 * @adapter: adapter being modified
1816 * @value: new TX STBC value
1817 *
1818 * Return: 0 on success, negative errno on failure
1819 */
1820int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
1821{
1822 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1823 int ret;
1824
1825 hdd_alert("%d", value);
1826 if (value) {
1827 /* make sure HT capabilities allow this */
1828 QDF_STATUS status;
1829 uint32_t cfg_value;
1830 union {
1831 uint16_t cfg_value16;
1832 tSirMacHTCapabilityInfo ht_cap_info;
1833 } u;
1834
1835 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1836 if (QDF_STATUS_SUCCESS != status) {
1837 hdd_alert("Failed to get HT capability info");
1838 return -EIO;
1839 }
1840 u.cfg_value16 = cfg_value & 0xFFFF;
1841 if (!u.ht_cap_info.txSTBC) {
1842 hdd_alert("TX STBC not supported");
1843 return -EINVAL;
1844 }
1845 }
1846 ret = sme_update_ht_config(hal, adapter->sessionId,
1847 WNI_CFG_HT_CAP_INFO_TX_STBC,
1848 value);
1849 if (ret)
1850 hdd_alert("Failed to set TX STBC value");
1851
1852 return ret;
1853}
1854
1855/**
1856 * hdd_get_rx_stbc() - Get adapter RX STBC
1857 * @adapter: adapter being queried
1858 * @value: where to store the value
1859 *
1860 * Return: 0 on success, negative errno on failure
1861 */
1862int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
1863{
1864 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1865 int ret;
1866
1867 ENTER();
1868 ret = sme_get_ht_config(hal, adapter->sessionId,
1869 WNI_CFG_HT_CAP_INFO_RX_STBC);
1870 if (ret < 0) {
1871 hdd_alert("Failed to get RX STBC value");
1872 } else {
1873 *value = ret;
1874 ret = 0;
1875 }
1876
1877 return ret;
1878}
1879
1880/**
1881 * hdd_set_rx_stbc() - Set adapter RX STBC
1882 * @adapter: adapter being modified
1883 * @value: new RX STBC value
1884 *
1885 * Return: 0 on success, negative errno on failure
1886 */
1887int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
1888{
1889 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
1890 int ret;
1891
1892 hdd_alert("%d", value);
1893 if (value) {
1894 /* make sure HT capabilities allow this */
1895 QDF_STATUS status;
1896 uint32_t cfg_value;
1897 union {
1898 uint16_t cfg_value16;
1899 tSirMacHTCapabilityInfo ht_cap_info;
1900 } u;
1901
1902 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
1903 if (QDF_STATUS_SUCCESS != status) {
1904 hdd_alert("Failed to get HT capability info");
1905 return -EIO;
1906 }
1907 u.cfg_value16 = cfg_value & 0xFFFF;
1908 if (!u.ht_cap_info.rxSTBC) {
1909 hdd_alert("RX STBC not supported");
1910 return -EINVAL;
1911 }
1912 }
1913 ret = sme_update_ht_config(hal, adapter->sessionId,
1914 WNI_CFG_HT_CAP_INFO_RX_STBC,
1915 value);
1916 if (ret)
1917 hdd_alert("Failed to set RX STBC value");
1918
1919 return ret;
1920}
1921
1922/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
1924 * @dev: device upon which the ioctl was received
1925 * @info: ioctl request information
1926 * @wrqu: ioctl request data
1927 * @extra: ioctl extra data
1928 *
1929 * Return: 0 on success, non-zero on error
1930 */
1931static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1932 union iwreq_data *wrqu, char *extra)
1933{
1934 hdd_adapter_t *adapter;
1935 hdd_context_t *hdd_ctx;
1936 int ret;
1937
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08001938 ENTER_DEV(dev);
1939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1941 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1942 ret = wlan_hdd_validate_context(hdd_ctx);
1943 if (0 != ret)
1944 return ret;
1945
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 /* Do nothing for now */
1947 return 0;
1948}
1949
1950/**
1951 * iw_set_commit() - SSR wrapper function for __iw_set_commit
1952 * @dev: pointer to net_device
1953 * @info: pointer to iw_request_info
1954 * @wrqu: pointer to iwreq_data
1955 * @extra: extra
1956 *
1957 * Return: 0 on success, error number otherwise
1958 */
1959int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
1960 union iwreq_data *wrqu, char *extra)
1961{
1962 int ret;
1963
1964 cds_ssr_protect(__func__);
1965 ret = __iw_set_commit(dev, info, wrqu, extra);
1966 cds_ssr_unprotect(__func__);
1967
1968 return ret;
1969}
1970
1971/**
1972 * __iw_get_name() - SIOCGIWNAME ioctl handler
1973 * @dev: device upon which the ioctl was received
1974 * @info: ioctl request information
1975 * @wrqu: ioctl request data
1976 * @extra: ioctl extra data
1977 *
1978 * Return: 0 on success, non-zero on error
1979 */
1980static int __iw_get_name(struct net_device *dev,
1981 struct iw_request_info *info, char *wrqu, char *extra)
1982{
1983 hdd_adapter_t *adapter;
1984 hdd_context_t *hdd_ctx;
1985 int ret;
1986
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08001987 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988
1989 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1990 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1991 ret = wlan_hdd_validate_context(hdd_ctx);
1992 if (0 != ret)
1993 return ret;
1994
1995 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
1996 EXIT();
1997 return 0;
1998}
1999
2000/**
2001 * __iw_get_name() - SSR wrapper for __iw_get_name
2002 * @dev: pointer to net_device
2003 * @info: pointer to iw_request_info
2004 * @wrqu: pointer to iwreq_data
2005 * @extra: extra
2006 *
2007 * Return: 0 on success, error number otherwise
2008 */
2009static int iw_get_name(struct net_device *dev,
2010 struct iw_request_info *info,
2011 char *wrqu, char *extra)
2012{
2013 int ret;
2014
2015 cds_ssr_protect(__func__);
2016 ret = __iw_get_name(dev, info, wrqu, extra);
2017 cds_ssr_unprotect(__func__);
2018
2019 return ret;
2020}
2021
2022/**
2023 * __iw_set_mode() - ioctl handler
2024 * @dev: device upon which the ioctl was received
2025 * @info: ioctl request information
2026 * @wrqu: ioctl request data
2027 * @extra: ioctl extra data
2028 *
2029 * Return: 0 on success, non-zero on error
2030 */
2031static int __iw_set_mode(struct net_device *dev,
2032 struct iw_request_info *info,
2033 union iwreq_data *wrqu, char *extra)
2034{
2035 hdd_wext_state_t *pWextState;
2036 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2037 hdd_context_t *hdd_ctx;
2038 tCsrRoamProfile *pRoamProfile;
2039 eCsrRoamBssType LastBSSType;
2040 eMib_dot11DesiredBssType connectedBssType;
2041 struct hdd_config *pConfig;
2042 struct wireless_dev *wdev;
2043 int ret;
2044
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002045 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046
2047 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2048 ret = wlan_hdd_validate_context(hdd_ctx);
2049 if (0 != ret)
2050 return ret;
2051
2052 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2053 wdev = dev->ieee80211_ptr;
2054 pRoamProfile = &pWextState->roamProfile;
2055 LastBSSType = pRoamProfile->BSSType;
2056
Jeff Johnson99bac312016-06-28 10:38:18 -07002057 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058
2059 switch (wrqu->mode) {
2060 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07002061 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2063 /* Set the phymode correctly for IBSS. */
2064 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
2065 pWextState->roamProfile.phyMode =
2066 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08002067 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068 wdev->iftype = NL80211_IFTYPE_ADHOC;
2069 break;
2070 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07002071 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2073 wdev->iftype = NL80211_IFTYPE_STATION;
2074 break;
2075 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07002076 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002077 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
2078 break;
2079 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002080 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002081 return -EOPNOTSUPP;
2082 }
2083
2084 if (LastBSSType != pRoamProfile->BSSType) {
2085 /* the BSS mode changed. We need to issue disconnect
2086 * if connected or in IBSS disconnect state
2087 */
2088 if (hdd_conn_get_connected_bss_type
2089 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType)
2090 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302091 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 /* need to issue a disconnect to CSR. */
2093 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302094 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
2096 pAdapter->sessionId,
2097 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302098 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 unsigned long rc;
2100 rc = wait_for_completion_timeout(&pAdapter->
2101 disconnect_comp_var,
2102 msecs_to_jiffies
2103 (WLAN_WAIT_TIME_DISCONNECT));
2104 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07002105 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 }
2107 }
2108 }
2109
2110 EXIT();
2111 return 0;
2112}
2113
2114/**
2115 * iw_set_mode() - SSR wrapper for __iw_set_mode()
2116 * @dev: pointer to net_device
2117 * @info: pointer to iw_request_info
2118 * @wrqu: pointer to iwreq_data
2119 * @extra: pointer to extra ioctl payload
2120 *
2121 * Return: 0 on success, error number otherwise
2122 */
2123static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
2124 union iwreq_data *wrqu, char *extra)
2125{
2126 int ret;
2127
2128 cds_ssr_protect(__func__);
2129 ret = __iw_set_mode(dev, info, wrqu, extra);
2130 cds_ssr_unprotect(__func__);
2131
2132 return ret;
2133}
2134
2135/**
2136 * __iw_get_mode() - SIOCGIWMODE ioctl handler
2137 * @dev: device upon which the ioctl was received
2138 * @info: ioctl request information
2139 * @wrqu: ioctl request data
2140 * @extra: ioctl extra data
2141 *
2142 * Return: 0 on success, non-zero on error
2143 */
2144static int
2145__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2146 union iwreq_data *wrqu, char *extra)
2147{
2148 hdd_wext_state_t *pWextState;
2149 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2150 hdd_context_t *hdd_ctx;
2151 int ret;
2152
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002153 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154
2155 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2156 ret = wlan_hdd_validate_context(hdd_ctx);
2157 if (0 != ret)
2158 return ret;
2159
2160 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2161
2162 switch (pWextState->roamProfile.BSSType) {
2163 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07002164 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 wrqu->mode = IW_MODE_INFRA;
2166 break;
2167 case eCSR_BSS_TYPE_IBSS:
2168 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07002169 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170 wrqu->mode = IW_MODE_ADHOC;
2171 break;
2172 case eCSR_BSS_TYPE_ANY:
2173 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002174 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 wrqu->mode = IW_MODE_AUTO;
2176 break;
2177 }
2178
2179 EXIT();
2180 return 0;
2181}
2182
2183/**
2184 * iw_get_mode() - SSR wrapper for __iw_get_mode()
2185 * @dev: pointer to net_device
2186 * @info: pointer to iw_request_info
2187 * @wrqu: pointer to iwreq_data
2188 * @extra: pointer to extra ioctl payload
2189 *
2190 * Return: 0 on success, error number otherwise
2191 */
2192static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2193 union iwreq_data *wrqu, char *extra)
2194{
2195 int ret;
2196
2197 cds_ssr_protect(__func__);
2198 ret = __iw_get_mode(dev, info, wrqu, extra);
2199 cds_ssr_unprotect(__func__);
2200
2201 return ret;
2202}
2203
2204/**
2205 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
2206 * @dev: device upon which the ioctl was received
2207 * @info: ioctl request information
2208 * @wrqu: ioctl request data
2209 * @extra: ioctl extra data
2210 *
2211 * Return: 0 on success, non-zero on error
2212 */
2213static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2214 union iwreq_data *wrqu, char *extra)
2215{
2216 uint32_t numChans = 0;
2217 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2218 uint32_t indx = 0;
2219 int ret;
2220 hdd_wext_state_t *pWextState;
2221 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2222 hdd_context_t *hdd_ctx;
2223 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2225 tCsrRoamProfile *pRoamProfile;
2226
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002227 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228
2229 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2230 ret = wlan_hdd_validate_context(hdd_ctx);
2231 if (0 != ret)
2232 return ret;
2233
2234 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2235
2236 pRoamProfile = &pWextState->roamProfile;
2237
Jeff Johnson99bac312016-06-28 10:38:18 -07002238 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239
2240 /* Link is up then return cant set channel */
2241 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
2242 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002243 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 return -EOPNOTSUPP;
2245 }
2246
2247 /* Settings by Frequency as input */
2248 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
2249 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
2250 uint32_t freq = wrqu->freq.m / 100000;
2251
2252 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
2253 && (freq != freq_chan_map[indx].freq))
2254 indx++;
2255 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
2256 return -EINVAL;
2257 }
2258 wrqu->freq.e = 0;
2259 wrqu->freq.m = freq_chan_map[indx].chan;
2260
2261 }
2262
2263 if (wrqu->freq.e == 0) {
2264 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2265 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002266 hdd_notice("Channel %d is outside valid range from %d to %d",
2267 wrqu->freq.m,
2268 WNI_CFG_CURRENT_CHANNEL_STAMIN,
2269 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 return -EINVAL;
2271 }
2272
2273 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2274
2275 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2276 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302277 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002278 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 return -EIO;
2280 }
2281
2282 for (indx = 0; indx < numChans; indx++) {
2283 if (wrqu->freq.m == validChan[indx]) {
2284 break;
2285 }
2286 }
2287 } else {
2288
2289 return -EINVAL;
2290 }
2291
2292 if (indx >= numChans) {
2293 return -EINVAL;
2294 }
2295
2296 /* Set the Operational Channel */
2297 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2298 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2299 pRoamProfile->ChannelInfo.ChannelList =
2300 &pHddStaCtx->conn_info.operationChannel;
2301
Jeff Johnson99bac312016-06-28 10:38:18 -07002302 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303
2304 EXIT();
2305
2306 return ret;
2307}
2308
2309/**
2310 * iw_set_freq() - SSR wrapper for __iw_set_freq()
2311 * @dev: pointer to net_device
2312 * @info: pointer to iw_request_info
2313 * @wrqu: pointer to iwreq_data
2314 * @extra: pointer to extra ioctl payload
2315 *
2316 * Return: 0 on success, error number otherwise
2317 */
2318static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2319 union iwreq_data *wrqu, char *extra)
2320{
2321 int ret;
2322
2323 cds_ssr_protect(__func__);
2324 ret = __iw_set_freq(dev, info, wrqu, extra);
2325 cds_ssr_unprotect(__func__);
2326
2327 return ret;
2328}
2329
2330/**
2331 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
2332 * @dev: device upon which the ioctl was received
2333 * @info: ioctl request information
2334 * @wrqu: ioctl request data
2335 * @extra: ioctl extra data
2336 *
2337 * Return: 0 on success, non-zero on error
2338 */
2339static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2340 struct iw_freq *fwrq, char *extra)
2341{
2342 uint32_t status = false, channel = 0, freq = 0;
2343 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2344 tHalHandle hHal;
2345 hdd_wext_state_t *pWextState;
2346 tCsrRoamProfile *pRoamProfile;
2347 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2348 hdd_context_t *hdd_ctx;
2349 int ret;
2350
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002351 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352
2353 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2354 ret = wlan_hdd_validate_context(hdd_ctx);
2355 if (0 != ret)
2356 return ret;
2357
2358 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2359 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2360
2361 pRoamProfile = &pWextState->roamProfile;
2362
2363 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
2364 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302365 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002366 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 pAdapter->sessionId);
2368 return -EIO;
2369 } else {
2370 status = hdd_wlan_get_freq(channel, &freq);
2371 if (true == status) {
2372 /* Set Exponent parameter as 6 (MHZ)
2373 * in struct iw_freq iwlist & iwconfig
2374 * command shows frequency into proper
2375 * format (2.412 GHz instead of 246.2
2376 * MHz)
2377 */
2378 fwrq->m = freq;
2379 fwrq->e = MHZ;
2380 }
2381 }
2382 } else {
2383 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2384 * iwlist & iwconfig command shows frequency into proper
2385 * format (2.412 GHz instead of 246.2 MHz)
2386 */
2387 fwrq->m = 0;
2388 fwrq->e = MHZ;
2389 }
2390 return 0;
2391}
2392
2393/**
2394 * iw_get_freq() - SSR wrapper for __iw_get_freq()
2395 * @dev: pointer to net_device
2396 * @info: pointer to iw_request_info
2397 * @fwrq: pointer to frequency data
2398 * @extra: pointer to extra ioctl payload
2399 *
2400 * Return: 0 on success, error number otherwise
2401 */
2402static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2403 struct iw_freq *fwrq, char *extra)
2404{
2405 int ret;
2406
2407 cds_ssr_protect(__func__);
2408 ret = __iw_get_freq(dev, info, fwrq, extra);
2409 cds_ssr_unprotect(__func__);
2410
2411 return ret;
2412}
2413
2414/**
2415 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
2416 * @dev: device upon which the ioctl was received
2417 * @info: ioctl request information
2418 * @wrqu: ioctl request data
2419 * @extra: ioctl extra data
2420 *
2421 * Return: 0 on success, non-zero on error
2422 */
2423static int __iw_get_tx_power(struct net_device *dev,
2424 struct iw_request_info *info,
2425 union iwreq_data *wrqu, char *extra)
2426{
2427
2428 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2429 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2430 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2431 int ret;
2432
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002433 ENTER_DEV(dev);
2434
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 ret = wlan_hdd_validate_context(hdd_ctx);
2436 if (0 != ret)
2437 return ret;
2438
2439 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2440 wrqu->txpower.value = 0;
2441 return 0;
2442 }
2443 wlan_hdd_get_class_astats(pAdapter);
2444 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2445
2446 return 0;
2447}
2448
2449/**
2450 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
2451 * @dev: pointer to net_device
2452 * @info: pointer to iw_request_info
2453 * @wrqu: pointer to iwreq_data
2454 * @extra: pointer to extra ioctl payload
2455 *
2456 * Return: 0 on success, error number otherwise
2457 */
2458static int iw_get_tx_power(struct net_device *dev,
2459 struct iw_request_info *info,
2460 union iwreq_data *wrqu, char *extra)
2461{
2462 int ret;
2463
2464 cds_ssr_protect(__func__);
2465 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2466 cds_ssr_unprotect(__func__);
2467
2468 return ret;
2469}
2470
2471/**
2472 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
2473 * @dev: device upon which the ioctl was received
2474 * @info: ioctl request information
2475 * @wrqu: ioctl request data
2476 * @extra: ioctl extra data
2477 *
2478 * Return: 0 on success, non-zero on error
2479 */
2480static int __iw_set_tx_power(struct net_device *dev,
2481 struct iw_request_info *info,
2482 union iwreq_data *wrqu, char *extra)
2483{
2484 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2485 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2486 hdd_context_t *hdd_ctx;
2487 int ret;
2488
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002489 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490
2491 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2492 ret = wlan_hdd_validate_context(hdd_ctx);
2493 if (0 != ret)
2494 return ret;
2495
2496 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302497 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002498 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 return -EIO;
2500 }
2501
2502 EXIT();
2503
2504 return 0;
2505}
2506
2507/**
2508 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
2509 * @dev: pointer to net_device
2510 * @info: pointer to iw_request_info
2511 * @wrqu: pointer to iwreq_data
2512 * @extra: pointer to extra ioctl payload
2513 *
2514 * Return: 0 on success, error number otherwise
2515 */
2516static int iw_set_tx_power(struct net_device *dev,
2517 struct iw_request_info *info,
2518 union iwreq_data *wrqu, char *extra)
2519{
2520 int ret;
2521
2522 cds_ssr_protect(__func__);
2523 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2524 cds_ssr_unprotect(__func__);
2525
2526 return ret;
2527}
2528
2529/**
2530 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
2531 * @dev: device upon which the ioctl was received
2532 * @info: ioctl request information
2533 * @wrqu: ioctl request data
2534 * @extra: ioctl extra data
2535 *
2536 * Return: 0 on success, non-zero on error
2537 */
2538static int __iw_get_bitrate(struct net_device *dev,
2539 struct iw_request_info *info,
2540 union iwreq_data *wrqu, char *extra)
2541{
Anurag Chouhance0dc992016-02-16 18:18:03 +05302542 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302543 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 hdd_wext_state_t *pWextState;
2545 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2546 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2547 hdd_context_t *hdd_ctx;
2548 int ret;
2549
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002550 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551
2552 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2553 ret = wlan_hdd_validate_context(hdd_ctx);
2554 if (0 != ret)
2555 return ret;
2556
Prashanth Bhatta9e143052015-12-04 11:56:47 -08002557 if (cds_is_driver_recovering()) {
2558 hdd_alert("Recovery in Progress. State: 0x%x Ignore!!!",
2559 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 return status;
2561 }
2562
2563 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2564 wrqu->bitrate.value = 0;
2565 } else {
2566 status =
2567 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2568 eCSR_HDD,
2569 SME_SUMMARY_STATS |
2570 SME_GLOBAL_CLASSA_STATS |
2571 SME_GLOBAL_CLASSB_STATS |
2572 SME_GLOBAL_CLASSC_STATS |
2573 SME_GLOBAL_CLASSD_STATS |
2574 SME_PER_STA_STATS,
2575 hdd_statistics_cb, 0,
2576 false,
2577 pHddStaCtx->conn_info.staId[0],
2578 pAdapter, pAdapter->sessionId);
2579
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302580 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002581 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582 return status;
2583 }
2584
2585 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2586
Anurag Chouhance0dc992016-02-16 18:18:03 +05302587 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302588 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 WLAN_WAIT_TIME_STATS);
2590
Anurag Chouhance0dc992016-02-16 18:18:03 +05302591 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002592 hdd_err("SME timeout while retrieving statistics");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302593 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 }
2595
2596 wrqu->bitrate.value =
2597 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
2598 }
2599
2600 EXIT();
2601
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302602 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603}
2604
2605/**
2606 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
2607 * @dev: pointer to net_device
2608 * @info: pointer to iw_request_info
2609 * @wrqu: pointer to iwreq_data
2610 * @extra: pointer to extra ioctl payload
2611 *
2612 * Return: 0 on success, error number otherwise
2613 */
2614static int iw_get_bitrate(struct net_device *dev,
2615 struct iw_request_info *info,
2616 union iwreq_data *wrqu, char *extra)
2617{
2618 int ret;
2619
2620 cds_ssr_protect(__func__);
2621 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2622 cds_ssr_unprotect(__func__);
2623
2624 return ret;
2625}
2626
2627/**
2628 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
2629 * @dev: device upon which the ioctl was received
2630 * @info: ioctl request information
2631 * @wrqu: ioctl request data
2632 * @extra: ioctl extra data
2633 *
2634 * Return: 0 on success, non-zero on error
2635 */
2636static int __iw_set_bitrate(struct net_device *dev,
2637 struct iw_request_info *info,
2638 union iwreq_data *wrqu, char *extra)
2639{
2640 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2641 hdd_wext_state_t *pWextState;
2642 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2643 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2644 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2645 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2646 uint32_t i, rate;
2647 uint32_t valid_rate = false, active_phy_mode = 0;
2648 hdd_context_t *hdd_ctx;
2649 int ret;
2650
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002651 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652
2653 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2654 ret = wlan_hdd_validate_context(hdd_ctx);
2655 if (0 != ret)
2656 return ret;
2657
2658 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2659
2660 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2661 return -ENXIO;
2662 }
2663
2664 rate = wrqu->bitrate.value;
2665
2666 if (rate == -1) {
2667 rate = WNI_CFG_FIXED_RATE_AUTO;
2668 valid_rate = true;
2669 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
2670 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302671 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
2673 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2674 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
2675 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2676 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302677 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 &&
2679 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2680 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302681 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 for (i = 0; i < (b_len + a_len); ++i) {
2683 /* supported rates returned is double
2684 * the actual rate so we divide it by 2
2685 */
2686 if ((supp_rates[i] & 0x7F) / 2 ==
2687 rate) {
2688 valid_rate = true;
2689 rate = i +
2690 WNI_CFG_FIXED_RATE_1MBPS;
2691 break;
2692 }
2693 }
2694 }
2695 }
2696 }
2697 if (valid_rate != true) {
2698 return -EINVAL;
2699 }
2700 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302701 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002702 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 return -EIO;
2704 }
2705 return 0;
2706}
2707
2708/**
2709 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
2710 * @dev: pointer to net_device
2711 * @info: pointer to iw_request_info
2712 * @wrqu: pointer to iwreq_data
2713 * @extra: pointer to extra ioctl payload
2714 *
2715 * Return: 0 on success, error number otherwise
2716 */
2717static int iw_set_bitrate(struct net_device *dev,
2718 struct iw_request_info *info,
2719 union iwreq_data *wrqu, char *extra)
2720{
2721 int ret;
2722
2723 cds_ssr_protect(__func__);
2724 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2725 cds_ssr_unprotect(__func__);
2726
2727 return ret;
2728}
2729
2730/**
2731 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
2732 * @dev: device upon which the ioctl was received
2733 * @info: ioctl request information
2734 * @wrqu: ioctl request data
2735 * @extra: ioctl extra data
2736 *
2737 * Return: 0 on success, non-zero on error
2738 */
2739static int __iw_set_genie(struct net_device *dev,
2740 struct iw_request_info *info,
2741 union iwreq_data *wrqu, char *extra)
2742{
2743 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2744 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2745 uint8_t *genie = NULL;
2746 uint8_t *base_genie = NULL;
2747 uint16_t remLen;
2748 hdd_context_t *hdd_ctx;
2749 int ret;
2750
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002751 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002752
2753 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2754 ret = wlan_hdd_validate_context(hdd_ctx);
2755 if (0 != ret)
2756 return ret;
2757
2758 if (!wrqu->data.length) {
2759 hdd_clear_roam_profile_ie(pAdapter);
2760 EXIT();
2761 return 0;
2762 }
2763
2764 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2765 wrqu->data.length);
2766 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002767 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 return -ENOMEM;
2769 }
2770
2771 genie = base_genie;
2772
2773 remLen = wrqu->data.length;
2774
Jeff Johnson99bac312016-06-28 10:38:18 -07002775 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 genie[1]);
2777
2778 /* clear any previous genIE before this call */
2779 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
2780
2781 while (remLen >= 2) {
2782 uint16_t eLen = 0;
2783 uint8_t elementId;
2784 elementId = *genie++;
2785 eLen = *genie++;
2786 remLen -= 2;
2787
Jeff Johnson99bac312016-06-28 10:38:18 -07002788 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789
2790 switch (elementId) {
2791 case IE_EID_VENDOR:
2792 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 +05302793 ret = -EINVAL;
2794 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 }
2796
2797 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
2798 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002799 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2800 genie[0], genie[1], genie[2],
2801 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802
2803 if (SIR_MAC_MAX_IE_LENGTH <
2804 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002805 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302806 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302807 ret = -ENOMEM;
2808 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 }
2810 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2811 memcpy(pWextState->genIE.addIEdata +
2812 curGenIELen, genie - 2, eLen + 2);
2813 pWextState->genIE.length += eLen + 2;
2814 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002815 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302816 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2817 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2818 ret = -EINVAL;
2819 QDF_ASSERT(0);
2820 goto exit;
2821 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 memset(pWextState->WPARSNIE, 0,
2823 MAX_WPA_RSN_IE_LEN);
2824 memcpy(pWextState->WPARSNIE, genie - 2,
2825 (eLen + 2));
2826 pWextState->roamProfile.pWPAReqIE =
2827 pWextState->WPARSNIE;
2828 pWextState->roamProfile.nWPAReqIELength =
2829 eLen + 2;
2830 } else { /* any vendorId except WPA IE should be accumulated to genIE */
2831
2832 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002833 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
2834 genie[0], genie[1], genie[2],
2835 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836
2837 if (SIR_MAC_MAX_IE_LENGTH <
2838 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002839 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302840 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302841 ret = -ENOMEM;
2842 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 }
2844 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2845 memcpy(pWextState->genIE.addIEdata +
2846 curGenIELen, genie - 2, eLen + 2);
2847 pWextState->genIE.length += eLen + 2;
2848 }
2849 break;
2850 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07002851 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302852 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2853 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2854 ret = -EINVAL;
2855 QDF_ASSERT(0);
2856 goto exit;
2857 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
2859 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
2860 pWextState->roamProfile.pRSNReqIE =
2861 pWextState->WPARSNIE;
2862 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2863 break;
2864
2865 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002866 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302867 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868 }
2869 genie += eLen;
2870 remLen -= eLen;
2871 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302872exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 EXIT();
2874 kfree(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302875 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876}
2877
2878/**
2879 * iw_set_genie() - SSR wrapper for __iw_set_genie()
2880 * @dev: pointer to net_device
2881 * @info: pointer to iw_request_info
2882 * @wrqu: pointer to iwreq_data
2883 * @extra: pointer to extra ioctl payload
2884 *
2885 * Return: 0 on success, error number otherwise
2886 */
2887static int iw_set_genie(struct net_device *dev,
2888 struct iw_request_info *info,
2889 union iwreq_data *wrqu, char *extra)
2890{
2891 int ret;
2892
2893 cds_ssr_protect(__func__);
2894 ret = __iw_set_genie(dev, info, wrqu, extra);
2895 cds_ssr_unprotect(__func__);
2896
2897 return ret;
2898}
2899
2900/**
2901 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
2902 * @dev: device upon which the ioctl was received
2903 * @info: ioctl request information
2904 * @wrqu: ioctl request data
2905 * @extra: ioctl extra data
2906 *
2907 * Return: 0 on success, non-zero on error
2908 */
2909static int __iw_get_genie(struct net_device *dev,
2910 struct iw_request_info *info,
2911 union iwreq_data *wrqu, char *extra)
2912{
2913 hdd_wext_state_t *pWextState;
2914 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2915 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302916 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
2918 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2919 hdd_context_t *hdd_ctx;
2920 int ret;
2921
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002922 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923
2924 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2925 ret = wlan_hdd_validate_context(hdd_ctx);
2926 if (0 != ret)
2927 return ret;
2928
Jeff Johnson99bac312016-06-28 10:38:18 -07002929 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930
2931 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2932
2933 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
2934 return -ENXIO;
2935 }
2936
2937 /* Return something ONLY if we are associated with an RSN or
2938 * WPA network
2939 */
2940 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
2941 return -ENXIO;
2942 }
2943
2944 /* Actually retrieve the RSN IE from CSR. (We previously sent
2945 * it down in the CSR Roam Profile.)
2946 */
2947 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
2948 pAdapter->sessionId,
2949 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05302950 if (QDF_STATUS_SUCCESS != status) {
2951 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 return -EFAULT;
2953 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05302955 if (length > DOT11F_IE_RSN_MAX_LEN) {
2956 hdd_notice("invalid buffer length length:%d", length);
2957 return -E2BIG;
2958 }
2959 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960
Jeff Johnson99bac312016-06-28 10:38:18 -07002961 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 wrqu->data.length);
2963
2964 EXIT();
2965
2966 return 0;
2967}
2968
2969/**
2970 * iw_get_genie() - SSR wrapper for __iw_get_genie()
2971 * @dev: pointer to net_device
2972 * @info: pointer to iw_request_info
2973 * @wrqu: pointer to iwreq_data
2974 * @extra: pointer to extra ioctl payload
2975 *
2976 * Return: 0 on success, error number otherwise
2977 */
2978static int iw_get_genie(struct net_device *dev,
2979 struct iw_request_info *info,
2980 union iwreq_data *wrqu, char *extra)
2981{
2982 int ret;
2983
2984 cds_ssr_protect(__func__);
2985 ret = __iw_get_genie(dev, info, wrqu, extra);
2986 cds_ssr_unprotect(__func__);
2987
2988 return ret;
2989}
2990
2991/**
2992 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
2993 * @dev: device upon which the ioctl was received
2994 * @info: ioctl request information
2995 * @wrqu: ioctl request data
2996 * @extra: ioctl extra data
2997 *
2998 * Return: 0 on success, non-zero on error
2999 */
3000static int __iw_get_encode(struct net_device *dev,
3001 struct iw_request_info *info,
3002 struct iw_point *dwrq, char *extra)
3003{
3004 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3005 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3006 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3007 int keyId;
3008 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3009 int i;
3010 hdd_context_t *hdd_ctx;
3011 int ret;
3012
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003013 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014
3015 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3016 ret = wlan_hdd_validate_context(hdd_ctx);
3017 if (0 != ret)
3018 return ret;
3019
3020 keyId = pRoamProfile->Keys.defaultIndex;
3021
3022 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003023 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 return -EINVAL;
3025 }
3026
3027 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
3028 dwrq->flags |= IW_ENCODE_ENABLED;
3029 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303030 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031 pRoamProfile->Keys.KeyLength[keyId]);
3032
3033 dwrq->flags |= (keyId + 1);
3034
3035 } else {
3036 dwrq->flags |= IW_ENCODE_DISABLED;
3037 }
3038
3039 for (i = 0; i < MAX_WEP_KEYS; i++) {
3040 if (pRoamProfile->Keys.KeyMaterial[i] == NULL) {
3041 continue;
3042 } else {
3043 break;
3044 }
3045 }
3046
3047 if (MAX_WEP_KEYS == i) {
3048 dwrq->flags |= IW_ENCODE_NOKEY;
3049 }
3050
3051 authType =
3052 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
3053 conn_info.authType;
3054
3055 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
3056 dwrq->flags |= IW_ENCODE_OPEN;
3057 } else {
3058 dwrq->flags |= IW_ENCODE_RESTRICTED;
3059 }
3060 EXIT();
3061 return 0;
3062}
3063
3064/**
3065 * iw_get_encode() - SSR wrapper for __iw_get_encode()
3066 * @dev: pointer to net_device
3067 * @info: pointer to iw_request_info
3068 * @dwrq: pointer to encoding information
3069 * @extra: pointer to extra ioctl payload
3070 *
3071 * Return: 0 on success, error number otherwise
3072 */
3073static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
3074 struct iw_point *dwrq, char *extra)
3075{
3076 int ret;
3077
3078 cds_ssr_protect(__func__);
3079 ret = __iw_get_encode(dev, info, dwrq, extra);
3080 cds_ssr_unprotect(__func__);
3081
3082 return ret;
3083}
3084
3085/**
3086 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
3087 * @dev: device upon which the ioctl was received
3088 * @info: ioctl request information
3089 * @wrqu: ioctl request data
3090 * @extra: ioctl extra data
3091 *
3092 * Return: 0 on success, non-zero on error
3093 */
3094static int __iw_get_rts_threshold(struct net_device *dev,
3095 struct iw_request_info *info,
3096 union iwreq_data *wrqu, char *extra)
3097{
3098 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3099 uint32_t status = 0;
3100
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003101 ENTER_DEV(dev);
3102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 status = hdd_wlan_get_rts_threshold(pAdapter, wrqu);
3104
3105 return status;
3106}
3107
3108/**
3109 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
3110 * @dev: device upon which the ioctl was received
3111 * @info: ioctl request information
3112 * @wrqu: ioctl request data
3113 * @extra: ioctl extra data
3114 *
3115 * Return: 0 on success, non-zero on error
3116 */
3117static int __iw_set_rts_threshold(struct net_device *dev,
3118 struct iw_request_info *info,
3119 union iwreq_data *wrqu, char *extra)
3120{
3121 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3122 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3123 hdd_context_t *hdd_ctx;
3124 int ret;
3125
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003126 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127
3128 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3129 ret = wlan_hdd_validate_context(hdd_ctx);
3130 if (0 != ret)
3131 return ret;
3132
3133 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
3134 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
3135 return -EINVAL;
3136 }
3137
3138 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303139 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003140 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 return -EIO;
3142 }
3143
3144 EXIT();
3145
3146 return 0;
3147}
3148
3149/**
3150 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
3151 * @dev: pointer to net_device
3152 * @info: pointer to iw_request_info
3153 * @wrqu: pointer to iwreq_data
3154 * @extra: pointer to extra ioctl payload
3155 *
3156 * Return: 0 on success, error number otherwise
3157 */
3158static int iw_get_rts_threshold(struct net_device *dev,
3159 struct iw_request_info *info,
3160 union iwreq_data *wrqu, char *extra)
3161{
3162 int ret;
3163
3164 cds_ssr_protect(__func__);
3165 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
3166 cds_ssr_unprotect(__func__);
3167
3168 return ret;
3169}
3170
3171/**
3172 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
3173 * @dev: pointer to net_device
3174 * @info: pointer to iw_request_info
3175 * @wrqu: pointer to iwreq_data
3176 * @extra: pointer to extra ioctl payload
3177 *
3178 * Return: 0 on success, error number otherwise
3179 */
3180static int iw_set_rts_threshold(struct net_device *dev,
3181 struct iw_request_info *info,
3182 union iwreq_data *wrqu, char *extra)
3183{
3184 int ret;
3185
3186 cds_ssr_protect(__func__);
3187 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
3188 cds_ssr_unprotect(__func__);
3189
3190 return ret;
3191}
3192
3193/**
3194 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
3195 * @dev: device upon which the ioctl was received
3196 * @info: ioctl request information
3197 * @wrqu: ioctl request data
3198 * @extra: ioctl extra data
3199 *
3200 * Return: 0 on success, non-zero on error
3201 */
3202static int __iw_get_frag_threshold(struct net_device *dev,
3203 struct iw_request_info *info,
3204 union iwreq_data *wrqu, char *extra)
3205{
3206 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3207 uint32_t status = 0;
3208
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003209 ENTER_DEV(dev);
3210
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211 status = hdd_wlan_get_frag_threshold(pAdapter, wrqu);
3212
3213 return status;
3214}
3215
3216/**
3217 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
3218 * @dev: pointer to net_device
3219 * @info: pointer to iw_request_info
3220 * @wrqu: pointer to iwreq_data
3221 * @extra: pointer to extra ioctl payload
3222 *
3223 * Return: 0 on success, error number otherwise
3224 */
3225static int iw_get_frag_threshold(struct net_device *dev,
3226 struct iw_request_info *info,
3227 union iwreq_data *wrqu, char *extra)
3228{
3229 int ret;
3230
3231 cds_ssr_protect(__func__);
3232 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3233 cds_ssr_unprotect(__func__);
3234
3235 return ret;
3236}
3237
3238/**
3239 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
3240 * @dev: device upon which the ioctl was received
3241 * @info: ioctl request information
3242 * @wrqu: ioctl request data
3243 * @extra: ioctl extra data
3244 *
3245 * Return: 0 on success, non-zero on error
3246 */
3247static int __iw_set_frag_threshold(struct net_device *dev,
3248 struct iw_request_info *info,
3249 union iwreq_data *wrqu, char *extra)
3250{
3251 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3252 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3253 hdd_context_t *hdd_ctx;
3254 int ret;
3255
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003256 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257
3258 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3259 ret = wlan_hdd_validate_context(hdd_ctx);
3260 if (0 != ret)
3261 return ret;
3262
3263 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
3264 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
3265 return -EINVAL;
3266 }
3267
3268 if (sme_cfg_set_int
3269 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303270 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003271 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 return -EIO;
3273 }
3274
3275 EXIT();
3276
3277 return 0;
3278}
3279
3280/**
3281 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
3282 * @dev: pointer to net_device
3283 * @info: pointer to iw_request_info
3284 * @wrqu: pointer to iwreq_data
3285 * @extra: pointer to extra ioctl payload
3286 *
3287 * Return: 0 on success, error number otherwise
3288 */
3289static int iw_set_frag_threshold(struct net_device *dev,
3290 struct iw_request_info *info,
3291 union iwreq_data *wrqu, char *extra)
3292{
3293 int ret;
3294
3295 cds_ssr_protect(__func__);
3296 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3297 cds_ssr_unprotect(__func__);
3298
3299 return ret;
3300}
3301
3302/**
3303 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
3304 * @dev: device upon which the ioctl was received
3305 * @info: ioctl request information
3306 * @wrqu: ioctl request data
3307 * @extra: ioctl extra data
3308 *
3309 * Return: 0 on success, non-zero on error
3310 */
3311static int __iw_get_power_mode(struct net_device *dev,
3312 struct iw_request_info *info,
3313 union iwreq_data *wrqu, char *extra)
3314{
3315 hdd_adapter_t *adapter;
3316 hdd_context_t *hdd_ctx;
3317 int ret;
3318
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003319 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320
3321 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3322 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3323 ret = wlan_hdd_validate_context(hdd_ctx);
3324 if (0 != ret)
3325 return ret;
3326
3327 return -EOPNOTSUPP;
3328}
3329
3330/**
3331 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
3332 * @dev: pointer to net_device
3333 * @info: pointer to iw_request_info
3334 * @wrqu: pointer to iwreq_data
3335 * @extra: extra
3336 *
3337 * Return: 0 on success, error number otherwise
3338 */
3339int iw_get_power_mode(struct net_device *dev,
3340 struct iw_request_info *info,
3341 union iwreq_data *wrqu, char *extra)
3342{
3343 int ret;
3344
3345 cds_ssr_protect(__func__);
3346 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3347 cds_ssr_unprotect(__func__);
3348
3349 return ret;
3350}
3351
3352/**
3353 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
3354 * @dev: device upon which the ioctl was received
3355 * @info: ioctl request information
3356 * @wrqu: ioctl request data
3357 * @extra: ioctl extra data
3358 *
3359 * Return: 0 on success, non-zero on error
3360 */
3361static int __iw_set_power_mode(struct net_device *dev,
3362 struct iw_request_info *info,
3363 union iwreq_data *wrqu, char *extra)
3364{
3365 hdd_adapter_t *adapter;
3366 hdd_context_t *hdd_ctx;
3367 int ret;
3368
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003369 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370
3371 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3372 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3373 ret = wlan_hdd_validate_context(hdd_ctx);
3374 if (0 != ret)
3375 return ret;
3376
3377 return -EOPNOTSUPP;
3378}
3379
3380/**
3381 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
3382 * @dev: pointer to net_device
3383 * @info: pointer to iw_request_info
3384 * @wrqu: pointer to iwreq_data
3385 * @extra: extra
3386 *
3387 * Return: 0 on success, error number otherwise
3388 */
3389int iw_set_power_mode(struct net_device *dev,
3390 struct iw_request_info *info,
3391 union iwreq_data *wrqu, char *extra)
3392{
3393 int ret;
3394
3395 cds_ssr_protect(__func__);
3396 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3397 cds_ssr_unprotect(__func__);
3398
3399 return ret;
3400}
3401
3402/**
3403 * __iw_get_range() - SIOCGIWRANGE ioctl handler
3404 * @dev: device upon which the ioctl was received
3405 * @info: ioctl request information
3406 * @wrqu: ioctl request data
3407 * @extra: ioctl extra data
3408 *
3409 * Return: 0 on success, non-zero on error
3410 */
3411static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
3412 union iwreq_data *wrqu, char *extra)
3413{
3414 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3415 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3416 struct iw_range *range = (struct iw_range *)extra;
3417
3418 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3419
3420 uint32_t num_channels = sizeof(channels);
3421 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3422 uint32_t a_len;
3423 uint32_t b_len;
3424 uint32_t active_phy_mode = 0;
3425 uint8_t index = 0, i;
3426 hdd_context_t *hdd_ctx;
3427 int ret;
3428
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003429 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430
3431 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3432 ret = wlan_hdd_validate_context(hdd_ctx);
3433 if (0 != ret)
3434 return ret;
3435
3436 wrqu->data.length = sizeof(struct iw_range);
3437 memset(range, 0, sizeof(struct iw_range));
3438
3439
3440 /*Get the phy mode */
3441 if (sme_cfg_get_int(hHal,
3442 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303443 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003444 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445
3446 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
3447 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
3448 /*Get the supported rates for 11G band */
3449 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3450 if (sme_cfg_get_str(hHal,
3451 WNI_CFG_SUPPORTED_RATES_11A,
3452 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303453 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
3455 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3456 }
3457 for (i = 0; i < a_len; i++) {
3458 range->bitrate[i] =
3459 ((supp_rates[i] & 0x7F) / 2) *
3460 1000000;
3461 }
3462 range->num_bitrates = a_len;
3463 } else {
3464 return -EIO;
3465 }
3466 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
3467 /*Get the supported rates for 11B band */
3468 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3469 if (sme_cfg_get_str(hHal,
3470 WNI_CFG_SUPPORTED_RATES_11B,
3471 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303472 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
3474 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3475 }
3476 for (i = 0; i < b_len; i++) {
3477 range->bitrate[i] =
3478 ((supp_rates[i] & 0x7F) / 2) *
3479 1000000;
3480 }
3481 range->num_bitrates = b_len;
3482 } else {
3483 return -EIO;
3484 }
3485 }
3486 }
3487
3488 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3489 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3490 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3491
3492 range->encoding_size[0] = 5;
3493 range->encoding_size[1] = 13;
3494 range->num_encoding_sizes = 2;
3495 range->max_encoding_tokens = MAX_WEP_KEYS;
3496
3497 /* we support through Wireless Extensions 22 */
3498 range->we_version_compiled = WIRELESS_EXT;
3499 range->we_version_source = 22;
3500
3501 /*Supported Channels and Frequencies */
3502 if (sme_cfg_get_str
3503 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303504 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003505 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 return -EIO;
3507 }
3508 if (num_channels > IW_MAX_FREQUENCIES) {
3509 num_channels = IW_MAX_FREQUENCIES;
3510 }
3511
3512 range->num_channels = num_channels;
3513 range->num_frequency = num_channels;
3514
3515 for (index = 0; index < num_channels; index++) {
3516 uint32_t frq_indx = 0;
3517
3518 range->freq[index].i = channels[index];
3519 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
3520 if (channels[index] == freq_chan_map[frq_indx].chan) {
3521 range->freq[index].m =
3522 freq_chan_map[frq_indx].freq * 100000;
3523 range->freq[index].e = 1;
3524 break;
3525 }
3526 frq_indx++;
3527 }
3528 }
3529
3530 /* Event capability (kernel + driver) */
3531 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3532 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3533 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3534 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3535
3536 /*Encryption capability */
3537 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3538 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3539
3540 /* Txpower capability */
3541 range->txpower_capa = IW_TXPOW_MWATT;
3542
3543 /*Scanning capability */
3544#if WIRELESS_EXT >= 22
3545 range->scan_capa =
3546 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3547#endif
3548
3549 EXIT();
3550 return 0;
3551}
3552
3553/**
3554 * iw_get_range() - SSR wrapper for __iw_get_range()
3555 * @dev: pointer to net_device
3556 * @info: pointer to iw_request_info
3557 * @wrqu: pointer to iwreq_data
3558 * @extra: pointer to extra ioctl payload
3559 *
3560 * Return: 0 on success, error number otherwise
3561 */
3562static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
3563 union iwreq_data *wrqu, char *extra)
3564{
3565 int ret;
3566
3567 cds_ssr_protect(__func__);
3568 ret = __iw_get_range(dev, info, wrqu, extra);
3569 cds_ssr_unprotect(__func__);
3570
3571 return ret;
3572}
3573
3574/**
3575 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
3576 * @pStats: pointer to Class A stats
3577 * @pContext: user context originally registered with SME
3578 *
3579 * Return: None
3580 */
3581static void hdd_get_class_a_statistics_cb(void *pStats, void *pContext)
3582{
3583 struct statsContext *pStatsContext;
3584 tCsrGlobalClassAStatsInfo *pClassAStats;
3585 hdd_adapter_t *pAdapter;
3586
3587 if (ioctl_debug) {
3588 pr_info("%s: pStats [%p] pContext [%p]\n",
3589 __func__, pStats, pContext);
3590 }
3591
3592 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003593 hdd_err("Bad param, pStats [%p] pContext [%p]",
3594 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 return;
3596 }
3597
3598 pClassAStats = pStats;
3599 pStatsContext = pContext;
3600 pAdapter = pStatsContext->pAdapter;
3601
3602 /* there is a race condition that exists between this callback
3603 * function and the caller since the caller could time out
3604 * either before or while this code is executing. we use a
3605 * spinlock to serialize these actions
3606 */
3607 spin_lock(&hdd_context_lock);
3608
3609 if ((NULL == pAdapter) ||
3610 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3611 /* the caller presumably timed out so there is nothing
3612 * we can do
3613 */
3614 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003615 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3616 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617 if (ioctl_debug) {
3618 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3619 __func__, pAdapter, pStatsContext->magic);
3620 }
3621 return;
3622 }
3623
3624 /* context is valid so caller is still waiting */
3625
3626 /* paranoia: invalidate the magic */
3627 pStatsContext->magic = 0;
3628
3629 /* copy over the stats. do so as a struct copy */
3630 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3631
3632 /* notify the caller */
3633 complete(&pStatsContext->completion);
3634
3635 /* serialization is complete */
3636 spin_unlock(&hdd_context_lock);
3637}
3638
3639/**
3640 * wlan_hdd_get_class_astats() - Get Class A statistics
3641 * @pAdapter: adapter for which statistics are desired
3642 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303643 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303645QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646{
3647 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303648 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 unsigned long rc;
3650 struct statsContext context;
3651
3652 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003653 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303654 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003656 if (cds_is_driver_recovering()) {
3657 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3658 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303659 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 }
3661
3662 /* we are connected so prepare our callback context */
3663 init_completion(&context.completion);
3664 context.pAdapter = pAdapter;
3665 context.magic = STATS_CONTEXT_MAGIC;
3666 /* query only for Class A statistics (which include link speed) */
3667 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3668 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
3669 hdd_get_class_a_statistics_cb,
3670 0, /* not periodic */
3671 false, /* non-cached results */
3672 pHddStaCtx->conn_info.staId[0],
3673 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303674 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003675 hdd_err("Unable to retrieve Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676 /* we'll returned a cached value below */
3677 } else {
3678 /* request was sent -- wait for the response */
3679 rc = wait_for_completion_timeout
3680 (&context.completion,
3681 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3682 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003683 hdd_err("SME timed out while retrieving Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 }
3685 }
3686
3687 /* either we never sent a request, we sent a request and
3688 * received a response or we sent a request and timed out. if
3689 * we never sent a request or if we sent a request and got a
3690 * response, we want to clear the magic out of paranoia. if
3691 * we timed out there is a race condition such that the
3692 * callback function could be executing at the same time we
3693 * are. of primary concern is if the callback function had
3694 * already verified the "magic" but had not yet set the
3695 * completion variable when a timeout occurred. we serialize
3696 * these activities by invalidating the magic while holding a
3697 * shared spinlock which will cause us to block if the
3698 * callback is currently executing
3699 */
3700 spin_lock(&hdd_context_lock);
3701 context.magic = 0;
3702 spin_unlock(&hdd_context_lock);
3703
3704 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303705 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706}
3707
3708/**
3709 * hdd_get_station_statistics_cb() - Get stats callback function
3710 * @pStats: pointer to Class A stats
3711 * @pContext: user context originally registered with SME
3712 *
3713 * Return: None
3714 */
3715static void hdd_get_station_statistics_cb(void *pStats, void *pContext)
3716{
3717 struct statsContext *pStatsContext;
3718 tCsrSummaryStatsInfo *pSummaryStats;
3719 tCsrGlobalClassAStatsInfo *pClassAStats;
3720 hdd_adapter_t *pAdapter;
3721
3722 if (ioctl_debug) {
3723 pr_info("%s: pStats [%p] pContext [%p]\n",
3724 __func__, pStats, pContext);
3725 }
3726
3727 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003728 hdd_err("Bad param, pStats [%p] pContext [%p]",
3729 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003730 return;
3731 }
3732
3733 /* there is a race condition that exists between this callback
3734 * function and the caller since the caller could time out
3735 * either before or while this code is executing. we use a
3736 * spinlock to serialize these actions
3737 */
3738 spin_lock(&hdd_context_lock);
3739
3740 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3741 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
3742 pStatsContext = pContext;
3743 pAdapter = pStatsContext->pAdapter;
3744 if ((NULL == pAdapter) ||
3745 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3746 /* the caller presumably timed out so there is nothing
3747 * we can do
3748 */
3749 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003750 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3751 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003752 if (ioctl_debug) {
3753 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3754 __func__, pAdapter, pStatsContext->magic);
3755 }
3756 return;
3757 }
3758
3759 /* context is valid so caller is still waiting */
3760
3761 /* paranoia: invalidate the magic */
3762 pStatsContext->magic = 0;
3763
3764 /* copy over the stats. do so as a struct copy */
3765 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3766 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3767
3768 /* notify the caller */
3769 complete(&pStatsContext->completion);
3770
3771 /* serialization is complete */
3772 spin_unlock(&hdd_context_lock);
3773}
3774
3775/**
3776 * wlan_hdd_get_station_stats() - Get station statistics
3777 * @pAdapter: adapter for which statistics are desired
3778 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303779 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003780 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303781QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782{
3783 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303784 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 unsigned long rc;
3786 struct statsContext context;
3787
3788 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003789 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303790 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791 }
3792
3793 /* we are connected so prepare our callback context */
3794 init_completion(&context.completion);
3795 context.pAdapter = pAdapter;
3796 context.magic = STATS_CONTEXT_MAGIC;
3797
3798 /* query only for Summary & Class A statistics */
3799 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3800 eCSR_HDD,
3801 SME_SUMMARY_STATS |
3802 SME_GLOBAL_CLASSA_STATS,
3803 hdd_get_station_statistics_cb,
3804 0, /* not periodic */
3805 false, /* non-cached results */
3806 pHddStaCtx->conn_info.staId[0],
3807 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303808 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003809 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 /* we'll return with cached values */
3811 } else {
3812 /* request was sent -- wait for the response */
3813 rc = wait_for_completion_timeout
3814 (&context.completion,
3815 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3816
3817 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003818 hdd_err("SME timed out while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 }
3820 }
3821
3822 /* either we never sent a request, we sent a request and
3823 * received a response or we sent a request and timed out. if
3824 * we never sent a request or if we sent a request and got a
3825 * response, we want to clear the magic out of paranoia. if
3826 * we timed out there is a race condition such that the
3827 * callback function could be executing at the same time we
3828 * are. of primary concern is if the callback function had
3829 * already verified the "magic" but had not yet set the
3830 * completion variable when a timeout occurred. we serialize
3831 * these activities by invalidating the magic while holding a
3832 * shared spinlock which will cause us to block if the
3833 * callback is currently executing
3834 */
3835 spin_lock(&hdd_context_lock);
3836 context.magic = 0;
3837 spin_unlock(&hdd_context_lock);
3838
3839 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303840 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841}
3842
3843/**
3844 * iw_get_linkspeed() - Get current link speed ioctl
3845 * @dev: device upon which the ioctl was received
3846 * @info: ioctl request information
3847 * @wrqu: ioctl request data
3848 * @extra: extra ioctl buffer
3849 *
3850 * Return: 0 on success, non-zero on error
3851 */
3852static int __iw_get_linkspeed(struct net_device *dev,
3853 struct iw_request_info *info,
3854 union iwreq_data *wrqu, char *extra)
3855{
3856 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3857 char *pLinkSpeed = (char *)extra;
3858 int len = sizeof(uint32_t) + 1;
3859 uint32_t link_speed = 0;
3860 hdd_context_t *hdd_ctx;
3861 int rc, valid;
3862
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08003863 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303864
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3866 valid = wlan_hdd_validate_context(hdd_ctx);
3867 if (0 != valid)
3868 return valid;
3869
3870 rc = wlan_hdd_get_link_speed(pAdapter, &link_speed);
3871 if (0 != rc) {
3872 return rc;
3873 }
3874
3875 wrqu->data.length = len;
3876 /* return the linkspeed as a string */
3877 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
3878 if ((rc < 0) || (rc >= len)) {
3879 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07003880 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 return -EIO;
3882 }
3883
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303884 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885 /* a value is being successfully returned */
3886 return 0;
3887}
3888
3889static int iw_get_linkspeed(struct net_device *dev,
3890 struct iw_request_info *info,
3891 union iwreq_data *wrqu, char *extra)
3892{
3893 int ret;
3894
3895 cds_ssr_protect(__func__);
3896 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
3897 cds_ssr_unprotect(__func__);
3898
3899 return ret;
3900}
3901
3902/**
3903 * wlan_hdd_change_country_code_callback() - Change country code callback
3904 * @context: opaque context originally passed to SME. All functions
3905 * which use this callback pass the adapter upon which the country
3906 * code change is active
3907 *
3908 * This function is registered as the callback function when
3909 * sme_change_country_code() is invoked. Callers of
3910 * sme_change_country_code() subsequently wait for the adapter's
3911 * @change_country_code completion variable, so all this function
3912 * needs to do is set that completion variable so that execution can
3913 * continue.
3914 *
3915 * Return: none
3916 */
3917void wlan_hdd_change_country_code_callback(void *context)
3918{
3919
3920 hdd_adapter_t *adapter = context;
3921
3922 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
3923 complete(&adapter->change_country_code);
3924
3925 return;
3926}
3927
3928/**
3929 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
3930 * @dev: device upon which the ioctl was received
3931 * @info: ioctl request information
3932 * @wrqu: ioctl request data
3933 * @extra: ioctl extra data
3934 *
3935 * Return: 0 on success, non-zero on error
3936 */
3937static int __iw_set_nick(struct net_device *dev,
3938 struct iw_request_info *info,
3939 union iwreq_data *wrqu, char *extra)
3940{
3941 hdd_adapter_t *adapter;
3942 hdd_context_t *hdd_ctx;
3943 int ret;
3944
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003945 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946
3947 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3948 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3949 ret = wlan_hdd_validate_context(hdd_ctx);
3950 if (0 != ret)
3951 return ret;
3952
3953 return 0;
3954}
3955
3956/**
3957 * iw_set_nick() - SSR wrapper for __iw_set_nick
3958 * @dev: pointer to net_device
3959 * @info: pointer to iw_request_info
3960 * @wrqu: pointer to iwreq_data
3961 * @extra: extra
3962 *
3963 * Return: 0 on success, error number otherwise
3964 */
3965static int iw_set_nick(struct net_device *dev,
3966 struct iw_request_info *info,
3967 union iwreq_data *wrqu, char *extra)
3968{
3969 int ret;
3970
3971 cds_ssr_protect(__func__);
3972 ret = __iw_set_nick(dev, info, wrqu, extra);
3973 cds_ssr_unprotect(__func__);
3974
3975 return ret;
3976}
3977
3978/**
3979 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
3980 * @dev: device upon which the ioctl was received
3981 * @info: ioctl request information
3982 * @wrqu: ioctl request data
3983 * @extra: ioctl extra data
3984 *
3985 * Return: 0 on success, non-zero on error
3986 */
3987static int __iw_get_nick(struct net_device *dev,
3988 struct iw_request_info *info,
3989 union iwreq_data *wrqu, char *extra)
3990{
3991 hdd_adapter_t *adapter;
3992 hdd_context_t *hdd_ctx;
3993 int ret;
3994
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003995 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003996
3997 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3998 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3999 ret = wlan_hdd_validate_context(hdd_ctx);
4000 if (0 != ret)
4001 return ret;
4002
4003 return 0;
4004}
4005
4006/**
4007 * iw_get_nick() - SSR wrapper for __iw_get_nick
4008 * @dev: pointer to net_device
4009 * @info: pointer to iw_request_info
4010 * @wrqu: pointer to iwreq_data
4011 * @extra: extra
4012 *
4013 * Return: 0 on success, error number otherwise
4014 */
4015static int iw_get_nick(struct net_device *dev,
4016 struct iw_request_info *info,
4017 union iwreq_data *wrqu, char *extra)
4018{
4019 int ret;
4020
4021 cds_ssr_protect(__func__);
4022 ret = __iw_get_nick(dev, info, wrqu, extra);
4023 cds_ssr_unprotect(__func__);
4024
4025 return ret;
4026}
4027
4028/**
4029 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
4030 * @dev: device upon which the ioctl was received
4031 * @info: ioctl request information
4032 * @wrqu: ioctl request data
4033 * @extra: ioctl extra data
4034 *
4035 * Return: 0 on success, non-zero on error
4036 */
4037static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4038 union iwreq_data *wrqu, char *extra)
4039{
4040 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4041 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4042 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4043 hdd_context_t *hdd_ctx;
4044 struct iw_point *encoderq = &(wrqu->encoding);
4045 uint32_t keyId;
4046 uint8_t key_length;
4047 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4048 bool fKeyPresent = 0;
4049 int i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304050 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 int ret;
4052
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004053 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054
4055 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4056 ret = wlan_hdd_validate_context(hdd_ctx);
4057 if (0 != ret)
4058 return ret;
4059
4060 keyId = encoderq->flags & IW_ENCODE_INDEX;
4061
4062 if (keyId) {
4063 if (keyId > MAX_WEP_KEYS) {
4064 return -EINVAL;
4065 }
4066
4067 fKeyPresent = 1;
4068 keyId--;
4069 } else {
4070 fKeyPresent = 0;
4071 }
4072
4073 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004074 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 if (!fKeyPresent) {
4076
4077 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
4078
4079 if (pWextState->roamProfile.Keys.KeyMaterial[i])
4080 pWextState->roamProfile.Keys.
4081 KeyLength[i] = 0;
4082 }
4083 }
4084 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4085 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4086 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4087 eCSR_ENCRYPT_TYPE_NONE;
4088 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4089 eCSR_ENCRYPT_TYPE_NONE;
4090
4091 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4092 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4093
4094 if (eConnectionState_Associated ==
4095 pHddStaCtx->conn_info.connState) {
4096 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4097 status =
4098 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4099 pAdapter->sessionId,
4100 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304101 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102 unsigned long rc;
4103 rc = wait_for_completion_timeout(&pAdapter->
4104 disconnect_comp_var,
4105 msecs_to_jiffies
4106 (WLAN_WAIT_TIME_DISCONNECT));
4107 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004108 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 }
4110 }
4111
4112 return status;
4113
4114 }
4115
4116 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004117 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118
4119 pHddStaCtx->conn_info.authType =
4120 (encoderq->
4121 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
4122 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4123
4124 }
4125
4126 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004127 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128
4129 key_length = wrqu->data.length;
4130
4131 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
4132
4133 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004134 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135 key_length);
4136
4137 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4138 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4139 pHddStaCtx->conn_info.authType)) {
4140 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4141 } else {
4142 encryptionType =
4143 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4144 }
4145 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004146 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 key_length);
4148
4149 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4150 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4151 pHddStaCtx->conn_info.authType)) {
4152 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4153 } else {
4154 encryptionType =
4155 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4156 }
4157 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004158 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159 key_length);
4160 return -EINVAL;
4161 }
4162
4163 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4164 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4165 pWextState->roamProfile.EncryptionType.numEntries = 1;
4166 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4167 encryptionType;
4168 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4169 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4170 encryptionType;
4171
4172 if ((eConnectionState_NotConnected ==
4173 pHddStaCtx->conn_info.connState)
4174 &&
4175 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4176 pHddStaCtx->conn_info.authType)
4177 || (eCSR_AUTH_TYPE_SHARED_KEY ==
4178 pHddStaCtx->conn_info.authType))) {
4179
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304180 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 KeyMaterial[keyId][0], extra, key_length);
4182
4183 pWextState->roamProfile.Keys.KeyLength[keyId] =
4184 (uint8_t) key_length;
4185 pWextState->roamProfile.Keys.defaultIndex =
4186 (uint8_t) keyId;
4187
4188 return status;
4189 }
4190 }
4191
4192 return 0;
4193}
4194
4195/**
4196 * iw_set_encode() - SSR wrapper for __iw_set_encode()
4197 * @dev: pointer to net_device
4198 * @info: pointer to iw_request_info
4199 * @wrqu: pointer to iwreq_data
4200 * @extra: pointer to extra ioctl payload
4201 *
4202 * Return: 0 on success, error number otherwise
4203 */
4204static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4205 union iwreq_data *wrqu, char *extra)
4206{
4207 int ret;
4208
4209 cds_ssr_protect(__func__);
4210 ret = __iw_set_encode(dev, info, wrqu, extra);
4211 cds_ssr_unprotect(__func__);
4212
4213 return ret;
4214}
4215
4216/**
4217 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
4218 * @dev: device upon which the ioctl was received
4219 * @info: ioctl request information
4220 * @wrqu: ioctl request data
4221 * @extra: ioctl extra data
4222 *
4223 * Return: 0 on success, non-zero on error
4224 */
4225static int __iw_get_encodeext(struct net_device *dev,
4226 struct iw_request_info *info,
4227 struct iw_point *dwrq, char *extra)
4228{
4229 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4230 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4231 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4232 int keyId;
4233 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4234 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4235 int i, ret;
4236 hdd_context_t *hdd_ctx;
4237
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004238 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004239
4240 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4241 ret = wlan_hdd_validate_context(hdd_ctx);
4242 if (0 != ret)
4243 return ret;
4244
4245 keyId = pRoamProfile->Keys.defaultIndex;
4246
4247 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004248 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 return -EINVAL;
4250 }
4251
4252 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
4253 dwrq->flags |= IW_ENCODE_ENABLED;
4254 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304255 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 pRoamProfile->Keys.KeyLength[keyId]);
4257 } else {
4258 dwrq->flags |= IW_ENCODE_DISABLED;
4259 }
4260
4261 for (i = 0; i < MAX_WEP_KEYS; i++) {
4262 if (pRoamProfile->Keys.KeyMaterial[i] == NULL) {
4263 continue;
4264 } else {
4265 break;
4266 }
4267 }
4268
4269 if (MAX_WEP_KEYS == i) {
4270 dwrq->flags |= IW_ENCODE_NOKEY;
4271 } else {
4272 dwrq->flags |= IW_ENCODE_ENABLED;
4273 }
4274
4275 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4276
4277 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
4278 dwrq->flags |= IW_ENCODE_DISABLED;
4279 }
4280
4281 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4282
4283 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
4284 dwrq->flags |= IW_ENCODE_OPEN;
4285 } else {
4286 dwrq->flags |= IW_ENCODE_RESTRICTED;
4287 }
4288 EXIT();
4289 return 0;
4290
4291}
4292
4293/**
4294 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
4295 * @dev: pointer to net_device
4296 * @info: pointer to iw_request_info
4297 * @dwrq: pointer to encoding information
4298 * @extra: pointer to extra ioctl payload
4299 *
4300 * Return: 0 on success, error number otherwise
4301 */
4302static int iw_get_encodeext(struct net_device *dev,
4303 struct iw_request_info *info,
4304 struct iw_point *dwrq, char *extra)
4305{
4306 int ret;
4307
4308 cds_ssr_protect(__func__);
4309 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4310 cds_ssr_unprotect(__func__);
4311
4312 return ret;
4313}
4314
4315/**
4316 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
4317 * @dev: device upon which the ioctl was received
4318 * @info: ioctl request information
4319 * @wrqu: ioctl request data
4320 * @extra: ioctl extra data
4321 *
4322 * Return: 0 on success, non-zero on error
4323 */
4324static int __iw_set_encodeext(struct net_device *dev,
4325 struct iw_request_info *info,
4326 union iwreq_data *wrqu, char *extra)
4327{
4328 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4329 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4330 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4331 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304332 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4334 int ret;
4335 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4336 int key_index;
4337 struct iw_point *encoding = &wrqu->encoding;
4338 tCsrRoamSetKey setKey;
4339 uint32_t roamId = 0xFF;
4340
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004341 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342
4343 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4344 ret = wlan_hdd_validate_context(hdd_ctx);
4345 if (0 != ret)
4346 return ret;
4347
4348 key_index = encoding->flags & IW_ENCODE_INDEX;
4349
4350 if (key_index > 0) {
4351
4352 /*Convert from 1-based to 0-based keying */
4353 key_index--;
4354 }
4355 if (!ext->key_len) {
4356
4357 /*Set the encrytion type to NONE */
4358 pRoamProfile->EncryptionType.encryptionType[0] =
4359 eCSR_ENCRYPT_TYPE_NONE;
4360 return ret;
4361 }
4362
4363 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4364 (IW_ENCODE_ALG_WEP == ext->alg)) {
4365 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4366
Jeff Johnson99bac312016-06-28 10:38:18 -07004367 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368 return -EINVAL;
4369 } else {
4370 /*Static wep, update the roam profile with the keys */
4371 if (ext->key
4372 && (ext->key_len <=
4373 eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES)
4374 && key_index < CSR_MAX_NUM_KEY) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304375 qdf_mem_copy(&pRoamProfile->Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376 KeyMaterial[key_index][0],
4377 ext->key, ext->key_len);
4378 pRoamProfile->Keys.KeyLength[key_index] =
4379 (uint8_t) ext->key_len;
4380
4381 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4382 pRoamProfile->Keys.defaultIndex =
4383 (uint8_t) key_index;
4384
4385 }
4386 }
4387 return ret;
4388 }
4389
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304390 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391
4392 setKey.keyId = key_index;
4393 setKey.keyLength = ext->key_len;
4394
4395 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304396 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004397 }
4398
4399 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4400 /*Key direction for group is RX only */
4401 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05304402 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 } else {
4404
4405 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304406 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304407 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 }
4409
4410 /*For supplicant pae role is zero */
4411 setKey.paeRole = 0;
4412
4413 switch (ext->alg) {
4414 case IW_ENCODE_ALG_NONE:
4415 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4416 break;
4417
4418 case IW_ENCODE_ALG_WEP:
4419 setKey.encType =
4420 (ext->key_len ==
4421 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
4422 break;
4423
4424 case IW_ENCODE_ALG_TKIP:
4425 {
4426 uint8_t *pKey = &setKey.Key[0];
4427
4428 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4429
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304430 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431
4432 /* Supplicant sends the 32bytes key in this order
4433 * |--------------|----------|----------|
4434 * | Tk1 | TX MIC | RX MIC |
4435 * |--------------|----------|----------|
4436 * <---16bytes---><--8bytes--><--8bytes-->
4437 *
4438 *
4439 * Sme expects the 32 bytes key to be in the below order
4440 * |--------------|----------|----------|
4441 * | Tk1 | RX MIC | TX MIC |
4442 * |--------------|----------|----------|
4443 * <---16bytes---><--8bytes--><--8bytes-->
4444 */
4445
4446 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304447 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004448
4449 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304450 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451
4452 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304453 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454
4455 }
4456 break;
4457
4458 case IW_ENCODE_ALG_CCMP:
4459 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4460 break;
4461
4462#ifdef FEATURE_WLAN_ESE
4463#define IW_ENCODE_ALG_KRK 6
4464 case IW_ENCODE_ALG_KRK:
4465 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4466 break;
4467#endif /* FEATURE_WLAN_ESE */
4468
4469 default:
4470 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4471 break;
4472 }
4473
Jeff Johnson99bac312016-06-28 10:38:18 -07004474 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
4475 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 /* The supplicant may attempt to set the PTK once
4478 * pre-authentication is done. Save the key in the UMAC and
4479 * include it in the ADD BSS request
4480 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304481 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304483 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004484 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304486 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004487 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488 return -EINVAL;
4489 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490
4491 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4492
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304493 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 pAdapter->sessionId,
4495 &setKey, &roamId);
4496
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304497 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004498 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304499 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500
4501 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4502 }
4503
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304504 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505}
4506
4507/**
4508 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
4509 * @dev: pointer to net_device
4510 * @info: pointer to iw_request_info
4511 * @wrqu: pointer to iwreq_data
4512 * @extra: pointer to extra ioctl payload
4513 *
4514 * Return: 0 on success, error number otherwise
4515 */
4516static int iw_set_encodeext(struct net_device *dev,
4517 struct iw_request_info *info,
4518 union iwreq_data *wrqu, char *extra)
4519{
4520 int ret;
4521
4522 cds_ssr_protect(__func__);
4523 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4524 cds_ssr_unprotect(__func__);
4525
4526 return ret;
4527}
4528
4529/**
4530 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
4531 * @dev: device upon which the ioctl was received
4532 * @info: ioctl request information
4533 * @wrqu: ioctl request data
4534 * @extra: ioctl extra data
4535 *
4536 * Return: 0 on success, non-zero on error
4537 */
4538static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4539 union iwreq_data *wrqu, char *extra)
4540{
4541 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4542 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4543 hdd_context_t *hdd_ctx;
4544 int ret;
4545
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004546 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547
4548 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4549 ret = wlan_hdd_validate_context(hdd_ctx);
4550 if (0 != ret)
4551 return ret;
4552
4553 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4554 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4555
Jeff Johnson99bac312016-06-28 10:38:18 -07004556 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557
4558 return -EINVAL;
4559 }
4560
4561 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
4562
4563 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4564 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
4565 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304566 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004567 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 return -EIO;
4569 }
4570 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4571 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
4572 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304573 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004574 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 return -EIO;
4576 }
4577 }
4578 } else {
4579 return -EOPNOTSUPP;
4580 }
4581
Jeff Johnson99bac312016-06-28 10:38:18 -07004582 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583
4584 EXIT();
4585
4586 return 0;
4587
4588}
4589
4590/**
4591 * iw_set_retry() - SSR wrapper for __iw_set_retry()
4592 * @dev: pointer to net_device
4593 * @info: pointer to iw_request_info
4594 * @wrqu: pointer to iwreq_data
4595 * @extra: pointer to extra ioctl payload
4596 *
4597 * Return: 0 on success, error number otherwise
4598 */
4599static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4600 union iwreq_data *wrqu, char *extra)
4601{
4602 int ret;
4603
4604 cds_ssr_protect(__func__);
4605 ret = __iw_set_retry(dev, info, wrqu, extra);
4606 cds_ssr_unprotect(__func__);
4607
4608 return ret;
4609}
4610
4611/**
4612 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
4613 * @dev: device upon which the ioctl was received
4614 * @info: ioctl request information
4615 * @wrqu: ioctl request data
4616 * @extra: ioctl extra data
4617 *
4618 * Return: 0 on success, non-zero on error
4619 */
4620static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4621 union iwreq_data *wrqu, char *extra)
4622{
4623 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4624 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4625 uint32_t retry = 0;
4626 hdd_context_t *hdd_ctx;
4627 int ret;
4628
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004629 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630
4631 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4632 ret = wlan_hdd_validate_context(hdd_ctx);
4633 if (0 != ret)
4634 return ret;
4635
4636 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4637 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
4638
4639 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304640 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004641 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642 return -EIO;
4643 }
4644
4645 wrqu->retry.value = retry;
4646 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4647 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
4648
4649 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304650 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004651 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 return -EIO;
4653 }
4654
4655 wrqu->retry.value = retry;
4656 } else {
4657 return -EOPNOTSUPP;
4658 }
4659
Jeff Johnson99bac312016-06-28 10:38:18 -07004660 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661
4662 EXIT();
4663
4664 return 0;
4665}
4666
4667/**
4668 * iw_get_retry() - SSR wrapper for __iw_get_retry()
4669 * @dev: pointer to net_device
4670 * @info: pointer to iw_request_info
4671 * @wrqu: pointer to iwreq_data
4672 * @extra: pointer to extra ioctl payload
4673 *
4674 * Return: 0 on success, error number otherwise
4675 */
4676static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4677 union iwreq_data *wrqu, char *extra)
4678{
4679 int ret;
4680
4681 cds_ssr_protect(__func__);
4682 ret = __iw_get_retry(dev, info, wrqu, extra);
4683 cds_ssr_unprotect(__func__);
4684
4685 return ret;
4686}
4687
4688/**
4689 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
4690 * @dev: device upon which the ioctl was received
4691 * @info: ioctl request information
4692 * @wrqu: ioctl request data
4693 * @extra: ioctl extra data
4694 *
4695 * Return: 0 on success, non-zero on error
4696 */
4697static int __iw_set_mlme(struct net_device *dev,
4698 struct iw_request_info *info,
4699 union iwreq_data *wrqu, char *extra)
4700{
4701 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4702 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4703 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304704 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705 hdd_context_t *hdd_ctx;
4706 int ret;
4707
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004708 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709
4710 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4711 ret = wlan_hdd_validate_context(hdd_ctx);
4712 if (0 != ret)
4713 return ret;
4714
4715 /* reason_code is unused. By default it is set to
4716 * eCSR_DISCONNECT_REASON_UNSPECIFIED
4717 */
4718 switch (mlme->cmd) {
4719 case IW_MLME_DISASSOC:
4720 case IW_MLME_DEAUTH:
4721
4722 if (pHddStaCtx->conn_info.connState ==
4723 eConnectionState_Associated) {
4724 eCsrRoamDisconnectReason reason =
4725 eCSR_DISCONNECT_REASON_UNSPECIFIED;
4726
4727 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
4728 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4729
4730 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4731 status =
4732 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4733 pAdapter->sessionId, reason);
4734
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304735 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004736 unsigned long rc;
4737 rc = wait_for_completion_timeout(&pAdapter->
4738 disconnect_comp_var,
4739 msecs_to_jiffies
4740 (WLAN_WAIT_TIME_DISCONNECT));
4741 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004742 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004743 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07004744 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
4745 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746
4747 /* Resetting authKeyMgmt */
4748 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
4749 0;
4750
Jeff Johnson99bac312016-06-28 10:38:18 -07004751 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752 wlan_hdd_netif_queue_control(pAdapter,
4753 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4754 WLAN_CONTROL_PATH);
4755
4756 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004757 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
4758 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759 }
4760 break;
4761 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004762 hdd_err("%d Command should be Disassociate/Deauthenticate",
4763 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 return -EINVAL;
4765 } /* end of switch */
4766
4767 EXIT();
4768
4769 return status;
4770
4771}
4772
4773/**
4774 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
4775 * @dev: pointer to net_device
4776 * @info: pointer to iw_request_info
4777 * @wrqu: pointer to iwreq_data
4778 * @extra: pointer to extra ioctl payload
4779 *
4780 * Return: 0 on success, error number otherwise
4781 */
4782static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
4783 union iwreq_data *wrqu, char *extra)
4784{
4785 int ret;
4786
4787 cds_ssr_protect(__func__);
4788 ret = __iw_set_mlme(dev, info, wrqu, extra);
4789 cds_ssr_unprotect(__func__);
4790
4791 return ret;
4792}
4793
4794/**
4795 * wlan_hdd_update_phymode() - handle change in PHY mode
4796 * @net: device upon which PHY mode change was received
4797 * @hal: umac handle for the driver
4798 * @new_phymode: new PHY mode for the device
4799 * @phddctx: pointer to the HDD context
4800 *
4801 * This function is called when the device is set to a new PHY mode.
4802 * It takes a holistic look at the desired PHY mode along with the
4803 * configured capabilities of the driver and the reported capabilities
4804 * of the hardware in order to correctly configure all PHY-related
4805 * parameters.
4806 *
4807 * Return: 0 on success, negative errno value on error
4808 */
4809int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
4810 int new_phymode, hdd_context_t *phddctx)
4811{
4812#ifdef QCA_HT_2040_COEX
4813 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304814 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815#endif
4816 bool band_24 = false, band_5g = false;
4817 bool ch_bond24 = false, ch_bond5g = false;
4818 tSmeConfigParams smeconfig;
4819 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004821 eCsrPhyMode phymode = -EIO, old_phymode;
4822 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
4823 eCsrBand curr_band = eCSR_BAND_ALL;
4824
4825 old_phymode = sme_get_phy_mode(hal);
4826
4827 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4828 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4829 nChannelBondingMode24GHz))
4830 ch_bond24 = true;
4831
4832 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4833 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4834 nChannelBondingMode5GHz))
4835 ch_bond5g = true;
4836
4837 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
4838 band_24 = band_5g = true;
4839 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
4840 band_24 = true;
4841 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
4842 band_5g = true;
4843 }
4844
4845 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07004846 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 -08004847 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
4848
4849 switch (new_phymode) {
4850 case IEEE80211_MODE_AUTO:
4851 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4852 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
4853 phymode = eCSR_DOT11_MODE_AUTO;
4854 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4855 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4856 curr_band = eCSR_BAND_ALL;
4857 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4858 } else {
4859 sme_set_phy_mode(hal, old_phymode);
4860 return -EIO;
4861 }
4862 break;
4863 case IEEE80211_MODE_11A:
4864 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
4865 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4866 phymode = eCSR_DOT11_MODE_11a;
4867 hdd_dot11mode = eHDD_DOT11_MODE_11a;
4868 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4869 curr_band = eCSR_BAND_5G;
4870 } else {
4871 sme_set_phy_mode(hal, old_phymode);
4872 return -EIO;
4873 }
4874 break;
4875 case IEEE80211_MODE_11B:
4876 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
4877 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4878 phymode = eCSR_DOT11_MODE_11b;
4879 hdd_dot11mode = eHDD_DOT11_MODE_11b;
4880 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4881 curr_band = eCSR_BAND_24;
4882 } else {
4883 sme_set_phy_mode(hal, old_phymode);
4884 return -EIO;
4885 }
4886 break;
4887 case IEEE80211_MODE_11G:
4888 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
4889 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4890 phymode = eCSR_DOT11_MODE_11g;
4891 hdd_dot11mode = eHDD_DOT11_MODE_11g;
4892 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4893 curr_band = eCSR_BAND_24;
4894 } else {
4895 sme_set_phy_mode(hal, old_phymode);
4896 return -EIO;
4897 }
4898 break;
4899 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
4900 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
4901 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
4902 */
4903 case IEEE80211_MODE_11NA_HT20:
4904 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4905 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4906 phymode = eCSR_DOT11_MODE_11n;
4907 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4908 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4909 curr_band = eCSR_BAND_5G;
4910 } else {
4911 sme_set_phy_mode(hal, old_phymode);
4912 return -EIO;
4913 }
4914 break;
4915 case IEEE80211_MODE_11NA_HT40:
4916 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4917 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4918 phymode = eCSR_DOT11_MODE_11n;
4919 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4920 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4921 curr_band = eCSR_BAND_5G;
4922 } else {
4923 sme_set_phy_mode(hal, old_phymode);
4924 return -EIO;
4925 }
4926 break;
4927 case IEEE80211_MODE_11NG_HT20:
4928 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4929 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4930 phymode = eCSR_DOT11_MODE_11n;
4931 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4932 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4933 curr_band = eCSR_BAND_24;
4934 } else {
4935 sme_set_phy_mode(hal, old_phymode);
4936 return -EIO;
4937 }
4938 break;
4939 case IEEE80211_MODE_11NG_HT40:
4940 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4941 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4942 phymode = eCSR_DOT11_MODE_11n;
4943 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4944 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4945 curr_band = eCSR_BAND_24;
4946 } else {
4947 sme_set_phy_mode(hal, old_phymode);
4948 return -EIO;
4949 }
4950 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951 case IEEE80211_MODE_11AC_VHT20:
4952 case IEEE80211_MODE_11AC_VHT40:
4953 case IEEE80211_MODE_11AC_VHT80:
4954 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
4955 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4956 phymode = eCSR_DOT11_MODE_11ac;
4957 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
4958 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4959 curr_band = eCSR_BAND_5G;
4960 } else {
4961 sme_set_phy_mode(hal, old_phymode);
4962 return -EIO;
4963 }
4964 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004965 case IEEE80211_MODE_2G_AUTO:
4966 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4967 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4968 phymode = eCSR_DOT11_MODE_AUTO;
4969 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4970 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4971 curr_band = eCSR_BAND_24;
4972 } else {
4973 sme_set_phy_mode(hal, old_phymode);
4974 return -EIO;
4975 }
4976 break;
4977 case IEEE80211_MODE_5G_AUTO:
4978 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4979 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4980 phymode = eCSR_DOT11_MODE_AUTO;
4981 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4982 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4983 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4984 curr_band = eCSR_BAND_5G;
4985 } else {
4986 sme_set_phy_mode(hal, old_phymode);
4987 return -EIO;
4988 }
4989 break;
4990 case IEEE80211_MODE_11AGN:
4991 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4992 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
4993 phymode = eCSR_DOT11_MODE_11n;
4994 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4995 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4996 curr_band = eCSR_BAND_ALL;
4997 } else {
4998 sme_set_phy_mode(hal, old_phymode);
4999 return -EIO;
5000 }
5001 break;
5002 default:
5003 return -EIO;
5004 }
5005
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005006 switch (new_phymode) {
5007 case IEEE80211_MODE_11AC_VHT20:
5008 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5009 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5010 break;
5011 case IEEE80211_MODE_11AC_VHT40:
5012 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5013 break;
5014 case IEEE80211_MODE_11AC_VHT80:
5015 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5016 break;
5017 default:
5018 vhtchanwidth = phddctx->config->vhtChannelWidth;
5019 break;
5020 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005021
5022 if (phymode != -EIO) {
5023 sme_get_config_param(hal, &smeconfig);
5024 smeconfig.csrConfig.phyMode = phymode;
5025#ifdef QCA_HT_2040_COEX
5026 if (phymode == eCSR_DOT11_MODE_11n &&
5027 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
5028 smeconfig.csrConfig.obssEnabled = false;
5029 halStatus = sme_set_ht2040_mode(hal,
5030 pAdapter->sessionId,
5031 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305032 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005033 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005034 return -EIO;
5035 }
5036 } else if (phymode == eCSR_DOT11_MODE_11n &&
5037 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
5038 smeconfig.csrConfig.obssEnabled = true;
5039 halStatus = sme_set_ht2040_mode(hal,
5040 pAdapter->sessionId,
5041 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305042 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005043 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005044 return -EIO;
5045 }
5046 }
5047#endif
5048 smeconfig.csrConfig.eBand = curr_band;
5049 smeconfig.csrConfig.bandCapability = curr_band;
5050 if (curr_band == eCSR_BAND_24)
5051 smeconfig.csrConfig.Is11hSupportEnabled = 0;
5052 else
5053 smeconfig.csrConfig.Is11hSupportEnabled =
5054 phddctx->config->Is11hSupportEnabled;
5055 if (curr_band == eCSR_BAND_24)
5056 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5057 else if (curr_band == eCSR_BAND_24)
5058 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5059 else {
5060 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5061 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5062 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005063 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005064 sme_update_config(hal, &smeconfig);
5065
5066 phddctx->config->dot11Mode = hdd_dot11mode;
5067 phddctx->config->nBandCapability = curr_band;
5068 phddctx->config->nChannelBondingMode24GHz =
5069 smeconfig.csrConfig.channelBondingMode24GHz;
5070 phddctx->config->nChannelBondingMode5GHz =
5071 smeconfig.csrConfig.channelBondingMode5GHz;
5072 phddctx->config->vhtChannelWidth = vhtchanwidth;
5073 if (hdd_update_config_dat(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005074 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 return -EIO;
5076 }
5077 if (phddctx->config->nChannelBondingMode5GHz)
5078 phddctx->wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap.cap
5079 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5080 else
5081 phddctx->wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap.cap
5082 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5083
Jeff Johnson99bac312016-06-28 10:38:18 -07005084 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085 phymode, chwidth, curr_band, vhtchanwidth);
5086 }
5087
5088 return 0;
5089}
5090
5091/**
5092 * hdd_get_temperature_cb() - "Get Temperature" callback function
5093 * @temperature: measured temperature
5094 * @pContext: callback context
5095 *
5096 * This function is passed to sme_get_temperature() as the callback
5097 * function to be invoked when the temperature measurement is
5098 * available.
5099 *
5100 * Return: None
5101 */
5102static void hdd_get_temperature_cb(int temperature, void *pContext)
5103{
5104 struct statsContext *pTempContext;
5105 hdd_adapter_t *pAdapter;
5106 ENTER();
5107 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005108 hdd_err("pContext is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 return;
5110 }
5111 pTempContext = pContext;
5112 pAdapter = pTempContext->pAdapter;
5113 spin_lock(&hdd_context_lock);
5114 if ((NULL == pAdapter) || (TEMP_CONTEXT_MAGIC != pTempContext->magic)) {
5115 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07005116 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 pAdapter, pTempContext->magic);
5118 return;
5119 }
5120 if (temperature != 0) {
5121 pAdapter->temperature = temperature;
5122 }
5123 complete(&pTempContext->completion);
5124 spin_unlock(&hdd_context_lock);
5125 EXIT();
5126}
5127
5128/**
5129 * wlan_hdd_get_temperature() - get current device temperature
5130 * @pAdapter: device upon which the request was made
5131 * @temperature: pointer to where the temperature is to be returned
5132 *
5133 * Return: 0 if a temperature value (either current or cached) was
5134 * returned, otherwise a negative errno is returned.
5135 *
5136 */
5137int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
5138{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305139 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005140 struct statsContext tempContext;
5141 unsigned long rc;
5142
5143 ENTER();
5144 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005145 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005146 return -EPERM;
5147 }
5148 init_completion(&tempContext.completion);
5149 tempContext.pAdapter = pAdapter;
5150 tempContext.magic = TEMP_CONTEXT_MAGIC;
5151 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
5152 &tempContext, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305153 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005154 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155 } else {
5156 rc = wait_for_completion_timeout(&tempContext.completion,
5157 msecs_to_jiffies
5158 (WLAN_WAIT_TIME_STATS));
5159 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005160 hdd_err("SME timed out while retrieving temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005161 }
5162 }
5163 spin_lock(&hdd_context_lock);
5164 tempContext.magic = 0;
5165 spin_unlock(&hdd_context_lock);
5166 *temperature = pAdapter->temperature;
5167 EXIT();
5168 return 0;
5169}
5170
5171/**
5172 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5173 * @dev: device upon which the ioctl was received
5174 * @info: ioctl request information
5175 * @wrqu: ioctl request data
5176 * @extra: ioctl extra data
5177 *
5178 * Return: 0 on success, non-zero on error
5179 */
5180static int __iw_setint_getnone(struct net_device *dev,
5181 struct iw_request_info *info,
5182 union iwreq_data *wrqu, char *extra)
5183{
5184 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5185 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5186 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5187 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5188 hdd_context_t *hdd_ctx;
5189 tSmeConfigParams smeConfig;
5190 int *value = (int *)extra;
5191 int sub_cmd = value[0];
5192 int set_value = value[1];
5193 int ret;
5194 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305195 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005196
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005197 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305198
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199 INIT_COMPLETION(pWextState->completion_var);
Mukul Sharma81661ae2015-10-30 20:26:02 +05305200 memset(&smeConfig, 0x00, sizeof(smeConfig));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201
5202 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5203 ret = wlan_hdd_validate_context(hdd_ctx);
5204 if (0 != ret)
5205 return ret;
5206
5207 switch (sub_cmd) {
5208 case WE_SET_11D_STATE:
5209 {
5210 if ((ENABLE_11D == set_value)
5211 || (DISABLE_11D == set_value)) {
5212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005213 sme_get_config_param(hHal, &smeConfig);
5214 smeConfig.csrConfig.Is11dSupportEnabled =
5215 (bool) set_value;
5216
Jeff Johnson99bac312016-06-28 10:38:18 -07005217 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 smeConfig.csrConfig.
5219 Is11dSupportEnabled);
5220
5221 sme_update_config(hHal, &smeConfig);
5222 } else {
5223 return -EINVAL;
5224 }
5225 break;
5226 }
5227
5228 case WE_WOWL:
5229 {
5230 switch (set_value) {
5231 case 0x00:
5232 hdd_exit_wowl(pAdapter);
5233 break;
5234 case 0x01:
5235 case 0x02:
5236 case 0x03:
5237 enable_mp = (set_value & 0x01) ? 1 : 0;
5238 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005239 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005240 (enable_mp ? "YES" : "NO"),
5241 (enable_pbm ? "YES" : "NO"));
5242 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5243 break;
5244 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005245 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246 set_value);
5247 ret = -EINVAL;
5248 break;
5249 }
5250
5251 break;
5252 }
5253 case WE_SET_POWER:
5254 {
5255 switch (set_value) {
5256 case 1:
5257 /* Enable PowerSave */
5258 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5259 SME_PS_ENABLE);
5260 break;
5261 case 2:
5262 /* Disable PowerSave */
5263 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5264 SME_PS_DISABLE);
5265 break;
5266 case 3: /* Enable UASPD */
5267 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
5268 break;
5269 case 4: /* Disable UASPD */
5270 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
5271 break;
5272 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005273 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005274 set_value);
5275 ret = -EINVAL;
5276 break;
5277 }
5278 break;
5279 }
5280
5281 case WE_SET_MAX_ASSOC:
5282 {
5283 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5284 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5285 ret = -EINVAL;
5286 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5287 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305288 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005289 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 ret = -EIO;
5291 }
5292 break;
5293 }
5294
5295 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5296 if (set_value == 0 || set_value == 1)
5297 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
5298 set_value;
5299 else
5300 ret = -EINVAL;
5301 break;
5302
5303 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5305 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5306 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5307 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305308 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005309 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 ret = -EINVAL;
5311 }
5312 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005313 case WE_SET_MC_RATE:
5314 {
5315 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
5316 break;
5317 }
5318 case WE_SET_TX_POWER:
5319 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305320 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321
Anurag Chouhanc5548422016-02-24 18:33:27 +05305322 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323 if (sme_set_tx_power
5324 (hHal, pAdapter->sessionId, bssid,
5325 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305326 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005327 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328 return -EIO;
5329 }
5330 break;
5331 }
5332 case WE_SET_MAX_TX_POWER:
5333 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305334 struct qdf_mac_addr bssid;
5335 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336
Jeff Johnson99bac312016-06-28 10:38:18 -07005337 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305339 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
5340 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341
5342 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305343 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005344 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 return -EIO;
5346 }
5347
5348 break;
5349 }
5350 case WE_SET_MAX_TX_POWER_2_4:
5351 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005352 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
5353 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305355 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005356 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357 return -EIO;
5358 }
5359
5360 break;
5361 }
5362 case WE_SET_MAX_TX_POWER_5_0:
5363 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005364 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
5365 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305367 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005368 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005369 return -EIO;
5370 }
5371
5372 break;
5373 }
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08005374 case WE_SET_PKTLOG:
5375 {
5376 hdd_process_pktlog_command(hdd_ctx, set_value);
5377 break;
5378 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379 case WE_SET_HIGHER_DTIM_TRANSITION:
5380 {
5381 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005382 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 set_value);
5384 ret = -EINVAL;
5385 } else {
5386 if (pAdapter->higherDtimTransition != set_value) {
5387 pAdapter->higherDtimTransition =
5388 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07005389 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390 pAdapter->higherDtimTransition);
5391 }
5392 }
5393
5394 break;
5395 }
5396
5397 case WE_SET_TM_LEVEL:
5398 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005399 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400 (void)sme_set_thermal_level(hHal, set_value);
5401 break;
5402 }
5403
5404 case WE_SET_PHYMODE:
5405 {
5406 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5407
5408 ret =
5409 wlan_hdd_update_phymode(dev, hHal, set_value,
5410 phddctx);
5411 break;
5412 }
5413
5414 case WE_SET_NSS:
5415 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005416 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005417 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005418 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419 ret = -EINVAL;
5420 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305421 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005422 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
5423 set_value))
5424 ret = -EINVAL;
5425 }
5426 break;
5427 }
5428
5429 case WE_SET_GTX_HT_MCS:
5430 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005431 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432 ret = wma_cli_set_command(pAdapter->sessionId,
5433 WMI_VDEV_PARAM_GTX_HT_MCS,
5434 set_value, GTX_CMD);
5435 break;
5436 }
5437
5438 case WE_SET_GTX_VHT_MCS:
5439 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005440 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441 set_value);
5442 ret = wma_cli_set_command(pAdapter->sessionId,
5443 WMI_VDEV_PARAM_GTX_VHT_MCS,
5444 set_value, GTX_CMD);
5445 break;
5446 }
5447
5448 case WE_SET_GTX_USRCFG:
5449 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005450 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 set_value);
5452 ret = wma_cli_set_command(pAdapter->sessionId,
5453 WMI_VDEV_PARAM_GTX_USR_CFG,
5454 set_value, GTX_CMD);
5455 break;
5456 }
5457
5458 case WE_SET_GTX_THRE:
5459 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005460 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005461 ret = wma_cli_set_command(pAdapter->sessionId,
5462 WMI_VDEV_PARAM_GTX_THRE,
5463 set_value, GTX_CMD);
5464 break;
5465 }
5466
5467 case WE_SET_GTX_MARGIN:
5468 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005469 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005470 ret = wma_cli_set_command(pAdapter->sessionId,
5471 WMI_VDEV_PARAM_GTX_MARGIN,
5472 set_value, GTX_CMD);
5473 break;
5474 }
5475
5476 case WE_SET_GTX_STEP:
5477 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005478 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479 ret = wma_cli_set_command(pAdapter->sessionId,
5480 WMI_VDEV_PARAM_GTX_STEP,
5481 set_value, GTX_CMD);
5482 break;
5483 }
5484
5485 case WE_SET_GTX_MINTPC:
5486 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005487 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488 ret = wma_cli_set_command(pAdapter->sessionId,
5489 WMI_VDEV_PARAM_GTX_MINTPC,
5490 set_value, GTX_CMD);
5491 break;
5492 }
5493
5494 case WE_SET_GTX_BWMASK:
5495 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005496 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497 ret = wma_cli_set_command(pAdapter->sessionId,
5498 WMI_VDEV_PARAM_GTX_BW_MASK,
5499 set_value, GTX_CMD);
5500 break;
5501 }
5502
5503 case WE_SET_LDPC:
5504 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305505 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506 break;
5507 }
5508
5509 case WE_SET_TX_STBC:
5510 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305511 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512 break;
5513 }
5514
5515 case WE_SET_RX_STBC:
5516 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305517 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005518 break;
5519 }
5520
5521 case WE_SET_SHORT_GI:
5522 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005523 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005524 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
5525 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
5526 set_value);
5527 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07005528 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005529 break;
5530 }
5531
5532 case WE_SET_RTSCTS:
5533 {
5534 uint32_t value;
5535
Jeff Johnson99bac312016-06-28 10:38:18 -07005536 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005537 set_value);
5538
5539 if ((set_value & HDD_RTSCTS_EN_MASK) ==
5540 HDD_RTSCTS_ENABLE)
5541 value =
5542 (WLAN_HDD_GET_CTX(pAdapter))->config->
5543 RTSThreshold;
5544 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
5545 || ((set_value & HDD_RTSCTS_EN_MASK) ==
5546 HDD_CTS_ENABLE))
5547 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
5548 else
5549 return -EIO;
5550
5551 ret = wma_cli_set_command(pAdapter->sessionId,
5552 WMI_VDEV_PARAM_ENABLE_RTSCTS,
5553 set_value, VDEV_CMD);
5554 if (!ret) {
5555 if (sme_cfg_set_int
5556 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305557 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005558 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559 return -EIO;
5560 }
5561 }
5562
5563 break;
5564 }
5565
5566 case WE_SET_CHWIDTH:
5567 {
5568 bool chwidth = false;
5569 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5570 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07005571 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 set_value);
5573 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005574 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 return -EINVAL;
5576 }
5577
5578 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5579 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
5580 nChannelBondingMode5GHz)))
5581 chwidth = true;
5582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005583 sme_get_config_param(hHal, &smeConfig);
5584 switch (set_value) {
5585 case eHT_CHANNEL_WIDTH_20MHZ:
5586 smeConfig.csrConfig.channelBondingMode5GHz =
5587 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5588 break;
5589 case eHT_CHANNEL_WIDTH_40MHZ:
5590 if (chwidth)
5591 smeConfig.csrConfig.
5592 channelBondingMode5GHz =
5593 phddctx->config->
5594 nChannelBondingMode5GHz;
5595 else
5596 return -EINVAL;
5597
5598 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005599 case eHT_CHANNEL_WIDTH_80MHZ:
5600 if (chwidth)
5601 smeConfig.csrConfig.
5602 channelBondingMode5GHz =
5603 phddctx->config->
5604 nChannelBondingMode5GHz;
5605 else
5606 return -EINVAL;
5607
5608 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005609
5610 default:
5611 return -EINVAL;
5612 }
5613
5614 ret = wma_cli_set_command(pAdapter->sessionId,
5615 WMI_VDEV_PARAM_CHWIDTH,
5616 set_value, VDEV_CMD);
5617 if (!ret)
5618 sme_update_config(hHal, &smeConfig);
5619
5620 break;
5621 }
5622
5623 case WE_SET_ANI_EN_DIS:
5624 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005625 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626 set_value);
5627 ret = wma_cli_set_command(pAdapter->sessionId,
5628 WMI_PDEV_PARAM_ANI_ENABLE,
5629 set_value, PDEV_CMD);
5630 break;
5631 }
5632
5633 case WE_SET_ANI_POLL_PERIOD:
5634 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005635 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636 set_value);
5637 ret = wma_cli_set_command(pAdapter->sessionId,
5638 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
5639 set_value, PDEV_CMD);
5640 break;
5641 }
5642
5643 case WE_SET_ANI_LISTEN_PERIOD:
5644 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005645 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005646 set_value);
5647 ret = wma_cli_set_command(pAdapter->sessionId,
5648 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
5649 set_value, PDEV_CMD);
5650 break;
5651 }
5652
5653 case WE_SET_ANI_OFDM_LEVEL:
5654 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005655 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005656 set_value);
5657 ret = wma_cli_set_command(pAdapter->sessionId,
5658 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
5659 set_value, PDEV_CMD);
5660 break;
5661 }
5662
5663 case WE_SET_ANI_CCK_LEVEL:
5664 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005665 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005666 set_value);
5667 ret = wma_cli_set_command(pAdapter->sessionId,
5668 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
5669 set_value, PDEV_CMD);
5670 break;
5671 }
5672
5673 case WE_SET_DYNAMIC_BW:
5674 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005675 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005676 set_value);
5677 ret = wma_cli_set_command(pAdapter->sessionId,
5678 WMI_PDEV_PARAM_DYNAMIC_BW,
5679 set_value, PDEV_CMD);
5680 break;
5681 }
5682
5683 case WE_SET_CTS_CBW:
5684 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005685 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005686 ret = wma_cli_set_command(pAdapter->sessionId,
5687 WMI_PDEV_PARAM_CTS_CBW,
5688 set_value, PDEV_CMD);
5689 break;
5690 }
5691
5692 case WE_SET_11N_RATE:
5693 {
5694 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005695 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696 set_value);
5697
5698 if (set_value != 0xff) {
5699 rix = RC_2_RATE_IDX(set_value);
5700 if (set_value & 0x80) {
5701 preamble = WMI_RATE_PREAMBLE_HT;
5702 nss = HT_RC_2_STREAMS(set_value) - 1;
5703 } else {
5704 nss = 0;
5705 rix = RC_2_RATE_IDX(set_value);
5706 if (set_value & 0x10) {
5707 preamble =
5708 WMI_RATE_PREAMBLE_CCK;
5709 if (rix != 0x3)
5710 /* Enable Short
5711 * preamble always for
5712 * CCK except 1mbps
5713 */
5714 rix |= 0x4;
5715 } else {
5716 preamble =
5717 WMI_RATE_PREAMBLE_OFDM;
5718 }
5719 }
5720 set_value = (preamble << 6) | (nss << 4) | rix;
5721 }
5722 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5723 set_value, rix, preamble, nss);
5724
5725 ret = wma_cli_set_command(pAdapter->sessionId,
5726 WMI_VDEV_PARAM_FIXED_RATE,
5727 set_value, VDEV_CMD);
5728 break;
5729 }
5730
5731 case WE_SET_VHT_RATE:
5732 {
5733 uint8_t preamble = 0, nss = 0, rix = 0;
5734
5735 if (set_value != 0xff) {
5736 rix = RC_2_RATE_IDX_11AC(set_value);
5737 preamble = WMI_RATE_PREAMBLE_VHT;
5738 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
5739
5740 set_value = (preamble << 6) | (nss << 4) | rix;
5741 }
5742 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5743 set_value, rix, preamble, nss);
5744 ret = wma_cli_set_command(pAdapter->sessionId,
5745 WMI_VDEV_PARAM_FIXED_RATE,
5746 set_value, VDEV_CMD);
5747 break;
5748 }
5749
5750 case WE_SET_AMPDU:
5751 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005752 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753 ret = wma_cli_set_command(pAdapter->sessionId,
5754 GEN_VDEV_PARAM_AMPDU,
5755 set_value, GEN_CMD);
5756 break;
5757 }
5758
5759 case WE_SET_AMSDU:
5760 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005761 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762 ret = wma_cli_set_command(pAdapter->sessionId,
5763 GEN_VDEV_PARAM_AMSDU,
5764 set_value, GEN_CMD);
5765 break;
5766 }
5767
5768 case WE_SET_BURST_ENABLE:
5769 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005770 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771 if ((set_value == 0) || (set_value == 1)) {
5772 ret = wma_cli_set_command(pAdapter->sessionId,
5773 WMI_PDEV_PARAM_BURST_ENABLE,
5774 set_value, PDEV_CMD);
5775 } else
5776 ret = -EINVAL;
5777 break;
5778 }
5779 case WE_SET_BURST_DUR:
5780 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005781 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07005782 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 ret = wma_cli_set_command(pAdapter->sessionId,
5784 WMI_PDEV_PARAM_BURST_DUR,
5785 set_value, PDEV_CMD);
5786 else
5787 ret = -EINVAL;
5788 break;
5789 }
5790
5791 case WE_SET_TX_CHAINMASK:
5792 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005793 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794 set_value);
5795 ret = wma_cli_set_command(pAdapter->sessionId,
5796 WMI_PDEV_PARAM_TX_CHAIN_MASK,
5797 set_value, PDEV_CMD);
5798 break;
5799 }
5800
5801 case WE_SET_RX_CHAINMASK:
5802 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005803 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 set_value);
5805 ret = wma_cli_set_command(pAdapter->sessionId,
5806 WMI_PDEV_PARAM_RX_CHAIN_MASK,
5807 set_value, PDEV_CMD);
5808 break;
5809 }
5810
5811 case WE_SET_TXPOW_2G:
5812 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005813 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005814 set_value);
5815 ret = wma_cli_set_command(pAdapter->sessionId,
5816 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
5817 set_value, PDEV_CMD);
5818 break;
5819 }
5820
5821 case WE_SET_TXPOW_5G:
5822 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005823 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005824 set_value);
5825 ret = wma_cli_set_command(pAdapter->sessionId,
5826 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
5827 set_value, PDEV_CMD);
5828 break;
5829 }
5830
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005831 /* Firmware debug log */
5832 case WE_DBGLOG_LOG_LEVEL:
5833 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005834 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
5836 ret = wma_cli_set_command(pAdapter->sessionId,
5837 WMI_DBGLOG_LOG_LEVEL,
5838 set_value, DBG_CMD);
5839 break;
5840 }
5841
5842 case WE_DBGLOG_VAP_ENABLE:
5843 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005844 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005845 ret = wma_cli_set_command(pAdapter->sessionId,
5846 WMI_DBGLOG_VAP_ENABLE,
5847 set_value, DBG_CMD);
5848 break;
5849 }
5850
5851 case WE_DBGLOG_VAP_DISABLE:
5852 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005853 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005854 ret = wma_cli_set_command(pAdapter->sessionId,
5855 WMI_DBGLOG_VAP_DISABLE,
5856 set_value, DBG_CMD);
5857 break;
5858 }
5859
5860 case WE_DBGLOG_MODULE_ENABLE:
5861 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005862 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863 set_value);
5864 hdd_ctx->fw_log_settings.enable = set_value;
5865 ret = wma_cli_set_command(pAdapter->sessionId,
5866 WMI_DBGLOG_MODULE_ENABLE,
5867 set_value, DBG_CMD);
5868 break;
5869 }
5870
5871 case WE_DBGLOG_MODULE_DISABLE:
5872 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005873 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005874 set_value);
5875 hdd_ctx->fw_log_settings.enable = set_value;
5876 ret = wma_cli_set_command(pAdapter->sessionId,
5877 WMI_DBGLOG_MODULE_DISABLE,
5878 set_value, DBG_CMD);
5879 break;
5880 }
5881 case WE_DBGLOG_MOD_LOG_LEVEL:
5882 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005883 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005884 set_value);
5885
5886 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
5887 hdd_ctx->fw_log_settings.index = 0;
5888
5889 hdd_ctx->fw_log_settings.
5890 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
5891 set_value;
5892 hdd_ctx->fw_log_settings.index++;
5893
5894 ret = wma_cli_set_command(pAdapter->sessionId,
5895 WMI_DBGLOG_MOD_LOG_LEVEL,
5896 set_value, DBG_CMD);
5897 break;
5898 }
5899
5900 case WE_DBGLOG_TYPE:
5901 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005902 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903 hdd_ctx->fw_log_settings.dl_type = set_value;
5904 ret = wma_cli_set_command(pAdapter->sessionId,
5905 WMI_DBGLOG_TYPE,
5906 set_value, DBG_CMD);
5907 break;
5908 }
5909 case WE_DBGLOG_REPORT_ENABLE:
5910 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005911 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005912 set_value);
5913 hdd_ctx->fw_log_settings.dl_report = set_value;
5914 ret = wma_cli_set_command(pAdapter->sessionId,
5915 WMI_DBGLOG_REPORT_ENABLE,
5916 set_value, DBG_CMD);
5917 break;
5918 }
5919
5920 case WE_SET_TXRX_FWSTATS:
5921 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005922 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923 ret = wma_cli_set_command(pAdapter->sessionId,
5924 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
5925 set_value, VDEV_CMD);
5926 break;
5927 }
5928
5929 case WE_TXRX_FWSTATS_RESET:
5930 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005931 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005932 ret = wma_cli_set_command(pAdapter->sessionId,
5933 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
5934 set_value, VDEV_CMD);
5935 break;
5936 }
5937
5938 case WE_DUMP_STATS:
5939 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005940 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005941 hdd_wlan_dump_stats(pAdapter, set_value);
5942 break;
5943 }
5944
5945 case WE_CLEAR_STATS:
5946 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005947 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005948 switch (set_value) {
5949 case WLAN_HDD_STATS:
5950 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5951 memset(&pAdapter->hdd_stats, 0,
5952 sizeof(pAdapter->hdd_stats));
5953 break;
5954 case WLAN_TXRX_HIST_STATS:
5955 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
5956 break;
5957 case WLAN_HDD_NETIF_OPER_HISTORY:
5958 wlan_hdd_clear_netif_queue_history(hdd_ctx);
5959 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05305960 case WLAN_HIF_STATS:
5961 hdd_clear_hif_stats();
5962 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005963 default:
5964 ol_txrx_clear_stats(set_value);
5965 }
5966 break;
5967 }
5968
5969 case WE_PPS_PAID_MATCH:
5970 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005971 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972 return EINVAL;
5973
Jeff Johnson99bac312016-06-28 10:38:18 -07005974 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975 set_value);
5976 ret = wma_cli_set_command(pAdapter->sessionId,
5977 WMI_VDEV_PPS_PAID_MATCH,
5978 set_value, PPS_CMD);
5979 break;
5980 }
5981
5982 case WE_PPS_GID_MATCH:
5983 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005984 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005985 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07005986 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005987 set_value);
5988 ret = wma_cli_set_command(pAdapter->sessionId,
5989 WMI_VDEV_PPS_GID_MATCH,
5990 set_value, PPS_CMD);
5991 break;
5992 }
5993
5994 case WE_PPS_EARLY_TIM_CLEAR:
5995 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005996 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005997 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07005998 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 set_value);
6000 ret = wma_cli_set_command(pAdapter->sessionId,
6001 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6002 set_value, PPS_CMD);
6003 break;
6004 }
6005
6006 case WE_PPS_EARLY_DTIM_CLEAR:
6007 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006008 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006010 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011 set_value);
6012 ret = wma_cli_set_command(pAdapter->sessionId,
6013 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6014 set_value, PPS_CMD);
6015 break;
6016 }
6017
6018 case WE_PPS_EOF_PAD_DELIM:
6019 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006020 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006022 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006023 set_value);
6024 ret = wma_cli_set_command(pAdapter->sessionId,
6025 WMI_VDEV_PPS_EOF_PAD_DELIM,
6026 set_value, PPS_CMD);
6027 break;
6028 }
6029
6030 case WE_PPS_MACADDR_MISMATCH:
6031 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006032 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006034 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 set_value);
6036 ret = wma_cli_set_command(pAdapter->sessionId,
6037 WMI_VDEV_PPS_MACADDR_MISMATCH,
6038 set_value, PPS_CMD);
6039 break;
6040 }
6041
6042 case WE_PPS_DELIM_CRC_FAIL:
6043 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006044 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006046 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006047 set_value);
6048 ret = wma_cli_set_command(pAdapter->sessionId,
6049 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6050 set_value, PPS_CMD);
6051 break;
6052 }
6053
6054 case WE_PPS_GID_NSTS_ZERO:
6055 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006056 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006057 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006058 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059 set_value);
6060 ret = wma_cli_set_command(pAdapter->sessionId,
6061 WMI_VDEV_PPS_GID_NSTS_ZERO,
6062 set_value, PPS_CMD);
6063 break;
6064 }
6065
6066 case WE_PPS_RSSI_CHECK:
6067 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006068 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006069 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006070 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 set_value);
6072 ret = wma_cli_set_command(pAdapter->sessionId,
6073 WMI_VDEV_PPS_RSSI_CHECK,
6074 set_value, PPS_CMD);
6075 break;
6076 }
6077
6078 case WE_PPS_5G_EBT:
6079 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006080 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 return -EINVAL;
6082
Jeff Johnson99bac312016-06-28 10:38:18 -07006083 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006084 ret = wma_cli_set_command(pAdapter->sessionId,
6085 WMI_VDEV_PPS_5G_EBT,
6086 set_value, PPS_CMD);
6087 break;
6088 }
6089
6090 case WE_SET_HTSMPS:
6091 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006092 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093 ret = wma_cli_set_command(pAdapter->sessionId,
6094 WMI_STA_SMPS_FORCE_MODE_CMDID,
6095 set_value, VDEV_CMD);
6096 break;
6097 }
6098
6099 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6100 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006101 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006102 set_value);
6103 ret = wma_cli_set_command(pAdapter->sessionId,
6104 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6105 set_value, QPOWER_CMD);
6106 break;
6107 }
6108
6109 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6110 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006111 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006112 set_value);
6113 ret = wma_cli_set_command(
6114 pAdapter->sessionId,
6115 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6116 set_value, QPOWER_CMD);
6117 break;
6118 }
6119
6120 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6121 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006122 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123 set_value);
6124 ret = wma_cli_set_command(
6125 pAdapter->sessionId,
6126 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6127 set_value, QPOWER_CMD);
6128 break;
6129 }
6130
6131 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6132 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006133 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006134 set_value);
6135 ret = wma_cli_set_command(
6136 pAdapter->sessionId,
6137 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6138 set_value, QPOWER_CMD);
6139 break;
6140 }
6141
6142 case WE_MCC_CONFIG_LATENCY:
6143 {
6144 cds_set_mcc_latency(pAdapter, set_value);
6145 break;
6146 }
6147
6148 case WE_MCC_CONFIG_QUOTA:
6149 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006150 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006151 set_value);
6152 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
6153 break;
6154 }
6155 case WE_SET_DEBUG_LOG:
6156 {
6157 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05306158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006159 hdd_ctx->config->gEnableDebugLog = set_value;
6160 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6161 break;
6162 }
6163 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6164 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006165 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006166 if ((set_value == 0) || (set_value == 1))
6167 ret = wma_cli_set_command(
6168 pAdapter->sessionId,
6169 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6170 set_value, VDEV_CMD);
6171 else
6172 ret = -EINVAL;
6173 break;
6174 }
6175 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6176 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006177 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006178 ret = wma_cli_set_command(pAdapter->sessionId,
6179 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6180 set_value, VDEV_CMD);
6181 break;
6182 }
6183 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6184 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006185 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 set_value);
6187 ret = wma_cli_set_command(
6188 pAdapter->sessionId,
6189 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6190 set_value, VDEV_CMD);
6191 break;
6192 }
6193 case WE_SET_EARLY_RX_SLOP_STEP:
6194 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006195 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006196 set_value);
6197 ret = wma_cli_set_command(pAdapter->sessionId,
6198 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6199 set_value, VDEV_CMD);
6200 break;
6201 }
6202 case WE_SET_EARLY_RX_INIT_SLOP:
6203 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006204 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006205 set_value);
6206 ret = wma_cli_set_command(pAdapter->sessionId,
6207 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6208 set_value, VDEV_CMD);
6209 break;
6210 }
6211 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6212 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006213 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006214 if ((set_value == 0) || (set_value == 1))
6215 ret = wma_cli_set_command(
6216 pAdapter->sessionId,
6217 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6218 set_value, VDEV_CMD);
6219 else
6220 ret = -EINVAL;
6221 break;
6222 }
6223 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6224 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006225 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006226 ret = wma_cli_set_command(pAdapter->sessionId,
6227 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6228 set_value, VDEV_CMD);
6229 break;
6230 }
6231 case WE_SET_SCAN_DISABLE:
6232 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006233 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006234 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
6235 break;
6236 }
Govind Singha471e5e2015-10-12 17:11:14 +05306237 case WE_START_FW_PROFILE:
6238 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006239 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05306240 ret = wma_cli_set_command(pAdapter->sessionId,
6241 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6242 set_value, DBG_CMD);
6243 break;
6244 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306245 case WE_SET_CHANNEL:
6246 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006247 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306248 pAdapter->sessionId, pAdapter->device_mode);
6249
Krunal Sonif07bb382016-03-10 13:02:11 -08006250 if ((QDF_STA_MODE == pAdapter->device_mode) ||
6251 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306252
6253 status = sme_ext_change_channel(hHal,
6254 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306255 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006256 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306257 status);
6258 ret = -EINVAL;
6259 }
6260 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006261 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306262 pAdapter->device_mode);
6263 ret = -EINVAL;
6264 }
6265 break;
6266 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306267 case WE_SET_CONC_SYSTEM_PREF:
6268 {
6269 hdd_info("New preference: %d", set_value);
6270 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6271 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6272 hdd_err("Invalid system preference %d", set_value);
6273 return -EINVAL;
6274 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306275
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306276 /* hdd_ctx, hdd_ctx->config are already checked for null */
6277 hdd_ctx->config->conc_system_pref = set_value;
6278 break;
6279 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006280 default:
6281 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006282 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006283 sub_cmd);
6284 ret = -EINVAL;
6285 break;
6286 }
6287 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306288 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006289 return ret;
6290}
6291
6292static int iw_setint_getnone(struct net_device *dev,
6293 struct iw_request_info *info,
6294 union iwreq_data *wrqu,
6295 char *extra)
6296{
6297 int ret;
6298
6299 cds_ssr_protect(__func__);
6300 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6301 cds_ssr_unprotect(__func__);
6302
6303 return ret;
6304}
6305
6306/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006307 * __iw_setnone_get_threeint() - return three value to up layer.
6308 *
6309 * @dev: pointer of net_device of this wireless card
6310 * @info: meta data about Request sent
6311 * @wrqu: include request info
6312 * @extra: buf used for in/Output
6313 *
6314 * Return: execute result
6315 */
6316static int __iw_setnone_get_threeint(struct net_device *dev,
6317 struct iw_request_info *info,
6318 union iwreq_data *wrqu, char *extra)
6319{
6320 int ret = 0; /* success */
6321 uint32_t *value = (int *)extra;
6322 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6323 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6324
6325 ENTER_DEV(dev);
6326 ret = wlan_hdd_validate_context(hdd_ctx);
6327 if (0 != ret)
6328 return ret;
6329
Jeff Johnson99bac312016-06-28 10:38:18 -07006330 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006331 switch (value[0]) {
6332 case WE_GET_TSF:
6333 ret = hdd_indicate_tsf(adapter, value, 3);
6334 break;
6335 default:
6336 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6337 break;
6338 }
6339 return ret;
6340}
6341
6342/**
6343 * iw_setnone_get_threeint() - return three value to up layer.
6344 *
6345 * @dev: pointer of net_device of this wireless card
6346 * @info: meta data about Request sent
6347 * @wrqu: include request info
6348 * @extra: buf used for in/Output
6349 *
6350 * Return: execute result
6351 */
6352static int iw_setnone_get_threeint(struct net_device *dev,
6353 struct iw_request_info *info,
6354 union iwreq_data *wrqu, char *extra)
6355{
6356 int ret;
6357
6358 cds_ssr_protect(__func__);
6359 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6360 cds_ssr_unprotect(__func__);
6361
6362 return ret;
6363}
6364
6365/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006366 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6367 * @dev: device upon which the ioctl was received
6368 * @info: ioctl request information
6369 * @wrqu: ioctl request data
6370 * @extra: ioctl extra data
6371 *
6372 * Return: 0 on success, non-zero on error
6373 */
6374static int __iw_setchar_getnone(struct net_device *dev,
6375 struct iw_request_info *info,
6376 union iwreq_data *wrqu, char *extra)
6377{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306378 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006379 int sub_cmd;
6380 int ret;
6381 char *pBuffer = NULL;
6382 hdd_adapter_t *pAdapter = (netdev_priv(dev));
6383 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006384 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006385 struct iw_point s_priv_data;
6386
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006387 ENTER_DEV(dev);
6388
Mukul Sharma34777c62015-11-02 20:22:30 +05306389 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006390 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306391 return -EPERM;
6392 }
6393
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006394 ret = wlan_hdd_validate_context(hdd_ctx);
6395 if (0 != ret)
6396 return ret;
6397
6398 /* helper function to get iwreq_data with compat handling. */
6399 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
6400 return -EINVAL;
6401 }
6402
6403 /* make sure all params are correctly passed to function */
6404 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
6405 return -EINVAL;
6406 }
6407
6408 sub_cmd = s_priv_data.flags;
6409
6410 /* ODD number is used for set, copy data using copy_from_user */
6411 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6412 s_priv_data.length);
6413 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006414 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006415 return -ENOMEM;
6416 }
6417
Jeff Johnson99bac312016-06-28 10:38:18 -07006418 hdd_notice("Received length %d", s_priv_data.length);
6419 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006420
6421 switch (sub_cmd) {
6422 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006423 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006424 hdd_add_wowl_ptrn(pAdapter, pBuffer);
6425 break;
6426 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006427 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006428 hdd_del_wowl_ptrn(pAdapter, pBuffer);
6429 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006430 case WE_NEIGHBOR_REPORT_REQUEST:
6431 {
6432 tRrmNeighborReq neighborReq;
6433 tRrmNeighborRspCallbackInfo callbackInfo;
6434
6435 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006436 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006437 neighborReq.no_ssid =
6438 (s_priv_data.length - 1) ? false : true;
6439 if (!neighborReq.no_ssid) {
6440 neighborReq.ssid.length =
6441 (s_priv_data.length - 1) >
6442 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306443 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006444 pBuffer,
6445 neighborReq.ssid.length);
6446 }
6447
6448 callbackInfo.neighborRspCallback = NULL;
6449 callbackInfo.neighborRspCallbackContext = NULL;
6450 callbackInfo.timeout = 5000; /* 5 seconds */
6451 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
6452 (pAdapter),
6453 pAdapter->sessionId,
6454 &neighborReq,
6455 &callbackInfo);
6456 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006457 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006458 ret = -EINVAL;
6459 }
6460 }
6461 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006462 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07006463 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006464 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
6465 s_priv_data.length);
6466 break;
6467 case WE_SET_CONFIG:
6468 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306469 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006470 ret = -EINVAL;
6471 }
6472 break;
6473 default:
6474 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006475 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006476 sub_cmd);
6477 ret = -EINVAL;
6478 break;
6479 }
6480 }
6481 kfree(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306482 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006483 return ret;
6484}
6485
6486static int iw_setchar_getnone(struct net_device *dev,
6487 struct iw_request_info *info,
6488 union iwreq_data *wrqu, char *extra)
6489{
6490 int ret;
6491
6492 cds_ssr_protect(__func__);
6493 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6494 cds_ssr_unprotect(__func__);
6495
6496 return ret;
6497}
6498
6499/**
6500 * iw_setnone_getint() - Generic "get integer" private ioctl handler
6501 * @dev: device upon which the ioctl was received
6502 * @info: ioctl request information
6503 * @wrqu: ioctl request data
6504 * @extra: ioctl extra data
6505 *
6506 * Return: 0 on success, non-zero on error
6507 */
6508static int __iw_setnone_getint(struct net_device *dev,
6509 struct iw_request_info *info,
6510 union iwreq_data *wrqu, char *extra)
6511{
6512 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6513 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6514 int *value = (int *)extra;
6515 int ret;
6516 tSmeConfigParams smeConfig;
6517 hdd_context_t *hdd_ctx;
6518
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006519 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306520
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006521 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6522 ret = wlan_hdd_validate_context(hdd_ctx);
6523 if (0 != ret)
6524 return ret;
6525
6526 switch (value[0]) {
6527 case WE_GET_11D_STATE:
6528 {
6529 sme_get_config_param(hHal, &smeConfig);
6530
6531 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6532
Jeff Johnson99bac312016-06-28 10:38:18 -07006533 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006534
6535 break;
6536 }
6537
6538 case WE_IBSS_STATUS:
Jeff Johnson99bac312016-06-28 10:38:18 -07006539 hdd_notice("****Return IBSS Status*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006540 break;
6541
6542 case WE_GET_WLAN_DBG:
6543 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306544 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006545 *value = 0;
6546 break;
6547 }
6548 case WE_GET_MAX_ASSOC:
6549 {
6550 if (sme_cfg_get_int
6551 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306552 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006553 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006554 ret = -EIO;
6555 }
6556 break;
6557 }
6558 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6559 *value = (WLAN_HDD_GET_CTX(
6560 pAdapter))->config->force_sap_acs;
6561 break;
6562
6563 case WE_GET_CONCURRENCY_MODE:
6564 {
6565 *value = cds_get_concurrency_mode();
6566
Jeff Johnson99bac312016-06-28 10:38:18 -07006567 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006568 break;
6569 }
6570
6571 case WE_GET_NSS:
6572 {
6573 sme_get_config_param(hHal, &smeConfig);
6574 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07006575 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006576 break;
6577 }
6578
6579 case WE_GET_GTX_HT_MCS:
6580 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006581 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582 *value = wma_cli_get_command(pAdapter->sessionId,
6583 WMI_VDEV_PARAM_GTX_HT_MCS,
6584 GTX_CMD);
6585 break;
6586 }
6587
6588 case WE_GET_GTX_VHT_MCS:
6589 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006590 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006591 *value = wma_cli_get_command(pAdapter->sessionId,
6592 WMI_VDEV_PARAM_GTX_VHT_MCS,
6593 GTX_CMD);
6594 break;
6595 }
6596
6597 case WE_GET_GTX_USRCFG:
6598 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006599 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006600 *value = wma_cli_get_command(pAdapter->sessionId,
6601 WMI_VDEV_PARAM_GTX_USR_CFG,
6602 GTX_CMD);
6603 break;
6604 }
6605
6606 case WE_GET_GTX_THRE:
6607 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006608 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006609 *value = wma_cli_get_command(pAdapter->sessionId,
6610 WMI_VDEV_PARAM_GTX_THRE,
6611 GTX_CMD);
6612 break;
6613 }
6614
6615 case WE_GET_GTX_MARGIN:
6616 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006617 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006618 *value = wma_cli_get_command(pAdapter->sessionId,
6619 WMI_VDEV_PARAM_GTX_MARGIN,
6620 GTX_CMD);
6621 break;
6622 }
6623
6624 case WE_GET_GTX_STEP:
6625 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006626 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006627 *value = wma_cli_get_command(pAdapter->sessionId,
6628 WMI_VDEV_PARAM_GTX_STEP,
6629 GTX_CMD);
6630 break;
6631 }
6632
6633 case WE_GET_GTX_MINTPC:
6634 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006635 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006636 *value = wma_cli_get_command(pAdapter->sessionId,
6637 WMI_VDEV_PARAM_GTX_MINTPC,
6638 GTX_CMD);
6639 break;
6640 }
6641
6642 case WE_GET_GTX_BWMASK:
6643 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006644 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006645 *value = wma_cli_get_command(pAdapter->sessionId,
6646 WMI_VDEV_PARAM_GTX_BW_MASK,
6647 GTX_CMD);
6648 break;
6649 }
6650
6651 case WE_GET_LDPC:
6652 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306653 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006654 break;
6655 }
6656
6657 case WE_GET_TX_STBC:
6658 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306659 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006660 break;
6661 }
6662
6663 case WE_GET_RX_STBC:
6664 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306665 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006666 break;
6667 }
6668
6669 case WE_GET_SHORT_GI:
6670 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006671 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006672 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
6673 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
6674 break;
6675 }
6676
6677 case WE_GET_RTSCTS:
6678 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006679 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006680 *value = wma_cli_get_command(pAdapter->sessionId,
6681 WMI_VDEV_PARAM_ENABLE_RTSCTS,
6682 VDEV_CMD);
6683 break;
6684 }
6685
6686 case WE_GET_CHWIDTH:
6687 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006688 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006689 *value = wma_cli_get_command(pAdapter->sessionId,
6690 WMI_VDEV_PARAM_CHWIDTH,
6691 VDEV_CMD);
6692 break;
6693 }
6694
6695 case WE_GET_ANI_EN_DIS:
6696 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006697 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006698 *value = wma_cli_get_command(pAdapter->sessionId,
6699 WMI_PDEV_PARAM_ANI_ENABLE,
6700 PDEV_CMD);
6701 break;
6702 }
6703
6704 case WE_GET_ANI_POLL_PERIOD:
6705 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006706 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006707 *value = wma_cli_get_command(pAdapter->sessionId,
6708 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6709 PDEV_CMD);
6710 break;
6711 }
6712
6713 case WE_GET_ANI_LISTEN_PERIOD:
6714 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006715 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006716 *value = wma_cli_get_command(pAdapter->sessionId,
6717 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6718 PDEV_CMD);
6719 break;
6720 }
6721
6722 case WE_GET_ANI_OFDM_LEVEL:
6723 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006724 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006725 *value = wma_cli_get_command(pAdapter->sessionId,
6726 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6727 PDEV_CMD);
6728 break;
6729 }
6730
6731 case WE_GET_ANI_CCK_LEVEL:
6732 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006733 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006734 *value = wma_cli_get_command(pAdapter->sessionId,
6735 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6736 PDEV_CMD);
6737 break;
6738 }
6739
6740 case WE_GET_DYNAMIC_BW:
6741 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006742 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006743 *value = wma_cli_get_command(pAdapter->sessionId,
6744 WMI_PDEV_PARAM_DYNAMIC_BW,
6745 PDEV_CMD);
6746 break;
6747 }
6748
6749 case WE_GET_11N_RATE:
6750 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006751 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006752 *value = wma_cli_get_command(pAdapter->sessionId,
6753 WMI_VDEV_PARAM_FIXED_RATE,
6754 VDEV_CMD);
6755 break;
6756 }
6757
6758 case WE_GET_AMPDU:
6759 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006760 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006761 *value = wma_cli_get_command(pAdapter->sessionId,
6762 GEN_VDEV_PARAM_AMPDU,
6763 GEN_CMD);
6764 break;
6765 }
6766
6767 case WE_GET_AMSDU:
6768 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006769 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006770 *value = wma_cli_get_command(pAdapter->sessionId,
6771 GEN_VDEV_PARAM_AMSDU,
6772 GEN_CMD);
6773 break;
6774 }
6775
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006776 case WE_GET_ROAM_SYNCH_DELAY:
6777 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006778 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006779 *value = wma_cli_get_command(pAdapter->sessionId,
6780 GEN_VDEV_ROAM_SYNCH_DELAY,
6781 GEN_CMD);
6782 break;
6783 }
6784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006785 case WE_GET_BURST_ENABLE:
6786 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006787 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006788 *value = wma_cli_get_command(pAdapter->sessionId,
6789 WMI_PDEV_PARAM_BURST_ENABLE,
6790 PDEV_CMD);
6791 break;
6792 }
6793 case WE_GET_BURST_DUR:
6794 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006795 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006796 *value = wma_cli_get_command(pAdapter->sessionId,
6797 WMI_PDEV_PARAM_BURST_DUR,
6798 PDEV_CMD);
6799 break;
6800 }
6801
6802 case WE_GET_TX_CHAINMASK:
6803 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006804 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006805 *value = wma_cli_get_command(pAdapter->sessionId,
6806 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6807 PDEV_CMD);
6808 break;
6809 }
6810
6811 case WE_GET_RX_CHAINMASK:
6812 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006813 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006814 *value = wma_cli_get_command(pAdapter->sessionId,
6815 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6816 PDEV_CMD);
6817 break;
6818 }
6819
6820 case WE_GET_TXPOW_2G:
6821 {
6822 uint32_t txpow2g = 0;
6823 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006824 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006825 *value = wma_cli_get_command(pAdapter->sessionId,
6826 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6827 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306828 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006829 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6830 &txpow2g)) {
6831 return -EIO;
6832 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006833 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006834 break;
6835 }
6836
6837 case WE_GET_TXPOW_5G:
6838 {
6839 uint32_t txpow5g = 0;
6840 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006841 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006842 *value = wma_cli_get_command(pAdapter->sessionId,
6843 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6844 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306845 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006846 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6847 &txpow5g)) {
6848 return -EIO;
6849 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006850 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006851 break;
6852 }
6853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006854 case WE_GET_PPS_PAID_MATCH:
6855 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006856 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006857 *value = wma_cli_get_command(pAdapter->sessionId,
6858 WMI_VDEV_PPS_PAID_MATCH,
6859 PPS_CMD);
6860 break;
6861 }
6862
6863 case WE_GET_PPS_GID_MATCH:
6864 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006865 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006866 *value = wma_cli_get_command(pAdapter->sessionId,
6867 WMI_VDEV_PPS_GID_MATCH,
6868 PPS_CMD);
6869 break;
6870 }
6871
6872 case WE_GET_PPS_EARLY_TIM_CLEAR:
6873 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006874 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006875 *value = wma_cli_get_command(pAdapter->sessionId,
6876 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6877 PPS_CMD);
6878 break;
6879 }
6880
6881 case WE_GET_PPS_EARLY_DTIM_CLEAR:
6882 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006883 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006884 *value = wma_cli_get_command(pAdapter->sessionId,
6885 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6886 PPS_CMD);
6887 break;
6888 }
6889
6890 case WE_GET_PPS_EOF_PAD_DELIM:
6891 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006892 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006893 *value = wma_cli_get_command(pAdapter->sessionId,
6894 WMI_VDEV_PPS_EOF_PAD_DELIM,
6895 PPS_CMD);
6896 break;
6897 }
6898
6899 case WE_GET_PPS_MACADDR_MISMATCH:
6900 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006901 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006902 *value = wma_cli_get_command(pAdapter->sessionId,
6903 WMI_VDEV_PPS_MACADDR_MISMATCH,
6904 PPS_CMD);
6905 break;
6906 }
6907
6908 case WE_GET_PPS_DELIM_CRC_FAIL:
6909 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006910 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006911 *value = wma_cli_get_command(pAdapter->sessionId,
6912 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6913 PPS_CMD);
6914 break;
6915 }
6916
6917 case WE_GET_PPS_GID_NSTS_ZERO:
6918 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006919 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006920 *value = wma_cli_get_command(pAdapter->sessionId,
6921 WMI_VDEV_PPS_GID_NSTS_ZERO,
6922 PPS_CMD);
6923 break;
6924 }
6925
6926 case WE_GET_PPS_RSSI_CHECK:
6927 {
6928
Jeff Johnson99bac312016-06-28 10:38:18 -07006929 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006930 *value = wma_cli_get_command(pAdapter->sessionId,
6931 WMI_VDEV_PPS_RSSI_CHECK,
6932 PPS_CMD);
6933 break;
6934 }
6935
6936 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
6937 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006938 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006939 *value = wma_cli_get_command(pAdapter->sessionId,
6940 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6941 QPOWER_CMD);
6942 break;
6943 }
6944
6945 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
6946 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006947 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006948 *value = wma_cli_get_command(pAdapter->sessionId,
6949 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6950 QPOWER_CMD);
6951 break;
6952 }
6953
6954 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6955 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006956 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006957 *value = wma_cli_get_command(pAdapter->sessionId,
6958 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6959 QPOWER_CMD);
6960 break;
6961 }
6962
6963 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6964 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006965 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006966 *value = wma_cli_get_command(pAdapter->sessionId,
6967 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6968 QPOWER_CMD);
6969 break;
6970 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006971 case WE_CAP_TSF:
6972 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
6973 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006974 case WE_GET_TEMPERATURE:
6975 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006976 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006977 ret = wlan_hdd_get_temperature(pAdapter, value);
6978 break;
6979 }
6980 default:
6981 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006982 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006983 value[0]);
6984 break;
6985 }
6986 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306987 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006988 return ret;
6989}
6990
6991static int iw_setnone_getint(struct net_device *dev,
6992 struct iw_request_info *info,
6993 union iwreq_data *wrqu, char *extra)
6994{
6995 int ret;
6996
6997 cds_ssr_protect(__func__);
6998 ret = __iw_setnone_getint(dev, info, wrqu, extra);
6999 cds_ssr_unprotect(__func__);
7000
7001 return ret;
7002}
7003
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307004static int hdd_set_fwtest(int argc, int cmd, int value)
7005{
7006 struct set_fwtest_params *fw_test;
7007
7008 /* check for max number of arguments */
7009 if (argc > (WMA_MAX_NUM_ARGS) ||
7010 argc != HDD_FWTEST_PARAMS) {
7011 hdd_err("Too Many args %d", argc);
7012 return -EINVAL;
7013 }
7014 /*
7015 * check if number of arguments are 3 then, check
7016 * then set the default value for sounding interval.
7017 */
7018 if (HDD_FWTEST_PARAMS == argc) {
7019 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7020 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7021 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7022 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7023 }
7024 /* check sounding interval value should not exceed to max */
7025 if (value > HDD_FWTEST_MAX_VALUE) {
7026 hdd_err("Invalid arguments value should not exceed max: %d",
7027 value);
7028 return -EINVAL;
7029 }
7030 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7031 if (NULL == fw_test) {
7032 hdd_err("qdf_mem_malloc failed for fw_test");
7033 return -ENOMEM;
7034 }
7035 fw_test->arg = cmd;
7036 fw_test->value = value;
7037 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7038 qdf_mem_free(fw_test);
7039 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7040 return -EINVAL;
7041 }
7042 return 0;
7043}
7044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007045/**
7046 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7047 * @dev: device upon which the ioctl was received
7048 * @info: ioctl request information
7049 * @wrqu: ioctl request data
7050 * @extra: ioctl extra data
7051 *
7052 * Return: 0 on success, non-zero on error
7053 */
7054static int __iw_set_three_ints_getnone(struct net_device *dev,
7055 struct iw_request_info *info,
7056 union iwreq_data *wrqu, char *extra)
7057{
7058 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7059 int *value = (int *)extra;
7060 int sub_cmd = value[0];
7061 int ret;
7062 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7063
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007064 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307065
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007066 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007067 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007068 return -EPERM;
7069 }
7070
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007071 ret = wlan_hdd_validate_context(hdd_ctx);
7072 if (0 != ret)
7073 return ret;
7074
7075 switch (sub_cmd) {
7076
7077 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307078 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007079 break;
7080 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307081 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007082 break;
7083
7084 /* value[3] the acs band is not required as start and end channels are
7085 * enough but this cmd is maintained under set three ints for historic
7086 * reasons.
7087 */
7088 case WE_SET_SAP_CHANNELS:
7089 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307090 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007091 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307092 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007093 ret = -EINVAL;
7094 } else {
7095 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7096 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7097 }
7098 break;
7099 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7100 hdd_debug("Ioctl to set dual mac scan config");
7101 if (hdd_ctx->config->dual_mac_feature_disable) {
7102 hdd_err("Dual mac feature is disabled from INI");
7103 return -EPERM;
7104 }
7105 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08007106 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007107 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307108 case WE_SET_FW_TEST:
7109 {
7110 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7111 if (ret) {
7112 hdd_err("Not able to set fwtest %d", ret);
7113 return ret;
7114 }
7115 }
7116 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007117 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007118 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007119 break;
7120
7121 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307122 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007123 return ret;
7124}
7125
7126int iw_set_three_ints_getnone(struct net_device *dev,
7127 struct iw_request_info *info,
7128 union iwreq_data *wrqu, char *extra)
7129{
7130 int ret;
7131
7132 cds_ssr_protect(__func__);
7133 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7134 cds_ssr_unprotect(__func__);
7135
7136 return ret;
7137}
7138
7139/**
7140 * hdd_connection_state_string() - Get connection state string
7141 * @connection_state: enum to be converted to a string
7142 *
7143 * Return: the string equivalent of @connection_state
7144 */
7145static const char *
7146hdd_connection_state_string(eConnectionState connection_state)
7147{
7148 switch (connection_state) {
7149 CASE_RETURN_STRING(eConnectionState_NotConnected);
7150 CASE_RETURN_STRING(eConnectionState_Connecting);
7151 CASE_RETURN_STRING(eConnectionState_Associated);
7152 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7153 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7154 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7155 default:
7156 return "UNKNOWN";
7157 }
7158}
7159
7160/**
7161 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7162 * @dev: device upon which the ioctl was received
7163 * @info: ioctl request information
7164 * @wrqu: ioctl request data
7165 * @extra: ioctl extra data
7166 *
7167 * Return: 0 on success, non-zero on error
7168 */
7169static int __iw_get_char_setnone(struct net_device *dev,
7170 struct iw_request_info *info,
7171 union iwreq_data *wrqu, char *extra)
7172{
7173 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7174 int sub_cmd = wrqu->data.flags;
7175 hdd_context_t *hdd_ctx;
7176 int ret;
7177#ifdef WLAN_FEATURE_11W
7178 hdd_wext_state_t *pWextState;
7179#endif
7180
7181#ifdef WLAN_FEATURE_11W
7182 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7183#endif
7184
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007185 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007187 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7188 ret = wlan_hdd_validate_context(hdd_ctx);
7189 if (0 != ret)
7190 return ret;
7191
7192 switch (sub_cmd) {
7193 case WE_WLAN_VERSION:
7194 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307195 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007196 break;
7197 }
7198
7199 case WE_GET_STATS:
7200 {
7201 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
7202 extra, WE_MAX_STR_LEN);
7203 break;
7204 }
7205
Govind Singha471e5e2015-10-12 17:11:14 +05307206 case WE_LIST_FW_PROFILE:
7207 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7208 extra, WE_MAX_STR_LEN);
7209 break;
7210
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007211 /* The case prints the current state of the HDD, SME, CSR, PE,
7212 * TL it can be extended for WDI Global State as well. And
7213 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7214 * and P2P_GO have not been added as of now.
7215 */
7216 case WE_GET_STATES:
7217 {
7218 int buf = 0, len = 0;
7219 int adapter_num = 0;
7220 int count = 0, check = 1;
7221
7222 tHalHandle hHal = NULL;
7223 tpAniSirGlobal pMac = NULL;
7224 hdd_station_ctx_t *pHddStaCtx = NULL;
7225
7226 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7227 hdd_adapter_t *useAdapter = NULL;
7228
7229 /* Print wlan0 or p2p0 states based on the adapter_num
7230 * by using the correct adapter
7231 */
7232 while (adapter_num < 2) {
7233 if (WLAN_ADAPTER == adapter_num) {
7234 useAdapter = pAdapter;
7235 buf =
7236 scnprintf(extra + len,
7237 WE_MAX_STR_LEN - len,
7238 "\n\n wlan0 States:-");
7239 len += buf;
7240 } else if (P2P_ADAPTER == adapter_num) {
7241 buf =
7242 scnprintf(extra + len,
7243 WE_MAX_STR_LEN - len,
7244 "\n\n p2p0 States:-");
7245 len += buf;
7246
7247 if (!pHddCtx) {
7248 buf =
7249 scnprintf(extra + len,
7250 WE_MAX_STR_LEN -
7251 len,
7252 "\n pHddCtx is NULL");
7253 len += buf;
7254 break;
7255 }
7256
7257 /* Printing p2p0 states only in the
7258 * case when the device is configured
7259 * as a p2p_client
7260 */
7261 useAdapter =
7262 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007263 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007264 if (!useAdapter) {
7265 buf =
7266 scnprintf(extra + len,
7267 WE_MAX_STR_LEN -
7268 len,
7269 "\n Device not configured as P2P_CLIENT.");
7270 len += buf;
7271 break;
7272 }
7273 }
7274
7275 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7276 if (!hHal) {
7277 buf =
7278 scnprintf(extra + len,
7279 WE_MAX_STR_LEN - len,
7280 "\n pMac is NULL");
7281 len += buf;
7282 break;
7283 }
7284 pMac = PMAC_STRUCT(hHal);
7285 if (!pMac) {
7286 buf =
7287 scnprintf(extra + len,
7288 WE_MAX_STR_LEN - len,
7289 "\n pMac is NULL");
7290 len += buf;
7291 break;
7292 }
7293 pHddStaCtx =
7294 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7295
7296
7297 buf =
7298 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7299 "\n HDD Conn State - %s "
7300 "\n \n SME State:"
7301 "\n Neighbour Roam State - %s"
7302 "\n CSR State - %s"
7303 "\n CSR Substate - %s",
7304 hdd_connection_state_string
7305 (pHddStaCtx->conn_info.connState),
7306 mac_trace_get_neighbour_roam_state
7307 (sme_get_neighbor_roam_state
7308 (hHal, useAdapter->sessionId)),
7309 mac_trace_getcsr_roam_state
7310 (sme_get_current_roam_state
7311 (hHal, useAdapter->sessionId)),
7312 mac_trace_getcsr_roam_sub_state
7313 (sme_get_current_roam_sub_state
7314 (hHal, useAdapter->sessionId))
7315 );
7316 len += buf;
7317 adapter_num++;
7318 }
7319
Mukul Sharma81661ae2015-10-30 20:26:02 +05307320 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007321 /* Printing Lim State starting with global lim states */
7322 buf =
7323 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7324 "\n \n LIM STATES:-"
7325 "\n Global Sme State - %s "
7326 "\n Global mlm State - %s " "\n",
7327 mac_trace_get_lim_sme_state
7328 (sme_get_lim_sme_state(hHal)),
7329 mac_trace_get_lim_mlm_state
7330 (sme_get_lim_sme_state(hHal))
7331 );
7332 len += buf;
7333
7334 /* Printing the PE Sme and Mlm states for valid lim sessions */
7335 while (check < 3 && count < 255) {
7336 if (sme_is_lim_session_valid(hHal, count)) {
7337 buf =
7338 scnprintf(extra + len,
7339 WE_MAX_STR_LEN -
7340 len,
7341 "\n Lim Valid Session %d:-"
7342 "\n PE Sme State - %s "
7343 "\n PE Mlm State - %s "
7344 "\n", check,
7345 mac_trace_get_lim_sme_state
7346 (sme_get_lim_sme_session_state
7347 (hHal, count)),
7348 mac_trace_get_lim_mlm_state
7349 (sme_get_lim_mlm_session_state
7350 (hHal, count))
7351 );
7352
7353 len += buf;
7354 check++;
7355 }
7356 count++;
7357 }
7358 }
7359
7360 wrqu->data.length = strlen(extra) + 1;
7361 break;
7362 }
7363
7364 case WE_GET_CFG:
7365 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007366 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007367 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
7368 extra,
7369 QCSAP_IOCTL_MAX_STR_LEN);
7370 wrqu->data.length = strlen(extra) + 1;
7371 break;
7372 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007373 case WE_GET_RSSI:
7374 {
7375 int8_t s7Rssi = 0;
7376 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7377 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7378 wrqu->data.length = strlen(extra) + 1;
7379 break;
7380 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007381
7382 case WE_GET_WMM_STATUS:
7383 {
7384 snprintf(extra, WE_MAX_STR_LEN,
7385 "\nDir: 0=up, 1=down, 3=both\n"
7386 "|------------------------|\n"
7387 "|AC | ACM |Admitted| Dir |\n"
7388 "|------------------------|\n"
7389 "|VO | %d | %3s | %d |\n"
7390 "|VI | %d | %3s | %d |\n"
7391 "|BE | %d | %3s | %d |\n"
7392 "|BK | %d | %3s | %d |\n"
7393 "|------------------------|\n",
7394 pAdapter->hddWmmStatus.
7395 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
7396 pAdapter->hddWmmStatus.
7397 wmmAcStatus[SME_AC_VO].
7398 wmmAcAccessAllowed ? "YES" : "NO",
7399 pAdapter->hddWmmStatus.
7400 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
7401 ts_info.direction,
7402 pAdapter->hddWmmStatus.
7403 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
7404 pAdapter->hddWmmStatus.
7405 wmmAcStatus[SME_AC_VI].
7406 wmmAcAccessAllowed ? "YES" : "NO",
7407 pAdapter->hddWmmStatus.
7408 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
7409 ts_info.direction,
7410 pAdapter->hddWmmStatus.
7411 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
7412 pAdapter->hddWmmStatus.
7413 wmmAcStatus[SME_AC_BE].
7414 wmmAcAccessAllowed ? "YES" : "NO",
7415 pAdapter->hddWmmStatus.
7416 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
7417 ts_info.direction,
7418 pAdapter->hddWmmStatus.
7419 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
7420 pAdapter->hddWmmStatus.
7421 wmmAcStatus[SME_AC_BK].
7422 wmmAcAccessAllowed ? "YES" : "NO",
7423 pAdapter->hddWmmStatus.
7424 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
7425 ts_info.direction);
7426
7427 wrqu->data.length = strlen(extra) + 1;
7428 break;
7429 }
7430 case WE_GET_CHANNEL_LIST:
7431 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307432 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007433 uint8_t i, len;
7434 char *buf;
7435 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
7436 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
7437 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7438
7439 tChannelListInfo channel_list;
7440
7441 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05307442 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007443 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307444 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007445 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007446 return -EINVAL;
7447 }
7448 buf = extra;
7449 /*
7450 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
7451 * Maximum buffer needed = 5 * number of channels.
7452 * Check ifsufficient buffer is available and then
7453 * proceed to fill the buffer.
7454 */
7455 if (WE_MAX_STR_LEN <
7456 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007457 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007458 return -EINVAL;
7459 }
7460 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7461 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307462 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007463 ubuf, &ubuf_len)) {
7464 /* Printing Country code in getChannelList */
7465 for (i = 0; i < (ubuf_len - 1); i++)
7466 len += scnprintf(buf + len,
7467 WE_MAX_STR_LEN - len,
7468 "%c", ubuf[i]);
7469 }
7470 for (i = 0; i < channel_list.num_channels; i++) {
7471 len +=
7472 scnprintf(buf + len, WE_MAX_STR_LEN - len,
7473 " %u", channel_list.channels[i]);
7474 }
7475 wrqu->data.length = strlen(extra) + 1;
7476
7477 break;
7478 }
7479#ifdef FEATURE_WLAN_TDLS
7480 case WE_GET_TDLS_PEERS:
7481 {
7482 wrqu->data.length =
7483 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
7484 WE_MAX_STR_LEN) + 1;
7485 break;
7486 }
7487#endif
7488#ifdef WLAN_FEATURE_11W
7489 case WE_GET_11W_INFO:
7490 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007491 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007492 pWextState->roamProfile.MFPEnabled);
7493
7494 snprintf(extra, WE_MAX_STR_LEN,
7495 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7496 "\n Number of Unprotected Disassocs %d"
7497 "\n Number of Unprotected Deauths %d",
7498 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
7499 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
7500 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
7501 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
7502 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
7503 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
7504 pWextState->roamProfile.MFPEnabled,
7505 pAdapter->hdd_stats.hddPmfStats.
7506 numUnprotDisassocRx,
7507 pAdapter->hdd_stats.hddPmfStats.
7508 numUnprotDeauthRx);
7509
7510 wrqu->data.length = strlen(extra) + 1;
7511 break;
7512 }
7513#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007514 case WE_GET_IBSS_STA_INFO:
7515 {
7516 hdd_station_ctx_t *pHddStaCtx =
7517 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7518 int idx = 0;
7519 int length = 0, buf = 0;
7520
Naveen Rawatc45d1622016-07-05 12:20:09 -07007521 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007522 if (0 != pHddStaCtx->conn_info.staId[idx]) {
7523 buf = snprintf
7524 ((extra + length),
7525 WE_MAX_STR_LEN - length,
7526 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7527 pHddStaCtx->conn_info.staId[idx],
7528 pHddStaCtx->conn_info.
7529 peerMacAddress[idx].bytes[0],
7530 pHddStaCtx->conn_info.
7531 peerMacAddress[idx].bytes[1],
7532 pHddStaCtx->conn_info.
7533 peerMacAddress[idx].bytes[2],
7534 pHddStaCtx->conn_info.
7535 peerMacAddress[idx].bytes[3],
7536 pHddStaCtx->conn_info.
7537 peerMacAddress[idx].bytes[4],
7538 pHddStaCtx->conn_info.
7539 peerMacAddress[idx].bytes[5]
7540 );
7541 length += buf;
7542 }
7543 }
7544 wrqu->data.length = strlen(extra) + 1;
7545 break;
7546 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007547 case WE_GET_PHYMODE:
7548 {
7549 bool ch_bond24 = false, ch_bond5g = false;
7550 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
7551 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7552 eCsrPhyMode phymode;
7553 eCsrBand currBand;
7554 tSmeConfigParams smeconfig;
7555
7556 sme_get_config_param(hal, &smeconfig);
7557 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7558 smeconfig.csrConfig.channelBondingMode24GHz)
7559 ch_bond24 = true;
7560
7561 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7562 smeconfig.csrConfig.channelBondingMode5GHz)
7563 ch_bond5g = true;
7564
7565 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307566 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007567 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007568 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007569 return -EIO;
7570 }
7571
7572 switch (phymode) {
7573 case eCSR_DOT11_MODE_AUTO:
7574 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
7575 break;
7576 case eCSR_DOT11_MODE_11n:
7577 case eCSR_DOT11_MODE_11n_ONLY:
7578 if (currBand == eCSR_BAND_24) {
7579 if (ch_bond24)
7580 snprintf(extra, WE_MAX_STR_LEN,
7581 "11NGHT40");
7582 else
7583 snprintf(extra, WE_MAX_STR_LEN,
7584 "11NGHT20");
7585 } else if (currBand == eCSR_BAND_5G) {
7586 if (ch_bond5g)
7587 snprintf(extra, WE_MAX_STR_LEN,
7588 "11NAHT40");
7589 else
7590 snprintf(extra, WE_MAX_STR_LEN,
7591 "11NAHT20");
7592 } else {
7593 snprintf(extra, WE_MAX_STR_LEN, "11N");
7594 }
7595 break;
7596 case eCSR_DOT11_MODE_abg:
7597 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
7598 break;
7599 case eCSR_DOT11_MODE_11a:
7600 snprintf(extra, WE_MAX_STR_LEN, "11A");
7601 break;
7602 case eCSR_DOT11_MODE_11b:
7603 case eCSR_DOT11_MODE_11b_ONLY:
7604 snprintf(extra, WE_MAX_STR_LEN, "11B");
7605 break;
7606 case eCSR_DOT11_MODE_11g:
7607 case eCSR_DOT11_MODE_11g_ONLY:
7608 snprintf(extra, WE_MAX_STR_LEN, "11G");
7609 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007610 case eCSR_DOT11_MODE_11ac:
7611 case eCSR_DOT11_MODE_11ac_ONLY:
7612 if (hddctx->config->vhtChannelWidth ==
7613 eHT_CHANNEL_WIDTH_20MHZ)
7614 snprintf(extra, WE_MAX_STR_LEN,
7615 "11ACVHT20");
7616 else if (hddctx->config->vhtChannelWidth ==
7617 eHT_CHANNEL_WIDTH_40MHZ)
7618 snprintf(extra, WE_MAX_STR_LEN,
7619 "11ACVHT40");
7620 else if (hddctx->config->vhtChannelWidth ==
7621 eHT_CHANNEL_WIDTH_80MHZ)
7622 snprintf(extra, WE_MAX_STR_LEN,
7623 "11ACVHT80");
7624 else if (hddctx->config->vhtChannelWidth ==
7625 eHT_CHANNEL_WIDTH_160MHZ)
7626 snprintf(extra, WE_MAX_STR_LEN,
7627 "11ACVHT160");
7628 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007629 }
7630
7631 wrqu->data.length = strlen(extra) + 1;
7632 break;
7633 }
7634
7635#ifdef FEATURE_OEM_DATA_SUPPORT
7636 case WE_GET_OEM_DATA_CAP:
7637 {
7638 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7639 }
7640#endif /* FEATURE_OEM_DATA_SUPPORT */
7641 case WE_GET_SNR:
7642 {
7643 int8_t s7snr = 0;
7644 int status = 0;
7645 hdd_context_t *pHddCtx;
7646 hdd_station_ctx_t *pHddStaCtx;
7647 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7648 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307649 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007650 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007652 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7653 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
7654 eConnectionState_Associated !=
7655 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007656 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007657 pHddCtx->config->fEnableSNRMonitoring,
7658 pHddStaCtx->conn_info.connState);
7659 return -ENONET;
7660 }
7661 wlan_hdd_get_snr(pAdapter, &s7snr);
7662 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
7663 wrqu->data.length = strlen(extra) + 1;
7664 break;
7665 }
7666 default:
7667 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007668 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007669 sub_cmd);
7670 break;
7671 }
7672 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307673 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007674 return 0;
7675}
7676
7677static int iw_get_char_setnone(struct net_device *dev,
7678 struct iw_request_info *info,
7679 union iwreq_data *wrqu, char *extra)
7680{
7681 int ret;
7682
7683 cds_ssr_protect(__func__);
7684 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7685 cds_ssr_unprotect(__func__);
7686
7687 return ret;
7688}
7689
7690/**
7691 * iw_setnone_getnone() - Generic "action" private ioctl handler
7692 * @dev: device upon which the ioctl was received
7693 * @info: ioctl request information
7694 * @wrqu: ioctl request data
7695 * @extra: ioctl extra data
7696 *
7697 * Return: 0 on success, non-zero on error
7698 */
7699static int __iw_setnone_getnone(struct net_device *dev,
7700 struct iw_request_info *info,
7701 union iwreq_data *wrqu, char *extra)
7702{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007703 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007704 hdd_context_t *hdd_ctx;
7705 int ret;
7706 int sub_cmd;
7707
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007708 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307709
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007710 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007711 ret = wlan_hdd_validate_context(hdd_ctx);
7712 if (0 != ret)
7713 return ret;
7714
7715#ifdef CONFIG_COMPAT
7716 /* this ioctl is a special case where a sub-ioctl is used and both
7717 * the number of get and set args is 0. in this specific case the
7718 * logic in iwpriv places the sub_cmd in the data.flags portion of
7719 * the iwreq. unfortunately the location of this field will be
7720 * different between 32-bit and 64-bit userspace, and the standard
7721 * compat support in the kernel does not handle this case. so we
7722 * need to explicitly handle it here.
7723 */
7724 if (is_compat_task()) {
7725 struct compat_iw_point *compat_iw_point =
7726 (struct compat_iw_point *)&wrqu->data;
7727 sub_cmd = compat_iw_point->flags;
7728 } else {
7729 sub_cmd = wrqu->data.flags;
7730 }
7731#else
7732 sub_cmd = wrqu->data.flags;
7733#endif
7734
7735 switch (sub_cmd) {
7736 case WE_GET_RECOVERY_STAT:
7737 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007738 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007739 sme_get_recovery_stats(hal);
7740 break;
7741 }
7742
Govind Singha471e5e2015-10-12 17:11:14 +05307743 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007744 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05307745 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
7746 0, DBG_CMD);
7747 break;
7748
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007749 case WE_IBSS_GET_PEER_INFO_ALL:
7750 {
7751 hdd_wlan_get_ibss_peer_info_all(adapter);
7752 break;
7753 }
7754
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007755 case WE_SET_REASSOC_TRIGGER:
7756 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007757 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7758 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307759 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007760 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307761 uint8_t operating_ch =
7762 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007763 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007764
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007765 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007766 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307767 if (roaming_offload_enabled(hdd_ctx)) {
7768 qdf_mem_copy(bssid,
7769 &adapter->sessionCtx.station.conn_info.bssId,
7770 sizeof(bssid));
7771 hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId,
7772 bssid, operating_ch);
7773 } else {
7774 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
7775 NULL, modProfileFields, &roamId, 1);
7776 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007777 return 0;
7778 }
7779
7780 case WE_DUMP_AGC_START:
7781 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007782 hdd_notice("WE_DUMP_AGC_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007783 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007784 GEN_PARAM_DUMP_AGC_START,
7785 0, GEN_CMD);
7786 break;
7787 }
7788 case WE_DUMP_AGC:
7789 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007790 hdd_notice("WE_DUMP_AGC");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007791 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007792 GEN_PARAM_DUMP_AGC,
7793 0, GEN_CMD);
7794 break;
7795 }
7796
7797 case WE_DUMP_CHANINFO_START:
7798 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007799 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007800 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007801 GEN_PARAM_DUMP_CHANINFO_START,
7802 0, GEN_CMD);
7803 break;
7804 }
7805 case WE_DUMP_CHANINFO:
7806 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007807 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007808 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007809 GEN_PARAM_DUMP_CHANINFO,
7810 0, GEN_CMD);
7811 break;
7812 }
7813 case WE_DUMP_WATCHDOG:
7814 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007815 hdd_notice("WE_DUMP_WATCHDOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007816 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007817 GEN_PARAM_DUMP_WATCHDOG,
7818 0, GEN_CMD);
7819 break;
7820 }
7821#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
7822 case WE_DUMP_PCIE_LOG:
7823 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007824 hdd_err("WE_DUMP_PCIE_LOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007825 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007826 GEN_PARAM_DUMP_PCIE_ACCESS_LOG,
7827 0, GEN_CMD);
7828 break;
7829 }
7830#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007831 case WE_STOP_OBSS_SCAN:
7832 {
7833 /*
7834 * 1.OBSS Scan is mandatory while operating in 2.4GHz
7835 * 2.OBSS scan is stopped by Firmware during the disassociation
7836 * 3.OBSS stop comamnd is added for debugging purpose
7837 */
7838 tHalHandle hal;
7839
7840 hal = WLAN_HDD_GET_HAL_CTX(adapter);
7841 if (hal == NULL) {
7842 hdd_err("hal context is NULL");
7843 return -EINVAL;
7844 }
7845 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
7846 }
7847 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007848 default:
7849 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007850 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007851 break;
7852 }
7853 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307854 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007855 return ret;
7856}
7857
7858static int iw_setnone_getnone(struct net_device *dev,
7859 struct iw_request_info *info,
7860 union iwreq_data *wrqu, char *extra)
7861{
7862 int ret;
7863
7864 cds_ssr_protect(__func__);
7865 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7866 cds_ssr_unprotect(__func__);
7867
7868 return ret;
7869}
7870
7871/**
7872 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
7873 * @dev: device upon which the ioctl was received
7874 * @info: ioctl request information
7875 * @wrqu: ioctl request data
7876 * @extra: ioctl extra data
7877 *
7878 * This is an SSR-protected generic handler for private ioctls which
7879 * take multiple arguments. Note that this implementation is also
7880 * somewhat unique in that it is shared by both STA-mode and SAP-mode
7881 * interfaces.
7882 *
7883 * Return: 0 on success, non-zero on error
7884 */
7885static int __iw_set_var_ints_getnone(struct net_device *dev,
7886 struct iw_request_info *info,
7887 union iwreq_data *wrqu, char *extra)
7888{
7889 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7890 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7891 int sub_cmd;
7892 int *apps_args = (int *) extra;
7893 hdd_context_t *hdd_ctx;
7894 int ret, num_args;
7895
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007896 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307897
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007898 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7899 ret = wlan_hdd_validate_context(hdd_ctx);
7900 if (0 != ret)
7901 return ret;
7902
7903 if (extra == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007904 hdd_err("NULL extra buffer pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007905 return -EINVAL;
7906 }
7907
7908 sub_cmd = wrqu->data.flags;
7909 num_args = wrqu->data.length;
7910
Jeff Johnson99bac312016-06-28 10:38:18 -07007911 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007912
7913 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007914 case WE_IBSS_GET_PEER_INFO:
7915 {
7916 pr_info("Station ID = %d\n", apps_args[0]);
7917 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7918 }
7919 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007920
7921 case WE_P2P_NOA_CMD:
7922 {
7923 p2p_app_setP2pPs_t p2pNoA;
7924
Krunal Sonif07bb382016-03-10 13:02:11 -08007925 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08007926 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
7927 hdd_device_mode_to_string(
7928 pAdapter->device_mode),
7929 pAdapter->device_mode);
7930 return -EINVAL;
7931 }
7932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007933 p2pNoA.opp_ps = apps_args[0];
7934 p2pNoA.ctWindow = apps_args[1];
7935 p2pNoA.duration = apps_args[2];
7936 p2pNoA.interval = apps_args[3];
7937 p2pNoA.count = apps_args[4];
7938 p2pNoA.single_noa_duration = apps_args[5];
7939 p2pNoA.psSelection = apps_args[6];
7940
Jeff Johnson99bac312016-06-28 10:38:18 -07007941 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
7942 apps_args[0], apps_args[1], apps_args[2],
7943 apps_args[3], apps_args[4],
7944 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007945
7946 hdd_set_p2p_ps(dev, &p2pNoA);
7947
7948 }
7949 break;
7950
7951 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7952 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007953 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7954 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307955 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956 }
7957 break;
7958
7959 case WE_MTRACE_DUMP_CMD:
7960 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007961 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
7962 apps_args[0], apps_args[1],
7963 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307964 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007965 apps_args[1], apps_args[2],
7966 apps_args[3]);
7967
7968 }
7969 break;
7970
7971 case WE_POLICY_MANAGER_CLIST_CMD:
7972 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007973 hdd_err("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007974 cds_incr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007975 apps_args[1], apps_args[2], apps_args[3],
7976 apps_args[4], apps_args[5], apps_args[6],
7977 apps_args[7]);
7978 }
7979 break;
7980
7981 case WE_POLICY_MANAGER_DLIST_CMD:
7982 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007983 hdd_err("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007984 cds_decr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007985 apps_args[1]);
7986 }
7987 break;
7988
7989 case WE_POLICY_MANAGER_ULIST_CMD:
7990 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007991 hdd_err("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007992 cds_update_connection_info_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007993 apps_args[1], apps_args[2], apps_args[3],
7994 apps_args[4], apps_args[5], apps_args[6],
7995 apps_args[7]);
7996 }
7997 break;
7998
7999 case WE_POLICY_MANAGER_DBS_CMD:
8000 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008001 hdd_err("<iwpriv wlan0 pm_dbs> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008002 if (apps_args[0] == 0)
8003 wma_set_dbs_capability_ut(0);
8004 else
8005 wma_set_dbs_capability_ut(1);
8006
8007 if (apps_args[1] >= CDS_THROUGHPUT &&
8008 apps_args[1] <= CDS_LATENCY) {
8009 pr_info("setting system pref to [%d]\n", apps_args[1]);
8010 hdd_ctx->config->conc_system_pref = apps_args[1];
8011 }
8012 }
8013 break;
8014
8015 case WE_POLICY_MANAGER_PCL_CMD:
8016 {
Manishekar Chandrasekaran1db3abe2016-06-24 03:27:07 +05308017 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8018 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008019 uint32_t pcl_len = 0, i = 0;
8020
Jeff Johnson99bac312016-06-28 10:38:18 -07008021 hdd_err("<iwpriv wlan0 pm_pcl> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008022
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008023 cds_get_pcl(apps_args[0],
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308024 pcl, &pcl_len,
8025 weight_list, QDF_ARRAY_SIZE(weight_list));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008026 pr_info("PCL list for role[%d] is {", apps_args[0]);
8027 for (i = 0 ; i < pcl_len; i++)
8028 pr_info(" %d, ", pcl[i]);
8029 pr_info("}--------->\n");
8030 }
8031 break;
8032
8033 case WE_POLICY_MANAGER_CINFO_CMD:
8034 {
8035 struct cds_conc_connection_info *conn_info;
8036 uint32_t i = 0, len = 0;
8037
Jeff Johnson99bac312016-06-28 10:38:18 -07008038 hdd_err("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008039 conn_info = cds_get_conn_info(&len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008040 pr_info("+-----------------------------+\n");
8041 for (i = 0; i < len; i++) {
8042 pr_info("|table_index[%d]\t\t|\n", i);
8043 pr_info("|\t|vdev_id - %d\t\t|\n", conn_info->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008044 pr_info("|\t|chan - %d\t\t|\n", conn_info->chan);
Tushnim Bhattacharyya7624a182016-03-30 13:30:46 -07008045 pr_info("|\t|bw - %d\t\t|\n", conn_info->bw);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008046 pr_info("|\t|mode - %d\t\t|\n", conn_info->mode);
8047 pr_info("|\t|mac - %d\t\t|\n", conn_info->mac);
8048 pr_info("|\t|in_use - %d\t\t|\n", conn_info->in_use);
8049 pr_info("+-----------------------------+\n");
8050 conn_info++;
8051 }
8052 }
8053 break;
8054
8055 case WE_POLICY_SET_HW_MODE_CMD:
8056 {
8057 if (apps_args[0] == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008058 hdd_err("set hw mode for single mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308059 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308060 pAdapter->sessionId,
8061 HW_MODE_SS_2x2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008062 HW_MODE_80_MHZ,
8063 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8064 HW_MODE_DBS_NONE,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308065 HW_MODE_AGILE_DFS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308066 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008067 } else if (apps_args[0] == 1) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008068 hdd_err("set hw mode for dual mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308069 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308070 pAdapter->sessionId,
8071 HW_MODE_SS_1x1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008072 HW_MODE_80_MHZ,
8073 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8074 HW_MODE_DBS,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308075 HW_MODE_AGILE_DFS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308076 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008077 }
8078 }
8079 break;
8080
8081 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8082 {
8083 enum cds_conc_next_action action;
Jeff Johnson99bac312016-06-28 10:38:18 -07008084 hdd_err("<iwpriv wlan0 pm_query_action> is called");
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308085 action = cds_current_connections_update(pAdapter->sessionId,
8086 apps_args[0],
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308087 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008088 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8089 }
8090 break;
8091 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8092 {
8093 bool allow;
Jeff Johnson99bac312016-06-28 10:38:18 -07008094 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008095 allow = cds_allow_concurrency(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008096 apps_args[0], apps_args[1], apps_args[2]);
8097 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8098 }
8099 break;
8100
8101 case WE_POLICY_MANAGER_SCENARIO_CMD:
8102 {
8103 clean_report(hdd_ctx);
8104 if (apps_args[0] == 1) {
8105 wlan_hdd_one_connection_scenario(hdd_ctx);
8106 } else if (apps_args[0] == 2) {
8107 wlan_hdd_two_connections_scenario(hdd_ctx,
8108 6, CDS_TWO_TWO);
8109 wlan_hdd_two_connections_scenario(hdd_ctx,
8110 36, CDS_TWO_TWO);
8111 wlan_hdd_two_connections_scenario(hdd_ctx,
8112 6, CDS_ONE_ONE);
8113 wlan_hdd_two_connections_scenario(hdd_ctx,
8114 36, CDS_ONE_ONE);
8115 } else if (apps_args[0] == 3) {
8116 /* MCC on same band with 2x2 same mac*/
8117 wlan_hdd_three_connections_scenario(hdd_ctx,
8118 6, 11, CDS_TWO_TWO, 0);
8119 /* MCC on diff band with 2x2 same mac*/
8120 wlan_hdd_three_connections_scenario(hdd_ctx,
8121 6, 36, CDS_TWO_TWO, 0);
8122 /* MCC on diff band with 1x1 diff mac */
8123 wlan_hdd_three_connections_scenario(hdd_ctx,
8124 36, 6, CDS_ONE_ONE, 0);
8125 /* MCC on diff band with 1x1 same mac */
8126 wlan_hdd_three_connections_scenario(hdd_ctx,
8127 36, 6, CDS_ONE_ONE, 1);
8128 /* SCC on same band with 2x2 same mac */
8129 wlan_hdd_three_connections_scenario(hdd_ctx,
8130 36, 36, CDS_TWO_TWO, 0);
8131 /* SCC on same band with 1x1 same mac */
8132 wlan_hdd_three_connections_scenario(hdd_ctx,
8133 36, 36, CDS_ONE_ONE, 1);
8134 /* MCC on same band with 2x2 same mac */
8135 wlan_hdd_three_connections_scenario(hdd_ctx,
8136 36, 149, CDS_TWO_TWO, 0);
8137 /* MCC on same band with 1x1 same mac */
8138 wlan_hdd_three_connections_scenario(hdd_ctx,
8139 36, 149, CDS_ONE_ONE, 1);
8140 }
8141 print_report(hdd_ctx);
8142 }
8143 break;
8144
8145#ifdef FEATURE_WLAN_TDLS
8146 case WE_TDLS_CONFIG_PARAMS:
8147 {
8148 tdls_config_params_t tdlsParams;
8149
8150 tdlsParams.tdls = apps_args[0];
8151 tdlsParams.tx_period_t = apps_args[1];
8152 tdlsParams.tx_packet_n = apps_args[2];
8153 /* ignore args[3] as discovery_period is not used anymore */
8154 tdlsParams.discovery_tries_n = apps_args[4];
8155 /* ignore args[5] as idle_timeout is not used anymore */
8156 tdlsParams.idle_packet_n = apps_args[6];
8157 /* ignore args[7] as rssi_hysteresis is not used anymore */
8158 tdlsParams.rssi_trigger_threshold = apps_args[8];
8159 tdlsParams.rssi_teardown_threshold = apps_args[9];
8160 tdlsParams.rssi_delta = apps_args[10];
8161
8162 wlan_hdd_tdls_set_params(dev, &tdlsParams);
8163 }
8164 break;
8165#endif
8166 case WE_UNIT_TEST_CMD:
8167 {
8168 t_wma_unit_test_cmd *unitTestArgs;
8169 cds_msg_t msg = { 0 };
8170 int i, j;
8171 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8172 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008173 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008174 apps_args[0]);
8175 return -EINVAL;
8176 }
Anurag Chouhan77564182016-09-03 16:38:01 +05308177 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
8178 (apps_args[1] < 0)) {
8179 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008180 apps_args[1]);
8181 return -EINVAL;
8182 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308183 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008184 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008185 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008186 return -ENOMEM;
8187 }
8188 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
8189 unitTestArgs->module_id = apps_args[0];
8190 unitTestArgs->num_args = apps_args[1];
8191 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
8192 unitTestArgs->args[i] = apps_args[j];
8193 }
8194 msg.type = SIR_HAL_UNIT_TEST_CMD;
8195 msg.reserved = 0;
8196 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308197 if (QDF_STATUS_SUCCESS !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05308198 cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308199 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -07008200 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008201 return -EINVAL;
8202 }
8203 }
8204 break;
8205#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8206 case WE_LED_FLASHING_PARAM:
8207 {
8208 int i;
8209 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008210 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008211 return -EINVAL;
8212 }
8213 for (i = 0; i < num_args; i++) {
8214 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008215 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008216 return -EINVAL;
8217 }
8218 }
8219 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8220 0, apps_args[0], apps_args[1]);
8221 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8222 1, apps_args[2], apps_args[3]);
8223 }
8224 break;
8225#endif
Manjeet Singhf82ed072016-07-08 11:40:00 +05308226 case WE_MAC_PWR_DEBUG_CMD:
8227 {
8228 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
8229 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8230 int i, j;
8231
8232 if (num_args < 3) {
8233 hdd_err("number of arguments can't be null %d",
8234 num_args);
8235 return -EINVAL;
8236 }
8237 if (num_args - 3 != apps_args[2]) {
8238 hdd_err("arg list of size %d doesn't match num_args %d",
8239 num_args-3, apps_args[2]);
8240 return -EINVAL;
8241 }
8242 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8243 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8244 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8245 return -EINVAL;
8246 }
8247 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8248 hdd_err("Too Many args %d", apps_args[2]);
8249 return -EINVAL;
8250 }
8251 mac_pwr_dbg_args.pdev_id = apps_args[0];
8252 mac_pwr_dbg_args.module_id = apps_args[1];
8253 mac_pwr_dbg_args.num_args = apps_args[2];
8254
8255 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8256 mac_pwr_dbg_args.args[i] = apps_args[j];
8257
8258 if (QDF_STATUS_SUCCESS !=
8259 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
8260 &mac_pwr_dbg_args)) {
8261 return -EINVAL;
8262 }
8263 }
8264 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008265 default:
8266 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008267 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008268 }
8269 break;
8270 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308271 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008272 return 0;
8273}
8274
8275/**
8276 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8277 * @dev: pointer to net_device structure
8278 * @info: pointer to iw_request_info structure
8279 * @wrqu: pointer to iwreq_data
8280 * @extra; extra
8281 *
8282 * Return: 0 on success, error number otherwise
8283 *
8284 */
8285static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8286 struct iw_request_info *info,
8287 union iwreq_data *wrqu, char *extra)
8288{
8289 union iwreq_data u_priv_wrqu;
8290 int apps_args[MAX_VAR_ARGS] = {0};
8291 int ret, num_args;
8292
Mukul Sharma64a70e82015-11-02 20:05:09 +05308293 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008294 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308295 return -EPERM;
8296 }
8297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008298 /* Helper function to get iwreq_data with compat handling. */
8299 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8300 return -EINVAL;
8301
8302 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008303 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008304 return -EINVAL;
8305 }
8306
8307 num_args = u_priv_wrqu.data.length;
8308 if (num_args > MAX_VAR_ARGS)
8309 num_args = MAX_VAR_ARGS;
8310
8311 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8312 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008313 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008314 return -EFAULT;
8315 }
8316
8317 cds_ssr_protect(__func__);
8318 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8319 (char *)&apps_args);
8320 cds_ssr_unprotect(__func__);
8321 return ret;
8322}
8323
8324/**
8325 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8326 * @dev: device upon which the ioctl was received
8327 * @info: ioctl request information
8328 * @wrqu: ioctl request data
8329 * @extra: ioctl extra data
8330 *
8331 * This is a generic handler for private ioctls which take multiple
8332 * arguments. Note that this implementation is also somewhat unique
8333 * in that it is shared by both STA-mode and SAP-mode interfaces.
8334 *
8335 * Return: 0 on success, non-zero on error
8336 */
8337int iw_set_var_ints_getnone(struct net_device *dev,
8338 struct iw_request_info *info,
8339 union iwreq_data *wrqu, char *extra)
8340{
8341 int ret;
8342
8343 cds_ssr_protect(__func__);
8344 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8345 cds_ssr_unprotect(__func__);
8346 return ret;
8347}
8348
8349/**
8350 * iw_add_tspec - Add TSpec private ioctl handler
8351 * @dev: device upon which the ioctl was received
8352 * @info: ioctl request information
8353 * @wrqu: ioctl request data
8354 * @extra: ioctl extra data
8355 *
8356 * Return: 0 on success, non-zero on error
8357 */
8358static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
8359 union iwreq_data *wrqu, char *extra)
8360{
8361 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8362 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8363 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8364 int params[HDD_WLAN_WMM_PARAM_COUNT];
8365 sme_QosWmmTspecInfo tSpec;
8366 uint32_t handle;
8367 struct iw_point s_priv_data;
8368 hdd_context_t *hdd_ctx;
8369 int ret;
8370
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008371 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308372
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008373 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8374 ret = wlan_hdd_validate_context(hdd_ctx);
8375 if (0 != ret)
8376 return ret;
8377
8378 /* make sure the application is sufficiently priviledged */
8379 /* note that the kernel will do this for "set" ioctls, but since */
8380 /* this ioctl wants to return status to user space it must be */
8381 /* defined as a "get" ioctl */
8382 if (!capable(CAP_NET_ADMIN)) {
8383 return -EPERM;
8384 }
8385
8386 /* we must be associated in order to add a tspec */
8387 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
8388 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8389 return 0;
8390 }
8391 /* since we are defined to be a "get" ioctl, and since the number */
8392 /* of params exceeds the number of params that wireless extensions */
8393 /* will pass down in the iwreq_data, we must copy the "set" params. */
8394 /* We must handle the compat for iwreq_data in 32U/64K environment. */
8395
8396 /* helper function to get iwreq_data with compat handling. */
8397 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8398 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8399 return 0;
8400 }
8401 /* make sure all params are correctly passed to function */
8402 if ((NULL == s_priv_data.pointer) ||
8403 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
8404 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8405 return 0;
8406 }
8407 /* from user space ourselves */
8408 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
8409 /* hmmm, can't get them */
8410 return -EIO;
8411 }
8412 /* clear the tspec */
8413 memset(&tSpec, 0, sizeof(tSpec));
8414
8415 /* validate the handle */
8416 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8417 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8418 /* that one is reserved */
8419 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8420 return 0;
8421 }
8422 /* validate the TID */
8423 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
8424 /* out of range */
8425 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8426 return 0;
8427 }
8428 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8429
8430 /* validate the direction */
8431 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
8432 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8433 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8434 break;
8435
8436 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8437 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8438 break;
8439
8440 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8441 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8442 break;
8443
8444 default:
8445 /* unknown */
8446 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8447 return 0;
8448 }
8449
8450 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8451
8452 /* validate the user priority */
8453 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
8454 /* out of range */
8455 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8456 return 0;
8457 }
8458 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
8459 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008460 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008461 return 0;
8462 }
8463
Jeff Johnson99bac312016-06-28 10:38:18 -07008464 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008465 tSpec.ts_info.psb, tSpec.ts_info.up);
8466
8467 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8468 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8469 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8470 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8471 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8472 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8473 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8474 tSpec.surplus_bw_allowance =
8475 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8476 tSpec.min_service_interval =
8477 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8478 tSpec.max_service_interval =
8479 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8480 tSpec.suspension_interval =
8481 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8482 tSpec.inactivity_interval =
8483 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8484
8485 tSpec.ts_info.burst_size_defn =
8486 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8487
8488 /* validate the ts info ack policy */
8489 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
8490 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8491 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8492 break;
8493
8494 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8495 tSpec.ts_info.ack_policy =
8496 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8497 break;
8498
8499 default:
8500 /* unknown */
8501 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8502 return 0;
8503 }
8504
8505 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308506 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008507 return 0;
8508}
8509
8510static int iw_add_tspec(struct net_device *dev,
8511 struct iw_request_info *info,
8512 union iwreq_data *wrqu, char *extra)
8513{
8514 int ret;
8515
8516 cds_ssr_protect(__func__);
8517 ret = __iw_add_tspec(dev, info, wrqu, extra);
8518 cds_ssr_unprotect(__func__);
8519
8520 return ret;
8521}
8522
8523/**
8524 * iw_del_tspec - Delete TSpec private ioctl handler
8525 * @dev: device upon which the ioctl was received
8526 * @info: ioctl request information
8527 * @wrqu: ioctl request data
8528 * @extra: ioctl extra data
8529 *
8530 * Return: 0 on success, non-zero on error
8531 */
8532static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
8533 union iwreq_data *wrqu, char *extra)
8534{
8535 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8536 hdd_context_t *hdd_ctx;
8537 int *params = (int *)extra;
8538 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8539 uint32_t handle;
8540 int ret;
8541
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008542 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308543
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008544 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8545 ret = wlan_hdd_validate_context(hdd_ctx);
8546 if (0 != ret)
8547 return ret;
8548
8549 /* make sure the application is sufficiently priviledged */
8550 /* note that the kernel will do this for "set" ioctls, but since */
8551 /* this ioctl wants to return status to user space it must be */
8552 /* defined as a "get" ioctl */
8553 if (!capable(CAP_NET_ADMIN)) {
8554 return -EPERM;
8555 }
8556
8557 /* although we are defined to be a "get" ioctl, the params we require */
8558 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8559 /* is no need to copy the params from user space */
8560
8561 /* validate the handle */
8562 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8563 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8564 /* that one is reserved */
8565 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8566 return 0;
8567 }
8568
8569 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308570 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008571 return 0;
8572}
8573
8574static int iw_del_tspec(struct net_device *dev,
8575 struct iw_request_info *info,
8576 union iwreq_data *wrqu, char *extra)
8577{
8578 int ret;
8579
8580 cds_ssr_protect(__func__);
8581 ret = __iw_del_tspec(dev, info, wrqu, extra);
8582 cds_ssr_unprotect(__func__);
8583
8584 return ret;
8585}
8586
8587/**
8588 * iw_get_tspec - Get TSpec private ioctl handler
8589 * @dev: device upon which the ioctl was received
8590 * @info: ioctl request information
8591 * @wrqu: ioctl request data
8592 * @extra: ioctl extra data
8593 *
8594 * Return: 0 on success, non-zero on error
8595 */
8596static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
8597 union iwreq_data *wrqu, char *extra)
8598{
8599 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8600 hdd_context_t *hdd_ctx;
8601 int *params = (int *)extra;
8602 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8603 uint32_t handle;
8604 int ret;
8605
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008606 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008608 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8609 ret = wlan_hdd_validate_context(hdd_ctx);
8610 if (0 != ret)
8611 return ret;
8612
8613 /* although we are defined to be a "get" ioctl, the params we require */
8614 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8615 /* is no need to copy the params from user space */
8616
8617 /* validate the handle */
8618 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8619 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8620 /* that one is reserved */
8621 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8622 return 0;
8623 }
8624
8625 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308626 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008627 return 0;
8628}
8629
8630static int iw_get_tspec(struct net_device *dev,
8631 struct iw_request_info *info,
8632 union iwreq_data *wrqu, char *extra)
8633{
8634 int ret;
8635
8636 cds_ssr_protect(__func__);
8637 ret = __iw_get_tspec(dev, info, wrqu, extra);
8638 cds_ssr_unprotect(__func__);
8639
8640 return ret;
8641}
8642
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008643/**
8644 * iw_set_fties - Set FT IEs private ioctl handler
8645 * @dev: device upon which the ioctl was received
8646 * @info: ioctl request information
8647 * @wrqu: ioctl request data
8648 * @extra: ioctl extra data
8649 *
8650 * Each time the supplicant has the auth_request or reassoc request
8651 * IEs ready they are pushed to the driver. The driver will in turn
8652 * use it to send out the auth req and reassoc req for 11r FT Assoc.
8653 *
8654 * Return: 0 on success, non-zero on error
8655 */
8656static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
8657 union iwreq_data *wrqu, char *extra)
8658{
8659 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8660 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8661 hdd_context_t *hdd_ctx;
8662 int ret;
8663
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008664 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308665
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008666 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8667 ret = wlan_hdd_validate_context(hdd_ctx);
8668 if (0 != ret)
8669 return ret;
8670
8671 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008672 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008673 return -EINVAL;
8674 }
8675 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008676 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008677 return -EINVAL;
8678 }
8679 /* Added for debug on reception of Re-assoc Req. */
8680 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008681 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008682 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -07008683 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008684 }
Jeff Johnson99bac312016-06-28 10:38:18 -07008685 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008686
8687 /* Pass the received FT IEs to SME */
8688 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8689 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308690 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008691 return 0;
8692}
8693
8694static int iw_set_fties(struct net_device *dev,
8695 struct iw_request_info *info,
8696 union iwreq_data *wrqu, char *extra)
8697{
8698 int ret;
8699
8700 cds_ssr_protect(__func__);
8701 ret = __iw_set_fties(dev, info, wrqu, extra);
8702 cds_ssr_unprotect(__func__);
8703
8704 return ret;
8705}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008706
8707/**
8708 * iw_set_host_offload - Set host offload ioctl handler
8709 * @dev: device upon which the ioctl was received
8710 * @info: ioctl request information
8711 * @wrqu: ioctl request data
8712 * @extra: ioctl extra data
8713 *
8714 * Return: 0 on success, non-zero on error
8715 */
8716static int __iw_set_host_offload(struct net_device *dev,
8717 struct iw_request_info *info,
8718 union iwreq_data *wrqu, char *extra)
8719{
8720 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8721 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
8722 tSirHostOffloadReq offloadRequest;
8723 hdd_context_t *hdd_ctx;
8724 int ret;
8725
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008726 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308727
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008728 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8729 ret = wlan_hdd_validate_context(hdd_ctx);
8730 if (0 != ret)
8731 return ret;
8732
8733 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008734 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008735 return -EINVAL;
8736 }
8737
8738 /* Debug display of request components. */
8739 switch (pRequest->offloadType) {
8740 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008741 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008742 switch (pRequest->enableOrDisable) {
8743 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008744 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008745 break;
8746 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008747 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008748 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008749 hdd_warn(" ARP offload enable");
8750 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008751 pRequest->params.hostIpv4Addr[0],
8752 pRequest->params.hostIpv4Addr[1],
8753 pRequest->params.hostIpv4Addr[2],
8754 pRequest->params.hostIpv4Addr[3]);
8755 }
8756 break;
8757
8758 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008759 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008760 switch (pRequest->enableOrDisable) {
8761 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008762 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008763 break;
8764 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008765 hdd_info(" enable");
8766 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008767 *(uint16_t *) (pRequest->params.hostIpv6Addr),
8768 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8769 2),
8770 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8771 4),
8772 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8773 6),
8774 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8775 8),
8776 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8777 10),
8778 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8779 12),
8780 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8781 14));
8782 }
8783 }
8784
8785 /* Execute offload request. The reason that we can copy the
8786 * request information from the ioctl structure to the SME
8787 * structure is that they are laid out exactly the same.
8788 * Otherwise, each piece of information would have to be
8789 * copied individually.
8790 */
8791 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308792 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008793 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8794 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008795 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008796 return -EINVAL;
8797 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308798 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008799 return 0;
8800}
8801
8802static int iw_set_host_offload(struct net_device *dev,
8803 struct iw_request_info *info,
8804 union iwreq_data *wrqu, char *extra)
8805{
8806 int ret;
8807
8808 cds_ssr_protect(__func__);
8809 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8810 cds_ssr_unprotect(__func__);
8811
8812 return ret;
8813}
8814
8815/**
8816 * iw_set_keepalive_params - Set keepalive params ioctl handler
8817 * @dev: device upon which the ioctl was received
8818 * @info: ioctl request information
8819 * @wrqu: ioctl request data
8820 * @extra: ioctl extra data
8821 *
8822 * Return: 0 on success, non-zero on error
8823 */
8824static int __iw_set_keepalive_params(struct net_device *dev,
8825 struct iw_request_info *info,
8826 union iwreq_data *wrqu, char *extra)
8827{
8828 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008829 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008830 hdd_context_t *hdd_ctx;
8831 int ret;
8832
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008833 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308834
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008835 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8836 ret = wlan_hdd_validate_context(hdd_ctx);
8837 if (0 != ret)
8838 return ret;
8839
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008840 if (wrqu->data.length != sizeof(*request)) {
8841 hdd_err("Invalid length %d", wrqu->data.length);
8842 return -EINVAL;
8843 }
8844
8845 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
8846 hdd_err("Value of timePeriod %d exceed Max limit %d",
8847 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008848 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
8849 return -EINVAL;
8850 }
8851
8852 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008853 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
8854 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008855
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008856 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008857 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008858 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008859 break;
8860
8861 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008862 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008863
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008864 hdd_info("Host IP address: %d.%d.%d.%d",
8865 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
8866 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008867
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008868 hdd_info("Dest IP address: %d.%d.%d.%d",
8869 request->destIpv4Addr[0], request->destIpv4Addr[1],
8870 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008871
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08008872 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
8873 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008874 break;
8875 }
8876
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008877 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008878
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308879 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008880 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008881 pAdapter->sessionId, request)) {
8882 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008883 return -EINVAL;
8884 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308885 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008886 return 0;
8887}
8888
8889static int iw_set_keepalive_params(struct net_device *dev,
8890 struct iw_request_info *info,
8891 union iwreq_data *wrqu,
8892 char *extra)
8893{
8894 int ret;
8895
8896 cds_ssr_protect(__func__);
8897 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8898 cds_ssr_unprotect(__func__);
8899
8900 return ret;
8901}
8902
8903#ifdef WLAN_FEATURE_PACKET_FILTERING
8904/**
8905 * wlan_hdd_set_filter() - Set packet filter
8906 * @hdd_ctx: Global HDD context
8907 * @request: Packet filter request struct
8908 * @sessionId: Target session for the request
8909 *
8910 * Return: 0 on success, non-zero on error
8911 */
8912static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
8913 struct pkt_filter_cfg *request,
8914 uint8_t sessionId)
8915{
8916 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8917 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8918 int i = 0;
8919
8920 if (hdd_ctx->config->disablePacketFilter) {
8921 hdd_err("packet filtering disabled in ini returning");
8922 return 0;
8923 }
8924
8925 /* Debug display of request components. */
8926 hdd_info("Packet Filter Request : FA %d params %d",
8927 request->filter_action, request->num_params);
8928
8929 switch (request->filter_action) {
8930 case HDD_RCV_FILTER_SET:
8931 hdd_info("Set Packet Filter Request for Id: %d",
8932 request->filter_id);
8933
8934 packetFilterSetReq.filterId = request->filter_id;
8935 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
8936 hdd_err("Number of Params exceed Max limit %d",
8937 request->num_params);
8938 return -EINVAL;
8939 }
8940 packetFilterSetReq.numFieldParams = request->num_params;
8941 packetFilterSetReq.coalesceTime = 0;
8942 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8943 for (i = 0; i < request->num_params; i++) {
8944 packetFilterSetReq.paramsData[i].protocolLayer =
8945 request->params_data[i].protocol_layer;
8946 packetFilterSetReq.paramsData[i].cmpFlag =
8947 request->params_data[i].compare_flag;
8948 packetFilterSetReq.paramsData[i].dataOffset =
8949 request->params_data[i].data_offset;
8950 packetFilterSetReq.paramsData[i].dataLength =
8951 request->params_data[i].data_length;
8952 packetFilterSetReq.paramsData[i].reserved = 0;
8953
8954 if (request->params_data[i].data_length >
8955 SIR_MAX_FILTER_TEST_DATA_LEN) {
8956 hdd_err("Error invalid data length %d",
8957 request->params_data[i].data_length);
8958 return -EINVAL;
8959 }
8960
8961 hdd_info("Proto %d Comp Flag %d Filter Type %d",
8962 request->params_data[i].protocol_layer,
8963 request->params_data[i].compare_flag,
8964 packetFilterSetReq.filterType);
8965
8966 hdd_info("Data Offset %d Data Len %d",
8967 request->params_data[i].data_offset,
8968 request->params_data[i].data_length);
8969
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07008970 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
8971 < (request->params_data[i].data_length)) {
8972 hdd_err("Error invalid data length %d",
8973 request->params_data[i].data_length);
8974 return -EINVAL;
8975 }
8976
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008977 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8978 request->params_data[i].compare_data,
8979 request->params_data[i].data_length);
8980 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8981 request->params_data[i].data_mask,
8982 request->params_data[i].data_length);
8983
8984 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
8985 request->params_data[i].compare_data[0],
8986 request->params_data[i].compare_data[1],
8987 request->params_data[i].compare_data[2],
8988 request->params_data[i].compare_data[3],
8989 request->params_data[i].compare_data[4],
8990 request->params_data[i].compare_data[5]);
8991
8992 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
8993 request->params_data[i].data_mask[0],
8994 request->params_data[i].data_mask[1],
8995 request->params_data[i].data_mask[2],
8996 request->params_data[i].data_mask[3],
8997 request->params_data[i].data_mask[4],
8998 request->params_data[i].data_mask[5]);
8999 }
9000
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309001 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009002 sme_receive_filter_set_filter(hdd_ctx->hHal,
9003 &packetFilterSetReq,
9004 sessionId)) {
9005 hdd_err("Failure to execute Set Filter");
9006 return -EINVAL;
9007 }
9008
9009 break;
9010
9011 case HDD_RCV_FILTER_CLEAR:
9012
9013 hdd_info("Clear Packet Filter Request for Id: %d",
9014 request->filter_id);
9015 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309016 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009017 sme_receive_filter_clear_filter(hdd_ctx->hHal,
9018 &packetFilterClrReq,
9019 sessionId)) {
9020 hdd_err("Failure to execute Clear Filter");
9021 return -EINVAL;
9022 }
9023 break;
9024
9025 default:
9026 hdd_err("Packet Filter Request: Invalid %d",
9027 request->filter_action);
9028 return -EINVAL;
9029 }
9030 return 0;
9031}
9032
9033/**
9034 * __iw_set_packet_filter_params() - set packet filter parameters in target
9035 * @dev: Pointer to netdev
9036 * @info: Pointer to iw request info
9037 * @wrqu: Pointer to data
9038 * @extra: Pointer to extra data
9039 *
9040 * Return: 0 on success, non-zero on error
9041 */
9042static int __iw_set_packet_filter_params(struct net_device *dev,
9043 struct iw_request_info *info,
9044 union iwreq_data *wrqu, char *extra)
9045{
9046 int ret;
9047 hdd_context_t *hdd_ctx;
9048 struct iw_point priv_data;
9049 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9050 struct pkt_filter_cfg *request = NULL;
9051
Mukul Sharma472382f2015-11-02 20:16:31 +05309052 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009053 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309054 return -EPERM;
9055 }
9056
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009057 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009059 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9060 ret = wlan_hdd_validate_context(hdd_ctx);
9061 if (0 != ret)
9062 return ret;
9063
9064 if (hdd_priv_get_data(&priv_data, wrqu)) {
9065 hdd_err("failed to get priv data");
9066 return -EINVAL;
9067 }
9068
9069 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
9070 hdd_err("invalid priv data %p or invalid priv data length %d",
9071 priv_data.pointer, priv_data.length);
9072 return -EINVAL;
9073 }
9074
9075 /* copy data using copy_from_user */
9076 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9077 priv_data.length);
9078 if (NULL == request) {
9079 hdd_err("mem_alloc_copy_from_user_helper fail");
9080 return -ENOMEM;
9081 }
9082
9083 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
9084
9085 kfree(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309086 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009087 return ret;
9088}
9089
9090/**
9091 * iw_set_packet_filter_params() - set packet filter parameters in target
9092 * @dev: Pointer to netdev
9093 * @info: Pointer to iw request info
9094 * @wrqu: Pointer to data
9095 * @extra: Pointer to extra data
9096 *
9097 * Return: 0 on success, non-zero on error
9098 */
9099static int iw_set_packet_filter_params(struct net_device *dev,
9100 struct iw_request_info *info,
9101 union iwreq_data *wrqu, char *extra)
9102{
9103 int ret;
9104
9105 cds_ssr_protect(__func__);
9106 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9107 cds_ssr_unprotect(__func__);
9108
9109 return ret;
9110}
9111#endif
9112
9113
9114static int __iw_get_statistics(struct net_device *dev,
9115 struct iw_request_info *info,
9116 union iwreq_data *wrqu, char *extra)
9117{
9118
Anurag Chouhance0dc992016-02-16 18:18:03 +05309119 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309120 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009121 hdd_wext_state_t *pWextState;
9122 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9123 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9124 char *p = extra;
9125 int tlen = 0;
9126 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
9127 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
9128 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
9129 int ret;
9130
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009131 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009132
9133 ret = wlan_hdd_validate_context(hdd_ctx);
9134 if (0 != ret)
9135 return ret;
9136
9137 if (eConnectionState_Associated !=
9138 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9139
9140 wrqu->txpower.value = 0;
9141 } else {
9142 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9143 SME_SUMMARY_STATS |
9144 SME_GLOBAL_CLASSA_STATS |
9145 SME_GLOBAL_CLASSB_STATS |
9146 SME_GLOBAL_CLASSC_STATS |
9147 SME_GLOBAL_CLASSD_STATS |
9148 SME_PER_STA_STATS,
9149 hdd_statistics_cb, 0, false,
9150 (WLAN_HDD_GET_STATION_CTX_PTR
9151 (pAdapter))->conn_info.staId[0],
9152 pAdapter, pAdapter->sessionId);
9153
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309154 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009155 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009156 return -EINVAL;
9157 }
9158
9159 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9160
Anurag Chouhance0dc992016-02-16 18:18:03 +05309161 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05309162 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009163 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +05309164 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009165 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009166 /*Remove the SME statistics list by passing NULL in callback argument */
9167 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9168 SME_SUMMARY_STATS |
9169 SME_GLOBAL_CLASSA_STATS |
9170 SME_GLOBAL_CLASSB_STATS |
9171 SME_GLOBAL_CLASSC_STATS |
9172 SME_GLOBAL_CLASSD_STATS |
9173 SME_PER_STA_STATS,
9174 NULL, 0, false,
9175 (WLAN_HDD_GET_STATION_CTX_PTR
9176 (pAdapter))->conn_info.
9177 staId[0], pAdapter,
9178 pAdapter->sessionId);
9179
9180 return -EINVAL;
9181 }
9182 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
9183 (uint8_t) sizeof(pStats->retry_cnt),
9184 (char *)&(pStats->retry_cnt[0]), tlen);
9185
9186 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
9187 (uint8_t) sizeof(pStats->multiple_retry_cnt),
9188 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
9189
9190 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
9191 (uint8_t) sizeof(pStats->tx_frm_cnt),
9192 (char *)&(pStats->tx_frm_cnt[0]), tlen);
9193
9194 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
9195 (uint8_t) sizeof(pStats->rx_frm_cnt),
9196 (char *)&(pStats->rx_frm_cnt), tlen);
9197
9198 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
9199 (uint8_t) sizeof(pStats->frm_dup_cnt),
9200 (char *)&(pStats->frm_dup_cnt), tlen);
9201
9202 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
9203 (uint8_t) sizeof(pStats->fail_cnt),
9204 (char *)&(pStats->fail_cnt[0]), tlen);
9205
9206 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
9207 (uint8_t) sizeof(pStats->rts_fail_cnt),
9208 (char *)&(pStats->rts_fail_cnt), tlen);
9209
9210 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
9211 (uint8_t) sizeof(pStats->ack_fail_cnt),
9212 (char *)&(pStats->ack_fail_cnt), tlen);
9213
9214 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
9215 (uint8_t) sizeof(pStats->rts_succ_cnt),
9216 (char *)&(pStats->rts_succ_cnt), tlen);
9217
9218 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
9219 (uint8_t) sizeof(pStats->rx_discard_cnt),
9220 (char *)&(pStats->rx_discard_cnt), tlen);
9221
9222 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
9223 (uint8_t) sizeof(pStats->rx_error_cnt),
9224 (char *)&(pStats->rx_error_cnt), tlen);
9225
9226 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
9227 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9228 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9229
9230 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
9231 (uint8_t) sizeof(dStats->rx_byte_cnt),
9232 (char *)&(dStats->rx_byte_cnt), tlen);
9233
9234 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
9235 (uint8_t) sizeof(dStats->rx_rate),
9236 (char *)&(dStats->rx_rate), tlen);
9237
9238 /* Transmit rate, in units of 500 kbit/sec */
9239 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
9240 (uint8_t) sizeof(aStats->tx_rate),
9241 (char *)&(aStats->tx_rate), tlen);
9242
9243 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
9244 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
9245 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
9246 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
9247 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
9248 (char *)&(dStats->rx_mc_byte_cnt), tlen);
9249 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
9250 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
9251 (char *)&(dStats->rx_bc_byte_cnt), tlen);
9252 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
9253 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9254 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9255 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
9256 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
9257 (char *)&(dStats->tx_mc_byte_cnt), tlen);
9258 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
9259 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
9260 (char *)&(dStats->tx_bc_byte_cnt), tlen);
9261
9262 wrqu->data.length = tlen;
9263
9264 }
9265
9266 EXIT();
9267
9268 return 0;
9269}
9270
9271static int iw_get_statistics(struct net_device *dev,
9272 struct iw_request_info *info,
9273 union iwreq_data *wrqu, char *extra)
9274{
9275 int ret;
9276
9277 cds_ssr_protect(__func__);
9278 ret = __iw_get_statistics(dev, info, wrqu, extra);
9279 cds_ssr_unprotect(__func__);
9280
9281 return ret;
9282}
9283
9284#ifdef FEATURE_WLAN_SCAN_PNO
9285
9286/*Max Len for PNO notification*/
9287#define MAX_PNO_NOTIFY_LEN 100
9288void found_pref_network_cb(void *callbackContext,
9289 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9290{
9291 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
9292 union iwreq_data wrqu;
9293 char buf[MAX_PNO_NOTIFY_LEN + 1];
9294
Jeff Johnson99bac312016-06-28 10:38:18 -07009295 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009296 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9297
9298 /* create the event */
9299 memset(&wrqu, 0, sizeof(wrqu));
9300 memset(buf, 0, sizeof(buf));
9301
9302 snprintf(buf, MAX_PNO_NOTIFY_LEN,
9303 "QCOM: Found preferred network: %s with RSSI of -%u",
9304 pPrefNetworkFoundInd->ssId.ssId,
9305 (unsigned int)pPrefNetworkFoundInd->rssi);
9306
9307 wrqu.data.pointer = buf;
9308 wrqu.data.length = strlen(buf);
9309
9310 /* send the event */
9311
9312 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9313
9314}
9315
9316/**
9317 * __iw_set_pno() - Preferred Network Offload ioctl handler
9318 * @dev: device upon which the ioctl was received
9319 * @info: ioctl request information
9320 * @wrqu: ioctl request data
9321 * @extra: ioctl extra data
9322 *
9323 * This function parses a Preferred Network Offload command
9324 * Input is string based and expected to be of the form:
9325 *
9326 * <enable(1) | disable(0)>
9327 * when enabling:
9328 * <number of networks>
9329 * for each network:
9330 * <ssid_len> <ssid> <authentication> <encryption>
9331 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
9332 * <number of scan timers>
9333 * for each timer:
9334 * <scan_time> <scan_repeat>
9335 * <suspend mode>
9336 *
9337 * e.g:
9338 * 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 2 5 2 300 0 1
9339 *
9340 * this translates into:
9341 * -----------------------------
9342 * enable PNO
9343 * 2 networks
9344 * Network 1:
9345 * test - with authentication type 0 and encryption type 0,
9346 * search on 3 channels: 1 6 and 11,
9347 * SSID bcast type is unknown (directed probe will be sent if
9348 * AP not found) and must meet -40dBm RSSI
9349 * Network 2:
9350 * test2 - with authentication type 4 and encryption type 4,
9351 * search on 6 channels 1, 2, 3, 4, 5 and 6
9352 * bcast type is non-bcast (directed probe will be sent)
9353 * and must not meet any RSSI threshold
9354 * 2 scan timers:
9355 * scan every 5 seconds 2 times
9356 * then scan every 300 seconds until stopped
9357 * enable on suspend
9358 */
9359static int __iw_set_pno(struct net_device *dev,
9360 struct iw_request_info *info,
9361 union iwreq_data *wrqu, char *extra)
9362{
9363 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9364 hdd_context_t *hdd_ctx;
9365 int ret;
9366 int offset;
9367 char *ptr;
9368 uint8_t i, j, params, mode;
9369
9370 /* request is a large struct, so we make it static to avoid
9371 * stack overflow. This API is only invoked via ioctl, so it
9372 * is serialized by the kernel rtnl_lock and hence does not
9373 * need to be reentrant
9374 */
9375 static tSirPNOScanReq request;
9376
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009377 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009378
9379 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9380 ret = wlan_hdd_validate_context(hdd_ctx);
9381 if (ret)
9382 return ret;
9383
9384 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
9385
9386 request.enable = 0;
9387 request.ucNetworksCount = 0;
9388
9389 ptr = extra;
9390
9391 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
9392 hdd_err("PNO enable input is not valid %s", ptr);
9393 return -EINVAL;
9394 }
9395
9396 if (0 == request.enable) {
9397 /* Disable PNO, ignore any other params */
9398 memset(&request, 0, sizeof(request));
9399 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9400 &request, adapter->sessionId,
9401 found_pref_network_cb, adapter);
9402 return 0;
9403 }
9404
9405 ptr += offset;
9406
9407 if (1 !=
9408 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
9409 hdd_err("PNO count input not valid %s", ptr);
9410 return -EINVAL;
9411
9412 }
9413
9414 hdd_info("PNO enable %d networks count %d offset %d",
9415 request.enable, request.ucNetworksCount, offset);
9416
9417 if ((0 == request.ucNetworksCount) ||
9418 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
9419 hdd_err("Network count %d invalid",
9420 request.ucNetworksCount);
9421 return -EINVAL;
9422 }
9423
9424 ptr += offset;
9425
9426 for (i = 0; i < request.ucNetworksCount; i++) {
9427
9428 request.aNetworks[i].ssId.length = 0;
9429
9430 params = sscanf(ptr, "%hhu %n",
9431 &(request.aNetworks[i].ssId.length),
9432 &offset);
9433
9434 if (1 != params) {
9435 hdd_err("PNO ssid length input is not valid %s", ptr);
9436 return -EINVAL;
9437 }
9438
9439 if ((0 == request.aNetworks[i].ssId.length) ||
9440 (request.aNetworks[i].ssId.length > 32)) {
9441 hdd_err("SSID Len %d is not correct for network %d",
9442 request.aNetworks[i].ssId.length, i);
9443 return -EINVAL;
9444 }
9445
9446 /* Advance to SSID */
9447 ptr += offset;
9448
9449 memcpy(request.aNetworks[i].ssId.ssId, ptr,
9450 request.aNetworks[i].ssId.length);
9451 ptr += request.aNetworks[i].ssId.length;
9452
9453 params = sscanf(ptr, "%u %u %hhu %n",
9454 &(request.aNetworks[i].authentication),
9455 &(request.aNetworks[i].encryption),
9456 &(request.aNetworks[i].ucChannelCount),
9457 &offset);
9458
9459 if (3 != params) {
9460 hdd_warn("Incorrect cmd %s", ptr);
9461 return -EINVAL;
9462 }
9463
9464 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
9465 request.aNetworks[i].ssId.length,
9466 request.aNetworks[i].ssId.length,
9467 request.aNetworks[i].ssId.ssId,
9468 request.aNetworks[i].authentication,
9469 request.aNetworks[i].encryption,
9470 request.aNetworks[i].ucChannelCount, offset);
9471
9472 /* Advance to channel list */
9473 ptr += offset;
9474
9475 if (SIR_PNO_MAX_NETW_CHANNELS <
9476 request.aNetworks[i].ucChannelCount) {
9477 hdd_warn("Incorrect number of channels");
9478 return -EINVAL;
9479 }
9480
9481 if (0 != request.aNetworks[i].ucChannelCount) {
9482 for (j = 0; j < request.aNetworks[i].ucChannelCount;
9483 j++) {
9484 if (1 !=
9485 sscanf(ptr, "%hhu %n",
9486 &(request.aNetworks[i].
9487 aChannels[j]), &offset)) {
9488 hdd_err("PNO network channel input is not valid %s",
9489 ptr);
9490 return -EINVAL;
9491 }
9492 /* Advance to next channel number */
9493 ptr += offset;
9494 }
9495 }
9496
9497 if (1 != sscanf(ptr, "%u %n",
9498 &(request.aNetworks[i].bcastNetwType),
9499 &offset)) {
9500 hdd_err("PNO broadcast network type input is not valid %s",
9501 ptr);
9502 return -EINVAL;
9503 }
9504
9505 hdd_notice("PNO bcastNetwType %d offset %d",
9506 request.aNetworks[i].bcastNetwType, offset);
9507
9508 /* Advance to rssi Threshold */
9509 ptr += offset;
9510 if (1 != sscanf(ptr, "%d %n",
9511 &(request.aNetworks[i].rssiThreshold),
9512 &offset)) {
9513 hdd_err("PNO rssi threshold input is not valid %s",
9514 ptr);
9515 return -EINVAL;
9516 }
9517 hdd_notice("PNO rssi %d offset %d",
9518 request.aNetworks[i].rssiThreshold, offset);
9519 /* Advance to next network */
9520 ptr += offset;
9521 } /* For ucNetworkCount */
9522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009523 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
9524
9525 request.modePNO = mode;
9526 /* for LA we just expose suspend option */
9527 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
9528 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9529 }
9530
9531 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9532 &request,
9533 adapter->sessionId,
9534 found_pref_network_cb, adapter);
9535
9536 return 0;
9537}
9538
9539static int iw_set_pno(struct net_device *dev,
9540 struct iw_request_info *info,
9541 union iwreq_data *wrqu, char *extra)
9542{
9543 int ret;
9544
9545 cds_ssr_protect(__func__);
9546 ret = __iw_set_pno(dev, info, wrqu, extra);
9547 cds_ssr_unprotect(__func__);
9548
9549 return ret;
9550}
9551#endif /* FEATURE_WLAN_SCAN_PNO */
9552
9553/* Common function to SetBand */
9554int hdd_set_band(struct net_device *dev, u8 ui_band)
9555{
9556 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9557 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9558 eCsrBand band;
9559
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309560 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009561 hdd_context_t *pHddCtx;
9562 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9563 eCsrBand currBand = eCSR_BAND_MAX;
9564 eCsrBand connectedBand;
9565
9566 pAdapterNode = NULL;
9567 pNext = NULL;
9568 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9569
9570 switch (ui_band) {
9571 case WLAN_HDD_UI_BAND_AUTO:
9572 band = eCSR_BAND_ALL;
9573 break;
9574 case WLAN_HDD_UI_BAND_5_GHZ:
9575 band = eCSR_BAND_5G;
9576 break;
9577 case WLAN_HDD_UI_BAND_2_4_GHZ:
9578 band = eCSR_BAND_24;
9579 break;
9580 default:
9581 band = eCSR_BAND_MAX;
9582 }
9583
Jeff Johnson99bac312016-06-28 10:38:18 -07009584 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009585
9586 if (band == eCSR_BAND_MAX) {
9587 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -07009588 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009589 return -EINVAL;
9590 }
9591
9592 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
9593 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009594 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009595 band, pHddCtx->config->nBandCapability);
9596 return -EIO;
9597 }
9598
9599 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009600 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009601 pHddCtx->config->nBandCapability);
9602 band = pHddCtx->config->nBandCapability;
9603 }
9604
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309605 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009606 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009607 return -EIO;
9608 }
9609
9610 if (currBand != band) {
9611 /* Change band request received.
9612 * Abort pending scan requests, flush the existing scan results,
9613 * and change the band capability
9614 */
Jeff Johnson99bac312016-06-28 10:38:18 -07009615 hdd_notice("Current band value = %u, new setting %u ",
9616 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009617
9618 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309619 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009620 pAdapter = pAdapterNode->pAdapter;
9621 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9622 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
9623 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9624 connectedBand =
9625 hdd_conn_get_connected_band
9626 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
9627
9628 /* Handling is done only for STA and P2P */
9629 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -08009630 ((pAdapter->device_mode == QDF_STA_MODE)
9631 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009632 &&
9633 (hdd_conn_is_connected
9634 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
9635 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309636 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009637 long lrc;
9638
9639 /* STA already connected on current band, So issue disconnect
9640 * first, then change the band*/
9641
Jeff Johnson99bac312016-06-28 10:38:18 -07009642 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009643 hdd_device_mode_to_string(pAdapter->device_mode),
9644 pAdapter->device_mode, currBand, band);
9645 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9646
9647 status =
9648 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
9649 (pAdapter),
9650 pAdapter->sessionId,
9651 eCSR_DISCONNECT_REASON_UNSPECIFIED);
9652
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309653 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009654 hdd_err("csr_roam_disconnect failure, returned %d",
9655 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009656 return -EINVAL;
9657 }
9658
9659 lrc =
9660 wait_for_completion_timeout(&pAdapter->
9661 disconnect_comp_var,
9662 msecs_to_jiffies
9663 (WLAN_WAIT_TIME_DISCONNECT));
9664
9665 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009666 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009667 return -ETIMEDOUT;
9668 }
9669 }
9670
9671 sme_scan_flush_result(hHal);
9672
9673 status =
9674 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
9675 pAdapterNode = pNext;
9676 }
9677
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309678 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009679 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009680 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009681 band);
9682 return -EINVAL;
9683 }
9684 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
9685 }
9686 return 0;
9687}
9688
9689int hdd_set_band_helper(struct net_device *dev, const char *command)
9690{
9691 uint8_t band;
9692 int ret;
9693
9694 /* Convert the band value from ascii to integer */
9695 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
9696 ret = kstrtou8(command, 10, &band);
9697 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009698 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009699 return -EINVAL;
9700 }
9701
9702 return hdd_set_band(dev, band);
9703}
9704
9705static int __iw_set_band_config(struct net_device *dev,
9706 struct iw_request_info *info,
9707 union iwreq_data *wrqu, char *extra)
9708{
9709 int *value = (int *)extra;
9710
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009711 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009712
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309713 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009714 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309715 return -EPERM;
9716 }
9717
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009718 return hdd_set_band(dev, value[0]);
9719}
9720
9721static int iw_set_band_config(struct net_device *dev,
9722 struct iw_request_info *info,
9723 union iwreq_data *wrqu, char *extra)
9724{
9725 int ret;
9726
9727 cds_ssr_protect(__func__);
9728 ret = __iw_set_band_config(dev, info, wrqu, extra);
9729 cds_ssr_unprotect(__func__);
9730
9731 return ret;
9732}
9733
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009734/**
9735 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
9736 * @adapter: Handle to adapter
9737 * @chan: Monitor mode channel
9738 * @bandwidth: Capture channel bandwidth
9739 *
9740 * Return: 0 on success else error code.
9741 */
9742static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
9743 uint32_t bandwidth)
9744{
9745 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9746 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
9747 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
9748 QDF_STATUS status;
9749 tHalHandle hal_hdl = hdd_ctx->hHal;
9750 struct qdf_mac_addr bssid;
9751 tCsrRoamProfile roam_profile;
9752 struct ch_params_s ch_params;
9753
9754 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
9755 hdd_err("Not supported, device is not in monitor mode");
9756 return -EINVAL;
9757 }
9758
9759 hdd_info("Set monitor mode Channel %d", chan);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009760 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
9761 roam_profile.ChannelInfo.numOfChannels = 1;
9762 roam_profile.phyMode = ch_info->phy_mode;
9763 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -07009764 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009765
9766 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
9767 QDF_MAC_ADDR_SIZE);
9768
9769 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07009770 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009771 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
9772 &roam_profile);
9773 if (status) {
9774 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
9775 status);
9776 }
9777
9778 return qdf_status_to_os_return(status);
9779}
9780
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009781#ifdef WLAN_SUSPEND_RESUME_TEST
9782static void *g_wiphy;
9783
9784/**
9785 * hdd_wlan_trigger_resume() - resume wlan
9786 * @val: interrupt val
9787 *
9788 * Resume wlan after getting very 1st CE interrupt from target
9789 *
9790 * Return: none
9791 */
9792static void hdd_wlan_trigger_resume(uint32_t val)
9793{
9794 hdd_err("Resume WLAN val 0x%x", val);
9795 wlan_hdd_bus_resume();
9796 wlan_hdd_cfg80211_resume_wlan(g_wiphy);
9797}
9798#endif
9799
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009800static int __iw_set_two_ints_getnone(struct net_device *dev,
9801 struct iw_request_info *info,
9802 union iwreq_data *wrqu, char *extra)
9803{
9804 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9805 int *value = (int *)extra;
9806 int sub_cmd = value[0];
9807 int ret;
9808 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009809#ifdef WLAN_SUSPEND_RESUME_TEST
9810 pm_message_t state;
9811#endif
9812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009813
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009814 ENTER_DEV(dev);
9815
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009816 ret = wlan_hdd_validate_context(hdd_ctx);
9817 if (0 != ret)
9818 return ret;
9819
9820 switch (sub_cmd) {
9821 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -07009822 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009823 ret = wma_cli_set_command(pAdapter->sessionId,
9824 WMI_STA_SMPS_PARAM_CMDID,
9825 value[1] << WMA_SMPS_PARAM_VALUE_S
9826 | value[2],
9827 VDEV_CMD);
9828 break;
9829#ifdef DEBUG
9830 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -07009831 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009832 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +05309833 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
9834 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009835 ret = wma_cli_set2_command(pAdapter->sessionId,
9836 GEN_PARAM_CRASH_INJECT,
9837 value[1], value[2], GEN_CMD);
9838 break;
9839#endif
Govind Singha471e5e2015-10-12 17:11:14 +05309840 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009841 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309842 value[1], value[2]);
9843 ret = wma_cli_set2_command(pAdapter->sessionId,
9844 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
9845 value[1], value[2], DBG_CMD);
9846 break;
9847 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -07009848 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309849 value[1], value[2]);
9850 ret = wma_cli_set2_command(pAdapter->sessionId,
9851 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
9852 value[1], value[2], DBG_CMD);
9853 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009854 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
9855 hdd_debug("Ioctl to set dual fw mode config");
9856 if (hdd_ctx->config->dual_mac_feature_disable) {
9857 hdd_err("Dual mac feature is disabled from INI");
9858 return -EPERM;
9859 }
9860 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08009861 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009862 break;
9863 case WE_DUMP_DP_TRACE_LEVEL:
9864 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
9865 value[1], value[2]);
9866 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309867 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +05309868 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
9869 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +05309870 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
9871 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009872 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009873 case WE_SET_MON_MODE_CHAN:
9874 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
9875 break;
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009876#ifdef WLAN_SUSPEND_RESUME_TEST
9877 case WE_SET_WLAN_SUSPEND:
9878 hdd_err("Suspend WLAN");
9879 g_wiphy = hdd_ctx->wiphy;
9880 state.event = PM_EVENT_SUSPEND;
9881 ret = wlan_hdd_cfg80211_suspend_wlan(hdd_ctx->wiphy, NULL);
9882 wlan_hdd_bus_suspend(state);
9883 hif_fake_apps_suspend(hdd_wlan_trigger_resume);
9884 break;
9885 case WE_SET_WLAN_RESUME:
9886 hdd_err("Resume WLAN");
9887 wlan_hdd_bus_resume();
9888 ret = wlan_hdd_cfg80211_resume_wlan(hdd_ctx->wiphy);
9889 break;
9890#endif
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,
10079 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10080 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 ,
11107#ifdef DEBUG
11108 {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 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011167int hdd_set_wext(hdd_adapter_t *pAdapter)
11168{
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}