blob: 6112c7527eaead456a6c6d0ab0bf9c031d015367 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_wext.c
30 *
31 * Linux Wireless Extensions Implementation
32 */
33
Jeff Johnson99bac312016-06-28 10:38:18 -070034/* denote that this file does not allow legacy hddLog */
35#define HDD_DISALLOW_LEGACY_HDDLOG 1
36
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037#include <linux/version.h>
38#include <linux/module.h>
39#include <linux/kernel.h>
40#include <linux/init.h>
41#include <linux/wireless.h>
42#include <mac_trace.h>
43#include <wlan_hdd_includes.h>
44#include <cds_api.h>
45#include <net/arp.h>
Manjunathappa Prakash3454fd62016-04-01 08:52:06 -070046#include <cdp_txrx_stats.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "sir_params.h"
48#include "csr_api.h"
49#include "csr_inside_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "sme_rrm_internal.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051#include <ani_global.h>
52#include "dot11f.h"
53#include <wlan_hdd_wowl.h>
54#include <wlan_hdd_cfg.h>
55#include <wlan_hdd_wmm.h>
56#include "utils_api.h"
57#include "wlan_hdd_p2p.h"
58#ifdef FEATURE_WLAN_TDLS
59#include "wlan_hdd_tdls.h"
60#endif
61
62#include "cds_ieee80211_common.h"
63#include "ol_if_athvar.h"
64#include "dbglog_host.h"
65#include "wma.h"
66
67#include "wlan_hdd_power.h"
68#include "qwlan_version.h"
69#include "wlan_hdd_host_offload.h"
70
71#include <linux/wireless.h>
72#include <net/cfg80211.h>
73
74#include "wlan_hdd_misc.h"
75
76#include "qc_sap_ioctl.h"
77#include "sme_api.h"
78#include "wma_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053079#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080#include "wlan_hdd_assoc.h"
81#include "wlan_hdd_ioctl.h"
82#include "wlan_hdd_scan.h"
83#include "sme_power_save_api.h"
84#include "cds_concurrency.h"
85#include "wlan_hdd_conc_ut.h"
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070086#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087#include "wlan_hdd_ocb.h"
88#include "wlan_hdd_napi.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080089#include "cdp_txrx_flow_ctrl_legacy.h"
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070090#include "wlan_hdd_nan_datapath.h"
Nirav Shahbf1b0332016-05-25 14:27:39 +053091#include "wlan_hdd_stats.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070092#ifdef WLAN_SUSPEND_RESUME_TEST
93#include "wlan_hdd_driver_ops.h"
94#include "hif.h"
Rajeev Kumar9bb2e852016-09-24 12:29:25 -070095#include "pld_common.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070096#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098#define HDD_FINISH_ULA_TIME_OUT 800
99#define HDD_SET_MCBC_FILTERS_TO_FW 1
100#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
101
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102static int ioctl_debug;
103module_param(ioctl_debug, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
104
105/* To Validate Channel against the Frequency and Vice-Versa */
106static const hdd_freq_chan_map_t freq_chan_map[] = {
107 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
108 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
109 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
110 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
111 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
112 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
113 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
114 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
115 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
116 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
117 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
118 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
119
120#define FREQ_CHAN_MAP_TABLE_SIZE \
121 (sizeof(freq_chan_map) / sizeof(freq_chan_map[0]))
122
123/* Private ioctls and their sub-ioctls */
124#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
125#define WE_SET_11D_STATE 1
126#define WE_WOWL 2
127#define WE_SET_POWER 3
128#define WE_SET_MAX_ASSOC 4
129#define WE_SET_SCAN_DISABLE 5
130#define WE_SET_DATA_INACTIVITY_TO 6
131#define WE_SET_MAX_TX_POWER 7
132#define WE_SET_HIGHER_DTIM_TRANSITION 8
133#define WE_SET_TM_LEVEL 9
134#define WE_SET_PHYMODE 10
135#define WE_SET_NSS 11
136#define WE_SET_LDPC 12
137#define WE_SET_TX_STBC 13
138#define WE_SET_RX_STBC 14
139#define WE_SET_SHORT_GI 15
140#define WE_SET_RTSCTS 16
141#define WE_SET_CHWIDTH 17
142#define WE_SET_ANI_EN_DIS 18
143#define WE_SET_ANI_POLL_PERIOD 19
144#define WE_SET_ANI_LISTEN_PERIOD 20
145#define WE_SET_ANI_OFDM_LEVEL 21
146#define WE_SET_ANI_CCK_LEVEL 22
147#define WE_SET_DYNAMIC_BW 23
148#define WE_SET_TX_CHAINMASK 24
149#define WE_SET_RX_CHAINMASK 25
150#define WE_SET_11N_RATE 26
151#define WE_SET_AMPDU 27
152#define WE_SET_AMSDU 28
153#define WE_SET_TXPOW_2G 29
154#define WE_SET_TXPOW_5G 30
155/* Private ioctl for firmware debug log */
156#define WE_DBGLOG_LOG_LEVEL 31
157#define WE_DBGLOG_VAP_ENABLE 32
158#define WE_DBGLOG_VAP_DISABLE 33
159#define WE_DBGLOG_MODULE_ENABLE 34
160#define WE_DBGLOG_MODULE_DISABLE 35
161#define WE_DBGLOG_MOD_LOG_LEVEL 36
162#define WE_DBGLOG_TYPE 37
163#define WE_SET_TXRX_FWSTATS 38
164#define WE_SET_VHT_RATE 39
165#define WE_DBGLOG_REPORT_ENABLE 40
166#define WE_TXRX_FWSTATS_RESET 41
167#define WE_SET_MAX_TX_POWER_2_4 42
168#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800169#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170/* Private ioctl for packet powe save */
171#define WE_PPS_PAID_MATCH 45
172#define WE_PPS_GID_MATCH 46
173#define WE_PPS_EARLY_TIM_CLEAR 47
174#define WE_PPS_EARLY_DTIM_CLEAR 48
175#define WE_PPS_EOF_PAD_DELIM 49
176#define WE_PPS_MACADDR_MISMATCH 50
177#define WE_PPS_DELIM_CRC_FAIL 51
178#define WE_PPS_GID_NSTS_ZERO 52
179#define WE_PPS_RSSI_CHECK 53
180#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
181#define WE_SET_HTSMPS 55
182/* Private ioctl for QPower */
183#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
184#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
185#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
186#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
187
188#define WE_SET_BURST_ENABLE 60
189#define WE_SET_BURST_DUR 61
190/* GTX Commands */
191#define WE_SET_GTX_HT_MCS 62
192#define WE_SET_GTX_VHT_MCS 63
193#define WE_SET_GTX_USRCFG 64
194#define WE_SET_GTX_THRE 65
195#define WE_SET_GTX_MARGIN 66
196#define WE_SET_GTX_STEP 67
197#define WE_SET_GTX_MINTPC 68
198#define WE_SET_GTX_BWMASK 69
199/* Private ioctl to configure MCC home channels time quota and latency */
200#define WE_MCC_CONFIG_LATENCY 70
201#define WE_MCC_CONFIG_QUOTA 71
202/* Private IOCTL for debug connection issues */
203#define WE_SET_DEBUG_LOG 72
204#ifdef WE_SET_TX_POWER
205#undef WE_SET_TX_POWER
206#endif
207#define WE_SET_TX_POWER 74
208/* Private ioctl for earlyrx power save feature */
209#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
210#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
211#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
212#define WE_SET_EARLY_RX_SLOP_STEP 78
213#define WE_SET_EARLY_RX_INIT_SLOP 79
214#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
215#define WE_SET_MC_RATE 81
216#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
217/* Private ioctl for packet power save */
218#define WE_PPS_5G_EBT 83
219#define WE_SET_CTS_CBW 84
220#define WE_DUMP_STATS 85
221#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530222/* Private sub ioctl for starting/stopping the profiling */
223#define WE_START_FW_PROFILE 87
Abhishek Singh1bdb1572015-10-16 16:24:19 +0530224#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +0530225#define WE_SET_CONC_SYSTEM_PREF 89
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226
227/* Private ioctls and their sub-ioctls */
228#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
229#define WE_GET_11D_STATE 1
230#define WE_IBSS_STATUS 2
231#define WE_SET_SAP_CHANNELS 3
232#define WE_GET_WLAN_DBG 4
233#define WE_GET_MAX_ASSOC 6
234/* 7 is unused */
235#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
236#define WE_GET_CONCURRENCY_MODE 9
237#define WE_GET_NSS 11
238#define WE_GET_LDPC 12
239#define WE_GET_TX_STBC 13
240#define WE_GET_RX_STBC 14
241#define WE_GET_SHORT_GI 15
242#define WE_GET_RTSCTS 16
243#define WE_GET_CHWIDTH 17
244#define WE_GET_ANI_EN_DIS 18
245#define WE_GET_ANI_POLL_PERIOD 19
246#define WE_GET_ANI_LISTEN_PERIOD 20
247#define WE_GET_ANI_OFDM_LEVEL 21
248#define WE_GET_ANI_CCK_LEVEL 22
249#define WE_GET_DYNAMIC_BW 23
250#define WE_GET_TX_CHAINMASK 24
251#define WE_GET_RX_CHAINMASK 25
252#define WE_GET_11N_RATE 26
253#define WE_GET_AMPDU 27
254#define WE_GET_AMSDU 28
255#define WE_GET_TXPOW_2G 29
256#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -0800257/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258#define WE_GET_PPS_PAID_MATCH 32
259#define WE_GET_PPS_GID_MATCH 33
260#define WE_GET_PPS_EARLY_TIM_CLEAR 34
261#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
262#define WE_GET_PPS_EOF_PAD_DELIM 36
263#define WE_GET_PPS_MACADDR_MISMATCH 37
264#define WE_GET_PPS_DELIM_CRC_FAIL 38
265#define WE_GET_PPS_GID_NSTS_ZERO 39
266#define WE_GET_PPS_RSSI_CHECK 40
267/* Private ioctl for QPower */
268#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
269#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
270#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
271#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
272#define WE_GET_BURST_ENABLE 45
273#define WE_GET_BURST_DUR 46
274/* GTX Commands */
275#define WE_GET_GTX_HT_MCS 47
276#define WE_GET_GTX_VHT_MCS 48
277#define WE_GET_GTX_USRCFG 49
278#define WE_GET_GTX_THRE 50
279#define WE_GET_GTX_MARGIN 51
280#define WE_GET_GTX_STEP 52
281#define WE_GET_GTX_MINTPC 53
282#define WE_GET_GTX_BWMASK 54
283#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700284#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700285#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286
287/* Private ioctls and their sub-ioctls */
288#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
289
290/* Private ioctls and their sub-ioctls */
291#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
292#define WE_WOWL_ADD_PTRN 1
293#define WE_WOWL_DEL_PTRN 2
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294#define WE_NEIGHBOR_REPORT_REQUEST 3
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295#define WE_SET_AP_WPS_IE 4 /* This is called in station mode to set probe rsp ie. */
296#define WE_SET_CONFIG 5
297
298/* Private ioctls and their sub-ioctls */
299#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
300#define WE_SET_WLAN_DBG 1
301#define WE_SET_DP_TRACE 2
302#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +0530303#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304
305/* Private ioctls and their sub-ioctls */
306#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
307#define WE_WLAN_VERSION 1
308#define WE_GET_STATS 2
309#define WE_GET_CFG 3
310#define WE_GET_WMM_STATUS 4
311#define WE_GET_CHANNEL_LIST 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312#define WE_GET_RSSI 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313#ifdef FEATURE_WLAN_TDLS
314#define WE_GET_TDLS_PEERS 8
315#endif
316#ifdef WLAN_FEATURE_11W
317#define WE_GET_11W_INFO 9
318#endif
319#define WE_GET_STATES 10
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800320#define WE_GET_IBSS_STA_INFO 11
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321#define WE_GET_PHYMODE 12
322#ifdef FEATURE_OEM_DATA_SUPPORT
323#define WE_GET_OEM_DATA_CAP 13
324#endif
325#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +0530326#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327
328/* Private ioctls and their sub-ioctls */
329#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
330#define WE_SET_REASSOC_TRIGGER 8
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800331#define WE_IBSS_GET_PEER_INFO_ALL 10
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332#define WE_DUMP_AGC_START 11
333#define WE_DUMP_AGC 12
334#define WE_DUMP_CHANINFO_START 13
335#define WE_DUMP_CHANINFO 14
336#define WE_DUMP_WATCHDOG 15
337#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
338#define WE_DUMP_PCIE_LOG 16
339#endif
340#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -0800341#define WE_GET_FW_PROFILE_DATA 18
342#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343
344/* Private ioctls and their sub-ioctls */
345#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
346
347#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +0530348/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800349
Manjeet Singhf82ed072016-07-08 11:40:00 +0530350#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351
352#ifdef FEATURE_WLAN_TDLS
353#define WE_TDLS_CONFIG_PARAMS 5
354#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800355#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356#define WE_UNIT_TEST_CMD 7
357
358#define WE_MTRACE_DUMP_CMD 8
359#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
360
361
362#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
363#define WE_LED_FLASHING_PARAM 10
364#endif
365
366#define WE_POLICY_MANAGER_CLIST_CMD 11
367#define WE_POLICY_MANAGER_DLIST_CMD 12
368#define WE_POLICY_MANAGER_DBS_CMD 13
369#define WE_POLICY_MANAGER_PCL_CMD 14
370#define WE_POLICY_MANAGER_CINFO_CMD 15
371#define WE_POLICY_MANAGER_ULIST_CMD 16
372#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
373#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
374#define WE_POLICY_MANAGER_SCENARIO_CMD 19
375#define WE_POLICY_SET_HW_MODE_CMD 20
376
377#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
378#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -0700379#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380
381#ifdef FEATURE_WLAN_TDLS
382#undef MAX_VAR_ARGS
383#define MAX_VAR_ARGS 11
384#else
385#undef MAX_VAR_ARGS
386#define MAX_VAR_ARGS 9
387#endif
388
389/* Private ioctls (with no sub-ioctls) */
390/* note that they must be odd so that they have "get" semantics */
391#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
392#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
393#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
394
395/* (SIOCIWFIRSTPRIV + 8) is currently unused */
396/* (SIOCIWFIRSTPRIV + 10) is currently unused */
397/* (SIOCIWFIRSTPRIV + 12) is currently unused */
398/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700399#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
400#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401/* (SIOCIWFIRSTPRIV + 16) is currently unused */
402/* (SIOCIWFIRSTPRIV + 17) is currently unused */
403/* (SIOCIWFIRSTPRIV + 19) is currently unused */
404
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406
407/* Private ioctl for setting the host offload feature */
408#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
409
410/* Private ioctl to get the statistics */
411#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
412
413/* Private ioctl to set the Keep Alive Params */
414#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
415
416#ifdef WLAN_FEATURE_PACKET_FILTERING
417/* Private ioctl to set the packet filtering params */
418#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
419#endif
420
421
422#ifdef FEATURE_WLAN_SCAN_PNO
423/* Private ioctl to get the statistics */
424#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
425#endif
426
427#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
428
429/* (SIOCIWFIRSTPRIV + 26) is currently unused */
430/* (SIOCIWFIRSTPRIV + 27) is currently unused */
431
432/* Private ioctls and their sub-ioctls */
433#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
434#define WE_SET_SMPS_PARAM 1
435#ifdef DEBUG
436#define WE_SET_FW_CRASH_INJECT 2
437#endif
438#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +0530439/* Private sub ioctl for enabling and setting histogram interval of profiling */
440#define WE_ENABLE_FW_PROFILE 4
441#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442
Rajeev Kumar9bb2e852016-09-24 12:29:25 -0700443/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700444#define WE_SET_WLAN_SUSPEND 6
445#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700446
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;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 struct hdd_config *pConfig;
2041 struct wireless_dev *wdev;
2042 int ret;
2043
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002044 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045
2046 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2047 ret = wlan_hdd_validate_context(hdd_ctx);
2048 if (0 != ret)
2049 return ret;
2050
2051 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2052 wdev = dev->ieee80211_ptr;
2053 pRoamProfile = &pWextState->roamProfile;
2054 LastBSSType = pRoamProfile->BSSType;
2055
Jeff Johnson99bac312016-06-28 10:38:18 -07002056 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057
2058 switch (wrqu->mode) {
2059 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07002060 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2062 /* Set the phymode correctly for IBSS. */
2063 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
2064 pWextState->roamProfile.phyMode =
2065 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08002066 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 wdev->iftype = NL80211_IFTYPE_ADHOC;
2068 break;
2069 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07002070 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2072 wdev->iftype = NL80211_IFTYPE_STATION;
2073 break;
2074 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07002075 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
2077 break;
2078 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002079 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 return -EOPNOTSUPP;
2081 }
2082
2083 if (LastBSSType != pRoamProfile->BSSType) {
2084 /* the BSS mode changed. We need to issue disconnect
2085 * if connected or in IBSS disconnect state
2086 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07002087 if (hdd_conn_is_connected
2088 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302090 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091 /* need to issue a disconnect to CSR. */
2092 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302093 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
2095 pAdapter->sessionId,
2096 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302097 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 unsigned long rc;
2099 rc = wait_for_completion_timeout(&pAdapter->
2100 disconnect_comp_var,
2101 msecs_to_jiffies
2102 (WLAN_WAIT_TIME_DISCONNECT));
2103 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07002104 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 }
2106 }
2107 }
2108
2109 EXIT();
2110 return 0;
2111}
2112
2113/**
2114 * iw_set_mode() - SSR wrapper for __iw_set_mode()
2115 * @dev: pointer to net_device
2116 * @info: pointer to iw_request_info
2117 * @wrqu: pointer to iwreq_data
2118 * @extra: pointer to extra ioctl payload
2119 *
2120 * Return: 0 on success, error number otherwise
2121 */
2122static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
2123 union iwreq_data *wrqu, char *extra)
2124{
2125 int ret;
2126
2127 cds_ssr_protect(__func__);
2128 ret = __iw_set_mode(dev, info, wrqu, extra);
2129 cds_ssr_unprotect(__func__);
2130
2131 return ret;
2132}
2133
2134/**
2135 * __iw_get_mode() - SIOCGIWMODE ioctl handler
2136 * @dev: device upon which the ioctl was received
2137 * @info: ioctl request information
2138 * @wrqu: ioctl request data
2139 * @extra: ioctl extra data
2140 *
2141 * Return: 0 on success, non-zero on error
2142 */
2143static int
2144__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2145 union iwreq_data *wrqu, char *extra)
2146{
2147 hdd_wext_state_t *pWextState;
2148 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2149 hdd_context_t *hdd_ctx;
2150 int ret;
2151
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002152 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153
2154 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2155 ret = wlan_hdd_validate_context(hdd_ctx);
2156 if (0 != ret)
2157 return ret;
2158
2159 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2160
2161 switch (pWextState->roamProfile.BSSType) {
2162 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07002163 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 wrqu->mode = IW_MODE_INFRA;
2165 break;
2166 case eCSR_BSS_TYPE_IBSS:
2167 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07002168 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 wrqu->mode = IW_MODE_ADHOC;
2170 break;
2171 case eCSR_BSS_TYPE_ANY:
2172 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002173 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174 wrqu->mode = IW_MODE_AUTO;
2175 break;
2176 }
2177
2178 EXIT();
2179 return 0;
2180}
2181
2182/**
2183 * iw_get_mode() - SSR wrapper for __iw_get_mode()
2184 * @dev: pointer to net_device
2185 * @info: pointer to iw_request_info
2186 * @wrqu: pointer to iwreq_data
2187 * @extra: pointer to extra ioctl payload
2188 *
2189 * Return: 0 on success, error number otherwise
2190 */
2191static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2192 union iwreq_data *wrqu, char *extra)
2193{
2194 int ret;
2195
2196 cds_ssr_protect(__func__);
2197 ret = __iw_get_mode(dev, info, wrqu, extra);
2198 cds_ssr_unprotect(__func__);
2199
2200 return ret;
2201}
2202
2203/**
2204 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
2205 * @dev: device upon which the ioctl was received
2206 * @info: ioctl request information
2207 * @wrqu: ioctl request data
2208 * @extra: ioctl extra data
2209 *
2210 * Return: 0 on success, non-zero on error
2211 */
2212static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2213 union iwreq_data *wrqu, char *extra)
2214{
2215 uint32_t numChans = 0;
2216 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2217 uint32_t indx = 0;
2218 int ret;
2219 hdd_wext_state_t *pWextState;
2220 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2221 hdd_context_t *hdd_ctx;
2222 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2223 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2224 tCsrRoamProfile *pRoamProfile;
2225
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002226 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227
2228 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2229 ret = wlan_hdd_validate_context(hdd_ctx);
2230 if (0 != ret)
2231 return ret;
2232
2233 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2234
2235 pRoamProfile = &pWextState->roamProfile;
2236
Jeff Johnson99bac312016-06-28 10:38:18 -07002237 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238
2239 /* Link is up then return cant set channel */
2240 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
2241 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002242 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243 return -EOPNOTSUPP;
2244 }
2245
2246 /* Settings by Frequency as input */
2247 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
2248 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
2249 uint32_t freq = wrqu->freq.m / 100000;
2250
2251 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
2252 && (freq != freq_chan_map[indx].freq))
2253 indx++;
2254 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
2255 return -EINVAL;
2256 }
2257 wrqu->freq.e = 0;
2258 wrqu->freq.m = freq_chan_map[indx].chan;
2259
2260 }
2261
2262 if (wrqu->freq.e == 0) {
2263 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2264 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002265 hdd_notice("Channel %d is outside valid range from %d to %d",
2266 wrqu->freq.m,
2267 WNI_CFG_CURRENT_CHANNEL_STAMIN,
2268 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 return -EINVAL;
2270 }
2271
2272 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2273
2274 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2275 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302276 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002277 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278 return -EIO;
2279 }
2280
2281 for (indx = 0; indx < numChans; indx++) {
2282 if (wrqu->freq.m == validChan[indx]) {
2283 break;
2284 }
2285 }
2286 } else {
2287
2288 return -EINVAL;
2289 }
2290
2291 if (indx >= numChans) {
2292 return -EINVAL;
2293 }
2294
2295 /* Set the Operational Channel */
2296 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2297 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2298 pRoamProfile->ChannelInfo.ChannelList =
2299 &pHddStaCtx->conn_info.operationChannel;
2300
Jeff Johnson99bac312016-06-28 10:38:18 -07002301 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302
2303 EXIT();
2304
2305 return ret;
2306}
2307
2308/**
2309 * iw_set_freq() - SSR wrapper for __iw_set_freq()
2310 * @dev: pointer to net_device
2311 * @info: pointer to iw_request_info
2312 * @wrqu: pointer to iwreq_data
2313 * @extra: pointer to extra ioctl payload
2314 *
2315 * Return: 0 on success, error number otherwise
2316 */
2317static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2318 union iwreq_data *wrqu, char *extra)
2319{
2320 int ret;
2321
2322 cds_ssr_protect(__func__);
2323 ret = __iw_set_freq(dev, info, wrqu, extra);
2324 cds_ssr_unprotect(__func__);
2325
2326 return ret;
2327}
2328
2329/**
2330 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
2331 * @dev: device upon which the ioctl was received
2332 * @info: ioctl request information
2333 * @wrqu: ioctl request data
2334 * @extra: ioctl extra data
2335 *
2336 * Return: 0 on success, non-zero on error
2337 */
2338static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2339 struct iw_freq *fwrq, char *extra)
2340{
2341 uint32_t status = false, channel = 0, freq = 0;
2342 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2343 tHalHandle hHal;
2344 hdd_wext_state_t *pWextState;
2345 tCsrRoamProfile *pRoamProfile;
2346 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2347 hdd_context_t *hdd_ctx;
2348 int ret;
2349
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002350 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351
2352 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2353 ret = wlan_hdd_validate_context(hdd_ctx);
2354 if (0 != ret)
2355 return ret;
2356
2357 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2358 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2359
2360 pRoamProfile = &pWextState->roamProfile;
2361
2362 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
2363 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302364 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002365 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 pAdapter->sessionId);
2367 return -EIO;
2368 } else {
2369 status = hdd_wlan_get_freq(channel, &freq);
2370 if (true == status) {
2371 /* Set Exponent parameter as 6 (MHZ)
2372 * in struct iw_freq iwlist & iwconfig
2373 * command shows frequency into proper
2374 * format (2.412 GHz instead of 246.2
2375 * MHz)
2376 */
2377 fwrq->m = freq;
2378 fwrq->e = MHZ;
2379 }
2380 }
2381 } else {
2382 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2383 * iwlist & iwconfig command shows frequency into proper
2384 * format (2.412 GHz instead of 246.2 MHz)
2385 */
2386 fwrq->m = 0;
2387 fwrq->e = MHZ;
2388 }
2389 return 0;
2390}
2391
2392/**
2393 * iw_get_freq() - SSR wrapper for __iw_get_freq()
2394 * @dev: pointer to net_device
2395 * @info: pointer to iw_request_info
2396 * @fwrq: pointer to frequency data
2397 * @extra: pointer to extra ioctl payload
2398 *
2399 * Return: 0 on success, error number otherwise
2400 */
2401static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2402 struct iw_freq *fwrq, char *extra)
2403{
2404 int ret;
2405
2406 cds_ssr_protect(__func__);
2407 ret = __iw_get_freq(dev, info, fwrq, extra);
2408 cds_ssr_unprotect(__func__);
2409
2410 return ret;
2411}
2412
2413/**
2414 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
2415 * @dev: device upon which the ioctl was received
2416 * @info: ioctl request information
2417 * @wrqu: ioctl request data
2418 * @extra: ioctl extra data
2419 *
2420 * Return: 0 on success, non-zero on error
2421 */
2422static int __iw_get_tx_power(struct net_device *dev,
2423 struct iw_request_info *info,
2424 union iwreq_data *wrqu, char *extra)
2425{
2426
2427 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2428 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2429 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2430 int ret;
2431
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002432 ENTER_DEV(dev);
2433
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 ret = wlan_hdd_validate_context(hdd_ctx);
2435 if (0 != ret)
2436 return ret;
2437
2438 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2439 wrqu->txpower.value = 0;
2440 return 0;
2441 }
2442 wlan_hdd_get_class_astats(pAdapter);
2443 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2444
2445 return 0;
2446}
2447
2448/**
2449 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
2450 * @dev: pointer to net_device
2451 * @info: pointer to iw_request_info
2452 * @wrqu: pointer to iwreq_data
2453 * @extra: pointer to extra ioctl payload
2454 *
2455 * Return: 0 on success, error number otherwise
2456 */
2457static int iw_get_tx_power(struct net_device *dev,
2458 struct iw_request_info *info,
2459 union iwreq_data *wrqu, char *extra)
2460{
2461 int ret;
2462
2463 cds_ssr_protect(__func__);
2464 ret = __iw_get_tx_power(dev, info, wrqu, extra);
2465 cds_ssr_unprotect(__func__);
2466
2467 return ret;
2468}
2469
2470/**
2471 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
2472 * @dev: device upon which the ioctl was received
2473 * @info: ioctl request information
2474 * @wrqu: ioctl request data
2475 * @extra: ioctl extra data
2476 *
2477 * Return: 0 on success, non-zero on error
2478 */
2479static int __iw_set_tx_power(struct net_device *dev,
2480 struct iw_request_info *info,
2481 union iwreq_data *wrqu, char *extra)
2482{
2483 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2484 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2485 hdd_context_t *hdd_ctx;
2486 int ret;
2487
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002488 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489
2490 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2491 ret = wlan_hdd_validate_context(hdd_ctx);
2492 if (0 != ret)
2493 return ret;
2494
2495 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302496 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002497 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498 return -EIO;
2499 }
2500
2501 EXIT();
2502
2503 return 0;
2504}
2505
2506/**
2507 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
2508 * @dev: pointer to net_device
2509 * @info: pointer to iw_request_info
2510 * @wrqu: pointer to iwreq_data
2511 * @extra: pointer to extra ioctl payload
2512 *
2513 * Return: 0 on success, error number otherwise
2514 */
2515static int iw_set_tx_power(struct net_device *dev,
2516 struct iw_request_info *info,
2517 union iwreq_data *wrqu, char *extra)
2518{
2519 int ret;
2520
2521 cds_ssr_protect(__func__);
2522 ret = __iw_set_tx_power(dev, info, wrqu, extra);
2523 cds_ssr_unprotect(__func__);
2524
2525 return ret;
2526}
2527
2528/**
2529 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
2530 * @dev: device upon which the ioctl was received
2531 * @info: ioctl request information
2532 * @wrqu: ioctl request data
2533 * @extra: ioctl extra data
2534 *
2535 * Return: 0 on success, non-zero on error
2536 */
2537static int __iw_get_bitrate(struct net_device *dev,
2538 struct iw_request_info *info,
2539 union iwreq_data *wrqu, char *extra)
2540{
Anurag Chouhance0dc992016-02-16 18:18:03 +05302541 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302542 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 hdd_wext_state_t *pWextState;
2544 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2545 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2546 hdd_context_t *hdd_ctx;
2547 int ret;
2548
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002549 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550
2551 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2552 ret = wlan_hdd_validate_context(hdd_ctx);
2553 if (0 != ret)
2554 return ret;
2555
Prashanth Bhatta9e143052015-12-04 11:56:47 -08002556 if (cds_is_driver_recovering()) {
2557 hdd_alert("Recovery in Progress. State: 0x%x Ignore!!!",
2558 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559 return status;
2560 }
2561
2562 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2563 wrqu->bitrate.value = 0;
2564 } else {
2565 status =
2566 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
2567 eCSR_HDD,
2568 SME_SUMMARY_STATS |
2569 SME_GLOBAL_CLASSA_STATS |
2570 SME_GLOBAL_CLASSB_STATS |
2571 SME_GLOBAL_CLASSC_STATS |
2572 SME_GLOBAL_CLASSD_STATS |
2573 SME_PER_STA_STATS,
2574 hdd_statistics_cb, 0,
2575 false,
2576 pHddStaCtx->conn_info.staId[0],
2577 pAdapter, pAdapter->sessionId);
2578
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302579 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002580 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 return status;
2582 }
2583
2584 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2585
Anurag Chouhance0dc992016-02-16 18:18:03 +05302586 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302587 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 WLAN_WAIT_TIME_STATS);
2589
Anurag Chouhance0dc992016-02-16 18:18:03 +05302590 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002591 hdd_err("SME timeout while retrieving statistics");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302592 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 }
2594
2595 wrqu->bitrate.value =
2596 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
2597 }
2598
2599 EXIT();
2600
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302601 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602}
2603
2604/**
2605 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
2606 * @dev: pointer to net_device
2607 * @info: pointer to iw_request_info
2608 * @wrqu: pointer to iwreq_data
2609 * @extra: pointer to extra ioctl payload
2610 *
2611 * Return: 0 on success, error number otherwise
2612 */
2613static int iw_get_bitrate(struct net_device *dev,
2614 struct iw_request_info *info,
2615 union iwreq_data *wrqu, char *extra)
2616{
2617 int ret;
2618
2619 cds_ssr_protect(__func__);
2620 ret = __iw_get_bitrate(dev, info, wrqu, extra);
2621 cds_ssr_unprotect(__func__);
2622
2623 return ret;
2624}
2625
2626/**
2627 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
2628 * @dev: device upon which the ioctl was received
2629 * @info: ioctl request information
2630 * @wrqu: ioctl request data
2631 * @extra: ioctl extra data
2632 *
2633 * Return: 0 on success, non-zero on error
2634 */
2635static int __iw_set_bitrate(struct net_device *dev,
2636 struct iw_request_info *info,
2637 union iwreq_data *wrqu, char *extra)
2638{
2639 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2640 hdd_wext_state_t *pWextState;
2641 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2642 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
2643 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
2644 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
2645 uint32_t i, rate;
2646 uint32_t valid_rate = false, active_phy_mode = 0;
2647 hdd_context_t *hdd_ctx;
2648 int ret;
2649
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002650 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651
2652 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2653 ret = wlan_hdd_validate_context(hdd_ctx);
2654 if (0 != ret)
2655 return ret;
2656
2657 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2658
2659 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2660 return -ENXIO;
2661 }
2662
2663 rate = wrqu->bitrate.value;
2664
2665 if (rate == -1) {
2666 rate = WNI_CFG_FIXED_RATE_AUTO;
2667 valid_rate = true;
2668 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
2669 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302670 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
2672 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
2673 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
2674 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2675 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302676 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 &&
2678 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
2679 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302680 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 for (i = 0; i < (b_len + a_len); ++i) {
2682 /* supported rates returned is double
2683 * the actual rate so we divide it by 2
2684 */
2685 if ((supp_rates[i] & 0x7F) / 2 ==
2686 rate) {
2687 valid_rate = true;
2688 rate = i +
2689 WNI_CFG_FIXED_RATE_1MBPS;
2690 break;
2691 }
2692 }
2693 }
2694 }
2695 }
2696 if (valid_rate != true) {
2697 return -EINVAL;
2698 }
2699 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302700 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002701 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 return -EIO;
2703 }
2704 return 0;
2705}
2706
2707/**
2708 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
2709 * @dev: pointer to net_device
2710 * @info: pointer to iw_request_info
2711 * @wrqu: pointer to iwreq_data
2712 * @extra: pointer to extra ioctl payload
2713 *
2714 * Return: 0 on success, error number otherwise
2715 */
2716static int iw_set_bitrate(struct net_device *dev,
2717 struct iw_request_info *info,
2718 union iwreq_data *wrqu, char *extra)
2719{
2720 int ret;
2721
2722 cds_ssr_protect(__func__);
2723 ret = __iw_set_bitrate(dev, info, wrqu, extra);
2724 cds_ssr_unprotect(__func__);
2725
2726 return ret;
2727}
2728
2729/**
2730 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
2731 * @dev: device upon which the ioctl was received
2732 * @info: ioctl request information
2733 * @wrqu: ioctl request data
2734 * @extra: ioctl extra data
2735 *
2736 * Return: 0 on success, non-zero on error
2737 */
2738static int __iw_set_genie(struct net_device *dev,
2739 struct iw_request_info *info,
2740 union iwreq_data *wrqu, char *extra)
2741{
2742 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2743 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2744 uint8_t *genie = NULL;
2745 uint8_t *base_genie = NULL;
2746 uint16_t remLen;
2747 hdd_context_t *hdd_ctx;
2748 int ret;
2749
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002750 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751
2752 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2753 ret = wlan_hdd_validate_context(hdd_ctx);
2754 if (0 != ret)
2755 return ret;
2756
2757 if (!wrqu->data.length) {
2758 hdd_clear_roam_profile_ie(pAdapter);
2759 EXIT();
2760 return 0;
2761 }
2762
2763 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
2764 wrqu->data.length);
2765 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002766 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 return -ENOMEM;
2768 }
2769
2770 genie = base_genie;
2771
2772 remLen = wrqu->data.length;
2773
Jeff Johnson99bac312016-06-28 10:38:18 -07002774 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 genie[1]);
2776
2777 /* clear any previous genIE before this call */
2778 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
2779
2780 while (remLen >= 2) {
2781 uint16_t eLen = 0;
2782 uint8_t elementId;
2783 elementId = *genie++;
2784 eLen = *genie++;
2785 remLen -= 2;
2786
Jeff Johnson99bac312016-06-28 10:38:18 -07002787 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788
2789 switch (elementId) {
2790 case IE_EID_VENDOR:
2791 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 +05302792 ret = -EINVAL;
2793 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002794 }
2795
2796 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
2797 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002798 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
2799 genie[0], genie[1], genie[2],
2800 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801
2802 if (SIR_MAC_MAX_IE_LENGTH <
2803 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002804 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302805 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302806 ret = -ENOMEM;
2807 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 }
2809 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2810 memcpy(pWextState->genIE.addIEdata +
2811 curGenIELen, genie - 2, eLen + 2);
2812 pWextState->genIE.length += eLen + 2;
2813 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002814 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302815 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2816 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2817 ret = -EINVAL;
2818 QDF_ASSERT(0);
2819 goto exit;
2820 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 memset(pWextState->WPARSNIE, 0,
2822 MAX_WPA_RSN_IE_LEN);
2823 memcpy(pWextState->WPARSNIE, genie - 2,
2824 (eLen + 2));
2825 pWextState->roamProfile.pWPAReqIE =
2826 pWextState->WPARSNIE;
2827 pWextState->roamProfile.nWPAReqIELength =
2828 eLen + 2;
2829 } else { /* any vendorId except WPA IE should be accumulated to genIE */
2830
2831 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07002832 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
2833 genie[0], genie[1], genie[2],
2834 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835
2836 if (SIR_MAC_MAX_IE_LENGTH <
2837 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002838 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302839 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302840 ret = -ENOMEM;
2841 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 }
2843 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
2844 memcpy(pWextState->genIE.addIEdata +
2845 curGenIELen, genie - 2, eLen + 2);
2846 pWextState->genIE.length += eLen + 2;
2847 }
2848 break;
2849 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07002850 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302851 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
2852 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
2853 ret = -EINVAL;
2854 QDF_ASSERT(0);
2855 goto exit;
2856 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
2858 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
2859 pWextState->roamProfile.pRSNReqIE =
2860 pWextState->WPARSNIE;
2861 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
2862 break;
2863
2864 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002865 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302866 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 }
2868 genie += eLen;
2869 remLen -= eLen;
2870 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302871exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 EXIT();
2873 kfree(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05302874 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875}
2876
2877/**
2878 * iw_set_genie() - SSR wrapper for __iw_set_genie()
2879 * @dev: pointer to net_device
2880 * @info: pointer to iw_request_info
2881 * @wrqu: pointer to iwreq_data
2882 * @extra: pointer to extra ioctl payload
2883 *
2884 * Return: 0 on success, error number otherwise
2885 */
2886static int iw_set_genie(struct net_device *dev,
2887 struct iw_request_info *info,
2888 union iwreq_data *wrqu, char *extra)
2889{
2890 int ret;
2891
2892 cds_ssr_protect(__func__);
2893 ret = __iw_set_genie(dev, info, wrqu, extra);
2894 cds_ssr_unprotect(__func__);
2895
2896 return ret;
2897}
2898
2899/**
2900 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
2901 * @dev: device upon which the ioctl was received
2902 * @info: ioctl request information
2903 * @wrqu: ioctl request data
2904 * @extra: ioctl extra data
2905 *
2906 * Return: 0 on success, non-zero on error
2907 */
2908static int __iw_get_genie(struct net_device *dev,
2909 struct iw_request_info *info,
2910 union iwreq_data *wrqu, char *extra)
2911{
2912 hdd_wext_state_t *pWextState;
2913 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2914 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302915 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
2917 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
2918 hdd_context_t *hdd_ctx;
2919 int ret;
2920
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002921 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922
2923 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2924 ret = wlan_hdd_validate_context(hdd_ctx);
2925 if (0 != ret)
2926 return ret;
2927
Jeff Johnson99bac312016-06-28 10:38:18 -07002928 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929
2930 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2931
2932 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
2933 return -ENXIO;
2934 }
2935
2936 /* Return something ONLY if we are associated with an RSN or
2937 * WPA network
2938 */
2939 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
2940 return -ENXIO;
2941 }
2942
2943 /* Actually retrieve the RSN IE from CSR. (We previously sent
2944 * it down in the CSR Roam Profile.)
2945 */
2946 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
2947 pAdapter->sessionId,
2948 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05302949 if (QDF_STATUS_SUCCESS != status) {
2950 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 return -EFAULT;
2952 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05302954 if (length > DOT11F_IE_RSN_MAX_LEN) {
2955 hdd_notice("invalid buffer length length:%d", length);
2956 return -E2BIG;
2957 }
2958 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959
Jeff Johnson99bac312016-06-28 10:38:18 -07002960 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961 wrqu->data.length);
2962
2963 EXIT();
2964
2965 return 0;
2966}
2967
2968/**
2969 * iw_get_genie() - SSR wrapper for __iw_get_genie()
2970 * @dev: pointer to net_device
2971 * @info: pointer to iw_request_info
2972 * @wrqu: pointer to iwreq_data
2973 * @extra: pointer to extra ioctl payload
2974 *
2975 * Return: 0 on success, error number otherwise
2976 */
2977static int iw_get_genie(struct net_device *dev,
2978 struct iw_request_info *info,
2979 union iwreq_data *wrqu, char *extra)
2980{
2981 int ret;
2982
2983 cds_ssr_protect(__func__);
2984 ret = __iw_get_genie(dev, info, wrqu, extra);
2985 cds_ssr_unprotect(__func__);
2986
2987 return ret;
2988}
2989
2990/**
2991 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
2992 * @dev: device upon which the ioctl was received
2993 * @info: ioctl request information
2994 * @wrqu: ioctl request data
2995 * @extra: ioctl extra data
2996 *
2997 * Return: 0 on success, non-zero on error
2998 */
2999static int __iw_get_encode(struct net_device *dev,
3000 struct iw_request_info *info,
3001 struct iw_point *dwrq, char *extra)
3002{
3003 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3004 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3005 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3006 int keyId;
3007 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3008 int i;
3009 hdd_context_t *hdd_ctx;
3010 int ret;
3011
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003012 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013
3014 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3015 ret = wlan_hdd_validate_context(hdd_ctx);
3016 if (0 != ret)
3017 return ret;
3018
3019 keyId = pRoamProfile->Keys.defaultIndex;
3020
3021 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003022 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023 return -EINVAL;
3024 }
3025
3026 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
3027 dwrq->flags |= IW_ENCODE_ENABLED;
3028 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303029 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 pRoamProfile->Keys.KeyLength[keyId]);
3031
3032 dwrq->flags |= (keyId + 1);
3033
3034 } else {
3035 dwrq->flags |= IW_ENCODE_DISABLED;
3036 }
3037
3038 for (i = 0; i < MAX_WEP_KEYS; i++) {
3039 if (pRoamProfile->Keys.KeyMaterial[i] == NULL) {
3040 continue;
3041 } else {
3042 break;
3043 }
3044 }
3045
3046 if (MAX_WEP_KEYS == i) {
3047 dwrq->flags |= IW_ENCODE_NOKEY;
3048 }
3049
3050 authType =
3051 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
3052 conn_info.authType;
3053
3054 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
3055 dwrq->flags |= IW_ENCODE_OPEN;
3056 } else {
3057 dwrq->flags |= IW_ENCODE_RESTRICTED;
3058 }
3059 EXIT();
3060 return 0;
3061}
3062
3063/**
3064 * iw_get_encode() - SSR wrapper for __iw_get_encode()
3065 * @dev: pointer to net_device
3066 * @info: pointer to iw_request_info
3067 * @dwrq: pointer to encoding information
3068 * @extra: pointer to extra ioctl payload
3069 *
3070 * Return: 0 on success, error number otherwise
3071 */
3072static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
3073 struct iw_point *dwrq, char *extra)
3074{
3075 int ret;
3076
3077 cds_ssr_protect(__func__);
3078 ret = __iw_get_encode(dev, info, dwrq, extra);
3079 cds_ssr_unprotect(__func__);
3080
3081 return ret;
3082}
3083
3084/**
3085 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
3086 * @dev: device upon which the ioctl was received
3087 * @info: ioctl request information
3088 * @wrqu: ioctl request data
3089 * @extra: ioctl extra data
3090 *
3091 * Return: 0 on success, non-zero on error
3092 */
3093static int __iw_get_rts_threshold(struct net_device *dev,
3094 struct iw_request_info *info,
3095 union iwreq_data *wrqu, char *extra)
3096{
3097 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3098 uint32_t status = 0;
3099
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003100 ENTER_DEV(dev);
3101
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 status = hdd_wlan_get_rts_threshold(pAdapter, wrqu);
3103
3104 return status;
3105}
3106
3107/**
3108 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
3109 * @dev: device upon which the ioctl was received
3110 * @info: ioctl request information
3111 * @wrqu: ioctl request data
3112 * @extra: ioctl extra data
3113 *
3114 * Return: 0 on success, non-zero on error
3115 */
3116static int __iw_set_rts_threshold(struct net_device *dev,
3117 struct iw_request_info *info,
3118 union iwreq_data *wrqu, char *extra)
3119{
3120 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3121 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3122 hdd_context_t *hdd_ctx;
3123 int ret;
3124
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003125 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126
3127 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3128 ret = wlan_hdd_validate_context(hdd_ctx);
3129 if (0 != ret)
3130 return ret;
3131
3132 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
3133 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
3134 return -EINVAL;
3135 }
3136
3137 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303138 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003139 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 return -EIO;
3141 }
3142
3143 EXIT();
3144
3145 return 0;
3146}
3147
3148/**
3149 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
3150 * @dev: pointer to net_device
3151 * @info: pointer to iw_request_info
3152 * @wrqu: pointer to iwreq_data
3153 * @extra: pointer to extra ioctl payload
3154 *
3155 * Return: 0 on success, error number otherwise
3156 */
3157static int iw_get_rts_threshold(struct net_device *dev,
3158 struct iw_request_info *info,
3159 union iwreq_data *wrqu, char *extra)
3160{
3161 int ret;
3162
3163 cds_ssr_protect(__func__);
3164 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
3165 cds_ssr_unprotect(__func__);
3166
3167 return ret;
3168}
3169
3170/**
3171 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
3172 * @dev: pointer to net_device
3173 * @info: pointer to iw_request_info
3174 * @wrqu: pointer to iwreq_data
3175 * @extra: pointer to extra ioctl payload
3176 *
3177 * Return: 0 on success, error number otherwise
3178 */
3179static int iw_set_rts_threshold(struct net_device *dev,
3180 struct iw_request_info *info,
3181 union iwreq_data *wrqu, char *extra)
3182{
3183 int ret;
3184
3185 cds_ssr_protect(__func__);
3186 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
3187 cds_ssr_unprotect(__func__);
3188
3189 return ret;
3190}
3191
3192/**
3193 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
3194 * @dev: device upon which the ioctl was received
3195 * @info: ioctl request information
3196 * @wrqu: ioctl request data
3197 * @extra: ioctl extra data
3198 *
3199 * Return: 0 on success, non-zero on error
3200 */
3201static int __iw_get_frag_threshold(struct net_device *dev,
3202 struct iw_request_info *info,
3203 union iwreq_data *wrqu, char *extra)
3204{
3205 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3206 uint32_t status = 0;
3207
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003208 ENTER_DEV(dev);
3209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 status = hdd_wlan_get_frag_threshold(pAdapter, wrqu);
3211
3212 return status;
3213}
3214
3215/**
3216 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
3217 * @dev: pointer to net_device
3218 * @info: pointer to iw_request_info
3219 * @wrqu: pointer to iwreq_data
3220 * @extra: pointer to extra ioctl payload
3221 *
3222 * Return: 0 on success, error number otherwise
3223 */
3224static int iw_get_frag_threshold(struct net_device *dev,
3225 struct iw_request_info *info,
3226 union iwreq_data *wrqu, char *extra)
3227{
3228 int ret;
3229
3230 cds_ssr_protect(__func__);
3231 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3232 cds_ssr_unprotect(__func__);
3233
3234 return ret;
3235}
3236
3237/**
3238 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
3239 * @dev: device upon which the ioctl was received
3240 * @info: ioctl request information
3241 * @wrqu: ioctl request data
3242 * @extra: ioctl extra data
3243 *
3244 * Return: 0 on success, non-zero on error
3245 */
3246static int __iw_set_frag_threshold(struct net_device *dev,
3247 struct iw_request_info *info,
3248 union iwreq_data *wrqu, char *extra)
3249{
3250 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3251 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3252 hdd_context_t *hdd_ctx;
3253 int ret;
3254
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003255 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256
3257 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3258 ret = wlan_hdd_validate_context(hdd_ctx);
3259 if (0 != ret)
3260 return ret;
3261
3262 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
3263 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
3264 return -EINVAL;
3265 }
3266
3267 if (sme_cfg_set_int
3268 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303269 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003270 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271 return -EIO;
3272 }
3273
3274 EXIT();
3275
3276 return 0;
3277}
3278
3279/**
3280 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
3281 * @dev: pointer to net_device
3282 * @info: pointer to iw_request_info
3283 * @wrqu: pointer to iwreq_data
3284 * @extra: pointer to extra ioctl payload
3285 *
3286 * Return: 0 on success, error number otherwise
3287 */
3288static int iw_set_frag_threshold(struct net_device *dev,
3289 struct iw_request_info *info,
3290 union iwreq_data *wrqu, char *extra)
3291{
3292 int ret;
3293
3294 cds_ssr_protect(__func__);
3295 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3296 cds_ssr_unprotect(__func__);
3297
3298 return ret;
3299}
3300
3301/**
3302 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
3303 * @dev: device upon which the ioctl was received
3304 * @info: ioctl request information
3305 * @wrqu: ioctl request data
3306 * @extra: ioctl extra data
3307 *
3308 * Return: 0 on success, non-zero on error
3309 */
3310static int __iw_get_power_mode(struct net_device *dev,
3311 struct iw_request_info *info,
3312 union iwreq_data *wrqu, char *extra)
3313{
3314 hdd_adapter_t *adapter;
3315 hdd_context_t *hdd_ctx;
3316 int ret;
3317
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003318 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319
3320 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3321 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3322 ret = wlan_hdd_validate_context(hdd_ctx);
3323 if (0 != ret)
3324 return ret;
3325
3326 return -EOPNOTSUPP;
3327}
3328
3329/**
3330 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
3331 * @dev: pointer to net_device
3332 * @info: pointer to iw_request_info
3333 * @wrqu: pointer to iwreq_data
3334 * @extra: extra
3335 *
3336 * Return: 0 on success, error number otherwise
3337 */
3338int iw_get_power_mode(struct net_device *dev,
3339 struct iw_request_info *info,
3340 union iwreq_data *wrqu, char *extra)
3341{
3342 int ret;
3343
3344 cds_ssr_protect(__func__);
3345 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3346 cds_ssr_unprotect(__func__);
3347
3348 return ret;
3349}
3350
3351/**
3352 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
3353 * @dev: device upon which the ioctl was received
3354 * @info: ioctl request information
3355 * @wrqu: ioctl request data
3356 * @extra: ioctl extra data
3357 *
3358 * Return: 0 on success, non-zero on error
3359 */
3360static int __iw_set_power_mode(struct net_device *dev,
3361 struct iw_request_info *info,
3362 union iwreq_data *wrqu, char *extra)
3363{
3364 hdd_adapter_t *adapter;
3365 hdd_context_t *hdd_ctx;
3366 int ret;
3367
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003368 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369
3370 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3371 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3372 ret = wlan_hdd_validate_context(hdd_ctx);
3373 if (0 != ret)
3374 return ret;
3375
3376 return -EOPNOTSUPP;
3377}
3378
3379/**
3380 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
3381 * @dev: pointer to net_device
3382 * @info: pointer to iw_request_info
3383 * @wrqu: pointer to iwreq_data
3384 * @extra: extra
3385 *
3386 * Return: 0 on success, error number otherwise
3387 */
3388int iw_set_power_mode(struct net_device *dev,
3389 struct iw_request_info *info,
3390 union iwreq_data *wrqu, char *extra)
3391{
3392 int ret;
3393
3394 cds_ssr_protect(__func__);
3395 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3396 cds_ssr_unprotect(__func__);
3397
3398 return ret;
3399}
3400
3401/**
3402 * __iw_get_range() - SIOCGIWRANGE ioctl handler
3403 * @dev: device upon which the ioctl was received
3404 * @info: ioctl request information
3405 * @wrqu: ioctl request data
3406 * @extra: ioctl extra data
3407 *
3408 * Return: 0 on success, non-zero on error
3409 */
3410static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
3411 union iwreq_data *wrqu, char *extra)
3412{
3413 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3414 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3415 struct iw_range *range = (struct iw_range *)extra;
3416
3417 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3418
3419 uint32_t num_channels = sizeof(channels);
3420 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3421 uint32_t a_len;
3422 uint32_t b_len;
3423 uint32_t active_phy_mode = 0;
3424 uint8_t index = 0, i;
3425 hdd_context_t *hdd_ctx;
3426 int ret;
3427
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003428 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429
3430 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3431 ret = wlan_hdd_validate_context(hdd_ctx);
3432 if (0 != ret)
3433 return ret;
3434
3435 wrqu->data.length = sizeof(struct iw_range);
3436 memset(range, 0, sizeof(struct iw_range));
3437
3438
3439 /*Get the phy mode */
3440 if (sme_cfg_get_int(hHal,
3441 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303442 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003443 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444
3445 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
3446 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
3447 /*Get the supported rates for 11G band */
3448 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3449 if (sme_cfg_get_str(hHal,
3450 WNI_CFG_SUPPORTED_RATES_11A,
3451 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303452 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
3454 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3455 }
3456 for (i = 0; i < a_len; i++) {
3457 range->bitrate[i] =
3458 ((supp_rates[i] & 0x7F) / 2) *
3459 1000000;
3460 }
3461 range->num_bitrates = a_len;
3462 } else {
3463 return -EIO;
3464 }
3465 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
3466 /*Get the supported rates for 11B band */
3467 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3468 if (sme_cfg_get_str(hHal,
3469 WNI_CFG_SUPPORTED_RATES_11B,
3470 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303471 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
3473 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3474 }
3475 for (i = 0; i < b_len; i++) {
3476 range->bitrate[i] =
3477 ((supp_rates[i] & 0x7F) / 2) *
3478 1000000;
3479 }
3480 range->num_bitrates = b_len;
3481 } else {
3482 return -EIO;
3483 }
3484 }
3485 }
3486
3487 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
3488 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
3489 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
3490
3491 range->encoding_size[0] = 5;
3492 range->encoding_size[1] = 13;
3493 range->num_encoding_sizes = 2;
3494 range->max_encoding_tokens = MAX_WEP_KEYS;
3495
3496 /* we support through Wireless Extensions 22 */
3497 range->we_version_compiled = WIRELESS_EXT;
3498 range->we_version_source = 22;
3499
3500 /*Supported Channels and Frequencies */
3501 if (sme_cfg_get_str
3502 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303503 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003504 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 return -EIO;
3506 }
3507 if (num_channels > IW_MAX_FREQUENCIES) {
3508 num_channels = IW_MAX_FREQUENCIES;
3509 }
3510
3511 range->num_channels = num_channels;
3512 range->num_frequency = num_channels;
3513
3514 for (index = 0; index < num_channels; index++) {
3515 uint32_t frq_indx = 0;
3516
3517 range->freq[index].i = channels[index];
3518 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
3519 if (channels[index] == freq_chan_map[frq_indx].chan) {
3520 range->freq[index].m =
3521 freq_chan_map[frq_indx].freq * 100000;
3522 range->freq[index].e = 1;
3523 break;
3524 }
3525 frq_indx++;
3526 }
3527 }
3528
3529 /* Event capability (kernel + driver) */
3530 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
3531 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
3532 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
3533 range->event_capa[1] = IW_EVENT_CAPA_K_1;
3534
3535 /*Encryption capability */
3536 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
3537 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
3538
3539 /* Txpower capability */
3540 range->txpower_capa = IW_TXPOW_MWATT;
3541
3542 /*Scanning capability */
3543#if WIRELESS_EXT >= 22
3544 range->scan_capa =
3545 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
3546#endif
3547
3548 EXIT();
3549 return 0;
3550}
3551
3552/**
3553 * iw_get_range() - SSR wrapper for __iw_get_range()
3554 * @dev: pointer to net_device
3555 * @info: pointer to iw_request_info
3556 * @wrqu: pointer to iwreq_data
3557 * @extra: pointer to extra ioctl payload
3558 *
3559 * Return: 0 on success, error number otherwise
3560 */
3561static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
3562 union iwreq_data *wrqu, char *extra)
3563{
3564 int ret;
3565
3566 cds_ssr_protect(__func__);
3567 ret = __iw_get_range(dev, info, wrqu, extra);
3568 cds_ssr_unprotect(__func__);
3569
3570 return ret;
3571}
3572
3573/**
3574 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
3575 * @pStats: pointer to Class A stats
3576 * @pContext: user context originally registered with SME
3577 *
3578 * Return: None
3579 */
3580static void hdd_get_class_a_statistics_cb(void *pStats, void *pContext)
3581{
3582 struct statsContext *pStatsContext;
3583 tCsrGlobalClassAStatsInfo *pClassAStats;
3584 hdd_adapter_t *pAdapter;
3585
3586 if (ioctl_debug) {
3587 pr_info("%s: pStats [%p] pContext [%p]\n",
3588 __func__, pStats, pContext);
3589 }
3590
3591 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003592 hdd_err("Bad param, pStats [%p] pContext [%p]",
3593 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594 return;
3595 }
3596
3597 pClassAStats = pStats;
3598 pStatsContext = pContext;
3599 pAdapter = pStatsContext->pAdapter;
3600
3601 /* there is a race condition that exists between this callback
3602 * function and the caller since the caller could time out
3603 * either before or while this code is executing. we use a
3604 * spinlock to serialize these actions
3605 */
3606 spin_lock(&hdd_context_lock);
3607
3608 if ((NULL == pAdapter) ||
3609 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3610 /* the caller presumably timed out so there is nothing
3611 * we can do
3612 */
3613 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003614 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3615 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616 if (ioctl_debug) {
3617 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3618 __func__, pAdapter, pStatsContext->magic);
3619 }
3620 return;
3621 }
3622
3623 /* context is valid so caller is still waiting */
3624
3625 /* paranoia: invalidate the magic */
3626 pStatsContext->magic = 0;
3627
3628 /* copy over the stats. do so as a struct copy */
3629 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
3630
3631 /* notify the caller */
3632 complete(&pStatsContext->completion);
3633
3634 /* serialization is complete */
3635 spin_unlock(&hdd_context_lock);
3636}
3637
3638/**
3639 * wlan_hdd_get_class_astats() - Get Class A statistics
3640 * @pAdapter: adapter for which statistics are desired
3641 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303642 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303644QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645{
3646 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303647 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 unsigned long rc;
3649 struct statsContext context;
3650
3651 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003652 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303653 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003655 if (cds_is_driver_recovering()) {
3656 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3657 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303658 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659 }
3660
3661 /* we are connected so prepare our callback context */
3662 init_completion(&context.completion);
3663 context.pAdapter = pAdapter;
3664 context.magic = STATS_CONTEXT_MAGIC;
3665 /* query only for Class A statistics (which include link speed) */
3666 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3667 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
3668 hdd_get_class_a_statistics_cb,
3669 0, /* not periodic */
3670 false, /* non-cached results */
3671 pHddStaCtx->conn_info.staId[0],
3672 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303673 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07003674 hdd_warn("Unable to retrieve Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675 /* we'll returned a cached value below */
3676 } else {
3677 /* request was sent -- wait for the response */
3678 rc = wait_for_completion_timeout
3679 (&context.completion,
3680 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3681 if (!rc) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07003682 hdd_warn("SME timed out while retrieving Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683 }
3684 }
3685
3686 /* either we never sent a request, we sent a request and
3687 * received a response or we sent a request and timed out. if
3688 * we never sent a request or if we sent a request and got a
3689 * response, we want to clear the magic out of paranoia. if
3690 * we timed out there is a race condition such that the
3691 * callback function could be executing at the same time we
3692 * are. of primary concern is if the callback function had
3693 * already verified the "magic" but had not yet set the
3694 * completion variable when a timeout occurred. we serialize
3695 * these activities by invalidating the magic while holding a
3696 * shared spinlock which will cause us to block if the
3697 * callback is currently executing
3698 */
3699 spin_lock(&hdd_context_lock);
3700 context.magic = 0;
3701 spin_unlock(&hdd_context_lock);
3702
3703 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303704 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705}
3706
3707/**
3708 * hdd_get_station_statistics_cb() - Get stats callback function
3709 * @pStats: pointer to Class A stats
3710 * @pContext: user context originally registered with SME
3711 *
3712 * Return: None
3713 */
3714static void hdd_get_station_statistics_cb(void *pStats, void *pContext)
3715{
3716 struct statsContext *pStatsContext;
3717 tCsrSummaryStatsInfo *pSummaryStats;
3718 tCsrGlobalClassAStatsInfo *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303719 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 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);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303742 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
3743 (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003744 pStatsContext = pContext;
3745 pAdapter = pStatsContext->pAdapter;
3746 if ((NULL == pAdapter) ||
3747 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
3748 /* the caller presumably timed out so there is nothing
3749 * we can do
3750 */
3751 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07003752 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
3753 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003754 if (ioctl_debug) {
3755 pr_info("%s: Invalid context, pAdapter [%p] magic [%08x]\n",
3756 __func__, pAdapter, pStatsContext->magic);
3757 }
3758 return;
3759 }
3760
3761 /* context is valid so caller is still waiting */
3762
3763 /* paranoia: invalidate the magic */
3764 pStatsContext->magic = 0;
3765
3766 /* copy over the stats. do so as a struct copy */
3767 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
3768 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303769 pAdapter->hdd_stats.per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003770
3771 /* notify the caller */
3772 complete(&pStatsContext->completion);
3773
3774 /* serialization is complete */
3775 spin_unlock(&hdd_context_lock);
3776}
3777
3778/**
3779 * wlan_hdd_get_station_stats() - Get station statistics
3780 * @pAdapter: adapter for which statistics are desired
3781 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303782 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303784QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785{
3786 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303787 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 unsigned long rc;
3789 struct statsContext context;
3790
3791 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003792 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303793 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003794 }
3795
3796 /* we are connected so prepare our callback context */
3797 init_completion(&context.completion);
3798 context.pAdapter = pAdapter;
3799 context.magic = STATS_CONTEXT_MAGIC;
3800
3801 /* query only for Summary & Class A statistics */
3802 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3803 eCSR_HDD,
3804 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05303805 SME_GLOBAL_CLASSA_STATS |
3806 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 hdd_get_station_statistics_cb,
3808 0, /* not periodic */
3809 false, /* non-cached results */
3810 pHddStaCtx->conn_info.staId[0],
3811 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303812 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003813 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814 /* we'll return with cached values */
3815 } else {
3816 /* request was sent -- wait for the response */
3817 rc = wait_for_completion_timeout
3818 (&context.completion,
3819 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
3820
3821 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003822 hdd_err("SME timed out while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823 }
3824 }
3825
3826 /* either we never sent a request, we sent a request and
3827 * received a response or we sent a request and timed out. if
3828 * we never sent a request or if we sent a request and got a
3829 * response, we want to clear the magic out of paranoia. if
3830 * we timed out there is a race condition such that the
3831 * callback function could be executing at the same time we
3832 * are. of primary concern is if the callback function had
3833 * already verified the "magic" but had not yet set the
3834 * completion variable when a timeout occurred. we serialize
3835 * these activities by invalidating the magic while holding a
3836 * shared spinlock which will cause us to block if the
3837 * callback is currently executing
3838 */
3839 spin_lock(&hdd_context_lock);
3840 context.magic = 0;
3841 spin_unlock(&hdd_context_lock);
3842
3843 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303844 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845}
3846
3847/**
3848 * iw_get_linkspeed() - Get current link speed ioctl
3849 * @dev: device upon which the ioctl was received
3850 * @info: ioctl request information
3851 * @wrqu: ioctl request data
3852 * @extra: extra ioctl buffer
3853 *
3854 * Return: 0 on success, non-zero on error
3855 */
3856static int __iw_get_linkspeed(struct net_device *dev,
3857 struct iw_request_info *info,
3858 union iwreq_data *wrqu, char *extra)
3859{
3860 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3861 char *pLinkSpeed = (char *)extra;
3862 int len = sizeof(uint32_t) + 1;
3863 uint32_t link_speed = 0;
3864 hdd_context_t *hdd_ctx;
3865 int rc, valid;
3866
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08003867 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303868
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3870 valid = wlan_hdd_validate_context(hdd_ctx);
3871 if (0 != valid)
3872 return valid;
3873
3874 rc = wlan_hdd_get_link_speed(pAdapter, &link_speed);
3875 if (0 != rc) {
3876 return rc;
3877 }
3878
3879 wrqu->data.length = len;
3880 /* return the linkspeed as a string */
3881 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
3882 if ((rc < 0) || (rc >= len)) {
3883 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07003884 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885 return -EIO;
3886 }
3887
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303888 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 /* a value is being successfully returned */
3890 return 0;
3891}
3892
3893static int iw_get_linkspeed(struct net_device *dev,
3894 struct iw_request_info *info,
3895 union iwreq_data *wrqu, char *extra)
3896{
3897 int ret;
3898
3899 cds_ssr_protect(__func__);
3900 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
3901 cds_ssr_unprotect(__func__);
3902
3903 return ret;
3904}
3905
3906/**
3907 * wlan_hdd_change_country_code_callback() - Change country code callback
3908 * @context: opaque context originally passed to SME. All functions
3909 * which use this callback pass the adapter upon which the country
3910 * code change is active
3911 *
3912 * This function is registered as the callback function when
3913 * sme_change_country_code() is invoked. Callers of
3914 * sme_change_country_code() subsequently wait for the adapter's
3915 * @change_country_code completion variable, so all this function
3916 * needs to do is set that completion variable so that execution can
3917 * continue.
3918 *
3919 * Return: none
3920 */
3921void wlan_hdd_change_country_code_callback(void *context)
3922{
3923
3924 hdd_adapter_t *adapter = context;
3925
3926 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
3927 complete(&adapter->change_country_code);
3928
3929 return;
3930}
3931
3932/**
3933 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
3934 * @dev: device upon which the ioctl was received
3935 * @info: ioctl request information
3936 * @wrqu: ioctl request data
3937 * @extra: ioctl extra data
3938 *
3939 * Return: 0 on success, non-zero on error
3940 */
3941static int __iw_set_nick(struct net_device *dev,
3942 struct iw_request_info *info,
3943 union iwreq_data *wrqu, char *extra)
3944{
3945 hdd_adapter_t *adapter;
3946 hdd_context_t *hdd_ctx;
3947 int ret;
3948
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003949 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003950
3951 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3952 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3953 ret = wlan_hdd_validate_context(hdd_ctx);
3954 if (0 != ret)
3955 return ret;
3956
3957 return 0;
3958}
3959
3960/**
3961 * iw_set_nick() - SSR wrapper for __iw_set_nick
3962 * @dev: pointer to net_device
3963 * @info: pointer to iw_request_info
3964 * @wrqu: pointer to iwreq_data
3965 * @extra: extra
3966 *
3967 * Return: 0 on success, error number otherwise
3968 */
3969static int iw_set_nick(struct net_device *dev,
3970 struct iw_request_info *info,
3971 union iwreq_data *wrqu, char *extra)
3972{
3973 int ret;
3974
3975 cds_ssr_protect(__func__);
3976 ret = __iw_set_nick(dev, info, wrqu, extra);
3977 cds_ssr_unprotect(__func__);
3978
3979 return ret;
3980}
3981
3982/**
3983 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
3984 * @dev: device upon which the ioctl was received
3985 * @info: ioctl request information
3986 * @wrqu: ioctl request data
3987 * @extra: ioctl extra data
3988 *
3989 * Return: 0 on success, non-zero on error
3990 */
3991static int __iw_get_nick(struct net_device *dev,
3992 struct iw_request_info *info,
3993 union iwreq_data *wrqu, char *extra)
3994{
3995 hdd_adapter_t *adapter;
3996 hdd_context_t *hdd_ctx;
3997 int ret;
3998
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003999 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000
4001 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4002 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4003 ret = wlan_hdd_validate_context(hdd_ctx);
4004 if (0 != ret)
4005 return ret;
4006
4007 return 0;
4008}
4009
4010/**
4011 * iw_get_nick() - SSR wrapper for __iw_get_nick
4012 * @dev: pointer to net_device
4013 * @info: pointer to iw_request_info
4014 * @wrqu: pointer to iwreq_data
4015 * @extra: extra
4016 *
4017 * Return: 0 on success, error number otherwise
4018 */
4019static int iw_get_nick(struct net_device *dev,
4020 struct iw_request_info *info,
4021 union iwreq_data *wrqu, char *extra)
4022{
4023 int ret;
4024
4025 cds_ssr_protect(__func__);
4026 ret = __iw_get_nick(dev, info, wrqu, extra);
4027 cds_ssr_unprotect(__func__);
4028
4029 return ret;
4030}
4031
4032/**
4033 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
4034 * @dev: device upon which the ioctl was received
4035 * @info: ioctl request information
4036 * @wrqu: ioctl request data
4037 * @extra: ioctl extra data
4038 *
4039 * Return: 0 on success, non-zero on error
4040 */
4041static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4042 union iwreq_data *wrqu, char *extra)
4043{
4044 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4045 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4046 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4047 hdd_context_t *hdd_ctx;
4048 struct iw_point *encoderq = &(wrqu->encoding);
4049 uint32_t keyId;
4050 uint8_t key_length;
4051 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4052 bool fKeyPresent = 0;
4053 int i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304054 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 int ret;
4056
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004057 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058
4059 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4060 ret = wlan_hdd_validate_context(hdd_ctx);
4061 if (0 != ret)
4062 return ret;
4063
4064 keyId = encoderq->flags & IW_ENCODE_INDEX;
4065
4066 if (keyId) {
4067 if (keyId > MAX_WEP_KEYS) {
4068 return -EINVAL;
4069 }
4070
4071 fKeyPresent = 1;
4072 keyId--;
4073 } else {
4074 fKeyPresent = 0;
4075 }
4076
4077 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004078 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079 if (!fKeyPresent) {
4080
4081 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
4082
4083 if (pWextState->roamProfile.Keys.KeyMaterial[i])
4084 pWextState->roamProfile.Keys.
4085 KeyLength[i] = 0;
4086 }
4087 }
4088 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4089 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4090 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4091 eCSR_ENCRYPT_TYPE_NONE;
4092 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4093 eCSR_ENCRYPT_TYPE_NONE;
4094
4095 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4096 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4097
4098 if (eConnectionState_Associated ==
4099 pHddStaCtx->conn_info.connState) {
4100 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4101 status =
4102 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4103 pAdapter->sessionId,
4104 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304105 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 unsigned long rc;
4107 rc = wait_for_completion_timeout(&pAdapter->
4108 disconnect_comp_var,
4109 msecs_to_jiffies
4110 (WLAN_WAIT_TIME_DISCONNECT));
4111 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004112 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 }
4114 }
4115
4116 return status;
4117
4118 }
4119
4120 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004121 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122
4123 pHddStaCtx->conn_info.authType =
4124 (encoderq->
4125 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
4126 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4127
4128 }
4129
4130 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004131 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132
4133 key_length = wrqu->data.length;
4134
4135 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
4136
4137 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004138 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139 key_length);
4140
4141 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4142 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4143 pHddStaCtx->conn_info.authType)) {
4144 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4145 } else {
4146 encryptionType =
4147 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4148 }
4149 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004150 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004151 key_length);
4152
4153 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4154 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4155 pHddStaCtx->conn_info.authType)) {
4156 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4157 } else {
4158 encryptionType =
4159 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4160 }
4161 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004162 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 key_length);
4164 return -EINVAL;
4165 }
4166
4167 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4168 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4169 pWextState->roamProfile.EncryptionType.numEntries = 1;
4170 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4171 encryptionType;
4172 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4173 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4174 encryptionType;
4175
4176 if ((eConnectionState_NotConnected ==
4177 pHddStaCtx->conn_info.connState)
4178 &&
4179 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4180 pHddStaCtx->conn_info.authType)
4181 || (eCSR_AUTH_TYPE_SHARED_KEY ==
4182 pHddStaCtx->conn_info.authType))) {
4183
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304184 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 KeyMaterial[keyId][0], extra, key_length);
4186
4187 pWextState->roamProfile.Keys.KeyLength[keyId] =
4188 (uint8_t) key_length;
4189 pWextState->roamProfile.Keys.defaultIndex =
4190 (uint8_t) keyId;
4191
4192 return status;
4193 }
4194 }
4195
4196 return 0;
4197}
4198
4199/**
4200 * iw_set_encode() - SSR wrapper for __iw_set_encode()
4201 * @dev: pointer to net_device
4202 * @info: pointer to iw_request_info
4203 * @wrqu: pointer to iwreq_data
4204 * @extra: pointer to extra ioctl payload
4205 *
4206 * Return: 0 on success, error number otherwise
4207 */
4208static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4209 union iwreq_data *wrqu, char *extra)
4210{
4211 int ret;
4212
4213 cds_ssr_protect(__func__);
4214 ret = __iw_set_encode(dev, info, wrqu, extra);
4215 cds_ssr_unprotect(__func__);
4216
4217 return ret;
4218}
4219
4220/**
4221 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
4222 * @dev: device upon which the ioctl was received
4223 * @info: ioctl request information
4224 * @wrqu: ioctl request data
4225 * @extra: ioctl extra data
4226 *
4227 * Return: 0 on success, non-zero on error
4228 */
4229static int __iw_get_encodeext(struct net_device *dev,
4230 struct iw_request_info *info,
4231 struct iw_point *dwrq, char *extra)
4232{
4233 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4234 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4235 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4236 int keyId;
4237 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4238 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4239 int i, ret;
4240 hdd_context_t *hdd_ctx;
4241
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004242 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243
4244 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4245 ret = wlan_hdd_validate_context(hdd_ctx);
4246 if (0 != ret)
4247 return ret;
4248
4249 keyId = pRoamProfile->Keys.defaultIndex;
4250
4251 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004252 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 return -EINVAL;
4254 }
4255
4256 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
4257 dwrq->flags |= IW_ENCODE_ENABLED;
4258 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304259 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 pRoamProfile->Keys.KeyLength[keyId]);
4261 } else {
4262 dwrq->flags |= IW_ENCODE_DISABLED;
4263 }
4264
4265 for (i = 0; i < MAX_WEP_KEYS; i++) {
4266 if (pRoamProfile->Keys.KeyMaterial[i] == NULL) {
4267 continue;
4268 } else {
4269 break;
4270 }
4271 }
4272
4273 if (MAX_WEP_KEYS == i) {
4274 dwrq->flags |= IW_ENCODE_NOKEY;
4275 } else {
4276 dwrq->flags |= IW_ENCODE_ENABLED;
4277 }
4278
4279 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4280
4281 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
4282 dwrq->flags |= IW_ENCODE_DISABLED;
4283 }
4284
4285 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4286
4287 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
4288 dwrq->flags |= IW_ENCODE_OPEN;
4289 } else {
4290 dwrq->flags |= IW_ENCODE_RESTRICTED;
4291 }
4292 EXIT();
4293 return 0;
4294
4295}
4296
4297/**
4298 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
4299 * @dev: pointer to net_device
4300 * @info: pointer to iw_request_info
4301 * @dwrq: pointer to encoding information
4302 * @extra: pointer to extra ioctl payload
4303 *
4304 * Return: 0 on success, error number otherwise
4305 */
4306static int iw_get_encodeext(struct net_device *dev,
4307 struct iw_request_info *info,
4308 struct iw_point *dwrq, char *extra)
4309{
4310 int ret;
4311
4312 cds_ssr_protect(__func__);
4313 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4314 cds_ssr_unprotect(__func__);
4315
4316 return ret;
4317}
4318
4319/**
4320 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
4321 * @dev: device upon which the ioctl was received
4322 * @info: ioctl request information
4323 * @wrqu: ioctl request data
4324 * @extra: ioctl extra data
4325 *
4326 * Return: 0 on success, non-zero on error
4327 */
4328static int __iw_set_encodeext(struct net_device *dev,
4329 struct iw_request_info *info,
4330 union iwreq_data *wrqu, char *extra)
4331{
4332 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4333 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4334 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4335 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304336 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4338 int ret;
4339 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4340 int key_index;
4341 struct iw_point *encoding = &wrqu->encoding;
4342 tCsrRoamSetKey setKey;
4343 uint32_t roamId = 0xFF;
4344
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004345 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346
4347 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4348 ret = wlan_hdd_validate_context(hdd_ctx);
4349 if (0 != ret)
4350 return ret;
4351
4352 key_index = encoding->flags & IW_ENCODE_INDEX;
4353
4354 if (key_index > 0) {
4355
4356 /*Convert from 1-based to 0-based keying */
4357 key_index--;
4358 }
4359 if (!ext->key_len) {
4360
4361 /*Set the encrytion type to NONE */
4362 pRoamProfile->EncryptionType.encryptionType[0] =
4363 eCSR_ENCRYPT_TYPE_NONE;
4364 return ret;
4365 }
4366
4367 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4368 (IW_ENCODE_ALG_WEP == ext->alg)) {
4369 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4370
Jeff Johnson99bac312016-06-28 10:38:18 -07004371 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004372 return -EINVAL;
4373 } else {
4374 /*Static wep, update the roam profile with the keys */
4375 if (ext->key
4376 && (ext->key_len <=
4377 eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES)
4378 && key_index < CSR_MAX_NUM_KEY) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304379 qdf_mem_copy(&pRoamProfile->Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 KeyMaterial[key_index][0],
4381 ext->key, ext->key_len);
4382 pRoamProfile->Keys.KeyLength[key_index] =
4383 (uint8_t) ext->key_len;
4384
4385 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4386 pRoamProfile->Keys.defaultIndex =
4387 (uint8_t) key_index;
4388
4389 }
4390 }
4391 return ret;
4392 }
4393
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304394 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395
4396 setKey.keyId = key_index;
4397 setKey.keyLength = ext->key_len;
4398
4399 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304400 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 }
4402
4403 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4404 /*Key direction for group is RX only */
4405 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05304406 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407 } else {
4408
4409 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304410 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304411 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 }
4413
4414 /*For supplicant pae role is zero */
4415 setKey.paeRole = 0;
4416
4417 switch (ext->alg) {
4418 case IW_ENCODE_ALG_NONE:
4419 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4420 break;
4421
4422 case IW_ENCODE_ALG_WEP:
4423 setKey.encType =
4424 (ext->key_len ==
4425 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
4426 break;
4427
4428 case IW_ENCODE_ALG_TKIP:
4429 {
4430 uint8_t *pKey = &setKey.Key[0];
4431
4432 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
4433
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304434 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435
4436 /* Supplicant sends the 32bytes key in this order
4437 * |--------------|----------|----------|
4438 * | Tk1 | TX MIC | RX MIC |
4439 * |--------------|----------|----------|
4440 * <---16bytes---><--8bytes--><--8bytes-->
4441 *
4442 *
4443 * Sme expects the 32 bytes key to be in the below order
4444 * |--------------|----------|----------|
4445 * | Tk1 | RX MIC | TX MIC |
4446 * |--------------|----------|----------|
4447 * <---16bytes---><--8bytes--><--8bytes-->
4448 */
4449
4450 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304451 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452
4453 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304454 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455
4456 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304457 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458
4459 }
4460 break;
4461
4462 case IW_ENCODE_ALG_CCMP:
4463 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
4464 break;
4465
4466#ifdef FEATURE_WLAN_ESE
4467#define IW_ENCODE_ALG_KRK 6
4468 case IW_ENCODE_ALG_KRK:
4469 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
4470 break;
4471#endif /* FEATURE_WLAN_ESE */
4472
4473 default:
4474 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4475 break;
4476 }
4477
Jeff Johnson99bac312016-06-28 10:38:18 -07004478 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
4479 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 /* The supplicant may attempt to set the PTK once
4482 * pre-authentication is done. Save the key in the UMAC and
4483 * include it in the ADD BSS request
4484 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304485 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304487 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004488 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004489 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304490 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004491 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492 return -EINVAL;
4493 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494
4495 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4496
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304497 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 pAdapter->sessionId,
4499 &setKey, &roamId);
4500
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304501 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004502 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304503 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504
4505 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4506 }
4507
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304508 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509}
4510
4511/**
4512 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
4513 * @dev: pointer to net_device
4514 * @info: pointer to iw_request_info
4515 * @wrqu: pointer to iwreq_data
4516 * @extra: pointer to extra ioctl payload
4517 *
4518 * Return: 0 on success, error number otherwise
4519 */
4520static int iw_set_encodeext(struct net_device *dev,
4521 struct iw_request_info *info,
4522 union iwreq_data *wrqu, char *extra)
4523{
4524 int ret;
4525
4526 cds_ssr_protect(__func__);
4527 ret = __iw_set_encodeext(dev, info, wrqu, extra);
4528 cds_ssr_unprotect(__func__);
4529
4530 return ret;
4531}
4532
4533/**
4534 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
4535 * @dev: device upon which the ioctl was received
4536 * @info: ioctl request information
4537 * @wrqu: ioctl request data
4538 * @extra: ioctl extra data
4539 *
4540 * Return: 0 on success, non-zero on error
4541 */
4542static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4543 union iwreq_data *wrqu, char *extra)
4544{
4545 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4546 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4547 hdd_context_t *hdd_ctx;
4548 int ret;
4549
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004550 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551
4552 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4553 ret = wlan_hdd_validate_context(hdd_ctx);
4554 if (0 != ret)
4555 return ret;
4556
4557 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
4558 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
4559
Jeff Johnson99bac312016-06-28 10:38:18 -07004560 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561
4562 return -EINVAL;
4563 }
4564
4565 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
4566
4567 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4568 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
4569 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304570 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004571 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 return -EIO;
4573 }
4574 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4575 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
4576 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304577 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004578 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 return -EIO;
4580 }
4581 }
4582 } else {
4583 return -EOPNOTSUPP;
4584 }
4585
Jeff Johnson99bac312016-06-28 10:38:18 -07004586 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587
4588 EXIT();
4589
4590 return 0;
4591
4592}
4593
4594/**
4595 * iw_set_retry() - SSR wrapper for __iw_set_retry()
4596 * @dev: pointer to net_device
4597 * @info: pointer to iw_request_info
4598 * @wrqu: pointer to iwreq_data
4599 * @extra: pointer to extra ioctl payload
4600 *
4601 * Return: 0 on success, error number otherwise
4602 */
4603static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
4604 union iwreq_data *wrqu, char *extra)
4605{
4606 int ret;
4607
4608 cds_ssr_protect(__func__);
4609 ret = __iw_set_retry(dev, info, wrqu, extra);
4610 cds_ssr_unprotect(__func__);
4611
4612 return ret;
4613}
4614
4615/**
4616 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
4617 * @dev: device upon which the ioctl was received
4618 * @info: ioctl request information
4619 * @wrqu: ioctl request data
4620 * @extra: ioctl extra data
4621 *
4622 * Return: 0 on success, non-zero on error
4623 */
4624static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4625 union iwreq_data *wrqu, char *extra)
4626{
4627 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4628 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4629 uint32_t retry = 0;
4630 hdd_context_t *hdd_ctx;
4631 int ret;
4632
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004633 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634
4635 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4636 ret = wlan_hdd_validate_context(hdd_ctx);
4637 if (0 != ret)
4638 return ret;
4639
4640 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
4641 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
4642
4643 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304644 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004645 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 return -EIO;
4647 }
4648
4649 wrqu->retry.value = retry;
4650 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
4651 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
4652
4653 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304654 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004655 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 return -EIO;
4657 }
4658
4659 wrqu->retry.value = retry;
4660 } else {
4661 return -EOPNOTSUPP;
4662 }
4663
Jeff Johnson99bac312016-06-28 10:38:18 -07004664 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665
4666 EXIT();
4667
4668 return 0;
4669}
4670
4671/**
4672 * iw_get_retry() - SSR wrapper for __iw_get_retry()
4673 * @dev: pointer to net_device
4674 * @info: pointer to iw_request_info
4675 * @wrqu: pointer to iwreq_data
4676 * @extra: pointer to extra ioctl payload
4677 *
4678 * Return: 0 on success, error number otherwise
4679 */
4680static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
4681 union iwreq_data *wrqu, char *extra)
4682{
4683 int ret;
4684
4685 cds_ssr_protect(__func__);
4686 ret = __iw_get_retry(dev, info, wrqu, extra);
4687 cds_ssr_unprotect(__func__);
4688
4689 return ret;
4690}
4691
4692/**
4693 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
4694 * @dev: device upon which the ioctl was received
4695 * @info: ioctl request information
4696 * @wrqu: ioctl request data
4697 * @extra: ioctl extra data
4698 *
4699 * Return: 0 on success, non-zero on error
4700 */
4701static int __iw_set_mlme(struct net_device *dev,
4702 struct iw_request_info *info,
4703 union iwreq_data *wrqu, char *extra)
4704{
4705 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4706 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4707 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304708 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709 hdd_context_t *hdd_ctx;
4710 int ret;
4711
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004712 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004713
4714 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4715 ret = wlan_hdd_validate_context(hdd_ctx);
4716 if (0 != ret)
4717 return ret;
4718
4719 /* reason_code is unused. By default it is set to
4720 * eCSR_DISCONNECT_REASON_UNSPECIFIED
4721 */
4722 switch (mlme->cmd) {
4723 case IW_MLME_DISASSOC:
4724 case IW_MLME_DEAUTH:
4725
4726 if (pHddStaCtx->conn_info.connState ==
4727 eConnectionState_Associated) {
4728 eCsrRoamDisconnectReason reason =
4729 eCSR_DISCONNECT_REASON_UNSPECIFIED;
4730
4731 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
4732 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
4733
4734 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4735 status =
4736 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4737 pAdapter->sessionId, reason);
4738
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304739 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004740 unsigned long rc;
4741 rc = wait_for_completion_timeout(&pAdapter->
4742 disconnect_comp_var,
4743 msecs_to_jiffies
4744 (WLAN_WAIT_TIME_DISCONNECT));
4745 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004746 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07004748 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
4749 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004750
4751 /* Resetting authKeyMgmt */
4752 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
4753 0;
4754
Jeff Johnson99bac312016-06-28 10:38:18 -07004755 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004756 wlan_hdd_netif_queue_control(pAdapter,
4757 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4758 WLAN_CONTROL_PATH);
4759
4760 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004761 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
4762 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 }
4764 break;
4765 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004766 hdd_err("%d Command should be Disassociate/Deauthenticate",
4767 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768 return -EINVAL;
4769 } /* end of switch */
4770
4771 EXIT();
4772
4773 return status;
4774
4775}
4776
4777/**
4778 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
4779 * @dev: pointer to net_device
4780 * @info: pointer to iw_request_info
4781 * @wrqu: pointer to iwreq_data
4782 * @extra: pointer to extra ioctl payload
4783 *
4784 * Return: 0 on success, error number otherwise
4785 */
4786static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
4787 union iwreq_data *wrqu, char *extra)
4788{
4789 int ret;
4790
4791 cds_ssr_protect(__func__);
4792 ret = __iw_set_mlme(dev, info, wrqu, extra);
4793 cds_ssr_unprotect(__func__);
4794
4795 return ret;
4796}
4797
4798/**
4799 * wlan_hdd_update_phymode() - handle change in PHY mode
4800 * @net: device upon which PHY mode change was received
4801 * @hal: umac handle for the driver
4802 * @new_phymode: new PHY mode for the device
4803 * @phddctx: pointer to the HDD context
4804 *
4805 * This function is called when the device is set to a new PHY mode.
4806 * It takes a holistic look at the desired PHY mode along with the
4807 * configured capabilities of the driver and the reported capabilities
4808 * of the hardware in order to correctly configure all PHY-related
4809 * parameters.
4810 *
4811 * Return: 0 on success, negative errno value on error
4812 */
4813int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
4814 int new_phymode, hdd_context_t *phddctx)
4815{
4816#ifdef QCA_HT_2040_COEX
4817 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304818 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004819#endif
4820 bool band_24 = false, band_5g = false;
4821 bool ch_bond24 = false, ch_bond5g = false;
4822 tSmeConfigParams smeconfig;
4823 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004824 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825 eCsrPhyMode phymode = -EIO, old_phymode;
4826 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
4827 eCsrBand curr_band = eCSR_BAND_ALL;
4828
4829 old_phymode = sme_get_phy_mode(hal);
4830
4831 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4832 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4833 nChannelBondingMode24GHz))
4834 ch_bond24 = true;
4835
4836 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
4837 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
4838 nChannelBondingMode5GHz))
4839 ch_bond5g = true;
4840
4841 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
4842 band_24 = band_5g = true;
4843 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
4844 band_24 = true;
4845 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
4846 band_5g = true;
4847 }
4848
4849 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07004850 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 -08004851 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
4852
4853 switch (new_phymode) {
4854 case IEEE80211_MODE_AUTO:
4855 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4856 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
4857 phymode = eCSR_DOT11_MODE_AUTO;
4858 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4859 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4860 curr_band = eCSR_BAND_ALL;
4861 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4862 } else {
4863 sme_set_phy_mode(hal, old_phymode);
4864 return -EIO;
4865 }
4866 break;
4867 case IEEE80211_MODE_11A:
4868 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
4869 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4870 phymode = eCSR_DOT11_MODE_11a;
4871 hdd_dot11mode = eHDD_DOT11_MODE_11a;
4872 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4873 curr_band = eCSR_BAND_5G;
4874 } else {
4875 sme_set_phy_mode(hal, old_phymode);
4876 return -EIO;
4877 }
4878 break;
4879 case IEEE80211_MODE_11B:
4880 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
4881 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4882 phymode = eCSR_DOT11_MODE_11b;
4883 hdd_dot11mode = eHDD_DOT11_MODE_11b;
4884 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4885 curr_band = eCSR_BAND_24;
4886 } else {
4887 sme_set_phy_mode(hal, old_phymode);
4888 return -EIO;
4889 }
4890 break;
4891 case IEEE80211_MODE_11G:
4892 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
4893 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4894 phymode = eCSR_DOT11_MODE_11g;
4895 hdd_dot11mode = eHDD_DOT11_MODE_11g;
4896 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4897 curr_band = eCSR_BAND_24;
4898 } else {
4899 sme_set_phy_mode(hal, old_phymode);
4900 return -EIO;
4901 }
4902 break;
4903 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
4904 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
4905 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
4906 */
4907 case IEEE80211_MODE_11NA_HT20:
4908 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4909 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4910 phymode = eCSR_DOT11_MODE_11n;
4911 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4912 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4913 curr_band = eCSR_BAND_5G;
4914 } else {
4915 sme_set_phy_mode(hal, old_phymode);
4916 return -EIO;
4917 }
4918 break;
4919 case IEEE80211_MODE_11NA_HT40:
4920 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4921 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4922 phymode = eCSR_DOT11_MODE_11n;
4923 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4924 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4925 curr_band = eCSR_BAND_5G;
4926 } else {
4927 sme_set_phy_mode(hal, old_phymode);
4928 return -EIO;
4929 }
4930 break;
4931 case IEEE80211_MODE_11NG_HT20:
4932 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4933 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4934 phymode = eCSR_DOT11_MODE_11n;
4935 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4936 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4937 curr_band = eCSR_BAND_24;
4938 } else {
4939 sme_set_phy_mode(hal, old_phymode);
4940 return -EIO;
4941 }
4942 break;
4943 case IEEE80211_MODE_11NG_HT40:
4944 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4945 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4946 phymode = eCSR_DOT11_MODE_11n;
4947 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4948 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4949 curr_band = eCSR_BAND_24;
4950 } else {
4951 sme_set_phy_mode(hal, old_phymode);
4952 return -EIO;
4953 }
4954 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 case IEEE80211_MODE_11AC_VHT20:
4956 case IEEE80211_MODE_11AC_VHT40:
4957 case IEEE80211_MODE_11AC_VHT80:
4958 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
4959 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4960 phymode = eCSR_DOT11_MODE_11ac;
4961 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
4962 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4963 curr_band = eCSR_BAND_5G;
4964 } else {
4965 sme_set_phy_mode(hal, old_phymode);
4966 return -EIO;
4967 }
4968 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969 case IEEE80211_MODE_2G_AUTO:
4970 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4971 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
4972 phymode = eCSR_DOT11_MODE_AUTO;
4973 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4974 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4975 curr_band = eCSR_BAND_24;
4976 } else {
4977 sme_set_phy_mode(hal, old_phymode);
4978 return -EIO;
4979 }
4980 break;
4981 case IEEE80211_MODE_5G_AUTO:
4982 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
4983 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
4984 phymode = eCSR_DOT11_MODE_AUTO;
4985 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
4986 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
4987 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
4988 curr_band = eCSR_BAND_5G;
4989 } else {
4990 sme_set_phy_mode(hal, old_phymode);
4991 return -EIO;
4992 }
4993 break;
4994 case IEEE80211_MODE_11AGN:
4995 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
4996 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
4997 phymode = eCSR_DOT11_MODE_11n;
4998 hdd_dot11mode = eHDD_DOT11_MODE_11n;
4999 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5000 curr_band = eCSR_BAND_ALL;
5001 } else {
5002 sme_set_phy_mode(hal, old_phymode);
5003 return -EIO;
5004 }
5005 break;
5006 default:
5007 return -EIO;
5008 }
5009
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010 switch (new_phymode) {
5011 case IEEE80211_MODE_11AC_VHT20:
5012 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5013 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5014 break;
5015 case IEEE80211_MODE_11AC_VHT40:
5016 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5017 break;
5018 case IEEE80211_MODE_11AC_VHT80:
5019 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5020 break;
5021 default:
5022 vhtchanwidth = phddctx->config->vhtChannelWidth;
5023 break;
5024 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005025
5026 if (phymode != -EIO) {
5027 sme_get_config_param(hal, &smeconfig);
5028 smeconfig.csrConfig.phyMode = phymode;
5029#ifdef QCA_HT_2040_COEX
5030 if (phymode == eCSR_DOT11_MODE_11n &&
5031 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
5032 smeconfig.csrConfig.obssEnabled = false;
5033 halStatus = sme_set_ht2040_mode(hal,
5034 pAdapter->sessionId,
5035 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305036 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005037 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 return -EIO;
5039 }
5040 } else if (phymode == eCSR_DOT11_MODE_11n &&
5041 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
5042 smeconfig.csrConfig.obssEnabled = true;
5043 halStatus = sme_set_ht2040_mode(hal,
5044 pAdapter->sessionId,
5045 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305046 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005047 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048 return -EIO;
5049 }
5050 }
5051#endif
5052 smeconfig.csrConfig.eBand = curr_band;
5053 smeconfig.csrConfig.bandCapability = curr_band;
5054 if (curr_band == eCSR_BAND_24)
5055 smeconfig.csrConfig.Is11hSupportEnabled = 0;
5056 else
5057 smeconfig.csrConfig.Is11hSupportEnabled =
5058 phddctx->config->Is11hSupportEnabled;
5059 if (curr_band == eCSR_BAND_24)
5060 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5061 else if (curr_band == eCSR_BAND_24)
5062 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5063 else {
5064 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5065 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5066 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005067 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005068 sme_update_config(hal, &smeconfig);
5069
5070 phddctx->config->dot11Mode = hdd_dot11mode;
5071 phddctx->config->nBandCapability = curr_band;
5072 phddctx->config->nChannelBondingMode24GHz =
5073 smeconfig.csrConfig.channelBondingMode24GHz;
5074 phddctx->config->nChannelBondingMode5GHz =
5075 smeconfig.csrConfig.channelBondingMode5GHz;
5076 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005077 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005078 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079 return -EIO;
5080 }
5081 if (phddctx->config->nChannelBondingMode5GHz)
5082 phddctx->wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap.cap
5083 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5084 else
5085 phddctx->wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap.cap
5086 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5087
Jeff Johnson99bac312016-06-28 10:38:18 -07005088 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005089 phymode, chwidth, curr_band, vhtchanwidth);
5090 }
5091
5092 return 0;
5093}
5094
5095/**
5096 * hdd_get_temperature_cb() - "Get Temperature" callback function
5097 * @temperature: measured temperature
5098 * @pContext: callback context
5099 *
5100 * This function is passed to sme_get_temperature() as the callback
5101 * function to be invoked when the temperature measurement is
5102 * available.
5103 *
5104 * Return: None
5105 */
5106static void hdd_get_temperature_cb(int temperature, void *pContext)
5107{
5108 struct statsContext *pTempContext;
5109 hdd_adapter_t *pAdapter;
5110 ENTER();
5111 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005112 hdd_err("pContext is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005113 return;
5114 }
5115 pTempContext = pContext;
5116 pAdapter = pTempContext->pAdapter;
5117 spin_lock(&hdd_context_lock);
5118 if ((NULL == pAdapter) || (TEMP_CONTEXT_MAGIC != pTempContext->magic)) {
5119 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07005120 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 pAdapter, pTempContext->magic);
5122 return;
5123 }
5124 if (temperature != 0) {
5125 pAdapter->temperature = temperature;
5126 }
5127 complete(&pTempContext->completion);
5128 spin_unlock(&hdd_context_lock);
5129 EXIT();
5130}
5131
5132/**
5133 * wlan_hdd_get_temperature() - get current device temperature
5134 * @pAdapter: device upon which the request was made
5135 * @temperature: pointer to where the temperature is to be returned
5136 *
5137 * Return: 0 if a temperature value (either current or cached) was
5138 * returned, otherwise a negative errno is returned.
5139 *
5140 */
5141int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
5142{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305143 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144 struct statsContext tempContext;
5145 unsigned long rc;
5146
5147 ENTER();
5148 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005149 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 return -EPERM;
5151 }
5152 init_completion(&tempContext.completion);
5153 tempContext.pAdapter = pAdapter;
5154 tempContext.magic = TEMP_CONTEXT_MAGIC;
5155 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
5156 &tempContext, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305157 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005158 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005159 } else {
5160 rc = wait_for_completion_timeout(&tempContext.completion,
5161 msecs_to_jiffies
5162 (WLAN_WAIT_TIME_STATS));
5163 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005164 hdd_err("SME timed out while retrieving temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165 }
5166 }
5167 spin_lock(&hdd_context_lock);
5168 tempContext.magic = 0;
5169 spin_unlock(&hdd_context_lock);
5170 *temperature = pAdapter->temperature;
5171 EXIT();
5172 return 0;
5173}
5174
5175/**
5176 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5177 * @dev: device upon which the ioctl was received
5178 * @info: ioctl request information
5179 * @wrqu: ioctl request data
5180 * @extra: ioctl extra data
5181 *
5182 * Return: 0 on success, non-zero on error
5183 */
5184static int __iw_setint_getnone(struct net_device *dev,
5185 struct iw_request_info *info,
5186 union iwreq_data *wrqu, char *extra)
5187{
5188 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5189 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5190 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5191 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5192 hdd_context_t *hdd_ctx;
5193 tSmeConfigParams smeConfig;
5194 int *value = (int *)extra;
5195 int sub_cmd = value[0];
5196 int set_value = value[1];
5197 int ret;
5198 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305199 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005201 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305202
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005203 INIT_COMPLETION(pWextState->completion_var);
Mukul Sharma81661ae2015-10-30 20:26:02 +05305204 memset(&smeConfig, 0x00, sizeof(smeConfig));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205
5206 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5207 ret = wlan_hdd_validate_context(hdd_ctx);
5208 if (0 != ret)
5209 return ret;
5210
5211 switch (sub_cmd) {
5212 case WE_SET_11D_STATE:
5213 {
5214 if ((ENABLE_11D == set_value)
5215 || (DISABLE_11D == set_value)) {
5216
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217 sme_get_config_param(hHal, &smeConfig);
5218 smeConfig.csrConfig.Is11dSupportEnabled =
5219 (bool) set_value;
5220
Jeff Johnson99bac312016-06-28 10:38:18 -07005221 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222 smeConfig.csrConfig.
5223 Is11dSupportEnabled);
5224
5225 sme_update_config(hHal, &smeConfig);
5226 } else {
5227 return -EINVAL;
5228 }
5229 break;
5230 }
5231
5232 case WE_WOWL:
5233 {
5234 switch (set_value) {
5235 case 0x00:
5236 hdd_exit_wowl(pAdapter);
5237 break;
5238 case 0x01:
5239 case 0x02:
5240 case 0x03:
5241 enable_mp = (set_value & 0x01) ? 1 : 0;
5242 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005243 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244 (enable_mp ? "YES" : "NO"),
5245 (enable_pbm ? "YES" : "NO"));
5246 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5247 break;
5248 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005249 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005250 set_value);
5251 ret = -EINVAL;
5252 break;
5253 }
5254
5255 break;
5256 }
5257 case WE_SET_POWER:
5258 {
5259 switch (set_value) {
5260 case 1:
5261 /* Enable PowerSave */
5262 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5263 SME_PS_ENABLE);
5264 break;
5265 case 2:
5266 /* Disable PowerSave */
5267 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5268 SME_PS_DISABLE);
5269 break;
5270 case 3: /* Enable UASPD */
5271 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
5272 break;
5273 case 4: /* Disable UASPD */
5274 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
5275 break;
5276 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005277 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278 set_value);
5279 ret = -EINVAL;
5280 break;
5281 }
5282 break;
5283 }
5284
5285 case WE_SET_MAX_ASSOC:
5286 {
5287 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5288 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5289 ret = -EINVAL;
5290 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5291 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305292 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005293 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 ret = -EIO;
5295 }
5296 break;
5297 }
5298
5299 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5300 if (set_value == 0 || set_value == 1)
5301 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
5302 set_value;
5303 else
5304 ret = -EINVAL;
5305 break;
5306
5307 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5309 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5310 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5311 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305312 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005313 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314 ret = -EINVAL;
5315 }
5316 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 case WE_SET_MC_RATE:
5318 {
5319 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
5320 break;
5321 }
5322 case WE_SET_TX_POWER:
5323 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305324 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005325
Anurag Chouhanc5548422016-02-24 18:33:27 +05305326 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327 if (sme_set_tx_power
5328 (hHal, pAdapter->sessionId, bssid,
5329 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305330 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005331 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332 return -EIO;
5333 }
5334 break;
5335 }
5336 case WE_SET_MAX_TX_POWER:
5337 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305338 struct qdf_mac_addr bssid;
5339 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340
Jeff Johnson99bac312016-06-28 10:38:18 -07005341 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005342 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305343 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
5344 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345
5346 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305347 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005348 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 return -EIO;
5350 }
5351
5352 break;
5353 }
5354 case WE_SET_MAX_TX_POWER_2_4:
5355 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005356 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
5357 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005358 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305359 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005360 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005361 return -EIO;
5362 }
5363
5364 break;
5365 }
5366 case WE_SET_MAX_TX_POWER_5_0:
5367 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005368 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
5369 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305371 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005372 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005373 return -EIO;
5374 }
5375
5376 break;
5377 }
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -08005378 case WE_SET_PKTLOG:
5379 {
5380 hdd_process_pktlog_command(hdd_ctx, set_value);
5381 break;
5382 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 case WE_SET_HIGHER_DTIM_TRANSITION:
5384 {
5385 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005386 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387 set_value);
5388 ret = -EINVAL;
5389 } else {
5390 if (pAdapter->higherDtimTransition != set_value) {
5391 pAdapter->higherDtimTransition =
5392 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07005393 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 pAdapter->higherDtimTransition);
5395 }
5396 }
5397
5398 break;
5399 }
5400
5401 case WE_SET_TM_LEVEL:
5402 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005403 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005404 (void)sme_set_thermal_level(hHal, set_value);
5405 break;
5406 }
5407
5408 case WE_SET_PHYMODE:
5409 {
5410 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5411
5412 ret =
5413 wlan_hdd_update_phymode(dev, hHal, set_value,
5414 phddctx);
5415 break;
5416 }
5417
5418 case WE_SET_NSS:
5419 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005420 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005421 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005422 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 ret = -EINVAL;
5424 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305425 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005426 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
5427 set_value))
5428 ret = -EINVAL;
5429 }
5430 break;
5431 }
5432
5433 case WE_SET_GTX_HT_MCS:
5434 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005435 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005436 ret = wma_cli_set_command(pAdapter->sessionId,
5437 WMI_VDEV_PARAM_GTX_HT_MCS,
5438 set_value, GTX_CMD);
5439 break;
5440 }
5441
5442 case WE_SET_GTX_VHT_MCS:
5443 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005444 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 set_value);
5446 ret = wma_cli_set_command(pAdapter->sessionId,
5447 WMI_VDEV_PARAM_GTX_VHT_MCS,
5448 set_value, GTX_CMD);
5449 break;
5450 }
5451
5452 case WE_SET_GTX_USRCFG:
5453 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005454 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455 set_value);
5456 ret = wma_cli_set_command(pAdapter->sessionId,
5457 WMI_VDEV_PARAM_GTX_USR_CFG,
5458 set_value, GTX_CMD);
5459 break;
5460 }
5461
5462 case WE_SET_GTX_THRE:
5463 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005464 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465 ret = wma_cli_set_command(pAdapter->sessionId,
5466 WMI_VDEV_PARAM_GTX_THRE,
5467 set_value, GTX_CMD);
5468 break;
5469 }
5470
5471 case WE_SET_GTX_MARGIN:
5472 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005473 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005474 ret = wma_cli_set_command(pAdapter->sessionId,
5475 WMI_VDEV_PARAM_GTX_MARGIN,
5476 set_value, GTX_CMD);
5477 break;
5478 }
5479
5480 case WE_SET_GTX_STEP:
5481 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005482 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483 ret = wma_cli_set_command(pAdapter->sessionId,
5484 WMI_VDEV_PARAM_GTX_STEP,
5485 set_value, GTX_CMD);
5486 break;
5487 }
5488
5489 case WE_SET_GTX_MINTPC:
5490 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005491 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005492 ret = wma_cli_set_command(pAdapter->sessionId,
5493 WMI_VDEV_PARAM_GTX_MINTPC,
5494 set_value, GTX_CMD);
5495 break;
5496 }
5497
5498 case WE_SET_GTX_BWMASK:
5499 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005500 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005501 ret = wma_cli_set_command(pAdapter->sessionId,
5502 WMI_VDEV_PARAM_GTX_BW_MASK,
5503 set_value, GTX_CMD);
5504 break;
5505 }
5506
5507 case WE_SET_LDPC:
5508 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305509 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005510 break;
5511 }
5512
5513 case WE_SET_TX_STBC:
5514 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305515 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 break;
5517 }
5518
5519 case WE_SET_RX_STBC:
5520 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05305521 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 break;
5523 }
5524
5525 case WE_SET_SHORT_GI:
5526 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005527 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005528 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
5529 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
5530 set_value);
5531 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07005532 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005533 break;
5534 }
5535
5536 case WE_SET_RTSCTS:
5537 {
5538 uint32_t value;
5539
Jeff Johnson99bac312016-06-28 10:38:18 -07005540 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541 set_value);
5542
5543 if ((set_value & HDD_RTSCTS_EN_MASK) ==
5544 HDD_RTSCTS_ENABLE)
5545 value =
5546 (WLAN_HDD_GET_CTX(pAdapter))->config->
5547 RTSThreshold;
5548 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
5549 || ((set_value & HDD_RTSCTS_EN_MASK) ==
5550 HDD_CTS_ENABLE))
5551 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
5552 else
5553 return -EIO;
5554
5555 ret = wma_cli_set_command(pAdapter->sessionId,
5556 WMI_VDEV_PARAM_ENABLE_RTSCTS,
5557 set_value, VDEV_CMD);
5558 if (!ret) {
5559 if (sme_cfg_set_int
5560 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305561 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005562 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005563 return -EIO;
5564 }
5565 }
5566
5567 break;
5568 }
5569
5570 case WE_SET_CHWIDTH:
5571 {
5572 bool chwidth = false;
5573 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5574 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07005575 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 set_value);
5577 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005578 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005579 return -EINVAL;
5580 }
5581
5582 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5583 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
5584 nChannelBondingMode5GHz)))
5585 chwidth = true;
5586
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005587 sme_get_config_param(hHal, &smeConfig);
5588 switch (set_value) {
5589 case eHT_CHANNEL_WIDTH_20MHZ:
5590 smeConfig.csrConfig.channelBondingMode5GHz =
5591 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5592 break;
5593 case eHT_CHANNEL_WIDTH_40MHZ:
5594 if (chwidth)
5595 smeConfig.csrConfig.
5596 channelBondingMode5GHz =
5597 phddctx->config->
5598 nChannelBondingMode5GHz;
5599 else
5600 return -EINVAL;
5601
5602 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603 case eHT_CHANNEL_WIDTH_80MHZ:
5604 if (chwidth)
5605 smeConfig.csrConfig.
5606 channelBondingMode5GHz =
5607 phddctx->config->
5608 nChannelBondingMode5GHz;
5609 else
5610 return -EINVAL;
5611
5612 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613
5614 default:
5615 return -EINVAL;
5616 }
5617
5618 ret = wma_cli_set_command(pAdapter->sessionId,
5619 WMI_VDEV_PARAM_CHWIDTH,
5620 set_value, VDEV_CMD);
5621 if (!ret)
5622 sme_update_config(hHal, &smeConfig);
5623
5624 break;
5625 }
5626
5627 case WE_SET_ANI_EN_DIS:
5628 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005629 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005630 set_value);
5631 ret = wma_cli_set_command(pAdapter->sessionId,
5632 WMI_PDEV_PARAM_ANI_ENABLE,
5633 set_value, PDEV_CMD);
5634 break;
5635 }
5636
5637 case WE_SET_ANI_POLL_PERIOD:
5638 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005639 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005640 set_value);
5641 ret = wma_cli_set_command(pAdapter->sessionId,
5642 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
5643 set_value, PDEV_CMD);
5644 break;
5645 }
5646
5647 case WE_SET_ANI_LISTEN_PERIOD:
5648 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005649 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005650 set_value);
5651 ret = wma_cli_set_command(pAdapter->sessionId,
5652 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
5653 set_value, PDEV_CMD);
5654 break;
5655 }
5656
5657 case WE_SET_ANI_OFDM_LEVEL:
5658 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005659 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660 set_value);
5661 ret = wma_cli_set_command(pAdapter->sessionId,
5662 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
5663 set_value, PDEV_CMD);
5664 break;
5665 }
5666
5667 case WE_SET_ANI_CCK_LEVEL:
5668 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005669 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 set_value);
5671 ret = wma_cli_set_command(pAdapter->sessionId,
5672 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
5673 set_value, PDEV_CMD);
5674 break;
5675 }
5676
5677 case WE_SET_DYNAMIC_BW:
5678 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005679 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680 set_value);
5681 ret = wma_cli_set_command(pAdapter->sessionId,
5682 WMI_PDEV_PARAM_DYNAMIC_BW,
5683 set_value, PDEV_CMD);
5684 break;
5685 }
5686
5687 case WE_SET_CTS_CBW:
5688 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005689 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005690 ret = wma_cli_set_command(pAdapter->sessionId,
5691 WMI_PDEV_PARAM_CTS_CBW,
5692 set_value, PDEV_CMD);
5693 break;
5694 }
5695
5696 case WE_SET_11N_RATE:
5697 {
5698 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005699 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005700 set_value);
5701
5702 if (set_value != 0xff) {
5703 rix = RC_2_RATE_IDX(set_value);
5704 if (set_value & 0x80) {
5705 preamble = WMI_RATE_PREAMBLE_HT;
5706 nss = HT_RC_2_STREAMS(set_value) - 1;
5707 } else {
5708 nss = 0;
5709 rix = RC_2_RATE_IDX(set_value);
5710 if (set_value & 0x10) {
5711 preamble =
5712 WMI_RATE_PREAMBLE_CCK;
5713 if (rix != 0x3)
5714 /* Enable Short
5715 * preamble always for
5716 * CCK except 1mbps
5717 */
5718 rix |= 0x4;
5719 } else {
5720 preamble =
5721 WMI_RATE_PREAMBLE_OFDM;
5722 }
5723 }
5724 set_value = (preamble << 6) | (nss << 4) | rix;
5725 }
5726 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5727 set_value, rix, preamble, nss);
5728
5729 ret = wma_cli_set_command(pAdapter->sessionId,
5730 WMI_VDEV_PARAM_FIXED_RATE,
5731 set_value, VDEV_CMD);
5732 break;
5733 }
5734
5735 case WE_SET_VHT_RATE:
5736 {
5737 uint8_t preamble = 0, nss = 0, rix = 0;
5738
5739 if (set_value != 0xff) {
5740 rix = RC_2_RATE_IDX_11AC(set_value);
5741 preamble = WMI_RATE_PREAMBLE_VHT;
5742 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
5743
5744 set_value = (preamble << 6) | (nss << 4) | rix;
5745 }
5746 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
5747 set_value, rix, preamble, nss);
5748 ret = wma_cli_set_command(pAdapter->sessionId,
5749 WMI_VDEV_PARAM_FIXED_RATE,
5750 set_value, VDEV_CMD);
5751 break;
5752 }
5753
5754 case WE_SET_AMPDU:
5755 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005756 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005757 ret = wma_cli_set_command(pAdapter->sessionId,
5758 GEN_VDEV_PARAM_AMPDU,
5759 set_value, GEN_CMD);
5760 break;
5761 }
5762
5763 case WE_SET_AMSDU:
5764 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005765 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005766 ret = wma_cli_set_command(pAdapter->sessionId,
5767 GEN_VDEV_PARAM_AMSDU,
5768 set_value, GEN_CMD);
5769 break;
5770 }
5771
5772 case WE_SET_BURST_ENABLE:
5773 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005774 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005775 if ((set_value == 0) || (set_value == 1)) {
5776 ret = wma_cli_set_command(pAdapter->sessionId,
5777 WMI_PDEV_PARAM_BURST_ENABLE,
5778 set_value, PDEV_CMD);
5779 } else
5780 ret = -EINVAL;
5781 break;
5782 }
5783 case WE_SET_BURST_DUR:
5784 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005785 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07005786 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787 ret = wma_cli_set_command(pAdapter->sessionId,
5788 WMI_PDEV_PARAM_BURST_DUR,
5789 set_value, PDEV_CMD);
5790 else
5791 ret = -EINVAL;
5792 break;
5793 }
5794
5795 case WE_SET_TX_CHAINMASK:
5796 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005797 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005798 set_value);
5799 ret = wma_cli_set_command(pAdapter->sessionId,
5800 WMI_PDEV_PARAM_TX_CHAIN_MASK,
5801 set_value, PDEV_CMD);
5802 break;
5803 }
5804
5805 case WE_SET_RX_CHAINMASK:
5806 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005807 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808 set_value);
5809 ret = wma_cli_set_command(pAdapter->sessionId,
5810 WMI_PDEV_PARAM_RX_CHAIN_MASK,
5811 set_value, PDEV_CMD);
5812 break;
5813 }
5814
5815 case WE_SET_TXPOW_2G:
5816 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005817 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818 set_value);
5819 ret = wma_cli_set_command(pAdapter->sessionId,
5820 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
5821 set_value, PDEV_CMD);
5822 break;
5823 }
5824
5825 case WE_SET_TXPOW_5G:
5826 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005827 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005828 set_value);
5829 ret = wma_cli_set_command(pAdapter->sessionId,
5830 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
5831 set_value, PDEV_CMD);
5832 break;
5833 }
5834
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 /* Firmware debug log */
5836 case WE_DBGLOG_LOG_LEVEL:
5837 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005838 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005839 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
5840 ret = wma_cli_set_command(pAdapter->sessionId,
5841 WMI_DBGLOG_LOG_LEVEL,
5842 set_value, DBG_CMD);
5843 break;
5844 }
5845
5846 case WE_DBGLOG_VAP_ENABLE:
5847 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005848 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849 ret = wma_cli_set_command(pAdapter->sessionId,
5850 WMI_DBGLOG_VAP_ENABLE,
5851 set_value, DBG_CMD);
5852 break;
5853 }
5854
5855 case WE_DBGLOG_VAP_DISABLE:
5856 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005857 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 ret = wma_cli_set_command(pAdapter->sessionId,
5859 WMI_DBGLOG_VAP_DISABLE,
5860 set_value, DBG_CMD);
5861 break;
5862 }
5863
5864 case WE_DBGLOG_MODULE_ENABLE:
5865 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005866 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 set_value);
5868 hdd_ctx->fw_log_settings.enable = set_value;
5869 ret = wma_cli_set_command(pAdapter->sessionId,
5870 WMI_DBGLOG_MODULE_ENABLE,
5871 set_value, DBG_CMD);
5872 break;
5873 }
5874
5875 case WE_DBGLOG_MODULE_DISABLE:
5876 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005877 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005878 set_value);
5879 hdd_ctx->fw_log_settings.enable = set_value;
5880 ret = wma_cli_set_command(pAdapter->sessionId,
5881 WMI_DBGLOG_MODULE_DISABLE,
5882 set_value, DBG_CMD);
5883 break;
5884 }
5885 case WE_DBGLOG_MOD_LOG_LEVEL:
5886 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005887 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005888 set_value);
5889
5890 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
5891 hdd_ctx->fw_log_settings.index = 0;
5892
5893 hdd_ctx->fw_log_settings.
5894 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
5895 set_value;
5896 hdd_ctx->fw_log_settings.index++;
5897
5898 ret = wma_cli_set_command(pAdapter->sessionId,
5899 WMI_DBGLOG_MOD_LOG_LEVEL,
5900 set_value, DBG_CMD);
5901 break;
5902 }
5903
5904 case WE_DBGLOG_TYPE:
5905 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005906 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005907 hdd_ctx->fw_log_settings.dl_type = set_value;
5908 ret = wma_cli_set_command(pAdapter->sessionId,
5909 WMI_DBGLOG_TYPE,
5910 set_value, DBG_CMD);
5911 break;
5912 }
5913 case WE_DBGLOG_REPORT_ENABLE:
5914 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005915 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005916 set_value);
5917 hdd_ctx->fw_log_settings.dl_report = set_value;
5918 ret = wma_cli_set_command(pAdapter->sessionId,
5919 WMI_DBGLOG_REPORT_ENABLE,
5920 set_value, DBG_CMD);
5921 break;
5922 }
5923
5924 case WE_SET_TXRX_FWSTATS:
5925 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005926 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005927 ret = wma_cli_set_command(pAdapter->sessionId,
5928 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
5929 set_value, VDEV_CMD);
5930 break;
5931 }
5932
5933 case WE_TXRX_FWSTATS_RESET:
5934 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005935 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005936 ret = wma_cli_set_command(pAdapter->sessionId,
5937 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
5938 set_value, VDEV_CMD);
5939 break;
5940 }
5941
5942 case WE_DUMP_STATS:
5943 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005944 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945 hdd_wlan_dump_stats(pAdapter, set_value);
5946 break;
5947 }
5948
5949 case WE_CLEAR_STATS:
5950 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005951 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005952 switch (set_value) {
5953 case WLAN_HDD_STATS:
5954 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
5955 memset(&pAdapter->hdd_stats, 0,
5956 sizeof(pAdapter->hdd_stats));
5957 break;
5958 case WLAN_TXRX_HIST_STATS:
5959 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
5960 break;
5961 case WLAN_HDD_NETIF_OPER_HISTORY:
5962 wlan_hdd_clear_netif_queue_history(hdd_ctx);
5963 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05305964 case WLAN_HIF_STATS:
5965 hdd_clear_hif_stats();
5966 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005967 default:
5968 ol_txrx_clear_stats(set_value);
5969 }
5970 break;
5971 }
5972
5973 case WE_PPS_PAID_MATCH:
5974 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005975 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005976 return EINVAL;
5977
Jeff Johnson99bac312016-06-28 10:38:18 -07005978 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005979 set_value);
5980 ret = wma_cli_set_command(pAdapter->sessionId,
5981 WMI_VDEV_PPS_PAID_MATCH,
5982 set_value, PPS_CMD);
5983 break;
5984 }
5985
5986 case WE_PPS_GID_MATCH:
5987 {
Krunal Sonif07bb382016-03-10 13:02:11 -08005988 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005989 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07005990 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005991 set_value);
5992 ret = wma_cli_set_command(pAdapter->sessionId,
5993 WMI_VDEV_PPS_GID_MATCH,
5994 set_value, PPS_CMD);
5995 break;
5996 }
5997
5998 case WE_PPS_EARLY_TIM_CLEAR:
5999 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006000 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006001 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006002 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006003 set_value);
6004 ret = wma_cli_set_command(pAdapter->sessionId,
6005 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6006 set_value, PPS_CMD);
6007 break;
6008 }
6009
6010 case WE_PPS_EARLY_DTIM_CLEAR:
6011 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006012 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006014 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 set_value);
6016 ret = wma_cli_set_command(pAdapter->sessionId,
6017 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6018 set_value, PPS_CMD);
6019 break;
6020 }
6021
6022 case WE_PPS_EOF_PAD_DELIM:
6023 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006024 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006026 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027 set_value);
6028 ret = wma_cli_set_command(pAdapter->sessionId,
6029 WMI_VDEV_PPS_EOF_PAD_DELIM,
6030 set_value, PPS_CMD);
6031 break;
6032 }
6033
6034 case WE_PPS_MACADDR_MISMATCH:
6035 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006036 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006038 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006039 set_value);
6040 ret = wma_cli_set_command(pAdapter->sessionId,
6041 WMI_VDEV_PPS_MACADDR_MISMATCH,
6042 set_value, PPS_CMD);
6043 break;
6044 }
6045
6046 case WE_PPS_DELIM_CRC_FAIL:
6047 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006048 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006049 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006050 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051 set_value);
6052 ret = wma_cli_set_command(pAdapter->sessionId,
6053 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6054 set_value, PPS_CMD);
6055 break;
6056 }
6057
6058 case WE_PPS_GID_NSTS_ZERO:
6059 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006060 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006061 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006062 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006063 set_value);
6064 ret = wma_cli_set_command(pAdapter->sessionId,
6065 WMI_VDEV_PPS_GID_NSTS_ZERO,
6066 set_value, PPS_CMD);
6067 break;
6068 }
6069
6070 case WE_PPS_RSSI_CHECK:
6071 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006072 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006073 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006074 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006075 set_value);
6076 ret = wma_cli_set_command(pAdapter->sessionId,
6077 WMI_VDEV_PPS_RSSI_CHECK,
6078 set_value, PPS_CMD);
6079 break;
6080 }
6081
6082 case WE_PPS_5G_EBT:
6083 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006084 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006085 return -EINVAL;
6086
Jeff Johnson99bac312016-06-28 10:38:18 -07006087 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006088 ret = wma_cli_set_command(pAdapter->sessionId,
6089 WMI_VDEV_PPS_5G_EBT,
6090 set_value, PPS_CMD);
6091 break;
6092 }
6093
6094 case WE_SET_HTSMPS:
6095 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006096 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097 ret = wma_cli_set_command(pAdapter->sessionId,
6098 WMI_STA_SMPS_FORCE_MODE_CMDID,
6099 set_value, VDEV_CMD);
6100 break;
6101 }
6102
6103 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6104 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006105 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006106 set_value);
6107 ret = wma_cli_set_command(pAdapter->sessionId,
6108 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6109 set_value, QPOWER_CMD);
6110 break;
6111 }
6112
6113 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6114 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006115 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006116 set_value);
6117 ret = wma_cli_set_command(
6118 pAdapter->sessionId,
6119 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6120 set_value, QPOWER_CMD);
6121 break;
6122 }
6123
6124 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6125 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006126 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006127 set_value);
6128 ret = wma_cli_set_command(
6129 pAdapter->sessionId,
6130 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6131 set_value, QPOWER_CMD);
6132 break;
6133 }
6134
6135 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6136 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006137 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006138 set_value);
6139 ret = wma_cli_set_command(
6140 pAdapter->sessionId,
6141 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6142 set_value, QPOWER_CMD);
6143 break;
6144 }
6145
6146 case WE_MCC_CONFIG_LATENCY:
6147 {
6148 cds_set_mcc_latency(pAdapter, set_value);
6149 break;
6150 }
6151
6152 case WE_MCC_CONFIG_QUOTA:
6153 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006154 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006155 set_value);
6156 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
6157 break;
6158 }
6159 case WE_SET_DEBUG_LOG:
6160 {
6161 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05306162
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163 hdd_ctx->config->gEnableDebugLog = set_value;
6164 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6165 break;
6166 }
6167 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6168 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006169 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006170 if ((set_value == 0) || (set_value == 1))
6171 ret = wma_cli_set_command(
6172 pAdapter->sessionId,
6173 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6174 set_value, VDEV_CMD);
6175 else
6176 ret = -EINVAL;
6177 break;
6178 }
6179 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6180 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006181 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006182 ret = wma_cli_set_command(pAdapter->sessionId,
6183 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6184 set_value, VDEV_CMD);
6185 break;
6186 }
6187 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6188 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006189 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006190 set_value);
6191 ret = wma_cli_set_command(
6192 pAdapter->sessionId,
6193 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6194 set_value, VDEV_CMD);
6195 break;
6196 }
6197 case WE_SET_EARLY_RX_SLOP_STEP:
6198 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006199 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006200 set_value);
6201 ret = wma_cli_set_command(pAdapter->sessionId,
6202 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6203 set_value, VDEV_CMD);
6204 break;
6205 }
6206 case WE_SET_EARLY_RX_INIT_SLOP:
6207 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006208 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006209 set_value);
6210 ret = wma_cli_set_command(pAdapter->sessionId,
6211 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6212 set_value, VDEV_CMD);
6213 break;
6214 }
6215 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6216 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006217 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006218 if ((set_value == 0) || (set_value == 1))
6219 ret = wma_cli_set_command(
6220 pAdapter->sessionId,
6221 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6222 set_value, VDEV_CMD);
6223 else
6224 ret = -EINVAL;
6225 break;
6226 }
6227 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6228 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006229 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006230 ret = wma_cli_set_command(pAdapter->sessionId,
6231 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6232 set_value, VDEV_CMD);
6233 break;
6234 }
6235 case WE_SET_SCAN_DISABLE:
6236 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006237 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006238 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
6239 break;
6240 }
Govind Singha471e5e2015-10-12 17:11:14 +05306241 case WE_START_FW_PROFILE:
6242 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006243 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05306244 ret = wma_cli_set_command(pAdapter->sessionId,
6245 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6246 set_value, DBG_CMD);
6247 break;
6248 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306249 case WE_SET_CHANNEL:
6250 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006251 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306252 pAdapter->sessionId, pAdapter->device_mode);
6253
Krunal Sonif07bb382016-03-10 13:02:11 -08006254 if ((QDF_STA_MODE == pAdapter->device_mode) ||
6255 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306256
6257 status = sme_ext_change_channel(hHal,
6258 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306259 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006260 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306261 status);
6262 ret = -EINVAL;
6263 }
6264 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006265 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306266 pAdapter->device_mode);
6267 ret = -EINVAL;
6268 }
6269 break;
6270 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306271 case WE_SET_CONC_SYSTEM_PREF:
6272 {
6273 hdd_info("New preference: %d", set_value);
6274 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6275 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6276 hdd_err("Invalid system preference %d", set_value);
6277 return -EINVAL;
6278 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306279
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306280 /* hdd_ctx, hdd_ctx->config are already checked for null */
6281 hdd_ctx->config->conc_system_pref = set_value;
6282 break;
6283 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006284 default:
6285 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006286 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006287 sub_cmd);
6288 ret = -EINVAL;
6289 break;
6290 }
6291 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306292 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006293 return ret;
6294}
6295
6296static int iw_setint_getnone(struct net_device *dev,
6297 struct iw_request_info *info,
6298 union iwreq_data *wrqu,
6299 char *extra)
6300{
6301 int ret;
6302
6303 cds_ssr_protect(__func__);
6304 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6305 cds_ssr_unprotect(__func__);
6306
6307 return ret;
6308}
6309
6310/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006311 * __iw_setnone_get_threeint() - return three value to up layer.
6312 *
6313 * @dev: pointer of net_device of this wireless card
6314 * @info: meta data about Request sent
6315 * @wrqu: include request info
6316 * @extra: buf used for in/Output
6317 *
6318 * Return: execute result
6319 */
6320static int __iw_setnone_get_threeint(struct net_device *dev,
6321 struct iw_request_info *info,
6322 union iwreq_data *wrqu, char *extra)
6323{
6324 int ret = 0; /* success */
6325 uint32_t *value = (int *)extra;
6326 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6327 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6328
6329 ENTER_DEV(dev);
6330 ret = wlan_hdd_validate_context(hdd_ctx);
6331 if (0 != ret)
6332 return ret;
6333
Jeff Johnson99bac312016-06-28 10:38:18 -07006334 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006335 switch (value[0]) {
6336 case WE_GET_TSF:
6337 ret = hdd_indicate_tsf(adapter, value, 3);
6338 break;
6339 default:
6340 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6341 break;
6342 }
6343 return ret;
6344}
6345
6346/**
6347 * iw_setnone_get_threeint() - return three value to up layer.
6348 *
6349 * @dev: pointer of net_device of this wireless card
6350 * @info: meta data about Request sent
6351 * @wrqu: include request info
6352 * @extra: buf used for in/Output
6353 *
6354 * Return: execute result
6355 */
6356static int iw_setnone_get_threeint(struct net_device *dev,
6357 struct iw_request_info *info,
6358 union iwreq_data *wrqu, char *extra)
6359{
6360 int ret;
6361
6362 cds_ssr_protect(__func__);
6363 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6364 cds_ssr_unprotect(__func__);
6365
6366 return ret;
6367}
6368
6369/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006370 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6371 * @dev: device upon which the ioctl was received
6372 * @info: ioctl request information
6373 * @wrqu: ioctl request data
6374 * @extra: ioctl extra data
6375 *
6376 * Return: 0 on success, non-zero on error
6377 */
6378static int __iw_setchar_getnone(struct net_device *dev,
6379 struct iw_request_info *info,
6380 union iwreq_data *wrqu, char *extra)
6381{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306382 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006383 int sub_cmd;
6384 int ret;
6385 char *pBuffer = NULL;
6386 hdd_adapter_t *pAdapter = (netdev_priv(dev));
6387 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006388 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006389 struct iw_point s_priv_data;
6390
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006391 ENTER_DEV(dev);
6392
Mukul Sharma34777c62015-11-02 20:22:30 +05306393 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006394 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306395 return -EPERM;
6396 }
6397
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006398 ret = wlan_hdd_validate_context(hdd_ctx);
6399 if (0 != ret)
6400 return ret;
6401
6402 /* helper function to get iwreq_data with compat handling. */
6403 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
6404 return -EINVAL;
6405 }
6406
6407 /* make sure all params are correctly passed to function */
6408 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
6409 return -EINVAL;
6410 }
6411
6412 sub_cmd = s_priv_data.flags;
6413
6414 /* ODD number is used for set, copy data using copy_from_user */
6415 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6416 s_priv_data.length);
6417 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006418 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006419 return -ENOMEM;
6420 }
6421
Jeff Johnson99bac312016-06-28 10:38:18 -07006422 hdd_notice("Received length %d", s_priv_data.length);
6423 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006424
6425 switch (sub_cmd) {
6426 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006427 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006428 hdd_add_wowl_ptrn(pAdapter, pBuffer);
6429 break;
6430 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006431 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006432 hdd_del_wowl_ptrn(pAdapter, pBuffer);
6433 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006434 case WE_NEIGHBOR_REPORT_REQUEST:
6435 {
6436 tRrmNeighborReq neighborReq;
6437 tRrmNeighborRspCallbackInfo callbackInfo;
6438
6439 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006440 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006441 neighborReq.no_ssid =
6442 (s_priv_data.length - 1) ? false : true;
6443 if (!neighborReq.no_ssid) {
6444 neighborReq.ssid.length =
6445 (s_priv_data.length - 1) >
6446 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306447 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006448 pBuffer,
6449 neighborReq.ssid.length);
6450 }
6451
6452 callbackInfo.neighborRspCallback = NULL;
6453 callbackInfo.neighborRspCallbackContext = NULL;
6454 callbackInfo.timeout = 5000; /* 5 seconds */
6455 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
6456 (pAdapter),
6457 pAdapter->sessionId,
6458 &neighborReq,
6459 &callbackInfo);
6460 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006461 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006462 ret = -EINVAL;
6463 }
6464 }
6465 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006466 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07006467 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006468 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
6469 s_priv_data.length);
6470 break;
6471 case WE_SET_CONFIG:
6472 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306473 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006474 ret = -EINVAL;
6475 }
6476 break;
6477 default:
6478 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006479 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006480 sub_cmd);
6481 ret = -EINVAL;
6482 break;
6483 }
6484 }
6485 kfree(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306486 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006487 return ret;
6488}
6489
6490static int iw_setchar_getnone(struct net_device *dev,
6491 struct iw_request_info *info,
6492 union iwreq_data *wrqu, char *extra)
6493{
6494 int ret;
6495
6496 cds_ssr_protect(__func__);
6497 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6498 cds_ssr_unprotect(__func__);
6499
6500 return ret;
6501}
6502
6503/**
6504 * iw_setnone_getint() - Generic "get integer" private ioctl handler
6505 * @dev: device upon which the ioctl was received
6506 * @info: ioctl request information
6507 * @wrqu: ioctl request data
6508 * @extra: ioctl extra data
6509 *
6510 * Return: 0 on success, non-zero on error
6511 */
6512static int __iw_setnone_getint(struct net_device *dev,
6513 struct iw_request_info *info,
6514 union iwreq_data *wrqu, char *extra)
6515{
6516 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6517 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6518 int *value = (int *)extra;
6519 int ret;
6520 tSmeConfigParams smeConfig;
6521 hdd_context_t *hdd_ctx;
6522
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006523 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306524
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006525 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6526 ret = wlan_hdd_validate_context(hdd_ctx);
6527 if (0 != ret)
6528 return ret;
6529
6530 switch (value[0]) {
6531 case WE_GET_11D_STATE:
6532 {
6533 sme_get_config_param(hHal, &smeConfig);
6534
6535 *value = smeConfig.csrConfig.Is11dSupportEnabled;
6536
Jeff Johnson99bac312016-06-28 10:38:18 -07006537 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006538
6539 break;
6540 }
6541
6542 case WE_IBSS_STATUS:
Jeff Johnson99bac312016-06-28 10:38:18 -07006543 hdd_notice("****Return IBSS Status*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006544 break;
6545
6546 case WE_GET_WLAN_DBG:
6547 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306548 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006549 *value = 0;
6550 break;
6551 }
6552 case WE_GET_MAX_ASSOC:
6553 {
6554 if (sme_cfg_get_int
6555 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306556 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006557 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006558 ret = -EIO;
6559 }
6560 break;
6561 }
6562 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
6563 *value = (WLAN_HDD_GET_CTX(
6564 pAdapter))->config->force_sap_acs;
6565 break;
6566
6567 case WE_GET_CONCURRENCY_MODE:
6568 {
6569 *value = cds_get_concurrency_mode();
6570
Jeff Johnson99bac312016-06-28 10:38:18 -07006571 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006572 break;
6573 }
6574
6575 case WE_GET_NSS:
6576 {
6577 sme_get_config_param(hHal, &smeConfig);
6578 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07006579 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006580 break;
6581 }
6582
6583 case WE_GET_GTX_HT_MCS:
6584 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006585 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006586 *value = wma_cli_get_command(pAdapter->sessionId,
6587 WMI_VDEV_PARAM_GTX_HT_MCS,
6588 GTX_CMD);
6589 break;
6590 }
6591
6592 case WE_GET_GTX_VHT_MCS:
6593 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006594 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006595 *value = wma_cli_get_command(pAdapter->sessionId,
6596 WMI_VDEV_PARAM_GTX_VHT_MCS,
6597 GTX_CMD);
6598 break;
6599 }
6600
6601 case WE_GET_GTX_USRCFG:
6602 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006603 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006604 *value = wma_cli_get_command(pAdapter->sessionId,
6605 WMI_VDEV_PARAM_GTX_USR_CFG,
6606 GTX_CMD);
6607 break;
6608 }
6609
6610 case WE_GET_GTX_THRE:
6611 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006612 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006613 *value = wma_cli_get_command(pAdapter->sessionId,
6614 WMI_VDEV_PARAM_GTX_THRE,
6615 GTX_CMD);
6616 break;
6617 }
6618
6619 case WE_GET_GTX_MARGIN:
6620 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006621 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006622 *value = wma_cli_get_command(pAdapter->sessionId,
6623 WMI_VDEV_PARAM_GTX_MARGIN,
6624 GTX_CMD);
6625 break;
6626 }
6627
6628 case WE_GET_GTX_STEP:
6629 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006630 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006631 *value = wma_cli_get_command(pAdapter->sessionId,
6632 WMI_VDEV_PARAM_GTX_STEP,
6633 GTX_CMD);
6634 break;
6635 }
6636
6637 case WE_GET_GTX_MINTPC:
6638 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006639 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006640 *value = wma_cli_get_command(pAdapter->sessionId,
6641 WMI_VDEV_PARAM_GTX_MINTPC,
6642 GTX_CMD);
6643 break;
6644 }
6645
6646 case WE_GET_GTX_BWMASK:
6647 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006648 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006649 *value = wma_cli_get_command(pAdapter->sessionId,
6650 WMI_VDEV_PARAM_GTX_BW_MASK,
6651 GTX_CMD);
6652 break;
6653 }
6654
6655 case WE_GET_LDPC:
6656 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306657 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006658 break;
6659 }
6660
6661 case WE_GET_TX_STBC:
6662 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306663 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006664 break;
6665 }
6666
6667 case WE_GET_RX_STBC:
6668 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306669 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006670 break;
6671 }
6672
6673 case WE_GET_SHORT_GI:
6674 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006675 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006676 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
6677 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
6678 break;
6679 }
6680
6681 case WE_GET_RTSCTS:
6682 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006683 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006684 *value = wma_cli_get_command(pAdapter->sessionId,
6685 WMI_VDEV_PARAM_ENABLE_RTSCTS,
6686 VDEV_CMD);
6687 break;
6688 }
6689
6690 case WE_GET_CHWIDTH:
6691 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006692 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006693 *value = wma_cli_get_command(pAdapter->sessionId,
6694 WMI_VDEV_PARAM_CHWIDTH,
6695 VDEV_CMD);
6696 break;
6697 }
6698
6699 case WE_GET_ANI_EN_DIS:
6700 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006701 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006702 *value = wma_cli_get_command(pAdapter->sessionId,
6703 WMI_PDEV_PARAM_ANI_ENABLE,
6704 PDEV_CMD);
6705 break;
6706 }
6707
6708 case WE_GET_ANI_POLL_PERIOD:
6709 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006710 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006711 *value = wma_cli_get_command(pAdapter->sessionId,
6712 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6713 PDEV_CMD);
6714 break;
6715 }
6716
6717 case WE_GET_ANI_LISTEN_PERIOD:
6718 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006719 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006720 *value = wma_cli_get_command(pAdapter->sessionId,
6721 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6722 PDEV_CMD);
6723 break;
6724 }
6725
6726 case WE_GET_ANI_OFDM_LEVEL:
6727 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006728 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006729 *value = wma_cli_get_command(pAdapter->sessionId,
6730 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6731 PDEV_CMD);
6732 break;
6733 }
6734
6735 case WE_GET_ANI_CCK_LEVEL:
6736 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006737 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006738 *value = wma_cli_get_command(pAdapter->sessionId,
6739 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6740 PDEV_CMD);
6741 break;
6742 }
6743
6744 case WE_GET_DYNAMIC_BW:
6745 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006746 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006747 *value = wma_cli_get_command(pAdapter->sessionId,
6748 WMI_PDEV_PARAM_DYNAMIC_BW,
6749 PDEV_CMD);
6750 break;
6751 }
6752
6753 case WE_GET_11N_RATE:
6754 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006755 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006756 *value = wma_cli_get_command(pAdapter->sessionId,
6757 WMI_VDEV_PARAM_FIXED_RATE,
6758 VDEV_CMD);
6759 break;
6760 }
6761
6762 case WE_GET_AMPDU:
6763 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006764 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006765 *value = wma_cli_get_command(pAdapter->sessionId,
6766 GEN_VDEV_PARAM_AMPDU,
6767 GEN_CMD);
6768 break;
6769 }
6770
6771 case WE_GET_AMSDU:
6772 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006773 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006774 *value = wma_cli_get_command(pAdapter->sessionId,
6775 GEN_VDEV_PARAM_AMSDU,
6776 GEN_CMD);
6777 break;
6778 }
6779
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006780 case WE_GET_ROAM_SYNCH_DELAY:
6781 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006782 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07006783 *value = wma_cli_get_command(pAdapter->sessionId,
6784 GEN_VDEV_ROAM_SYNCH_DELAY,
6785 GEN_CMD);
6786 break;
6787 }
6788
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006789 case WE_GET_BURST_ENABLE:
6790 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006791 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006792 *value = wma_cli_get_command(pAdapter->sessionId,
6793 WMI_PDEV_PARAM_BURST_ENABLE,
6794 PDEV_CMD);
6795 break;
6796 }
6797 case WE_GET_BURST_DUR:
6798 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006799 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006800 *value = wma_cli_get_command(pAdapter->sessionId,
6801 WMI_PDEV_PARAM_BURST_DUR,
6802 PDEV_CMD);
6803 break;
6804 }
6805
6806 case WE_GET_TX_CHAINMASK:
6807 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006808 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809 *value = wma_cli_get_command(pAdapter->sessionId,
6810 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6811 PDEV_CMD);
6812 break;
6813 }
6814
6815 case WE_GET_RX_CHAINMASK:
6816 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006817 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006818 *value = wma_cli_get_command(pAdapter->sessionId,
6819 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6820 PDEV_CMD);
6821 break;
6822 }
6823
6824 case WE_GET_TXPOW_2G:
6825 {
6826 uint32_t txpow2g = 0;
6827 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006828 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006829 *value = wma_cli_get_command(pAdapter->sessionId,
6830 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6831 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306832 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006833 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6834 &txpow2g)) {
6835 return -EIO;
6836 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006837 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006838 break;
6839 }
6840
6841 case WE_GET_TXPOW_5G:
6842 {
6843 uint32_t txpow5g = 0;
6844 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07006845 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006846 *value = wma_cli_get_command(pAdapter->sessionId,
6847 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6848 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306849 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006850 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6851 &txpow5g)) {
6852 return -EIO;
6853 }
Jeff Johnson99bac312016-06-28 10:38:18 -07006854 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006855 break;
6856 }
6857
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006858 case WE_GET_PPS_PAID_MATCH:
6859 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006860 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006861 *value = wma_cli_get_command(pAdapter->sessionId,
6862 WMI_VDEV_PPS_PAID_MATCH,
6863 PPS_CMD);
6864 break;
6865 }
6866
6867 case WE_GET_PPS_GID_MATCH:
6868 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006869 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006870 *value = wma_cli_get_command(pAdapter->sessionId,
6871 WMI_VDEV_PPS_GID_MATCH,
6872 PPS_CMD);
6873 break;
6874 }
6875
6876 case WE_GET_PPS_EARLY_TIM_CLEAR:
6877 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006878 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006879 *value = wma_cli_get_command(pAdapter->sessionId,
6880 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6881 PPS_CMD);
6882 break;
6883 }
6884
6885 case WE_GET_PPS_EARLY_DTIM_CLEAR:
6886 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006887 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006888 *value = wma_cli_get_command(pAdapter->sessionId,
6889 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6890 PPS_CMD);
6891 break;
6892 }
6893
6894 case WE_GET_PPS_EOF_PAD_DELIM:
6895 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006896 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006897 *value = wma_cli_get_command(pAdapter->sessionId,
6898 WMI_VDEV_PPS_EOF_PAD_DELIM,
6899 PPS_CMD);
6900 break;
6901 }
6902
6903 case WE_GET_PPS_MACADDR_MISMATCH:
6904 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006905 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006906 *value = wma_cli_get_command(pAdapter->sessionId,
6907 WMI_VDEV_PPS_MACADDR_MISMATCH,
6908 PPS_CMD);
6909 break;
6910 }
6911
6912 case WE_GET_PPS_DELIM_CRC_FAIL:
6913 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006914 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006915 *value = wma_cli_get_command(pAdapter->sessionId,
6916 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6917 PPS_CMD);
6918 break;
6919 }
6920
6921 case WE_GET_PPS_GID_NSTS_ZERO:
6922 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006923 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006924 *value = wma_cli_get_command(pAdapter->sessionId,
6925 WMI_VDEV_PPS_GID_NSTS_ZERO,
6926 PPS_CMD);
6927 break;
6928 }
6929
6930 case WE_GET_PPS_RSSI_CHECK:
6931 {
6932
Jeff Johnson99bac312016-06-28 10:38:18 -07006933 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006934 *value = wma_cli_get_command(pAdapter->sessionId,
6935 WMI_VDEV_PPS_RSSI_CHECK,
6936 PPS_CMD);
6937 break;
6938 }
6939
6940 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
6941 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006942 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006943 *value = wma_cli_get_command(pAdapter->sessionId,
6944 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6945 QPOWER_CMD);
6946 break;
6947 }
6948
6949 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
6950 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006951 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006952 *value = wma_cli_get_command(pAdapter->sessionId,
6953 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6954 QPOWER_CMD);
6955 break;
6956 }
6957
6958 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6959 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006960 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006961 *value = wma_cli_get_command(pAdapter->sessionId,
6962 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6963 QPOWER_CMD);
6964 break;
6965 }
6966
6967 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6968 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006969 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006970 *value = wma_cli_get_command(pAdapter->sessionId,
6971 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6972 QPOWER_CMD);
6973 break;
6974 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006975 case WE_CAP_TSF:
6976 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
6977 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006978 case WE_GET_TEMPERATURE:
6979 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006980 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006981 ret = wlan_hdd_get_temperature(pAdapter, value);
6982 break;
6983 }
6984 default:
6985 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006986 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006987 value[0]);
6988 break;
6989 }
6990 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306991 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006992 return ret;
6993}
6994
6995static int iw_setnone_getint(struct net_device *dev,
6996 struct iw_request_info *info,
6997 union iwreq_data *wrqu, char *extra)
6998{
6999 int ret;
7000
7001 cds_ssr_protect(__func__);
7002 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7003 cds_ssr_unprotect(__func__);
7004
7005 return ret;
7006}
7007
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307008static int hdd_set_fwtest(int argc, int cmd, int value)
7009{
7010 struct set_fwtest_params *fw_test;
7011
7012 /* check for max number of arguments */
7013 if (argc > (WMA_MAX_NUM_ARGS) ||
7014 argc != HDD_FWTEST_PARAMS) {
7015 hdd_err("Too Many args %d", argc);
7016 return -EINVAL;
7017 }
7018 /*
7019 * check if number of arguments are 3 then, check
7020 * then set the default value for sounding interval.
7021 */
7022 if (HDD_FWTEST_PARAMS == argc) {
7023 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7024 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7025 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7026 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7027 }
7028 /* check sounding interval value should not exceed to max */
7029 if (value > HDD_FWTEST_MAX_VALUE) {
7030 hdd_err("Invalid arguments value should not exceed max: %d",
7031 value);
7032 return -EINVAL;
7033 }
7034 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7035 if (NULL == fw_test) {
7036 hdd_err("qdf_mem_malloc failed for fw_test");
7037 return -ENOMEM;
7038 }
7039 fw_test->arg = cmd;
7040 fw_test->value = value;
7041 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7042 qdf_mem_free(fw_test);
7043 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7044 return -EINVAL;
7045 }
7046 return 0;
7047}
7048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007049/**
7050 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7051 * @dev: device upon which the ioctl was received
7052 * @info: ioctl request information
7053 * @wrqu: ioctl request data
7054 * @extra: ioctl extra data
7055 *
7056 * Return: 0 on success, non-zero on error
7057 */
7058static int __iw_set_three_ints_getnone(struct net_device *dev,
7059 struct iw_request_info *info,
7060 union iwreq_data *wrqu, char *extra)
7061{
7062 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7063 int *value = (int *)extra;
7064 int sub_cmd = value[0];
7065 int ret;
7066 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7067
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007068 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307069
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007070 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007071 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007072 return -EPERM;
7073 }
7074
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007075 ret = wlan_hdd_validate_context(hdd_ctx);
7076 if (0 != ret)
7077 return ret;
7078
7079 switch (sub_cmd) {
7080
7081 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307082 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007083 break;
7084 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307085 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007086 break;
7087
7088 /* value[3] the acs band is not required as start and end channels are
7089 * enough but this cmd is maintained under set three ints for historic
7090 * reasons.
7091 */
7092 case WE_SET_SAP_CHANNELS:
7093 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307094 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007095 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307096 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007097 ret = -EINVAL;
7098 } else {
7099 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7100 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7101 }
7102 break;
7103 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7104 hdd_debug("Ioctl to set dual mac scan config");
7105 if (hdd_ctx->config->dual_mac_feature_disable) {
7106 hdd_err("Dual mac feature is disabled from INI");
7107 return -EPERM;
7108 }
7109 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08007110 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007111 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307112 case WE_SET_FW_TEST:
7113 {
7114 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7115 if (ret) {
7116 hdd_err("Not able to set fwtest %d", ret);
7117 return ret;
7118 }
7119 }
7120 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007121 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007122 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007123 break;
7124
7125 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307126 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007127 return ret;
7128}
7129
7130int iw_set_three_ints_getnone(struct net_device *dev,
7131 struct iw_request_info *info,
7132 union iwreq_data *wrqu, char *extra)
7133{
7134 int ret;
7135
7136 cds_ssr_protect(__func__);
7137 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7138 cds_ssr_unprotect(__func__);
7139
7140 return ret;
7141}
7142
7143/**
7144 * hdd_connection_state_string() - Get connection state string
7145 * @connection_state: enum to be converted to a string
7146 *
7147 * Return: the string equivalent of @connection_state
7148 */
7149static const char *
7150hdd_connection_state_string(eConnectionState connection_state)
7151{
7152 switch (connection_state) {
7153 CASE_RETURN_STRING(eConnectionState_NotConnected);
7154 CASE_RETURN_STRING(eConnectionState_Connecting);
7155 CASE_RETURN_STRING(eConnectionState_Associated);
7156 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7157 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7158 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7159 default:
7160 return "UNKNOWN";
7161 }
7162}
7163
7164/**
7165 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7166 * @dev: device upon which the ioctl was received
7167 * @info: ioctl request information
7168 * @wrqu: ioctl request data
7169 * @extra: ioctl extra data
7170 *
7171 * Return: 0 on success, non-zero on error
7172 */
7173static int __iw_get_char_setnone(struct net_device *dev,
7174 struct iw_request_info *info,
7175 union iwreq_data *wrqu, char *extra)
7176{
7177 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7178 int sub_cmd = wrqu->data.flags;
7179 hdd_context_t *hdd_ctx;
7180 int ret;
7181#ifdef WLAN_FEATURE_11W
7182 hdd_wext_state_t *pWextState;
7183#endif
7184
7185#ifdef WLAN_FEATURE_11W
7186 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7187#endif
7188
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007189 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307190
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007191 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7192 ret = wlan_hdd_validate_context(hdd_ctx);
7193 if (0 != ret)
7194 return ret;
7195
7196 switch (sub_cmd) {
7197 case WE_WLAN_VERSION:
7198 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307199 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007200 break;
7201 }
7202
7203 case WE_GET_STATS:
7204 {
7205 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
7206 extra, WE_MAX_STR_LEN);
7207 break;
7208 }
7209
Govind Singha471e5e2015-10-12 17:11:14 +05307210 case WE_LIST_FW_PROFILE:
7211 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7212 extra, WE_MAX_STR_LEN);
7213 break;
7214
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007215 /* The case prints the current state of the HDD, SME, CSR, PE,
7216 * TL it can be extended for WDI Global State as well. And
7217 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7218 * and P2P_GO have not been added as of now.
7219 */
7220 case WE_GET_STATES:
7221 {
7222 int buf = 0, len = 0;
7223 int adapter_num = 0;
7224 int count = 0, check = 1;
7225
7226 tHalHandle hHal = NULL;
7227 tpAniSirGlobal pMac = NULL;
7228 hdd_station_ctx_t *pHddStaCtx = NULL;
7229
7230 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7231 hdd_adapter_t *useAdapter = NULL;
7232
7233 /* Print wlan0 or p2p0 states based on the adapter_num
7234 * by using the correct adapter
7235 */
7236 while (adapter_num < 2) {
7237 if (WLAN_ADAPTER == adapter_num) {
7238 useAdapter = pAdapter;
7239 buf =
7240 scnprintf(extra + len,
7241 WE_MAX_STR_LEN - len,
7242 "\n\n wlan0 States:-");
7243 len += buf;
7244 } else if (P2P_ADAPTER == adapter_num) {
7245 buf =
7246 scnprintf(extra + len,
7247 WE_MAX_STR_LEN - len,
7248 "\n\n p2p0 States:-");
7249 len += buf;
7250
7251 if (!pHddCtx) {
7252 buf =
7253 scnprintf(extra + len,
7254 WE_MAX_STR_LEN -
7255 len,
7256 "\n pHddCtx is NULL");
7257 len += buf;
7258 break;
7259 }
7260
7261 /* Printing p2p0 states only in the
7262 * case when the device is configured
7263 * as a p2p_client
7264 */
7265 useAdapter =
7266 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007267 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007268 if (!useAdapter) {
7269 buf =
7270 scnprintf(extra + len,
7271 WE_MAX_STR_LEN -
7272 len,
7273 "\n Device not configured as P2P_CLIENT.");
7274 len += buf;
7275 break;
7276 }
7277 }
7278
7279 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7280 if (!hHal) {
7281 buf =
7282 scnprintf(extra + len,
7283 WE_MAX_STR_LEN - len,
7284 "\n pMac is NULL");
7285 len += buf;
7286 break;
7287 }
7288 pMac = PMAC_STRUCT(hHal);
7289 if (!pMac) {
7290 buf =
7291 scnprintf(extra + len,
7292 WE_MAX_STR_LEN - len,
7293 "\n pMac is NULL");
7294 len += buf;
7295 break;
7296 }
7297 pHddStaCtx =
7298 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7299
7300
7301 buf =
7302 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7303 "\n HDD Conn State - %s "
7304 "\n \n SME State:"
7305 "\n Neighbour Roam State - %s"
7306 "\n CSR State - %s"
7307 "\n CSR Substate - %s",
7308 hdd_connection_state_string
7309 (pHddStaCtx->conn_info.connState),
7310 mac_trace_get_neighbour_roam_state
7311 (sme_get_neighbor_roam_state
7312 (hHal, useAdapter->sessionId)),
7313 mac_trace_getcsr_roam_state
7314 (sme_get_current_roam_state
7315 (hHal, useAdapter->sessionId)),
7316 mac_trace_getcsr_roam_sub_state
7317 (sme_get_current_roam_sub_state
7318 (hHal, useAdapter->sessionId))
7319 );
7320 len += buf;
7321 adapter_num++;
7322 }
7323
Mukul Sharma81661ae2015-10-30 20:26:02 +05307324 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007325 /* Printing Lim State starting with global lim states */
7326 buf =
7327 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7328 "\n \n LIM STATES:-"
7329 "\n Global Sme State - %s "
7330 "\n Global mlm State - %s " "\n",
7331 mac_trace_get_lim_sme_state
7332 (sme_get_lim_sme_state(hHal)),
7333 mac_trace_get_lim_mlm_state
7334 (sme_get_lim_sme_state(hHal))
7335 );
7336 len += buf;
7337
7338 /* Printing the PE Sme and Mlm states for valid lim sessions */
7339 while (check < 3 && count < 255) {
7340 if (sme_is_lim_session_valid(hHal, count)) {
7341 buf =
7342 scnprintf(extra + len,
7343 WE_MAX_STR_LEN -
7344 len,
7345 "\n Lim Valid Session %d:-"
7346 "\n PE Sme State - %s "
7347 "\n PE Mlm State - %s "
7348 "\n", check,
7349 mac_trace_get_lim_sme_state
7350 (sme_get_lim_sme_session_state
7351 (hHal, count)),
7352 mac_trace_get_lim_mlm_state
7353 (sme_get_lim_mlm_session_state
7354 (hHal, count))
7355 );
7356
7357 len += buf;
7358 check++;
7359 }
7360 count++;
7361 }
7362 }
7363
7364 wrqu->data.length = strlen(extra) + 1;
7365 break;
7366 }
7367
7368 case WE_GET_CFG:
7369 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007370 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007371 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
7372 extra,
7373 QCSAP_IOCTL_MAX_STR_LEN);
7374 wrqu->data.length = strlen(extra) + 1;
7375 break;
7376 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007377 case WE_GET_RSSI:
7378 {
7379 int8_t s7Rssi = 0;
7380 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7381 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7382 wrqu->data.length = strlen(extra) + 1;
7383 break;
7384 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007385
7386 case WE_GET_WMM_STATUS:
7387 {
7388 snprintf(extra, WE_MAX_STR_LEN,
7389 "\nDir: 0=up, 1=down, 3=both\n"
7390 "|------------------------|\n"
7391 "|AC | ACM |Admitted| Dir |\n"
7392 "|------------------------|\n"
7393 "|VO | %d | %3s | %d |\n"
7394 "|VI | %d | %3s | %d |\n"
7395 "|BE | %d | %3s | %d |\n"
7396 "|BK | %d | %3s | %d |\n"
7397 "|------------------------|\n",
7398 pAdapter->hddWmmStatus.
7399 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
7400 pAdapter->hddWmmStatus.
7401 wmmAcStatus[SME_AC_VO].
7402 wmmAcAccessAllowed ? "YES" : "NO",
7403 pAdapter->hddWmmStatus.
7404 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
7405 ts_info.direction,
7406 pAdapter->hddWmmStatus.
7407 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
7408 pAdapter->hddWmmStatus.
7409 wmmAcStatus[SME_AC_VI].
7410 wmmAcAccessAllowed ? "YES" : "NO",
7411 pAdapter->hddWmmStatus.
7412 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
7413 ts_info.direction,
7414 pAdapter->hddWmmStatus.
7415 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
7416 pAdapter->hddWmmStatus.
7417 wmmAcStatus[SME_AC_BE].
7418 wmmAcAccessAllowed ? "YES" : "NO",
7419 pAdapter->hddWmmStatus.
7420 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
7421 ts_info.direction,
7422 pAdapter->hddWmmStatus.
7423 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
7424 pAdapter->hddWmmStatus.
7425 wmmAcStatus[SME_AC_BK].
7426 wmmAcAccessAllowed ? "YES" : "NO",
7427 pAdapter->hddWmmStatus.
7428 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
7429 ts_info.direction);
7430
7431 wrqu->data.length = strlen(extra) + 1;
7432 break;
7433 }
7434 case WE_GET_CHANNEL_LIST:
7435 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307436 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007437 uint8_t i, len;
7438 char *buf;
7439 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
7440 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
7441 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7442
7443 tChannelListInfo channel_list;
7444
7445 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05307446 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007447 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307448 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007449 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007450 return -EINVAL;
7451 }
7452 buf = extra;
7453 /*
7454 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
7455 * Maximum buffer needed = 5 * number of channels.
7456 * Check ifsufficient buffer is available and then
7457 * proceed to fill the buffer.
7458 */
7459 if (WE_MAX_STR_LEN <
7460 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007461 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007462 return -EINVAL;
7463 }
7464 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
7465 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307466 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007467 ubuf, &ubuf_len)) {
7468 /* Printing Country code in getChannelList */
7469 for (i = 0; i < (ubuf_len - 1); i++)
7470 len += scnprintf(buf + len,
7471 WE_MAX_STR_LEN - len,
7472 "%c", ubuf[i]);
7473 }
7474 for (i = 0; i < channel_list.num_channels; i++) {
7475 len +=
7476 scnprintf(buf + len, WE_MAX_STR_LEN - len,
7477 " %u", channel_list.channels[i]);
7478 }
7479 wrqu->data.length = strlen(extra) + 1;
7480
7481 break;
7482 }
7483#ifdef FEATURE_WLAN_TDLS
7484 case WE_GET_TDLS_PEERS:
7485 {
7486 wrqu->data.length =
7487 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
7488 WE_MAX_STR_LEN) + 1;
7489 break;
7490 }
7491#endif
7492#ifdef WLAN_FEATURE_11W
7493 case WE_GET_11W_INFO:
7494 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007495 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007496 pWextState->roamProfile.MFPEnabled);
7497
7498 snprintf(extra, WE_MAX_STR_LEN,
7499 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
7500 "\n Number of Unprotected Disassocs %d"
7501 "\n Number of Unprotected Deauths %d",
7502 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
7503 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
7504 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
7505 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
7506 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
7507 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
7508 pWextState->roamProfile.MFPEnabled,
7509 pAdapter->hdd_stats.hddPmfStats.
7510 numUnprotDisassocRx,
7511 pAdapter->hdd_stats.hddPmfStats.
7512 numUnprotDeauthRx);
7513
7514 wrqu->data.length = strlen(extra) + 1;
7515 break;
7516 }
7517#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007518 case WE_GET_IBSS_STA_INFO:
7519 {
7520 hdd_station_ctx_t *pHddStaCtx =
7521 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7522 int idx = 0;
7523 int length = 0, buf = 0;
7524
Naveen Rawatc45d1622016-07-05 12:20:09 -07007525 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007526 if (0 != pHddStaCtx->conn_info.staId[idx]) {
7527 buf = snprintf
7528 ((extra + length),
7529 WE_MAX_STR_LEN - length,
7530 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
7531 pHddStaCtx->conn_info.staId[idx],
7532 pHddStaCtx->conn_info.
7533 peerMacAddress[idx].bytes[0],
7534 pHddStaCtx->conn_info.
7535 peerMacAddress[idx].bytes[1],
7536 pHddStaCtx->conn_info.
7537 peerMacAddress[idx].bytes[2],
7538 pHddStaCtx->conn_info.
7539 peerMacAddress[idx].bytes[3],
7540 pHddStaCtx->conn_info.
7541 peerMacAddress[idx].bytes[4],
7542 pHddStaCtx->conn_info.
7543 peerMacAddress[idx].bytes[5]
7544 );
7545 length += buf;
7546 }
7547 }
7548 wrqu->data.length = strlen(extra) + 1;
7549 break;
7550 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007551 case WE_GET_PHYMODE:
7552 {
7553 bool ch_bond24 = false, ch_bond5g = false;
7554 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
7555 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7556 eCsrPhyMode phymode;
7557 eCsrBand currBand;
7558 tSmeConfigParams smeconfig;
7559
7560 sme_get_config_param(hal, &smeconfig);
7561 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7562 smeconfig.csrConfig.channelBondingMode24GHz)
7563 ch_bond24 = true;
7564
7565 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7566 smeconfig.csrConfig.channelBondingMode5GHz)
7567 ch_bond5g = true;
7568
7569 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307570 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007571 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007572 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007573 return -EIO;
7574 }
7575
7576 switch (phymode) {
7577 case eCSR_DOT11_MODE_AUTO:
7578 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
7579 break;
7580 case eCSR_DOT11_MODE_11n:
7581 case eCSR_DOT11_MODE_11n_ONLY:
7582 if (currBand == eCSR_BAND_24) {
7583 if (ch_bond24)
7584 snprintf(extra, WE_MAX_STR_LEN,
7585 "11NGHT40");
7586 else
7587 snprintf(extra, WE_MAX_STR_LEN,
7588 "11NGHT20");
7589 } else if (currBand == eCSR_BAND_5G) {
7590 if (ch_bond5g)
7591 snprintf(extra, WE_MAX_STR_LEN,
7592 "11NAHT40");
7593 else
7594 snprintf(extra, WE_MAX_STR_LEN,
7595 "11NAHT20");
7596 } else {
7597 snprintf(extra, WE_MAX_STR_LEN, "11N");
7598 }
7599 break;
7600 case eCSR_DOT11_MODE_abg:
7601 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
7602 break;
7603 case eCSR_DOT11_MODE_11a:
7604 snprintf(extra, WE_MAX_STR_LEN, "11A");
7605 break;
7606 case eCSR_DOT11_MODE_11b:
7607 case eCSR_DOT11_MODE_11b_ONLY:
7608 snprintf(extra, WE_MAX_STR_LEN, "11B");
7609 break;
7610 case eCSR_DOT11_MODE_11g:
7611 case eCSR_DOT11_MODE_11g_ONLY:
7612 snprintf(extra, WE_MAX_STR_LEN, "11G");
7613 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007614 case eCSR_DOT11_MODE_11ac:
7615 case eCSR_DOT11_MODE_11ac_ONLY:
7616 if (hddctx->config->vhtChannelWidth ==
7617 eHT_CHANNEL_WIDTH_20MHZ)
7618 snprintf(extra, WE_MAX_STR_LEN,
7619 "11ACVHT20");
7620 else if (hddctx->config->vhtChannelWidth ==
7621 eHT_CHANNEL_WIDTH_40MHZ)
7622 snprintf(extra, WE_MAX_STR_LEN,
7623 "11ACVHT40");
7624 else if (hddctx->config->vhtChannelWidth ==
7625 eHT_CHANNEL_WIDTH_80MHZ)
7626 snprintf(extra, WE_MAX_STR_LEN,
7627 "11ACVHT80");
7628 else if (hddctx->config->vhtChannelWidth ==
7629 eHT_CHANNEL_WIDTH_160MHZ)
7630 snprintf(extra, WE_MAX_STR_LEN,
7631 "11ACVHT160");
7632 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007633 }
7634
7635 wrqu->data.length = strlen(extra) + 1;
7636 break;
7637 }
7638
7639#ifdef FEATURE_OEM_DATA_SUPPORT
7640 case WE_GET_OEM_DATA_CAP:
7641 {
7642 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7643 }
7644#endif /* FEATURE_OEM_DATA_SUPPORT */
7645 case WE_GET_SNR:
7646 {
7647 int8_t s7snr = 0;
7648 int status = 0;
7649 hdd_context_t *pHddCtx;
7650 hdd_station_ctx_t *pHddStaCtx;
7651 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7652 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307653 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007654 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05307655
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007656 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7657 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
7658 eConnectionState_Associated !=
7659 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007660 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007661 pHddCtx->config->fEnableSNRMonitoring,
7662 pHddStaCtx->conn_info.connState);
7663 return -ENONET;
7664 }
7665 wlan_hdd_get_snr(pAdapter, &s7snr);
7666 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
7667 wrqu->data.length = strlen(extra) + 1;
7668 break;
7669 }
7670 default:
7671 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007672 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007673 sub_cmd);
7674 break;
7675 }
7676 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307677 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007678 return 0;
7679}
7680
7681static int iw_get_char_setnone(struct net_device *dev,
7682 struct iw_request_info *info,
7683 union iwreq_data *wrqu, char *extra)
7684{
7685 int ret;
7686
7687 cds_ssr_protect(__func__);
7688 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
7689 cds_ssr_unprotect(__func__);
7690
7691 return ret;
7692}
7693
7694/**
7695 * iw_setnone_getnone() - Generic "action" private ioctl handler
7696 * @dev: device upon which the ioctl was received
7697 * @info: ioctl request information
7698 * @wrqu: ioctl request data
7699 * @extra: ioctl extra data
7700 *
7701 * Return: 0 on success, non-zero on error
7702 */
7703static int __iw_setnone_getnone(struct net_device *dev,
7704 struct iw_request_info *info,
7705 union iwreq_data *wrqu, char *extra)
7706{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007707 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007708 hdd_context_t *hdd_ctx;
7709 int ret;
7710 int sub_cmd;
7711
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007712 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307713
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007714 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007715 ret = wlan_hdd_validate_context(hdd_ctx);
7716 if (0 != ret)
7717 return ret;
7718
7719#ifdef CONFIG_COMPAT
7720 /* this ioctl is a special case where a sub-ioctl is used and both
7721 * the number of get and set args is 0. in this specific case the
7722 * logic in iwpriv places the sub_cmd in the data.flags portion of
7723 * the iwreq. unfortunately the location of this field will be
7724 * different between 32-bit and 64-bit userspace, and the standard
7725 * compat support in the kernel does not handle this case. so we
7726 * need to explicitly handle it here.
7727 */
7728 if (is_compat_task()) {
7729 struct compat_iw_point *compat_iw_point =
7730 (struct compat_iw_point *)&wrqu->data;
7731 sub_cmd = compat_iw_point->flags;
7732 } else {
7733 sub_cmd = wrqu->data.flags;
7734 }
7735#else
7736 sub_cmd = wrqu->data.flags;
7737#endif
7738
7739 switch (sub_cmd) {
7740 case WE_GET_RECOVERY_STAT:
7741 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007742 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007743 sme_get_recovery_stats(hal);
7744 break;
7745 }
7746
Govind Singha471e5e2015-10-12 17:11:14 +05307747 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007748 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05307749 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
7750 0, DBG_CMD);
7751 break;
7752
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007753 case WE_IBSS_GET_PEER_INFO_ALL:
7754 {
7755 hdd_wlan_get_ibss_peer_info_all(adapter);
7756 break;
7757 }
7758
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007759 case WE_SET_REASSOC_TRIGGER:
7760 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007761 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7762 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307763 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007764 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307765 uint8_t operating_ch =
7766 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007767 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007768
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007769 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007770 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05307771 if (roaming_offload_enabled(hdd_ctx)) {
7772 qdf_mem_copy(bssid,
7773 &adapter->sessionCtx.station.conn_info.bssId,
7774 sizeof(bssid));
7775 hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId,
7776 bssid, operating_ch);
7777 } else {
7778 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
7779 NULL, modProfileFields, &roamId, 1);
7780 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007781 return 0;
7782 }
7783
7784 case WE_DUMP_AGC_START:
7785 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007786 hdd_notice("WE_DUMP_AGC_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007787 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007788 GEN_PARAM_DUMP_AGC_START,
7789 0, GEN_CMD);
7790 break;
7791 }
7792 case WE_DUMP_AGC:
7793 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007794 hdd_notice("WE_DUMP_AGC");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007795 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007796 GEN_PARAM_DUMP_AGC,
7797 0, GEN_CMD);
7798 break;
7799 }
7800
7801 case WE_DUMP_CHANINFO_START:
7802 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007803 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007804 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007805 GEN_PARAM_DUMP_CHANINFO_START,
7806 0, GEN_CMD);
7807 break;
7808 }
7809 case WE_DUMP_CHANINFO:
7810 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007811 hdd_notice("WE_DUMP_CHANINFO_START");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007812 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007813 GEN_PARAM_DUMP_CHANINFO,
7814 0, GEN_CMD);
7815 break;
7816 }
7817 case WE_DUMP_WATCHDOG:
7818 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007819 hdd_notice("WE_DUMP_WATCHDOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007820 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007821 GEN_PARAM_DUMP_WATCHDOG,
7822 0, GEN_CMD);
7823 break;
7824 }
7825#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
7826 case WE_DUMP_PCIE_LOG:
7827 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007828 hdd_err("WE_DUMP_PCIE_LOG");
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007829 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007830 GEN_PARAM_DUMP_PCIE_ACCESS_LOG,
7831 0, GEN_CMD);
7832 break;
7833 }
7834#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08007835 case WE_STOP_OBSS_SCAN:
7836 {
7837 /*
7838 * 1.OBSS Scan is mandatory while operating in 2.4GHz
7839 * 2.OBSS scan is stopped by Firmware during the disassociation
7840 * 3.OBSS stop comamnd is added for debugging purpose
7841 */
7842 tHalHandle hal;
7843
7844 hal = WLAN_HDD_GET_HAL_CTX(adapter);
7845 if (hal == NULL) {
7846 hdd_err("hal context is NULL");
7847 return -EINVAL;
7848 }
7849 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
7850 }
7851 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007852 default:
7853 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007854 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007855 break;
7856 }
7857 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307858 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007859 return ret;
7860}
7861
7862static int iw_setnone_getnone(struct net_device *dev,
7863 struct iw_request_info *info,
7864 union iwreq_data *wrqu, char *extra)
7865{
7866 int ret;
7867
7868 cds_ssr_protect(__func__);
7869 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
7870 cds_ssr_unprotect(__func__);
7871
7872 return ret;
7873}
7874
7875/**
7876 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
7877 * @dev: device upon which the ioctl was received
7878 * @info: ioctl request information
7879 * @wrqu: ioctl request data
7880 * @extra: ioctl extra data
7881 *
7882 * This is an SSR-protected generic handler for private ioctls which
7883 * take multiple arguments. Note that this implementation is also
7884 * somewhat unique in that it is shared by both STA-mode and SAP-mode
7885 * interfaces.
7886 *
7887 * Return: 0 on success, non-zero on error
7888 */
7889static int __iw_set_var_ints_getnone(struct net_device *dev,
7890 struct iw_request_info *info,
7891 union iwreq_data *wrqu, char *extra)
7892{
7893 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7894 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7895 int sub_cmd;
7896 int *apps_args = (int *) extra;
7897 hdd_context_t *hdd_ctx;
7898 int ret, num_args;
7899
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007900 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307901
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007902 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7903 ret = wlan_hdd_validate_context(hdd_ctx);
7904 if (0 != ret)
7905 return ret;
7906
7907 if (extra == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007908 hdd_err("NULL extra buffer pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007909 return -EINVAL;
7910 }
7911
7912 sub_cmd = wrqu->data.flags;
7913 num_args = wrqu->data.length;
7914
Jeff Johnson99bac312016-06-28 10:38:18 -07007915 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007916
7917 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08007918 case WE_IBSS_GET_PEER_INFO:
7919 {
7920 pr_info("Station ID = %d\n", apps_args[0]);
7921 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
7922 }
7923 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007924
7925 case WE_P2P_NOA_CMD:
7926 {
7927 p2p_app_setP2pPs_t p2pNoA;
7928
Krunal Sonif07bb382016-03-10 13:02:11 -08007929 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08007930 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
7931 hdd_device_mode_to_string(
7932 pAdapter->device_mode),
7933 pAdapter->device_mode);
7934 return -EINVAL;
7935 }
7936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007937 p2pNoA.opp_ps = apps_args[0];
7938 p2pNoA.ctWindow = apps_args[1];
7939 p2pNoA.duration = apps_args[2];
7940 p2pNoA.interval = apps_args[3];
7941 p2pNoA.count = apps_args[4];
7942 p2pNoA.single_noa_duration = apps_args[5];
7943 p2pNoA.psSelection = apps_args[6];
7944
Jeff Johnson99bac312016-06-28 10:38:18 -07007945 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
7946 apps_args[0], apps_args[1], apps_args[2],
7947 apps_args[3], apps_args[4],
7948 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007949
7950 hdd_set_p2p_ps(dev, &p2pNoA);
7951
7952 }
7953 break;
7954
7955 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
7956 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007957 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
7958 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307959 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007960 }
7961 break;
7962
7963 case WE_MTRACE_DUMP_CMD:
7964 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007965 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
7966 apps_args[0], apps_args[1],
7967 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307968 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007969 apps_args[1], apps_args[2],
7970 apps_args[3]);
7971
7972 }
7973 break;
7974
7975 case WE_POLICY_MANAGER_CLIST_CMD:
7976 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007977 hdd_err("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007978 cds_incr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007979 apps_args[1], apps_args[2], apps_args[3],
7980 apps_args[4], apps_args[5], apps_args[6],
7981 apps_args[7]);
7982 }
7983 break;
7984
7985 case WE_POLICY_MANAGER_DLIST_CMD:
7986 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007987 hdd_err("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007988 cds_decr_connection_count_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007989 apps_args[1]);
7990 }
7991 break;
7992
7993 case WE_POLICY_MANAGER_ULIST_CMD:
7994 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007995 hdd_err("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08007996 cds_update_connection_info_utfw(apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007997 apps_args[1], apps_args[2], apps_args[3],
7998 apps_args[4], apps_args[5], apps_args[6],
7999 apps_args[7]);
8000 }
8001 break;
8002
8003 case WE_POLICY_MANAGER_DBS_CMD:
8004 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008005 hdd_err("<iwpriv wlan0 pm_dbs> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008006 if (apps_args[0] == 0)
8007 wma_set_dbs_capability_ut(0);
8008 else
8009 wma_set_dbs_capability_ut(1);
8010
8011 if (apps_args[1] >= CDS_THROUGHPUT &&
8012 apps_args[1] <= CDS_LATENCY) {
8013 pr_info("setting system pref to [%d]\n", apps_args[1]);
8014 hdd_ctx->config->conc_system_pref = apps_args[1];
8015 }
8016 }
8017 break;
8018
8019 case WE_POLICY_MANAGER_PCL_CMD:
8020 {
Manishekar Chandrasekaran1db3abe2016-06-24 03:27:07 +05308021 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8022 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008023 uint32_t pcl_len = 0, i = 0;
8024
Jeff Johnson99bac312016-06-28 10:38:18 -07008025 hdd_err("<iwpriv wlan0 pm_pcl> is called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008026
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008027 cds_get_pcl(apps_args[0],
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +05308028 pcl, &pcl_len,
8029 weight_list, QDF_ARRAY_SIZE(weight_list));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008030 pr_info("PCL list for role[%d] is {", apps_args[0]);
8031 for (i = 0 ; i < pcl_len; i++)
8032 pr_info(" %d, ", pcl[i]);
8033 pr_info("}--------->\n");
8034 }
8035 break;
8036
8037 case WE_POLICY_MANAGER_CINFO_CMD:
8038 {
8039 struct cds_conc_connection_info *conn_info;
8040 uint32_t i = 0, len = 0;
8041
Jeff Johnson99bac312016-06-28 10:38:18 -07008042 hdd_err("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008043 conn_info = cds_get_conn_info(&len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008044 pr_info("+-----------------------------+\n");
8045 for (i = 0; i < len; i++) {
8046 pr_info("|table_index[%d]\t\t|\n", i);
8047 pr_info("|\t|vdev_id - %d\t\t|\n", conn_info->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008048 pr_info("|\t|chan - %d\t\t|\n", conn_info->chan);
Tushnim Bhattacharyya7624a182016-03-30 13:30:46 -07008049 pr_info("|\t|bw - %d\t\t|\n", conn_info->bw);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008050 pr_info("|\t|mode - %d\t\t|\n", conn_info->mode);
8051 pr_info("|\t|mac - %d\t\t|\n", conn_info->mac);
8052 pr_info("|\t|in_use - %d\t\t|\n", conn_info->in_use);
8053 pr_info("+-----------------------------+\n");
8054 conn_info++;
8055 }
8056 }
8057 break;
8058
8059 case WE_POLICY_SET_HW_MODE_CMD:
8060 {
8061 if (apps_args[0] == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008062 hdd_err("set hw mode for single mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308063 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308064 pAdapter->sessionId,
8065 HW_MODE_SS_2x2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008066 HW_MODE_80_MHZ,
8067 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8068 HW_MODE_DBS_NONE,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308069 HW_MODE_AGILE_DFS_NONE,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05308070 HW_MODE_SBS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308071 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008072 } else if (apps_args[0] == 1) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008073 hdd_err("set hw mode for dual mac");
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +05308074 cds_pdev_set_hw_mode(
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308075 pAdapter->sessionId,
8076 HW_MODE_SS_1x1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008077 HW_MODE_80_MHZ,
8078 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8079 HW_MODE_DBS,
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308080 HW_MODE_AGILE_DFS_NONE,
Nitesh Shah5b7bae02016-09-28 18:58:33 +05308081 HW_MODE_SBS_NONE,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308082 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008083 }
8084 }
8085 break;
8086
8087 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8088 {
8089 enum cds_conc_next_action action;
Jeff Johnson99bac312016-06-28 10:38:18 -07008090 hdd_err("<iwpriv wlan0 pm_query_action> is called");
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +05308091 action = cds_current_connections_update(pAdapter->sessionId,
8092 apps_args[0],
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05308093 SIR_UPDATE_REASON_UT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008094 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8095 }
8096 break;
8097 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8098 {
8099 bool allow;
Jeff Johnson99bac312016-06-28 10:38:18 -07008100 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008101 allow = cds_allow_concurrency(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008102 apps_args[0], apps_args[1], apps_args[2]);
8103 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8104 }
8105 break;
8106
8107 case WE_POLICY_MANAGER_SCENARIO_CMD:
8108 {
8109 clean_report(hdd_ctx);
8110 if (apps_args[0] == 1) {
8111 wlan_hdd_one_connection_scenario(hdd_ctx);
8112 } else if (apps_args[0] == 2) {
8113 wlan_hdd_two_connections_scenario(hdd_ctx,
8114 6, CDS_TWO_TWO);
8115 wlan_hdd_two_connections_scenario(hdd_ctx,
8116 36, CDS_TWO_TWO);
8117 wlan_hdd_two_connections_scenario(hdd_ctx,
8118 6, CDS_ONE_ONE);
8119 wlan_hdd_two_connections_scenario(hdd_ctx,
8120 36, CDS_ONE_ONE);
8121 } else if (apps_args[0] == 3) {
8122 /* MCC on same band with 2x2 same mac*/
8123 wlan_hdd_three_connections_scenario(hdd_ctx,
8124 6, 11, CDS_TWO_TWO, 0);
8125 /* MCC on diff band with 2x2 same mac*/
8126 wlan_hdd_three_connections_scenario(hdd_ctx,
8127 6, 36, CDS_TWO_TWO, 0);
8128 /* MCC on diff band with 1x1 diff mac */
8129 wlan_hdd_three_connections_scenario(hdd_ctx,
8130 36, 6, CDS_ONE_ONE, 0);
8131 /* MCC on diff band with 1x1 same mac */
8132 wlan_hdd_three_connections_scenario(hdd_ctx,
8133 36, 6, CDS_ONE_ONE, 1);
8134 /* SCC on same band with 2x2 same mac */
8135 wlan_hdd_three_connections_scenario(hdd_ctx,
8136 36, 36, CDS_TWO_TWO, 0);
8137 /* SCC on same band with 1x1 same mac */
8138 wlan_hdd_three_connections_scenario(hdd_ctx,
8139 36, 36, CDS_ONE_ONE, 1);
8140 /* MCC on same band with 2x2 same mac */
8141 wlan_hdd_three_connections_scenario(hdd_ctx,
8142 36, 149, CDS_TWO_TWO, 0);
8143 /* MCC on same band with 1x1 same mac */
8144 wlan_hdd_three_connections_scenario(hdd_ctx,
8145 36, 149, CDS_ONE_ONE, 1);
8146 }
8147 print_report(hdd_ctx);
8148 }
8149 break;
8150
8151#ifdef FEATURE_WLAN_TDLS
8152 case WE_TDLS_CONFIG_PARAMS:
8153 {
8154 tdls_config_params_t tdlsParams;
8155
8156 tdlsParams.tdls = apps_args[0];
8157 tdlsParams.tx_period_t = apps_args[1];
8158 tdlsParams.tx_packet_n = apps_args[2];
8159 /* ignore args[3] as discovery_period is not used anymore */
8160 tdlsParams.discovery_tries_n = apps_args[4];
8161 /* ignore args[5] as idle_timeout is not used anymore */
8162 tdlsParams.idle_packet_n = apps_args[6];
8163 /* ignore args[7] as rssi_hysteresis is not used anymore */
8164 tdlsParams.rssi_trigger_threshold = apps_args[8];
8165 tdlsParams.rssi_teardown_threshold = apps_args[9];
8166 tdlsParams.rssi_delta = apps_args[10];
8167
8168 wlan_hdd_tdls_set_params(dev, &tdlsParams);
8169 }
8170 break;
8171#endif
8172 case WE_UNIT_TEST_CMD:
8173 {
8174 t_wma_unit_test_cmd *unitTestArgs;
8175 cds_msg_t msg = { 0 };
8176 int i, j;
8177 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8178 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008179 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008180 apps_args[0]);
8181 return -EINVAL;
8182 }
Anurag Chouhan77564182016-09-03 16:38:01 +05308183 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
8184 (apps_args[1] < 0)) {
8185 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008186 apps_args[1]);
8187 return -EINVAL;
8188 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308189 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008190 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008191 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008192 return -ENOMEM;
8193 }
8194 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
8195 unitTestArgs->module_id = apps_args[0];
8196 unitTestArgs->num_args = apps_args[1];
8197 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
8198 unitTestArgs->args[i] = apps_args[j];
8199 }
8200 msg.type = SIR_HAL_UNIT_TEST_CMD;
8201 msg.reserved = 0;
8202 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308203 if (QDF_STATUS_SUCCESS !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05308204 cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308205 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -07008206 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008207 return -EINVAL;
8208 }
8209 }
8210 break;
8211#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8212 case WE_LED_FLASHING_PARAM:
8213 {
8214 int i;
8215 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008216 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008217 return -EINVAL;
8218 }
8219 for (i = 0; i < num_args; i++) {
8220 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008221 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008222 return -EINVAL;
8223 }
8224 }
8225 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8226 0, apps_args[0], apps_args[1]);
8227 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8228 1, apps_args[2], apps_args[3]);
8229 }
8230 break;
8231#endif
Manjeet Singhf82ed072016-07-08 11:40:00 +05308232 case WE_MAC_PWR_DEBUG_CMD:
8233 {
8234 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
8235 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8236 int i, j;
8237
8238 if (num_args < 3) {
8239 hdd_err("number of arguments can't be null %d",
8240 num_args);
8241 return -EINVAL;
8242 }
8243 if (num_args - 3 != apps_args[2]) {
8244 hdd_err("arg list of size %d doesn't match num_args %d",
8245 num_args-3, apps_args[2]);
8246 return -EINVAL;
8247 }
8248 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8249 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8250 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8251 return -EINVAL;
8252 }
8253 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8254 hdd_err("Too Many args %d", apps_args[2]);
8255 return -EINVAL;
8256 }
8257 mac_pwr_dbg_args.pdev_id = apps_args[0];
8258 mac_pwr_dbg_args.module_id = apps_args[1];
8259 mac_pwr_dbg_args.num_args = apps_args[2];
8260
8261 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8262 mac_pwr_dbg_args.args[i] = apps_args[j];
8263
8264 if (QDF_STATUS_SUCCESS !=
8265 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
8266 &mac_pwr_dbg_args)) {
8267 return -EINVAL;
8268 }
8269 }
8270 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008271 default:
8272 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008273 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008274 }
8275 break;
8276 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308277 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008278 return 0;
8279}
8280
8281/**
8282 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8283 * @dev: pointer to net_device structure
8284 * @info: pointer to iw_request_info structure
8285 * @wrqu: pointer to iwreq_data
8286 * @extra; extra
8287 *
8288 * Return: 0 on success, error number otherwise
8289 *
8290 */
8291static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8292 struct iw_request_info *info,
8293 union iwreq_data *wrqu, char *extra)
8294{
8295 union iwreq_data u_priv_wrqu;
8296 int apps_args[MAX_VAR_ARGS] = {0};
8297 int ret, num_args;
8298
Mukul Sharma64a70e82015-11-02 20:05:09 +05308299 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008300 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308301 return -EPERM;
8302 }
8303
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008304 /* Helper function to get iwreq_data with compat handling. */
8305 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8306 return -EINVAL;
8307
8308 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008309 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008310 return -EINVAL;
8311 }
8312
8313 num_args = u_priv_wrqu.data.length;
8314 if (num_args > MAX_VAR_ARGS)
8315 num_args = MAX_VAR_ARGS;
8316
8317 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8318 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008319 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008320 return -EFAULT;
8321 }
8322
8323 cds_ssr_protect(__func__);
8324 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8325 (char *)&apps_args);
8326 cds_ssr_unprotect(__func__);
8327 return ret;
8328}
8329
8330/**
8331 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8332 * @dev: device upon which the ioctl was received
8333 * @info: ioctl request information
8334 * @wrqu: ioctl request data
8335 * @extra: ioctl extra data
8336 *
8337 * This is a generic handler for private ioctls which take multiple
8338 * arguments. Note that this implementation is also somewhat unique
8339 * in that it is shared by both STA-mode and SAP-mode interfaces.
8340 *
8341 * Return: 0 on success, non-zero on error
8342 */
8343int iw_set_var_ints_getnone(struct net_device *dev,
8344 struct iw_request_info *info,
8345 union iwreq_data *wrqu, char *extra)
8346{
8347 int ret;
8348
8349 cds_ssr_protect(__func__);
8350 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8351 cds_ssr_unprotect(__func__);
8352 return ret;
8353}
8354
8355/**
8356 * iw_add_tspec - Add TSpec private ioctl handler
8357 * @dev: device upon which the ioctl was received
8358 * @info: ioctl request information
8359 * @wrqu: ioctl request data
8360 * @extra: ioctl extra data
8361 *
8362 * Return: 0 on success, non-zero on error
8363 */
8364static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
8365 union iwreq_data *wrqu, char *extra)
8366{
8367 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8368 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8369 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8370 int params[HDD_WLAN_WMM_PARAM_COUNT];
8371 sme_QosWmmTspecInfo tSpec;
8372 uint32_t handle;
8373 struct iw_point s_priv_data;
8374 hdd_context_t *hdd_ctx;
8375 int ret;
8376
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008377 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308378
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008379 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8380 ret = wlan_hdd_validate_context(hdd_ctx);
8381 if (0 != ret)
8382 return ret;
8383
8384 /* make sure the application is sufficiently priviledged */
8385 /* note that the kernel will do this for "set" ioctls, but since */
8386 /* this ioctl wants to return status to user space it must be */
8387 /* defined as a "get" ioctl */
8388 if (!capable(CAP_NET_ADMIN)) {
8389 return -EPERM;
8390 }
8391
8392 /* we must be associated in order to add a tspec */
8393 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
8394 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8395 return 0;
8396 }
8397 /* since we are defined to be a "get" ioctl, and since the number */
8398 /* of params exceeds the number of params that wireless extensions */
8399 /* will pass down in the iwreq_data, we must copy the "set" params. */
8400 /* We must handle the compat for iwreq_data in 32U/64K environment. */
8401
8402 /* helper function to get iwreq_data with compat handling. */
8403 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8404 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8405 return 0;
8406 }
8407 /* make sure all params are correctly passed to function */
8408 if ((NULL == s_priv_data.pointer) ||
8409 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
8410 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8411 return 0;
8412 }
8413 /* from user space ourselves */
8414 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
8415 /* hmmm, can't get them */
8416 return -EIO;
8417 }
8418 /* clear the tspec */
8419 memset(&tSpec, 0, sizeof(tSpec));
8420
8421 /* validate the handle */
8422 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8423 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8424 /* that one is reserved */
8425 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8426 return 0;
8427 }
8428 /* validate the TID */
8429 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
8430 /* out of range */
8431 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8432 return 0;
8433 }
8434 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
8435
8436 /* validate the direction */
8437 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
8438 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
8439 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
8440 break;
8441
8442 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
8443 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
8444 break;
8445
8446 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
8447 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
8448 break;
8449
8450 default:
8451 /* unknown */
8452 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8453 return 0;
8454 }
8455
8456 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
8457
8458 /* validate the user priority */
8459 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
8460 /* out of range */
8461 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8462 return 0;
8463 }
8464 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
8465 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008466 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008467 return 0;
8468 }
8469
Jeff Johnson99bac312016-06-28 10:38:18 -07008470 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008471 tSpec.ts_info.psb, tSpec.ts_info.up);
8472
8473 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
8474 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
8475 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
8476 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
8477 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
8478 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
8479 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
8480 tSpec.surplus_bw_allowance =
8481 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
8482 tSpec.min_service_interval =
8483 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
8484 tSpec.max_service_interval =
8485 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
8486 tSpec.suspension_interval =
8487 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
8488 tSpec.inactivity_interval =
8489 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
8490
8491 tSpec.ts_info.burst_size_defn =
8492 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
8493
8494 /* validate the ts info ack policy */
8495 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
8496 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
8497 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
8498 break;
8499
8500 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
8501 tSpec.ts_info.ack_policy =
8502 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
8503 break;
8504
8505 default:
8506 /* unknown */
8507 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8508 return 0;
8509 }
8510
8511 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308512 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008513 return 0;
8514}
8515
8516static int iw_add_tspec(struct net_device *dev,
8517 struct iw_request_info *info,
8518 union iwreq_data *wrqu, char *extra)
8519{
8520 int ret;
8521
8522 cds_ssr_protect(__func__);
8523 ret = __iw_add_tspec(dev, info, wrqu, extra);
8524 cds_ssr_unprotect(__func__);
8525
8526 return ret;
8527}
8528
8529/**
8530 * iw_del_tspec - Delete TSpec private ioctl handler
8531 * @dev: device upon which the ioctl was received
8532 * @info: ioctl request information
8533 * @wrqu: ioctl request data
8534 * @extra: ioctl extra data
8535 *
8536 * Return: 0 on success, non-zero on error
8537 */
8538static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
8539 union iwreq_data *wrqu, char *extra)
8540{
8541 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8542 hdd_context_t *hdd_ctx;
8543 int *params = (int *)extra;
8544 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8545 uint32_t handle;
8546 int ret;
8547
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008548 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308549
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008550 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8551 ret = wlan_hdd_validate_context(hdd_ctx);
8552 if (0 != ret)
8553 return ret;
8554
8555 /* make sure the application is sufficiently priviledged */
8556 /* note that the kernel will do this for "set" ioctls, but since */
8557 /* this ioctl wants to return status to user space it must be */
8558 /* defined as a "get" ioctl */
8559 if (!capable(CAP_NET_ADMIN)) {
8560 return -EPERM;
8561 }
8562
8563 /* although we are defined to be a "get" ioctl, the params we require */
8564 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8565 /* is no need to copy the params from user space */
8566
8567 /* validate the handle */
8568 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8569 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8570 /* that one is reserved */
8571 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8572 return 0;
8573 }
8574
8575 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308576 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008577 return 0;
8578}
8579
8580static int iw_del_tspec(struct net_device *dev,
8581 struct iw_request_info *info,
8582 union iwreq_data *wrqu, char *extra)
8583{
8584 int ret;
8585
8586 cds_ssr_protect(__func__);
8587 ret = __iw_del_tspec(dev, info, wrqu, extra);
8588 cds_ssr_unprotect(__func__);
8589
8590 return ret;
8591}
8592
8593/**
8594 * iw_get_tspec - Get TSpec private ioctl handler
8595 * @dev: device upon which the ioctl was received
8596 * @info: ioctl request information
8597 * @wrqu: ioctl request data
8598 * @extra: ioctl extra data
8599 *
8600 * Return: 0 on success, non-zero on error
8601 */
8602static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
8603 union iwreq_data *wrqu, char *extra)
8604{
8605 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8606 hdd_context_t *hdd_ctx;
8607 int *params = (int *)extra;
8608 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8609 uint32_t handle;
8610 int ret;
8611
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008612 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308613
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008614 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8615 ret = wlan_hdd_validate_context(hdd_ctx);
8616 if (0 != ret)
8617 return ret;
8618
8619 /* although we are defined to be a "get" ioctl, the params we require */
8620 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
8621 /* is no need to copy the params from user space */
8622
8623 /* validate the handle */
8624 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
8625 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
8626 /* that one is reserved */
8627 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8628 return 0;
8629 }
8630
8631 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308632 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008633 return 0;
8634}
8635
8636static int iw_get_tspec(struct net_device *dev,
8637 struct iw_request_info *info,
8638 union iwreq_data *wrqu, char *extra)
8639{
8640 int ret;
8641
8642 cds_ssr_protect(__func__);
8643 ret = __iw_get_tspec(dev, info, wrqu, extra);
8644 cds_ssr_unprotect(__func__);
8645
8646 return ret;
8647}
8648
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008649/**
8650 * iw_set_fties - Set FT IEs private ioctl handler
8651 * @dev: device upon which the ioctl was received
8652 * @info: ioctl request information
8653 * @wrqu: ioctl request data
8654 * @extra: ioctl extra data
8655 *
8656 * Each time the supplicant has the auth_request or reassoc request
8657 * IEs ready they are pushed to the driver. The driver will in turn
8658 * use it to send out the auth req and reassoc req for 11r FT Assoc.
8659 *
8660 * Return: 0 on success, non-zero on error
8661 */
8662static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
8663 union iwreq_data *wrqu, char *extra)
8664{
8665 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8666 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8667 hdd_context_t *hdd_ctx;
8668 int ret;
8669
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008670 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008672 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8673 ret = wlan_hdd_validate_context(hdd_ctx);
8674 if (0 != ret)
8675 return ret;
8676
8677 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008678 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008679 return -EINVAL;
8680 }
8681 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008682 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008683 return -EINVAL;
8684 }
8685 /* Added for debug on reception of Re-assoc Req. */
8686 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008687 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008688 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -07008689 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008690 }
Jeff Johnson99bac312016-06-28 10:38:18 -07008691 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008692
8693 /* Pass the received FT IEs to SME */
8694 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8695 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308696 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008697 return 0;
8698}
8699
8700static int iw_set_fties(struct net_device *dev,
8701 struct iw_request_info *info,
8702 union iwreq_data *wrqu, char *extra)
8703{
8704 int ret;
8705
8706 cds_ssr_protect(__func__);
8707 ret = __iw_set_fties(dev, info, wrqu, extra);
8708 cds_ssr_unprotect(__func__);
8709
8710 return ret;
8711}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008712
8713/**
8714 * iw_set_host_offload - Set host offload ioctl handler
8715 * @dev: device upon which the ioctl was received
8716 * @info: ioctl request information
8717 * @wrqu: ioctl request data
8718 * @extra: ioctl extra data
8719 *
8720 * Return: 0 on success, non-zero on error
8721 */
8722static int __iw_set_host_offload(struct net_device *dev,
8723 struct iw_request_info *info,
8724 union iwreq_data *wrqu, char *extra)
8725{
8726 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8727 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
8728 tSirHostOffloadReq offloadRequest;
8729 hdd_context_t *hdd_ctx;
8730 int ret;
8731
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008732 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008734 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8735 ret = wlan_hdd_validate_context(hdd_ctx);
8736 if (0 != ret)
8737 return ret;
8738
8739 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008740 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008741 return -EINVAL;
8742 }
8743
8744 /* Debug display of request components. */
8745 switch (pRequest->offloadType) {
8746 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008747 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008748 switch (pRequest->enableOrDisable) {
8749 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008750 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008751 break;
8752 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008753 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008754 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008755 hdd_warn(" ARP offload enable");
8756 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008757 pRequest->params.hostIpv4Addr[0],
8758 pRequest->params.hostIpv4Addr[1],
8759 pRequest->params.hostIpv4Addr[2],
8760 pRequest->params.hostIpv4Addr[3]);
8761 }
8762 break;
8763
8764 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07008765 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008766 switch (pRequest->enableOrDisable) {
8767 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008768 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008769 break;
8770 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008771 hdd_info(" enable");
8772 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008773 *(uint16_t *) (pRequest->params.hostIpv6Addr),
8774 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8775 2),
8776 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8777 4),
8778 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8779 6),
8780 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8781 8),
8782 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8783 10),
8784 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8785 12),
8786 *(uint16_t *) (pRequest->params.hostIpv6Addr +
8787 14));
8788 }
8789 }
8790
8791 /* Execute offload request. The reason that we can copy the
8792 * request information from the ioctl structure to the SME
8793 * structure is that they are laid out exactly the same.
8794 * Otherwise, each piece of information would have to be
8795 * copied individually.
8796 */
8797 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308798 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008799 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
8800 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008801 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008802 return -EINVAL;
8803 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308804 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008805 return 0;
8806}
8807
8808static int iw_set_host_offload(struct net_device *dev,
8809 struct iw_request_info *info,
8810 union iwreq_data *wrqu, char *extra)
8811{
8812 int ret;
8813
8814 cds_ssr_protect(__func__);
8815 ret = __iw_set_host_offload(dev, info, wrqu, extra);
8816 cds_ssr_unprotect(__func__);
8817
8818 return ret;
8819}
8820
8821/**
8822 * iw_set_keepalive_params - Set keepalive params ioctl handler
8823 * @dev: device upon which the ioctl was received
8824 * @info: ioctl request information
8825 * @wrqu: ioctl request data
8826 * @extra: ioctl extra data
8827 *
8828 * Return: 0 on success, non-zero on error
8829 */
8830static int __iw_set_keepalive_params(struct net_device *dev,
8831 struct iw_request_info *info,
8832 union iwreq_data *wrqu, char *extra)
8833{
8834 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008835 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008836 hdd_context_t *hdd_ctx;
8837 int ret;
8838
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008839 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008841 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8842 ret = wlan_hdd_validate_context(hdd_ctx);
8843 if (0 != ret)
8844 return ret;
8845
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008846 if (wrqu->data.length != sizeof(*request)) {
8847 hdd_err("Invalid length %d", wrqu->data.length);
8848 return -EINVAL;
8849 }
8850
8851 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
8852 hdd_err("Value of timePeriod %d exceed Max limit %d",
8853 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008854 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
8855 return -EINVAL;
8856 }
8857
8858 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008859 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
8860 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008861
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008862 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008863 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008864 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008865 break;
8866
8867 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008868 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008869
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008870 hdd_info("Host IP address: %d.%d.%d.%d",
8871 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
8872 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008873
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008874 hdd_info("Dest IP address: %d.%d.%d.%d",
8875 request->destIpv4Addr[0], request->destIpv4Addr[1],
8876 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008877
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08008878 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
8879 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008880 break;
8881 }
8882
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008883 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008884
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308885 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008886 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08008887 pAdapter->sessionId, request)) {
8888 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008889 return -EINVAL;
8890 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308891 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008892 return 0;
8893}
8894
8895static int iw_set_keepalive_params(struct net_device *dev,
8896 struct iw_request_info *info,
8897 union iwreq_data *wrqu,
8898 char *extra)
8899{
8900 int ret;
8901
8902 cds_ssr_protect(__func__);
8903 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
8904 cds_ssr_unprotect(__func__);
8905
8906 return ret;
8907}
8908
8909#ifdef WLAN_FEATURE_PACKET_FILTERING
8910/**
8911 * wlan_hdd_set_filter() - Set packet filter
8912 * @hdd_ctx: Global HDD context
8913 * @request: Packet filter request struct
8914 * @sessionId: Target session for the request
8915 *
8916 * Return: 0 on success, non-zero on error
8917 */
8918static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
8919 struct pkt_filter_cfg *request,
8920 uint8_t sessionId)
8921{
8922 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
8923 tSirRcvFltPktClearParam packetFilterClrReq = {0};
8924 int i = 0;
8925
8926 if (hdd_ctx->config->disablePacketFilter) {
8927 hdd_err("packet filtering disabled in ini returning");
8928 return 0;
8929 }
8930
8931 /* Debug display of request components. */
8932 hdd_info("Packet Filter Request : FA %d params %d",
8933 request->filter_action, request->num_params);
8934
8935 switch (request->filter_action) {
8936 case HDD_RCV_FILTER_SET:
8937 hdd_info("Set Packet Filter Request for Id: %d",
8938 request->filter_id);
8939
8940 packetFilterSetReq.filterId = request->filter_id;
8941 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
8942 hdd_err("Number of Params exceed Max limit %d",
8943 request->num_params);
8944 return -EINVAL;
8945 }
8946 packetFilterSetReq.numFieldParams = request->num_params;
8947 packetFilterSetReq.coalesceTime = 0;
8948 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
8949 for (i = 0; i < request->num_params; i++) {
8950 packetFilterSetReq.paramsData[i].protocolLayer =
8951 request->params_data[i].protocol_layer;
8952 packetFilterSetReq.paramsData[i].cmpFlag =
8953 request->params_data[i].compare_flag;
8954 packetFilterSetReq.paramsData[i].dataOffset =
8955 request->params_data[i].data_offset;
8956 packetFilterSetReq.paramsData[i].dataLength =
8957 request->params_data[i].data_length;
8958 packetFilterSetReq.paramsData[i].reserved = 0;
8959
8960 if (request->params_data[i].data_length >
8961 SIR_MAX_FILTER_TEST_DATA_LEN) {
8962 hdd_err("Error invalid data length %d",
8963 request->params_data[i].data_length);
8964 return -EINVAL;
8965 }
8966
8967 hdd_info("Proto %d Comp Flag %d Filter Type %d",
8968 request->params_data[i].protocol_layer,
8969 request->params_data[i].compare_flag,
8970 packetFilterSetReq.filterType);
8971
8972 hdd_info("Data Offset %d Data Len %d",
8973 request->params_data[i].data_offset,
8974 request->params_data[i].data_length);
8975
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07008976 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
8977 < (request->params_data[i].data_length)) {
8978 hdd_err("Error invalid data length %d",
8979 request->params_data[i].data_length);
8980 return -EINVAL;
8981 }
8982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008983 memcpy(&packetFilterSetReq.paramsData[i].compareData,
8984 request->params_data[i].compare_data,
8985 request->params_data[i].data_length);
8986 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
8987 request->params_data[i].data_mask,
8988 request->params_data[i].data_length);
8989
8990 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
8991 request->params_data[i].compare_data[0],
8992 request->params_data[i].compare_data[1],
8993 request->params_data[i].compare_data[2],
8994 request->params_data[i].compare_data[3],
8995 request->params_data[i].compare_data[4],
8996 request->params_data[i].compare_data[5]);
8997
8998 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
8999 request->params_data[i].data_mask[0],
9000 request->params_data[i].data_mask[1],
9001 request->params_data[i].data_mask[2],
9002 request->params_data[i].data_mask[3],
9003 request->params_data[i].data_mask[4],
9004 request->params_data[i].data_mask[5]);
9005 }
9006
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309007 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009008 sme_receive_filter_set_filter(hdd_ctx->hHal,
9009 &packetFilterSetReq,
9010 sessionId)) {
9011 hdd_err("Failure to execute Set Filter");
9012 return -EINVAL;
9013 }
9014
9015 break;
9016
9017 case HDD_RCV_FILTER_CLEAR:
9018
9019 hdd_info("Clear Packet Filter Request for Id: %d",
9020 request->filter_id);
9021 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309022 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009023 sme_receive_filter_clear_filter(hdd_ctx->hHal,
9024 &packetFilterClrReq,
9025 sessionId)) {
9026 hdd_err("Failure to execute Clear Filter");
9027 return -EINVAL;
9028 }
9029 break;
9030
9031 default:
9032 hdd_err("Packet Filter Request: Invalid %d",
9033 request->filter_action);
9034 return -EINVAL;
9035 }
9036 return 0;
9037}
9038
9039/**
9040 * __iw_set_packet_filter_params() - set packet filter parameters in target
9041 * @dev: Pointer to netdev
9042 * @info: Pointer to iw request info
9043 * @wrqu: Pointer to data
9044 * @extra: Pointer to extra data
9045 *
9046 * Return: 0 on success, non-zero on error
9047 */
9048static int __iw_set_packet_filter_params(struct net_device *dev,
9049 struct iw_request_info *info,
9050 union iwreq_data *wrqu, char *extra)
9051{
9052 int ret;
9053 hdd_context_t *hdd_ctx;
9054 struct iw_point priv_data;
9055 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9056 struct pkt_filter_cfg *request = NULL;
9057
Mukul Sharma472382f2015-11-02 20:16:31 +05309058 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009059 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309060 return -EPERM;
9061 }
9062
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009063 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309064
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009065 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9066 ret = wlan_hdd_validate_context(hdd_ctx);
9067 if (0 != ret)
9068 return ret;
9069
9070 if (hdd_priv_get_data(&priv_data, wrqu)) {
9071 hdd_err("failed to get priv data");
9072 return -EINVAL;
9073 }
9074
9075 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
9076 hdd_err("invalid priv data %p or invalid priv data length %d",
9077 priv_data.pointer, priv_data.length);
9078 return -EINVAL;
9079 }
9080
9081 /* copy data using copy_from_user */
9082 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9083 priv_data.length);
9084 if (NULL == request) {
9085 hdd_err("mem_alloc_copy_from_user_helper fail");
9086 return -ENOMEM;
9087 }
9088
9089 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
9090
9091 kfree(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309092 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009093 return ret;
9094}
9095
9096/**
9097 * iw_set_packet_filter_params() - set packet filter parameters in target
9098 * @dev: Pointer to netdev
9099 * @info: Pointer to iw request info
9100 * @wrqu: Pointer to data
9101 * @extra: Pointer to extra data
9102 *
9103 * Return: 0 on success, non-zero on error
9104 */
9105static int iw_set_packet_filter_params(struct net_device *dev,
9106 struct iw_request_info *info,
9107 union iwreq_data *wrqu, char *extra)
9108{
9109 int ret;
9110
9111 cds_ssr_protect(__func__);
9112 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9113 cds_ssr_unprotect(__func__);
9114
9115 return ret;
9116}
9117#endif
9118
9119
9120static int __iw_get_statistics(struct net_device *dev,
9121 struct iw_request_info *info,
9122 union iwreq_data *wrqu, char *extra)
9123{
9124
Anurag Chouhance0dc992016-02-16 18:18:03 +05309125 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309126 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009127 hdd_wext_state_t *pWextState;
9128 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9129 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9130 char *p = extra;
9131 int tlen = 0;
9132 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
9133 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
9134 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
9135 int ret;
9136
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009137 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009138
9139 ret = wlan_hdd_validate_context(hdd_ctx);
9140 if (0 != ret)
9141 return ret;
9142
9143 if (eConnectionState_Associated !=
9144 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9145
9146 wrqu->txpower.value = 0;
9147 } else {
9148 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9149 SME_SUMMARY_STATS |
9150 SME_GLOBAL_CLASSA_STATS |
9151 SME_GLOBAL_CLASSB_STATS |
9152 SME_GLOBAL_CLASSC_STATS |
9153 SME_GLOBAL_CLASSD_STATS |
9154 SME_PER_STA_STATS,
9155 hdd_statistics_cb, 0, false,
9156 (WLAN_HDD_GET_STATION_CTX_PTR
9157 (pAdapter))->conn_info.staId[0],
9158 pAdapter, pAdapter->sessionId);
9159
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309160 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009161 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009162 return -EINVAL;
9163 }
9164
9165 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9166
Anurag Chouhance0dc992016-02-16 18:18:03 +05309167 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05309168 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009169 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +05309170 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009171 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009172 /*Remove the SME statistics list by passing NULL in callback argument */
9173 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9174 SME_SUMMARY_STATS |
9175 SME_GLOBAL_CLASSA_STATS |
9176 SME_GLOBAL_CLASSB_STATS |
9177 SME_GLOBAL_CLASSC_STATS |
9178 SME_GLOBAL_CLASSD_STATS |
9179 SME_PER_STA_STATS,
9180 NULL, 0, false,
9181 (WLAN_HDD_GET_STATION_CTX_PTR
9182 (pAdapter))->conn_info.
9183 staId[0], pAdapter,
9184 pAdapter->sessionId);
9185
9186 return -EINVAL;
9187 }
9188 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
9189 (uint8_t) sizeof(pStats->retry_cnt),
9190 (char *)&(pStats->retry_cnt[0]), tlen);
9191
9192 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
9193 (uint8_t) sizeof(pStats->multiple_retry_cnt),
9194 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
9195
9196 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
9197 (uint8_t) sizeof(pStats->tx_frm_cnt),
9198 (char *)&(pStats->tx_frm_cnt[0]), tlen);
9199
9200 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
9201 (uint8_t) sizeof(pStats->rx_frm_cnt),
9202 (char *)&(pStats->rx_frm_cnt), tlen);
9203
9204 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
9205 (uint8_t) sizeof(pStats->frm_dup_cnt),
9206 (char *)&(pStats->frm_dup_cnt), tlen);
9207
9208 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
9209 (uint8_t) sizeof(pStats->fail_cnt),
9210 (char *)&(pStats->fail_cnt[0]), tlen);
9211
9212 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
9213 (uint8_t) sizeof(pStats->rts_fail_cnt),
9214 (char *)&(pStats->rts_fail_cnt), tlen);
9215
9216 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
9217 (uint8_t) sizeof(pStats->ack_fail_cnt),
9218 (char *)&(pStats->ack_fail_cnt), tlen);
9219
9220 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
9221 (uint8_t) sizeof(pStats->rts_succ_cnt),
9222 (char *)&(pStats->rts_succ_cnt), tlen);
9223
9224 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
9225 (uint8_t) sizeof(pStats->rx_discard_cnt),
9226 (char *)&(pStats->rx_discard_cnt), tlen);
9227
9228 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
9229 (uint8_t) sizeof(pStats->rx_error_cnt),
9230 (char *)&(pStats->rx_error_cnt), tlen);
9231
9232 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
9233 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9234 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9235
9236 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
9237 (uint8_t) sizeof(dStats->rx_byte_cnt),
9238 (char *)&(dStats->rx_byte_cnt), tlen);
9239
9240 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
9241 (uint8_t) sizeof(dStats->rx_rate),
9242 (char *)&(dStats->rx_rate), tlen);
9243
9244 /* Transmit rate, in units of 500 kbit/sec */
9245 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
9246 (uint8_t) sizeof(aStats->tx_rate),
9247 (char *)&(aStats->tx_rate), tlen);
9248
9249 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
9250 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
9251 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
9252 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
9253 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
9254 (char *)&(dStats->rx_mc_byte_cnt), tlen);
9255 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
9256 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
9257 (char *)&(dStats->rx_bc_byte_cnt), tlen);
9258 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
9259 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9260 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9261 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
9262 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
9263 (char *)&(dStats->tx_mc_byte_cnt), tlen);
9264 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
9265 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
9266 (char *)&(dStats->tx_bc_byte_cnt), tlen);
9267
9268 wrqu->data.length = tlen;
9269
9270 }
9271
9272 EXIT();
9273
9274 return 0;
9275}
9276
9277static int iw_get_statistics(struct net_device *dev,
9278 struct iw_request_info *info,
9279 union iwreq_data *wrqu, char *extra)
9280{
9281 int ret;
9282
9283 cds_ssr_protect(__func__);
9284 ret = __iw_get_statistics(dev, info, wrqu, extra);
9285 cds_ssr_unprotect(__func__);
9286
9287 return ret;
9288}
9289
9290#ifdef FEATURE_WLAN_SCAN_PNO
9291
9292/*Max Len for PNO notification*/
9293#define MAX_PNO_NOTIFY_LEN 100
9294void found_pref_network_cb(void *callbackContext,
9295 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9296{
9297 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
9298 union iwreq_data wrqu;
9299 char buf[MAX_PNO_NOTIFY_LEN + 1];
9300
Jeff Johnson99bac312016-06-28 10:38:18 -07009301 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009302 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9303
9304 /* create the event */
9305 memset(&wrqu, 0, sizeof(wrqu));
9306 memset(buf, 0, sizeof(buf));
9307
9308 snprintf(buf, MAX_PNO_NOTIFY_LEN,
9309 "QCOM: Found preferred network: %s with RSSI of -%u",
9310 pPrefNetworkFoundInd->ssId.ssId,
9311 (unsigned int)pPrefNetworkFoundInd->rssi);
9312
9313 wrqu.data.pointer = buf;
9314 wrqu.data.length = strlen(buf);
9315
9316 /* send the event */
9317
9318 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9319
9320}
9321
9322/**
9323 * __iw_set_pno() - Preferred Network Offload ioctl handler
9324 * @dev: device upon which the ioctl was received
9325 * @info: ioctl request information
9326 * @wrqu: ioctl request data
9327 * @extra: ioctl extra data
9328 *
9329 * This function parses a Preferred Network Offload command
9330 * Input is string based and expected to be of the form:
9331 *
9332 * <enable(1) | disable(0)>
9333 * when enabling:
9334 * <number of networks>
9335 * for each network:
9336 * <ssid_len> <ssid> <authentication> <encryption>
9337 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -07009338 * <scan_time (seconds)>
9339 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009340 * <suspend mode>
9341 *
9342 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -07009343 * 1 2 4 test 0 0 3 1 6 11 2 40 5 test2 4 4 6 1 2 3 4 5 6 1 0 5 2 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009344 *
9345 * this translates into:
9346 * -----------------------------
9347 * enable PNO
9348 * 2 networks
9349 * Network 1:
9350 * test - with authentication type 0 and encryption type 0,
9351 * search on 3 channels: 1 6 and 11,
9352 * SSID bcast type is unknown (directed probe will be sent if
9353 * AP not found) and must meet -40dBm RSSI
9354 * Network 2:
9355 * test2 - with authentication type 4 and encryption type 4,
9356 * search on 6 channels 1, 2, 3, 4, 5 and 6
9357 * bcast type is non-bcast (directed probe will be sent)
9358 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009359 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -07009360 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009361 */
9362static int __iw_set_pno(struct net_device *dev,
9363 struct iw_request_info *info,
9364 union iwreq_data *wrqu, char *extra)
9365{
9366 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9367 hdd_context_t *hdd_ctx;
9368 int ret;
9369 int offset;
9370 char *ptr;
9371 uint8_t i, j, params, mode;
9372
9373 /* request is a large struct, so we make it static to avoid
9374 * stack overflow. This API is only invoked via ioctl, so it
9375 * is serialized by the kernel rtnl_lock and hence does not
9376 * need to be reentrant
9377 */
9378 static tSirPNOScanReq request;
9379
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009380 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009381
9382 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9383 ret = wlan_hdd_validate_context(hdd_ctx);
9384 if (ret)
9385 return ret;
9386
9387 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
9388
9389 request.enable = 0;
9390 request.ucNetworksCount = 0;
9391
9392 ptr = extra;
9393
9394 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
9395 hdd_err("PNO enable input is not valid %s", ptr);
9396 return -EINVAL;
9397 }
9398
9399 if (0 == request.enable) {
9400 /* Disable PNO, ignore any other params */
9401 memset(&request, 0, sizeof(request));
9402 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9403 &request, adapter->sessionId,
9404 found_pref_network_cb, adapter);
9405 return 0;
9406 }
9407
9408 ptr += offset;
9409
9410 if (1 !=
9411 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
9412 hdd_err("PNO count input not valid %s", ptr);
9413 return -EINVAL;
9414
9415 }
9416
9417 hdd_info("PNO enable %d networks count %d offset %d",
9418 request.enable, request.ucNetworksCount, offset);
9419
9420 if ((0 == request.ucNetworksCount) ||
9421 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
9422 hdd_err("Network count %d invalid",
9423 request.ucNetworksCount);
9424 return -EINVAL;
9425 }
9426
9427 ptr += offset;
9428
9429 for (i = 0; i < request.ucNetworksCount; i++) {
9430
9431 request.aNetworks[i].ssId.length = 0;
9432
9433 params = sscanf(ptr, "%hhu %n",
9434 &(request.aNetworks[i].ssId.length),
9435 &offset);
9436
9437 if (1 != params) {
9438 hdd_err("PNO ssid length input is not valid %s", ptr);
9439 return -EINVAL;
9440 }
9441
9442 if ((0 == request.aNetworks[i].ssId.length) ||
9443 (request.aNetworks[i].ssId.length > 32)) {
9444 hdd_err("SSID Len %d is not correct for network %d",
9445 request.aNetworks[i].ssId.length, i);
9446 return -EINVAL;
9447 }
9448
9449 /* Advance to SSID */
9450 ptr += offset;
9451
9452 memcpy(request.aNetworks[i].ssId.ssId, ptr,
9453 request.aNetworks[i].ssId.length);
9454 ptr += request.aNetworks[i].ssId.length;
9455
9456 params = sscanf(ptr, "%u %u %hhu %n",
9457 &(request.aNetworks[i].authentication),
9458 &(request.aNetworks[i].encryption),
9459 &(request.aNetworks[i].ucChannelCount),
9460 &offset);
9461
9462 if (3 != params) {
9463 hdd_warn("Incorrect cmd %s", ptr);
9464 return -EINVAL;
9465 }
9466
9467 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
9468 request.aNetworks[i].ssId.length,
9469 request.aNetworks[i].ssId.length,
9470 request.aNetworks[i].ssId.ssId,
9471 request.aNetworks[i].authentication,
9472 request.aNetworks[i].encryption,
9473 request.aNetworks[i].ucChannelCount, offset);
9474
9475 /* Advance to channel list */
9476 ptr += offset;
9477
9478 if (SIR_PNO_MAX_NETW_CHANNELS <
9479 request.aNetworks[i].ucChannelCount) {
9480 hdd_warn("Incorrect number of channels");
9481 return -EINVAL;
9482 }
9483
9484 if (0 != request.aNetworks[i].ucChannelCount) {
9485 for (j = 0; j < request.aNetworks[i].ucChannelCount;
9486 j++) {
9487 if (1 !=
9488 sscanf(ptr, "%hhu %n",
9489 &(request.aNetworks[i].
9490 aChannels[j]), &offset)) {
9491 hdd_err("PNO network channel input is not valid %s",
9492 ptr);
9493 return -EINVAL;
9494 }
9495 /* Advance to next channel number */
9496 ptr += offset;
9497 }
9498 }
9499
9500 if (1 != sscanf(ptr, "%u %n",
9501 &(request.aNetworks[i].bcastNetwType),
9502 &offset)) {
9503 hdd_err("PNO broadcast network type input is not valid %s",
9504 ptr);
9505 return -EINVAL;
9506 }
9507
9508 hdd_notice("PNO bcastNetwType %d offset %d",
9509 request.aNetworks[i].bcastNetwType, offset);
9510
9511 /* Advance to rssi Threshold */
9512 ptr += offset;
9513 if (1 != sscanf(ptr, "%d %n",
9514 &(request.aNetworks[i].rssiThreshold),
9515 &offset)) {
9516 hdd_err("PNO rssi threshold input is not valid %s",
9517 ptr);
9518 return -EINVAL;
9519 }
9520 hdd_notice("PNO rssi %d offset %d",
9521 request.aNetworks[i].rssiThreshold, offset);
9522 /* Advance to next network */
9523 ptr += offset;
9524 } /* For ucNetworkCount */
9525
Dustin Brown43e87292016-10-10 10:38:25 -07009526 request.fast_scan_period = 0;
9527 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
9528 request.fast_scan_period *= MSEC_PER_SEC;
9529 ptr += offset;
9530 }
9531
9532 request.fast_scan_max_cycles = 0;
9533 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
9534 &offset) > 0)
9535 ptr += offset;
9536
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009537 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
9538
9539 request.modePNO = mode;
9540 /* for LA we just expose suspend option */
9541 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
9542 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
9543 }
9544
9545 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
9546 &request,
9547 adapter->sessionId,
9548 found_pref_network_cb, adapter);
9549
9550 return 0;
9551}
9552
9553static int iw_set_pno(struct net_device *dev,
9554 struct iw_request_info *info,
9555 union iwreq_data *wrqu, char *extra)
9556{
9557 int ret;
9558
9559 cds_ssr_protect(__func__);
9560 ret = __iw_set_pno(dev, info, wrqu, extra);
9561 cds_ssr_unprotect(__func__);
9562
9563 return ret;
9564}
9565#endif /* FEATURE_WLAN_SCAN_PNO */
9566
9567/* Common function to SetBand */
9568int hdd_set_band(struct net_device *dev, u8 ui_band)
9569{
9570 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9571 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9572 eCsrBand band;
9573
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309574 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009575 hdd_context_t *pHddCtx;
9576 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9577 eCsrBand currBand = eCSR_BAND_MAX;
9578 eCsrBand connectedBand;
9579
9580 pAdapterNode = NULL;
9581 pNext = NULL;
9582 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9583
9584 switch (ui_band) {
9585 case WLAN_HDD_UI_BAND_AUTO:
9586 band = eCSR_BAND_ALL;
9587 break;
9588 case WLAN_HDD_UI_BAND_5_GHZ:
9589 band = eCSR_BAND_5G;
9590 break;
9591 case WLAN_HDD_UI_BAND_2_4_GHZ:
9592 band = eCSR_BAND_24;
9593 break;
9594 default:
9595 band = eCSR_BAND_MAX;
9596 }
9597
Jeff Johnson99bac312016-06-28 10:38:18 -07009598 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009599
9600 if (band == eCSR_BAND_MAX) {
9601 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -07009602 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009603 return -EINVAL;
9604 }
9605
9606 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
9607 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009608 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009609 band, pHddCtx->config->nBandCapability);
9610 return -EIO;
9611 }
9612
9613 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009614 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009615 pHddCtx->config->nBandCapability);
9616 band = pHddCtx->config->nBandCapability;
9617 }
9618
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309619 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009620 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009621 return -EIO;
9622 }
9623
9624 if (currBand != band) {
9625 /* Change band request received.
9626 * Abort pending scan requests, flush the existing scan results,
9627 * and change the band capability
9628 */
Jeff Johnson99bac312016-06-28 10:38:18 -07009629 hdd_notice("Current band value = %u, new setting %u ",
9630 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009631
9632 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309633 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009634 pAdapter = pAdapterNode->pAdapter;
9635 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9636 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
9637 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
9638 connectedBand =
9639 hdd_conn_get_connected_band
9640 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
9641
9642 /* Handling is done only for STA and P2P */
9643 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -08009644 ((pAdapter->device_mode == QDF_STA_MODE)
9645 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009646 &&
9647 (hdd_conn_is_connected
9648 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
9649 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309650 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009651 long lrc;
9652
9653 /* STA already connected on current band, So issue disconnect
9654 * first, then change the band*/
9655
Jeff Johnson99bac312016-06-28 10:38:18 -07009656 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009657 hdd_device_mode_to_string(pAdapter->device_mode),
9658 pAdapter->device_mode, currBand, band);
9659 INIT_COMPLETION(pAdapter->disconnect_comp_var);
9660
9661 status =
9662 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
9663 (pAdapter),
9664 pAdapter->sessionId,
9665 eCSR_DISCONNECT_REASON_UNSPECIFIED);
9666
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309667 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009668 hdd_err("csr_roam_disconnect failure, returned %d",
9669 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009670 return -EINVAL;
9671 }
9672
9673 lrc =
9674 wait_for_completion_timeout(&pAdapter->
9675 disconnect_comp_var,
9676 msecs_to_jiffies
9677 (WLAN_WAIT_TIME_DISCONNECT));
9678
9679 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009680 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009681 return -ETIMEDOUT;
9682 }
9683 }
9684
9685 sme_scan_flush_result(hHal);
9686
9687 status =
9688 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
9689 pAdapterNode = pNext;
9690 }
9691
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309692 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009693 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009694 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009695 band);
9696 return -EINVAL;
9697 }
9698 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
9699 }
9700 return 0;
9701}
9702
9703int hdd_set_band_helper(struct net_device *dev, const char *command)
9704{
9705 uint8_t band;
9706 int ret;
9707
9708 /* Convert the band value from ascii to integer */
9709 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
9710 ret = kstrtou8(command, 10, &band);
9711 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009712 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009713 return -EINVAL;
9714 }
9715
9716 return hdd_set_band(dev, band);
9717}
9718
9719static int __iw_set_band_config(struct net_device *dev,
9720 struct iw_request_info *info,
9721 union iwreq_data *wrqu, char *extra)
9722{
9723 int *value = (int *)extra;
9724
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009725 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009726
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309727 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009728 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +05309729 return -EPERM;
9730 }
9731
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009732 return hdd_set_band(dev, value[0]);
9733}
9734
9735static int iw_set_band_config(struct net_device *dev,
9736 struct iw_request_info *info,
9737 union iwreq_data *wrqu, char *extra)
9738{
9739 int ret;
9740
9741 cds_ssr_protect(__func__);
9742 ret = __iw_set_band_config(dev, info, wrqu, extra);
9743 cds_ssr_unprotect(__func__);
9744
9745 return ret;
9746}
9747
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009748/**
9749 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
9750 * @adapter: Handle to adapter
9751 * @chan: Monitor mode channel
9752 * @bandwidth: Capture channel bandwidth
9753 *
9754 * Return: 0 on success else error code.
9755 */
9756static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
9757 uint32_t bandwidth)
9758{
9759 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9760 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
9761 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
9762 QDF_STATUS status;
9763 tHalHandle hal_hdl = hdd_ctx->hHal;
9764 struct qdf_mac_addr bssid;
9765 tCsrRoamProfile roam_profile;
9766 struct ch_params_s ch_params;
9767
9768 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
9769 hdd_err("Not supported, device is not in monitor mode");
9770 return -EINVAL;
9771 }
9772
9773 hdd_info("Set monitor mode Channel %d", chan);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009774 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
9775 roam_profile.ChannelInfo.numOfChannels = 1;
9776 roam_profile.phyMode = ch_info->phy_mode;
9777 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -07009778 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009779
9780 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
9781 QDF_MAC_ADDR_SIZE);
9782
9783 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07009784 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009785 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
9786 &roam_profile);
9787 if (status) {
9788 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
9789 status);
9790 }
9791
9792 return qdf_status_to_os_return(status);
9793}
9794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009795static int __iw_set_two_ints_getnone(struct net_device *dev,
9796 struct iw_request_info *info,
9797 union iwreq_data *wrqu, char *extra)
9798{
9799 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9800 int *value = (int *)extra;
9801 int sub_cmd = value[0];
9802 int ret;
9803 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9804
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009805 ENTER_DEV(dev);
9806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009807 ret = wlan_hdd_validate_context(hdd_ctx);
9808 if (0 != ret)
9809 return ret;
9810
9811 switch (sub_cmd) {
9812 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -07009813 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009814 ret = wma_cli_set_command(pAdapter->sessionId,
9815 WMI_STA_SMPS_PARAM_CMDID,
9816 value[1] << WMA_SMPS_PARAM_VALUE_S
9817 | value[2],
9818 VDEV_CMD);
9819 break;
9820#ifdef DEBUG
9821 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -07009822 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009823 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +05309824 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
9825 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009826 ret = wma_cli_set2_command(pAdapter->sessionId,
9827 GEN_PARAM_CRASH_INJECT,
9828 value[1], value[2], GEN_CMD);
9829 break;
9830#endif
Govind Singha471e5e2015-10-12 17:11:14 +05309831 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009832 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309833 value[1], value[2]);
9834 ret = wma_cli_set2_command(pAdapter->sessionId,
9835 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
9836 value[1], value[2], DBG_CMD);
9837 break;
9838 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -07009839 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +05309840 value[1], value[2]);
9841 ret = wma_cli_set2_command(pAdapter->sessionId,
9842 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
9843 value[1], value[2], DBG_CMD);
9844 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009845 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
9846 hdd_debug("Ioctl to set dual fw mode config");
9847 if (hdd_ctx->config->dual_mac_feature_disable) {
9848 hdd_err("Dual mac feature is disabled from INI");
9849 return -EPERM;
9850 }
9851 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08009852 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009853 break;
9854 case WE_DUMP_DP_TRACE_LEVEL:
9855 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
9856 value[1], value[2]);
9857 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309858 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +05309859 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
9860 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +05309861 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
9862 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009863 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07009864 case WE_SET_MON_MODE_CHAN:
9865 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
9866 break;
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009867 case WE_SET_WLAN_SUSPEND:
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07009868 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009869 break;
9870 case WE_SET_WLAN_RESUME:
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07009871 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy);
Rajeev Kumara78a0a42016-07-13 19:28:20 -07009872 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009873 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009874 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009875 break;
9876 }
9877
9878 return ret;
9879}
9880
9881static int iw_set_two_ints_getnone(struct net_device *dev,
9882 struct iw_request_info *info,
9883 union iwreq_data *wrqu, char *extra)
9884{
9885 int ret;
9886
9887 cds_ssr_protect(__func__);
9888 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
9889 cds_ssr_unprotect(__func__);
9890
9891 return ret;
9892}
9893
9894/* Define the Wireless Extensions to the Linux Network Device structure */
9895/* A number of these routines are NULL (meaning they are not implemented.) */
9896
9897static const iw_handler we_handler[] = {
9898 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
9899 (iw_handler) iw_get_name, /* SIOCGIWNAME */
9900 (iw_handler) NULL, /* SIOCSIWNWID */
9901 (iw_handler) NULL, /* SIOCGIWNWID */
9902 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
9903 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
9904 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
9905 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
9906 (iw_handler) NULL, /* SIOCSIWSENS */
9907 (iw_handler) NULL, /* SIOCGIWSENS */
9908 (iw_handler) NULL, /* SIOCSIWRANGE */
9909 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
9910 (iw_handler) NULL, /* SIOCSIWPRIV */
9911 (iw_handler) NULL, /* SIOCGIWPRIV */
9912 (iw_handler) NULL, /* SIOCSIWSTATS */
9913 (iw_handler) NULL, /* SIOCGIWSTATS */
9914 (iw_handler) NULL, /* SIOCSIWSPY */
9915 (iw_handler) NULL, /* SIOCGIWSPY */
9916 (iw_handler) NULL, /* SIOCSIWTHRSPY */
9917 (iw_handler) NULL, /* SIOCGIWTHRSPY */
9918 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
9919 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
9920 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
9921 (iw_handler) NULL, /* SIOCGIWAPLIST */
9922 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
9923 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
9924 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
9925 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
9926 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
9927 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
9928 (iw_handler) NULL, /* -- hole -- */
9929 (iw_handler) NULL, /* -- hole -- */
9930 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
9931 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
9932 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
9933 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
9934 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
9935 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
9936 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
9937 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
9938 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
9939 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
9940 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
9941 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
9942 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
9943 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
9944 (iw_handler) NULL, /* -- hole -- */
9945 (iw_handler) NULL, /* -- hole -- */
9946 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
9947 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
9948 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
9949 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
9950 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
9951 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
9952 (iw_handler) NULL, /* SIOCSIWPMKSA */
9953};
9954
9955static const iw_handler we_private[] = {
9956
9957 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
9958 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
9959 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
9960 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9961 iw_set_three_ints_getnone,
9962 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
9963 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
9964 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9965 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009966 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
9967 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009968 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
9969 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
9970 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009971 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009972 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
9973 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
9974 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
9975 iw_set_keepalive_params,
9976#ifdef WLAN_FEATURE_PACKET_FILTERING
9977 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
9978 iw_set_packet_filter_params,
9979#endif
9980#ifdef FEATURE_WLAN_SCAN_PNO
9981 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
9982#endif
9983 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
9984 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
9985 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
9986 iw_set_two_ints_getnone,
9987 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
9988 iw_set_dot11p_channel_sched,
9989};
9990
9991/*Maximum command length can be only 15 */
9992static const struct iw_priv_args we_private_args[] = {
9993
9994 /* handlers for main ioctl */
9995 {WLAN_PRIV_SET_INT_GET_NONE,
9996 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9997 0,
9998 ""},
9999
10000 /* handlers for sub-ioctl */
10001 {WE_SET_11D_STATE,
10002 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10003 0,
10004 "set11Dstate"},
10005
10006 {WE_WOWL,
10007 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10008 0,
10009 "wowl"},
10010
10011 {WE_SET_POWER,
10012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10013 0,
10014 "setPower"},
10015
10016 {WE_SET_MAX_ASSOC,
10017 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10018 0,
10019 "setMaxAssoc"},
10020
10021 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10022 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10023 "setAutoChannel" },
10024
10025 {WE_SET_SCAN_DISABLE,
10026 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10027 0,
10028 "scan_disable"},
10029
10030 {WE_SET_DATA_INACTIVITY_TO,
10031 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10032 0,
10033 "inactivityTO"},
10034
10035 {WE_SET_MAX_TX_POWER,
10036 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10037 0,
10038 "setMaxTxPower"},
10039
10040 {WE_SET_TX_POWER,
10041 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10042 0,
10043 "setTxPower"},
10044
10045 {WE_SET_MC_RATE,
10046 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10047 0,
10048 "setMcRate"},
10049
10050 {WE_SET_MAX_TX_POWER_2_4,
10051 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10052 0,
10053 "setTxMaxPower2G"},
10054
10055 {WE_SET_MAX_TX_POWER_5_0,
10056 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10057 0,
10058 "setTxMaxPower5G"},
10059
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010060 {WE_SET_PKTLOG,
10061 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10062 0,
10063 "pktlog"},
10064
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010065 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10066 * as well to keep same syntax as in SAP. Now onwards, STA
10067 * will support both */
10068 {WE_SET_MAX_TX_POWER,
10069 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10070 0,
10071 "setTxMaxPower"},
10072
10073 /* set Higher DTIM Transition (DTIM1 to DTIM3)
10074 * 1 = enable and 0 = disable */
10075 {
10076 WE_SET_HIGHER_DTIM_TRANSITION,
10077 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10078 0,
10079 "setHDtimTransn"
10080 },
10081
10082 {WE_SET_TM_LEVEL,
10083 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10084 0,
10085 "setTmLevel"},
10086
10087 {WE_SET_PHYMODE,
10088 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10089 0,
10090 "setphymode"},
10091
10092 {WE_SET_NSS,
10093 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10094 0,
10095 "nss"},
10096
10097 {WE_SET_LDPC,
10098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10099 0,
10100 "ldpc"},
10101
10102 {WE_SET_TX_STBC,
10103 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10104 0,
10105 "tx_stbc"},
10106
10107 {WE_SET_RX_STBC,
10108 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10109 0,
10110 "rx_stbc"},
10111
10112 {WE_SET_SHORT_GI,
10113 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10114 0,
10115 "shortgi"},
10116
10117 {WE_SET_RTSCTS,
10118 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10119 0,
10120 "enablertscts"},
10121
10122 {WE_SET_CHWIDTH,
10123 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10124 0,
10125 "chwidth"},
10126
10127 {WE_SET_ANI_EN_DIS,
10128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10129 0,
10130 "anienable"},
10131
10132 {WE_SET_ANI_POLL_PERIOD,
10133 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10134 0,
10135 "aniplen"},
10136
10137 {WE_SET_ANI_LISTEN_PERIOD,
10138 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10139 0,
10140 "anilislen"},
10141
10142 {WE_SET_ANI_OFDM_LEVEL,
10143 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10144 0,
10145 "aniofdmlvl"},
10146
10147 {WE_SET_ANI_CCK_LEVEL,
10148 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10149 0,
10150 "aniccklvl"},
10151
10152 {WE_SET_DYNAMIC_BW,
10153 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10154 0,
10155 "cwmenable"},
10156
10157 {WE_SET_CTS_CBW,
10158 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10159 0,
10160 "cts_cbw" },
10161
10162 {WE_SET_GTX_HT_MCS,
10163 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10164 0,
10165 "gtxHTMcs"},
10166
10167 {WE_SET_GTX_VHT_MCS,
10168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10169 0,
10170 "gtxVHTMcs"},
10171
10172 {WE_SET_GTX_USRCFG,
10173 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10174 0,
10175 "gtxUsrCfg"},
10176
10177 {WE_SET_GTX_THRE,
10178 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10179 0,
10180 "gtxThre"},
10181
10182 {WE_SET_GTX_MARGIN,
10183 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10184 0,
10185 "gtxMargin"},
10186
10187 {WE_SET_GTX_STEP,
10188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10189 0,
10190 "gtxStep"},
10191
10192 {WE_SET_GTX_MINTPC,
10193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10194 0,
10195 "gtxMinTpc"},
10196
10197 {WE_SET_GTX_BWMASK,
10198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10199 0,
10200 "gtxBWMask"},
10201
10202 {WE_SET_TX_CHAINMASK,
10203 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10204 0,
10205 "txchainmask"},
10206
10207 {WE_SET_RX_CHAINMASK,
10208 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10209 0,
10210 "rxchainmask"},
10211
10212 {WE_SET_11N_RATE,
10213 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10214 0,
10215 "set11NRates"},
10216
10217 {WE_SET_VHT_RATE,
10218 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10219 0,
10220 "set11ACRates"},
10221
10222 {WE_SET_AMPDU,
10223 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10224 0,
10225 "ampdu"},
10226
10227 {WE_SET_AMSDU,
10228 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10229 0,
10230 "amsdu"},
10231
10232 {WE_SET_BURST_ENABLE,
10233 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10234 0,
10235 "burst_enable"},
10236
10237 {WE_SET_BURST_DUR,
10238 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10239 0,
10240 "burst_dur"},
10241
10242 {WE_SET_TXPOW_2G,
10243 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10244 0,
10245 "txpow2g"},
10246
10247 {WE_SET_TXPOW_5G,
10248 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10249 0,
10250 "txpow5g"},
10251
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010252 /* Sub-cmds DBGLOG specific commands */
10253 {WE_DBGLOG_LOG_LEVEL,
10254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10255 0,
10256 "dl_loglevel"},
10257
10258 {WE_DBGLOG_VAP_ENABLE,
10259 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10260 0,
10261 "dl_vapon"},
10262
10263 {WE_DBGLOG_VAP_DISABLE,
10264 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10265 0,
10266 "dl_vapoff"},
10267
10268 {WE_DBGLOG_MODULE_ENABLE,
10269 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10270 0,
10271 "dl_modon"},
10272
10273 {WE_DBGLOG_MODULE_DISABLE,
10274 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10275 0,
10276 "dl_modoff"},
10277
10278 {WE_DBGLOG_MOD_LOG_LEVEL,
10279 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10280 0,
10281 "dl_mod_loglevel"},
10282
10283 {WE_DBGLOG_TYPE,
10284 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10285 0,
10286 "dl_type"},
10287 {WE_DBGLOG_REPORT_ENABLE,
10288 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10289 0,
10290 "dl_report"},
10291
10292 {WE_SET_TXRX_FWSTATS,
10293 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10294 0,
10295 "txrx_fw_stats"},
10296
10297 {WE_TXRX_FWSTATS_RESET,
10298 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10299 0,
10300 "txrx_fw_st_rst"},
10301
10302 {WE_PPS_PAID_MATCH,
10303 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10304 0, "paid_match"},
10305
10306 {WE_PPS_GID_MATCH,
10307 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10308 0, "gid_match"},
10309
10310 {WE_PPS_EARLY_TIM_CLEAR,
10311 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10312 0, "tim_clear"},
10313
10314 {WE_PPS_EARLY_DTIM_CLEAR,
10315 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10316 0, "dtim_clear"},
10317
10318 {WE_PPS_EOF_PAD_DELIM,
10319 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10320 0, "eof_delim"},
10321
10322 {WE_PPS_MACADDR_MISMATCH,
10323 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10324 0, "mac_match"},
10325
10326 {WE_PPS_DELIM_CRC_FAIL,
10327 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10328 0, "delim_fail"},
10329
10330 {WE_PPS_GID_NSTS_ZERO,
10331 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10332 0, "nsts_zero"},
10333
10334 {WE_PPS_RSSI_CHECK,
10335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10336 0, "rssi_chk"},
10337
10338 {WE_PPS_5G_EBT,
10339 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10340 0, "5g_ebt"},
10341
10342 {WE_SET_HTSMPS,
10343 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10344 0, "htsmps"},
10345
10346 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
10347 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10348 0, "set_qpspollcnt"},
10349
10350 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
10351 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10352 0, "set_qtxwake"},
10353
10354 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10355 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10356 0, "set_qwakeintv"},
10357
10358 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10359 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10360 0, "set_qnodatapoll"},
10361
10362 /* handlers for MCC time quota and latency sub ioctls */
10363 {WE_MCC_CONFIG_LATENCY,
10364 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10365 0, "setMccLatency"},
10366
10367 {WE_MCC_CONFIG_QUOTA,
10368 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10369 0, "setMccQuota"},
10370
10371 {WE_SET_DEBUG_LOG,
10372 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10373 0, "setDbgLvl"},
10374
10375 /* handlers for early_rx power save */
10376 {WE_SET_EARLY_RX_ADJUST_ENABLE,
10377 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10378 0, "erx_enable"},
10379
10380 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
10381 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10382 0, "erx_bmiss_val"},
10383
10384 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
10385 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10386 0, "erx_bmiss_smpl"},
10387
10388 {WE_SET_EARLY_RX_SLOP_STEP,
10389 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10390 0, "erx_slop_step"},
10391
10392 {WE_SET_EARLY_RX_INIT_SLOP,
10393 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10394 0, "erx_init_slop"},
10395
10396 {WE_SET_EARLY_RX_ADJUST_PAUSE,
10397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10398 0, "erx_adj_pause"},
10399
10400 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
10401 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10402 0, "erx_dri_sample"},
10403
10404 {WE_DUMP_STATS,
10405 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10406 0, "dumpStats"},
10407
10408 {WE_CLEAR_STATS,
10409 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10410 0, "clearStats"},
10411
Govind Singha471e5e2015-10-12 17:11:14 +053010412 {WE_START_FW_PROFILE,
10413 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10414 0, "startProfile"},
10415
Abhishek Singh1bdb1572015-10-16 16:24:19 +053010416 {WE_SET_CHANNEL,
10417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10418 0, "setChanChange" },
10419
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053010420 {WE_SET_CONC_SYSTEM_PREF,
10421 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10422 0, "setConcSysPref" },
10423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010424 {WLAN_PRIV_SET_NONE_GET_INT,
10425 0,
10426 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10427 ""},
10428
10429 /* handlers for sub-ioctl */
10430 {WE_GET_11D_STATE,
10431 0,
10432 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10433 "get11Dstate"},
10434
10435 {WE_IBSS_STATUS,
10436 0,
10437 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10438 "getAdhocStatus"},
10439
10440 {WE_GET_WLAN_DBG,
10441 0,
10442 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10443 "getwlandbg"},
10444
10445 {WE_GET_MAX_ASSOC,
10446 0,
10447 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10448 "getMaxAssoc"},
10449
10450 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
10451 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10452 "getAutoChannel" },
10453
10454 {WE_GET_CONCURRENCY_MODE,
10455 0,
10456 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10457 "getconcurrency"},
10458
10459 {WE_GET_NSS,
10460 0,
10461 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10462 "get_nss"},
10463
10464 {WE_GET_LDPC,
10465 0,
10466 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10467 "get_ldpc"},
10468
10469 {WE_GET_TX_STBC,
10470 0,
10471 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10472 "get_tx_stbc"},
10473
10474 {WE_GET_RX_STBC,
10475 0,
10476 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10477 "get_rx_stbc"},
10478
10479 {WE_GET_SHORT_GI,
10480 0,
10481 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10482 "get_shortgi"},
10483
10484 {WE_GET_RTSCTS,
10485 0,
10486 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10487 "get_rtscts"},
10488
10489 {WE_GET_CHWIDTH,
10490 0,
10491 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10492 "get_chwidth"},
10493
10494 {WE_GET_ANI_EN_DIS,
10495 0,
10496 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10497 "get_anienable"},
10498
10499 {WE_GET_ANI_POLL_PERIOD,
10500 0,
10501 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10502 "get_aniplen"},
10503
10504 {WE_GET_ANI_LISTEN_PERIOD,
10505 0,
10506 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10507 "get_anilislen"},
10508
10509 {WE_GET_ANI_OFDM_LEVEL,
10510 0,
10511 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10512 "get_aniofdmlvl"},
10513
10514 {WE_GET_ANI_CCK_LEVEL,
10515 0,
10516 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10517 "get_aniccklvl"},
10518
10519 {WE_GET_DYNAMIC_BW,
10520 0,
10521 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10522 "get_cwmenable"},
10523
10524 {WE_GET_GTX_HT_MCS,
10525 0,
10526 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10527 "get_gtxHTMcs"},
10528
10529 {WE_GET_GTX_VHT_MCS,
10530 0,
10531 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10532 "get_gtxVHTMcs"},
10533
10534 {WE_GET_GTX_USRCFG,
10535 0,
10536 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10537 "get_gtxUsrCfg"},
10538
10539 {WE_GET_GTX_THRE,
10540 0,
10541 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10542 "get_gtxThre"},
10543
10544 {WE_GET_GTX_MARGIN,
10545 0,
10546 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10547 "get_gtxMargin"},
10548
10549 {WE_GET_GTX_STEP,
10550 0,
10551 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10552 "get_gtxStep"},
10553
10554 {WE_GET_GTX_MINTPC,
10555 0,
10556 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10557 "get_gtxMinTpc"},
10558
10559 {WE_GET_GTX_BWMASK,
10560 0,
10561 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10562 "get_gtxBWMask"},
10563
10564 {WE_GET_TX_CHAINMASK,
10565 0,
10566 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10567 "get_txchainmask"},
10568
10569 {WE_GET_RX_CHAINMASK,
10570 0,
10571 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10572 "get_rxchainmask"},
10573
10574 {WE_GET_11N_RATE,
10575 0,
10576 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10577 "get_11nrate"},
10578
10579 {WE_GET_AMPDU,
10580 0,
10581 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10582 "get_ampdu"},
10583
10584 {WE_GET_AMSDU,
10585 0,
10586 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10587 "get_amsdu"},
10588
10589 {WE_GET_BURST_ENABLE,
10590 0,
10591 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10592 "get_burst_en"},
10593
10594 {WE_GET_BURST_DUR,
10595 0,
10596 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10597 "get_burst_dur"},
10598
10599 {WE_GET_TXPOW_2G,
10600 0,
10601 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10602 "get_txpow2g"},
10603
10604 {WE_GET_TXPOW_5G,
10605 0,
10606 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10607 "get_txpow5g"},
10608
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010609 {WE_GET_PPS_PAID_MATCH,
10610 0,
10611 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10612 "get_paid_match"},
10613
10614 {WE_GET_PPS_GID_MATCH,
10615 0,
10616 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10617 "get_gid_match"},
10618
10619 {WE_GET_PPS_EARLY_TIM_CLEAR,
10620 0,
10621 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10622 "get_tim_clear"},
10623
10624 {WE_GET_PPS_EARLY_DTIM_CLEAR,
10625 0,
10626 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10627 "get_dtim_clear"},
10628
10629 {WE_GET_PPS_EOF_PAD_DELIM,
10630 0,
10631 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10632 "get_eof_delim"},
10633
10634 {WE_GET_PPS_MACADDR_MISMATCH,
10635 0,
10636 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10637 "get_mac_match"},
10638
10639 {WE_GET_PPS_DELIM_CRC_FAIL,
10640 0,
10641 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10642 "get_delim_fail"},
10643
10644 {WE_GET_PPS_GID_NSTS_ZERO,
10645 0,
10646 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10647 "get_nsts_zero"},
10648
10649 {WE_GET_PPS_RSSI_CHECK,
10650 0,
10651 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10652 "get_rssi_chk"},
10653
10654 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
10655 0,
10656 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10657 "get_qpspollcnt"},
10658
10659 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
10660 0,
10661 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10662 "get_qtxwake"},
10663
10664 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10665 0,
10666 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10667 "get_qwakeintv"},
10668
10669 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10670 0,
10671 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10672 "get_qnodatapoll"},
10673
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010674 {WE_CAP_TSF,
10675 0,
10676 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10677 "cap_tsf"},
10678
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010679 {WE_GET_TEMPERATURE,
10680 0,
10681 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10682 "get_temp"},
10683 /* handlers for main ioctl */
10684 {WLAN_PRIV_SET_CHAR_GET_NONE,
10685 IW_PRIV_TYPE_CHAR | 512,
10686 0,
10687 ""},
10688
10689 /* handlers for sub-ioctl */
10690 {WE_WOWL_ADD_PTRN,
10691 IW_PRIV_TYPE_CHAR | 512,
10692 0,
10693 "wowlAddPtrn"},
10694
10695 {WE_WOWL_DEL_PTRN,
10696 IW_PRIV_TYPE_CHAR | 512,
10697 0,
10698 "wowlDelPtrn"},
10699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010700 /* handlers for sub-ioctl */
10701 {WE_NEIGHBOR_REPORT_REQUEST,
10702 IW_PRIV_TYPE_CHAR | 512,
10703 0,
10704 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080010705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010706 {WE_SET_AP_WPS_IE,
10707 IW_PRIV_TYPE_CHAR | 512,
10708 0,
10709 "set_ap_wps_ie"},
10710
10711 {WE_SET_CONFIG,
10712 IW_PRIV_TYPE_CHAR | 512,
10713 0,
10714 "setConfig"},
10715
10716 /* handlers for main ioctl */
10717 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
10718 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10719 0,
10720 ""},
10721
10722 /* handlers for sub-ioctl */
10723 {WE_SET_WLAN_DBG,
10724 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10725 0,
10726 "setwlandbg"},
10727
10728 /* handlers for sub-ioctl */
10729 {WE_SET_DP_TRACE,
10730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10731 0,
10732 "set_dp_trace"},
10733
10734 {WE_SET_SAP_CHANNELS,
10735 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10736 0,
10737 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053010738
10739 {WE_SET_FW_TEST,
10740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10741 0, "fw_test"},
10742
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010743 /* handlers for main ioctl */
10744 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
10745 0,
10746 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10747 "" },
10748 {WE_GET_TSF,
10749 0,
10750 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10751 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010752
10753 {WE_SET_DUAL_MAC_SCAN_CONFIG,
10754 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
10755 0,
10756 "set_scan_cfg"},
10757
10758 /* handlers for main ioctl */
10759 {WLAN_PRIV_GET_CHAR_SET_NONE,
10760 0,
10761 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10762 ""},
10763
10764 /* handlers for sub-ioctl */
10765 {WE_WLAN_VERSION,
10766 0,
10767 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10768 "version"},
10769 {WE_GET_STATS,
10770 0,
10771 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10772 "getStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053010773 {WE_LIST_FW_PROFILE,
10774 0,
10775 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10776 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010777 {WE_GET_STATES,
10778 0,
10779 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10780 "getHostStates"},
10781 {WE_GET_CFG,
10782 0,
10783 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10784 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010785 {WE_GET_RSSI,
10786 0,
10787 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10788 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010789 {WE_GET_WMM_STATUS,
10790 0,
10791 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10792 "getWmmStatus"},
10793 {
10794 WE_GET_CHANNEL_LIST,
10795 0,
10796 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10797 "getChannelList"
10798 },
10799#ifdef FEATURE_WLAN_TDLS
10800 {
10801 WE_GET_TDLS_PEERS,
10802 0,
10803 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10804 "getTdlsPeers"
10805 },
10806#endif
10807#ifdef WLAN_FEATURE_11W
10808 {
10809 WE_GET_11W_INFO,
10810 0,
10811 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10812 "getPMFInfo"
10813 },
10814#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010815 {
10816 WE_GET_IBSS_STA_INFO,
10817 0,
10818 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10819 "getIbssSTAs"
10820 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010821 {WE_GET_PHYMODE,
10822 0,
10823 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10824 "getphymode"},
10825#ifdef FEATURE_OEM_DATA_SUPPORT
10826 {WE_GET_OEM_DATA_CAP,
10827 0,
10828 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10829 "getOemDataCap"},
10830#endif /* FEATURE_OEM_DATA_SUPPORT */
10831 {WE_GET_SNR,
10832 0,
10833 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
10834 "getSNR"},
10835
10836 /* handlers for main ioctl */
10837 {WLAN_PRIV_SET_NONE_GET_NONE,
10838 0,
10839 0,
10840 ""},
10841
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010842 /* handlers for sub-ioctl */
10843 {
10844 WE_IBSS_GET_PEER_INFO_ALL,
10845 0,
10846 0,
10847 "ibssPeerInfoAll"
10848 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010849 {WE_GET_RECOVERY_STAT,
10850 0,
10851 0,
10852 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053010853
10854 {WE_GET_FW_PROFILE_DATA,
10855 0,
10856 0,
10857 "getProfileData"},
10858
10859 {WE_SET_REASSOC_TRIGGER,
10860 0,
10861 0,
10862 "reassoc"},
10863
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010864 {WE_DUMP_AGC_START,
10865 0,
10866 0,
10867 "dump_agc_start"},
10868
10869 {WE_DUMP_AGC,
10870 0,
10871 0,
10872 "dump_agc"},
10873
10874 {WE_DUMP_CHANINFO_START,
10875 0,
10876 0,
10877 "dump_chninfo_en"},
10878
10879 {WE_DUMP_CHANINFO,
10880 0,
10881 0,
10882 "dump_chninfo"},
10883
10884 {WE_DUMP_WATCHDOG,
10885 0,
10886 0,
10887 "dump_watchdog"},
10888#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
10889 {WE_DUMP_PCIE_LOG,
10890 0,
10891 0,
10892 "dump_pcie_log"},
10893#endif
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010894 {WE_STOP_OBSS_SCAN,
10895 0,
10896 0,
10897 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010898 /* handlers for main ioctl */
10899 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
10900 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10901 0,
10902 ""},
10903
10904 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010905 {WE_IBSS_GET_PEER_INFO,
10906 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10907 0,
10908 "ibssPeerInfo"},
10909
10910 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010911 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
10912 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10913 0,
10914 "setdumplog"},
10915
10916 {WE_MTRACE_DUMP_CMD,
10917 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10918 0,
10919 "dumplog"},
10920#ifdef MPC_UT_FRAMEWORK
10921 {WE_POLICY_MANAGER_CLIST_CMD,
10922 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10923 0,
10924 "pm_clist"},
10925
10926 {WE_POLICY_MANAGER_DLIST_CMD,
10927 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10928 0,
10929 "pm_dlist"},
10930
10931 {WE_POLICY_MANAGER_DBS_CMD,
10932 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10933 0,
10934 "pm_dbs"},
10935
10936 {WE_POLICY_MANAGER_PCL_CMD,
10937 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10938 0,
10939 "pm_pcl"},
10940
10941 {WE_POLICY_MANAGER_CINFO_CMD,
10942 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10943 0,
10944 "pm_cinfo"},
10945
10946 {WE_POLICY_MANAGER_ULIST_CMD,
10947 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10948 0,
10949 "pm_ulist"},
10950
10951 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
10952 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10953 0,
10954 "pm_query_action"},
10955
10956 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
10957 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10958 0,
10959 "pm_query_allow"},
10960
10961 {WE_POLICY_MANAGER_SCENARIO_CMD,
10962 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10963 0,
10964 "pm_run_scenario"},
10965
10966 {WE_POLICY_SET_HW_MODE_CMD,
10967 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10968 0,
10969 "pm_set_hw_mode"},
10970#endif
10971#ifdef FEATURE_WLAN_TDLS
10972 /* handlers for sub ioctl */
10973 {
10974 WE_TDLS_CONFIG_PARAMS,
10975 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10976 0,
10977 "setTdlsConfig"
10978 },
10979#endif
10980 {
10981 WE_UNIT_TEST_CMD,
10982 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10983 0,
10984 "setUnitTestCmd"
10985 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053010986 {
10987 WE_MAC_PWR_DEBUG_CMD,
10988 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10989 0,
10990 "halPwrDebug"
10991 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010992
10993#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
10994 {WE_LED_FLASHING_PARAM,
10995 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
10996 0,
10997 "gpio_control"},
10998#endif
10999 /* handlers for main ioctl */
11000 {WLAN_PRIV_ADD_TSPEC,
11001 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11002 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11003 "addTspec"},
11004
11005 /* handlers for main ioctl */
11006 {WLAN_PRIV_DEL_TSPEC,
11007 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11008 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11009 "delTspec"},
11010
11011 /* handlers for main ioctl */
11012 {WLAN_PRIV_GET_TSPEC,
11013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11015 "getTspec"},
11016
11017 /* handlers for main ioctl - host offload */
11018 {
11019 WLAN_PRIV_SET_HOST_OFFLOAD,
11020 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11021 0,
11022 "setHostOffload"
11023 }
11024 ,
11025
11026 {
11027 WLAN_GET_WLAN_STATISTICS,
11028 0,
11029 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11030 "getWlanStats"
11031 }
11032 ,
11033
11034 {
11035 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011036 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11037 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011038 0,
11039 "setKeepAlive"
11040 }
11041 ,
11042#ifdef WLAN_FEATURE_PACKET_FILTERING
11043 {
11044 WLAN_SET_PACKET_FILTER_PARAMS,
11045 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED |
11046 sizeof(struct pkt_filter_cfg),
11047 0,
11048 "setPktFilter"
11049 }
11050 ,
11051#endif
11052#ifdef FEATURE_WLAN_SCAN_PNO
11053 {
11054 WLAN_SET_PNO,
11055 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11056 0,
11057 "setpno"
11058 }
11059 ,
11060#endif
11061 {
11062 WLAN_SET_BAND_CONFIG,
11063 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11064 0,
11065 "SETBAND"
11066 }
11067 ,
11068 {
11069 WLAN_GET_LINK_SPEED,
11070 IW_PRIV_TYPE_CHAR | 18,
11071 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11072 }
11073 ,
11074
11075 /* handlers for main ioctl */
11076 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
11077 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11078 0,
11079 ""}
11080 ,
11081 {WE_SET_SMPS_PARAM,
11082 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11083 0, "set_smps_param"}
11084 ,
11085 {WLAN_SET_DOT11P_CHANNEL_SCHED,
11086 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
11087 0, "set_dot11p" }
11088 ,
11089#ifdef DEBUG
11090 {WE_SET_FW_CRASH_INJECT,
11091 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11092 0, "crash_inject"}
11093 ,
11094#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070011095#ifdef WLAN_SUSPEND_RESUME_TEST
11096 {WE_SET_WLAN_SUSPEND,
11097 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11098 0, "wlan_suspend"}
11099 ,
11100 {WE_SET_WLAN_RESUME,
11101 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11102 0, "wlan_resume"}
11103 ,
11104#endif
Govind Singha471e5e2015-10-12 17:11:14 +053011105 {WE_ENABLE_FW_PROFILE,
11106 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11107 0, "enableProfile"}
11108 ,
11109 {WE_SET_FW_PROFILE_HIST_INTVL,
11110 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11111 0, "set_hist_intvl"}
11112 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011113 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
11114 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11115 0, "set_fw_mode_cfg"}
11116 ,
11117 {WE_DUMP_DP_TRACE_LEVEL,
11118 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11119 0, "dump_dp_trace"}
11120 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011121 {WE_SET_MON_MODE_CHAN,
11122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11123 0, "setMonChan"}
11124 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070011125
11126 {WE_GET_ROAM_SYNCH_DELAY,
11127 0,
11128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11129 "hostroamdelay"}
11130 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011131};
11132
11133const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053011134 .num_standard = QDF_ARRAY_SIZE(we_handler),
11135 .num_private = QDF_ARRAY_SIZE(we_private),
11136 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011137
11138 .standard = (iw_handler *) we_handler,
11139 .private = (iw_handler *) we_private,
11140 .private_args = we_private_args,
11141 .get_wireless_stats = NULL,
11142};
11143
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011144/* hdd_set_wext() - configures bss parameters
11145 * @pAdapter: handle to adapter context
11146 *
11147 * Returns: none
11148 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011149int hdd_set_wext(hdd_adapter_t *pAdapter)
11150{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011151 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11152 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011153
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011154 ENTER();
11155
11156 if (!pwextBuf) {
11157 hdd_err("ERROR: pwextBuf is NULL");
11158 return QDF_STATUS_E_FAILURE;
11159 }
11160
11161 if (!pHddStaCtx) {
11162 hdd_err("ERROR: pHddStaCtx is NULL");
11163 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011164 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011165
11166 /* Now configure the roaming profile links. To SSID and bssid. */
11167 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011168 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011169
11170 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011171 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011172
11173 /*Set the numOfChannels to zero to scan all the channels */
11174 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11175 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11176
11177 /* Default is no encryption */
11178 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11179 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
11180 eCSR_ENCRYPT_TYPE_NONE;
11181
11182 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11183 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
11184 eCSR_ENCRYPT_TYPE_NONE;
11185
11186 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11187
11188 /* Default is no authentication */
11189 pwextBuf->roamProfile.AuthType.numEntries = 1;
11190 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11191
11192 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
11193 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11194
11195 /*Set the default scan mode */
11196 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
11197
11198 hdd_clear_roam_profile_ie(pAdapter);
11199
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011200 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011201 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011202
11203}
11204
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011205/**
11206 * hdd_register_wext() - register wext context
11207 * @dev: net device handle
11208 *
11209 * Registers wext interface context for a given net device
11210 *
11211 * Returns: 0 on success, errno on failure
11212 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011213int hdd_register_wext(struct net_device *dev)
11214{
11215 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011216 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011217 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011218
11219 ENTER();
11220
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011221 if (!pwextBuf) {
11222 hdd_err(FL("ERROR: pwextBuf is NULL"));
11223 return QDF_STATUS_E_FAILURE;
11224 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011225
11226 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011227 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
11228
11229 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->
11230 completion_var);
11231
11232 status = hdd_set_wext(pAdapter);
11233
Anurag Chouhance0dc992016-02-16 18:18:03 +053011234 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011235
Jeff Johnson99bac312016-06-28 10:38:18 -070011236 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011237 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011238 }
11239
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011240 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011241 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011242 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011243 }
11244
Anurag Chouhance0dc992016-02-16 18:18:03 +053011245 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->scanevent))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011246 hdd_err("ERROR: HDD scan event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011247 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011248 }
11249 /* Register as a wireless device */
11250 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11251
11252 EXIT();
11253 return 0;
11254}
11255
11256int hdd_unregister_wext(struct net_device *dev)
11257{
Jeff Johnson99bac312016-06-28 10:38:18 -070011258 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011259
11260 if (dev != NULL) {
11261 rtnl_lock();
11262 dev->wireless_handlers = NULL;
11263 rtnl_unlock();
11264 }
11265
11266 return 0;
11267}