blob: 5303b7aa47f9d157b15274438ab75ea56e3b81c1 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Dustin Brownd9322482017-01-09 12:46:03 -08002 * Copyright (c) 2011-2017 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
34#include <linux/version.h>
35#include <linux/module.h>
36#include <linux/kernel.h>
37#include <linux/init.h>
38#include <linux/wireless.h>
39#include <mac_trace.h>
40#include <wlan_hdd_includes.h>
41#include <cds_api.h>
Rajeev Kumarea95edd2017-01-11 20:49:36 -080042#include "scheduler_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043#include <net/arp.h>
Manjunathappa Prakash3454fd62016-04-01 08:52:06 -070044#include <cdp_txrx_stats.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "sir_params.h"
46#include "csr_api.h"
47#include "csr_inside_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "sme_rrm_internal.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include <ani_global.h>
50#include "dot11f.h"
51#include <wlan_hdd_wowl.h>
52#include <wlan_hdd_cfg.h>
53#include <wlan_hdd_wmm.h>
54#include "utils_api.h"
55#include "wlan_hdd_p2p.h"
56#ifdef FEATURE_WLAN_TDLS
57#include "wlan_hdd_tdls.h"
58#endif
59
60#include "cds_ieee80211_common.h"
61#include "ol_if_athvar.h"
62#include "dbglog_host.h"
63#include "wma.h"
64
65#include "wlan_hdd_power.h"
66#include "qwlan_version.h"
67#include "wlan_hdd_host_offload.h"
68
69#include <linux/wireless.h>
70#include <net/cfg80211.h>
71
72#include "wlan_hdd_misc.h"
73
74#include "qc_sap_ioctl.h"
75#include "sme_api.h"
76#include "wma_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053077#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078#include "wlan_hdd_assoc.h"
79#include "wlan_hdd_ioctl.h"
80#include "wlan_hdd_scan.h"
81#include "sme_power_save_api.h"
82#include "cds_concurrency.h"
83#include "wlan_hdd_conc_ut.h"
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070084#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085#include "wlan_hdd_ocb.h"
86#include "wlan_hdd_napi.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080087#include "cdp_txrx_flow_ctrl_legacy.h"
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070088#include "wlan_hdd_nan_datapath.h"
Nirav Shahbf1b0332016-05-25 14:27:39 +053089#include "wlan_hdd_stats.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070090#ifdef WLAN_SUSPEND_RESUME_TEST
91#include "wlan_hdd_driver_ops.h"
92#include "hif.h"
Rajeev Kumar9bb2e852016-09-24 12:29:25 -070093#include "pld_common.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070094#endif
Dhanashri Atree7d442a2016-07-14 18:20:29 -070095#include "wlan_hdd_lro.h"
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053096#include "cds_utils.h"
Jeff Johnsona6ace5b2017-01-23 07:11:02 -080097#include "wlan_hdd_request_manager.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099#define HDD_FINISH_ULA_TIME_OUT 800
100#define HDD_SET_MCBC_FILTERS_TO_FW 1
101#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103/* To Validate Channel against the Frequency and Vice-Versa */
104static const hdd_freq_chan_map_t freq_chan_map[] = {
105 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
106 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
107 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
108 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
109 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
110 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
111 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
112 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
113 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
114 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
115 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
116 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
117
118#define FREQ_CHAN_MAP_TABLE_SIZE \
119 (sizeof(freq_chan_map) / sizeof(freq_chan_map[0]))
120
121/* Private ioctls and their sub-ioctls */
122#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
123#define WE_SET_11D_STATE 1
124#define WE_WOWL 2
125#define WE_SET_POWER 3
126#define WE_SET_MAX_ASSOC 4
127#define WE_SET_SCAN_DISABLE 5
128#define WE_SET_DATA_INACTIVITY_TO 6
129#define WE_SET_MAX_TX_POWER 7
130#define WE_SET_HIGHER_DTIM_TRANSITION 8
131#define WE_SET_TM_LEVEL 9
132#define WE_SET_PHYMODE 10
133#define WE_SET_NSS 11
134#define WE_SET_LDPC 12
135#define WE_SET_TX_STBC 13
136#define WE_SET_RX_STBC 14
137#define WE_SET_SHORT_GI 15
138#define WE_SET_RTSCTS 16
139#define WE_SET_CHWIDTH 17
140#define WE_SET_ANI_EN_DIS 18
141#define WE_SET_ANI_POLL_PERIOD 19
142#define WE_SET_ANI_LISTEN_PERIOD 20
143#define WE_SET_ANI_OFDM_LEVEL 21
144#define WE_SET_ANI_CCK_LEVEL 22
145#define WE_SET_DYNAMIC_BW 23
146#define WE_SET_TX_CHAINMASK 24
147#define WE_SET_RX_CHAINMASK 25
148#define WE_SET_11N_RATE 26
149#define WE_SET_AMPDU 27
150#define WE_SET_AMSDU 28
151#define WE_SET_TXPOW_2G 29
152#define WE_SET_TXPOW_5G 30
153/* Private ioctl for firmware debug log */
154#define WE_DBGLOG_LOG_LEVEL 31
155#define WE_DBGLOG_VAP_ENABLE 32
156#define WE_DBGLOG_VAP_DISABLE 33
157#define WE_DBGLOG_MODULE_ENABLE 34
158#define WE_DBGLOG_MODULE_DISABLE 35
159#define WE_DBGLOG_MOD_LOG_LEVEL 36
160#define WE_DBGLOG_TYPE 37
161#define WE_SET_TXRX_FWSTATS 38
162#define WE_SET_VHT_RATE 39
163#define WE_DBGLOG_REPORT_ENABLE 40
164#define WE_TXRX_FWSTATS_RESET 41
165#define WE_SET_MAX_TX_POWER_2_4 42
166#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800167#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168/* Private ioctl for packet powe save */
169#define WE_PPS_PAID_MATCH 45
170#define WE_PPS_GID_MATCH 46
171#define WE_PPS_EARLY_TIM_CLEAR 47
172#define WE_PPS_EARLY_DTIM_CLEAR 48
173#define WE_PPS_EOF_PAD_DELIM 49
174#define WE_PPS_MACADDR_MISMATCH 50
175#define WE_PPS_DELIM_CRC_FAIL 51
176#define WE_PPS_GID_NSTS_ZERO 52
177#define WE_PPS_RSSI_CHECK 53
178#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
179#define WE_SET_HTSMPS 55
180/* Private ioctl for QPower */
181#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
182#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
183#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
184#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
185
186#define WE_SET_BURST_ENABLE 60
187#define WE_SET_BURST_DUR 61
188/* GTX Commands */
189#define WE_SET_GTX_HT_MCS 62
190#define WE_SET_GTX_VHT_MCS 63
191#define WE_SET_GTX_USRCFG 64
192#define WE_SET_GTX_THRE 65
193#define WE_SET_GTX_MARGIN 66
194#define WE_SET_GTX_STEP 67
195#define WE_SET_GTX_MINTPC 68
196#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530197
198/*
199 * <ioctl>
200 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
201 *
202 * @INPUT: set_value
203 *
204 * @OUTPUT: None
205 *
206 * This IOCTL is used to set the MCC latency value in milliseconds
207 * during STA-P2P concurrency.
208 *
209 * If 0ms latency is provided, then FW will set to a default.
210 * Otherwise, latency must be at least 30ms.
211 *
212 * @E.g: iwpriv wlan0 setMccLatency 40
213 *
214 *
215 * Supported Feature: Concurrency
216 *
217 * Usage: Internal/External
218 *
219 * </ioctl>
220 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530222
223/*
224 * <ioctl>
225 * setMccQuota- Set the quota for P2P cases
226 *
227 * @INPUT: set_value [0,100]
228 *
229 * @OUTPUT: None
230 *
231 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
232 *
233 * Currently used to set time quota for 2 MCC vdevs/adapters using
234 * (operating channel, quota) for each mode.
235 * The info is provided run time using iwpriv command:
236 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
237 * Note: the quota provided in command is for the same mode in cmd.
238 * HDD checks if MCC mode is active, gets the second mode and its
239 * operating chan.
240 * Quota for the 2nd role is calculated as 100 - quota of first mode.
241 *
242 * @E.g: iwpriv wlan0 setMccQuota 50
243 * iwpriv p2p0 setMccQuota 50
244 *
245 * Supported Feature: Concurrency
246 *
247 * Usage: Internal/External
248 *
249 * </ioctl>
250 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251#define WE_MCC_CONFIG_QUOTA 71
252/* Private IOCTL for debug connection issues */
253#define WE_SET_DEBUG_LOG 72
254#ifdef WE_SET_TX_POWER
255#undef WE_SET_TX_POWER
256#endif
257#define WE_SET_TX_POWER 74
258/* Private ioctl for earlyrx power save feature */
259#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
260#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
261#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
262#define WE_SET_EARLY_RX_SLOP_STEP 78
263#define WE_SET_EARLY_RX_INIT_SLOP 79
264#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
265#define WE_SET_MC_RATE 81
266#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
267/* Private ioctl for packet power save */
268#define WE_PPS_5G_EBT 83
269#define WE_SET_CTS_CBW 84
270#define WE_DUMP_STATS 85
271#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530272/* Private sub ioctl for starting/stopping the profiling */
273#define WE_START_FW_PROFILE 87
Abhishek Singh3c507012016-12-01 11:15:42 +0530274/*
275 * <ioctl>
276 * setChanChange - Initiate channel change
277 *
278 * @INPUT: channel number to switch to.
279 *
280 * @OUTPUT: None
281 *
282 * This IOCTL is used to initiate a channel change.
283 * If called on STA/CLI interface it will send the
284 * ECSA action frame to the connected SAP/GO asking to
285 * initiate the ECSA, if supported.
286 * If called on SAP/GO interface it will initiate
287 * ECSA and ask connected peers to move to new channel.
288 *
289 * @E.g: iwpriv wlan0 setChanChange <channel>
290 * iwpriv wlan0 setChanChange 1
291 *
292 * Supported Feature: ECSA
293 *
294 * Usage: Internal/External
295 *
296 * </ioctl>
297 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +0530298#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +0530299#define WE_SET_CONC_SYSTEM_PREF 89
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300
301/* Private ioctls and their sub-ioctls */
302#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
303#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304#define WE_SET_SAP_CHANNELS 3
305#define WE_GET_WLAN_DBG 4
306#define WE_GET_MAX_ASSOC 6
307/* 7 is unused */
308#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530309
310/*
311 * <ioctl>
312 * getconcurrency - Get concurrency mode
313 *
314 * @INPUT: None
315 *
316 * @OUTPUT: It shows concurrency value
317 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
318 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
319 * 8:OCB 9:EPPING 10:QVIT 11:NDI
320 *
321 * This IOCTL is used to retrieve concurrency mode.
322 *
323 * @E.g: iwpriv wlan0 getconcurrency
324 * wlan0 getconcurrency:5
325 * Above value shows STA+P2P_Client
326 *
327 * Supported Feature: Concurrency
328 *
329 * Usage: Internal/External
330 *
331 * </ioctl>
332 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333#define WE_GET_CONCURRENCY_MODE 9
334#define WE_GET_NSS 11
335#define WE_GET_LDPC 12
336#define WE_GET_TX_STBC 13
337#define WE_GET_RX_STBC 14
338#define WE_GET_SHORT_GI 15
339#define WE_GET_RTSCTS 16
340#define WE_GET_CHWIDTH 17
341#define WE_GET_ANI_EN_DIS 18
342#define WE_GET_ANI_POLL_PERIOD 19
343#define WE_GET_ANI_LISTEN_PERIOD 20
344#define WE_GET_ANI_OFDM_LEVEL 21
345#define WE_GET_ANI_CCK_LEVEL 22
346#define WE_GET_DYNAMIC_BW 23
347#define WE_GET_TX_CHAINMASK 24
348#define WE_GET_RX_CHAINMASK 25
349#define WE_GET_11N_RATE 26
350#define WE_GET_AMPDU 27
351#define WE_GET_AMSDU 28
352#define WE_GET_TXPOW_2G 29
353#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -0800354/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355#define WE_GET_PPS_PAID_MATCH 32
356#define WE_GET_PPS_GID_MATCH 33
357#define WE_GET_PPS_EARLY_TIM_CLEAR 34
358#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
359#define WE_GET_PPS_EOF_PAD_DELIM 36
360#define WE_GET_PPS_MACADDR_MISMATCH 37
361#define WE_GET_PPS_DELIM_CRC_FAIL 38
362#define WE_GET_PPS_GID_NSTS_ZERO 39
363#define WE_GET_PPS_RSSI_CHECK 40
364/* Private ioctl for QPower */
365#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
366#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
367#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
368#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
369#define WE_GET_BURST_ENABLE 45
370#define WE_GET_BURST_DUR 46
371/* GTX Commands */
372#define WE_GET_GTX_HT_MCS 47
373#define WE_GET_GTX_VHT_MCS 48
374#define WE_GET_GTX_USRCFG 49
375#define WE_GET_GTX_THRE 50
376#define WE_GET_GTX_MARGIN 51
377#define WE_GET_GTX_STEP 52
378#define WE_GET_GTX_MINTPC 53
379#define WE_GET_GTX_BWMASK 54
380#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700381#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700382#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383
384/* Private ioctls and their sub-ioctls */
385#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
386
387/* Private ioctls and their sub-ioctls */
388#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
389#define WE_WOWL_ADD_PTRN 1
390#define WE_WOWL_DEL_PTRN 2
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391#define WE_NEIGHBOR_REPORT_REQUEST 3
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392#define WE_SET_AP_WPS_IE 4 /* This is called in station mode to set probe rsp ie. */
393#define WE_SET_CONFIG 5
394
395/* Private ioctls and their sub-ioctls */
396#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
397#define WE_SET_WLAN_DBG 1
398#define WE_SET_DP_TRACE 2
399#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +0530400#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401
402/* Private ioctls and their sub-ioctls */
403#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
404#define WE_WLAN_VERSION 1
405#define WE_GET_STATS 2
406#define WE_GET_CFG 3
407#define WE_GET_WMM_STATUS 4
408#define WE_GET_CHANNEL_LIST 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -0800410
411/*
412 * <ioctl>
413 * getSuspendStats - Get suspend/resume stats
414 *
415 * @INPUT: None
416 *
417 * @OUTPUT: character string containing formatted suspend/resume stats
418 *
419 * This ioctl is used to get suspend/resume stats formatted for display.
420 * Currently it includes suspend/resume counts, wow wake up reasons, and
421 * suspend fail reasons.
422 *
423 * @E.g: iwpriv wlan0 getSuspendStats
424 * iwpriv wlan0 getSuspendStats
425 *
426 * Supported Feature: suspend/resume
427 *
428 * Usage: Internal
429 *
430 * </ioctl>
431 */
432#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +0530434/*
435 * <ioctl>
436 * getTdlsPeers - Get all TDLS peers.
437 *
438 * @INPUT: None
439 *
440 * @OUTPUT: Returns the MAC address of all the TDLS peers
441 * wlan0 getTdlsPeers:
442 * MAC Id cap up RSSI
443 * ---------------------------------
444 * 00:0a:f5:0e:bd:18 2 Y Y -44
445 * 00:0a:f5:bf:0e:12 0 N N 0
446 *
447 * This IOCTL is used to get all TDLS peers.
448 *
449 * @E.g: iwpriv wlan0 getTdlsPeers
450 *
451 * Supported Feature: TDLS
452 *
453 * Usage: Internal/External
454 *
455 * </ioctl>
456 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457#define WE_GET_TDLS_PEERS 8
458#endif
459#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +0530460/*
461 * <ioctl>
462 * getPMFInfo - get the PMF info of the connected session
463 *
464 * @INPUT: None
465 *
466 * @OUTPUT:
467 * wlan0 getPMFInfo:
468 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
469 * Number of Unprotected Disassocs 0
470 * Number of Unprotected Deauths 0
471 *
472 * This IOCTL is used to get the PMF stats/status of the current
473 * connection.
474 *
475 * @e.g:iwpriv wlan0 getPMFInfo
476 *
477 * Supported Feature: PMF
478 *
479 * Usage: Internal/External
480 *
481 * </ioctl>
482 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483#define WE_GET_11W_INFO 9
484#endif
485#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +0530486/*
487 * <ioctl>
488 * getIbssSTAs - get ibss sta info
489 *
490 * @INPUT: None
491 *
492 * @OUTPUT: Give the MAC of the IBSS STA
493 * wlan0 getIbssSTAs:
494 * 1 .8c:fd:f0:01:9c:bf
495 *
496 * This IOCTL is used to get ibss sta info
497 *
498 * @E.g: iwpriv wlan0 getIbssSTAs
499 *
500 * Supported Feature: IBSS
501 *
502 * Usage: Internal/External
503 *
504 * </ioctl>
505 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800506#define WE_GET_IBSS_STA_INFO 11
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507#define WE_GET_PHYMODE 12
508#ifdef FEATURE_OEM_DATA_SUPPORT
509#define WE_GET_OEM_DATA_CAP 13
510#endif
511#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +0530512#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513
514/* Private ioctls and their sub-ioctls */
515#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
516#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +0530517/*
518 * <ioctl>
519 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
520 *
521 * @INPUT: None
522 *
523 * @OUTPUT: print ibss peer in info logs
524 * pPeerInfo->numIBSSPeers = 1
525 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
526 *
527 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
528 * in info logs
529 *
530 * @E.g: iwpriv wlan0 ibssPeerInfoAll
531 *
532 * Supported Feature: IBSS
533 *
534 * Usage: Internal/External
535 *
536 * </ioctl>
537 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800538#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -0800539/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800540#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -0800541#define WE_GET_FW_PROFILE_DATA 18
542#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800543
544/* Private ioctls and their sub-ioctls */
545#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
546
547#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +0530548/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549
Manjeet Singhf82ed072016-07-08 11:40:00 +0530550#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551
552#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +0530553/*
554 * <ioctl>
555 * setTdlsConfig - Set TDLS configuration parameters.
556 *
557 * @INPUT: 11 TDLS configuration parameters
558 * @args[0]: tdls: [0..2]
559 * @args[1]: tx_period_t: [1000..4294967295UL]
560 * @args[2]: tx_packet_n: [0..4294967295UL]
561 * @args[3]: [discovery_period is not used anymore]
562 * @args[4]: discovery_tries_n: [1..100]
563 * @args[5]: [idle_timeout is not used anymore]
564 * @args[6]: idle_packet_n: [0..40000]
565 * @args[7]: [rssi_hysteresis is not used anymore]
566 * @args[8]: rssi_trigger_threshold: [-120..0]
567 * @args[9]: rssi_teardown_threshold: [-120..0]
568 * @args[10]: rssi_delta: [-30..0]
569 *
570 * @OUTPUT: None
571 *
572 * This IOCTL is used to set the TDLS configuration parameters.
573 *
574 * @E.g: iwpriv wlan0 setTdlsConfig tdls tx_period_t tx_packet_n
575 * discovery_period discovery_tries_n idle_timeout
576 * idle_packet_n rssi_hysteresis rssi_trigger_threshold
577 * rssi_teardown_threshold rssi_delta
578 * iwpriv wlan0 setTdlsConfig 1 1500 40 1 5 1 5 0 -70 -70 -10
579 *
580 * Supported Feature: TDLS
581 *
582 * Usage: Internal/External
583 *
584 * </ioctl>
585 */
586
587
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588#define WE_TDLS_CONFIG_PARAMS 5
589#endif
Abhishek Singh49b654e2016-12-01 16:11:17 +0530590/*
591 * <ioctl>
592 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
593 *
594 * @INPUT: staid
595 *
596 * @OUTPUT: print ibss peer corresponding to staid in info logs
597 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
598 *
599 * This IOCTL is used to print the specific ibss peers's MAC,
600 * rate and RSSI in info logs
601 *
602 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
603 * iwpriv wlan0 ibssPeerInfo 0
604 *
605 * Supported Feature: IBSS
606 *
607 * Usage: Internal/External
608 *
609 * </ioctl>
610 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800611#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612#define WE_UNIT_TEST_CMD 7
613
614#define WE_MTRACE_DUMP_CMD 8
615#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
616
617
618#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
619#define WE_LED_FLASHING_PARAM 10
620#endif
621
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530622/*
623 * <ioctl>
624 * pm_clist - Increments the index value of the concurrent connection list
625 * and update with the input parameters provided.
626 *
627 * @INPUT: Following 8 arguments:
628 * @vdev_id: vdev id
629 * @tx_streams: TX streams
630 * @rx_streams: RX streams
631 * @chain_mask: Chain mask
632 * @type: vdev_type
633 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
634 * @sub_type: vdev_subtype
635 * P2P_Device:1 P2P_Client:2 P2P_GO:3
636 * Proxy_STA:4 Mesh:5 Mesh_11s:6
637 * @channel: Channel
638 * @mac: Mac id
639 *
640 * @OUTPUT: None
641 *
642 * This IOCTL is used to increments the index value of the concurrent connection
643 * list and update with the input parameters provided.
644 *
645 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
646 * sub_type channel mac
647 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
648 *
649 * Supported Feature: DBS
650 *
651 * Usage: Internal/External
652 *
653 * </ioctl>
654 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530656
657/*
658 * <ioctl>
659 * pm_dlist - Delete the index from the concurrent connection list that is
660 * present in the given vdev_id.
661 *
662 * @INPUT: delete_all, vdev_id
663 * @delete_all: delete all indices
664 * @vdev_id: vdev id
665 *
666 * @OUTPUT: None
667 *
668 * This IOCTL is used to delete the index from the concurrent connection list
669 * that is present in the given vdev_id.
670 *
671 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
672 * iwpriv wlan0 pm_dlist 0 1
673 *
674 * Supported Feature: DBS
675 *
676 * Usage: Internal/External
677 *
678 * </ioctl>
679 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530681
682/*
683 * <ioctl>
684 * pm_dbs - Set dbs capability and system preference
685 *
686 * @INPUT: dbs, system_pref
687 * @dbs: Value of DBS capability to be set
688 * @system_pref: System preference
689 * 0:CDS_THROUGHPUT 1: CDS_POWERSAVE 2: CDS_LATENCY
690 *
691 * @OUTPUT: None
692 *
693 * This IOCTL is used to set dbs capability and system preference.
694 *
695 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
696 * iwpriv wlan0 pm_dbs 1 0
697 *
698 * Supported Feature: DBS
699 *
700 * Usage: Internal/External
701 *
702 * </ioctl>
703 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530705
706/*
707 * <ioctl>
708 * pm_pcl - Set pcl for concurrency mode.
709 *
710 * @INPUT: cds_con_mode
711 * @cds_con_mode: concurrency mode for PCL table
712 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
713 *
714 * @OUTPUT: None
715 *
716 * This IOCTL is used to set pcl for concurrency mode.
717 *
718 * @E.g: iwpriv wlan0 pm_pcl cds_con_mode
719 * iwpriv wlan0 pm_pcl 0
720 *
721 * Supported Feature: DBS
722 *
723 * Usage: Internal/External
724 *
725 * </ioctl>
726 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530728
729/*
730 * <ioctl>
731 * pm_cinfo - Shows the concurrent connection list.
732 *
733 * @INPUT: None
734 *
735 * @OUTPUT: None
736 *
737 * This IOCTL is used to show the concurrent connection list.
738 *
739 * @E.g: iwpriv wlan0 pm_cinfo
740 *
741 * Supported Feature: DBS
742 *
743 * Usage: Internal/External
744 *
745 * </ioctl>
746 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530748
749/*
750 * <ioctl>
751 * pm_ulist - Updates the index value of the concurrent connection list
752 * with the input parameters provided.
753 *
754 * @INPUT: Following 8 arguments:
755 * @vdev_id: vdev id
756 * @tx_streams: TX streams
757 * @rx_streams: RX streams
758 * @chain_mask: Chain mask
759 * @type: vdev_type
760 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
761 * @sub_type: vdev_subtype
762 * P2P_Device:1 P2P_Client:2 P2P_GO:3
763 * Proxy_STA:4 Mesh:5 Mesh_11s:6
764 * @channel: Channel
765 * @mac: Mac id
766 *
767 * @OUTPUT: None
768 *
769 * This IOCTL is used to updates the index value of the concurrent
770 * connection list with the input parameters provided.
771 *
772 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
773 * sub_type channel mac
774 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
775 *
776 * Supported Feature: DBS
777 *
778 * Usage: Internal/External
779 *
780 * </ioctl>
781 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530783
784/*
785 * <ioctl>
786 * pm_query_action - Initiate actions needed on current connections as
787 * per the channel provided.
788 *
789 * @INPUT: channel
790 * @channel: Channel on which new connection will be.
791 *
792 * @OUTPUT: None
793 *
794 * This IOCTL is used to initiate actions needed on current connections
795 * as per the channel provided.
796 *
797 * @E.g: iwpriv wlan0 pm_query_action channel
798 * iwpriv wlan0 pm_query_action 6
799 *
800 * Supported Feature: DBS
801 *
802 * Usage: Internal/External
803 *
804 * </ioctl>
805 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530807
808/*
809 * <ioctl>
810 * pm_query_allow - Checks for allowed concurrency combination
811 *
812 * @INPUT: mode, channel, bandwidth
813 * @mode: new connection mode
814 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
815 * @channel: channel on which new connection is coming up
816 * @bandwidth: Bandwidth requested by the connection
817 * 0:None 1:5MHz 2:10MHz 3:20MHz
818 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
819 *
820 * @OUTPUT: None
821 *
822 * This IOCTL is used to checks for allowed concurrency combination.
823 *
824 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
825 * iwpriv wlan0 pm_query_allow 0 6 4
826 *
827 * Supported Feature: DBS
828 *
829 * Usage: Internal/External
830 *
831 * </ioctl>
832 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800833#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530834
835/*
836 * <ioctl>
837 * pm_run_scenario - Create scenario with number of connections provided.
838 *
839 * @INPUT: num_of_conn
840 * @num_of_conn: the number of connections (values: 1~3)
841 *
842 * @OUTPUT: None
843 *
844 * This IOCTL is used to create scenario with the number of connections
845 * provided.
846 *
847 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
848 * iwpriv wlan0 pm_run_scenario 1
849 *
850 * Supported Feature: DBS
851 *
852 * Usage: Internal/External
853 *
854 * </ioctl>
855 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530857
858/*
859 * <ioctl>
860 * pm_set_hw_mode - Set hardware for single/dual mac.
861 *
862 * @INPUT: hw_mode
863 * 0:single mac 1:dual mac
864 *
865 * @OUTPUT: None
866 *
867 * This IOCTL is used to set hardware for single/dual mac.
868 *
869 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
870 * iwpriv wlan0 pm_set_hw_mode 1
871 *
872 * Supported Feature: DBS
873 *
874 * Usage: Internal/External
875 *
876 * </ioctl>
877 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878#define WE_POLICY_SET_HW_MODE_CMD 20
879
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530880/*
881 * <ioctl>
882 * set_scan_cfg - Set dual MAC scan config parameters.
883 *
884 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
885 * @dbs: Value of DBS bit
886 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
887 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
888 *
889 * @OUTPUT: None
890 *
891 * This IOCTL is used to set the dual MAC scan config.
892 *
893 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
894 * single_mac_scan_with_dbs
895 * iwpriv wlan0 set_scan_cfg 1 0 1
896 *
897 * Supported Feature: DBS
898 *
899 * Usage: Internal/External
900 *
901 * </ioctl>
902 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530904
905/*
906 * <ioctl>
907 * set_fw_mode_cfg - Sets the dual mac FW mode config
908 *
909 * @INPUT: dbs, dfs
910 * @dbs: DBS bit
911 * @dfs: Agile DFS bit
912 *
913 * @OUTPUT: None
914 *
915 * This IOCTL is used to set the dual mac FW mode config.
916 *
917 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
918 * iwpriv wlan0 set_fw_mode_cfg 1 1
919 *
920 * Supported Feature: DBS
921 *
922 * Usage: Internal/External
923 *
924 * </ioctl>
925 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -0700927#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928
929#ifdef FEATURE_WLAN_TDLS
930#undef MAX_VAR_ARGS
931#define MAX_VAR_ARGS 11
932#else
933#undef MAX_VAR_ARGS
934#define MAX_VAR_ARGS 9
935#endif
936
937/* Private ioctls (with no sub-ioctls) */
938/* note that they must be odd so that they have "get" semantics */
939#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
940#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
941#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
942
943/* (SIOCIWFIRSTPRIV + 8) is currently unused */
944/* (SIOCIWFIRSTPRIV + 10) is currently unused */
945/* (SIOCIWFIRSTPRIV + 12) is currently unused */
946/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700947#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
948#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949/* (SIOCIWFIRSTPRIV + 16) is currently unused */
950/* (SIOCIWFIRSTPRIV + 17) is currently unused */
951/* (SIOCIWFIRSTPRIV + 19) is currently unused */
952
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800954
955/* Private ioctl for setting the host offload feature */
956#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
957
958/* Private ioctl to get the statistics */
959#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
960
961/* Private ioctl to set the Keep Alive Params */
962#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
963
964#ifdef WLAN_FEATURE_PACKET_FILTERING
965/* Private ioctl to set the packet filtering params */
966#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
967#endif
968
969
970#ifdef FEATURE_WLAN_SCAN_PNO
971/* Private ioctl to get the statistics */
972#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
973#endif
974
975#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
976
Dustin Brown0cbc7572016-12-16 13:54:40 -0800977#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -0800978/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979
980/* Private ioctls and their sub-ioctls */
981#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
982#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -0700983#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984#define WE_SET_FW_CRASH_INJECT 2
985#endif
986#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +0530987/* Private sub ioctl for enabling and setting histogram interval of profiling */
988#define WE_ENABLE_FW_PROFILE 4
989#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990
Rajeev Kumar9bb2e852016-09-24 12:29:25 -0700991/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700992#define WE_SET_WLAN_SUSPEND 6
993#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700994
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995/* (SIOCIWFIRSTPRIV + 29) is currently unused */
996
997/* 802.11p IOCTL */
998#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
999
1000#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
1001
1002#define WLAN_STATS_INVALID 0
1003#define WLAN_STATS_RETRY_CNT 1
1004#define WLAN_STATS_MUL_RETRY_CNT 2
1005#define WLAN_STATS_TX_FRM_CNT 3
1006#define WLAN_STATS_RX_FRM_CNT 4
1007#define WLAN_STATS_FRM_DUP_CNT 5
1008#define WLAN_STATS_FAIL_CNT 6
1009#define WLAN_STATS_RTS_FAIL_CNT 7
1010#define WLAN_STATS_ACK_FAIL_CNT 8
1011#define WLAN_STATS_RTS_SUC_CNT 9
1012#define WLAN_STATS_RX_DISCARD_CNT 10
1013#define WLAN_STATS_RX_ERROR_CNT 11
1014#define WLAN_STATS_TX_BYTE_CNT 12
1015
1016#define WLAN_STATS_RX_BYTE_CNT 13
1017#define WLAN_STATS_RX_RATE 14
1018#define WLAN_STATS_TX_RATE 15
1019
1020#define WLAN_STATS_RX_UC_BYTE_CNT 16
1021#define WLAN_STATS_RX_MC_BYTE_CNT 17
1022#define WLAN_STATS_RX_BC_BYTE_CNT 18
1023#define WLAN_STATS_TX_UC_BYTE_CNT 19
1024#define WLAN_STATS_TX_MC_BYTE_CNT 20
1025#define WLAN_STATS_TX_BC_BYTE_CNT 21
1026
1027#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
1028 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
1029 *__p++ = __type; \
1030 *__p++ = __size; \
1031 memcpy(__p, __val, __size); \
1032 __p += __size; \
1033 __tlen += __size + 2; \
1034 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07001035 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 } \
1037 } while (0)
1038
1039#define VERSION_VALUE_MAX_LEN 32
1040
1041#define TX_PER_TRACKING_DEFAULT_RATIO 5
1042#define TX_PER_TRACKING_MAX_RATIO 10
1043#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
1044
1045#define WLAN_ADAPTER 0
1046#define P2P_ADAPTER 1
1047
1048/**
1049 * mem_alloc_copy_from_user_helper - copy from user helper
1050 * @wrqu_data: wireless extensions request data
1051 * @len: length of @wrqu_data
1052 *
1053 * Helper function to allocate buffer and copy user data.
1054 *
1055 * Return: On success return a pointer to a kernel buffer containing a
1056 * copy of the userspace data (with an additional NUL character
1057 * appended for safety). On failure return %NULL.
1058 */
1059void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
1060{
1061 u8 *ptr = NULL;
1062
1063 /* in order to protect the code, an extra byte is post
1064 * appended to the buffer and the null termination is added.
1065 * However, when allocating (len+1) byte of memory, we need to
1066 * make sure that there is no uint overflow when doing
1067 * addition. In theory check len < UINT_MAX protects the uint
1068 * overflow. For wlan private ioctl, the buffer size is much
1069 * less than UINT_MAX, as a good guess, now, it is assumed
1070 * that the private command buffer size is no greater than 4K
1071 * (4096 bytes). So we use 4096 as the upper boundary for now.
1072 */
1073 if (len > MAX_USER_COMMAND_SIZE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001074 hdd_err("Invalid length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 return NULL;
1076 }
1077
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001078 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001080 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 return NULL;
1082 }
1083
1084 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001085 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001086 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 return NULL;
1088 }
1089 ptr[len] = '\0';
1090 return ptr;
1091}
1092
1093/**
1094 * hdd_priv_get_data() - Get pointer to ioctl private data
1095 * @p_priv_data: pointer to iw_point struct to be filled
1096 * @wrqu: Pointer to IOCTL Data received from userspace
1097 *
1098 * Helper function to get compatible struct iw_point passed to ioctl
1099 *
1100 * Return - 0 if p_priv_data successfully filled, error otherwise
1101 */
1102int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
1103{
1104 if ((NULL == p_priv_data) || (NULL == wrqu)) {
1105 return -EINVAL;
1106 }
1107#ifdef CONFIG_COMPAT
1108 if (is_compat_task()) {
1109 struct compat_iw_point *p_compat_priv_data;
1110
1111 /* Compat task:
1112 * typecast to compat structure and copy the members.
1113 */
1114 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
1115
1116 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
1117 p_priv_data->length = p_compat_priv_data->length;
1118 p_priv_data->flags = p_compat_priv_data->flags;
1119 } else {
1120#endif /* #ifdef CONFIG_COMPAT */
1121
1122 /* Non compat task: directly copy the structure. */
1123 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
1124
1125#ifdef CONFIG_COMPAT
1126 }
1127#endif /* #ifdef CONFIG_COMPAT */
1128
1129 return 0;
1130}
1131
Jeff Johnson441e1f72017-02-07 08:50:49 -08001132static int hdd_check_wext_control(enum hdd_wext_control wext_control,
1133 struct iw_request_info *info)
1134{
1135 switch (wext_control) {
1136 default:
1137 case hdd_wext_disabled:
1138 hdd_err("Rejecting disabled ioctl %x", info->cmd);
1139 return -ENOTSUPP;
1140 case hdd_wext_deprecated:
1141 hdd_warn("Using deprecated ioctl %x", info->cmd);
1142 return 0;
1143 case hdd_wext_enabled:
1144 return 0;
1145 }
1146}
1147
1148int hdd_check_standard_wext_control(struct hdd_context_s *hdd_ctx,
1149 struct iw_request_info *info)
1150{
1151 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
1152 info);
1153}
1154
1155int hdd_check_private_wext_control(struct hdd_context_s *hdd_ctx,
1156 struct iw_request_info *info)
1157{
1158 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
1159 info);
1160}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001161
1162/**
1163 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
1164 * @pAdapter: Pointer to the hdd adapter.
1165 * @length: Size of the data copied
1166 * @buffer: Pointer to char buffer.
1167 * @buf_len: Length of the char buffer.
1168 *
1169 * This function called when the "iwpriv wlan0 get_stats" command is given.
1170 * It used to collect the txrx stats when the device is configured in SAP mode.
1171 *
1172 * Return - none
1173 */
1174void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
1175 char *buffer, uint16_t buf_len)
1176{
1177 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
1178 uint32_t len = 0;
1179 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
1180 uint32_t total_rx_delv = 0, total_rx_refused = 0;
1181 int i = 0;
1182
1183 for (; i < NUM_CPUS; i++) {
1184 total_rx_pkt += pStats->rxPackets[i];
1185 total_rx_dropped += pStats->rxDropped[i];
1186 total_rx_delv += pStats->rxDelivered[i];
1187 total_rx_refused += pStats->rxRefused[i];
1188 }
1189
1190 len = scnprintf(buffer, buf_len,
1191 "\nTransmit"
1192 "\ncalled %u, dropped %u,"
1193 "\n dropped BK %u, BE %u, VI %u, VO %u"
1194 "\n classified BK %u, BE %u, VI %u, VO %u"
1195 "\ncompleted %u,"
1196 "\n\nReceive Total"
1197 "\n packets %u, dropped %u, delivered %u, refused %u"
1198 "\n",
1199 pStats->txXmitCalled,
1200 pStats->txXmitDropped,
1201
1202 pStats->txXmitDroppedAC[SME_AC_BK],
1203 pStats->txXmitDroppedAC[SME_AC_BE],
1204 pStats->txXmitDroppedAC[SME_AC_VI],
1205 pStats->txXmitDroppedAC[SME_AC_VO],
1206
1207 pStats->txXmitClassifiedAC[SME_AC_BK],
1208 pStats->txXmitClassifiedAC[SME_AC_BE],
1209 pStats->txXmitClassifiedAC[SME_AC_VI],
1210 pStats->txXmitClassifiedAC[SME_AC_VO],
1211
1212 pStats->txCompleted,
1213 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
1214 );
1215
1216 for (i = 0; i < NUM_CPUS; i++) {
1217 len += scnprintf(buffer + len, buf_len - len,
1218 "\nReceive CPU: %d"
1219 "\n packets %u, dropped %u, delivered %u, refused %u",
1220 i, pStats->rxPackets[i], pStats->rxDropped[i],
1221 pStats->rxDelivered[i], pStats->rxRefused[i]);
1222 }
1223
1224 len += scnprintf(buffer + len, buf_len - len,
1225 "\n\nTX_FLOW"
1226 "\nCurrent status: %s"
1227 "\ntx-flow timer start count %u"
1228 "\npause count %u, unpause count %u",
1229 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
1230 pStats->txflow_timer_cnt,
1231 pStats->txflow_pause_cnt,
1232 pStats->txflow_unpause_cnt);
1233
Leo Changfdb45c32016-10-28 11:09:23 -07001234 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
1235 pAdapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236
1237 len += hdd_napi_stats(buffer + len, buf_len - len,
1238 NULL, hdd_napi_get_all());
1239
1240 *length = len + 1;
1241}
1242
1243/**
Dustin Brownd9322482017-01-09 12:46:03 -08001244 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
1245 * @hdd_ctx: The Hdd context owning the stats to be written
1246 * @buffer: The char buffer to write to
1247 * @max_len: The maximum number of chars to write
1248 *
1249 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
1250 *
1251 * Return - length of written content, negative number on error
1252 */
1253static int wlan_hdd_write_suspend_resume_stats(hdd_context_t *hdd_ctx,
1254 char *buffer, uint16_t max_len)
1255{
1256 QDF_STATUS status;
1257 struct suspend_resume_stats *sr_stats;
1258 struct sir_wake_lock_stats wow_stats;
1259
1260 sr_stats = &hdd_ctx->suspend_resume_stats;
1261
1262 status = wma_get_wakelock_stats(&wow_stats);
1263 if (QDF_IS_STATUS_ERROR(status)) {
1264 hdd_err("Failed to get WoW stats");
1265 return qdf_status_to_os_return(status);
1266 }
1267
1268 return scnprintf(buffer, max_len,
1269 "\n"
1270 "Suspends: %u\n"
1271 "Resumes: %u\n"
1272 "\n"
1273 "Suspend Fail Reasons\n"
1274 "\tIPA: %u\n"
1275 "\tRadar: %u\n"
1276 "\tRoam: %u\n"
1277 "\tScan: %u\n"
1278 "\tInitial Wakeup: %u\n"
1279 "\n"
1280 "WoW Wake Reasons\n"
1281 "\tunicast: %u\n"
1282 "\tbroadcast: %u\n"
1283 "\tIPv4 multicast: %u\n"
1284 "\tIPv6 multicast: %u\n"
1285 "\tIPv6 multicast RA: %u\n"
1286 "\tIPv6 multicast NS: %u\n"
1287 "\tIPv6 multicast NA: %u\n"
1288 "\tICMPv4: %u\n"
1289 "\tICMPv6: %u\n"
1290 "\tRSSI Breach: %u\n"
1291 "\tLow RSSI: %u\n"
1292 "\tG-Scan: %u\n"
1293 "\tPNO Complete: %u\n"
1294 "\tPNO Match: %u\n",
1295 sr_stats->suspends,
1296 sr_stats->resumes,
1297 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
1298 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
1299 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
1300 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
1301 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
1302 wow_stats.wow_ucast_wake_up_count,
1303 wow_stats.wow_bcast_wake_up_count,
1304 wow_stats.wow_ipv4_mcast_wake_up_count,
1305 wow_stats.wow_ipv6_mcast_wake_up_count,
1306 wow_stats.wow_ipv6_mcast_ra_stats,
1307 wow_stats.wow_ipv6_mcast_ns_stats,
1308 wow_stats.wow_ipv6_mcast_na_stats,
1309 wow_stats.wow_icmpv4_count,
1310 wow_stats.wow_icmpv6_count,
1311 wow_stats.wow_rssi_breach_wake_up_count,
1312 wow_stats.wow_low_rssi_wake_up_count,
1313 wow_stats.wow_gscan_wake_up_count,
1314 wow_stats.wow_pno_complete_wake_up_count,
1315 wow_stats.wow_pno_match_wake_up_count);
1316}
1317
1318/**
Govind Singha471e5e2015-10-12 17:11:14 +05301319 * hdd_wlan_list_fw_profile() - Get fw profiling points
1320 * @length: Size of the data copied
1321 * @buffer: Pointer to char buffer.
1322 * @buf_len: Length of the char buffer.
1323 *
1324 * This function called when the "iwpriv wlan0 listProfile" command is given.
1325 * It is used to get the supported profiling points in FW.
1326 *
1327 * Return - none
1328 */
1329void hdd_wlan_list_fw_profile(uint16_t *length,
1330 char *buffer, uint16_t buf_len)
1331{
1332 uint32_t len = 0;
1333
1334 len = scnprintf(buffer, buf_len,
1335 "PROF_CPU_IDLE: %u\n"
1336 "PROF_PPDU_PROC: %u\n"
1337 "PROF_PPDU_POST: %u\n"
1338 "PROF_HTT_TX_INPUT: %u\n"
1339 "PROF_MSDU_ENQ: %u\n"
1340 "PROF_PPDU_POST_HAL: %u\n"
1341 "PROF_COMPUTE_TX_TIME: %u\n",
1342 PROF_CPU_IDLE,
1343 PROF_PPDU_PROC,
1344 PROF_PPDU_POST,
1345 PROF_HTT_TX_INPUT,
1346 PROF_MSDU_ENQ,
1347 PROF_PPDU_POST_HAL,
1348 PROF_COMPUTE_TX_TIME);
1349
1350 *length = len + 1;
1351}
1352
1353/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354 * hdd_wlan_dump_stats() - display dump Stats
1355 * @adapter: adapter handle
1356 * @value: value from user
1357 *
1358 * Return: none
1359 */
1360void hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value)
1361{
1362 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1363
1364 switch (value) {
1365
1366 case WLAN_TXRX_HIST_STATS:
1367 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
1368 break;
1369 case WLAN_HDD_NETIF_OPER_HISTORY:
1370 wlan_hdd_display_netif_queue_history(hdd_ctx);
1371 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05301372 case WLAN_HIF_STATS:
1373 hdd_display_hif_stats();
1374 break;
Dhanashri Atree7d442a2016-07-14 18:20:29 -07001375 case WLAN_LRO_STATS:
1376 hdd_lro_display_stats(hdd_ctx);
1377 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 default:
Leo Changfdb45c32016-10-28 11:09:23 -07001379 cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 break;
1381 }
1382}
1383
1384/**
1385 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301386 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 * @wrqu: Pointer to IOCTL REQUEST Data.
1388 * @extra: Pointer to destination buffer
1389 *
1390 * This function is used to get Wlan Driver, Firmware, & Hardware
1391 * Version information. If @wrqu and @extra are specified, then the
1392 * version string is returned. Otherwise it is simply printed to the
1393 * kernel log.
1394 *
1395 * Return: none
1396 */
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301397void hdd_wlan_get_version(hdd_context_t *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 char *extra)
1399{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301400 tSirVersionString wcnss_sw_version;
1401 const char *swversion;
1402 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001403 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301405 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001406 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 goto error;
1408 }
1409
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301410 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
1411 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301413 swversion = wcnss_sw_version;
1414 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
1415 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
1416 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
1417 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001418 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301420 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421
1422 if (wrqu && extra) {
1423 wrqu->data.length =
1424 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001425 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001427 msp_id, mspid, siid, crmid,
1428 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001430 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001432 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 }
1434error:
1435 return;
1436}
1437
1438/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001439 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
1440 * @pAdapter: Adapter upon which the IBSS client is active
1441 * @staIdx: Station index of the IBSS peer
1442 *
1443 * Return: a pointer to the MAC address of the IBSS peer if the peer is
1444 * found, otherwise %NULL.
1445 */
1446struct qdf_mac_addr *
1447hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
1448 uint8_t staIdx)
1449{
1450 uint8_t idx;
1451 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1452
Naveen Rawatc45d1622016-07-05 12:20:09 -07001453 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001454 if (0 != pHddStaCtx->conn_info.staId[idx] &&
1455 staIdx == pHddStaCtx->conn_info.staId[idx]) {
1456 return &pHddStaCtx->conn_info.peerMacAddress[idx];
1457 }
1458 }
1459 return NULL;
1460}
1461
1462/**
1463 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
1464 * @pAdapter: Adapter upon which the IBSS client is active
1465 * @staIdx: Station index of the IBSS peer
1466 *
1467 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
1468 * otherwise an appropriate QDF_STATUS_E_* failure code.
1469 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001470static QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter,
1471 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001472{
1473 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1474 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1475 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001476 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001477
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001478 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08001479 status = sme_request_ibss_peer_info(hHal, pAdapter,
1480 hdd_get_ibss_peer_info_cb,
1481 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001482
1483 if (QDF_STATUS_SUCCESS == status) {
1484 unsigned long rc;
1485 rc = wait_for_completion_timeout
1486 (&pAdapter->ibss_peer_info_comp,
1487 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
1488 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001489 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001490 return QDF_STATUS_E_FAILURE;
1491 }
1492
1493 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001494 hdd_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001495 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001496 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
1497 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001498
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001499 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
1500 mac_addr, sizeof(mac_addr));
1501 hdd_info("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
1502 mac_addr, (int)tx_rate,
1503 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001504 }
1505 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07001506 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001507 }
1508
1509 return status;
1510}
1511
1512/**
1513 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
1514 * @pAdapter: Adapter upon which the IBSS clients are active
1515 *
1516 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
1517 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
1518 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001519static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001520{
1521 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1522 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1523 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001524 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001525 int i;
1526
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001527 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08001528 status = sme_request_ibss_peer_info(hHal, pAdapter,
1529 hdd_get_ibss_peer_info_cb,
1530 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001531
1532 if (QDF_STATUS_SUCCESS == status) {
1533 unsigned long rc;
1534 rc = wait_for_completion_timeout
1535 (&pAdapter->ibss_peer_info_comp,
1536 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
1537 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001538 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001539 return QDF_STATUS_E_FAILURE;
1540 }
1541
1542 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001543 hdd_info("pPeerInfo->numIBSSPeers = %d ",
1544 (int)pPeerInfo->numPeers);
1545 for (i = 0; i < pPeerInfo->numPeers; i++) {
1546 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
1547 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001548
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001549 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
1550 qdf_mem_copy(mac_addr,
1551 pPeerInfo->peerInfoParams[i].mac_addr,
1552 sizeof(mac_addr));
1553
1554 hdd_info(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
1555 mac_addr, (int)tx_rate,
1556 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001557 }
1558 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07001559 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001560 }
1561
1562 return status;
1563}
1564
1565/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 * hdd_wlan_get_freq() - Convert channel to frequency
1567 * @channel: channel to be converted
1568 * @pfreq: where to store the frequency
1569 *
1570 * Return: 1 on success, otherwise a negative errno
1571 */
1572int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
1573{
1574 int i;
1575 if (channel > 0) {
1576 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
1577 if (channel == freq_chan_map[i].chan) {
1578 *pfreq = freq_chan_map[i].freq;
1579 return 1;
1580 }
1581 }
1582 }
Jeff Johnson99bac312016-06-28 10:38:18 -07001583 hdd_notice("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001584 return -EINVAL;
1585}
1586
1587/**
1588 * hdd_is_auth_type_rsn() - RSN authentication type check
1589 * @authType: authentication type to be checked
1590 *
1591 * Return: true if @authType is an RSN authentication type,
1592 * false if it is not
1593 */
1594static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
1595{
1596 bool rsnType = false;
1597 /* is the authType supported? */
1598 switch (authType) {
1599 case eCSR_AUTH_TYPE_NONE: /* never used */
1600 rsnType = false;
1601 break;
1602 /* MAC layer authentication types */
1603 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
1604 rsnType = false;
1605 break;
1606 case eCSR_AUTH_TYPE_SHARED_KEY:
1607 rsnType = false;
1608 break;
1609 case eCSR_AUTH_TYPE_AUTOSWITCH:
1610 rsnType = false;
1611 break;
1612
1613 /* Upper layer authentication types */
1614 case eCSR_AUTH_TYPE_WPA:
1615 rsnType = true;
1616 break;
1617 case eCSR_AUTH_TYPE_WPA_PSK:
1618 rsnType = true;
1619 break;
1620 case eCSR_AUTH_TYPE_WPA_NONE:
1621 rsnType = true;
1622 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 case eCSR_AUTH_TYPE_RSN:
1625 rsnType = true;
1626 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 case eCSR_AUTH_TYPE_RSN_PSK:
1629#ifdef WLAN_FEATURE_11W
1630 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
1631 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
1632#endif
1633 rsnType = true;
1634 break;
1635 /* case eCSR_AUTH_TYPE_FAILED: */
1636 case eCSR_AUTH_TYPE_UNKNOWN:
1637 rsnType = false;
1638 break;
1639 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07001640 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 authType);
1642 rsnType = false;
1643 break;
1644 }
Jeff Johnson99bac312016-06-28 10:38:18 -07001645 hdd_notice("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 authType, rsnType);
1647 return rsnType;
1648}
1649
Jeff Johnsona5444942017-01-23 13:11:08 -08001650struct rssi_priv {
1651 int8_t rssi;
1652};
1653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654/**
1655 * hdd_get_rssi_cb() - "Get RSSI" callback function
1656 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08001657 * @sta_id: ID of the station
1658 * @context: opaque context originally passed to SME. HDD always passes
1659 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 *
1661 * Return: None
1662 */
Jeff Johnsona5444942017-01-23 13:11:08 -08001663static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664{
Jeff Johnsona5444942017-01-23 13:11:08 -08001665 struct hdd_request *request;
1666 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667
Jeff Johnsona5444942017-01-23 13:11:08 -08001668 request = hdd_request_get(context);
1669 if (!request) {
1670 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 return;
1672 }
1673
Jeff Johnsona5444942017-01-23 13:11:08 -08001674 priv = hdd_request_priv(request);
1675 priv->rssi = rssi;
1676 hdd_request_complete(request);
1677 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678}
1679
1680/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 * wlan_hdd_get_rssi() - Get the current RSSI
1682 * @pAdapter: adapter upon which the measurement is requested
1683 * @rssi_value: pointer to where the RSSI should be returned
1684 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301685 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301687QDF_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 hdd_context_t *pHddCtx;
1690 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301691 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08001692 int ret;
1693 void *cookie;
1694 struct hdd_request *request;
1695 struct rssi_priv *priv;
1696 static const struct hdd_request_params params = {
1697 .priv_size = sizeof(*priv),
1698 .timeout_ms = WLAN_WAIT_TIME_STATS,
1699 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700
1701 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001702 hdd_warn("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301703 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08001705 if (cds_is_driver_recovering()) {
1706 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
1707 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 /* return a cached value */
1709 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301710 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 }
1712
1713 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1714 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1715
1716 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301717 hdd_err("Not associated!, rssi on disconnect %d",
1718 pAdapter->rssi_on_disconnect);
1719 *rssi_value = pAdapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301720 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 }
1722
1723 if (pHddStaCtx->hdd_ReassocScenario) {
1724 hdd_info("Roaming in progress, return cached RSSI");
1725 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301726 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 }
1728
Jeff Johnsona5444942017-01-23 13:11:08 -08001729 request = hdd_request_alloc(&params);
1730 if (!request) {
1731 hdd_err("Request allocation failure, return cached RSSI");
1732 *rssi_value = pAdapter->rssi;
1733 return QDF_STATUS_SUCCESS;
1734 }
1735 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736
1737 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
1738 pHddStaCtx->conn_info.staId[0],
1739 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
Jeff Johnsona5444942017-01-23 13:11:08 -08001740 cookie, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301741 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001742 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 /* we'll returned a cached value below */
1744 } else {
1745 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08001746 ret = hdd_request_wait_for_response(request);
1747 if (ret) {
1748 hdd_warn("SME timed out while retrieving RSSI");
1749 /* we'll returned a cached value below */
1750 } else {
1751 /* update the adapter with the fresh results */
1752 priv = hdd_request_priv(request);
1753 pAdapter->rssi = priv->rssi;
1754 if (pAdapter->rssi > 0)
1755 pAdapter->rssi = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 }
1757 }
1758
Jeff Johnsona5444942017-01-23 13:11:08 -08001759 /*
1760 * either we never sent a request, we sent a request and
1761 * received a response or we sent a request and timed out.
1762 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001763 */
Jeff Johnsona5444942017-01-23 13:11:08 -08001764 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765
1766 *rssi_value = pAdapter->rssi;
1767
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301768 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769}
1770
1771/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08001772 * hdd_get_snr_cb() - "Get SNR" callback function
1773 * @snr: Current SNR of the station
1774 * @staId: ID of the station
1775 * @pContext: opaque context originally passed to SME. HDD always passes
1776 * a &struct statsContext
1777 *
1778 * Return: None
1779 */
1780static void hdd_get_snr_cb(int8_t snr, uint32_t staId, void *pContext)
1781{
1782 struct statsContext *pStatsContext;
1783 hdd_adapter_t *pAdapter;
1784
1785 if (NULL == pContext) {
1786 hdd_err("Bad param");
1787 return;
1788 }
1789
1790 pStatsContext = pContext;
1791 pAdapter = pStatsContext->pAdapter;
1792
1793 /* there is a race condition that exists between this callback
1794 * function and the caller since the caller could time out
1795 * either before or while this code is executing. we use a
1796 * spinlock to serialize these actions
1797 */
1798 spin_lock(&hdd_context_lock);
1799
1800 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic)) {
1801 /* the caller presumably timed out so there is nothing
1802 * we can do
1803 */
1804 spin_unlock(&hdd_context_lock);
1805 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1806 pAdapter, pStatsContext->magic);
1807 return;
1808 }
1809
1810 /* context is valid so caller is still waiting */
1811
1812 /* paranoia: invalidate the magic */
1813 pStatsContext->magic = 0;
1814
1815 /* copy over the snr */
1816 pAdapter->snr = snr;
1817
1818 /* notify the caller */
1819 complete(&pStatsContext->completion);
1820
1821 /* serialization is complete */
1822 spin_unlock(&hdd_context_lock);
1823}
1824
1825/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 * wlan_hdd_get_snr() - Get the current SNR
1827 * @pAdapter: adapter upon which the measurement is requested
1828 * @snr: pointer to where the SNR should be returned
1829 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301830 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301832QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833{
Houston Hoffman59c097f2016-11-09 15:50:25 -08001834 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 hdd_context_t *pHddCtx;
1836 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301837 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838 unsigned long rc;
1839 int valid;
1840
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301841 ENTER();
1842
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001844 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301845 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 }
1847
1848 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1849
1850 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301851 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301852 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853
1854 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1855
1856 init_completion(&context.completion);
1857 context.pAdapter = pAdapter;
1858 context.magic = SNR_CONTEXT_MAGIC;
1859
1860 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
1861 pHddStaCtx->conn_info.staId[0],
1862 pHddStaCtx->conn_info.bssId, &context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301863 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001864 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 /* we'll returned a cached value below */
1866 } else {
1867 /* request was sent -- wait for the response */
1868 rc = wait_for_completion_timeout(&context.completion,
1869 msecs_to_jiffies
1870 (WLAN_WAIT_TIME_STATS));
1871 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001872 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 /* we'll now returned a cached value below */
1874 }
1875 }
1876
1877 /* either we never sent a request, we sent a request and
1878 * received a response or we sent a request and timed out. if
1879 * we never sent a request or if we sent a request and got a
1880 * response, we want to clear the magic out of paranoia. if
1881 * we timed out there is a race condition such that the
1882 * callback function could be executing at the same time we
1883 * are. of primary concern is if the callback function had
1884 * already verified the "magic" but had not yet set the
1885 * completion variable when a timeout occurred. we serialize
1886 * these activities by invalidating the magic while holding a
1887 * shared spinlock which will cause us to block if the
1888 * callback is currently executing
1889 */
1890 spin_lock(&hdd_context_lock);
1891 context.magic = 0;
1892 spin_unlock(&hdd_context_lock);
1893
1894 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301895 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301896 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897}
1898
1899/**
1900 * hdd_get_link_speed_cb() - Get link speed callback function
1901 * @pLinkSpeed: pointer to the link speed record
1902 * @pContext: pointer to the user context passed to SME
1903 *
1904 * This function is passed as the callback function to
1905 * sme_get_link_speed() by wlan_hdd_get_linkspeed_for_peermac(). By
1906 * agreement a &struct linkspeedContext is passed as @pContext. If
1907 * the context is valid, then the contents of @pLinkSpeed are copied
1908 * into the adapter record referenced by @pContext where they can be
1909 * subsequently retrieved. If the context is invalid, then this
1910 * function does nothing since it is assumed the caller has already
1911 * timed-out and destroyed the context.
1912 *
1913 * Return: None.
1914 */
1915static void
1916hdd_get_link_speed_cb(tSirLinkSpeedInfo *pLinkSpeed, void *pContext)
1917{
1918 struct linkspeedContext *pLinkSpeedContext;
1919 hdd_adapter_t *pAdapter;
1920
1921 if ((NULL == pLinkSpeed) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001922 hdd_err("Bad param, pLinkSpeed [%p] pContext [%p]",
1923 pLinkSpeed, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 return;
1925 }
1926 spin_lock(&hdd_context_lock);
1927 pLinkSpeedContext = pContext;
1928 pAdapter = pLinkSpeedContext->pAdapter;
1929
1930 /* there is a race condition that exists between this callback
1931 * function and the caller since the caller could time out either
1932 * before or while this code is executing. we use a spinlock to
1933 * serialize these actions
1934 */
1935
1936 if ((NULL == pAdapter) ||
1937 (LINK_CONTEXT_MAGIC != pLinkSpeedContext->magic)) {
1938 /* the caller presumably timed out so there is nothing
1939 * we can do
1940 */
1941 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07001942 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1943 pAdapter, pLinkSpeedContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 return;
1945 }
1946
1947 /* context is valid so caller is still waiting */
1948
1949 /* paranoia: invalidate the magic */
1950 pLinkSpeedContext->magic = 0;
1951
1952 /* copy over the stats. do so as a struct copy */
1953 pAdapter->ls_stats = *pLinkSpeed;
1954
1955 /* notify the caller */
1956 complete(&pLinkSpeedContext->completion);
1957
1958 /* serialization is complete */
1959 spin_unlock(&hdd_context_lock);
1960}
1961
1962/**
1963 * wlan_hdd_get_linkspeed_for_peermac() - Get link speed for a peer
1964 * @pAdapter: adapter upon which the peer is active
1965 * @macAddress: MAC address of the peer
1966 *
1967 * This function will send a query to SME for the linkspeed of the
1968 * given peer, and then wait for the callback to be invoked.
1969 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301970 * Return: QDF_STATUS_SUCCESS if linkspeed data is available,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301971 * otherwise a QDF_STATUS_E_** error.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301973QDF_STATUS wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301974 struct qdf_mac_addr macAddress) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301975 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976 unsigned long rc;
Houston Hoffman59c097f2016-11-09 15:50:25 -08001977 static struct linkspeedContext context;
Jeff Johnsona5317a62017-01-26 08:51:25 -08001978 tSirLinkSpeedInfo linkspeed_req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979
1980 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001981 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301982 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984 init_completion(&context.completion);
1985 context.pAdapter = pAdapter;
1986 context.magic = LINK_CONTEXT_MAGIC;
1987
Jeff Johnsona5317a62017-01-26 08:51:25 -08001988 qdf_copy_macaddr(&linkspeed_req.peer_macaddr, &macAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsona5317a62017-01-26 08:51:25 -08001990 &linkspeed_req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 &context, hdd_get_link_speed_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301992 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001993 hdd_err("Unable to retrieve statistics for link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 } else {
1995 rc = wait_for_completion_timeout
1996 (&context.completion,
1997 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
1998 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001999 hdd_err("SME timed out while retrieving link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 }
2001 }
2002
2003 /* either we never sent a request, we sent a request and
2004 * received a response or we sent a request and timed out. if
2005 * we never sent a request or if we sent a request and got a
2006 * response, we want to clear the magic out of paranoia. if
2007 * we timed out there is a race condition such that the
2008 * callback function could be executing at the same time we
2009 * are. of primary concern is if the callback function had
2010 * already verified the "magic" but had not yet set the
2011 * completion variable when a timeout occurred. we serialize
2012 * these activities by invalidating the magic while holding a
2013 * shared spinlock which will cause us to block if the
2014 * callback is currently executing
2015 */
2016 spin_lock(&hdd_context_lock);
2017 context.magic = 0;
2018 spin_unlock(&hdd_context_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302019 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020}
2021
2022/**
2023 * wlan_hdd_get_link_speed() - get link speed
2024 * @pAdapter: pointer to the adapter
2025 * @link_speed: pointer to link speed
2026 *
2027 * This function fetches per bssid link speed.
2028 *
2029 * Return: if associated, link speed shall be returned.
2030 * if not associated, link speed of 0 is returned.
2031 * On error, error number will be returned.
2032 */
2033int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
2034{
2035 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
2036 hdd_station_ctx_t *hdd_stactx =
2037 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
2038 int ret;
2039
2040 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05302041 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05302044 /* Linkspeed is allowed only for P2P mode */
2045 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
2046 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
2047 hdd_device_mode_to_string(sta_adapter->device_mode),
2048 sta_adapter->device_mode);
2049 return -ENOTSUPP;
2050 }
2051
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
2053 /* we are not connected so we don't have a classAstats */
2054 *link_speed = 0;
2055 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302056 QDF_STATUS status;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302057 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058
Anurag Chouhanc5548422016-02-24 18:33:27 +05302059 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060
2061 status = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302062 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002063 hdd_err("Unable to retrieve SME linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 return -EINVAL;
2065 }
2066 *link_speed = sta_adapter->ls_stats.estLinkSpeed;
2067 /* linkspeed in units of 500 kbps */
2068 *link_speed = (*link_speed) / 500;
2069 }
2070 return 0;
2071}
2072
2073/**
2074 * hdd_statistics_cb() - "Get statistics" callback function
2075 * @pStats: statistics payload
2076 * @pContext: opaque context originally passed to SME. HDD always passes
2077 * a pointer to an adapter
2078 *
2079 * Return: None
2080 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07002081static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082{
2083 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
2084 hdd_stats_t *pStatsCache = NULL;
2085 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05302086 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087
2088 tCsrSummaryStatsInfo *pSummaryStats = NULL;
2089 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
2090 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
2091 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
2092 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
2093 tCsrPerStaStatsInfo *pPerStaStats = NULL;
2094
2095 if (pAdapter != NULL)
2096 pStatsCache = &pAdapter->hdd_stats;
2097
2098 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
2099 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
2100 pClassBStats = (tCsrGlobalClassBStatsInfo *) (pClassAStats + 1);
2101 pClassCStats = (tCsrGlobalClassCStatsInfo *) (pClassBStats + 1);
2102 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassCStats + 1);
2103 pPerStaStats = (tCsrPerStaStatsInfo *) (pClassDStats + 1);
2104
2105 if (pStatsCache != NULL) {
2106 /* copy the stats into the cache we keep in the
2107 * adapter instance structure
2108 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302109 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302111 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302113 qdf_mem_copy(&pStatsCache->ClassB_stat, pClassBStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 sizeof(pStatsCache->ClassB_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302115 qdf_mem_copy(&pStatsCache->ClassC_stat, pClassCStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116 sizeof(pStatsCache->ClassC_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302117 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 sizeof(pStatsCache->ClassD_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302119 qdf_mem_copy(&pStatsCache->perStaStats, pPerStaStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120 sizeof(pStatsCache->perStaStats));
2121 }
2122
2123 if (pAdapter) {
2124 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302125 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05302126 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002127 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 return;
2129 }
2130 }
2131}
2132
2133/**
2134 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
2135 * @pAdapter: adapter who's IEs are to be cleared
2136 *
2137 * Return: None
2138 */
2139void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
2140{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07002141 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07002142
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07002143 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144
2145 /* clear WPA/RSN/WSC IE information in the profile */
2146 pWextState->roamProfile.nWPAReqIELength = 0;
2147 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
2148 pWextState->roamProfile.nRSNReqIELength = 0;
2149 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
2150
2151#ifdef FEATURE_WLAN_WAPI
2152 pWextState->roamProfile.nWAPIReqIELength = 0;
2153 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
2154#endif
2155
2156 pWextState->roamProfile.bWPSAssociation = false;
2157 pWextState->roamProfile.bOSENAssociation = false;
2158 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
2159 pWextState->roamProfile.nAddIEScanLength = 0;
2160 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
2161 pWextState->roamProfile.nAddIEAssocLength = 0;
2162
2163 pWextState->roamProfile.EncryptionType.numEntries = 1;
2164 pWextState->roamProfile.EncryptionType.encryptionType[0]
2165 = eCSR_ENCRYPT_TYPE_NONE;
2166
2167 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
2168 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
2169 = eCSR_ENCRYPT_TYPE_NONE;
2170
2171 pWextState->roamProfile.AuthType.numEntries = 1;
2172 pWextState->roamProfile.AuthType.authType[0] =
2173 eCSR_AUTH_TYPE_OPEN_SYSTEM;
2174
Abhishek Singh3c9910e2017-01-06 17:56:47 +05302175 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
2176 QDF_MAC_ADDR_SIZE);
2177
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178#ifdef WLAN_FEATURE_11W
2179 pWextState->roamProfile.MFPEnabled = false;
2180 pWextState->roamProfile.MFPRequired = 0;
2181 pWextState->roamProfile.MFPCapable = 0;
2182#endif
2183
2184 pWextState->authKeyMgmt = 0;
2185
Yingying Tang3cc6b792016-10-20 17:00:37 +08002186 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
2187
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188#ifdef FEATURE_WLAN_WAPI
2189 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
2190 pAdapter->wapi_info.nWapiMode = 0;
2191#endif
2192
Anurag Chouhanc5548422016-02-24 18:33:27 +05302193 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07002194 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002195}
2196
2197/**
2198 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
2199 * @oui: The OUI that is being searched for
2200 * @oui_size: The length of @oui
2201 * @ie: The set of IEs within which we're trying to find @oui
2202 * @ie_len: The length of @ie
2203 *
2204 * This function will scan the IEs contained within @ie looking for @oui.
2205 *
2206 * Return: Pointer to @oui embedded within @ie if it is present, NULL
2207 * if @oui is not present within @ie.
2208 */
2209uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
2210 uint8_t *ie, int ie_len)
2211{
2212 int left = ie_len;
2213 uint8_t *ptr = ie;
2214 uint8_t elem_id, elem_len;
2215 uint8_t eid = 0xDD;
2216
2217 if (NULL == ie || 0 == ie_len)
2218 return NULL;
2219
2220 while (left >= 2) {
2221 elem_id = ptr[0];
2222 elem_len = ptr[1];
2223 left -= 2;
2224 if (elem_len > left) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002225 hdd_alert("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 eid, elem_len, left);
2227 return NULL;
2228 }
2229 if (elem_id == eid) {
2230 if (memcmp(&ptr[2], oui, oui_size) == 0)
2231 return ptr;
2232 }
2233
2234 left -= elem_len;
2235 ptr += (elem_len + 2);
2236 }
2237 return NULL;
2238}
2239
2240/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05302241 * hdd_get_ldpc() - Get adapter LDPC
2242 * @adapter: adapter being queried
2243 * @value: where to store the value
2244 *
2245 * Return: 0 on success, negative errno on failure
2246 */
2247int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
2248{
2249 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2250 int ret;
2251
2252 ENTER();
2253 ret = sme_get_ht_config(hal, adapter->sessionId,
2254 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
2255 if (ret < 0) {
2256 hdd_alert("Failed to get LDPC value");
2257 } else {
2258 *value = ret;
2259 ret = 0;
2260 }
2261 return ret;
2262}
2263
2264/**
2265 * hdd_set_ldpc() - Set adapter LDPC
2266 * @adapter: adapter being modified
2267 * @value: new LDPC value
2268 *
2269 * Return: 0 on success, negative errno on failure
2270 */
2271int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
2272{
2273 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2274 int ret;
2275
2276 hdd_alert("%d", value);
2277 if (value) {
2278 /* make sure HT capabilities allow this */
2279 QDF_STATUS status;
2280 uint32_t cfg_value;
2281 union {
2282 uint16_t cfg_value16;
2283 tSirMacHTCapabilityInfo ht_cap_info;
2284 } u;
2285
2286 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
2287 if (QDF_STATUS_SUCCESS != status) {
2288 hdd_alert("Failed to get HT capability info");
2289 return -EIO;
2290 }
2291 u.cfg_value16 = cfg_value & 0xFFFF;
2292 if (!u.ht_cap_info.advCodingCap) {
2293 hdd_alert("LDCP not supported");
2294 return -EINVAL;
2295 }
2296 }
2297
2298 ret = sme_update_ht_config(hal, adapter->sessionId,
2299 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
2300 value);
2301 if (ret)
2302 hdd_alert("Failed to set LDPC value");
2303
2304 return ret;
2305}
2306
2307/**
2308 * hdd_get_tx_stbc() - Get adapter TX STBC
2309 * @adapter: adapter being queried
2310 * @value: where to store the value
2311 *
2312 * Return: 0 on success, negative errno on failure
2313 */
2314int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
2315{
2316 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2317 int ret;
2318
2319 ENTER();
2320 ret = sme_get_ht_config(hal, adapter->sessionId,
2321 WNI_CFG_HT_CAP_INFO_TX_STBC);
2322 if (ret < 0) {
2323 hdd_alert("Failed to get TX STBC value");
2324 } else {
2325 *value = ret;
2326 ret = 0;
2327 }
2328
2329 return ret;
2330}
2331
2332/**
2333 * hdd_set_tx_stbc() - Set adapter TX STBC
2334 * @adapter: adapter being modified
2335 * @value: new TX STBC value
2336 *
2337 * Return: 0 on success, negative errno on failure
2338 */
2339int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
2340{
2341 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2342 int ret;
2343
2344 hdd_alert("%d", value);
2345 if (value) {
2346 /* make sure HT capabilities allow this */
2347 QDF_STATUS status;
2348 uint32_t cfg_value;
2349 union {
2350 uint16_t cfg_value16;
2351 tSirMacHTCapabilityInfo ht_cap_info;
2352 } u;
2353
2354 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
2355 if (QDF_STATUS_SUCCESS != status) {
2356 hdd_alert("Failed to get HT capability info");
2357 return -EIO;
2358 }
2359 u.cfg_value16 = cfg_value & 0xFFFF;
2360 if (!u.ht_cap_info.txSTBC) {
2361 hdd_alert("TX STBC not supported");
2362 return -EINVAL;
2363 }
2364 }
2365 ret = sme_update_ht_config(hal, adapter->sessionId,
2366 WNI_CFG_HT_CAP_INFO_TX_STBC,
2367 value);
2368 if (ret)
2369 hdd_alert("Failed to set TX STBC value");
2370
2371 return ret;
2372}
2373
2374/**
2375 * hdd_get_rx_stbc() - Get adapter RX STBC
2376 * @adapter: adapter being queried
2377 * @value: where to store the value
2378 *
2379 * Return: 0 on success, negative errno on failure
2380 */
2381int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
2382{
2383 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2384 int ret;
2385
2386 ENTER();
2387 ret = sme_get_ht_config(hal, adapter->sessionId,
2388 WNI_CFG_HT_CAP_INFO_RX_STBC);
2389 if (ret < 0) {
2390 hdd_alert("Failed to get RX STBC value");
2391 } else {
2392 *value = ret;
2393 ret = 0;
2394 }
2395
2396 return ret;
2397}
2398
2399/**
2400 * hdd_set_rx_stbc() - Set adapter RX STBC
2401 * @adapter: adapter being modified
2402 * @value: new RX STBC value
2403 *
2404 * Return: 0 on success, negative errno on failure
2405 */
2406int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
2407{
2408 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2409 int ret;
2410
2411 hdd_alert("%d", value);
2412 if (value) {
2413 /* make sure HT capabilities allow this */
2414 QDF_STATUS status;
2415 uint32_t cfg_value;
2416 union {
2417 uint16_t cfg_value16;
2418 tSirMacHTCapabilityInfo ht_cap_info;
2419 } u;
2420
2421 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
2422 if (QDF_STATUS_SUCCESS != status) {
2423 hdd_alert("Failed to get HT capability info");
2424 return -EIO;
2425 }
2426 u.cfg_value16 = cfg_value & 0xFFFF;
2427 if (!u.ht_cap_info.rxSTBC) {
2428 hdd_alert("RX STBC not supported");
2429 return -EINVAL;
2430 }
2431 }
2432 ret = sme_update_ht_config(hal, adapter->sessionId,
2433 WNI_CFG_HT_CAP_INFO_RX_STBC,
2434 value);
2435 if (ret)
2436 hdd_alert("Failed to set RX STBC value");
2437
2438 return ret;
2439}
2440
2441/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
2443 * @dev: device upon which the ioctl was received
2444 * @info: ioctl request information
2445 * @wrqu: ioctl request data
2446 * @extra: ioctl extra data
2447 *
2448 * Return: 0 on success, non-zero on error
2449 */
2450static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
2451 union iwreq_data *wrqu, char *extra)
2452{
2453 hdd_adapter_t *adapter;
2454 hdd_context_t *hdd_ctx;
2455 int ret;
2456
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002457 ENTER_DEV(dev);
2458
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
2460 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
2461 ret = wlan_hdd_validate_context(hdd_ctx);
2462 if (0 != ret)
2463 return ret;
2464
Jeff Johnson441e1f72017-02-07 08:50:49 -08002465 ret = hdd_check_standard_wext_control(hdd_ctx, info);
2466 if (0 != ret)
2467 return ret;
2468
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 /* Do nothing for now */
2470 return 0;
2471}
2472
2473/**
2474 * iw_set_commit() - SSR wrapper function for __iw_set_commit
2475 * @dev: pointer to net_device
2476 * @info: pointer to iw_request_info
2477 * @wrqu: pointer to iwreq_data
2478 * @extra: extra
2479 *
2480 * Return: 0 on success, error number otherwise
2481 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07002482static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 union iwreq_data *wrqu, char *extra)
2484{
2485 int ret;
2486
2487 cds_ssr_protect(__func__);
2488 ret = __iw_set_commit(dev, info, wrqu, extra);
2489 cds_ssr_unprotect(__func__);
2490
2491 return ret;
2492}
2493
2494/**
2495 * __iw_get_name() - SIOCGIWNAME ioctl handler
2496 * @dev: device upon which the ioctl was received
2497 * @info: ioctl request information
2498 * @wrqu: ioctl request data
2499 * @extra: ioctl extra data
2500 *
2501 * Return: 0 on success, non-zero on error
2502 */
2503static int __iw_get_name(struct net_device *dev,
2504 struct iw_request_info *info, char *wrqu, char *extra)
2505{
2506 hdd_adapter_t *adapter;
2507 hdd_context_t *hdd_ctx;
2508 int ret;
2509
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002510 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511
2512 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
2513 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
2514 ret = wlan_hdd_validate_context(hdd_ctx);
2515 if (0 != ret)
2516 return ret;
2517
Jeff Johnson441e1f72017-02-07 08:50:49 -08002518 ret = hdd_check_standard_wext_control(hdd_ctx, info);
2519 if (0 != ret)
2520 return ret;
2521
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
2523 EXIT();
2524 return 0;
2525}
2526
2527/**
2528 * __iw_get_name() - SSR wrapper for __iw_get_name
2529 * @dev: pointer to net_device
2530 * @info: pointer to iw_request_info
2531 * @wrqu: pointer to iwreq_data
2532 * @extra: extra
2533 *
2534 * Return: 0 on success, error number otherwise
2535 */
2536static int iw_get_name(struct net_device *dev,
2537 struct iw_request_info *info,
2538 char *wrqu, char *extra)
2539{
2540 int ret;
2541
2542 cds_ssr_protect(__func__);
2543 ret = __iw_get_name(dev, info, wrqu, extra);
2544 cds_ssr_unprotect(__func__);
2545
2546 return ret;
2547}
2548
2549/**
2550 * __iw_set_mode() - ioctl handler
2551 * @dev: device upon which the ioctl was received
2552 * @info: ioctl request information
2553 * @wrqu: ioctl request data
2554 * @extra: ioctl extra data
2555 *
2556 * Return: 0 on success, non-zero on error
2557 */
2558static int __iw_set_mode(struct net_device *dev,
2559 struct iw_request_info *info,
2560 union iwreq_data *wrqu, char *extra)
2561{
2562 hdd_wext_state_t *pWextState;
2563 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2564 hdd_context_t *hdd_ctx;
2565 tCsrRoamProfile *pRoamProfile;
2566 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 struct hdd_config *pConfig;
2568 struct wireless_dev *wdev;
2569 int ret;
2570
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002571 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572
2573 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2574 ret = wlan_hdd_validate_context(hdd_ctx);
2575 if (0 != ret)
2576 return ret;
2577
Jeff Johnson441e1f72017-02-07 08:50:49 -08002578 ret = hdd_check_standard_wext_control(hdd_ctx, info);
2579 if (0 != ret)
2580 return ret;
2581
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2583 wdev = dev->ieee80211_ptr;
2584 pRoamProfile = &pWextState->roamProfile;
2585 LastBSSType = pRoamProfile->BSSType;
2586
Jeff Johnson99bac312016-06-28 10:38:18 -07002587 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588
2589 switch (wrqu->mode) {
2590 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07002591 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2593 /* Set the phymode correctly for IBSS. */
2594 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
2595 pWextState->roamProfile.phyMode =
2596 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08002597 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 wdev->iftype = NL80211_IFTYPE_ADHOC;
2599 break;
2600 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07002601 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2603 wdev->iftype = NL80211_IFTYPE_STATION;
2604 break;
2605 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07002606 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
2608 break;
2609 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002610 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 return -EOPNOTSUPP;
2612 }
2613
2614 if (LastBSSType != pRoamProfile->BSSType) {
2615 /* the BSS mode changed. We need to issue disconnect
2616 * if connected or in IBSS disconnect state
2617 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07002618 if (hdd_conn_is_connected
2619 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302621 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 /* need to issue a disconnect to CSR. */
2623 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302624 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
2626 pAdapter->sessionId,
2627 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302628 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 unsigned long rc;
2630 rc = wait_for_completion_timeout(&pAdapter->
2631 disconnect_comp_var,
2632 msecs_to_jiffies
2633 (WLAN_WAIT_TIME_DISCONNECT));
2634 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07002635 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 }
2637 }
2638 }
2639
2640 EXIT();
2641 return 0;
2642}
2643
2644/**
2645 * iw_set_mode() - SSR wrapper for __iw_set_mode()
2646 * @dev: pointer to net_device
2647 * @info: pointer to iw_request_info
2648 * @wrqu: pointer to iwreq_data
2649 * @extra: pointer to extra ioctl payload
2650 *
2651 * Return: 0 on success, error number otherwise
2652 */
2653static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
2654 union iwreq_data *wrqu, char *extra)
2655{
2656 int ret;
2657
2658 cds_ssr_protect(__func__);
2659 ret = __iw_set_mode(dev, info, wrqu, extra);
2660 cds_ssr_unprotect(__func__);
2661
2662 return ret;
2663}
2664
2665/**
2666 * __iw_get_mode() - SIOCGIWMODE ioctl handler
2667 * @dev: device upon which the ioctl was received
2668 * @info: ioctl request information
2669 * @wrqu: ioctl request data
2670 * @extra: ioctl extra data
2671 *
2672 * Return: 0 on success, non-zero on error
2673 */
2674static int
2675__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2676 union iwreq_data *wrqu, char *extra)
2677{
2678 hdd_wext_state_t *pWextState;
2679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2680 hdd_context_t *hdd_ctx;
2681 int ret;
2682
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002683 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684
2685 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2686 ret = wlan_hdd_validate_context(hdd_ctx);
2687 if (0 != ret)
2688 return ret;
2689
Jeff Johnson441e1f72017-02-07 08:50:49 -08002690 ret = hdd_check_standard_wext_control(hdd_ctx, info);
2691 if (0 != ret)
2692 return ret;
2693
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2695
2696 switch (pWextState->roamProfile.BSSType) {
2697 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07002698 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 wrqu->mode = IW_MODE_INFRA;
2700 break;
2701 case eCSR_BSS_TYPE_IBSS:
2702 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07002703 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 wrqu->mode = IW_MODE_ADHOC;
2705 break;
2706 case eCSR_BSS_TYPE_ANY:
2707 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002708 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 wrqu->mode = IW_MODE_AUTO;
2710 break;
2711 }
2712
2713 EXIT();
2714 return 0;
2715}
2716
2717/**
2718 * iw_get_mode() - SSR wrapper for __iw_get_mode()
2719 * @dev: pointer to net_device
2720 * @info: pointer to iw_request_info
2721 * @wrqu: pointer to iwreq_data
2722 * @extra: pointer to extra ioctl payload
2723 *
2724 * Return: 0 on success, error number otherwise
2725 */
2726static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2727 union iwreq_data *wrqu, char *extra)
2728{
2729 int ret;
2730
2731 cds_ssr_protect(__func__);
2732 ret = __iw_get_mode(dev, info, wrqu, extra);
2733 cds_ssr_unprotect(__func__);
2734
2735 return ret;
2736}
2737
2738/**
2739 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
2740 * @dev: device upon which the ioctl was received
2741 * @info: ioctl request information
2742 * @wrqu: ioctl request data
2743 * @extra: ioctl extra data
2744 *
2745 * Return: 0 on success, non-zero on error
2746 */
2747static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2748 union iwreq_data *wrqu, char *extra)
2749{
2750 uint32_t numChans = 0;
2751 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2752 uint32_t indx = 0;
2753 int ret;
2754 hdd_wext_state_t *pWextState;
2755 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2756 hdd_context_t *hdd_ctx;
2757 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2758 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2759 tCsrRoamProfile *pRoamProfile;
2760
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002761 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762
2763 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2764 ret = wlan_hdd_validate_context(hdd_ctx);
2765 if (0 != ret)
2766 return ret;
2767
Jeff Johnson441e1f72017-02-07 08:50:49 -08002768 ret = hdd_check_standard_wext_control(hdd_ctx, info);
2769 if (0 != ret)
2770 return ret;
2771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002772 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2773
2774 pRoamProfile = &pWextState->roamProfile;
2775
Jeff Johnson99bac312016-06-28 10:38:18 -07002776 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777
2778 /* Link is up then return cant set channel */
2779 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
2780 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002781 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 return -EOPNOTSUPP;
2783 }
2784
2785 /* Settings by Frequency as input */
2786 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
2787 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
2788 uint32_t freq = wrqu->freq.m / 100000;
2789
2790 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
2791 && (freq != freq_chan_map[indx].freq))
2792 indx++;
2793 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
2794 return -EINVAL;
2795 }
2796 wrqu->freq.e = 0;
2797 wrqu->freq.m = freq_chan_map[indx].chan;
2798
2799 }
2800
2801 if (wrqu->freq.e == 0) {
2802 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2803 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002804 hdd_notice("Channel %d is outside valid range from %d to %d",
2805 wrqu->freq.m,
2806 WNI_CFG_CURRENT_CHANNEL_STAMIN,
2807 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 return -EINVAL;
2809 }
2810
2811 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2812
2813 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2814 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302815 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002816 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 return -EIO;
2818 }
2819
2820 for (indx = 0; indx < numChans; indx++) {
2821 if (wrqu->freq.m == validChan[indx]) {
2822 break;
2823 }
2824 }
2825 } else {
2826
2827 return -EINVAL;
2828 }
2829
2830 if (indx >= numChans) {
2831 return -EINVAL;
2832 }
2833
2834 /* Set the Operational Channel */
2835 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2836 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2837 pRoamProfile->ChannelInfo.ChannelList =
2838 &pHddStaCtx->conn_info.operationChannel;
2839
Jeff Johnson99bac312016-06-28 10:38:18 -07002840 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841
2842 EXIT();
2843
2844 return ret;
2845}
2846
2847/**
2848 * iw_set_freq() - SSR wrapper for __iw_set_freq()
2849 * @dev: pointer to net_device
2850 * @info: pointer to iw_request_info
2851 * @wrqu: pointer to iwreq_data
2852 * @extra: pointer to extra ioctl payload
2853 *
2854 * Return: 0 on success, error number otherwise
2855 */
2856static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2857 union iwreq_data *wrqu, char *extra)
2858{
2859 int ret;
2860
2861 cds_ssr_protect(__func__);
2862 ret = __iw_set_freq(dev, info, wrqu, extra);
2863 cds_ssr_unprotect(__func__);
2864
2865 return ret;
2866}
2867
2868/**
2869 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
2870 * @dev: device upon which the ioctl was received
2871 * @info: ioctl request information
2872 * @wrqu: ioctl request data
2873 * @extra: ioctl extra data
2874 *
2875 * Return: 0 on success, non-zero on error
2876 */
2877static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2878 struct iw_freq *fwrq, char *extra)
2879{
2880 uint32_t status = false, channel = 0, freq = 0;
2881 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2882 tHalHandle hHal;
2883 hdd_wext_state_t *pWextState;
2884 tCsrRoamProfile *pRoamProfile;
2885 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2886 hdd_context_t *hdd_ctx;
2887 int ret;
2888
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002889 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890
2891 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2892 ret = wlan_hdd_validate_context(hdd_ctx);
2893 if (0 != ret)
2894 return ret;
2895
Jeff Johnson441e1f72017-02-07 08:50:49 -08002896 ret = hdd_check_standard_wext_control(hdd_ctx, info);
2897 if (0 != ret)
2898 return ret;
2899
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2901 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2902
2903 pRoamProfile = &pWextState->roamProfile;
2904
2905 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
2906 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302907 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002908 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 pAdapter->sessionId);
2910 return -EIO;
Jeff Johnson68755312017-02-10 11:46:55 -08002911 }
2912
2913 status = hdd_wlan_get_freq(channel, &freq);
2914 if (true == status) {
2915 /* Set Exponent parameter as 6 (MHZ)
2916 * in struct iw_freq iwlist & iwconfig
2917 * command shows frequency into proper
2918 * format (2.412 GHz instead of 246.2
2919 * MHz)
2920 */
2921 fwrq->m = freq;
2922 fwrq->e = MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 }
2924 } else {
2925 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2926 * iwlist & iwconfig command shows frequency into proper
2927 * format (2.412 GHz instead of 246.2 MHz)
2928 */
2929 fwrq->m = 0;
2930 fwrq->e = MHZ;
2931 }
2932 return 0;
2933}
2934
2935/**
2936 * iw_get_freq() - SSR wrapper for __iw_get_freq()
2937 * @dev: pointer to net_device
2938 * @info: pointer to iw_request_info
2939 * @fwrq: pointer to frequency data
2940 * @extra: pointer to extra ioctl payload
2941 *
2942 * Return: 0 on success, error number otherwise
2943 */
2944static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2945 struct iw_freq *fwrq, char *extra)
2946{
2947 int ret;
2948
2949 cds_ssr_protect(__func__);
2950 ret = __iw_get_freq(dev, info, fwrq, extra);
2951 cds_ssr_unprotect(__func__);
2952
2953 return ret;
2954}
2955
2956/**
2957 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
2958 * @dev: device upon which the ioctl was received
2959 * @info: ioctl request information
2960 * @wrqu: ioctl request data
2961 * @extra: ioctl extra data
2962 *
2963 * Return: 0 on success, non-zero on error
2964 */
2965static int __iw_get_tx_power(struct net_device *dev,
2966 struct iw_request_info *info,
2967 union iwreq_data *wrqu, char *extra)
2968{
2969
2970 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2971 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2972 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2973 int ret;
2974
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002975 ENTER_DEV(dev);
2976
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 ret = wlan_hdd_validate_context(hdd_ctx);
2978 if (0 != ret)
2979 return ret;
2980
Jeff Johnson441e1f72017-02-07 08:50:49 -08002981 ret = hdd_check_standard_wext_control(hdd_ctx, info);
2982 if (0 != ret)
2983 return ret;
2984
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
2986 wrqu->txpower.value = 0;
2987 return 0;
2988 }
2989 wlan_hdd_get_class_astats(pAdapter);
2990 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
2991
2992 return 0;
2993}
2994
2995/**
2996 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
2997 * @dev: pointer to net_device
2998 * @info: pointer to iw_request_info
2999 * @wrqu: pointer to iwreq_data
3000 * @extra: pointer to extra ioctl payload
3001 *
3002 * Return: 0 on success, error number otherwise
3003 */
3004static int iw_get_tx_power(struct net_device *dev,
3005 struct iw_request_info *info,
3006 union iwreq_data *wrqu, char *extra)
3007{
3008 int ret;
3009
3010 cds_ssr_protect(__func__);
3011 ret = __iw_get_tx_power(dev, info, wrqu, extra);
3012 cds_ssr_unprotect(__func__);
3013
3014 return ret;
3015}
3016
3017/**
3018 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
3019 * @dev: device upon which the ioctl was received
3020 * @info: ioctl request information
3021 * @wrqu: ioctl request data
3022 * @extra: ioctl extra data
3023 *
3024 * Return: 0 on success, non-zero on error
3025 */
3026static int __iw_set_tx_power(struct net_device *dev,
3027 struct iw_request_info *info,
3028 union iwreq_data *wrqu, char *extra)
3029{
3030 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3031 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3032 hdd_context_t *hdd_ctx;
3033 int ret;
3034
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003035 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036
3037 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3038 ret = wlan_hdd_validate_context(hdd_ctx);
3039 if (0 != ret)
3040 return ret;
3041
Jeff Johnson441e1f72017-02-07 08:50:49 -08003042 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3043 if (0 != ret)
3044 return ret;
3045
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303047 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003048 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 return -EIO;
3050 }
3051
3052 EXIT();
3053
3054 return 0;
3055}
3056
3057/**
3058 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
3059 * @dev: pointer to net_device
3060 * @info: pointer to iw_request_info
3061 * @wrqu: pointer to iwreq_data
3062 * @extra: pointer to extra ioctl payload
3063 *
3064 * Return: 0 on success, error number otherwise
3065 */
3066static int iw_set_tx_power(struct net_device *dev,
3067 struct iw_request_info *info,
3068 union iwreq_data *wrqu, char *extra)
3069{
3070 int ret;
3071
3072 cds_ssr_protect(__func__);
3073 ret = __iw_set_tx_power(dev, info, wrqu, extra);
3074 cds_ssr_unprotect(__func__);
3075
3076 return ret;
3077}
3078
3079/**
3080 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
3081 * @dev: device upon which the ioctl was received
3082 * @info: ioctl request information
3083 * @wrqu: ioctl request data
3084 * @extra: ioctl extra data
3085 *
3086 * Return: 0 on success, non-zero on error
3087 */
3088static int __iw_get_bitrate(struct net_device *dev,
3089 struct iw_request_info *info,
3090 union iwreq_data *wrqu, char *extra)
3091{
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003092 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 hdd_wext_state_t *pWextState;
3094 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3095 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3096 hdd_context_t *hdd_ctx;
3097 int ret;
3098
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003099 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100
3101 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3102 ret = wlan_hdd_validate_context(hdd_ctx);
3103 if (0 != ret)
3104 return ret;
3105
Jeff Johnson441e1f72017-02-07 08:50:49 -08003106 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3107 if (0 != ret)
3108 return ret;
3109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
3111 wrqu->bitrate.value = 0;
3112 } else {
3113 status =
3114 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3115 eCSR_HDD,
3116 SME_SUMMARY_STATS |
3117 SME_GLOBAL_CLASSA_STATS |
3118 SME_GLOBAL_CLASSB_STATS |
3119 SME_GLOBAL_CLASSC_STATS |
3120 SME_GLOBAL_CLASSD_STATS |
3121 SME_PER_STA_STATS,
3122 hdd_statistics_cb, 0,
3123 false,
3124 pHddStaCtx->conn_info.staId[0],
3125 pAdapter, pAdapter->sessionId);
3126
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303127 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003128 hdd_err("Unable to retrieve statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003129 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 }
3131
3132 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3133
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003134 status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303135 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 WLAN_WAIT_TIME_STATS);
3137
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003138 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003139 hdd_err("SME timeout while retrieving statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003140 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 }
3142
3143 wrqu->bitrate.value =
3144 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
3145 }
3146
3147 EXIT();
3148
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003149 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150}
3151
3152/**
3153 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
3154 * @dev: pointer to net_device
3155 * @info: pointer to iw_request_info
3156 * @wrqu: pointer to iwreq_data
3157 * @extra: pointer to extra ioctl payload
3158 *
3159 * Return: 0 on success, error number otherwise
3160 */
3161static int iw_get_bitrate(struct net_device *dev,
3162 struct iw_request_info *info,
3163 union iwreq_data *wrqu, char *extra)
3164{
3165 int ret;
3166
3167 cds_ssr_protect(__func__);
3168 ret = __iw_get_bitrate(dev, info, wrqu, extra);
3169 cds_ssr_unprotect(__func__);
3170
3171 return ret;
3172}
3173
3174/**
3175 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
3176 * @dev: device upon which the ioctl was received
3177 * @info: ioctl request information
3178 * @wrqu: ioctl request data
3179 * @extra: ioctl extra data
3180 *
3181 * Return: 0 on success, non-zero on error
3182 */
3183static int __iw_set_bitrate(struct net_device *dev,
3184 struct iw_request_info *info,
3185 union iwreq_data *wrqu, char *extra)
3186{
3187 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3188 hdd_wext_state_t *pWextState;
3189 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3190 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3191 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3192 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3193 uint32_t i, rate;
3194 uint32_t valid_rate = false, active_phy_mode = 0;
3195 hdd_context_t *hdd_ctx;
3196 int ret;
3197
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003198 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199
3200 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3201 ret = wlan_hdd_validate_context(hdd_ctx);
3202 if (0 != ret)
3203 return ret;
3204
Jeff Johnson441e1f72017-02-07 08:50:49 -08003205 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3206 if (0 != ret)
3207 return ret;
3208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3210
3211 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
3212 return -ENXIO;
3213 }
3214
3215 rate = wrqu->bitrate.value;
3216
3217 if (rate == -1) {
3218 rate = WNI_CFG_FIXED_RATE_AUTO;
3219 valid_rate = true;
3220 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
3221 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303222 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
3224 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
3225 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
3226 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
3227 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303228 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 &&
3230 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
3231 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303232 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 for (i = 0; i < (b_len + a_len); ++i) {
3234 /* supported rates returned is double
3235 * the actual rate so we divide it by 2
3236 */
3237 if ((supp_rates[i] & 0x7F) / 2 ==
3238 rate) {
3239 valid_rate = true;
3240 rate = i +
3241 WNI_CFG_FIXED_RATE_1MBPS;
3242 break;
3243 }
3244 }
3245 }
3246 }
3247 }
3248 if (valid_rate != true) {
3249 return -EINVAL;
3250 }
3251 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303252 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003253 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 return -EIO;
3255 }
3256 return 0;
3257}
3258
3259/**
3260 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
3261 * @dev: pointer to net_device
3262 * @info: pointer to iw_request_info
3263 * @wrqu: pointer to iwreq_data
3264 * @extra: pointer to extra ioctl payload
3265 *
3266 * Return: 0 on success, error number otherwise
3267 */
3268static int iw_set_bitrate(struct net_device *dev,
3269 struct iw_request_info *info,
3270 union iwreq_data *wrqu, char *extra)
3271{
3272 int ret;
3273
3274 cds_ssr_protect(__func__);
3275 ret = __iw_set_bitrate(dev, info, wrqu, extra);
3276 cds_ssr_unprotect(__func__);
3277
3278 return ret;
3279}
3280
3281/**
3282 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
3283 * @dev: device upon which the ioctl was received
3284 * @info: ioctl request information
3285 * @wrqu: ioctl request data
3286 * @extra: ioctl extra data
3287 *
3288 * Return: 0 on success, non-zero on error
3289 */
3290static int __iw_set_genie(struct net_device *dev,
3291 struct iw_request_info *info,
3292 union iwreq_data *wrqu, char *extra)
3293{
3294 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3295 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3296 uint8_t *genie = NULL;
3297 uint8_t *base_genie = NULL;
3298 uint16_t remLen;
3299 hdd_context_t *hdd_ctx;
3300 int ret;
3301
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003302 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303
3304 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3305 ret = wlan_hdd_validate_context(hdd_ctx);
3306 if (0 != ret)
3307 return ret;
3308
Jeff Johnson441e1f72017-02-07 08:50:49 -08003309 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3310 if (0 != ret)
3311 return ret;
3312
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 if (!wrqu->data.length) {
3314 hdd_clear_roam_profile_ie(pAdapter);
3315 EXIT();
3316 return 0;
3317 }
3318
3319 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3320 wrqu->data.length);
3321 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003322 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 return -ENOMEM;
3324 }
3325
3326 genie = base_genie;
3327
3328 remLen = wrqu->data.length;
3329
Jeff Johnson99bac312016-06-28 10:38:18 -07003330 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003331 genie[1]);
3332
3333 /* clear any previous genIE before this call */
3334 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
3335
3336 while (remLen >= 2) {
3337 uint16_t eLen = 0;
3338 uint8_t elementId;
3339 elementId = *genie++;
3340 eLen = *genie++;
3341 remLen -= 2;
3342
Jeff Johnson99bac312016-06-28 10:38:18 -07003343 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344
3345 switch (elementId) {
3346 case IE_EID_VENDOR:
3347 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 +05303348 ret = -EINVAL;
3349 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 }
3351
3352 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
3353 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07003354 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
3355 genie[0], genie[1], genie[2],
3356 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357
3358 if (SIR_MAC_MAX_IE_LENGTH <
3359 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003360 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303361 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303362 ret = -ENOMEM;
3363 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364 }
3365 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
3366 memcpy(pWextState->genIE.addIEdata +
3367 curGenIELen, genie - 2, eLen + 2);
3368 pWextState->genIE.length += eLen + 2;
3369 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003370 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303371 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
3372 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
3373 ret = -EINVAL;
3374 QDF_ASSERT(0);
3375 goto exit;
3376 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377 memset(pWextState->WPARSNIE, 0,
3378 MAX_WPA_RSN_IE_LEN);
3379 memcpy(pWextState->WPARSNIE, genie - 2,
3380 (eLen + 2));
3381 pWextState->roamProfile.pWPAReqIE =
3382 pWextState->WPARSNIE;
3383 pWextState->roamProfile.nWPAReqIELength =
3384 eLen + 2;
3385 } else { /* any vendorId except WPA IE should be accumulated to genIE */
3386
3387 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07003388 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
3389 genie[0], genie[1], genie[2],
3390 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391
3392 if (SIR_MAC_MAX_IE_LENGTH <
3393 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003394 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303395 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303396 ret = -ENOMEM;
3397 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 }
3399 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
3400 memcpy(pWextState->genIE.addIEdata +
3401 curGenIELen, genie - 2, eLen + 2);
3402 pWextState->genIE.length += eLen + 2;
3403 }
3404 break;
3405 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07003406 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303407 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
3408 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
3409 ret = -EINVAL;
3410 QDF_ASSERT(0);
3411 goto exit;
3412 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
3414 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
3415 pWextState->roamProfile.pRSNReqIE =
3416 pWextState->WPARSNIE;
3417 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
3418 break;
3419
3420 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003421 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303422 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 }
3424 genie += eLen;
3425 remLen -= eLen;
3426 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303427exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07003429 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303430 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431}
3432
3433/**
3434 * iw_set_genie() - SSR wrapper for __iw_set_genie()
3435 * @dev: pointer to net_device
3436 * @info: pointer to iw_request_info
3437 * @wrqu: pointer to iwreq_data
3438 * @extra: pointer to extra ioctl payload
3439 *
3440 * Return: 0 on success, error number otherwise
3441 */
3442static int iw_set_genie(struct net_device *dev,
3443 struct iw_request_info *info,
3444 union iwreq_data *wrqu, char *extra)
3445{
3446 int ret;
3447
3448 cds_ssr_protect(__func__);
3449 ret = __iw_set_genie(dev, info, wrqu, extra);
3450 cds_ssr_unprotect(__func__);
3451
3452 return ret;
3453}
3454
3455/**
3456 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
3457 * @dev: device upon which the ioctl was received
3458 * @info: ioctl request information
3459 * @wrqu: ioctl request data
3460 * @extra: ioctl extra data
3461 *
3462 * Return: 0 on success, non-zero on error
3463 */
3464static int __iw_get_genie(struct net_device *dev,
3465 struct iw_request_info *info,
3466 union iwreq_data *wrqu, char *extra)
3467{
3468 hdd_wext_state_t *pWextState;
3469 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3470 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303471 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
3473 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
3474 hdd_context_t *hdd_ctx;
3475 int ret;
3476
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003477 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478
3479 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3480 ret = wlan_hdd_validate_context(hdd_ctx);
3481 if (0 != ret)
3482 return ret;
3483
Jeff Johnson441e1f72017-02-07 08:50:49 -08003484 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3485 if (0 != ret)
3486 return ret;
3487
Jeff Johnson99bac312016-06-28 10:38:18 -07003488 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489
3490 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3491
3492 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
3493 return -ENXIO;
3494 }
3495
3496 /* Return something ONLY if we are associated with an RSN or
3497 * WPA network
3498 */
3499 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
3500 return -ENXIO;
3501 }
3502
3503 /* Actually retrieve the RSN IE from CSR. (We previously sent
3504 * it down in the CSR Roam Profile.)
3505 */
3506 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
3507 pAdapter->sessionId,
3508 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05303509 if (QDF_STATUS_SUCCESS != status) {
3510 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 return -EFAULT;
3512 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05303514 if (length > DOT11F_IE_RSN_MAX_LEN) {
3515 hdd_notice("invalid buffer length length:%d", length);
3516 return -E2BIG;
3517 }
3518 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003519
Jeff Johnson99bac312016-06-28 10:38:18 -07003520 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 wrqu->data.length);
3522
3523 EXIT();
3524
3525 return 0;
3526}
3527
3528/**
3529 * iw_get_genie() - SSR wrapper for __iw_get_genie()
3530 * @dev: pointer to net_device
3531 * @info: pointer to iw_request_info
3532 * @wrqu: pointer to iwreq_data
3533 * @extra: pointer to extra ioctl payload
3534 *
3535 * Return: 0 on success, error number otherwise
3536 */
3537static int iw_get_genie(struct net_device *dev,
3538 struct iw_request_info *info,
3539 union iwreq_data *wrqu, char *extra)
3540{
3541 int ret;
3542
3543 cds_ssr_protect(__func__);
3544 ret = __iw_get_genie(dev, info, wrqu, extra);
3545 cds_ssr_unprotect(__func__);
3546
3547 return ret;
3548}
3549
3550/**
3551 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
3552 * @dev: device upon which the ioctl was received
3553 * @info: ioctl request information
3554 * @wrqu: ioctl request data
3555 * @extra: ioctl extra data
3556 *
3557 * Return: 0 on success, non-zero on error
3558 */
3559static int __iw_get_encode(struct net_device *dev,
3560 struct iw_request_info *info,
3561 struct iw_point *dwrq, char *extra)
3562{
3563 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3564 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3565 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3566 int keyId;
3567 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3568 int i;
3569 hdd_context_t *hdd_ctx;
3570 int ret;
3571
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003572 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573
3574 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3575 ret = wlan_hdd_validate_context(hdd_ctx);
3576 if (0 != ret)
3577 return ret;
3578
Jeff Johnson441e1f72017-02-07 08:50:49 -08003579 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3580 if (0 != ret)
3581 return ret;
3582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 keyId = pRoamProfile->Keys.defaultIndex;
3584
3585 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003586 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587 return -EINVAL;
3588 }
3589
3590 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
3591 dwrq->flags |= IW_ENCODE_ENABLED;
3592 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303593 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594 pRoamProfile->Keys.KeyLength[keyId]);
3595
3596 dwrq->flags |= (keyId + 1);
3597
3598 } else {
3599 dwrq->flags |= IW_ENCODE_DISABLED;
3600 }
3601
3602 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08003603 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 continue;
3605 } else {
3606 break;
3607 }
3608 }
3609
3610 if (MAX_WEP_KEYS == i) {
3611 dwrq->flags |= IW_ENCODE_NOKEY;
3612 }
3613
3614 authType =
3615 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
3616 conn_info.authType;
3617
3618 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
3619 dwrq->flags |= IW_ENCODE_OPEN;
3620 } else {
3621 dwrq->flags |= IW_ENCODE_RESTRICTED;
3622 }
3623 EXIT();
3624 return 0;
3625}
3626
3627/**
3628 * iw_get_encode() - SSR wrapper for __iw_get_encode()
3629 * @dev: pointer to net_device
3630 * @info: pointer to iw_request_info
3631 * @dwrq: pointer to encoding information
3632 * @extra: pointer to extra ioctl payload
3633 *
3634 * Return: 0 on success, error number otherwise
3635 */
3636static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
3637 struct iw_point *dwrq, char *extra)
3638{
3639 int ret;
3640
3641 cds_ssr_protect(__func__);
3642 ret = __iw_get_encode(dev, info, dwrq, extra);
3643 cds_ssr_unprotect(__func__);
3644
3645 return ret;
3646}
3647
3648/**
3649 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
3650 * @dev: device upon which the ioctl was received
3651 * @info: ioctl request information
3652 * @wrqu: ioctl request data
3653 * @extra: ioctl extra data
3654 *
3655 * Return: 0 on success, non-zero on error
3656 */
3657static int __iw_get_rts_threshold(struct net_device *dev,
3658 struct iw_request_info *info,
3659 union iwreq_data *wrqu, char *extra)
3660{
Jeff Johnson5b907622017-02-07 10:00:37 -08003661 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3662 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3663 uint32_t threshold = 0;
3664 hdd_context_t *hdd_ctx;
3665 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003667 ENTER_DEV(dev);
3668
Jeff Johnson5b907622017-02-07 10:00:37 -08003669 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3670 ret = wlan_hdd_validate_context(hdd_ctx);
3671 if (0 != ret)
3672 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673
Jeff Johnson441e1f72017-02-07 08:50:49 -08003674 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3675 if (0 != ret)
3676 return ret;
3677
Jeff Johnson5b907622017-02-07 10:00:37 -08003678 if (QDF_STATUS_SUCCESS !=
3679 sme_cfg_get_int(hal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
3680 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
3681 return -EIO;
3682 }
3683 wrqu->rts.value = threshold;
3684
3685 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
3686
3687 EXIT();
3688
3689 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690}
3691
3692/**
3693 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
3694 * @dev: device upon which the ioctl was received
3695 * @info: ioctl request information
3696 * @wrqu: ioctl request data
3697 * @extra: ioctl extra data
3698 *
3699 * Return: 0 on success, non-zero on error
3700 */
3701static int __iw_set_rts_threshold(struct net_device *dev,
3702 struct iw_request_info *info,
3703 union iwreq_data *wrqu, char *extra)
3704{
3705 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3706 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3707 hdd_context_t *hdd_ctx;
3708 int ret;
3709
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003710 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711
3712 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3713 ret = wlan_hdd_validate_context(hdd_ctx);
3714 if (0 != ret)
3715 return ret;
3716
Jeff Johnson441e1f72017-02-07 08:50:49 -08003717 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3718 if (0 != ret)
3719 return ret;
3720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003721 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
3722 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
3723 return -EINVAL;
3724 }
3725
3726 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303727 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003728 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003729 return -EIO;
3730 }
3731
3732 EXIT();
3733
3734 return 0;
3735}
3736
3737/**
3738 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
3739 * @dev: pointer to net_device
3740 * @info: pointer to iw_request_info
3741 * @wrqu: pointer to iwreq_data
3742 * @extra: pointer to extra ioctl payload
3743 *
3744 * Return: 0 on success, error number otherwise
3745 */
Jeff Johnson5b907622017-02-07 10:00:37 -08003746int iw_get_rts_threshold(struct net_device *dev,
3747 struct iw_request_info *info,
3748 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749{
3750 int ret;
3751
3752 cds_ssr_protect(__func__);
3753 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
3754 cds_ssr_unprotect(__func__);
3755
3756 return ret;
3757}
3758
3759/**
3760 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
3761 * @dev: pointer to net_device
3762 * @info: pointer to iw_request_info
3763 * @wrqu: pointer to iwreq_data
3764 * @extra: pointer to extra ioctl payload
3765 *
3766 * Return: 0 on success, error number otherwise
3767 */
3768static int iw_set_rts_threshold(struct net_device *dev,
3769 struct iw_request_info *info,
3770 union iwreq_data *wrqu, char *extra)
3771{
3772 int ret;
3773
3774 cds_ssr_protect(__func__);
3775 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
3776 cds_ssr_unprotect(__func__);
3777
3778 return ret;
3779}
3780
3781/**
3782 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
3783 * @dev: device upon which the ioctl was received
3784 * @info: ioctl request information
3785 * @wrqu: ioctl request data
3786 * @extra: ioctl extra data
3787 *
3788 * Return: 0 on success, non-zero on error
3789 */
3790static int __iw_get_frag_threshold(struct net_device *dev,
3791 struct iw_request_info *info,
3792 union iwreq_data *wrqu, char *extra)
3793{
Jeff Johnson5b907622017-02-07 10:00:37 -08003794 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3795 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3796 uint32_t threshold = 0;
3797 hdd_context_t *hdd_ctx;
3798 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003800 ENTER_DEV(dev);
3801
Jeff Johnson5b907622017-02-07 10:00:37 -08003802 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3803 ret = wlan_hdd_validate_context(hdd_ctx);
3804 if (0 != ret)
3805 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806
Jeff Johnson441e1f72017-02-07 08:50:49 -08003807 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3808 if (0 != ret)
3809 return ret;
3810
Jeff Johnson5b907622017-02-07 10:00:37 -08003811 if (sme_cfg_get_int(hal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
3812 != QDF_STATUS_SUCCESS) {
3813 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
3814 return -EIO;
3815 }
3816 wrqu->frag.value = threshold;
3817
3818 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
3819
3820 EXIT();
3821
3822 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823}
3824
3825/**
3826 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
3827 * @dev: pointer to net_device
3828 * @info: pointer to iw_request_info
3829 * @wrqu: pointer to iwreq_data
3830 * @extra: pointer to extra ioctl payload
3831 *
3832 * Return: 0 on success, error number otherwise
3833 */
Jeff Johnson5b907622017-02-07 10:00:37 -08003834int iw_get_frag_threshold(struct net_device *dev,
3835 struct iw_request_info *info,
3836 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837{
3838 int ret;
3839
3840 cds_ssr_protect(__func__);
3841 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3842 cds_ssr_unprotect(__func__);
3843
3844 return ret;
3845}
3846
3847/**
3848 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
3849 * @dev: device upon which the ioctl was received
3850 * @info: ioctl request information
3851 * @wrqu: ioctl request data
3852 * @extra: ioctl extra data
3853 *
3854 * Return: 0 on success, non-zero on error
3855 */
3856static int __iw_set_frag_threshold(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 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3862 hdd_context_t *hdd_ctx;
3863 int ret;
3864
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003865 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866
3867 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3868 ret = wlan_hdd_validate_context(hdd_ctx);
3869 if (0 != ret)
3870 return ret;
3871
Jeff Johnson441e1f72017-02-07 08:50:49 -08003872 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3873 if (0 != ret)
3874 return ret;
3875
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
3877 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
3878 return -EINVAL;
3879 }
3880
3881 if (sme_cfg_set_int
3882 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303883 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003884 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885 return -EIO;
3886 }
3887
3888 EXIT();
3889
3890 return 0;
3891}
3892
3893/**
3894 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
3895 * @dev: pointer to net_device
3896 * @info: pointer to iw_request_info
3897 * @wrqu: pointer to iwreq_data
3898 * @extra: pointer to extra ioctl payload
3899 *
3900 * Return: 0 on success, error number otherwise
3901 */
3902static int iw_set_frag_threshold(struct net_device *dev,
3903 struct iw_request_info *info,
3904 union iwreq_data *wrqu, char *extra)
3905{
3906 int ret;
3907
3908 cds_ssr_protect(__func__);
3909 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3910 cds_ssr_unprotect(__func__);
3911
3912 return ret;
3913}
3914
3915/**
3916 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
3917 * @dev: device upon which the ioctl was received
3918 * @info: ioctl request information
3919 * @wrqu: ioctl request data
3920 * @extra: ioctl extra data
3921 *
3922 * Return: 0 on success, non-zero on error
3923 */
3924static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003925 struct iw_request_info *info,
3926 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927{
3928 hdd_adapter_t *adapter;
3929 hdd_context_t *hdd_ctx;
3930 int ret;
3931
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003932 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003933
3934 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3935 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3936 ret = wlan_hdd_validate_context(hdd_ctx);
3937 if (0 != ret)
3938 return ret;
3939
Jeff Johnson441e1f72017-02-07 08:50:49 -08003940 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3941 if (0 != ret)
3942 return ret;
3943
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 return -EOPNOTSUPP;
3945}
3946
3947/**
3948 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
3949 * @dev: pointer to net_device
3950 * @info: pointer to iw_request_info
3951 * @wrqu: pointer to iwreq_data
3952 * @extra: extra
3953 *
3954 * Return: 0 on success, error number otherwise
3955 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003956static int iw_get_power_mode(struct net_device *dev,
3957 struct iw_request_info *info,
3958 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959{
3960 int ret;
3961
3962 cds_ssr_protect(__func__);
3963 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3964 cds_ssr_unprotect(__func__);
3965
3966 return ret;
3967}
3968
3969/**
3970 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
3971 * @dev: device upon which the ioctl was received
3972 * @info: ioctl request information
3973 * @wrqu: ioctl request data
3974 * @extra: ioctl extra data
3975 *
3976 * Return: 0 on success, non-zero on error
3977 */
3978static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003979 struct iw_request_info *info,
3980 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981{
3982 hdd_adapter_t *adapter;
3983 hdd_context_t *hdd_ctx;
3984 int ret;
3985
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003986 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987
3988 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3989 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3990 ret = wlan_hdd_validate_context(hdd_ctx);
3991 if (0 != ret)
3992 return ret;
3993
Jeff Johnson441e1f72017-02-07 08:50:49 -08003994 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3995 if (0 != ret)
3996 return ret;
3997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998 return -EOPNOTSUPP;
3999}
4000
4001/**
4002 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
4003 * @dev: pointer to net_device
4004 * @info: pointer to iw_request_info
4005 * @wrqu: pointer to iwreq_data
4006 * @extra: extra
4007 *
4008 * Return: 0 on success, error number otherwise
4009 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004010static int iw_set_power_mode(struct net_device *dev,
4011 struct iw_request_info *info,
4012 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013{
4014 int ret;
4015
4016 cds_ssr_protect(__func__);
4017 ret = __iw_set_power_mode(dev, info, wrqu, extra);
4018 cds_ssr_unprotect(__func__);
4019
4020 return ret;
4021}
4022
4023/**
4024 * __iw_get_range() - SIOCGIWRANGE ioctl handler
4025 * @dev: device upon which the ioctl was received
4026 * @info: ioctl request information
4027 * @wrqu: ioctl request data
4028 * @extra: ioctl extra data
4029 *
4030 * Return: 0 on success, non-zero on error
4031 */
4032static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
4033 union iwreq_data *wrqu, char *extra)
4034{
4035 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4036 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4037 struct iw_range *range = (struct iw_range *)extra;
4038
4039 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4040
4041 uint32_t num_channels = sizeof(channels);
4042 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4043 uint32_t a_len;
4044 uint32_t b_len;
4045 uint32_t active_phy_mode = 0;
4046 uint8_t index = 0, i;
4047 hdd_context_t *hdd_ctx;
4048 int ret;
4049
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004050 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051
4052 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4053 ret = wlan_hdd_validate_context(hdd_ctx);
4054 if (0 != ret)
4055 return ret;
4056
Jeff Johnson441e1f72017-02-07 08:50:49 -08004057 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4058 if (0 != ret)
4059 return ret;
4060
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 wrqu->data.length = sizeof(struct iw_range);
4062 memset(range, 0, sizeof(struct iw_range));
4063
4064
4065 /*Get the phy mode */
4066 if (sme_cfg_get_int(hHal,
4067 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304068 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004069 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070
4071 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
4072 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
4073 /*Get the supported rates for 11G band */
4074 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4075 if (sme_cfg_get_str(hHal,
4076 WNI_CFG_SUPPORTED_RATES_11A,
4077 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304078 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
4080 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4081 }
4082 for (i = 0; i < a_len; i++) {
4083 range->bitrate[i] =
4084 ((supp_rates[i] & 0x7F) / 2) *
4085 1000000;
4086 }
4087 range->num_bitrates = a_len;
4088 } else {
4089 return -EIO;
4090 }
4091 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
4092 /*Get the supported rates for 11B band */
4093 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4094 if (sme_cfg_get_str(hHal,
4095 WNI_CFG_SUPPORTED_RATES_11B,
4096 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304097 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
4099 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4100 }
4101 for (i = 0; i < b_len; i++) {
4102 range->bitrate[i] =
4103 ((supp_rates[i] & 0x7F) / 2) *
4104 1000000;
4105 }
4106 range->num_bitrates = b_len;
4107 } else {
4108 return -EIO;
4109 }
4110 }
4111 }
4112
4113 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
4114 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
4115 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
4116
4117 range->encoding_size[0] = 5;
4118 range->encoding_size[1] = 13;
4119 range->num_encoding_sizes = 2;
4120 range->max_encoding_tokens = MAX_WEP_KEYS;
4121
4122 /* we support through Wireless Extensions 22 */
4123 range->we_version_compiled = WIRELESS_EXT;
4124 range->we_version_source = 22;
4125
4126 /*Supported Channels and Frequencies */
4127 if (sme_cfg_get_str
4128 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304129 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004130 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 return -EIO;
4132 }
4133 if (num_channels > IW_MAX_FREQUENCIES) {
4134 num_channels = IW_MAX_FREQUENCIES;
4135 }
4136
4137 range->num_channels = num_channels;
4138 range->num_frequency = num_channels;
4139
4140 for (index = 0; index < num_channels; index++) {
4141 uint32_t frq_indx = 0;
4142
4143 range->freq[index].i = channels[index];
4144 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
4145 if (channels[index] == freq_chan_map[frq_indx].chan) {
4146 range->freq[index].m =
4147 freq_chan_map[frq_indx].freq * 100000;
4148 range->freq[index].e = 1;
4149 break;
4150 }
4151 frq_indx++;
4152 }
4153 }
4154
4155 /* Event capability (kernel + driver) */
4156 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
4157 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
4158 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
4159 range->event_capa[1] = IW_EVENT_CAPA_K_1;
4160
4161 /*Encryption capability */
4162 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
4163 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
4164
4165 /* Txpower capability */
4166 range->txpower_capa = IW_TXPOW_MWATT;
4167
4168 /*Scanning capability */
4169#if WIRELESS_EXT >= 22
4170 range->scan_capa =
4171 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
4172#endif
4173
4174 EXIT();
4175 return 0;
4176}
4177
4178/**
4179 * iw_get_range() - SSR wrapper for __iw_get_range()
4180 * @dev: pointer to net_device
4181 * @info: pointer to iw_request_info
4182 * @wrqu: pointer to iwreq_data
4183 * @extra: pointer to extra ioctl payload
4184 *
4185 * Return: 0 on success, error number otherwise
4186 */
4187static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
4188 union iwreq_data *wrqu, char *extra)
4189{
4190 int ret;
4191
4192 cds_ssr_protect(__func__);
4193 ret = __iw_get_range(dev, info, wrqu, extra);
4194 cds_ssr_unprotect(__func__);
4195
4196 return ret;
4197}
4198
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004199struct class_a_stats {
4200 tCsrGlobalClassAStatsInfo class_a_stats;
4201};
4202
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203/**
4204 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004205 * @stats: pointer to Class A stats
4206 * @context: user context originally registered with SME (always the
4207 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 *
4209 * Return: None
4210 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004211static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004213 struct hdd_request *request;
4214 struct class_a_stats *priv;
4215 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004217 ENTER();
4218 if ((NULL == stats) || (NULL == context)) {
4219 hdd_err("Bad param, stats [%p] context [%p]",
4220 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221 return;
4222 }
4223
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004224 request = hdd_request_get(context);
4225 if (!request) {
4226 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 return;
4228 }
4229
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004230 returned_stats = stats;
4231 priv = hdd_request_priv(request);
4232 priv->class_a_stats = *returned_stats;
4233 hdd_request_complete(request);
4234 hdd_request_put(request);
4235 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236}
4237
4238/**
4239 * wlan_hdd_get_class_astats() - Get Class A statistics
4240 * @pAdapter: adapter for which statistics are desired
4241 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304242 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304244QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245{
4246 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304247 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004248 int ret;
4249 void *cookie;
4250 struct hdd_request *request;
4251 struct class_a_stats *priv;
4252 static const struct hdd_request_params params = {
4253 .priv_size = sizeof(*priv),
4254 .timeout_ms = WLAN_WAIT_TIME_STATS,
4255 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256
4257 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004258 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304259 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08004261 if (cds_is_driver_recovering()) {
4262 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
4263 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304264 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 }
4266
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004267 request = hdd_request_alloc(&params);
4268 if (!request) {
4269 hdd_err("Request allocation failure");
4270 return QDF_STATUS_E_NOMEM;
4271 }
4272 cookie = hdd_request_cookie(request);
4273
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 /* query only for Class A statistics (which include link speed) */
4275 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4276 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
4277 hdd_get_class_a_statistics_cb,
4278 0, /* not periodic */
4279 false, /* non-cached results */
4280 pHddStaCtx->conn_info.staId[0],
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004281 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304282 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07004283 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004284 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004285 }
4286
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004287 /* request was sent -- wait for the response */
4288 ret = hdd_request_wait_for_response(request);
4289 if (ret) {
4290 hdd_warn("SME timed out while retrieving Class A statistics");
4291 goto return_cached_results;
4292 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004294 /* update the adapter with the fresh results */
4295 priv = hdd_request_priv(request);
4296 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
4297
4298return_cached_results:
4299 /*
4300 * either we never sent a request, we sent a request and
4301 * received a response or we sent a request and timed out.
4302 * regardless we are done with the request.
4303 */
4304 hdd_request_put(request);
4305
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304306 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307}
4308
Jeff Johnsondda167c2017-01-23 10:37:57 -08004309struct station_stats {
4310 tCsrSummaryStatsInfo summary_stats;
4311 tCsrGlobalClassAStatsInfo class_a_stats;
4312 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
4313};
4314
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315/**
4316 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08004317 * @stats: pointer to combined station stats
4318 * @context: user context originally registered with SME (always the
4319 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 *
4321 * Return: None
4322 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004323static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324{
Jeff Johnsondda167c2017-01-23 10:37:57 -08004325 struct hdd_request *request;
4326 struct station_stats *priv;
4327 tCsrSummaryStatsInfo *summary_stats;
4328 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304329 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004330
Jeff Johnsondda167c2017-01-23 10:37:57 -08004331 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004332 hdd_err("Bad param, pStats [%p] pContext [%p]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08004333 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004334 return;
4335 }
4336
Jeff Johnsondda167c2017-01-23 10:37:57 -08004337 request = hdd_request_get(context);
4338 if (!request) {
4339 hdd_err("Obsolete request");
4340 return;
4341 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342
Jeff Johnsondda167c2017-01-23 10:37:57 -08004343 summary_stats = (tCsrSummaryStatsInfo *) stats;
4344 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304345 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08004346 (class_a_stats + 1);
4347 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348
4349 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004350 priv->summary_stats = *summary_stats;
4351 priv->class_a_stats = *class_a_stats;
4352 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353
Jeff Johnsondda167c2017-01-23 10:37:57 -08004354 hdd_request_complete(request);
4355 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004356}
4357
4358/**
4359 * wlan_hdd_get_station_stats() - Get station statistics
4360 * @pAdapter: adapter for which statistics are desired
4361 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304362 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304364QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365{
4366 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304367 QDF_STATUS hstatus;
Jeff Johnsondda167c2017-01-23 10:37:57 -08004368 int ret;
4369 void *cookie;
4370 struct hdd_request *request;
4371 struct station_stats *priv;
4372 static const struct hdd_request_params params = {
4373 .priv_size = sizeof(*priv),
4374 .timeout_ms = WLAN_WAIT_TIME_STATS,
4375 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376
4377 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004378 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304379 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 }
4381
Jeff Johnsondda167c2017-01-23 10:37:57 -08004382 request = hdd_request_alloc(&params);
4383 if (!request) {
4384 hdd_err("Request allocation failure");
4385 return QDF_STATUS_E_NOMEM;
4386 }
4387 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388
4389 /* query only for Summary & Class A statistics */
4390 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4391 eCSR_HDD,
4392 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304393 SME_GLOBAL_CLASSA_STATS |
4394 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 hdd_get_station_statistics_cb,
4396 0, /* not periodic */
4397 false, /* non-cached results */
4398 pHddStaCtx->conn_info.staId[0],
Jeff Johnsondda167c2017-01-23 10:37:57 -08004399 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304400 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004401 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402 /* we'll return with cached values */
4403 } else {
4404 /* request was sent -- wait for the response */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004405 ret = hdd_request_wait_for_response(request);
4406 if (ret) {
4407 hdd_warn("SME timed out while retrieving statistics");
4408 /* we'll returned a cached value below */
4409 } else {
4410 /* update the adapter with the fresh results */
4411 priv = hdd_request_priv(request);
4412 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
4413 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
4414 pAdapter->hdd_stats.per_chain_rssi_stats =
4415 priv->per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 }
4417 }
4418
Jeff Johnsondda167c2017-01-23 10:37:57 -08004419 /*
4420 * either we never sent a request, we sent a request and
4421 * received a response or we sent a request and timed out.
4422 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004424 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425
4426 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304427 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428}
4429
4430/**
4431 * iw_get_linkspeed() - Get current link speed ioctl
4432 * @dev: device upon which the ioctl was received
4433 * @info: ioctl request information
4434 * @wrqu: ioctl request data
4435 * @extra: extra ioctl buffer
4436 *
4437 * Return: 0 on success, non-zero on error
4438 */
4439static int __iw_get_linkspeed(struct net_device *dev,
4440 struct iw_request_info *info,
4441 union iwreq_data *wrqu, char *extra)
4442{
4443 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4444 char *pLinkSpeed = (char *)extra;
4445 int len = sizeof(uint32_t) + 1;
4446 uint32_t link_speed = 0;
4447 hdd_context_t *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08004448 int ret;
4449 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08004451 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05304452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08004454 ret = wlan_hdd_validate_context(hdd_ctx);
4455 if (0 != ret)
4456 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457
Jeff Johnson441e1f72017-02-07 08:50:49 -08004458 ret = hdd_check_private_wext_control(hdd_ctx, info);
4459 if (0 != ret)
4460 return ret;
4461
4462 ret = wlan_hdd_get_link_speed(pAdapter, &link_speed);
4463 if (0 != ret) {
4464 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 }
4466
4467 wrqu->data.length = len;
4468 /* return the linkspeed as a string */
4469 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
4470 if ((rc < 0) || (rc >= len)) {
4471 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07004472 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 return -EIO;
4474 }
4475
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05304476 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 /* a value is being successfully returned */
4478 return 0;
4479}
4480
4481static int iw_get_linkspeed(struct net_device *dev,
4482 struct iw_request_info *info,
4483 union iwreq_data *wrqu, char *extra)
4484{
4485 int ret;
4486
4487 cds_ssr_protect(__func__);
4488 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
4489 cds_ssr_unprotect(__func__);
4490
4491 return ret;
4492}
4493
4494/**
4495 * wlan_hdd_change_country_code_callback() - Change country code callback
4496 * @context: opaque context originally passed to SME. All functions
4497 * which use this callback pass the adapter upon which the country
4498 * code change is active
4499 *
4500 * This function is registered as the callback function when
4501 * sme_change_country_code() is invoked. Callers of
4502 * sme_change_country_code() subsequently wait for the adapter's
4503 * @change_country_code completion variable, so all this function
4504 * needs to do is set that completion variable so that execution can
4505 * continue.
4506 *
4507 * Return: none
4508 */
4509void wlan_hdd_change_country_code_callback(void *context)
4510{
4511
4512 hdd_adapter_t *adapter = context;
4513
4514 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
4515 complete(&adapter->change_country_code);
4516
4517 return;
4518}
4519
4520/**
4521 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
4522 * @dev: device upon which the ioctl was received
4523 * @info: ioctl request information
4524 * @wrqu: ioctl request data
4525 * @extra: ioctl extra data
4526 *
4527 * Return: 0 on success, non-zero on error
4528 */
4529static int __iw_set_nick(struct net_device *dev,
4530 struct iw_request_info *info,
4531 union iwreq_data *wrqu, char *extra)
4532{
4533 hdd_adapter_t *adapter;
4534 hdd_context_t *hdd_ctx;
4535 int ret;
4536
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004537 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538
4539 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4540 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4541 ret = wlan_hdd_validate_context(hdd_ctx);
4542 if (0 != ret)
4543 return ret;
4544
Jeff Johnson441e1f72017-02-07 08:50:49 -08004545 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4546 if (0 != ret)
4547 return ret;
4548
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 return 0;
4550}
4551
4552/**
4553 * iw_set_nick() - SSR wrapper for __iw_set_nick
4554 * @dev: pointer to net_device
4555 * @info: pointer to iw_request_info
4556 * @wrqu: pointer to iwreq_data
4557 * @extra: extra
4558 *
4559 * Return: 0 on success, error number otherwise
4560 */
4561static int iw_set_nick(struct net_device *dev,
4562 struct iw_request_info *info,
4563 union iwreq_data *wrqu, char *extra)
4564{
4565 int ret;
4566
4567 cds_ssr_protect(__func__);
4568 ret = __iw_set_nick(dev, info, wrqu, extra);
4569 cds_ssr_unprotect(__func__);
4570
4571 return ret;
4572}
4573
4574/**
4575 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
4576 * @dev: device upon which the ioctl was received
4577 * @info: ioctl request information
4578 * @wrqu: ioctl request data
4579 * @extra: ioctl extra data
4580 *
4581 * Return: 0 on success, non-zero on error
4582 */
4583static int __iw_get_nick(struct net_device *dev,
4584 struct iw_request_info *info,
4585 union iwreq_data *wrqu, char *extra)
4586{
4587 hdd_adapter_t *adapter;
4588 hdd_context_t *hdd_ctx;
4589 int ret;
4590
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004591 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592
4593 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4594 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4595 ret = wlan_hdd_validate_context(hdd_ctx);
4596 if (0 != ret)
4597 return ret;
4598
Jeff Johnson441e1f72017-02-07 08:50:49 -08004599 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4600 if (0 != ret)
4601 return ret;
4602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603 return 0;
4604}
4605
4606/**
4607 * iw_get_nick() - SSR wrapper for __iw_get_nick
4608 * @dev: pointer to net_device
4609 * @info: pointer to iw_request_info
4610 * @wrqu: pointer to iwreq_data
4611 * @extra: extra
4612 *
4613 * Return: 0 on success, error number otherwise
4614 */
4615static int iw_get_nick(struct net_device *dev,
4616 struct iw_request_info *info,
4617 union iwreq_data *wrqu, char *extra)
4618{
4619 int ret;
4620
4621 cds_ssr_protect(__func__);
4622 ret = __iw_get_nick(dev, info, wrqu, extra);
4623 cds_ssr_unprotect(__func__);
4624
4625 return ret;
4626}
4627
4628/**
4629 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
4630 * @dev: device upon which the ioctl was received
4631 * @info: ioctl request information
4632 * @wrqu: ioctl request data
4633 * @extra: ioctl extra data
4634 *
4635 * Return: 0 on success, non-zero on error
4636 */
4637static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4638 union iwreq_data *wrqu, char *extra)
4639{
4640 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4641 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4642 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4643 hdd_context_t *hdd_ctx;
4644 struct iw_point *encoderq = &(wrqu->encoding);
4645 uint32_t keyId;
4646 uint8_t key_length;
4647 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4648 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304649 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 int ret;
4651
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004652 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653
4654 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4655 ret = wlan_hdd_validate_context(hdd_ctx);
4656 if (0 != ret)
4657 return ret;
4658
Jeff Johnson441e1f72017-02-07 08:50:49 -08004659 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4660 if (0 != ret)
4661 return ret;
4662
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663 keyId = encoderq->flags & IW_ENCODE_INDEX;
4664
4665 if (keyId) {
4666 if (keyId > MAX_WEP_KEYS) {
4667 return -EINVAL;
4668 }
4669
4670 fKeyPresent = 1;
4671 keyId--;
4672 } else {
4673 fKeyPresent = 0;
4674 }
4675
4676 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004677 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08004679 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
4680 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 }
4682 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4683 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4684 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4685 eCSR_ENCRYPT_TYPE_NONE;
4686 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4687 eCSR_ENCRYPT_TYPE_NONE;
4688
4689 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4690 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4691
4692 if (eConnectionState_Associated ==
4693 pHddStaCtx->conn_info.connState) {
4694 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4695 status =
4696 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4697 pAdapter->sessionId,
4698 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304699 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 unsigned long rc;
4701 rc = wait_for_completion_timeout(&pAdapter->
4702 disconnect_comp_var,
4703 msecs_to_jiffies
4704 (WLAN_WAIT_TIME_DISCONNECT));
4705 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004706 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 }
4708 }
4709
4710 return status;
4711
4712 }
4713
4714 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004715 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716
4717 pHddStaCtx->conn_info.authType =
4718 (encoderq->
4719 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
4720 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4721
4722 }
4723
4724 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004725 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726
4727 key_length = wrqu->data.length;
4728
4729 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
4730
4731 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004732 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004733 key_length);
4734
4735 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4736 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4737 pHddStaCtx->conn_info.authType)) {
4738 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4739 } else {
4740 encryptionType =
4741 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4742 }
4743 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004744 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 key_length);
4746
4747 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4748 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4749 pHddStaCtx->conn_info.authType)) {
4750 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4751 } else {
4752 encryptionType =
4753 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4754 }
4755 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004756 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757 key_length);
4758 return -EINVAL;
4759 }
4760
4761 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4762 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4763 pWextState->roamProfile.EncryptionType.numEntries = 1;
4764 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4765 encryptionType;
4766 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4767 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4768 encryptionType;
4769
4770 if ((eConnectionState_NotConnected ==
4771 pHddStaCtx->conn_info.connState)
4772 &&
4773 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4774 pHddStaCtx->conn_info.authType)
4775 || (eCSR_AUTH_TYPE_SHARED_KEY ==
4776 pHddStaCtx->conn_info.authType))) {
4777
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304778 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 KeyMaterial[keyId][0], extra, key_length);
4780
4781 pWextState->roamProfile.Keys.KeyLength[keyId] =
4782 (uint8_t) key_length;
4783 pWextState->roamProfile.Keys.defaultIndex =
4784 (uint8_t) keyId;
4785
4786 return status;
4787 }
4788 }
4789
4790 return 0;
4791}
4792
4793/**
4794 * iw_set_encode() - SSR wrapper for __iw_set_encode()
4795 * @dev: pointer to net_device
4796 * @info: pointer to iw_request_info
4797 * @wrqu: pointer to iwreq_data
4798 * @extra: pointer to extra ioctl payload
4799 *
4800 * Return: 0 on success, error number otherwise
4801 */
4802static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4803 union iwreq_data *wrqu, char *extra)
4804{
4805 int ret;
4806
4807 cds_ssr_protect(__func__);
4808 ret = __iw_set_encode(dev, info, wrqu, extra);
4809 cds_ssr_unprotect(__func__);
4810
4811 return ret;
4812}
4813
4814/**
4815 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
4816 * @dev: device upon which the ioctl was received
4817 * @info: ioctl request information
4818 * @wrqu: ioctl request data
4819 * @extra: ioctl extra data
4820 *
4821 * Return: 0 on success, non-zero on error
4822 */
4823static int __iw_get_encodeext(struct net_device *dev,
4824 struct iw_request_info *info,
4825 struct iw_point *dwrq, char *extra)
4826{
4827 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4828 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4829 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4830 int keyId;
4831 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4832 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4833 int i, ret;
4834 hdd_context_t *hdd_ctx;
4835
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004836 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837
4838 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4839 ret = wlan_hdd_validate_context(hdd_ctx);
4840 if (0 != ret)
4841 return ret;
4842
Jeff Johnson441e1f72017-02-07 08:50:49 -08004843 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4844 if (0 != ret)
4845 return ret;
4846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847 keyId = pRoamProfile->Keys.defaultIndex;
4848
4849 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004850 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851 return -EINVAL;
4852 }
4853
4854 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
4855 dwrq->flags |= IW_ENCODE_ENABLED;
4856 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304857 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858 pRoamProfile->Keys.KeyLength[keyId]);
4859 } else {
4860 dwrq->flags |= IW_ENCODE_DISABLED;
4861 }
4862
4863 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08004864 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004865 continue;
4866 } else {
4867 break;
4868 }
4869 }
4870
4871 if (MAX_WEP_KEYS == i) {
4872 dwrq->flags |= IW_ENCODE_NOKEY;
4873 } else {
4874 dwrq->flags |= IW_ENCODE_ENABLED;
4875 }
4876
4877 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4878
4879 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
4880 dwrq->flags |= IW_ENCODE_DISABLED;
4881 }
4882
4883 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4884
4885 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
4886 dwrq->flags |= IW_ENCODE_OPEN;
4887 } else {
4888 dwrq->flags |= IW_ENCODE_RESTRICTED;
4889 }
4890 EXIT();
4891 return 0;
4892
4893}
4894
4895/**
4896 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
4897 * @dev: pointer to net_device
4898 * @info: pointer to iw_request_info
4899 * @dwrq: pointer to encoding information
4900 * @extra: pointer to extra ioctl payload
4901 *
4902 * Return: 0 on success, error number otherwise
4903 */
4904static int iw_get_encodeext(struct net_device *dev,
4905 struct iw_request_info *info,
4906 struct iw_point *dwrq, char *extra)
4907{
4908 int ret;
4909
4910 cds_ssr_protect(__func__);
4911 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4912 cds_ssr_unprotect(__func__);
4913
4914 return ret;
4915}
4916
4917/**
4918 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
4919 * @dev: device upon which the ioctl was received
4920 * @info: ioctl request information
4921 * @wrqu: ioctl request data
4922 * @extra: ioctl extra data
4923 *
4924 * Return: 0 on success, non-zero on error
4925 */
4926static int __iw_set_encodeext(struct net_device *dev,
4927 struct iw_request_info *info,
4928 union iwreq_data *wrqu, char *extra)
4929{
4930 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4931 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4932 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4933 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304934 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004935 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4936 int ret;
4937 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4938 int key_index;
4939 struct iw_point *encoding = &wrqu->encoding;
4940 tCsrRoamSetKey setKey;
4941 uint32_t roamId = 0xFF;
4942
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004943 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944
4945 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4946 ret = wlan_hdd_validate_context(hdd_ctx);
4947 if (0 != ret)
4948 return ret;
4949
Jeff Johnson441e1f72017-02-07 08:50:49 -08004950 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4951 if (0 != ret)
4952 return ret;
4953
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004954 key_index = encoding->flags & IW_ENCODE_INDEX;
4955
4956 if (key_index > 0) {
4957
4958 /*Convert from 1-based to 0-based keying */
4959 key_index--;
4960 }
4961 if (!ext->key_len) {
4962
4963 /*Set the encrytion type to NONE */
4964 pRoamProfile->EncryptionType.encryptionType[0] =
4965 eCSR_ENCRYPT_TYPE_NONE;
4966 return ret;
4967 }
4968
4969 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4970 (IW_ENCODE_ALG_WEP == ext->alg)) {
4971 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4972
Jeff Johnson99bac312016-06-28 10:38:18 -07004973 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974 return -EINVAL;
Jeff Johnson68755312017-02-10 11:46:55 -08004975 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976
Jeff Johnson68755312017-02-10 11:46:55 -08004977 /*Static wep, update the roam profile with the keys */
4978 if (ext->key_len &&
4979 (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
4980 key_index < CSR_MAX_NUM_KEY) {
4981 qdf_mem_copy(&pRoamProfile->Keys.
4982 KeyMaterial[key_index][0],
4983 ext->key, ext->key_len);
4984 pRoamProfile->Keys.KeyLength[key_index] =
4985 (uint8_t) ext->key_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004986
Jeff Johnson68755312017-02-10 11:46:55 -08004987 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4988 pRoamProfile->Keys.defaultIndex =
4989 (uint8_t) key_index;
4990
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004991 }
4992 return ret;
4993 }
4994
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304995 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004996
4997 setKey.keyId = key_index;
4998 setKey.keyLength = ext->key_len;
4999
5000 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305001 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005002 }
5003
5004 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
5005 /*Key direction for group is RX only */
5006 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05305007 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005008 } else {
5009
5010 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305011 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305012 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013 }
5014
5015 /*For supplicant pae role is zero */
5016 setKey.paeRole = 0;
5017
5018 switch (ext->alg) {
5019 case IW_ENCODE_ALG_NONE:
5020 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5021 break;
5022
5023 case IW_ENCODE_ALG_WEP:
5024 setKey.encType =
5025 (ext->key_len ==
5026 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
5027 break;
5028
5029 case IW_ENCODE_ALG_TKIP:
5030 {
5031 uint8_t *pKey = &setKey.Key[0];
5032
5033 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5034
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305035 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036
5037 /* Supplicant sends the 32bytes key in this order
5038 * |--------------|----------|----------|
5039 * | Tk1 | TX MIC | RX MIC |
5040 * |--------------|----------|----------|
5041 * <---16bytes---><--8bytes--><--8bytes-->
5042 *
5043 *
5044 * Sme expects the 32 bytes key to be in the below order
5045 * |--------------|----------|----------|
5046 * | Tk1 | RX MIC | TX MIC |
5047 * |--------------|----------|----------|
5048 * <---16bytes---><--8bytes--><--8bytes-->
5049 */
5050
5051 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305052 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005053
5054 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305055 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005056
5057 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305058 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005059
5060 }
5061 break;
5062
5063 case IW_ENCODE_ALG_CCMP:
5064 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5065 break;
5066
5067#ifdef FEATURE_WLAN_ESE
5068#define IW_ENCODE_ALG_KRK 6
5069 case IW_ENCODE_ALG_KRK:
5070 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5071 break;
5072#endif /* FEATURE_WLAN_ESE */
5073
5074 default:
5075 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5076 break;
5077 }
5078
Jeff Johnson99bac312016-06-28 10:38:18 -07005079 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
5080 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082 /* The supplicant may attempt to set the PTK once
5083 * pre-authentication is done. Save the key in the UMAC and
5084 * include it in the ADD BSS request
5085 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305086 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305088 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005089 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005090 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305091 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005092 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 return -EINVAL;
5094 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005095
5096 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5097
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305098 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 pAdapter->sessionId,
5100 &setKey, &roamId);
5101
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305102 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005103 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305104 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105
5106 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5107 }
5108
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305109 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005110}
5111
5112/**
5113 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
5114 * @dev: pointer to net_device
5115 * @info: pointer to iw_request_info
5116 * @wrqu: pointer to iwreq_data
5117 * @extra: pointer to extra ioctl payload
5118 *
5119 * Return: 0 on success, error number otherwise
5120 */
5121static int iw_set_encodeext(struct net_device *dev,
5122 struct iw_request_info *info,
5123 union iwreq_data *wrqu, char *extra)
5124{
5125 int ret;
5126
5127 cds_ssr_protect(__func__);
5128 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5129 cds_ssr_unprotect(__func__);
5130
5131 return ret;
5132}
5133
5134/**
5135 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
5136 * @dev: device upon which the ioctl was received
5137 * @info: ioctl request information
5138 * @wrqu: ioctl request data
5139 * @extra: ioctl extra data
5140 *
5141 * Return: 0 on success, non-zero on error
5142 */
5143static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
5144 union iwreq_data *wrqu, char *extra)
5145{
5146 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5147 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5148 hdd_context_t *hdd_ctx;
5149 int ret;
5150
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005151 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005152
5153 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5154 ret = wlan_hdd_validate_context(hdd_ctx);
5155 if (0 != ret)
5156 return ret;
5157
Jeff Johnson441e1f72017-02-07 08:50:49 -08005158 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5159 if (0 != ret)
5160 return ret;
5161
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5163 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5164
Jeff Johnson99bac312016-06-28 10:38:18 -07005165 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166
5167 return -EINVAL;
5168 }
5169
5170 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
5171
5172 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
5173 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
5174 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305175 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005176 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005177 return -EIO;
5178 }
5179 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
5180 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
5181 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305182 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05305183 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184 return -EIO;
5185 }
5186 }
5187 } else {
5188 return -EOPNOTSUPP;
5189 }
5190
Jeff Johnson99bac312016-06-28 10:38:18 -07005191 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192
5193 EXIT();
5194
5195 return 0;
5196
5197}
5198
5199/**
5200 * iw_set_retry() - SSR wrapper for __iw_set_retry()
5201 * @dev: pointer to net_device
5202 * @info: pointer to iw_request_info
5203 * @wrqu: pointer to iwreq_data
5204 * @extra: pointer to extra ioctl payload
5205 *
5206 * Return: 0 on success, error number otherwise
5207 */
5208static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
5209 union iwreq_data *wrqu, char *extra)
5210{
5211 int ret;
5212
5213 cds_ssr_protect(__func__);
5214 ret = __iw_set_retry(dev, info, wrqu, extra);
5215 cds_ssr_unprotect(__func__);
5216
5217 return ret;
5218}
5219
5220/**
5221 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
5222 * @dev: device upon which the ioctl was received
5223 * @info: ioctl request information
5224 * @wrqu: ioctl request data
5225 * @extra: ioctl extra data
5226 *
5227 * Return: 0 on success, non-zero on error
5228 */
5229static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
5230 union iwreq_data *wrqu, char *extra)
5231{
5232 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5233 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5234 uint32_t retry = 0;
5235 hdd_context_t *hdd_ctx;
5236 int ret;
5237
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005238 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239
5240 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5241 ret = wlan_hdd_validate_context(hdd_ctx);
5242 if (0 != ret)
5243 return ret;
5244
Jeff Johnson441e1f72017-02-07 08:50:49 -08005245 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5246 if (0 != ret)
5247 return ret;
5248
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
5250 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5251
5252 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305253 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005254 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 return -EIO;
5256 }
5257
5258 wrqu->retry.value = retry;
5259 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
5260 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5261
5262 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305263 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05305264 hdd_warn("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005265 return -EIO;
5266 }
5267
5268 wrqu->retry.value = retry;
5269 } else {
5270 return -EOPNOTSUPP;
5271 }
5272
Jeff Johnson99bac312016-06-28 10:38:18 -07005273 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005274
5275 EXIT();
5276
5277 return 0;
5278}
5279
5280/**
5281 * iw_get_retry() - SSR wrapper for __iw_get_retry()
5282 * @dev: pointer to net_device
5283 * @info: pointer to iw_request_info
5284 * @wrqu: pointer to iwreq_data
5285 * @extra: pointer to extra ioctl payload
5286 *
5287 * Return: 0 on success, error number otherwise
5288 */
5289static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
5290 union iwreq_data *wrqu, char *extra)
5291{
5292 int ret;
5293
5294 cds_ssr_protect(__func__);
5295 ret = __iw_get_retry(dev, info, wrqu, extra);
5296 cds_ssr_unprotect(__func__);
5297
5298 return ret;
5299}
5300
5301/**
5302 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
5303 * @dev: device upon which the ioctl was received
5304 * @info: ioctl request information
5305 * @wrqu: ioctl request data
5306 * @extra: ioctl extra data
5307 *
5308 * Return: 0 on success, non-zero on error
5309 */
5310static int __iw_set_mlme(struct net_device *dev,
5311 struct iw_request_info *info,
5312 union iwreq_data *wrqu, char *extra)
5313{
5314 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5315 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5316 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305317 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318 hdd_context_t *hdd_ctx;
5319 int ret;
5320
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005321 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322
5323 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5324 ret = wlan_hdd_validate_context(hdd_ctx);
5325 if (0 != ret)
5326 return ret;
5327
Jeff Johnson441e1f72017-02-07 08:50:49 -08005328 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5329 if (0 != ret)
5330 return ret;
5331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332 /* reason_code is unused. By default it is set to
5333 * eCSR_DISCONNECT_REASON_UNSPECIFIED
5334 */
5335 switch (mlme->cmd) {
5336 case IW_MLME_DISASSOC:
5337 case IW_MLME_DEAUTH:
5338
5339 if (pHddStaCtx->conn_info.connState ==
5340 eConnectionState_Associated) {
5341 eCsrRoamDisconnectReason reason =
5342 eCSR_DISCONNECT_REASON_UNSPECIFIED;
5343
5344 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
5345 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5346
5347 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5348 status =
5349 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
5350 pAdapter->sessionId, reason);
5351
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305352 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 unsigned long rc;
5354 rc = wait_for_completion_timeout(&pAdapter->
5355 disconnect_comp_var,
5356 msecs_to_jiffies
5357 (WLAN_WAIT_TIME_DISCONNECT));
5358 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07005359 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07005361 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
5362 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005363
5364 /* Resetting authKeyMgmt */
5365 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
5366 0;
5367
Jeff Johnson99bac312016-06-28 10:38:18 -07005368 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005369 wlan_hdd_netif_queue_control(pAdapter,
5370 WLAN_NETIF_TX_DISABLE_N_CARRIER,
5371 WLAN_CONTROL_PATH);
5372
5373 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07005374 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
5375 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376 }
5377 break;
5378 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005379 hdd_err("%d Command should be Disassociate/Deauthenticate",
5380 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381 return -EINVAL;
5382 } /* end of switch */
5383
5384 EXIT();
5385
5386 return status;
5387
5388}
5389
5390/**
5391 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
5392 * @dev: pointer to net_device
5393 * @info: pointer to iw_request_info
5394 * @wrqu: pointer to iwreq_data
5395 * @extra: pointer to extra ioctl payload
5396 *
5397 * Return: 0 on success, error number otherwise
5398 */
5399static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
5400 union iwreq_data *wrqu, char *extra)
5401{
5402 int ret;
5403
5404 cds_ssr_protect(__func__);
5405 ret = __iw_set_mlme(dev, info, wrqu, extra);
5406 cds_ssr_unprotect(__func__);
5407
5408 return ret;
5409}
5410
5411/**
5412 * wlan_hdd_update_phymode() - handle change in PHY mode
5413 * @net: device upon which PHY mode change was received
5414 * @hal: umac handle for the driver
5415 * @new_phymode: new PHY mode for the device
5416 * @phddctx: pointer to the HDD context
5417 *
5418 * This function is called when the device is set to a new PHY mode.
5419 * It takes a holistic look at the desired PHY mode along with the
5420 * configured capabilities of the driver and the reported capabilities
5421 * of the hardware in order to correctly configure all PHY-related
5422 * parameters.
5423 *
5424 * Return: 0 on success, negative errno value on error
5425 */
5426int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
5427 int new_phymode, hdd_context_t *phddctx)
5428{
5429#ifdef QCA_HT_2040_COEX
5430 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305431 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432#endif
5433 bool band_24 = false, band_5g = false;
5434 bool ch_bond24 = false, ch_bond5g = false;
5435 tSmeConfigParams smeconfig;
5436 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005437 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 eCsrPhyMode phymode = -EIO, old_phymode;
5439 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
5440 eCsrBand curr_band = eCSR_BAND_ALL;
5441
5442 old_phymode = sme_get_phy_mode(hal);
5443
5444 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5445 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5446 nChannelBondingMode24GHz))
5447 ch_bond24 = true;
5448
5449 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5450 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5451 nChannelBondingMode5GHz))
5452 ch_bond5g = true;
5453
5454 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
5455 band_24 = band_5g = true;
5456 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
5457 band_24 = true;
5458 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
5459 band_5g = true;
5460 }
5461
5462 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07005463 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 -08005464 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
5465
5466 switch (new_phymode) {
5467 case IEEE80211_MODE_AUTO:
5468 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
5469 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
5470 phymode = eCSR_DOT11_MODE_AUTO;
5471 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5472 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5473 curr_band = eCSR_BAND_ALL;
5474 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5475 } else {
5476 sme_set_phy_mode(hal, old_phymode);
5477 return -EIO;
5478 }
5479 break;
5480 case IEEE80211_MODE_11A:
5481 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
5482 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5483 phymode = eCSR_DOT11_MODE_11a;
5484 hdd_dot11mode = eHDD_DOT11_MODE_11a;
5485 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5486 curr_band = eCSR_BAND_5G;
5487 } else {
5488 sme_set_phy_mode(hal, old_phymode);
5489 return -EIO;
5490 }
5491 break;
5492 case IEEE80211_MODE_11B:
5493 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
5494 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5495 phymode = eCSR_DOT11_MODE_11b;
5496 hdd_dot11mode = eHDD_DOT11_MODE_11b;
5497 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5498 curr_band = eCSR_BAND_24;
5499 } else {
5500 sme_set_phy_mode(hal, old_phymode);
5501 return -EIO;
5502 }
5503 break;
5504 case IEEE80211_MODE_11G:
5505 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
5506 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5507 phymode = eCSR_DOT11_MODE_11g;
5508 hdd_dot11mode = eHDD_DOT11_MODE_11g;
5509 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5510 curr_band = eCSR_BAND_24;
5511 } else {
5512 sme_set_phy_mode(hal, old_phymode);
5513 return -EIO;
5514 }
5515 break;
5516 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
5517 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
5518 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
5519 */
5520 case IEEE80211_MODE_11NA_HT20:
5521 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5522 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5523 phymode = eCSR_DOT11_MODE_11n;
5524 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5525 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5526 curr_band = eCSR_BAND_5G;
5527 } else {
5528 sme_set_phy_mode(hal, old_phymode);
5529 return -EIO;
5530 }
5531 break;
5532 case IEEE80211_MODE_11NA_HT40:
5533 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5534 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5535 phymode = eCSR_DOT11_MODE_11n;
5536 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5537 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5538 curr_band = eCSR_BAND_5G;
5539 } else {
5540 sme_set_phy_mode(hal, old_phymode);
5541 return -EIO;
5542 }
5543 break;
5544 case IEEE80211_MODE_11NG_HT20:
5545 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5546 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5547 phymode = eCSR_DOT11_MODE_11n;
5548 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5549 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5550 curr_band = eCSR_BAND_24;
5551 } else {
5552 sme_set_phy_mode(hal, old_phymode);
5553 return -EIO;
5554 }
5555 break;
5556 case IEEE80211_MODE_11NG_HT40:
5557 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5558 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5559 phymode = eCSR_DOT11_MODE_11n;
5560 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5561 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5562 curr_band = eCSR_BAND_24;
5563 } else {
5564 sme_set_phy_mode(hal, old_phymode);
5565 return -EIO;
5566 }
5567 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 case IEEE80211_MODE_11AC_VHT20:
5569 case IEEE80211_MODE_11AC_VHT40:
5570 case IEEE80211_MODE_11AC_VHT80:
5571 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
5572 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5573 phymode = eCSR_DOT11_MODE_11ac;
5574 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
5575 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5576 curr_band = eCSR_BAND_5G;
5577 } else {
5578 sme_set_phy_mode(hal, old_phymode);
5579 return -EIO;
5580 }
5581 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 case IEEE80211_MODE_2G_AUTO:
5583 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
5584 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5585 phymode = eCSR_DOT11_MODE_AUTO;
5586 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5587 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5588 curr_band = eCSR_BAND_24;
5589 } else {
5590 sme_set_phy_mode(hal, old_phymode);
5591 return -EIO;
5592 }
5593 break;
5594 case IEEE80211_MODE_5G_AUTO:
5595 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
5596 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5597 phymode = eCSR_DOT11_MODE_AUTO;
5598 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5599 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5600 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5601 curr_band = eCSR_BAND_5G;
5602 } else {
5603 sme_set_phy_mode(hal, old_phymode);
5604 return -EIO;
5605 }
5606 break;
5607 case IEEE80211_MODE_11AGN:
5608 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5609 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
5610 phymode = eCSR_DOT11_MODE_11n;
5611 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5612 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5613 curr_band = eCSR_BAND_ALL;
5614 } else {
5615 sme_set_phy_mode(hal, old_phymode);
5616 return -EIO;
5617 }
5618 break;
5619 default:
5620 return -EIO;
5621 }
5622
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 switch (new_phymode) {
5624 case IEEE80211_MODE_11AC_VHT20:
5625 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5626 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5627 break;
5628 case IEEE80211_MODE_11AC_VHT40:
5629 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5630 break;
5631 case IEEE80211_MODE_11AC_VHT80:
5632 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5633 break;
5634 default:
5635 vhtchanwidth = phddctx->config->vhtChannelWidth;
5636 break;
5637 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005638
5639 if (phymode != -EIO) {
5640 sme_get_config_param(hal, &smeconfig);
5641 smeconfig.csrConfig.phyMode = phymode;
5642#ifdef QCA_HT_2040_COEX
5643 if (phymode == eCSR_DOT11_MODE_11n &&
5644 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
5645 smeconfig.csrConfig.obssEnabled = false;
5646 halStatus = sme_set_ht2040_mode(hal,
5647 pAdapter->sessionId,
5648 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305649 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005650 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651 return -EIO;
5652 }
5653 } else if (phymode == eCSR_DOT11_MODE_11n &&
5654 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
5655 smeconfig.csrConfig.obssEnabled = true;
5656 halStatus = sme_set_ht2040_mode(hal,
5657 pAdapter->sessionId,
5658 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305659 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005660 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 return -EIO;
5662 }
5663 }
5664#endif
5665 smeconfig.csrConfig.eBand = curr_band;
5666 smeconfig.csrConfig.bandCapability = curr_band;
5667 if (curr_band == eCSR_BAND_24)
5668 smeconfig.csrConfig.Is11hSupportEnabled = 0;
5669 else
5670 smeconfig.csrConfig.Is11hSupportEnabled =
5671 phddctx->config->Is11hSupportEnabled;
5672 if (curr_band == eCSR_BAND_24)
5673 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5674 else if (curr_band == eCSR_BAND_24)
5675 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5676 else {
5677 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5678 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5679 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005681 sme_update_config(hal, &smeconfig);
5682
5683 phddctx->config->dot11Mode = hdd_dot11mode;
5684 phddctx->config->nBandCapability = curr_band;
5685 phddctx->config->nChannelBondingMode24GHz =
5686 smeconfig.csrConfig.channelBondingMode24GHz;
5687 phddctx->config->nChannelBondingMode5GHz =
5688 smeconfig.csrConfig.channelBondingMode5GHz;
5689 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005690 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005691 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 return -EIO;
5693 }
5694 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07005695 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5697 else
Dustin Browna30892e2016-10-12 17:28:36 -07005698 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005699 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5700
Jeff Johnson99bac312016-06-28 10:38:18 -07005701 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 phymode, chwidth, curr_band, vhtchanwidth);
5703 }
5704
5705 return 0;
5706}
5707
5708/**
5709 * hdd_get_temperature_cb() - "Get Temperature" callback function
5710 * @temperature: measured temperature
5711 * @pContext: callback context
5712 *
5713 * This function is passed to sme_get_temperature() as the callback
5714 * function to be invoked when the temperature measurement is
5715 * available.
5716 *
5717 * Return: None
5718 */
5719static void hdd_get_temperature_cb(int temperature, void *pContext)
5720{
5721 struct statsContext *pTempContext;
5722 hdd_adapter_t *pAdapter;
5723 ENTER();
5724 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005725 hdd_err("pContext is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005726 return;
5727 }
5728 pTempContext = pContext;
5729 pAdapter = pTempContext->pAdapter;
5730 spin_lock(&hdd_context_lock);
5731 if ((NULL == pAdapter) || (TEMP_CONTEXT_MAGIC != pTempContext->magic)) {
5732 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07005733 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734 pAdapter, pTempContext->magic);
5735 return;
5736 }
5737 if (temperature != 0) {
5738 pAdapter->temperature = temperature;
5739 }
5740 complete(&pTempContext->completion);
5741 spin_unlock(&hdd_context_lock);
5742 EXIT();
5743}
5744
5745/**
5746 * wlan_hdd_get_temperature() - get current device temperature
5747 * @pAdapter: device upon which the request was made
5748 * @temperature: pointer to where the temperature is to be returned
5749 *
5750 * Return: 0 if a temperature value (either current or cached) was
5751 * returned, otherwise a negative errno is returned.
5752 *
5753 */
5754int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
5755{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305756 QDF_STATUS status;
Houston Hoffman59c097f2016-11-09 15:50:25 -08005757 static struct statsContext tempContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 unsigned long rc;
5759
5760 ENTER();
5761 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005762 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005763 return -EPERM;
5764 }
5765 init_completion(&tempContext.completion);
5766 tempContext.pAdapter = pAdapter;
5767 tempContext.magic = TEMP_CONTEXT_MAGIC;
5768 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
5769 &tempContext, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305770 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005771 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005772 } else {
5773 rc = wait_for_completion_timeout(&tempContext.completion,
5774 msecs_to_jiffies
5775 (WLAN_WAIT_TIME_STATS));
5776 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005777 hdd_err("SME timed out while retrieving temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005778 }
5779 }
5780 spin_lock(&hdd_context_lock);
5781 tempContext.magic = 0;
5782 spin_unlock(&hdd_context_lock);
5783 *temperature = pAdapter->temperature;
5784 EXIT();
5785 return 0;
5786}
5787
5788/**
5789 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5790 * @dev: device upon which the ioctl was received
5791 * @info: ioctl request information
5792 * @wrqu: ioctl request data
5793 * @extra: ioctl extra data
5794 *
5795 * Return: 0 on success, non-zero on error
5796 */
5797static int __iw_setint_getnone(struct net_device *dev,
5798 struct iw_request_info *info,
5799 union iwreq_data *wrqu, char *extra)
5800{
5801 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5802 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5803 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5804 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5805 hdd_context_t *hdd_ctx;
5806 tSmeConfigParams smeConfig;
5807 int *value = (int *)extra;
5808 int sub_cmd = value[0];
5809 int set_value = value[1];
5810 int ret;
5811 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305812 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005814 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305815
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005816 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5817 ret = wlan_hdd_validate_context(hdd_ctx);
5818 if (0 != ret)
5819 return ret;
5820
Jeff Johnson441e1f72017-02-07 08:50:49 -08005821 ret = hdd_check_private_wext_control(hdd_ctx, info);
5822 if (0 != ret)
5823 return ret;
5824
5825 INIT_COMPLETION(pWextState->completion_var);
5826 memset(&smeConfig, 0x00, sizeof(smeConfig));
5827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005828 switch (sub_cmd) {
5829 case WE_SET_11D_STATE:
5830 {
5831 if ((ENABLE_11D == set_value)
5832 || (DISABLE_11D == set_value)) {
5833
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005834 sme_get_config_param(hHal, &smeConfig);
5835 smeConfig.csrConfig.Is11dSupportEnabled =
5836 (bool) set_value;
5837
Jeff Johnson99bac312016-06-28 10:38:18 -07005838 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005839 smeConfig.csrConfig.
5840 Is11dSupportEnabled);
5841
5842 sme_update_config(hHal, &smeConfig);
5843 } else {
5844 return -EINVAL;
5845 }
5846 break;
5847 }
5848
5849 case WE_WOWL:
5850 {
5851 switch (set_value) {
5852 case 0x00:
5853 hdd_exit_wowl(pAdapter);
5854 break;
5855 case 0x01:
5856 case 0x02:
5857 case 0x03:
5858 enable_mp = (set_value & 0x01) ? 1 : 0;
5859 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005860 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005861 (enable_mp ? "YES" : "NO"),
5862 (enable_pbm ? "YES" : "NO"));
5863 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5864 break;
5865 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005866 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 set_value);
5868 ret = -EINVAL;
5869 break;
5870 }
5871
5872 break;
5873 }
5874 case WE_SET_POWER:
5875 {
5876 switch (set_value) {
5877 case 1:
5878 /* Enable PowerSave */
5879 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5880 SME_PS_ENABLE);
5881 break;
5882 case 2:
5883 /* Disable PowerSave */
5884 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5885 SME_PS_DISABLE);
5886 break;
5887 case 3: /* Enable UASPD */
5888 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
5889 break;
5890 case 4: /* Disable UASPD */
5891 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
5892 break;
5893 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005894 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005895 set_value);
5896 ret = -EINVAL;
5897 break;
5898 }
5899 break;
5900 }
5901
5902 case WE_SET_MAX_ASSOC:
5903 {
5904 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5905 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5906 ret = -EINVAL;
5907 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5908 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305909 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005910 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005911 ret = -EIO;
5912 }
5913 break;
5914 }
5915
5916 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5917 if (set_value == 0 || set_value == 1)
5918 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
5919 set_value;
5920 else
5921 ret = -EINVAL;
5922 break;
5923
5924 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005925 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5926 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5927 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5928 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305929 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005930 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005931 ret = -EINVAL;
5932 }
5933 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005934 case WE_SET_MC_RATE:
5935 {
5936 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
5937 break;
5938 }
5939 case WE_SET_TX_POWER:
5940 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305941 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942
Anurag Chouhanc5548422016-02-24 18:33:27 +05305943 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944 if (sme_set_tx_power
5945 (hHal, pAdapter->sessionId, bssid,
5946 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305947 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005948 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005949 return -EIO;
5950 }
5951 break;
5952 }
5953 case WE_SET_MAX_TX_POWER:
5954 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305955 struct qdf_mac_addr bssid;
5956 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957
Jeff Johnson99bac312016-06-28 10:38:18 -07005958 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005959 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305960 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
5961 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005962
5963 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305964 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005965 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 return -EIO;
5967 }
5968
5969 break;
5970 }
5971 case WE_SET_MAX_TX_POWER_2_4:
5972 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005973 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
5974 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305976 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005977 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005978 return -EIO;
5979 }
5980
5981 break;
5982 }
5983 case WE_SET_MAX_TX_POWER_5_0:
5984 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005985 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
5986 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005987 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305988 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005989 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 return -EIO;
5991 }
5992
5993 break;
5994 }
5995 case WE_SET_HIGHER_DTIM_TRANSITION:
5996 {
5997 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005998 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 set_value);
6000 ret = -EINVAL;
6001 } else {
6002 if (pAdapter->higherDtimTransition != set_value) {
6003 pAdapter->higherDtimTransition =
6004 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07006005 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006006 pAdapter->higherDtimTransition);
6007 }
6008 }
6009
6010 break;
6011 }
6012
6013 case WE_SET_TM_LEVEL:
6014 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006015 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 (void)sme_set_thermal_level(hHal, set_value);
6017 break;
6018 }
6019
6020 case WE_SET_PHYMODE:
6021 {
6022 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
6023
6024 ret =
6025 wlan_hdd_update_phymode(dev, hHal, set_value,
6026 phddctx);
6027 break;
6028 }
6029
6030 case WE_SET_NSS:
6031 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006032 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006034 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 ret = -EINVAL;
6036 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306037 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006038 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
6039 set_value))
6040 ret = -EINVAL;
6041 }
6042 break;
6043 }
6044
6045 case WE_SET_GTX_HT_MCS:
6046 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006047 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006048 ret = wma_cli_set_command(pAdapter->sessionId,
6049 WMI_VDEV_PARAM_GTX_HT_MCS,
6050 set_value, GTX_CMD);
6051 break;
6052 }
6053
6054 case WE_SET_GTX_VHT_MCS:
6055 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006056 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006057 set_value);
6058 ret = wma_cli_set_command(pAdapter->sessionId,
6059 WMI_VDEV_PARAM_GTX_VHT_MCS,
6060 set_value, GTX_CMD);
6061 break;
6062 }
6063
6064 case WE_SET_GTX_USRCFG:
6065 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006066 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067 set_value);
6068 ret = wma_cli_set_command(pAdapter->sessionId,
6069 WMI_VDEV_PARAM_GTX_USR_CFG,
6070 set_value, GTX_CMD);
6071 break;
6072 }
6073
6074 case WE_SET_GTX_THRE:
6075 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006076 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077 ret = wma_cli_set_command(pAdapter->sessionId,
6078 WMI_VDEV_PARAM_GTX_THRE,
6079 set_value, GTX_CMD);
6080 break;
6081 }
6082
6083 case WE_SET_GTX_MARGIN:
6084 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006085 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006086 ret = wma_cli_set_command(pAdapter->sessionId,
6087 WMI_VDEV_PARAM_GTX_MARGIN,
6088 set_value, GTX_CMD);
6089 break;
6090 }
6091
6092 case WE_SET_GTX_STEP:
6093 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006094 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006095 ret = wma_cli_set_command(pAdapter->sessionId,
6096 WMI_VDEV_PARAM_GTX_STEP,
6097 set_value, GTX_CMD);
6098 break;
6099 }
6100
6101 case WE_SET_GTX_MINTPC:
6102 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006103 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006104 ret = wma_cli_set_command(pAdapter->sessionId,
6105 WMI_VDEV_PARAM_GTX_MINTPC,
6106 set_value, GTX_CMD);
6107 break;
6108 }
6109
6110 case WE_SET_GTX_BWMASK:
6111 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006112 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006113 ret = wma_cli_set_command(pAdapter->sessionId,
6114 WMI_VDEV_PARAM_GTX_BW_MASK,
6115 set_value, GTX_CMD);
6116 break;
6117 }
6118
6119 case WE_SET_LDPC:
6120 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306121 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006122 break;
6123 }
6124
6125 case WE_SET_TX_STBC:
6126 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306127 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006128 break;
6129 }
6130
6131 case WE_SET_RX_STBC:
6132 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306133 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006134 break;
6135 }
6136
6137 case WE_SET_SHORT_GI:
6138 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006139 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006140 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
6141 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
6142 set_value);
6143 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07006144 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006145 break;
6146 }
6147
6148 case WE_SET_RTSCTS:
6149 {
6150 uint32_t value;
6151
Jeff Johnson99bac312016-06-28 10:38:18 -07006152 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006153 set_value);
6154
6155 if ((set_value & HDD_RTSCTS_EN_MASK) ==
6156 HDD_RTSCTS_ENABLE)
6157 value =
6158 (WLAN_HDD_GET_CTX(pAdapter))->config->
6159 RTSThreshold;
6160 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
6161 || ((set_value & HDD_RTSCTS_EN_MASK) ==
6162 HDD_CTS_ENABLE))
6163 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
6164 else
6165 return -EIO;
6166
6167 ret = wma_cli_set_command(pAdapter->sessionId,
6168 WMI_VDEV_PARAM_ENABLE_RTSCTS,
6169 set_value, VDEV_CMD);
6170 if (!ret) {
6171 if (sme_cfg_set_int
6172 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306173 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006174 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006175 return -EIO;
6176 }
6177 }
6178
6179 break;
6180 }
6181
6182 case WE_SET_CHWIDTH:
6183 {
6184 bool chwidth = false;
6185 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
6186 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07006187 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006188 set_value);
6189 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006190 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006191 return -EINVAL;
6192 }
6193
6194 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
6195 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
6196 nChannelBondingMode5GHz)))
6197 chwidth = true;
6198
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199 sme_get_config_param(hHal, &smeConfig);
6200 switch (set_value) {
6201 case eHT_CHANNEL_WIDTH_20MHZ:
6202 smeConfig.csrConfig.channelBondingMode5GHz =
6203 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
6204 break;
6205 case eHT_CHANNEL_WIDTH_40MHZ:
6206 if (chwidth)
6207 smeConfig.csrConfig.
6208 channelBondingMode5GHz =
6209 phddctx->config->
6210 nChannelBondingMode5GHz;
6211 else
6212 return -EINVAL;
6213
6214 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006215 case eHT_CHANNEL_WIDTH_80MHZ:
6216 if (chwidth)
6217 smeConfig.csrConfig.
6218 channelBondingMode5GHz =
6219 phddctx->config->
6220 nChannelBondingMode5GHz;
6221 else
6222 return -EINVAL;
6223
6224 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006225
6226 default:
6227 return -EINVAL;
6228 }
6229
6230 ret = wma_cli_set_command(pAdapter->sessionId,
6231 WMI_VDEV_PARAM_CHWIDTH,
6232 set_value, VDEV_CMD);
6233 if (!ret)
6234 sme_update_config(hHal, &smeConfig);
6235
6236 break;
6237 }
6238
6239 case WE_SET_ANI_EN_DIS:
6240 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006241 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006242 set_value);
6243 ret = wma_cli_set_command(pAdapter->sessionId,
6244 WMI_PDEV_PARAM_ANI_ENABLE,
6245 set_value, PDEV_CMD);
6246 break;
6247 }
6248
6249 case WE_SET_ANI_POLL_PERIOD:
6250 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006251 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006252 set_value);
6253 ret = wma_cli_set_command(pAdapter->sessionId,
6254 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6255 set_value, PDEV_CMD);
6256 break;
6257 }
6258
6259 case WE_SET_ANI_LISTEN_PERIOD:
6260 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006261 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006262 set_value);
6263 ret = wma_cli_set_command(pAdapter->sessionId,
6264 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6265 set_value, PDEV_CMD);
6266 break;
6267 }
6268
6269 case WE_SET_ANI_OFDM_LEVEL:
6270 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006271 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006272 set_value);
6273 ret = wma_cli_set_command(pAdapter->sessionId,
6274 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6275 set_value, PDEV_CMD);
6276 break;
6277 }
6278
6279 case WE_SET_ANI_CCK_LEVEL:
6280 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006281 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006282 set_value);
6283 ret = wma_cli_set_command(pAdapter->sessionId,
6284 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6285 set_value, PDEV_CMD);
6286 break;
6287 }
6288
6289 case WE_SET_DYNAMIC_BW:
6290 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006291 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292 set_value);
6293 ret = wma_cli_set_command(pAdapter->sessionId,
6294 WMI_PDEV_PARAM_DYNAMIC_BW,
6295 set_value, PDEV_CMD);
6296 break;
6297 }
6298
6299 case WE_SET_CTS_CBW:
6300 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006301 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006302 ret = wma_cli_set_command(pAdapter->sessionId,
6303 WMI_PDEV_PARAM_CTS_CBW,
6304 set_value, PDEV_CMD);
6305 break;
6306 }
6307
6308 case WE_SET_11N_RATE:
6309 {
6310 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07006311 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006312 set_value);
6313
6314 if (set_value != 0xff) {
6315 rix = RC_2_RATE_IDX(set_value);
6316 if (set_value & 0x80) {
6317 preamble = WMI_RATE_PREAMBLE_HT;
6318 nss = HT_RC_2_STREAMS(set_value) - 1;
6319 } else {
6320 nss = 0;
6321 rix = RC_2_RATE_IDX(set_value);
6322 if (set_value & 0x10) {
6323 preamble =
6324 WMI_RATE_PREAMBLE_CCK;
6325 if (rix != 0x3)
6326 /* Enable Short
6327 * preamble always for
6328 * CCK except 1mbps
6329 */
6330 rix |= 0x4;
6331 } else {
6332 preamble =
6333 WMI_RATE_PREAMBLE_OFDM;
6334 }
6335 }
6336 set_value = (preamble << 6) | (nss << 4) | rix;
6337 }
6338 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
6339 set_value, rix, preamble, nss);
6340
6341 ret = wma_cli_set_command(pAdapter->sessionId,
6342 WMI_VDEV_PARAM_FIXED_RATE,
6343 set_value, VDEV_CMD);
6344 break;
6345 }
6346
6347 case WE_SET_VHT_RATE:
6348 {
6349 uint8_t preamble = 0, nss = 0, rix = 0;
6350
6351 if (set_value != 0xff) {
6352 rix = RC_2_RATE_IDX_11AC(set_value);
6353 preamble = WMI_RATE_PREAMBLE_VHT;
6354 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
6355
6356 set_value = (preamble << 6) | (nss << 4) | rix;
6357 }
6358 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
6359 set_value, rix, preamble, nss);
6360 ret = wma_cli_set_command(pAdapter->sessionId,
6361 WMI_VDEV_PARAM_FIXED_RATE,
6362 set_value, VDEV_CMD);
6363 break;
6364 }
6365
6366 case WE_SET_AMPDU:
6367 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006368 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006369 ret = wma_cli_set_command(pAdapter->sessionId,
6370 GEN_VDEV_PARAM_AMPDU,
6371 set_value, GEN_CMD);
6372 break;
6373 }
6374
6375 case WE_SET_AMSDU:
6376 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006377 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006378 ret = wma_cli_set_command(pAdapter->sessionId,
6379 GEN_VDEV_PARAM_AMSDU,
6380 set_value, GEN_CMD);
6381 break;
6382 }
6383
6384 case WE_SET_BURST_ENABLE:
6385 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006386 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006387 if ((set_value == 0) || (set_value == 1)) {
6388 ret = wma_cli_set_command(pAdapter->sessionId,
6389 WMI_PDEV_PARAM_BURST_ENABLE,
6390 set_value, PDEV_CMD);
6391 } else
6392 ret = -EINVAL;
6393 break;
6394 }
6395 case WE_SET_BURST_DUR:
6396 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006397 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07006398 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006399 ret = wma_cli_set_command(pAdapter->sessionId,
6400 WMI_PDEV_PARAM_BURST_DUR,
6401 set_value, PDEV_CMD);
6402 else
6403 ret = -EINVAL;
6404 break;
6405 }
6406
6407 case WE_SET_TX_CHAINMASK:
6408 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006409 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006410 set_value);
6411 ret = wma_cli_set_command(pAdapter->sessionId,
6412 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6413 set_value, PDEV_CMD);
6414 break;
6415 }
6416
6417 case WE_SET_RX_CHAINMASK:
6418 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006419 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006420 set_value);
6421 ret = wma_cli_set_command(pAdapter->sessionId,
6422 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6423 set_value, PDEV_CMD);
6424 break;
6425 }
6426
6427 case WE_SET_TXPOW_2G:
6428 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006429 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006430 set_value);
6431 ret = wma_cli_set_command(pAdapter->sessionId,
6432 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6433 set_value, PDEV_CMD);
6434 break;
6435 }
6436
6437 case WE_SET_TXPOW_5G:
6438 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006439 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006440 set_value);
6441 ret = wma_cli_set_command(pAdapter->sessionId,
6442 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6443 set_value, PDEV_CMD);
6444 break;
6445 }
6446
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006447 /* Firmware debug log */
6448 case WE_DBGLOG_LOG_LEVEL:
6449 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006450 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006451 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
6452 ret = wma_cli_set_command(pAdapter->sessionId,
6453 WMI_DBGLOG_LOG_LEVEL,
6454 set_value, DBG_CMD);
6455 break;
6456 }
6457
6458 case WE_DBGLOG_VAP_ENABLE:
6459 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006460 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006461 ret = wma_cli_set_command(pAdapter->sessionId,
6462 WMI_DBGLOG_VAP_ENABLE,
6463 set_value, DBG_CMD);
6464 break;
6465 }
6466
6467 case WE_DBGLOG_VAP_DISABLE:
6468 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006469 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006470 ret = wma_cli_set_command(pAdapter->sessionId,
6471 WMI_DBGLOG_VAP_DISABLE,
6472 set_value, DBG_CMD);
6473 break;
6474 }
6475
6476 case WE_DBGLOG_MODULE_ENABLE:
6477 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006478 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006479 set_value);
6480 hdd_ctx->fw_log_settings.enable = set_value;
6481 ret = wma_cli_set_command(pAdapter->sessionId,
6482 WMI_DBGLOG_MODULE_ENABLE,
6483 set_value, DBG_CMD);
6484 break;
6485 }
6486
6487 case WE_DBGLOG_MODULE_DISABLE:
6488 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006489 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006490 set_value);
6491 hdd_ctx->fw_log_settings.enable = set_value;
6492 ret = wma_cli_set_command(pAdapter->sessionId,
6493 WMI_DBGLOG_MODULE_DISABLE,
6494 set_value, DBG_CMD);
6495 break;
6496 }
6497 case WE_DBGLOG_MOD_LOG_LEVEL:
6498 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006499 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006500 set_value);
6501
6502 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
6503 hdd_ctx->fw_log_settings.index = 0;
6504
6505 hdd_ctx->fw_log_settings.
6506 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
6507 set_value;
6508 hdd_ctx->fw_log_settings.index++;
6509
6510 ret = wma_cli_set_command(pAdapter->sessionId,
6511 WMI_DBGLOG_MOD_LOG_LEVEL,
6512 set_value, DBG_CMD);
6513 break;
6514 }
6515
6516 case WE_DBGLOG_TYPE:
6517 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006518 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006519 hdd_ctx->fw_log_settings.dl_type = set_value;
6520 ret = wma_cli_set_command(pAdapter->sessionId,
6521 WMI_DBGLOG_TYPE,
6522 set_value, DBG_CMD);
6523 break;
6524 }
6525 case WE_DBGLOG_REPORT_ENABLE:
6526 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006527 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006528 set_value);
6529 hdd_ctx->fw_log_settings.dl_report = set_value;
6530 ret = wma_cli_set_command(pAdapter->sessionId,
6531 WMI_DBGLOG_REPORT_ENABLE,
6532 set_value, DBG_CMD);
6533 break;
6534 }
6535
6536 case WE_SET_TXRX_FWSTATS:
6537 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006538 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006539 ret = wma_cli_set_command(pAdapter->sessionId,
6540 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
6541 set_value, VDEV_CMD);
6542 break;
6543 }
6544
6545 case WE_TXRX_FWSTATS_RESET:
6546 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006547 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006548 ret = wma_cli_set_command(pAdapter->sessionId,
6549 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
6550 set_value, VDEV_CMD);
6551 break;
6552 }
6553
6554 case WE_DUMP_STATS:
6555 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006556 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006557 hdd_wlan_dump_stats(pAdapter, set_value);
6558 break;
6559 }
6560
6561 case WE_CLEAR_STATS:
6562 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006563 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006564 switch (set_value) {
6565 case WLAN_HDD_STATS:
6566 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6567 memset(&pAdapter->hdd_stats, 0,
6568 sizeof(pAdapter->hdd_stats));
6569 break;
6570 case WLAN_TXRX_HIST_STATS:
6571 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
6572 break;
6573 case WLAN_HDD_NETIF_OPER_HISTORY:
6574 wlan_hdd_clear_netif_queue_history(hdd_ctx);
6575 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05306576 case WLAN_HIF_STATS:
6577 hdd_clear_hif_stats();
6578 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006579 default:
Leo Changfdb45c32016-10-28 11:09:23 -07006580 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
6581 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582 }
6583 break;
6584 }
6585
6586 case WE_PPS_PAID_MATCH:
6587 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006588 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006589 return EINVAL;
6590
Jeff Johnson99bac312016-06-28 10:38:18 -07006591 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006592 set_value);
6593 ret = wma_cli_set_command(pAdapter->sessionId,
6594 WMI_VDEV_PPS_PAID_MATCH,
6595 set_value, PPS_CMD);
6596 break;
6597 }
6598
6599 case WE_PPS_GID_MATCH:
6600 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006601 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006602 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006603 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006604 set_value);
6605 ret = wma_cli_set_command(pAdapter->sessionId,
6606 WMI_VDEV_PPS_GID_MATCH,
6607 set_value, PPS_CMD);
6608 break;
6609 }
6610
6611 case WE_PPS_EARLY_TIM_CLEAR:
6612 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006613 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006614 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006615 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006616 set_value);
6617 ret = wma_cli_set_command(pAdapter->sessionId,
6618 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6619 set_value, PPS_CMD);
6620 break;
6621 }
6622
6623 case WE_PPS_EARLY_DTIM_CLEAR:
6624 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006625 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006626 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006627 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006628 set_value);
6629 ret = wma_cli_set_command(pAdapter->sessionId,
6630 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6631 set_value, PPS_CMD);
6632 break;
6633 }
6634
6635 case WE_PPS_EOF_PAD_DELIM:
6636 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006637 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006638 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006639 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006640 set_value);
6641 ret = wma_cli_set_command(pAdapter->sessionId,
6642 WMI_VDEV_PPS_EOF_PAD_DELIM,
6643 set_value, PPS_CMD);
6644 break;
6645 }
6646
6647 case WE_PPS_MACADDR_MISMATCH:
6648 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006649 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006650 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006651 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006652 set_value);
6653 ret = wma_cli_set_command(pAdapter->sessionId,
6654 WMI_VDEV_PPS_MACADDR_MISMATCH,
6655 set_value, PPS_CMD);
6656 break;
6657 }
6658
6659 case WE_PPS_DELIM_CRC_FAIL:
6660 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006661 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006662 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006663 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006664 set_value);
6665 ret = wma_cli_set_command(pAdapter->sessionId,
6666 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6667 set_value, PPS_CMD);
6668 break;
6669 }
6670
6671 case WE_PPS_GID_NSTS_ZERO:
6672 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006673 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006674 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006675 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006676 set_value);
6677 ret = wma_cli_set_command(pAdapter->sessionId,
6678 WMI_VDEV_PPS_GID_NSTS_ZERO,
6679 set_value, PPS_CMD);
6680 break;
6681 }
6682
6683 case WE_PPS_RSSI_CHECK:
6684 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006685 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006686 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006687 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006688 set_value);
6689 ret = wma_cli_set_command(pAdapter->sessionId,
6690 WMI_VDEV_PPS_RSSI_CHECK,
6691 set_value, PPS_CMD);
6692 break;
6693 }
6694
6695 case WE_PPS_5G_EBT:
6696 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006697 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006698 return -EINVAL;
6699
Jeff Johnson99bac312016-06-28 10:38:18 -07006700 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006701 ret = wma_cli_set_command(pAdapter->sessionId,
6702 WMI_VDEV_PPS_5G_EBT,
6703 set_value, PPS_CMD);
6704 break;
6705 }
6706
6707 case WE_SET_HTSMPS:
6708 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006709 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006710 ret = wma_cli_set_command(pAdapter->sessionId,
6711 WMI_STA_SMPS_FORCE_MODE_CMDID,
6712 set_value, VDEV_CMD);
6713 break;
6714 }
6715
6716 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6717 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006718 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006719 set_value);
6720 ret = wma_cli_set_command(pAdapter->sessionId,
6721 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6722 set_value, QPOWER_CMD);
6723 break;
6724 }
6725
6726 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6727 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006728 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006729 set_value);
6730 ret = wma_cli_set_command(
6731 pAdapter->sessionId,
6732 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6733 set_value, QPOWER_CMD);
6734 break;
6735 }
6736
6737 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6738 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006739 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006740 set_value);
6741 ret = wma_cli_set_command(
6742 pAdapter->sessionId,
6743 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6744 set_value, QPOWER_CMD);
6745 break;
6746 }
6747
6748 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6749 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006750 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006751 set_value);
6752 ret = wma_cli_set_command(
6753 pAdapter->sessionId,
6754 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6755 set_value, QPOWER_CMD);
6756 break;
6757 }
6758
6759 case WE_MCC_CONFIG_LATENCY:
6760 {
6761 cds_set_mcc_latency(pAdapter, set_value);
6762 break;
6763 }
6764
6765 case WE_MCC_CONFIG_QUOTA:
6766 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006767 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006768 set_value);
6769 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
6770 break;
6771 }
6772 case WE_SET_DEBUG_LOG:
6773 {
6774 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05306775
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006776 hdd_ctx->config->gEnableDebugLog = set_value;
6777 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6778 break;
6779 }
6780 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6781 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006782 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006783 if ((set_value == 0) || (set_value == 1))
6784 ret = wma_cli_set_command(
6785 pAdapter->sessionId,
6786 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6787 set_value, VDEV_CMD);
6788 else
6789 ret = -EINVAL;
6790 break;
6791 }
6792 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6793 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006794 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006795 ret = wma_cli_set_command(pAdapter->sessionId,
6796 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6797 set_value, VDEV_CMD);
6798 break;
6799 }
6800 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6801 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006802 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006803 set_value);
6804 ret = wma_cli_set_command(
6805 pAdapter->sessionId,
6806 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6807 set_value, VDEV_CMD);
6808 break;
6809 }
6810 case WE_SET_EARLY_RX_SLOP_STEP:
6811 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006812 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006813 set_value);
6814 ret = wma_cli_set_command(pAdapter->sessionId,
6815 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6816 set_value, VDEV_CMD);
6817 break;
6818 }
6819 case WE_SET_EARLY_RX_INIT_SLOP:
6820 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006821 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006822 set_value);
6823 ret = wma_cli_set_command(pAdapter->sessionId,
6824 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6825 set_value, VDEV_CMD);
6826 break;
6827 }
6828 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6829 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006830 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006831 if ((set_value == 0) || (set_value == 1))
6832 ret = wma_cli_set_command(
6833 pAdapter->sessionId,
6834 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6835 set_value, VDEV_CMD);
6836 else
6837 ret = -EINVAL;
6838 break;
6839 }
6840 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6841 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006842 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006843 ret = wma_cli_set_command(pAdapter->sessionId,
6844 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6845 set_value, VDEV_CMD);
6846 break;
6847 }
6848 case WE_SET_SCAN_DISABLE:
6849 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006850 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006851 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
6852 break;
6853 }
Govind Singha471e5e2015-10-12 17:11:14 +05306854 case WE_START_FW_PROFILE:
6855 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006856 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05306857 ret = wma_cli_set_command(pAdapter->sessionId,
6858 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6859 set_value, DBG_CMD);
6860 break;
6861 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306862 case WE_SET_CHANNEL:
6863 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006864 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306865 pAdapter->sessionId, pAdapter->device_mode);
6866
Krunal Sonif07bb382016-03-10 13:02:11 -08006867 if ((QDF_STA_MODE == pAdapter->device_mode) ||
6868 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306869
6870 status = sme_ext_change_channel(hHal,
6871 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306872 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006873 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306874 status);
6875 ret = -EINVAL;
6876 }
6877 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006878 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306879 pAdapter->device_mode);
6880 ret = -EINVAL;
6881 }
6882 break;
6883 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306884 case WE_SET_CONC_SYSTEM_PREF:
6885 {
6886 hdd_info("New preference: %d", set_value);
6887 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6888 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6889 hdd_err("Invalid system preference %d", set_value);
6890 return -EINVAL;
6891 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306892
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306893 /* hdd_ctx, hdd_ctx->config are already checked for null */
6894 hdd_ctx->config->conc_system_pref = set_value;
6895 break;
6896 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006897 default:
6898 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006899 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006900 sub_cmd);
6901 ret = -EINVAL;
6902 break;
6903 }
6904 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306905 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006906 return ret;
6907}
6908
6909static int iw_setint_getnone(struct net_device *dev,
6910 struct iw_request_info *info,
6911 union iwreq_data *wrqu,
6912 char *extra)
6913{
6914 int ret;
6915
6916 cds_ssr_protect(__func__);
6917 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6918 cds_ssr_unprotect(__func__);
6919
6920 return ret;
6921}
6922
6923/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006924 * __iw_setnone_get_threeint() - return three value to up layer.
6925 *
6926 * @dev: pointer of net_device of this wireless card
6927 * @info: meta data about Request sent
6928 * @wrqu: include request info
6929 * @extra: buf used for in/Output
6930 *
6931 * Return: execute result
6932 */
6933static int __iw_setnone_get_threeint(struct net_device *dev,
6934 struct iw_request_info *info,
6935 union iwreq_data *wrqu, char *extra)
6936{
6937 int ret = 0; /* success */
6938 uint32_t *value = (int *)extra;
6939 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6940 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6941
6942 ENTER_DEV(dev);
6943 ret = wlan_hdd_validate_context(hdd_ctx);
6944 if (0 != ret)
6945 return ret;
6946
Jeff Johnson441e1f72017-02-07 08:50:49 -08006947 ret = hdd_check_private_wext_control(hdd_ctx, info);
6948 if (0 != ret)
6949 return ret;
6950
Jeff Johnson99bac312016-06-28 10:38:18 -07006951 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006952 switch (value[0]) {
6953 case WE_GET_TSF:
6954 ret = hdd_indicate_tsf(adapter, value, 3);
6955 break;
6956 default:
6957 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6958 break;
6959 }
6960 return ret;
6961}
6962
6963/**
6964 * iw_setnone_get_threeint() - return three value to up layer.
6965 *
6966 * @dev: pointer of net_device of this wireless card
6967 * @info: meta data about Request sent
6968 * @wrqu: include request info
6969 * @extra: buf used for in/Output
6970 *
6971 * Return: execute result
6972 */
6973static int iw_setnone_get_threeint(struct net_device *dev,
6974 struct iw_request_info *info,
6975 union iwreq_data *wrqu, char *extra)
6976{
6977 int ret;
6978
6979 cds_ssr_protect(__func__);
6980 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6981 cds_ssr_unprotect(__func__);
6982
6983 return ret;
6984}
6985
6986/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006987 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6988 * @dev: device upon which the ioctl was received
6989 * @info: ioctl request information
6990 * @wrqu: ioctl request data
6991 * @extra: ioctl extra data
6992 *
6993 * Return: 0 on success, non-zero on error
6994 */
6995static int __iw_setchar_getnone(struct net_device *dev,
6996 struct iw_request_info *info,
6997 union iwreq_data *wrqu, char *extra)
6998{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306999 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007000 int sub_cmd;
7001 int ret;
7002 char *pBuffer = NULL;
7003 hdd_adapter_t *pAdapter = (netdev_priv(dev));
7004 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007005 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007006 struct iw_point s_priv_data;
7007
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007008 ENTER_DEV(dev);
7009
Mukul Sharma34777c62015-11-02 20:22:30 +05307010 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007011 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05307012 return -EPERM;
7013 }
7014
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007015 ret = wlan_hdd_validate_context(hdd_ctx);
7016 if (0 != ret)
7017 return ret;
7018
Jeff Johnson441e1f72017-02-07 08:50:49 -08007019 ret = hdd_check_private_wext_control(hdd_ctx, info);
7020 if (0 != ret)
7021 return ret;
7022
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007023 /* helper function to get iwreq_data with compat handling. */
7024 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
7025 return -EINVAL;
7026 }
7027
7028 /* make sure all params are correctly passed to function */
7029 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
7030 return -EINVAL;
7031 }
7032
7033 sub_cmd = s_priv_data.flags;
7034
7035 /* ODD number is used for set, copy data using copy_from_user */
7036 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
7037 s_priv_data.length);
7038 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007039 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007040 return -ENOMEM;
7041 }
7042
Jeff Johnson99bac312016-06-28 10:38:18 -07007043 hdd_notice("Received length %d", s_priv_data.length);
7044 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007045
7046 switch (sub_cmd) {
7047 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07007048 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007049 hdd_add_wowl_ptrn(pAdapter, pBuffer);
7050 break;
7051 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07007052 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007053 hdd_del_wowl_ptrn(pAdapter, pBuffer);
7054 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007055 case WE_NEIGHBOR_REPORT_REQUEST:
7056 {
7057 tRrmNeighborReq neighborReq;
7058 tRrmNeighborRspCallbackInfo callbackInfo;
7059
7060 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007061 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007062 neighborReq.no_ssid =
7063 (s_priv_data.length - 1) ? false : true;
7064 if (!neighborReq.no_ssid) {
7065 neighborReq.ssid.length =
7066 (s_priv_data.length - 1) >
7067 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307068 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007069 pBuffer,
7070 neighborReq.ssid.length);
7071 }
7072
7073 callbackInfo.neighborRspCallback = NULL;
7074 callbackInfo.neighborRspCallbackContext = NULL;
7075 callbackInfo.timeout = 5000; /* 5 seconds */
7076 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
7077 (pAdapter),
7078 pAdapter->sessionId,
7079 &neighborReq,
7080 &callbackInfo);
7081 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07007082 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007083 ret = -EINVAL;
7084 }
7085 }
7086 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007087 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07007088 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007089 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
7090 s_priv_data.length);
7091 break;
7092 case WE_SET_CONFIG:
7093 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307094 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007095 ret = -EINVAL;
7096 }
7097 break;
7098 default:
7099 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007100 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007101 sub_cmd);
7102 ret = -EINVAL;
7103 break;
7104 }
7105 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07007106 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307107 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007108 return ret;
7109}
7110
7111static int iw_setchar_getnone(struct net_device *dev,
7112 struct iw_request_info *info,
7113 union iwreq_data *wrqu, char *extra)
7114{
7115 int ret;
7116
7117 cds_ssr_protect(__func__);
7118 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
7119 cds_ssr_unprotect(__func__);
7120
7121 return ret;
7122}
7123
7124/**
7125 * iw_setnone_getint() - Generic "get integer" private ioctl handler
7126 * @dev: device upon which the ioctl was received
7127 * @info: ioctl request information
7128 * @wrqu: ioctl request data
7129 * @extra: ioctl extra data
7130 *
7131 * Return: 0 on success, non-zero on error
7132 */
7133static int __iw_setnone_getint(struct net_device *dev,
7134 struct iw_request_info *info,
7135 union iwreq_data *wrqu, char *extra)
7136{
7137 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7138 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7139 int *value = (int *)extra;
7140 int ret;
7141 tSmeConfigParams smeConfig;
7142 hdd_context_t *hdd_ctx;
7143
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007144 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007146 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7147 ret = wlan_hdd_validate_context(hdd_ctx);
7148 if (0 != ret)
7149 return ret;
7150
Jeff Johnson441e1f72017-02-07 08:50:49 -08007151 ret = hdd_check_private_wext_control(hdd_ctx, info);
7152 if (0 != ret)
7153 return ret;
7154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007155 switch (value[0]) {
7156 case WE_GET_11D_STATE:
7157 {
7158 sme_get_config_param(hHal, &smeConfig);
7159
7160 *value = smeConfig.csrConfig.Is11dSupportEnabled;
7161
Jeff Johnson99bac312016-06-28 10:38:18 -07007162 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007163
7164 break;
7165 }
7166
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007167 case WE_GET_WLAN_DBG:
7168 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307169 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007170 *value = 0;
7171 break;
7172 }
7173 case WE_GET_MAX_ASSOC:
7174 {
7175 if (sme_cfg_get_int
7176 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307177 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007178 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007179 ret = -EIO;
7180 }
7181 break;
7182 }
7183 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
7184 *value = (WLAN_HDD_GET_CTX(
7185 pAdapter))->config->force_sap_acs;
7186 break;
7187
7188 case WE_GET_CONCURRENCY_MODE:
7189 {
7190 *value = cds_get_concurrency_mode();
7191
Jeff Johnson99bac312016-06-28 10:38:18 -07007192 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007193 break;
7194 }
7195
7196 case WE_GET_NSS:
7197 {
7198 sme_get_config_param(hHal, &smeConfig);
7199 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07007200 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007201 break;
7202 }
7203
7204 case WE_GET_GTX_HT_MCS:
7205 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007206 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007207 *value = wma_cli_get_command(pAdapter->sessionId,
7208 WMI_VDEV_PARAM_GTX_HT_MCS,
7209 GTX_CMD);
7210 break;
7211 }
7212
7213 case WE_GET_GTX_VHT_MCS:
7214 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007215 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007216 *value = wma_cli_get_command(pAdapter->sessionId,
7217 WMI_VDEV_PARAM_GTX_VHT_MCS,
7218 GTX_CMD);
7219 break;
7220 }
7221
7222 case WE_GET_GTX_USRCFG:
7223 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007224 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007225 *value = wma_cli_get_command(pAdapter->sessionId,
7226 WMI_VDEV_PARAM_GTX_USR_CFG,
7227 GTX_CMD);
7228 break;
7229 }
7230
7231 case WE_GET_GTX_THRE:
7232 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007233 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007234 *value = wma_cli_get_command(pAdapter->sessionId,
7235 WMI_VDEV_PARAM_GTX_THRE,
7236 GTX_CMD);
7237 break;
7238 }
7239
7240 case WE_GET_GTX_MARGIN:
7241 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007242 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007243 *value = wma_cli_get_command(pAdapter->sessionId,
7244 WMI_VDEV_PARAM_GTX_MARGIN,
7245 GTX_CMD);
7246 break;
7247 }
7248
7249 case WE_GET_GTX_STEP:
7250 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007251 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007252 *value = wma_cli_get_command(pAdapter->sessionId,
7253 WMI_VDEV_PARAM_GTX_STEP,
7254 GTX_CMD);
7255 break;
7256 }
7257
7258 case WE_GET_GTX_MINTPC:
7259 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007260 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007261 *value = wma_cli_get_command(pAdapter->sessionId,
7262 WMI_VDEV_PARAM_GTX_MINTPC,
7263 GTX_CMD);
7264 break;
7265 }
7266
7267 case WE_GET_GTX_BWMASK:
7268 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007269 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007270 *value = wma_cli_get_command(pAdapter->sessionId,
7271 WMI_VDEV_PARAM_GTX_BW_MASK,
7272 GTX_CMD);
7273 break;
7274 }
7275
7276 case WE_GET_LDPC:
7277 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307278 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007279 break;
7280 }
7281
7282 case WE_GET_TX_STBC:
7283 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307284 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007285 break;
7286 }
7287
7288 case WE_GET_RX_STBC:
7289 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307290 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007291 break;
7292 }
7293
7294 case WE_GET_SHORT_GI:
7295 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007296 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007297 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
7298 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
7299 break;
7300 }
7301
7302 case WE_GET_RTSCTS:
7303 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007304 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007305 *value = wma_cli_get_command(pAdapter->sessionId,
7306 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7307 VDEV_CMD);
7308 break;
7309 }
7310
7311 case WE_GET_CHWIDTH:
7312 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007313 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007314 *value = wma_cli_get_command(pAdapter->sessionId,
7315 WMI_VDEV_PARAM_CHWIDTH,
7316 VDEV_CMD);
7317 break;
7318 }
7319
7320 case WE_GET_ANI_EN_DIS:
7321 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007322 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007323 *value = wma_cli_get_command(pAdapter->sessionId,
7324 WMI_PDEV_PARAM_ANI_ENABLE,
7325 PDEV_CMD);
7326 break;
7327 }
7328
7329 case WE_GET_ANI_POLL_PERIOD:
7330 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007331 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007332 *value = wma_cli_get_command(pAdapter->sessionId,
7333 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
7334 PDEV_CMD);
7335 break;
7336 }
7337
7338 case WE_GET_ANI_LISTEN_PERIOD:
7339 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007340 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007341 *value = wma_cli_get_command(pAdapter->sessionId,
7342 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
7343 PDEV_CMD);
7344 break;
7345 }
7346
7347 case WE_GET_ANI_OFDM_LEVEL:
7348 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007349 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007350 *value = wma_cli_get_command(pAdapter->sessionId,
7351 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
7352 PDEV_CMD);
7353 break;
7354 }
7355
7356 case WE_GET_ANI_CCK_LEVEL:
7357 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007358 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007359 *value = wma_cli_get_command(pAdapter->sessionId,
7360 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
7361 PDEV_CMD);
7362 break;
7363 }
7364
7365 case WE_GET_DYNAMIC_BW:
7366 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007367 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007368 *value = wma_cli_get_command(pAdapter->sessionId,
7369 WMI_PDEV_PARAM_DYNAMIC_BW,
7370 PDEV_CMD);
7371 break;
7372 }
7373
7374 case WE_GET_11N_RATE:
7375 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007376 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007377 *value = wma_cli_get_command(pAdapter->sessionId,
7378 WMI_VDEV_PARAM_FIXED_RATE,
7379 VDEV_CMD);
7380 break;
7381 }
7382
7383 case WE_GET_AMPDU:
7384 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007385 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007386 *value = wma_cli_get_command(pAdapter->sessionId,
7387 GEN_VDEV_PARAM_AMPDU,
7388 GEN_CMD);
7389 break;
7390 }
7391
7392 case WE_GET_AMSDU:
7393 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007394 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007395 *value = wma_cli_get_command(pAdapter->sessionId,
7396 GEN_VDEV_PARAM_AMSDU,
7397 GEN_CMD);
7398 break;
7399 }
7400
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007401 case WE_GET_ROAM_SYNCH_DELAY:
7402 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007403 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007404 *value = wma_cli_get_command(pAdapter->sessionId,
7405 GEN_VDEV_ROAM_SYNCH_DELAY,
7406 GEN_CMD);
7407 break;
7408 }
7409
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007410 case WE_GET_BURST_ENABLE:
7411 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007412 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007413 *value = wma_cli_get_command(pAdapter->sessionId,
7414 WMI_PDEV_PARAM_BURST_ENABLE,
7415 PDEV_CMD);
7416 break;
7417 }
7418 case WE_GET_BURST_DUR:
7419 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007420 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007421 *value = wma_cli_get_command(pAdapter->sessionId,
7422 WMI_PDEV_PARAM_BURST_DUR,
7423 PDEV_CMD);
7424 break;
7425 }
7426
7427 case WE_GET_TX_CHAINMASK:
7428 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007429 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007430 *value = wma_cli_get_command(pAdapter->sessionId,
7431 WMI_PDEV_PARAM_TX_CHAIN_MASK,
7432 PDEV_CMD);
7433 break;
7434 }
7435
7436 case WE_GET_RX_CHAINMASK:
7437 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007438 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007439 *value = wma_cli_get_command(pAdapter->sessionId,
7440 WMI_PDEV_PARAM_RX_CHAIN_MASK,
7441 PDEV_CMD);
7442 break;
7443 }
7444
7445 case WE_GET_TXPOW_2G:
7446 {
7447 uint32_t txpow2g = 0;
7448 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07007449 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007450 *value = wma_cli_get_command(pAdapter->sessionId,
7451 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
7452 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307453 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007454 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7455 &txpow2g)) {
7456 return -EIO;
7457 }
Jeff Johnson99bac312016-06-28 10:38:18 -07007458 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007459 break;
7460 }
7461
7462 case WE_GET_TXPOW_5G:
7463 {
7464 uint32_t txpow5g = 0;
7465 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07007466 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007467 *value = wma_cli_get_command(pAdapter->sessionId,
7468 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
7469 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307470 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007471 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7472 &txpow5g)) {
7473 return -EIO;
7474 }
Jeff Johnson99bac312016-06-28 10:38:18 -07007475 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007476 break;
7477 }
7478
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007479 case WE_GET_PPS_PAID_MATCH:
7480 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007481 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007482 *value = wma_cli_get_command(pAdapter->sessionId,
7483 WMI_VDEV_PPS_PAID_MATCH,
7484 PPS_CMD);
7485 break;
7486 }
7487
7488 case WE_GET_PPS_GID_MATCH:
7489 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007490 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007491 *value = wma_cli_get_command(pAdapter->sessionId,
7492 WMI_VDEV_PPS_GID_MATCH,
7493 PPS_CMD);
7494 break;
7495 }
7496
7497 case WE_GET_PPS_EARLY_TIM_CLEAR:
7498 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007499 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007500 *value = wma_cli_get_command(pAdapter->sessionId,
7501 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
7502 PPS_CMD);
7503 break;
7504 }
7505
7506 case WE_GET_PPS_EARLY_DTIM_CLEAR:
7507 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007508 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007509 *value = wma_cli_get_command(pAdapter->sessionId,
7510 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
7511 PPS_CMD);
7512 break;
7513 }
7514
7515 case WE_GET_PPS_EOF_PAD_DELIM:
7516 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007517 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007518 *value = wma_cli_get_command(pAdapter->sessionId,
7519 WMI_VDEV_PPS_EOF_PAD_DELIM,
7520 PPS_CMD);
7521 break;
7522 }
7523
7524 case WE_GET_PPS_MACADDR_MISMATCH:
7525 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007526 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007527 *value = wma_cli_get_command(pAdapter->sessionId,
7528 WMI_VDEV_PPS_MACADDR_MISMATCH,
7529 PPS_CMD);
7530 break;
7531 }
7532
7533 case WE_GET_PPS_DELIM_CRC_FAIL:
7534 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007535 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007536 *value = wma_cli_get_command(pAdapter->sessionId,
7537 WMI_VDEV_PPS_DELIM_CRC_FAIL,
7538 PPS_CMD);
7539 break;
7540 }
7541
7542 case WE_GET_PPS_GID_NSTS_ZERO:
7543 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007544 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007545 *value = wma_cli_get_command(pAdapter->sessionId,
7546 WMI_VDEV_PPS_GID_NSTS_ZERO,
7547 PPS_CMD);
7548 break;
7549 }
7550
7551 case WE_GET_PPS_RSSI_CHECK:
7552 {
7553
Jeff Johnson99bac312016-06-28 10:38:18 -07007554 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007555 *value = wma_cli_get_command(pAdapter->sessionId,
7556 WMI_VDEV_PPS_RSSI_CHECK,
7557 PPS_CMD);
7558 break;
7559 }
7560
7561 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
7562 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007563 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007564 *value = wma_cli_get_command(pAdapter->sessionId,
7565 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
7566 QPOWER_CMD);
7567 break;
7568 }
7569
7570 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
7571 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007572 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007573 *value = wma_cli_get_command(pAdapter->sessionId,
7574 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
7575 QPOWER_CMD);
7576 break;
7577 }
7578
7579 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
7580 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007581 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007582 *value = wma_cli_get_command(pAdapter->sessionId,
7583 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
7584 QPOWER_CMD);
7585 break;
7586 }
7587
7588 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
7589 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007590 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007591 *value = wma_cli_get_command(pAdapter->sessionId,
7592 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
7593 QPOWER_CMD);
7594 break;
7595 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07007596 case WE_CAP_TSF:
7597 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
7598 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007599 case WE_GET_TEMPERATURE:
7600 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007601 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007602 ret = wlan_hdd_get_temperature(pAdapter, value);
7603 break;
7604 }
7605 default:
7606 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007607 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007608 value[0]);
7609 break;
7610 }
7611 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307612 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007613 return ret;
7614}
7615
7616static int iw_setnone_getint(struct net_device *dev,
7617 struct iw_request_info *info,
7618 union iwreq_data *wrqu, char *extra)
7619{
7620 int ret;
7621
7622 cds_ssr_protect(__func__);
7623 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7624 cds_ssr_unprotect(__func__);
7625
7626 return ret;
7627}
7628
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307629static int hdd_set_fwtest(int argc, int cmd, int value)
7630{
7631 struct set_fwtest_params *fw_test;
7632
7633 /* check for max number of arguments */
7634 if (argc > (WMA_MAX_NUM_ARGS) ||
7635 argc != HDD_FWTEST_PARAMS) {
7636 hdd_err("Too Many args %d", argc);
7637 return -EINVAL;
7638 }
7639 /*
7640 * check if number of arguments are 3 then, check
7641 * then set the default value for sounding interval.
7642 */
7643 if (HDD_FWTEST_PARAMS == argc) {
7644 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7645 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7646 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7647 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7648 }
7649 /* check sounding interval value should not exceed to max */
7650 if (value > HDD_FWTEST_MAX_VALUE) {
7651 hdd_err("Invalid arguments value should not exceed max: %d",
7652 value);
7653 return -EINVAL;
7654 }
7655 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7656 if (NULL == fw_test) {
7657 hdd_err("qdf_mem_malloc failed for fw_test");
7658 return -ENOMEM;
7659 }
7660 fw_test->arg = cmd;
7661 fw_test->value = value;
7662 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7663 qdf_mem_free(fw_test);
7664 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7665 return -EINVAL;
7666 }
7667 return 0;
7668}
7669
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007670/**
7671 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7672 * @dev: device upon which the ioctl was received
7673 * @info: ioctl request information
7674 * @wrqu: ioctl request data
7675 * @extra: ioctl extra data
7676 *
7677 * Return: 0 on success, non-zero on error
7678 */
7679static int __iw_set_three_ints_getnone(struct net_device *dev,
7680 struct iw_request_info *info,
7681 union iwreq_data *wrqu, char *extra)
7682{
7683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7684 int *value = (int *)extra;
7685 int sub_cmd = value[0];
7686 int ret;
7687 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7688
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007689 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307690
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007691 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007692 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007693 return -EPERM;
7694 }
7695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007696 ret = wlan_hdd_validate_context(hdd_ctx);
7697 if (0 != ret)
7698 return ret;
7699
Jeff Johnson441e1f72017-02-07 08:50:49 -08007700 ret = hdd_check_private_wext_control(hdd_ctx, info);
7701 if (0 != ret)
7702 return ret;
7703
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007704 switch (sub_cmd) {
7705
7706 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307707 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007708 break;
7709 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307710 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007711 break;
7712
7713 /* value[3] the acs band is not required as start and end channels are
7714 * enough but this cmd is maintained under set three ints for historic
7715 * reasons.
7716 */
7717 case WE_SET_SAP_CHANNELS:
7718 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307719 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007720 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307721 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007722 ret = -EINVAL;
7723 } else {
7724 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7725 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7726 }
7727 break;
7728 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7729 hdd_debug("Ioctl to set dual mac scan config");
7730 if (hdd_ctx->config->dual_mac_feature_disable) {
7731 hdd_err("Dual mac feature is disabled from INI");
7732 return -EPERM;
7733 }
7734 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08007735 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007736 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307737 case WE_SET_FW_TEST:
7738 {
7739 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7740 if (ret) {
7741 hdd_err("Not able to set fwtest %d", ret);
7742 return ret;
7743 }
7744 }
7745 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007746 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007747 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007748 break;
7749
7750 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307751 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007752 return ret;
7753}
7754
7755int iw_set_three_ints_getnone(struct net_device *dev,
7756 struct iw_request_info *info,
7757 union iwreq_data *wrqu, char *extra)
7758{
7759 int ret;
7760
7761 cds_ssr_protect(__func__);
7762 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7763 cds_ssr_unprotect(__func__);
7764
7765 return ret;
7766}
7767
7768/**
7769 * hdd_connection_state_string() - Get connection state string
7770 * @connection_state: enum to be converted to a string
7771 *
7772 * Return: the string equivalent of @connection_state
7773 */
7774static const char *
7775hdd_connection_state_string(eConnectionState connection_state)
7776{
7777 switch (connection_state) {
7778 CASE_RETURN_STRING(eConnectionState_NotConnected);
7779 CASE_RETURN_STRING(eConnectionState_Connecting);
7780 CASE_RETURN_STRING(eConnectionState_Associated);
7781 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7782 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7783 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7784 default:
7785 return "UNKNOWN";
7786 }
7787}
7788
7789/**
7790 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7791 * @dev: device upon which the ioctl was received
7792 * @info: ioctl request information
7793 * @wrqu: ioctl request data
7794 * @extra: ioctl extra data
7795 *
7796 * Return: 0 on success, non-zero on error
7797 */
7798static int __iw_get_char_setnone(struct net_device *dev,
7799 struct iw_request_info *info,
7800 union iwreq_data *wrqu, char *extra)
7801{
7802 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7803 int sub_cmd = wrqu->data.flags;
7804 hdd_context_t *hdd_ctx;
7805 int ret;
7806#ifdef WLAN_FEATURE_11W
7807 hdd_wext_state_t *pWextState;
7808#endif
7809
7810#ifdef WLAN_FEATURE_11W
7811 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7812#endif
7813
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007814 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307815
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007816 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7817 ret = wlan_hdd_validate_context(hdd_ctx);
7818 if (0 != ret)
7819 return ret;
7820
Jeff Johnson441e1f72017-02-07 08:50:49 -08007821 ret = hdd_check_private_wext_control(hdd_ctx, info);
7822 if (0 != ret)
7823 return ret;
7824
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007825 switch (sub_cmd) {
7826 case WE_WLAN_VERSION:
7827 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307828 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007829 break;
7830 }
7831
7832 case WE_GET_STATS:
7833 {
7834 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
7835 extra, WE_MAX_STR_LEN);
7836 break;
7837 }
7838
Dustin Brownd9322482017-01-09 12:46:03 -08007839 case WE_GET_SUSPEND_RESUME_STATS:
7840 {
7841 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
7842 WE_MAX_STR_LEN);
7843 if (ret >= 0) {
7844 wrqu->data.length = ret;
7845 ret = 0;
7846 }
7847
7848 break;
7849 }
7850
Govind Singha471e5e2015-10-12 17:11:14 +05307851 case WE_LIST_FW_PROFILE:
7852 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7853 extra, WE_MAX_STR_LEN);
7854 break;
7855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007856 /* The case prints the current state of the HDD, SME, CSR, PE,
7857 * TL it can be extended for WDI Global State as well. And
7858 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7859 * and P2P_GO have not been added as of now.
7860 */
7861 case WE_GET_STATES:
7862 {
7863 int buf = 0, len = 0;
7864 int adapter_num = 0;
7865 int count = 0, check = 1;
7866
7867 tHalHandle hHal = NULL;
7868 tpAniSirGlobal pMac = NULL;
7869 hdd_station_ctx_t *pHddStaCtx = NULL;
7870
7871 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7872 hdd_adapter_t *useAdapter = NULL;
7873
7874 /* Print wlan0 or p2p0 states based on the adapter_num
7875 * by using the correct adapter
7876 */
7877 while (adapter_num < 2) {
7878 if (WLAN_ADAPTER == adapter_num) {
7879 useAdapter = pAdapter;
7880 buf =
7881 scnprintf(extra + len,
7882 WE_MAX_STR_LEN - len,
7883 "\n\n wlan0 States:-");
7884 len += buf;
7885 } else if (P2P_ADAPTER == adapter_num) {
7886 buf =
7887 scnprintf(extra + len,
7888 WE_MAX_STR_LEN - len,
7889 "\n\n p2p0 States:-");
7890 len += buf;
7891
7892 if (!pHddCtx) {
7893 buf =
7894 scnprintf(extra + len,
7895 WE_MAX_STR_LEN -
7896 len,
7897 "\n pHddCtx is NULL");
7898 len += buf;
7899 break;
7900 }
7901
7902 /* Printing p2p0 states only in the
7903 * case when the device is configured
7904 * as a p2p_client
7905 */
7906 useAdapter =
7907 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007908 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007909 if (!useAdapter) {
7910 buf =
7911 scnprintf(extra + len,
7912 WE_MAX_STR_LEN -
7913 len,
7914 "\n Device not configured as P2P_CLIENT.");
7915 len += buf;
7916 break;
7917 }
7918 }
7919
7920 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7921 if (!hHal) {
7922 buf =
7923 scnprintf(extra + len,
7924 WE_MAX_STR_LEN - len,
7925 "\n pMac is NULL");
7926 len += buf;
7927 break;
7928 }
7929 pMac = PMAC_STRUCT(hHal);
7930 if (!pMac) {
7931 buf =
7932 scnprintf(extra + len,
7933 WE_MAX_STR_LEN - len,
7934 "\n pMac is NULL");
7935 len += buf;
7936 break;
7937 }
7938 pHddStaCtx =
7939 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7940
7941
7942 buf =
7943 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7944 "\n HDD Conn State - %s "
7945 "\n \n SME State:"
7946 "\n Neighbour Roam State - %s"
7947 "\n CSR State - %s"
7948 "\n CSR Substate - %s",
7949 hdd_connection_state_string
7950 (pHddStaCtx->conn_info.connState),
7951 mac_trace_get_neighbour_roam_state
7952 (sme_get_neighbor_roam_state
7953 (hHal, useAdapter->sessionId)),
7954 mac_trace_getcsr_roam_state
7955 (sme_get_current_roam_state
7956 (hHal, useAdapter->sessionId)),
7957 mac_trace_getcsr_roam_sub_state
7958 (sme_get_current_roam_sub_state
7959 (hHal, useAdapter->sessionId))
7960 );
7961 len += buf;
7962 adapter_num++;
7963 }
7964
Mukul Sharma81661ae2015-10-30 20:26:02 +05307965 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007966 /* Printing Lim State starting with global lim states */
7967 buf =
7968 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7969 "\n \n LIM STATES:-"
7970 "\n Global Sme State - %s "
7971 "\n Global mlm State - %s " "\n",
7972 mac_trace_get_lim_sme_state
7973 (sme_get_lim_sme_state(hHal)),
7974 mac_trace_get_lim_mlm_state
7975 (sme_get_lim_sme_state(hHal))
7976 );
7977 len += buf;
7978
7979 /* Printing the PE Sme and Mlm states for valid lim sessions */
7980 while (check < 3 && count < 255) {
7981 if (sme_is_lim_session_valid(hHal, count)) {
7982 buf =
7983 scnprintf(extra + len,
7984 WE_MAX_STR_LEN -
7985 len,
7986 "\n Lim Valid Session %d:-"
7987 "\n PE Sme State - %s "
7988 "\n PE Mlm State - %s "
7989 "\n", check,
7990 mac_trace_get_lim_sme_state
7991 (sme_get_lim_sme_session_state
7992 (hHal, count)),
7993 mac_trace_get_lim_mlm_state
7994 (sme_get_lim_mlm_session_state
7995 (hHal, count))
7996 );
7997
7998 len += buf;
7999 check++;
8000 }
8001 count++;
8002 }
8003 }
8004
8005 wrqu->data.length = strlen(extra) + 1;
8006 break;
8007 }
8008
8009 case WE_GET_CFG:
8010 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008011 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008012 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
8013 extra,
8014 QCSAP_IOCTL_MAX_STR_LEN);
8015 wrqu->data.length = strlen(extra) + 1;
8016 break;
8017 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008018 case WE_GET_RSSI:
8019 {
8020 int8_t s7Rssi = 0;
8021 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
8022 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
8023 wrqu->data.length = strlen(extra) + 1;
8024 break;
8025 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008026
8027 case WE_GET_WMM_STATUS:
8028 {
8029 snprintf(extra, WE_MAX_STR_LEN,
8030 "\nDir: 0=up, 1=down, 3=both\n"
8031 "|------------------------|\n"
8032 "|AC | ACM |Admitted| Dir |\n"
8033 "|------------------------|\n"
8034 "|VO | %d | %3s | %d |\n"
8035 "|VI | %d | %3s | %d |\n"
8036 "|BE | %d | %3s | %d |\n"
8037 "|BK | %d | %3s | %d |\n"
8038 "|------------------------|\n",
8039 pAdapter->hddWmmStatus.
8040 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
8041 pAdapter->hddWmmStatus.
8042 wmmAcStatus[SME_AC_VO].
8043 wmmAcAccessAllowed ? "YES" : "NO",
8044 pAdapter->hddWmmStatus.
8045 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
8046 ts_info.direction,
8047 pAdapter->hddWmmStatus.
8048 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
8049 pAdapter->hddWmmStatus.
8050 wmmAcStatus[SME_AC_VI].
8051 wmmAcAccessAllowed ? "YES" : "NO",
8052 pAdapter->hddWmmStatus.
8053 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
8054 ts_info.direction,
8055 pAdapter->hddWmmStatus.
8056 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
8057 pAdapter->hddWmmStatus.
8058 wmmAcStatus[SME_AC_BE].
8059 wmmAcAccessAllowed ? "YES" : "NO",
8060 pAdapter->hddWmmStatus.
8061 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
8062 ts_info.direction,
8063 pAdapter->hddWmmStatus.
8064 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
8065 pAdapter->hddWmmStatus.
8066 wmmAcStatus[SME_AC_BK].
8067 wmmAcAccessAllowed ? "YES" : "NO",
8068 pAdapter->hddWmmStatus.
8069 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
8070 ts_info.direction);
8071
8072 wrqu->data.length = strlen(extra) + 1;
8073 break;
8074 }
8075 case WE_GET_CHANNEL_LIST:
8076 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308077 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008078 uint8_t i, len;
8079 char *buf;
8080 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
8081 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
8082 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8083
8084 tChannelListInfo channel_list;
8085
8086 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05308087 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008088 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308089 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008090 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008091 return -EINVAL;
8092 }
8093 buf = extra;
8094 /*
8095 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
8096 * Maximum buffer needed = 5 * number of channels.
8097 * Check ifsufficient buffer is available and then
8098 * proceed to fill the buffer.
8099 */
8100 if (WE_MAX_STR_LEN <
8101 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008102 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008103 return -EINVAL;
8104 }
8105 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
8106 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308107 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008108 ubuf, &ubuf_len)) {
8109 /* Printing Country code in getChannelList */
8110 for (i = 0; i < (ubuf_len - 1); i++)
8111 len += scnprintf(buf + len,
8112 WE_MAX_STR_LEN - len,
8113 "%c", ubuf[i]);
8114 }
8115 for (i = 0; i < channel_list.num_channels; i++) {
8116 len +=
8117 scnprintf(buf + len, WE_MAX_STR_LEN - len,
8118 " %u", channel_list.channels[i]);
8119 }
8120 wrqu->data.length = strlen(extra) + 1;
8121
8122 break;
8123 }
8124#ifdef FEATURE_WLAN_TDLS
8125 case WE_GET_TDLS_PEERS:
8126 {
8127 wrqu->data.length =
8128 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
8129 WE_MAX_STR_LEN) + 1;
8130 break;
8131 }
8132#endif
8133#ifdef WLAN_FEATURE_11W
8134 case WE_GET_11W_INFO:
8135 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008136 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008137 pWextState->roamProfile.MFPEnabled);
8138
8139 snprintf(extra, WE_MAX_STR_LEN,
8140 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
8141 "\n Number of Unprotected Disassocs %d"
8142 "\n Number of Unprotected Deauths %d",
8143 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
8144 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
8145 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
8146 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
8147 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
8148 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
8149 pWextState->roamProfile.MFPEnabled,
8150 pAdapter->hdd_stats.hddPmfStats.
8151 numUnprotDisassocRx,
8152 pAdapter->hdd_stats.hddPmfStats.
8153 numUnprotDeauthRx);
8154
8155 wrqu->data.length = strlen(extra) + 1;
8156 break;
8157 }
8158#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008159 case WE_GET_IBSS_STA_INFO:
8160 {
8161 hdd_station_ctx_t *pHddStaCtx =
8162 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8163 int idx = 0;
8164 int length = 0, buf = 0;
8165
Naveen Rawatc45d1622016-07-05 12:20:09 -07008166 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008167 if (0 != pHddStaCtx->conn_info.staId[idx]) {
8168 buf = snprintf
8169 ((extra + length),
8170 WE_MAX_STR_LEN - length,
8171 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
8172 pHddStaCtx->conn_info.staId[idx],
8173 pHddStaCtx->conn_info.
8174 peerMacAddress[idx].bytes[0],
8175 pHddStaCtx->conn_info.
8176 peerMacAddress[idx].bytes[1],
8177 pHddStaCtx->conn_info.
8178 peerMacAddress[idx].bytes[2],
8179 pHddStaCtx->conn_info.
8180 peerMacAddress[idx].bytes[3],
8181 pHddStaCtx->conn_info.
8182 peerMacAddress[idx].bytes[4],
8183 pHddStaCtx->conn_info.
8184 peerMacAddress[idx].bytes[5]
8185 );
8186 length += buf;
8187 }
8188 }
8189 wrqu->data.length = strlen(extra) + 1;
8190 break;
8191 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008192 case WE_GET_PHYMODE:
8193 {
8194 bool ch_bond24 = false, ch_bond5g = false;
8195 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
8196 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8197 eCsrPhyMode phymode;
8198 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008199 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008200
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008201 sme_config = qdf_mem_malloc(sizeof(*sme_config));
8202 if (!sme_config) {
8203 hdd_err("Out of memory");
8204 ret = -ENOMEM;
8205 break;
8206 }
8207
8208 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008209 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008210 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008211 ch_bond24 = true;
8212
8213 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008214 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008215 ch_bond5g = true;
8216
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008217 qdf_mem_free(sme_config);
8218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008219 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308220 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008221 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008222 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008223 return -EIO;
8224 }
8225
8226 switch (phymode) {
8227 case eCSR_DOT11_MODE_AUTO:
8228 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
8229 break;
8230 case eCSR_DOT11_MODE_11n:
8231 case eCSR_DOT11_MODE_11n_ONLY:
8232 if (currBand == eCSR_BAND_24) {
8233 if (ch_bond24)
8234 snprintf(extra, WE_MAX_STR_LEN,
8235 "11NGHT40");
8236 else
8237 snprintf(extra, WE_MAX_STR_LEN,
8238 "11NGHT20");
8239 } else if (currBand == eCSR_BAND_5G) {
8240 if (ch_bond5g)
8241 snprintf(extra, WE_MAX_STR_LEN,
8242 "11NAHT40");
8243 else
8244 snprintf(extra, WE_MAX_STR_LEN,
8245 "11NAHT20");
8246 } else {
8247 snprintf(extra, WE_MAX_STR_LEN, "11N");
8248 }
8249 break;
8250 case eCSR_DOT11_MODE_abg:
8251 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
8252 break;
8253 case eCSR_DOT11_MODE_11a:
8254 snprintf(extra, WE_MAX_STR_LEN, "11A");
8255 break;
8256 case eCSR_DOT11_MODE_11b:
8257 case eCSR_DOT11_MODE_11b_ONLY:
8258 snprintf(extra, WE_MAX_STR_LEN, "11B");
8259 break;
8260 case eCSR_DOT11_MODE_11g:
8261 case eCSR_DOT11_MODE_11g_ONLY:
8262 snprintf(extra, WE_MAX_STR_LEN, "11G");
8263 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008264 case eCSR_DOT11_MODE_11ac:
8265 case eCSR_DOT11_MODE_11ac_ONLY:
8266 if (hddctx->config->vhtChannelWidth ==
8267 eHT_CHANNEL_WIDTH_20MHZ)
8268 snprintf(extra, WE_MAX_STR_LEN,
8269 "11ACVHT20");
8270 else if (hddctx->config->vhtChannelWidth ==
8271 eHT_CHANNEL_WIDTH_40MHZ)
8272 snprintf(extra, WE_MAX_STR_LEN,
8273 "11ACVHT40");
8274 else if (hddctx->config->vhtChannelWidth ==
8275 eHT_CHANNEL_WIDTH_80MHZ)
8276 snprintf(extra, WE_MAX_STR_LEN,
8277 "11ACVHT80");
8278 else if (hddctx->config->vhtChannelWidth ==
8279 eHT_CHANNEL_WIDTH_160MHZ)
8280 snprintf(extra, WE_MAX_STR_LEN,
8281 "11ACVHT160");
8282 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008283 }
8284
8285 wrqu->data.length = strlen(extra) + 1;
8286 break;
8287 }
8288
8289#ifdef FEATURE_OEM_DATA_SUPPORT
8290 case WE_GET_OEM_DATA_CAP:
8291 {
8292 return iw_get_oem_data_cap(dev, info, wrqu, extra);
8293 }
8294#endif /* FEATURE_OEM_DATA_SUPPORT */
8295 case WE_GET_SNR:
8296 {
8297 int8_t s7snr = 0;
8298 int status = 0;
8299 hdd_context_t *pHddCtx;
8300 hdd_station_ctx_t *pHddStaCtx;
8301 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8302 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308303 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008304 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308305
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008306 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8307 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
8308 eConnectionState_Associated !=
8309 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008310 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008311 pHddCtx->config->fEnableSNRMonitoring,
8312 pHddStaCtx->conn_info.connState);
8313 return -ENONET;
8314 }
8315 wlan_hdd_get_snr(pAdapter, &s7snr);
8316 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
8317 wrqu->data.length = strlen(extra) + 1;
8318 break;
8319 }
8320 default:
8321 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008322 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008323 sub_cmd);
8324 break;
8325 }
8326 }
Dustin Brownd9322482017-01-09 12:46:03 -08008327
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308328 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -08008329 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008330}
8331
8332static int iw_get_char_setnone(struct net_device *dev,
8333 struct iw_request_info *info,
8334 union iwreq_data *wrqu, char *extra)
8335{
8336 int ret;
8337
8338 cds_ssr_protect(__func__);
8339 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
8340 cds_ssr_unprotect(__func__);
8341
8342 return ret;
8343}
8344
8345/**
8346 * iw_setnone_getnone() - Generic "action" private ioctl handler
8347 * @dev: device upon which the ioctl was received
8348 * @info: ioctl request information
8349 * @wrqu: ioctl request data
8350 * @extra: ioctl extra data
8351 *
8352 * Return: 0 on success, non-zero on error
8353 */
8354static int __iw_setnone_getnone(struct net_device *dev,
8355 struct iw_request_info *info,
8356 union iwreq_data *wrqu, char *extra)
8357{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008358 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008359 hdd_context_t *hdd_ctx;
8360 int ret;
8361 int sub_cmd;
8362
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008363 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308364
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008365 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008366 ret = wlan_hdd_validate_context(hdd_ctx);
8367 if (0 != ret)
8368 return ret;
8369
Jeff Johnson441e1f72017-02-07 08:50:49 -08008370 ret = hdd_check_private_wext_control(hdd_ctx, info);
8371 if (0 != ret)
8372 return ret;
8373
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008374#ifdef CONFIG_COMPAT
8375 /* this ioctl is a special case where a sub-ioctl is used and both
8376 * the number of get and set args is 0. in this specific case the
8377 * logic in iwpriv places the sub_cmd in the data.flags portion of
8378 * the iwreq. unfortunately the location of this field will be
8379 * different between 32-bit and 64-bit userspace, and the standard
8380 * compat support in the kernel does not handle this case. so we
8381 * need to explicitly handle it here.
8382 */
8383 if (is_compat_task()) {
8384 struct compat_iw_point *compat_iw_point =
8385 (struct compat_iw_point *)&wrqu->data;
8386 sub_cmd = compat_iw_point->flags;
8387 } else {
8388 sub_cmd = wrqu->data.flags;
8389 }
8390#else
8391 sub_cmd = wrqu->data.flags;
8392#endif
8393
8394 switch (sub_cmd) {
8395 case WE_GET_RECOVERY_STAT:
8396 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008397 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008398 sme_get_recovery_stats(hal);
8399 break;
8400 }
8401
Govind Singha471e5e2015-10-12 17:11:14 +05308402 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008403 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05308404 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
8405 0, DBG_CMD);
8406 break;
8407
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008408 case WE_IBSS_GET_PEER_INFO_ALL:
8409 {
8410 hdd_wlan_get_ibss_peer_info_all(adapter);
8411 break;
8412 }
8413
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008414 case WE_SET_REASSOC_TRIGGER:
8415 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008416 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8417 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308418 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008419 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308420 uint8_t operating_ch =
8421 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008422 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008423
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008424 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008425 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308426 if (roaming_offload_enabled(hdd_ctx)) {
8427 qdf_mem_copy(bssid,
8428 &adapter->sessionCtx.station.conn_info.bssId,
8429 sizeof(bssid));
8430 hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId,
8431 bssid, operating_ch);
8432 } else {
8433 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
8434 NULL, modProfileFields, &roamId, 1);
8435 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008436 return 0;
8437 }
8438
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008439 case WE_STOP_OBSS_SCAN:
8440 {
8441 /*
8442 * 1.OBSS Scan is mandatory while operating in 2.4GHz
8443 * 2.OBSS scan is stopped by Firmware during the disassociation
8444 * 3.OBSS stop comamnd is added for debugging purpose
8445 */
8446 tHalHandle hal;
8447
8448 hal = WLAN_HDD_GET_HAL_CTX(adapter);
8449 if (hal == NULL) {
8450 hdd_err("hal context is NULL");
8451 return -EINVAL;
8452 }
8453 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
8454 }
8455 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008456 default:
8457 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008458 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008459 break;
8460 }
8461 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308462 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008463 return ret;
8464}
8465
8466static int iw_setnone_getnone(struct net_device *dev,
8467 struct iw_request_info *info,
8468 union iwreq_data *wrqu, char *extra)
8469{
8470 int ret;
8471
8472 cds_ssr_protect(__func__);
8473 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
8474 cds_ssr_unprotect(__func__);
8475
8476 return ret;
8477}
8478
Krunal Sonia6e505b2017-01-12 12:25:18 -08008479#ifdef MPC_UT_FRAMEWORK
8480static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
8481 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
8482{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -08008483 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08008484 case WE_POLICY_MANAGER_CLIST_CMD:
8485 {
8486 hdd_err("<iwpriv wlan0 pm_clist> is called");
8487 cds_incr_connection_count_utfw(apps_args[0],
8488 apps_args[1], apps_args[2], apps_args[3],
8489 apps_args[4], apps_args[5], apps_args[6],
8490 apps_args[7]);
8491 }
8492 break;
8493
8494 case WE_POLICY_MANAGER_DLIST_CMD:
8495 {
8496 hdd_err("<iwpriv wlan0 pm_dlist> is called");
8497 cds_decr_connection_count_utfw(apps_args[0],
8498 apps_args[1]);
8499 }
8500 break;
8501
8502 case WE_POLICY_MANAGER_ULIST_CMD:
8503 {
8504 hdd_err("<iwpriv wlan0 pm_ulist> is called");
8505 cds_update_connection_info_utfw(apps_args[0],
8506 apps_args[1], apps_args[2], apps_args[3],
8507 apps_args[4], apps_args[5], apps_args[6],
8508 apps_args[7]);
8509 }
8510 break;
8511
8512 case WE_POLICY_MANAGER_DBS_CMD:
8513 {
8514 hdd_err("<iwpriv wlan0 pm_dbs> is called");
8515 if (apps_args[0] == 0)
8516 wma_set_dbs_capability_ut(0);
8517 else
8518 wma_set_dbs_capability_ut(1);
8519
8520 if (apps_args[1] >= CDS_THROUGHPUT &&
8521 apps_args[1] <= CDS_LATENCY) {
8522 pr_info("setting system pref to [%d]\n", apps_args[1]);
8523 hdd_ctx->config->conc_system_pref = apps_args[1];
8524 }
8525 }
8526 break;
8527
8528 case WE_POLICY_MANAGER_PCL_CMD:
8529 {
8530 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8531 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
8532 uint32_t pcl_len = 0, i = 0;
8533
8534 hdd_err("<iwpriv wlan0 pm_pcl> is called");
8535
8536 cds_get_pcl(apps_args[0],
8537 pcl, &pcl_len,
8538 weight_list, QDF_ARRAY_SIZE(weight_list));
8539 pr_info("PCL list for role[%d] is {", apps_args[0]);
8540 for (i = 0 ; i < pcl_len; i++)
8541 pr_info(" %d, ", pcl[i]);
8542 pr_info("}--------->\n");
8543 }
8544 break;
8545
8546 case WE_POLICY_SET_HW_MODE_CMD:
8547 {
8548 if (apps_args[0] == 0) {
8549 hdd_err("set hw mode for single mac");
8550 cds_pdev_set_hw_mode(
8551 adapter->sessionId,
8552 HW_MODE_SS_2x2,
8553 HW_MODE_80_MHZ,
8554 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8555 HW_MODE_DBS_NONE,
8556 HW_MODE_AGILE_DFS_NONE,
8557 HW_MODE_SBS_NONE,
8558 SIR_UPDATE_REASON_UT);
8559 } else if (apps_args[0] == 1) {
8560 hdd_err("set hw mode for dual mac");
8561 cds_pdev_set_hw_mode(
8562 adapter->sessionId,
8563 HW_MODE_SS_1x1,
8564 HW_MODE_80_MHZ,
8565 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8566 HW_MODE_DBS,
8567 HW_MODE_AGILE_DFS_NONE,
8568 HW_MODE_SBS_NONE,
8569 SIR_UPDATE_REASON_UT);
8570 }
8571 }
8572 break;
8573
8574 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8575 {
8576 enum cds_conc_next_action action;
8577 hdd_notice("<iwpriv wlan0 pm_query_action> is called");
8578 action = cds_current_connections_update(adapter->sessionId,
8579 apps_args[0],
8580 SIR_UPDATE_REASON_UT);
8581 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8582 }
8583 break;
8584
8585 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8586 {
8587 bool allow;
8588 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
8589 allow = cds_allow_concurrency(
8590 apps_args[0], apps_args[1], apps_args[2]);
8591 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8592 }
8593 break;
8594
8595 case WE_POLICY_MANAGER_SCENARIO_CMD:
8596 {
8597 clean_report(hdd_ctx);
8598 if (apps_args[0] == 1) {
8599 wlan_hdd_one_connection_scenario(hdd_ctx);
8600 } else if (apps_args[0] == 2) {
8601 wlan_hdd_two_connections_scenario(hdd_ctx,
8602 6, CDS_TWO_TWO);
8603 wlan_hdd_two_connections_scenario(hdd_ctx,
8604 36, CDS_TWO_TWO);
8605 wlan_hdd_two_connections_scenario(hdd_ctx,
8606 6, CDS_ONE_ONE);
8607 wlan_hdd_two_connections_scenario(hdd_ctx,
8608 36, CDS_ONE_ONE);
8609 } else if (apps_args[0] == 3) {
8610 /* MCC on same band with 2x2 same mac*/
8611 wlan_hdd_three_connections_scenario(hdd_ctx,
8612 6, 11, CDS_TWO_TWO, 0);
8613 /* MCC on diff band with 2x2 same mac*/
8614 wlan_hdd_three_connections_scenario(hdd_ctx,
8615 6, 36, CDS_TWO_TWO, 0);
8616 /* MCC on diff band with 1x1 diff mac */
8617 wlan_hdd_three_connections_scenario(hdd_ctx,
8618 36, 6, CDS_ONE_ONE, 0);
8619 /* MCC on diff band with 1x1 same mac */
8620 wlan_hdd_three_connections_scenario(hdd_ctx,
8621 36, 6, CDS_ONE_ONE, 1);
8622 /* SCC on same band with 2x2 same mac */
8623 wlan_hdd_three_connections_scenario(hdd_ctx,
8624 36, 36, CDS_TWO_TWO, 0);
8625 /* SCC on same band with 1x1 same mac */
8626 wlan_hdd_three_connections_scenario(hdd_ctx,
8627 36, 36, CDS_ONE_ONE, 1);
8628 /* MCC on same band with 2x2 same mac */
8629 wlan_hdd_three_connections_scenario(hdd_ctx,
8630 36, 149, CDS_TWO_TWO, 0);
8631 /* MCC on same band with 1x1 same mac */
8632 wlan_hdd_three_connections_scenario(hdd_ctx,
8633 36, 149, CDS_ONE_ONE, 1);
8634 }
8635 print_report(hdd_ctx);
8636 }
8637 break;
8638 }
8639 return 0;
8640}
8641#else
8642static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
8643 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
8644{
8645 return 0;
8646}
8647#endif
8648
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008649/**
8650 * __iw_set_var_ints_getnone - Generic "set many" 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 * This is an SSR-protected generic handler for private ioctls which
8657 * take multiple arguments. Note that this implementation is also
8658 * somewhat unique in that it is shared by both STA-mode and SAP-mode
8659 * interfaces.
8660 *
8661 * Return: 0 on success, non-zero on error
8662 */
8663static int __iw_set_var_ints_getnone(struct net_device *dev,
8664 struct iw_request_info *info,
8665 union iwreq_data *wrqu, char *extra)
8666{
8667 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8668 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8669 int sub_cmd;
8670 int *apps_args = (int *) extra;
8671 hdd_context_t *hdd_ctx;
8672 int ret, num_args;
8673
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008674 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308675
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008676 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8677 ret = wlan_hdd_validate_context(hdd_ctx);
8678 if (0 != ret)
8679 return ret;
8680
Jeff Johnson441e1f72017-02-07 08:50:49 -08008681 ret = hdd_check_private_wext_control(hdd_ctx, info);
8682 if (0 != ret)
8683 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008684
8685 sub_cmd = wrqu->data.flags;
8686 num_args = wrqu->data.length;
8687
Jeff Johnson99bac312016-06-28 10:38:18 -07008688 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008689
8690 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008691 case WE_IBSS_GET_PEER_INFO:
8692 {
8693 pr_info("Station ID = %d\n", apps_args[0]);
8694 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
8695 }
8696 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008697
8698 case WE_P2P_NOA_CMD:
8699 {
8700 p2p_app_setP2pPs_t p2pNoA;
8701
Krunal Sonif07bb382016-03-10 13:02:11 -08008702 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08008703 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
8704 hdd_device_mode_to_string(
8705 pAdapter->device_mode),
8706 pAdapter->device_mode);
8707 return -EINVAL;
8708 }
8709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008710 p2pNoA.opp_ps = apps_args[0];
8711 p2pNoA.ctWindow = apps_args[1];
8712 p2pNoA.duration = apps_args[2];
8713 p2pNoA.interval = apps_args[3];
8714 p2pNoA.count = apps_args[4];
8715 p2pNoA.single_noa_duration = apps_args[5];
8716 p2pNoA.psSelection = apps_args[6];
8717
Jeff Johnson99bac312016-06-28 10:38:18 -07008718 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
8719 apps_args[0], apps_args[1], apps_args[2],
8720 apps_args[3], apps_args[4],
8721 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008722
8723 hdd_set_p2p_ps(dev, &p2pNoA);
8724
8725 }
8726 break;
8727
8728 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8729 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008730 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
8731 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308732 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008733 }
8734 break;
8735
8736 case WE_MTRACE_DUMP_CMD:
8737 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008738 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
8739 apps_args[0], apps_args[1],
8740 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308741 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008742 apps_args[1], apps_args[2],
8743 apps_args[3]);
8744
8745 }
8746 break;
8747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008748 case WE_POLICY_MANAGER_CINFO_CMD:
8749 {
8750 struct cds_conc_connection_info *conn_info;
8751 uint32_t i = 0, len = 0;
8752
Krunal Sonia6e505b2017-01-12 12:25:18 -08008753 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008754 conn_info = cds_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008755 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008756 for (i = 0; i < len; i++) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08008757 pr_info("|table_index[%d]\t\t\n", i);
8758 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
8759 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
8760 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
8761 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
8762 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
8763 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
8764 pr_info("+--------------------------+\n");
8765 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008766 }
8767 }
8768 break;
8769
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008770
8771#ifdef FEATURE_WLAN_TDLS
8772 case WE_TDLS_CONFIG_PARAMS:
8773 {
8774 tdls_config_params_t tdlsParams;
8775
8776 tdlsParams.tdls = apps_args[0];
8777 tdlsParams.tx_period_t = apps_args[1];
8778 tdlsParams.tx_packet_n = apps_args[2];
8779 /* ignore args[3] as discovery_period is not used anymore */
8780 tdlsParams.discovery_tries_n = apps_args[4];
8781 /* ignore args[5] as idle_timeout is not used anymore */
8782 tdlsParams.idle_packet_n = apps_args[6];
8783 /* ignore args[7] as rssi_hysteresis is not used anymore */
8784 tdlsParams.rssi_trigger_threshold = apps_args[8];
8785 tdlsParams.rssi_teardown_threshold = apps_args[9];
8786 tdlsParams.rssi_delta = apps_args[10];
8787
8788 wlan_hdd_tdls_set_params(dev, &tdlsParams);
8789 }
8790 break;
8791#endif
8792 case WE_UNIT_TEST_CMD:
8793 {
8794 t_wma_unit_test_cmd *unitTestArgs;
Rajeev Kumarea95edd2017-01-11 20:49:36 -08008795 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008796 int i, j;
8797 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8798 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008799 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008800 apps_args[0]);
8801 return -EINVAL;
8802 }
Anurag Chouhan77564182016-09-03 16:38:01 +05308803 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
8804 (apps_args[1] < 0)) {
8805 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008806 apps_args[1]);
8807 return -EINVAL;
8808 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308809 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008810 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008811 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008812 return -ENOMEM;
8813 }
8814 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
8815 unitTestArgs->module_id = apps_args[0];
8816 unitTestArgs->num_args = apps_args[1];
8817 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
8818 unitTestArgs->args[i] = apps_args[j];
8819 }
8820 msg.type = SIR_HAL_UNIT_TEST_CMD;
8821 msg.reserved = 0;
8822 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308823 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarea95edd2017-01-11 20:49:36 -08008824 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308825 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -07008826 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008827 return -EINVAL;
8828 }
8829 }
8830 break;
8831#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8832 case WE_LED_FLASHING_PARAM:
8833 {
8834 int i;
8835 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008836 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008837 return -EINVAL;
8838 }
8839 for (i = 0; i < num_args; i++) {
8840 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008841 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008842 return -EINVAL;
8843 }
8844 }
8845 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8846 0, apps_args[0], apps_args[1]);
8847 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8848 1, apps_args[2], apps_args[3]);
8849 }
8850 break;
8851#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05308852 case WE_SET_PKTLOG:
8853 {
8854 int ret;
8855
8856 if (num_args < 1 || num_args > 2) {
8857 hdd_err("pktlog: either 1 or 2 parameters are required");
8858 return -EINVAL;
8859 }
8860
8861 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
8862 apps_args[1]);
8863 if (ret)
8864 return ret;
8865 break;
8866 }
8867
Manjeet Singhf82ed072016-07-08 11:40:00 +05308868 case WE_MAC_PWR_DEBUG_CMD:
8869 {
8870 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
8871 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8872 int i, j;
8873
8874 if (num_args < 3) {
8875 hdd_err("number of arguments can't be null %d",
8876 num_args);
8877 return -EINVAL;
8878 }
8879 if (num_args - 3 != apps_args[2]) {
8880 hdd_err("arg list of size %d doesn't match num_args %d",
8881 num_args-3, apps_args[2]);
8882 return -EINVAL;
8883 }
8884 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8885 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8886 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8887 return -EINVAL;
8888 }
8889 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8890 hdd_err("Too Many args %d", apps_args[2]);
8891 return -EINVAL;
8892 }
8893 mac_pwr_dbg_args.pdev_id = apps_args[0];
8894 mac_pwr_dbg_args.module_id = apps_args[1];
8895 mac_pwr_dbg_args.num_args = apps_args[2];
8896
8897 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8898 mac_pwr_dbg_args.args[i] = apps_args[j];
8899
8900 if (QDF_STATUS_SUCCESS !=
8901 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
8902 &mac_pwr_dbg_args)) {
8903 return -EINVAL;
8904 }
8905 }
8906 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -08008907 case WE_POLICY_MANAGER_CLIST_CMD:
8908 case WE_POLICY_MANAGER_DLIST_CMD:
8909 case WE_POLICY_MANAGER_ULIST_CMD:
8910 case WE_POLICY_MANAGER_DBS_CMD:
8911 case WE_POLICY_MANAGER_PCL_CMD:
8912 case WE_POLICY_SET_HW_MODE_CMD:
8913 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8914 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8915 case WE_POLICY_MANAGER_SCENARIO_CMD:
8916 {
8917 iw_get_policy_manager_ut_ops(hdd_ctx, pAdapter,
8918 sub_cmd, apps_args);
8919 }
8920 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008921 default:
8922 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008923 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008924 }
8925 break;
8926 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308927 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008928 return 0;
8929}
8930
8931/**
8932 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8933 * @dev: pointer to net_device structure
8934 * @info: pointer to iw_request_info structure
8935 * @wrqu: pointer to iwreq_data
8936 * @extra; extra
8937 *
8938 * Return: 0 on success, error number otherwise
8939 *
8940 */
8941static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8942 struct iw_request_info *info,
8943 union iwreq_data *wrqu, char *extra)
8944{
8945 union iwreq_data u_priv_wrqu;
8946 int apps_args[MAX_VAR_ARGS] = {0};
8947 int ret, num_args;
8948
Mukul Sharma64a70e82015-11-02 20:05:09 +05308949 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008950 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308951 return -EPERM;
8952 }
8953
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008954 /* Helper function to get iwreq_data with compat handling. */
8955 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8956 return -EINVAL;
8957
8958 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008959 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008960 return -EINVAL;
8961 }
8962
8963 num_args = u_priv_wrqu.data.length;
8964 if (num_args > MAX_VAR_ARGS)
8965 num_args = MAX_VAR_ARGS;
8966
8967 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8968 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008969 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008970 return -EFAULT;
8971 }
8972
8973 cds_ssr_protect(__func__);
8974 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8975 (char *)&apps_args);
8976 cds_ssr_unprotect(__func__);
8977 return ret;
8978}
8979
8980/**
8981 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8982 * @dev: device upon which the ioctl was received
8983 * @info: ioctl request information
8984 * @wrqu: ioctl request data
8985 * @extra: ioctl extra data
8986 *
8987 * This is a generic handler for private ioctls which take multiple
8988 * arguments. Note that this implementation is also somewhat unique
8989 * in that it is shared by both STA-mode and SAP-mode interfaces.
8990 *
8991 * Return: 0 on success, non-zero on error
8992 */
8993int iw_set_var_ints_getnone(struct net_device *dev,
8994 struct iw_request_info *info,
8995 union iwreq_data *wrqu, char *extra)
8996{
8997 int ret;
8998
8999 cds_ssr_protect(__func__);
9000 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
9001 cds_ssr_unprotect(__func__);
9002 return ret;
9003}
9004
9005/**
9006 * iw_add_tspec - Add TSpec private ioctl handler
9007 * @dev: device upon which the ioctl was received
9008 * @info: ioctl request information
9009 * @wrqu: ioctl request data
9010 * @extra: ioctl extra data
9011 *
9012 * Return: 0 on success, non-zero on error
9013 */
9014static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
9015 union iwreq_data *wrqu, char *extra)
9016{
9017 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9018 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9019 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9020 int params[HDD_WLAN_WMM_PARAM_COUNT];
9021 sme_QosWmmTspecInfo tSpec;
9022 uint32_t handle;
9023 struct iw_point s_priv_data;
9024 hdd_context_t *hdd_ctx;
9025 int ret;
9026
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009027 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309028
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009029 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9030 ret = wlan_hdd_validate_context(hdd_ctx);
9031 if (0 != ret)
9032 return ret;
9033
Jeff Johnson441e1f72017-02-07 08:50:49 -08009034 ret = hdd_check_private_wext_control(hdd_ctx, info);
9035 if (0 != ret)
9036 return ret;
9037
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009038 /* make sure the application is sufficiently priviledged */
9039 /* note that the kernel will do this for "set" ioctls, but since */
9040 /* this ioctl wants to return status to user space it must be */
9041 /* defined as a "get" ioctl */
9042 if (!capable(CAP_NET_ADMIN)) {
9043 return -EPERM;
9044 }
9045
9046 /* we must be associated in order to add a tspec */
9047 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
9048 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9049 return 0;
9050 }
9051 /* since we are defined to be a "get" ioctl, and since the number */
9052 /* of params exceeds the number of params that wireless extensions */
9053 /* will pass down in the iwreq_data, we must copy the "set" params. */
9054 /* We must handle the compat for iwreq_data in 32U/64K environment. */
9055
9056 /* helper function to get iwreq_data with compat handling. */
9057 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
9058 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9059 return 0;
9060 }
9061 /* make sure all params are correctly passed to function */
9062 if ((NULL == s_priv_data.pointer) ||
9063 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
9064 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9065 return 0;
9066 }
9067 /* from user space ourselves */
9068 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
9069 /* hmmm, can't get them */
9070 return -EIO;
9071 }
9072 /* clear the tspec */
9073 memset(&tSpec, 0, sizeof(tSpec));
9074
9075 /* validate the handle */
9076 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9077 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9078 /* that one is reserved */
9079 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9080 return 0;
9081 }
9082 /* validate the TID */
9083 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
9084 /* out of range */
9085 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9086 return 0;
9087 }
9088 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
9089
9090 /* validate the direction */
9091 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
9092 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
9093 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
9094 break;
9095
9096 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
9097 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
9098 break;
9099
9100 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
9101 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
9102 break;
9103
9104 default:
9105 /* unknown */
9106 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9107 return 0;
9108 }
9109
9110 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
9111
9112 /* validate the user priority */
9113 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
9114 /* out of range */
9115 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9116 return 0;
9117 }
9118 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
9119 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009120 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009121 return 0;
9122 }
9123
Jeff Johnson99bac312016-06-28 10:38:18 -07009124 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009125 tSpec.ts_info.psb, tSpec.ts_info.up);
9126
9127 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
9128 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
9129 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
9130 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
9131 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
9132 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
9133 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
9134 tSpec.surplus_bw_allowance =
9135 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
9136 tSpec.min_service_interval =
9137 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
9138 tSpec.max_service_interval =
9139 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
9140 tSpec.suspension_interval =
9141 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
9142 tSpec.inactivity_interval =
9143 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
9144
9145 tSpec.ts_info.burst_size_defn =
9146 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
9147
9148 /* validate the ts info ack policy */
9149 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
9150 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
9151 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
9152 break;
9153
9154 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
9155 tSpec.ts_info.ack_policy =
9156 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
9157 break;
9158
9159 default:
9160 /* unknown */
9161 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9162 return 0;
9163 }
9164
9165 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309166 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009167 return 0;
9168}
9169
9170static int iw_add_tspec(struct net_device *dev,
9171 struct iw_request_info *info,
9172 union iwreq_data *wrqu, char *extra)
9173{
9174 int ret;
9175
9176 cds_ssr_protect(__func__);
9177 ret = __iw_add_tspec(dev, info, wrqu, extra);
9178 cds_ssr_unprotect(__func__);
9179
9180 return ret;
9181}
9182
9183/**
9184 * iw_del_tspec - Delete TSpec private ioctl handler
9185 * @dev: device upon which the ioctl was received
9186 * @info: ioctl request information
9187 * @wrqu: ioctl request data
9188 * @extra: ioctl extra data
9189 *
9190 * Return: 0 on success, non-zero on error
9191 */
9192static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
9193 union iwreq_data *wrqu, char *extra)
9194{
9195 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9196 hdd_context_t *hdd_ctx;
9197 int *params = (int *)extra;
9198 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9199 uint32_t handle;
9200 int ret;
9201
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009202 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309203
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009204 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9205 ret = wlan_hdd_validate_context(hdd_ctx);
9206 if (0 != ret)
9207 return ret;
9208
Jeff Johnson441e1f72017-02-07 08:50:49 -08009209 ret = hdd_check_private_wext_control(hdd_ctx, info);
9210 if (0 != ret)
9211 return ret;
9212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009213 /* make sure the application is sufficiently priviledged */
9214 /* note that the kernel will do this for "set" ioctls, but since */
9215 /* this ioctl wants to return status to user space it must be */
9216 /* defined as a "get" ioctl */
9217 if (!capable(CAP_NET_ADMIN)) {
9218 return -EPERM;
9219 }
9220
9221 /* although we are defined to be a "get" ioctl, the params we require */
9222 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9223 /* is no need to copy the params from user space */
9224
9225 /* validate the handle */
9226 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9227 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9228 /* that one is reserved */
9229 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9230 return 0;
9231 }
9232
9233 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309234 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009235 return 0;
9236}
9237
9238static int iw_del_tspec(struct net_device *dev,
9239 struct iw_request_info *info,
9240 union iwreq_data *wrqu, char *extra)
9241{
9242 int ret;
9243
9244 cds_ssr_protect(__func__);
9245 ret = __iw_del_tspec(dev, info, wrqu, extra);
9246 cds_ssr_unprotect(__func__);
9247
9248 return ret;
9249}
9250
9251/**
9252 * iw_get_tspec - Get TSpec private ioctl handler
9253 * @dev: device upon which the ioctl was received
9254 * @info: ioctl request information
9255 * @wrqu: ioctl request data
9256 * @extra: ioctl extra data
9257 *
9258 * Return: 0 on success, non-zero on error
9259 */
9260static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
9261 union iwreq_data *wrqu, char *extra)
9262{
9263 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9264 hdd_context_t *hdd_ctx;
9265 int *params = (int *)extra;
9266 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9267 uint32_t handle;
9268 int ret;
9269
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009270 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309271
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009272 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9273 ret = wlan_hdd_validate_context(hdd_ctx);
9274 if (0 != ret)
9275 return ret;
9276
Jeff Johnson441e1f72017-02-07 08:50:49 -08009277 ret = hdd_check_private_wext_control(hdd_ctx, info);
9278 if (0 != ret)
9279 return ret;
9280
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009281 /* although we are defined to be a "get" ioctl, the params we require */
9282 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9283 /* is no need to copy the params from user space */
9284
9285 /* validate the handle */
9286 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9287 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9288 /* that one is reserved */
9289 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9290 return 0;
9291 }
9292
9293 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309294 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009295 return 0;
9296}
9297
9298static int iw_get_tspec(struct net_device *dev,
9299 struct iw_request_info *info,
9300 union iwreq_data *wrqu, char *extra)
9301{
9302 int ret;
9303
9304 cds_ssr_protect(__func__);
9305 ret = __iw_get_tspec(dev, info, wrqu, extra);
9306 cds_ssr_unprotect(__func__);
9307
9308 return ret;
9309}
9310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009311/**
9312 * iw_set_fties - Set FT IEs private ioctl handler
9313 * @dev: device upon which the ioctl was received
9314 * @info: ioctl request information
9315 * @wrqu: ioctl request data
9316 * @extra: ioctl extra data
9317 *
9318 * Each time the supplicant has the auth_request or reassoc request
9319 * IEs ready they are pushed to the driver. The driver will in turn
9320 * use it to send out the auth req and reassoc req for 11r FT Assoc.
9321 *
9322 * Return: 0 on success, non-zero on error
9323 */
9324static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
9325 union iwreq_data *wrqu, char *extra)
9326{
9327 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9328 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9329 hdd_context_t *hdd_ctx;
9330 int ret;
9331
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009332 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309333
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009334 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9335 ret = wlan_hdd_validate_context(hdd_ctx);
9336 if (0 != ret)
9337 return ret;
9338
Jeff Johnson441e1f72017-02-07 08:50:49 -08009339 ret = hdd_check_private_wext_control(hdd_ctx, info);
9340 if (0 != ret)
9341 return ret;
9342
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009343 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009344 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009345 return -EINVAL;
9346 }
9347 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009348 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009349 return -EINVAL;
9350 }
9351 /* Added for debug on reception of Re-assoc Req. */
9352 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009353 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009354 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -07009355 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009356 }
Jeff Johnson99bac312016-06-28 10:38:18 -07009357 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009358
9359 /* Pass the received FT IEs to SME */
9360 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
9361 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309362 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009363 return 0;
9364}
9365
9366static int iw_set_fties(struct net_device *dev,
9367 struct iw_request_info *info,
9368 union iwreq_data *wrqu, char *extra)
9369{
9370 int ret;
9371
9372 cds_ssr_protect(__func__);
9373 ret = __iw_set_fties(dev, info, wrqu, extra);
9374 cds_ssr_unprotect(__func__);
9375
9376 return ret;
9377}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009378
Dustin Brown0cbc7572016-12-16 13:54:40 -08009379/**
9380 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
9381 * @dev: device upon which the ioctl was received
9382 * @info: ioctl request information
9383 * @wrqu: ioctl request data
9384 * @extra: ioctl extra data
9385 *
Dustin Brown860566f2017-01-31 15:24:43 -08009386 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
9387 * time being to provide guidance in migrating to standard APIs.
9388 *
Dustin Brown0cbc7572016-12-16 13:54:40 -08009389 * Return: 0 on success, non-zero on error
9390 */
9391static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
9392 struct iw_request_info *info,
9393 union iwreq_data *wrqu,
9394 char *extra)
9395{
Dustin Brown860566f2017-01-31 15:24:43 -08009396 hdd_err("\n"
9397 "setMCBCFilter is obsolete. Use the following instead:\n"
9398 "Configure multicast filtering via the ‘ip’ command.\n"
9399 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
9400 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
9401 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
9402 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
9403 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Dustin Brown0cbc7572016-12-16 13:54:40 -08009404
Dustin Brown860566f2017-01-31 15:24:43 -08009405 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -08009406}
9407
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009408/**
9409 * iw_set_host_offload - Set host offload ioctl handler
9410 * @dev: device upon which the ioctl was received
9411 * @info: ioctl request information
9412 * @wrqu: ioctl request data
9413 * @extra: ioctl extra data
9414 *
9415 * Return: 0 on success, non-zero on error
9416 */
9417static int __iw_set_host_offload(struct net_device *dev,
9418 struct iw_request_info *info,
9419 union iwreq_data *wrqu, char *extra)
9420{
9421 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9422 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
9423 tSirHostOffloadReq offloadRequest;
9424 hdd_context_t *hdd_ctx;
9425 int ret;
9426
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009427 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309428
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009429 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9430 ret = wlan_hdd_validate_context(hdd_ctx);
9431 if (0 != ret)
9432 return ret;
9433
Jeff Johnson441e1f72017-02-07 08:50:49 -08009434 ret = hdd_check_private_wext_control(hdd_ctx, info);
9435 if (0 != ret)
9436 return ret;
9437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009438 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009439 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009440 return -EINVAL;
9441 }
9442
9443 /* Debug display of request components. */
9444 switch (pRequest->offloadType) {
9445 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07009446 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009447 switch (pRequest->enableOrDisable) {
9448 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009449 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009450 break;
9451 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009452 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009453 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009454 hdd_warn(" ARP offload enable");
9455 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009456 pRequest->params.hostIpv4Addr[0],
9457 pRequest->params.hostIpv4Addr[1],
9458 pRequest->params.hostIpv4Addr[2],
9459 pRequest->params.hostIpv4Addr[3]);
9460 }
9461 break;
9462
9463 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07009464 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009465 switch (pRequest->enableOrDisable) {
9466 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009467 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009468 break;
9469 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009470 hdd_info(" enable");
9471 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009472 *(uint16_t *) (pRequest->params.hostIpv6Addr),
9473 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9474 2),
9475 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9476 4),
9477 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9478 6),
9479 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9480 8),
9481 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9482 10),
9483 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9484 12),
9485 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9486 14));
9487 }
9488 }
9489
9490 /* Execute offload request. The reason that we can copy the
9491 * request information from the ioctl structure to the SME
9492 * structure is that they are laid out exactly the same.
9493 * Otherwise, each piece of information would have to be
9494 * copied individually.
9495 */
9496 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309497 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009498 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
9499 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009500 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009501 return -EINVAL;
9502 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309503 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009504 return 0;
9505}
9506
9507static int iw_set_host_offload(struct net_device *dev,
9508 struct iw_request_info *info,
9509 union iwreq_data *wrqu, char *extra)
9510{
9511 int ret;
9512
9513 cds_ssr_protect(__func__);
9514 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9515 cds_ssr_unprotect(__func__);
9516
9517 return ret;
9518}
9519
9520/**
9521 * iw_set_keepalive_params - Set keepalive params ioctl handler
9522 * @dev: device upon which the ioctl was received
9523 * @info: ioctl request information
9524 * @wrqu: ioctl request data
9525 * @extra: ioctl extra data
9526 *
9527 * Return: 0 on success, non-zero on error
9528 */
9529static int __iw_set_keepalive_params(struct net_device *dev,
9530 struct iw_request_info *info,
9531 union iwreq_data *wrqu, char *extra)
9532{
9533 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009534 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009535 hdd_context_t *hdd_ctx;
9536 int ret;
9537
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009538 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009540 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9541 ret = wlan_hdd_validate_context(hdd_ctx);
9542 if (0 != ret)
9543 return ret;
9544
Jeff Johnson441e1f72017-02-07 08:50:49 -08009545 ret = hdd_check_private_wext_control(hdd_ctx, info);
9546 if (0 != ret)
9547 return ret;
9548
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009549 if (wrqu->data.length != sizeof(*request)) {
9550 hdd_err("Invalid length %d", wrqu->data.length);
9551 return -EINVAL;
9552 }
9553
9554 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
9555 hdd_err("Value of timePeriod %d exceed Max limit %d",
9556 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009557 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
9558 return -EINVAL;
9559 }
9560
9561 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009562 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
9563 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009564
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009565 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009566 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009567 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009568 break;
9569
9570 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009571 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009572
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009573 hdd_info("Host IP address: %d.%d.%d.%d",
9574 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
9575 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009576
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009577 hdd_info("Dest IP address: %d.%d.%d.%d",
9578 request->destIpv4Addr[0], request->destIpv4Addr[1],
9579 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009580
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08009581 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
9582 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009583 break;
9584 }
9585
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009586 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009587
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309588 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009589 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009590 pAdapter->sessionId, request)) {
9591 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009592 return -EINVAL;
9593 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309594 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009595 return 0;
9596}
9597
9598static int iw_set_keepalive_params(struct net_device *dev,
9599 struct iw_request_info *info,
9600 union iwreq_data *wrqu,
9601 char *extra)
9602{
9603 int ret;
9604
9605 cds_ssr_protect(__func__);
9606 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9607 cds_ssr_unprotect(__func__);
9608
9609 return ret;
9610}
9611
9612#ifdef WLAN_FEATURE_PACKET_FILTERING
9613/**
9614 * wlan_hdd_set_filter() - Set packet filter
9615 * @hdd_ctx: Global HDD context
9616 * @request: Packet filter request struct
9617 * @sessionId: Target session for the request
9618 *
9619 * Return: 0 on success, non-zero on error
9620 */
9621static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
9622 struct pkt_filter_cfg *request,
9623 uint8_t sessionId)
9624{
9625 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9626 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9627 int i = 0;
9628
9629 if (hdd_ctx->config->disablePacketFilter) {
9630 hdd_err("packet filtering disabled in ini returning");
9631 return 0;
9632 }
9633
9634 /* Debug display of request components. */
9635 hdd_info("Packet Filter Request : FA %d params %d",
9636 request->filter_action, request->num_params);
9637
9638 switch (request->filter_action) {
9639 case HDD_RCV_FILTER_SET:
9640 hdd_info("Set Packet Filter Request for Id: %d",
9641 request->filter_id);
9642
9643 packetFilterSetReq.filterId = request->filter_id;
9644 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
9645 hdd_err("Number of Params exceed Max limit %d",
9646 request->num_params);
9647 return -EINVAL;
9648 }
9649 packetFilterSetReq.numFieldParams = request->num_params;
9650 packetFilterSetReq.coalesceTime = 0;
9651 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9652 for (i = 0; i < request->num_params; i++) {
9653 packetFilterSetReq.paramsData[i].protocolLayer =
9654 request->params_data[i].protocol_layer;
9655 packetFilterSetReq.paramsData[i].cmpFlag =
9656 request->params_data[i].compare_flag;
9657 packetFilterSetReq.paramsData[i].dataOffset =
9658 request->params_data[i].data_offset;
9659 packetFilterSetReq.paramsData[i].dataLength =
9660 request->params_data[i].data_length;
9661 packetFilterSetReq.paramsData[i].reserved = 0;
9662
Dustin Brown4d1e8462016-12-14 12:12:24 -08009663 if (request->params_data[i].data_offset >
9664 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
9665 hdd_err("Invalid data offset %u for param %d (max = %d)",
9666 request->params_data[i].data_offset,
9667 i,
9668 SIR_MAX_FILTER_TEST_DATA_OFFSET);
9669 return -EINVAL;
9670 }
9671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009672 if (request->params_data[i].data_length >
9673 SIR_MAX_FILTER_TEST_DATA_LEN) {
9674 hdd_err("Error invalid data length %d",
9675 request->params_data[i].data_length);
9676 return -EINVAL;
9677 }
9678
9679 hdd_info("Proto %d Comp Flag %d Filter Type %d",
9680 request->params_data[i].protocol_layer,
9681 request->params_data[i].compare_flag,
9682 packetFilterSetReq.filterType);
9683
9684 hdd_info("Data Offset %d Data Len %d",
9685 request->params_data[i].data_offset,
9686 request->params_data[i].data_length);
9687
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07009688 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
9689 < (request->params_data[i].data_length)) {
9690 hdd_err("Error invalid data length %d",
9691 request->params_data[i].data_length);
9692 return -EINVAL;
9693 }
9694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009695 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9696 request->params_data[i].compare_data,
9697 request->params_data[i].data_length);
9698 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9699 request->params_data[i].data_mask,
9700 request->params_data[i].data_length);
9701
9702 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
9703 request->params_data[i].compare_data[0],
9704 request->params_data[i].compare_data[1],
9705 request->params_data[i].compare_data[2],
9706 request->params_data[i].compare_data[3],
9707 request->params_data[i].compare_data[4],
9708 request->params_data[i].compare_data[5]);
9709
9710 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
9711 request->params_data[i].data_mask[0],
9712 request->params_data[i].data_mask[1],
9713 request->params_data[i].data_mask[2],
9714 request->params_data[i].data_mask[3],
9715 request->params_data[i].data_mask[4],
9716 request->params_data[i].data_mask[5]);
9717 }
9718
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309719 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009720 sme_receive_filter_set_filter(hdd_ctx->hHal,
9721 &packetFilterSetReq,
9722 sessionId)) {
9723 hdd_err("Failure to execute Set Filter");
9724 return -EINVAL;
9725 }
9726
9727 break;
9728
9729 case HDD_RCV_FILTER_CLEAR:
9730
9731 hdd_info("Clear Packet Filter Request for Id: %d",
9732 request->filter_id);
9733 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309734 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009735 sme_receive_filter_clear_filter(hdd_ctx->hHal,
9736 &packetFilterClrReq,
9737 sessionId)) {
9738 hdd_err("Failure to execute Clear Filter");
9739 return -EINVAL;
9740 }
9741 break;
9742
9743 default:
9744 hdd_err("Packet Filter Request: Invalid %d",
9745 request->filter_action);
9746 return -EINVAL;
9747 }
9748 return 0;
9749}
9750
9751/**
9752 * __iw_set_packet_filter_params() - set packet filter parameters in target
9753 * @dev: Pointer to netdev
9754 * @info: Pointer to iw request info
9755 * @wrqu: Pointer to data
9756 * @extra: Pointer to extra data
9757 *
9758 * Return: 0 on success, non-zero on error
9759 */
9760static int __iw_set_packet_filter_params(struct net_device *dev,
9761 struct iw_request_info *info,
9762 union iwreq_data *wrqu, char *extra)
9763{
9764 int ret;
9765 hdd_context_t *hdd_ctx;
9766 struct iw_point priv_data;
9767 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9768 struct pkt_filter_cfg *request = NULL;
9769
Mukul Sharma472382f2015-11-02 20:16:31 +05309770 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009771 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309772 return -EPERM;
9773 }
9774
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009775 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309776
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009777 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9778 ret = wlan_hdd_validate_context(hdd_ctx);
9779 if (0 != ret)
9780 return ret;
9781
Jeff Johnson441e1f72017-02-07 08:50:49 -08009782 ret = hdd_check_private_wext_control(hdd_ctx, info);
9783 if (0 != ret)
9784 return ret;
9785
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009786 if (hdd_priv_get_data(&priv_data, wrqu)) {
9787 hdd_err("failed to get priv data");
9788 return -EINVAL;
9789 }
9790
9791 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
9792 hdd_err("invalid priv data %p or invalid priv data length %d",
9793 priv_data.pointer, priv_data.length);
9794 return -EINVAL;
9795 }
9796
9797 /* copy data using copy_from_user */
9798 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9799 priv_data.length);
9800 if (NULL == request) {
9801 hdd_err("mem_alloc_copy_from_user_helper fail");
9802 return -ENOMEM;
9803 }
9804
9805 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
9806
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07009807 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309808 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009809 return ret;
9810}
9811
9812/**
9813 * iw_set_packet_filter_params() - set packet filter parameters in target
9814 * @dev: Pointer to netdev
9815 * @info: Pointer to iw request info
9816 * @wrqu: Pointer to data
9817 * @extra: Pointer to extra data
9818 *
9819 * Return: 0 on success, non-zero on error
9820 */
9821static int iw_set_packet_filter_params(struct net_device *dev,
9822 struct iw_request_info *info,
9823 union iwreq_data *wrqu, char *extra)
9824{
9825 int ret;
9826
9827 cds_ssr_protect(__func__);
9828 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9829 cds_ssr_unprotect(__func__);
9830
9831 return ret;
9832}
9833#endif
9834
9835
9836static int __iw_get_statistics(struct net_device *dev,
9837 struct iw_request_info *info,
9838 union iwreq_data *wrqu, char *extra)
9839{
9840
Anurag Chouhance0dc992016-02-16 18:18:03 +05309841 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309842 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009843 hdd_wext_state_t *pWextState;
9844 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9845 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9846 char *p = extra;
9847 int tlen = 0;
9848 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
9849 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
9850 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
9851 int ret;
9852
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009853 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009854
9855 ret = wlan_hdd_validate_context(hdd_ctx);
9856 if (0 != ret)
9857 return ret;
9858
Jeff Johnson441e1f72017-02-07 08:50:49 -08009859 ret = hdd_check_private_wext_control(hdd_ctx, info);
9860 if (0 != ret)
9861 return ret;
9862
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009863 if (eConnectionState_Associated !=
9864 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9865
9866 wrqu->txpower.value = 0;
9867 } else {
9868 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9869 SME_SUMMARY_STATS |
9870 SME_GLOBAL_CLASSA_STATS |
9871 SME_GLOBAL_CLASSB_STATS |
9872 SME_GLOBAL_CLASSC_STATS |
9873 SME_GLOBAL_CLASSD_STATS |
9874 SME_PER_STA_STATS,
9875 hdd_statistics_cb, 0, false,
9876 (WLAN_HDD_GET_STATION_CTX_PTR
9877 (pAdapter))->conn_info.staId[0],
9878 pAdapter, pAdapter->sessionId);
9879
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309880 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009881 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009882 return -EINVAL;
9883 }
9884
9885 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9886
Anurag Chouhance0dc992016-02-16 18:18:03 +05309887 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05309888 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009889 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +05309890 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009891 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009892 /*Remove the SME statistics list by passing NULL in callback argument */
9893 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9894 SME_SUMMARY_STATS |
9895 SME_GLOBAL_CLASSA_STATS |
9896 SME_GLOBAL_CLASSB_STATS |
9897 SME_GLOBAL_CLASSC_STATS |
9898 SME_GLOBAL_CLASSD_STATS |
9899 SME_PER_STA_STATS,
9900 NULL, 0, false,
9901 (WLAN_HDD_GET_STATION_CTX_PTR
9902 (pAdapter))->conn_info.
9903 staId[0], pAdapter,
9904 pAdapter->sessionId);
9905
9906 return -EINVAL;
9907 }
9908 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
9909 (uint8_t) sizeof(pStats->retry_cnt),
9910 (char *)&(pStats->retry_cnt[0]), tlen);
9911
9912 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
9913 (uint8_t) sizeof(pStats->multiple_retry_cnt),
9914 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
9915
9916 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
9917 (uint8_t) sizeof(pStats->tx_frm_cnt),
9918 (char *)&(pStats->tx_frm_cnt[0]), tlen);
9919
9920 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
9921 (uint8_t) sizeof(pStats->rx_frm_cnt),
9922 (char *)&(pStats->rx_frm_cnt), tlen);
9923
9924 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
9925 (uint8_t) sizeof(pStats->frm_dup_cnt),
9926 (char *)&(pStats->frm_dup_cnt), tlen);
9927
9928 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
9929 (uint8_t) sizeof(pStats->fail_cnt),
9930 (char *)&(pStats->fail_cnt[0]), tlen);
9931
9932 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
9933 (uint8_t) sizeof(pStats->rts_fail_cnt),
9934 (char *)&(pStats->rts_fail_cnt), tlen);
9935
9936 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
9937 (uint8_t) sizeof(pStats->ack_fail_cnt),
9938 (char *)&(pStats->ack_fail_cnt), tlen);
9939
9940 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
9941 (uint8_t) sizeof(pStats->rts_succ_cnt),
9942 (char *)&(pStats->rts_succ_cnt), tlen);
9943
9944 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
9945 (uint8_t) sizeof(pStats->rx_discard_cnt),
9946 (char *)&(pStats->rx_discard_cnt), tlen);
9947
9948 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
9949 (uint8_t) sizeof(pStats->rx_error_cnt),
9950 (char *)&(pStats->rx_error_cnt), tlen);
9951
9952 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
9953 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9954 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9955
9956 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
9957 (uint8_t) sizeof(dStats->rx_byte_cnt),
9958 (char *)&(dStats->rx_byte_cnt), tlen);
9959
9960 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
9961 (uint8_t) sizeof(dStats->rx_rate),
9962 (char *)&(dStats->rx_rate), tlen);
9963
9964 /* Transmit rate, in units of 500 kbit/sec */
9965 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
9966 (uint8_t) sizeof(aStats->tx_rate),
9967 (char *)&(aStats->tx_rate), tlen);
9968
9969 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
9970 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
9971 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
9972 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
9973 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
9974 (char *)&(dStats->rx_mc_byte_cnt), tlen);
9975 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
9976 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
9977 (char *)&(dStats->rx_bc_byte_cnt), tlen);
9978 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
9979 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9980 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9981 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
9982 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
9983 (char *)&(dStats->tx_mc_byte_cnt), tlen);
9984 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
9985 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
9986 (char *)&(dStats->tx_bc_byte_cnt), tlen);
9987
9988 wrqu->data.length = tlen;
9989
9990 }
9991
9992 EXIT();
9993
9994 return 0;
9995}
9996
9997static int iw_get_statistics(struct net_device *dev,
9998 struct iw_request_info *info,
9999 union iwreq_data *wrqu, char *extra)
10000{
10001 int ret;
10002
10003 cds_ssr_protect(__func__);
10004 ret = __iw_get_statistics(dev, info, wrqu, extra);
10005 cds_ssr_unprotect(__func__);
10006
10007 return ret;
10008}
10009
10010#ifdef FEATURE_WLAN_SCAN_PNO
10011
10012/*Max Len for PNO notification*/
10013#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070010014static void found_pref_network_cb(void *callbackContext,
10015 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010016{
10017 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
10018 union iwreq_data wrqu;
10019 char buf[MAX_PNO_NOTIFY_LEN + 1];
10020
Jeff Johnson99bac312016-06-28 10:38:18 -070010021 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010022 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
10023
10024 /* create the event */
10025 memset(&wrqu, 0, sizeof(wrqu));
10026 memset(buf, 0, sizeof(buf));
10027
10028 snprintf(buf, MAX_PNO_NOTIFY_LEN,
10029 "QCOM: Found preferred network: %s with RSSI of -%u",
10030 pPrefNetworkFoundInd->ssId.ssId,
10031 (unsigned int)pPrefNetworkFoundInd->rssi);
10032
10033 wrqu.data.pointer = buf;
10034 wrqu.data.length = strlen(buf);
10035
10036 /* send the event */
10037
10038 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
10039
10040}
10041
10042/**
10043 * __iw_set_pno() - Preferred Network Offload ioctl handler
10044 * @dev: device upon which the ioctl was received
10045 * @info: ioctl request information
10046 * @wrqu: ioctl request data
10047 * @extra: ioctl extra data
10048 *
10049 * This function parses a Preferred Network Offload command
10050 * Input is string based and expected to be of the form:
10051 *
10052 * <enable(1) | disable(0)>
10053 * when enabling:
10054 * <number of networks>
10055 * for each network:
10056 * <ssid_len> <ssid> <authentication> <encryption>
10057 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070010058 * <scan_time (seconds)>
10059 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010060 * <suspend mode>
10061 *
10062 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070010063 * 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 -080010064 *
10065 * this translates into:
10066 * -----------------------------
10067 * enable PNO
10068 * 2 networks
10069 * Network 1:
10070 * test - with authentication type 0 and encryption type 0,
10071 * search on 3 channels: 1 6 and 11,
10072 * SSID bcast type is unknown (directed probe will be sent if
10073 * AP not found) and must meet -40dBm RSSI
10074 * Network 2:
10075 * test2 - with authentication type 4 and encryption type 4,
10076 * search on 6 channels 1, 2, 3, 4, 5 and 6
10077 * bcast type is non-bcast (directed probe will be sent)
10078 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010079 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070010080 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010081 */
10082static int __iw_set_pno(struct net_device *dev,
10083 struct iw_request_info *info,
10084 union iwreq_data *wrqu, char *extra)
10085{
10086 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
10087 hdd_context_t *hdd_ctx;
10088 int ret;
10089 int offset;
10090 char *ptr;
10091 uint8_t i, j, params, mode;
10092
10093 /* request is a large struct, so we make it static to avoid
10094 * stack overflow. This API is only invoked via ioctl, so it
10095 * is serialized by the kernel rtnl_lock and hence does not
10096 * need to be reentrant
10097 */
10098 static tSirPNOScanReq request;
10099
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010100 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010101
10102 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10103 ret = wlan_hdd_validate_context(hdd_ctx);
10104 if (ret)
10105 return ret;
10106
Jeff Johnson441e1f72017-02-07 08:50:49 -080010107 ret = hdd_check_private_wext_control(hdd_ctx, info);
10108 if (0 != ret)
10109 return ret;
10110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010111 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
10112
10113 request.enable = 0;
10114 request.ucNetworksCount = 0;
10115
10116 ptr = extra;
10117
10118 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
10119 hdd_err("PNO enable input is not valid %s", ptr);
10120 return -EINVAL;
10121 }
10122
10123 if (0 == request.enable) {
10124 /* Disable PNO, ignore any other params */
10125 memset(&request, 0, sizeof(request));
10126 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
10127 &request, adapter->sessionId,
10128 found_pref_network_cb, adapter);
10129 return 0;
10130 }
10131
10132 ptr += offset;
10133
10134 if (1 !=
10135 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
10136 hdd_err("PNO count input not valid %s", ptr);
10137 return -EINVAL;
10138
10139 }
10140
10141 hdd_info("PNO enable %d networks count %d offset %d",
10142 request.enable, request.ucNetworksCount, offset);
10143
10144 if ((0 == request.ucNetworksCount) ||
10145 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
10146 hdd_err("Network count %d invalid",
10147 request.ucNetworksCount);
10148 return -EINVAL;
10149 }
10150
10151 ptr += offset;
10152
10153 for (i = 0; i < request.ucNetworksCount; i++) {
10154
10155 request.aNetworks[i].ssId.length = 0;
10156
10157 params = sscanf(ptr, "%hhu %n",
10158 &(request.aNetworks[i].ssId.length),
10159 &offset);
10160
10161 if (1 != params) {
10162 hdd_err("PNO ssid length input is not valid %s", ptr);
10163 return -EINVAL;
10164 }
10165
10166 if ((0 == request.aNetworks[i].ssId.length) ||
10167 (request.aNetworks[i].ssId.length > 32)) {
10168 hdd_err("SSID Len %d is not correct for network %d",
10169 request.aNetworks[i].ssId.length, i);
10170 return -EINVAL;
10171 }
10172
10173 /* Advance to SSID */
10174 ptr += offset;
10175
10176 memcpy(request.aNetworks[i].ssId.ssId, ptr,
10177 request.aNetworks[i].ssId.length);
10178 ptr += request.aNetworks[i].ssId.length;
10179
10180 params = sscanf(ptr, "%u %u %hhu %n",
10181 &(request.aNetworks[i].authentication),
10182 &(request.aNetworks[i].encryption),
10183 &(request.aNetworks[i].ucChannelCount),
10184 &offset);
10185
10186 if (3 != params) {
10187 hdd_warn("Incorrect cmd %s", ptr);
10188 return -EINVAL;
10189 }
10190
10191 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
10192 request.aNetworks[i].ssId.length,
10193 request.aNetworks[i].ssId.length,
10194 request.aNetworks[i].ssId.ssId,
10195 request.aNetworks[i].authentication,
10196 request.aNetworks[i].encryption,
10197 request.aNetworks[i].ucChannelCount, offset);
10198
10199 /* Advance to channel list */
10200 ptr += offset;
10201
10202 if (SIR_PNO_MAX_NETW_CHANNELS <
10203 request.aNetworks[i].ucChannelCount) {
10204 hdd_warn("Incorrect number of channels");
10205 return -EINVAL;
10206 }
10207
10208 if (0 != request.aNetworks[i].ucChannelCount) {
10209 for (j = 0; j < request.aNetworks[i].ucChannelCount;
10210 j++) {
10211 if (1 !=
10212 sscanf(ptr, "%hhu %n",
10213 &(request.aNetworks[i].
10214 aChannels[j]), &offset)) {
10215 hdd_err("PNO network channel input is not valid %s",
10216 ptr);
10217 return -EINVAL;
10218 }
10219 /* Advance to next channel number */
10220 ptr += offset;
10221 }
10222 }
10223
10224 if (1 != sscanf(ptr, "%u %n",
10225 &(request.aNetworks[i].bcastNetwType),
10226 &offset)) {
10227 hdd_err("PNO broadcast network type input is not valid %s",
10228 ptr);
10229 return -EINVAL;
10230 }
10231
10232 hdd_notice("PNO bcastNetwType %d offset %d",
10233 request.aNetworks[i].bcastNetwType, offset);
10234
10235 /* Advance to rssi Threshold */
10236 ptr += offset;
10237 if (1 != sscanf(ptr, "%d %n",
10238 &(request.aNetworks[i].rssiThreshold),
10239 &offset)) {
10240 hdd_err("PNO rssi threshold input is not valid %s",
10241 ptr);
10242 return -EINVAL;
10243 }
10244 hdd_notice("PNO rssi %d offset %d",
10245 request.aNetworks[i].rssiThreshold, offset);
10246 /* Advance to next network */
10247 ptr += offset;
10248 } /* For ucNetworkCount */
10249
Dustin Brown43e87292016-10-10 10:38:25 -070010250 request.fast_scan_period = 0;
10251 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
10252 request.fast_scan_period *= MSEC_PER_SEC;
10253 ptr += offset;
10254 }
10255
10256 request.fast_scan_max_cycles = 0;
10257 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
10258 &offset) > 0)
10259 ptr += offset;
10260
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010261 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
10262
10263 request.modePNO = mode;
10264 /* for LA we just expose suspend option */
10265 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
10266 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10267 }
10268
10269 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
10270 &request,
10271 adapter->sessionId,
10272 found_pref_network_cb, adapter);
10273
10274 return 0;
10275}
10276
10277static int iw_set_pno(struct net_device *dev,
10278 struct iw_request_info *info,
10279 union iwreq_data *wrqu, char *extra)
10280{
10281 int ret;
10282
10283 cds_ssr_protect(__func__);
10284 ret = __iw_set_pno(dev, info, wrqu, extra);
10285 cds_ssr_unprotect(__func__);
10286
10287 return ret;
10288}
10289#endif /* FEATURE_WLAN_SCAN_PNO */
10290
10291/* Common function to SetBand */
10292int hdd_set_band(struct net_device *dev, u8 ui_band)
10293{
10294 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10295 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10296 eCsrBand band;
10297
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010298 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010299 hdd_context_t *pHddCtx;
10300 hdd_adapter_list_node_t *pAdapterNode, *pNext;
10301 eCsrBand currBand = eCSR_BAND_MAX;
10302 eCsrBand connectedBand;
10303
10304 pAdapterNode = NULL;
10305 pNext = NULL;
10306 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10307
10308 switch (ui_band) {
10309 case WLAN_HDD_UI_BAND_AUTO:
10310 band = eCSR_BAND_ALL;
10311 break;
10312 case WLAN_HDD_UI_BAND_5_GHZ:
10313 band = eCSR_BAND_5G;
10314 break;
10315 case WLAN_HDD_UI_BAND_2_4_GHZ:
10316 band = eCSR_BAND_24;
10317 break;
10318 default:
10319 band = eCSR_BAND_MAX;
10320 }
10321
Jeff Johnson99bac312016-06-28 10:38:18 -070010322 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010323
10324 if (band == eCSR_BAND_MAX) {
10325 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -070010326 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010327 return -EINVAL;
10328 }
10329
10330 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
10331 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010332 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010333 band, pHddCtx->config->nBandCapability);
10334 return -EIO;
10335 }
10336
10337 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010338 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010339 pHddCtx->config->nBandCapability);
10340 band = pHddCtx->config->nBandCapability;
10341 }
10342
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010343 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010344 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010345 return -EIO;
10346 }
10347
10348 if (currBand != band) {
10349 /* Change band request received.
10350 * Abort pending scan requests, flush the existing scan results,
10351 * and change the band capability
10352 */
Jeff Johnson99bac312016-06-28 10:38:18 -070010353 hdd_notice("Current band value = %u, new setting %u ",
10354 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010355
10356 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010357 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010358 pAdapter = pAdapterNode->pAdapter;
10359 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10360 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053010361 INVALID_SCAN_ID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010362 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10363 connectedBand =
10364 hdd_conn_get_connected_band
10365 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
10366
10367 /* Handling is done only for STA and P2P */
10368 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -080010369 ((pAdapter->device_mode == QDF_STA_MODE)
10370 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010371 &&
10372 (hdd_conn_is_connected
10373 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
10374 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010375 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010376 long lrc;
10377
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010378 /* STA already connected on current
10379 * band, So issue disconnect first,
10380 * then change the band
10381 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010382
Jeff Johnson99bac312016-06-28 10:38:18 -070010383 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010384 hdd_device_mode_to_string(pAdapter->device_mode),
10385 pAdapter->device_mode, currBand, band);
10386 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10387
10388 status =
10389 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
10390 (pAdapter),
10391 pAdapter->sessionId,
10392 eCSR_DISCONNECT_REASON_UNSPECIFIED);
10393
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010394 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010395 hdd_err("csr_roam_disconnect failure, returned %d",
10396 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010397 return -EINVAL;
10398 }
10399
10400 lrc =
10401 wait_for_completion_timeout(&pAdapter->
10402 disconnect_comp_var,
10403 msecs_to_jiffies
10404 (WLAN_WAIT_TIME_DISCONNECT));
10405
10406 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010407 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010408 return -ETIMEDOUT;
10409 }
10410 }
10411
10412 sme_scan_flush_result(hHal);
10413
10414 status =
10415 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
10416 pAdapterNode = pNext;
10417 }
10418
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010419 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010420 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010421 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010422 band);
10423 return -EINVAL;
10424 }
10425 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
10426 }
10427 return 0;
10428}
10429
10430int hdd_set_band_helper(struct net_device *dev, const char *command)
10431{
10432 uint8_t band;
10433 int ret;
10434
10435 /* Convert the band value from ascii to integer */
10436 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
10437 ret = kstrtou8(command, 10, &band);
10438 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010439 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010440 return -EINVAL;
10441 }
10442
10443 return hdd_set_band(dev, band);
10444}
10445
10446static int __iw_set_band_config(struct net_device *dev,
10447 struct iw_request_info *info,
10448 union iwreq_data *wrqu, char *extra)
10449{
Jeff Johnson441e1f72017-02-07 08:50:49 -080010450 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
10451 hdd_context_t *hdd_ctx;
10452 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010453 int *value = (int *)extra;
10454
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010455 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010456
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010457 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010458 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010459 return -EPERM;
10460 }
10461
Jeff Johnson441e1f72017-02-07 08:50:49 -080010462 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10463 ret = hdd_check_private_wext_control(hdd_ctx, info);
10464 if (0 != ret)
10465 return ret;
10466
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010467 return hdd_set_band(dev, value[0]);
10468}
10469
10470static int iw_set_band_config(struct net_device *dev,
10471 struct iw_request_info *info,
10472 union iwreq_data *wrqu, char *extra)
10473{
10474 int ret;
10475
10476 cds_ssr_protect(__func__);
10477 ret = __iw_set_band_config(dev, info, wrqu, extra);
10478 cds_ssr_unprotect(__func__);
10479
10480 return ret;
10481}
10482
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010483/**
10484 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
10485 * @adapter: Handle to adapter
10486 * @chan: Monitor mode channel
10487 * @bandwidth: Capture channel bandwidth
10488 *
10489 * Return: 0 on success else error code.
10490 */
10491static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
10492 uint32_t bandwidth)
10493{
10494 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10495 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
10496 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
10497 QDF_STATUS status;
10498 tHalHandle hal_hdl = hdd_ctx->hHal;
10499 struct qdf_mac_addr bssid;
10500 tCsrRoamProfile roam_profile;
10501 struct ch_params_s ch_params;
10502
10503 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
10504 hdd_err("Not supported, device is not in monitor mode");
10505 return -EINVAL;
10506 }
10507
10508 hdd_info("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080010509 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010510 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
10511 roam_profile.ChannelInfo.numOfChannels = 1;
10512 roam_profile.phyMode = ch_info->phy_mode;
10513 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070010514 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010515
10516 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
10517 QDF_MAC_ADDR_SIZE);
10518
10519 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -070010520 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010521 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
10522 &roam_profile);
10523 if (status) {
10524 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
10525 status);
10526 }
10527
10528 return qdf_status_to_os_return(status);
10529}
10530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010531static int __iw_set_two_ints_getnone(struct net_device *dev,
10532 struct iw_request_info *info,
10533 union iwreq_data *wrqu, char *extra)
10534{
10535 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10536 int *value = (int *)extra;
10537 int sub_cmd = value[0];
10538 int ret;
10539 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10540
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010541 ENTER_DEV(dev);
10542
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010543 ret = wlan_hdd_validate_context(hdd_ctx);
10544 if (0 != ret)
10545 return ret;
10546
Jeff Johnson441e1f72017-02-07 08:50:49 -080010547 ret = hdd_check_private_wext_control(hdd_ctx, info);
10548 if (0 != ret)
10549 return ret;
10550
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010551 switch (sub_cmd) {
10552 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -070010553 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010554 ret = wma_cli_set_command(pAdapter->sessionId,
10555 WMI_STA_SMPS_PARAM_CMDID,
10556 value[1] << WMA_SMPS_PARAM_VALUE_S
10557 | value[2],
10558 VDEV_CMD);
10559 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070010560#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010561 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -070010562 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010563 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053010564 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
10565 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010566 ret = wma_cli_set2_command(pAdapter->sessionId,
10567 GEN_PARAM_CRASH_INJECT,
10568 value[1], value[2], GEN_CMD);
10569 break;
10570#endif
Govind Singha471e5e2015-10-12 17:11:14 +053010571 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010572 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010573 value[1], value[2]);
10574 ret = wma_cli_set2_command(pAdapter->sessionId,
10575 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
10576 value[1], value[2], DBG_CMD);
10577 break;
10578 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070010579 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010580 value[1], value[2]);
10581 ret = wma_cli_set2_command(pAdapter->sessionId,
10582 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
10583 value[1], value[2], DBG_CMD);
10584 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010585 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
10586 hdd_debug("Ioctl to set dual fw mode config");
10587 if (hdd_ctx->config->dual_mac_feature_disable) {
10588 hdd_err("Dual mac feature is disabled from INI");
10589 return -EPERM;
10590 }
10591 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -080010592 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010593 break;
10594 case WE_DUMP_DP_TRACE_LEVEL:
10595 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
10596 value[1], value[2]);
10597 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010598 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053010599 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
10600 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053010601 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
10602 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010603 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010604 case WE_SET_MON_MODE_CHAN:
10605 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
10606 break;
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010607 case WE_SET_WLAN_SUSPEND:
Dustin Brownbc81a472016-10-26 16:56:59 -070010608 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010609 break;
10610 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070010611 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010612 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010613 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070010614 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010615 break;
10616 }
10617
10618 return ret;
10619}
10620
10621static int iw_set_two_ints_getnone(struct net_device *dev,
10622 struct iw_request_info *info,
10623 union iwreq_data *wrqu, char *extra)
10624{
10625 int ret;
10626
10627 cds_ssr_protect(__func__);
10628 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
10629 cds_ssr_unprotect(__func__);
10630
10631 return ret;
10632}
10633
10634/* Define the Wireless Extensions to the Linux Network Device structure */
10635/* A number of these routines are NULL (meaning they are not implemented.) */
10636
10637static const iw_handler we_handler[] = {
10638 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10639 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10640 (iw_handler) NULL, /* SIOCSIWNWID */
10641 (iw_handler) NULL, /* SIOCGIWNWID */
10642 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10643 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10644 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10645 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10646 (iw_handler) NULL, /* SIOCSIWSENS */
10647 (iw_handler) NULL, /* SIOCGIWSENS */
10648 (iw_handler) NULL, /* SIOCSIWRANGE */
10649 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10650 (iw_handler) NULL, /* SIOCSIWPRIV */
10651 (iw_handler) NULL, /* SIOCGIWPRIV */
10652 (iw_handler) NULL, /* SIOCSIWSTATS */
10653 (iw_handler) NULL, /* SIOCGIWSTATS */
10654 (iw_handler) NULL, /* SIOCSIWSPY */
10655 (iw_handler) NULL, /* SIOCGIWSPY */
10656 (iw_handler) NULL, /* SIOCSIWTHRSPY */
10657 (iw_handler) NULL, /* SIOCGIWTHRSPY */
10658 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10659 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10660 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10661 (iw_handler) NULL, /* SIOCGIWAPLIST */
10662 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10663 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10664 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10665 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10666 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10667 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10668 (iw_handler) NULL, /* -- hole -- */
10669 (iw_handler) NULL, /* -- hole -- */
10670 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10671 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10672 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
10673 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
10674 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10675 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10676 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10677 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10678 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10679 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10680 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10681 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10682 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10683 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10684 (iw_handler) NULL, /* -- hole -- */
10685 (iw_handler) NULL, /* -- hole -- */
10686 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10687 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10688 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10689 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10690 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10691 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10692 (iw_handler) NULL, /* SIOCSIWPMKSA */
10693};
10694
10695static const iw_handler we_private[] = {
10696
10697 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
10698 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
10699 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
10700 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10701 iw_set_three_ints_getnone,
10702 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10703 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
10704 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10705 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010706 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
10707 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010708 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10709 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10710 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010711 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010712 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10713 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10714 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
10715 iw_set_keepalive_params,
10716#ifdef WLAN_FEATURE_PACKET_FILTERING
10717 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
10718 iw_set_packet_filter_params,
10719#endif
10720#ifdef FEATURE_WLAN_SCAN_PNO
10721 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
10722#endif
10723 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080010724 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
10725 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010726 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
10727 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10728 iw_set_two_ints_getnone,
10729 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
10730 iw_set_dot11p_channel_sched,
10731};
10732
10733/*Maximum command length can be only 15 */
10734static const struct iw_priv_args we_private_args[] = {
10735
10736 /* handlers for main ioctl */
10737 {WLAN_PRIV_SET_INT_GET_NONE,
10738 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10739 0,
10740 ""},
10741
10742 /* handlers for sub-ioctl */
10743 {WE_SET_11D_STATE,
10744 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10745 0,
10746 "set11Dstate"},
10747
10748 {WE_WOWL,
10749 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10750 0,
10751 "wowl"},
10752
10753 {WE_SET_POWER,
10754 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10755 0,
10756 "setPower"},
10757
10758 {WE_SET_MAX_ASSOC,
10759 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10760 0,
10761 "setMaxAssoc"},
10762
10763 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10765 "setAutoChannel" },
10766
10767 {WE_SET_SCAN_DISABLE,
10768 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10769 0,
10770 "scan_disable"},
10771
10772 {WE_SET_DATA_INACTIVITY_TO,
10773 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10774 0,
10775 "inactivityTO"},
10776
10777 {WE_SET_MAX_TX_POWER,
10778 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10779 0,
10780 "setMaxTxPower"},
10781
10782 {WE_SET_TX_POWER,
10783 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10784 0,
10785 "setTxPower"},
10786
10787 {WE_SET_MC_RATE,
10788 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10789 0,
10790 "setMcRate"},
10791
10792 {WE_SET_MAX_TX_POWER_2_4,
10793 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10794 0,
10795 "setTxMaxPower2G"},
10796
10797 {WE_SET_MAX_TX_POWER_5_0,
10798 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10799 0,
10800 "setTxMaxPower5G"},
10801
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010802 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010803 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010804 0,
10805 "pktlog"},
10806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010807 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10808 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010809 * will support both
10810 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010811 {WE_SET_MAX_TX_POWER,
10812 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10813 0,
10814 "setTxMaxPower"},
10815
10816 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010817 * 1 = enable and 0 = disable
10818 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010819 {
10820 WE_SET_HIGHER_DTIM_TRANSITION,
10821 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10822 0,
10823 "setHDtimTransn"
10824 },
10825
10826 {WE_SET_TM_LEVEL,
10827 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10828 0,
10829 "setTmLevel"},
10830
10831 {WE_SET_PHYMODE,
10832 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10833 0,
10834 "setphymode"},
10835
10836 {WE_SET_NSS,
10837 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10838 0,
10839 "nss"},
10840
10841 {WE_SET_LDPC,
10842 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10843 0,
10844 "ldpc"},
10845
10846 {WE_SET_TX_STBC,
10847 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10848 0,
10849 "tx_stbc"},
10850
10851 {WE_SET_RX_STBC,
10852 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10853 0,
10854 "rx_stbc"},
10855
10856 {WE_SET_SHORT_GI,
10857 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10858 0,
10859 "shortgi"},
10860
10861 {WE_SET_RTSCTS,
10862 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10863 0,
10864 "enablertscts"},
10865
10866 {WE_SET_CHWIDTH,
10867 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10868 0,
10869 "chwidth"},
10870
10871 {WE_SET_ANI_EN_DIS,
10872 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10873 0,
10874 "anienable"},
10875
10876 {WE_SET_ANI_POLL_PERIOD,
10877 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10878 0,
10879 "aniplen"},
10880
10881 {WE_SET_ANI_LISTEN_PERIOD,
10882 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10883 0,
10884 "anilislen"},
10885
10886 {WE_SET_ANI_OFDM_LEVEL,
10887 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10888 0,
10889 "aniofdmlvl"},
10890
10891 {WE_SET_ANI_CCK_LEVEL,
10892 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10893 0,
10894 "aniccklvl"},
10895
10896 {WE_SET_DYNAMIC_BW,
10897 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10898 0,
10899 "cwmenable"},
10900
10901 {WE_SET_CTS_CBW,
10902 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10903 0,
10904 "cts_cbw" },
10905
10906 {WE_SET_GTX_HT_MCS,
10907 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10908 0,
10909 "gtxHTMcs"},
10910
10911 {WE_SET_GTX_VHT_MCS,
10912 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10913 0,
10914 "gtxVHTMcs"},
10915
10916 {WE_SET_GTX_USRCFG,
10917 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10918 0,
10919 "gtxUsrCfg"},
10920
10921 {WE_SET_GTX_THRE,
10922 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10923 0,
10924 "gtxThre"},
10925
10926 {WE_SET_GTX_MARGIN,
10927 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10928 0,
10929 "gtxMargin"},
10930
10931 {WE_SET_GTX_STEP,
10932 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10933 0,
10934 "gtxStep"},
10935
10936 {WE_SET_GTX_MINTPC,
10937 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10938 0,
10939 "gtxMinTpc"},
10940
10941 {WE_SET_GTX_BWMASK,
10942 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10943 0,
10944 "gtxBWMask"},
10945
10946 {WE_SET_TX_CHAINMASK,
10947 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10948 0,
10949 "txchainmask"},
10950
10951 {WE_SET_RX_CHAINMASK,
10952 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10953 0,
10954 "rxchainmask"},
10955
10956 {WE_SET_11N_RATE,
10957 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10958 0,
10959 "set11NRates"},
10960
10961 {WE_SET_VHT_RATE,
10962 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10963 0,
10964 "set11ACRates"},
10965
10966 {WE_SET_AMPDU,
10967 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10968 0,
10969 "ampdu"},
10970
10971 {WE_SET_AMSDU,
10972 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10973 0,
10974 "amsdu"},
10975
10976 {WE_SET_BURST_ENABLE,
10977 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10978 0,
10979 "burst_enable"},
10980
10981 {WE_SET_BURST_DUR,
10982 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10983 0,
10984 "burst_dur"},
10985
10986 {WE_SET_TXPOW_2G,
10987 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10988 0,
10989 "txpow2g"},
10990
10991 {WE_SET_TXPOW_5G,
10992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10993 0,
10994 "txpow5g"},
10995
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010996 /* Sub-cmds DBGLOG specific commands */
10997 {WE_DBGLOG_LOG_LEVEL,
10998 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10999 0,
11000 "dl_loglevel"},
11001
11002 {WE_DBGLOG_VAP_ENABLE,
11003 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11004 0,
11005 "dl_vapon"},
11006
11007 {WE_DBGLOG_VAP_DISABLE,
11008 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11009 0,
11010 "dl_vapoff"},
11011
11012 {WE_DBGLOG_MODULE_ENABLE,
11013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11014 0,
11015 "dl_modon"},
11016
11017 {WE_DBGLOG_MODULE_DISABLE,
11018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11019 0,
11020 "dl_modoff"},
11021
11022 {WE_DBGLOG_MOD_LOG_LEVEL,
11023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11024 0,
11025 "dl_mod_loglevel"},
11026
11027 {WE_DBGLOG_TYPE,
11028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11029 0,
11030 "dl_type"},
11031 {WE_DBGLOG_REPORT_ENABLE,
11032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11033 0,
11034 "dl_report"},
11035
11036 {WE_SET_TXRX_FWSTATS,
11037 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11038 0,
11039 "txrx_fw_stats"},
11040
11041 {WE_TXRX_FWSTATS_RESET,
11042 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11043 0,
11044 "txrx_fw_st_rst"},
11045
11046 {WE_PPS_PAID_MATCH,
11047 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11048 0, "paid_match"},
11049
11050 {WE_PPS_GID_MATCH,
11051 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11052 0, "gid_match"},
11053
11054 {WE_PPS_EARLY_TIM_CLEAR,
11055 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11056 0, "tim_clear"},
11057
11058 {WE_PPS_EARLY_DTIM_CLEAR,
11059 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11060 0, "dtim_clear"},
11061
11062 {WE_PPS_EOF_PAD_DELIM,
11063 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11064 0, "eof_delim"},
11065
11066 {WE_PPS_MACADDR_MISMATCH,
11067 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11068 0, "mac_match"},
11069
11070 {WE_PPS_DELIM_CRC_FAIL,
11071 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11072 0, "delim_fail"},
11073
11074 {WE_PPS_GID_NSTS_ZERO,
11075 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11076 0, "nsts_zero"},
11077
11078 {WE_PPS_RSSI_CHECK,
11079 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11080 0, "rssi_chk"},
11081
11082 {WE_PPS_5G_EBT,
11083 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11084 0, "5g_ebt"},
11085
11086 {WE_SET_HTSMPS,
11087 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11088 0, "htsmps"},
11089
11090 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
11091 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11092 0, "set_qpspollcnt"},
11093
11094 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
11095 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11096 0, "set_qtxwake"},
11097
11098 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
11099 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11100 0, "set_qwakeintv"},
11101
11102 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
11103 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11104 0, "set_qnodatapoll"},
11105
11106 /* handlers for MCC time quota and latency sub ioctls */
11107 {WE_MCC_CONFIG_LATENCY,
11108 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11109 0, "setMccLatency"},
11110
11111 {WE_MCC_CONFIG_QUOTA,
11112 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11113 0, "setMccQuota"},
11114
11115 {WE_SET_DEBUG_LOG,
11116 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11117 0, "setDbgLvl"},
11118
11119 /* handlers for early_rx power save */
11120 {WE_SET_EARLY_RX_ADJUST_ENABLE,
11121 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11122 0, "erx_enable"},
11123
11124 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
11125 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11126 0, "erx_bmiss_val"},
11127
11128 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
11129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11130 0, "erx_bmiss_smpl"},
11131
11132 {WE_SET_EARLY_RX_SLOP_STEP,
11133 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11134 0, "erx_slop_step"},
11135
11136 {WE_SET_EARLY_RX_INIT_SLOP,
11137 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11138 0, "erx_init_slop"},
11139
11140 {WE_SET_EARLY_RX_ADJUST_PAUSE,
11141 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11142 0, "erx_adj_pause"},
11143
11144 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
11145 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11146 0, "erx_dri_sample"},
11147
11148 {WE_DUMP_STATS,
11149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11150 0, "dumpStats"},
11151
11152 {WE_CLEAR_STATS,
11153 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11154 0, "clearStats"},
11155
Govind Singha471e5e2015-10-12 17:11:14 +053011156 {WE_START_FW_PROFILE,
11157 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11158 0, "startProfile"},
11159
Abhishek Singh1bdb1572015-10-16 16:24:19 +053011160 {WE_SET_CHANNEL,
11161 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11162 0, "setChanChange" },
11163
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053011164 {WE_SET_CONC_SYSTEM_PREF,
11165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11166 0, "setConcSysPref" },
11167
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011168 {WLAN_PRIV_SET_NONE_GET_INT,
11169 0,
11170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11171 ""},
11172
11173 /* handlers for sub-ioctl */
11174 {WE_GET_11D_STATE,
11175 0,
11176 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11177 "get11Dstate"},
11178
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011179 {WE_GET_WLAN_DBG,
11180 0,
11181 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11182 "getwlandbg"},
11183
11184 {WE_GET_MAX_ASSOC,
11185 0,
11186 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11187 "getMaxAssoc"},
11188
11189 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11190 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11191 "getAutoChannel" },
11192
11193 {WE_GET_CONCURRENCY_MODE,
11194 0,
11195 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11196 "getconcurrency"},
11197
11198 {WE_GET_NSS,
11199 0,
11200 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11201 "get_nss"},
11202
11203 {WE_GET_LDPC,
11204 0,
11205 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11206 "get_ldpc"},
11207
11208 {WE_GET_TX_STBC,
11209 0,
11210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11211 "get_tx_stbc"},
11212
11213 {WE_GET_RX_STBC,
11214 0,
11215 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11216 "get_rx_stbc"},
11217
11218 {WE_GET_SHORT_GI,
11219 0,
11220 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11221 "get_shortgi"},
11222
11223 {WE_GET_RTSCTS,
11224 0,
11225 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11226 "get_rtscts"},
11227
11228 {WE_GET_CHWIDTH,
11229 0,
11230 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11231 "get_chwidth"},
11232
11233 {WE_GET_ANI_EN_DIS,
11234 0,
11235 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11236 "get_anienable"},
11237
11238 {WE_GET_ANI_POLL_PERIOD,
11239 0,
11240 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11241 "get_aniplen"},
11242
11243 {WE_GET_ANI_LISTEN_PERIOD,
11244 0,
11245 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11246 "get_anilislen"},
11247
11248 {WE_GET_ANI_OFDM_LEVEL,
11249 0,
11250 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11251 "get_aniofdmlvl"},
11252
11253 {WE_GET_ANI_CCK_LEVEL,
11254 0,
11255 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11256 "get_aniccklvl"},
11257
11258 {WE_GET_DYNAMIC_BW,
11259 0,
11260 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11261 "get_cwmenable"},
11262
11263 {WE_GET_GTX_HT_MCS,
11264 0,
11265 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11266 "get_gtxHTMcs"},
11267
11268 {WE_GET_GTX_VHT_MCS,
11269 0,
11270 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11271 "get_gtxVHTMcs"},
11272
11273 {WE_GET_GTX_USRCFG,
11274 0,
11275 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11276 "get_gtxUsrCfg"},
11277
11278 {WE_GET_GTX_THRE,
11279 0,
11280 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11281 "get_gtxThre"},
11282
11283 {WE_GET_GTX_MARGIN,
11284 0,
11285 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11286 "get_gtxMargin"},
11287
11288 {WE_GET_GTX_STEP,
11289 0,
11290 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11291 "get_gtxStep"},
11292
11293 {WE_GET_GTX_MINTPC,
11294 0,
11295 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11296 "get_gtxMinTpc"},
11297
11298 {WE_GET_GTX_BWMASK,
11299 0,
11300 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11301 "get_gtxBWMask"},
11302
11303 {WE_GET_TX_CHAINMASK,
11304 0,
11305 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11306 "get_txchainmask"},
11307
11308 {WE_GET_RX_CHAINMASK,
11309 0,
11310 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11311 "get_rxchainmask"},
11312
11313 {WE_GET_11N_RATE,
11314 0,
11315 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11316 "get_11nrate"},
11317
11318 {WE_GET_AMPDU,
11319 0,
11320 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11321 "get_ampdu"},
11322
11323 {WE_GET_AMSDU,
11324 0,
11325 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11326 "get_amsdu"},
11327
11328 {WE_GET_BURST_ENABLE,
11329 0,
11330 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11331 "get_burst_en"},
11332
11333 {WE_GET_BURST_DUR,
11334 0,
11335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11336 "get_burst_dur"},
11337
11338 {WE_GET_TXPOW_2G,
11339 0,
11340 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11341 "get_txpow2g"},
11342
11343 {WE_GET_TXPOW_5G,
11344 0,
11345 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11346 "get_txpow5g"},
11347
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011348 {WE_GET_PPS_PAID_MATCH,
11349 0,
11350 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11351 "get_paid_match"},
11352
11353 {WE_GET_PPS_GID_MATCH,
11354 0,
11355 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11356 "get_gid_match"},
11357
11358 {WE_GET_PPS_EARLY_TIM_CLEAR,
11359 0,
11360 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11361 "get_tim_clear"},
11362
11363 {WE_GET_PPS_EARLY_DTIM_CLEAR,
11364 0,
11365 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11366 "get_dtim_clear"},
11367
11368 {WE_GET_PPS_EOF_PAD_DELIM,
11369 0,
11370 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11371 "get_eof_delim"},
11372
11373 {WE_GET_PPS_MACADDR_MISMATCH,
11374 0,
11375 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11376 "get_mac_match"},
11377
11378 {WE_GET_PPS_DELIM_CRC_FAIL,
11379 0,
11380 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11381 "get_delim_fail"},
11382
11383 {WE_GET_PPS_GID_NSTS_ZERO,
11384 0,
11385 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11386 "get_nsts_zero"},
11387
11388 {WE_GET_PPS_RSSI_CHECK,
11389 0,
11390 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11391 "get_rssi_chk"},
11392
11393 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
11394 0,
11395 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11396 "get_qpspollcnt"},
11397
11398 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
11399 0,
11400 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11401 "get_qtxwake"},
11402
11403 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
11404 0,
11405 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11406 "get_qwakeintv"},
11407
11408 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
11409 0,
11410 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11411 "get_qnodatapoll"},
11412
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011413 {WE_CAP_TSF,
11414 0,
11415 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11416 "cap_tsf"},
11417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011418 {WE_GET_TEMPERATURE,
11419 0,
11420 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11421 "get_temp"},
11422 /* handlers for main ioctl */
11423 {WLAN_PRIV_SET_CHAR_GET_NONE,
11424 IW_PRIV_TYPE_CHAR | 512,
11425 0,
11426 ""},
11427
11428 /* handlers for sub-ioctl */
11429 {WE_WOWL_ADD_PTRN,
11430 IW_PRIV_TYPE_CHAR | 512,
11431 0,
11432 "wowlAddPtrn"},
11433
11434 {WE_WOWL_DEL_PTRN,
11435 IW_PRIV_TYPE_CHAR | 512,
11436 0,
11437 "wowlDelPtrn"},
11438
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011439 /* handlers for sub-ioctl */
11440 {WE_NEIGHBOR_REPORT_REQUEST,
11441 IW_PRIV_TYPE_CHAR | 512,
11442 0,
11443 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080011444
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011445 {WE_SET_AP_WPS_IE,
11446 IW_PRIV_TYPE_CHAR | 512,
11447 0,
11448 "set_ap_wps_ie"},
11449
11450 {WE_SET_CONFIG,
11451 IW_PRIV_TYPE_CHAR | 512,
11452 0,
11453 "setConfig"},
11454
11455 /* handlers for main ioctl */
11456 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
11457 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11458 0,
11459 ""},
11460
11461 /* handlers for sub-ioctl */
11462 {WE_SET_WLAN_DBG,
11463 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11464 0,
11465 "setwlandbg"},
11466
11467 /* handlers for sub-ioctl */
11468 {WE_SET_DP_TRACE,
11469 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11470 0,
11471 "set_dp_trace"},
11472
11473 {WE_SET_SAP_CHANNELS,
11474 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11475 0,
11476 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053011477
11478 {WE_SET_FW_TEST,
11479 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11480 0, "fw_test"},
11481
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011482 /* handlers for main ioctl */
11483 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
11484 0,
11485 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11486 "" },
11487 {WE_GET_TSF,
11488 0,
11489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11490 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011491
11492 {WE_SET_DUAL_MAC_SCAN_CONFIG,
11493 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11494 0,
11495 "set_scan_cfg"},
11496
11497 /* handlers for main ioctl */
11498 {WLAN_PRIV_GET_CHAR_SET_NONE,
11499 0,
11500 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11501 ""},
11502
11503 /* handlers for sub-ioctl */
11504 {WE_WLAN_VERSION,
11505 0,
11506 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11507 "version"},
11508 {WE_GET_STATS,
11509 0,
11510 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11511 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080011512 {WE_GET_SUSPEND_RESUME_STATS,
11513 0,
11514 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11515 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053011516 {WE_LIST_FW_PROFILE,
11517 0,
11518 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11519 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011520 {WE_GET_STATES,
11521 0,
11522 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11523 "getHostStates"},
11524 {WE_GET_CFG,
11525 0,
11526 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11527 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011528 {WE_GET_RSSI,
11529 0,
11530 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11531 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011532 {WE_GET_WMM_STATUS,
11533 0,
11534 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11535 "getWmmStatus"},
11536 {
11537 WE_GET_CHANNEL_LIST,
11538 0,
11539 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11540 "getChannelList"
11541 },
11542#ifdef FEATURE_WLAN_TDLS
11543 {
11544 WE_GET_TDLS_PEERS,
11545 0,
11546 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11547 "getTdlsPeers"
11548 },
11549#endif
11550#ifdef WLAN_FEATURE_11W
11551 {
11552 WE_GET_11W_INFO,
11553 0,
11554 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11555 "getPMFInfo"
11556 },
11557#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011558 {
11559 WE_GET_IBSS_STA_INFO,
11560 0,
11561 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11562 "getIbssSTAs"
11563 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011564 {WE_GET_PHYMODE,
11565 0,
11566 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11567 "getphymode"},
11568#ifdef FEATURE_OEM_DATA_SUPPORT
11569 {WE_GET_OEM_DATA_CAP,
11570 0,
11571 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11572 "getOemDataCap"},
11573#endif /* FEATURE_OEM_DATA_SUPPORT */
11574 {WE_GET_SNR,
11575 0,
11576 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11577 "getSNR"},
11578
11579 /* handlers for main ioctl */
11580 {WLAN_PRIV_SET_NONE_GET_NONE,
11581 0,
11582 0,
11583 ""},
11584
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011585 /* handlers for sub-ioctl */
11586 {
11587 WE_IBSS_GET_PEER_INFO_ALL,
11588 0,
11589 0,
11590 "ibssPeerInfoAll"
11591 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011592 {WE_GET_RECOVERY_STAT,
11593 0,
11594 0,
11595 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053011596
11597 {WE_GET_FW_PROFILE_DATA,
11598 0,
11599 0,
11600 "getProfileData"},
11601
11602 {WE_SET_REASSOC_TRIGGER,
11603 0,
11604 0,
11605 "reassoc"},
11606
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080011607 {WE_STOP_OBSS_SCAN,
11608 0,
11609 0,
11610 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011611 /* handlers for main ioctl */
11612 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
11613 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11614 0,
11615 ""},
11616
11617 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011618 {WE_IBSS_GET_PEER_INFO,
11619 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11620 0,
11621 "ibssPeerInfo"},
11622
11623 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011624 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11625 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11626 0,
11627 "setdumplog"},
11628
11629 {WE_MTRACE_DUMP_CMD,
11630 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11631 0,
11632 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080011633
11634 {WE_POLICY_MANAGER_CINFO_CMD,
11635 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11636 0,
11637 "pm_cinfo"},
11638
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011639#ifdef MPC_UT_FRAMEWORK
11640 {WE_POLICY_MANAGER_CLIST_CMD,
11641 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11642 0,
11643 "pm_clist"},
11644
11645 {WE_POLICY_MANAGER_DLIST_CMD,
11646 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11647 0,
11648 "pm_dlist"},
11649
11650 {WE_POLICY_MANAGER_DBS_CMD,
11651 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11652 0,
11653 "pm_dbs"},
11654
11655 {WE_POLICY_MANAGER_PCL_CMD,
11656 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11657 0,
11658 "pm_pcl"},
11659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011660 {WE_POLICY_MANAGER_ULIST_CMD,
11661 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11662 0,
11663 "pm_ulist"},
11664
11665 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
11666 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11667 0,
11668 "pm_query_action"},
11669
11670 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
11671 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11672 0,
11673 "pm_query_allow"},
11674
11675 {WE_POLICY_MANAGER_SCENARIO_CMD,
11676 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11677 0,
11678 "pm_run_scenario"},
11679
11680 {WE_POLICY_SET_HW_MODE_CMD,
11681 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11682 0,
11683 "pm_set_hw_mode"},
11684#endif
11685#ifdef FEATURE_WLAN_TDLS
11686 /* handlers for sub ioctl */
11687 {
11688 WE_TDLS_CONFIG_PARAMS,
11689 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11690 0,
11691 "setTdlsConfig"
11692 },
11693#endif
11694 {
11695 WE_UNIT_TEST_CMD,
11696 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11697 0,
11698 "setUnitTestCmd"
11699 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053011700 {
11701 WE_MAC_PWR_DEBUG_CMD,
11702 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11703 0,
11704 "halPwrDebug"
11705 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011706
11707#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11708 {WE_LED_FLASHING_PARAM,
11709 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11710 0,
11711 "gpio_control"},
11712#endif
11713 /* handlers for main ioctl */
11714 {WLAN_PRIV_ADD_TSPEC,
11715 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11716 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11717 "addTspec"},
11718
11719 /* handlers for main ioctl */
11720 {WLAN_PRIV_DEL_TSPEC,
11721 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11722 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11723 "delTspec"},
11724
11725 /* handlers for main ioctl */
11726 {WLAN_PRIV_GET_TSPEC,
11727 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11728 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11729 "getTspec"},
11730
11731 /* handlers for main ioctl - host offload */
11732 {
11733 WLAN_PRIV_SET_HOST_OFFLOAD,
11734 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11735 0,
11736 "setHostOffload"
11737 }
11738 ,
11739
11740 {
11741 WLAN_GET_WLAN_STATISTICS,
11742 0,
11743 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11744 "getWlanStats"
11745 }
11746 ,
11747
11748 {
11749 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011750 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11751 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011752 0,
11753 "setKeepAlive"
11754 }
11755 ,
11756#ifdef WLAN_FEATURE_PACKET_FILTERING
11757 {
11758 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053011759 IW_PRIV_TYPE_BYTE |
11760 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011761 0,
11762 "setPktFilter"
11763 }
11764 ,
11765#endif
11766#ifdef FEATURE_WLAN_SCAN_PNO
11767 {
11768 WLAN_SET_PNO,
11769 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11770 0,
11771 "setpno"
11772 }
11773 ,
11774#endif
11775 {
11776 WLAN_SET_BAND_CONFIG,
11777 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11778 0,
11779 "SETBAND"
11780 }
11781 ,
11782 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080011783 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080011784 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011785 0,
11786 "setMCBCFilter"
11787 }
11788 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011789
11790 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011791 WLAN_GET_LINK_SPEED,
11792 IW_PRIV_TYPE_CHAR | 18,
11793 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11794 }
11795 ,
11796
11797 /* handlers for main ioctl */
11798 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
11799 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11800 0,
11801 ""}
11802 ,
11803 {WE_SET_SMPS_PARAM,
11804 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11805 0, "set_smps_param"}
11806 ,
11807 {WLAN_SET_DOT11P_CHANNEL_SCHED,
11808 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
11809 0, "set_dot11p" }
11810 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070011811#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011812 {WE_SET_FW_CRASH_INJECT,
11813 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11814 0, "crash_inject"}
11815 ,
11816#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070011817#ifdef WLAN_SUSPEND_RESUME_TEST
11818 {WE_SET_WLAN_SUSPEND,
11819 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11820 0, "wlan_suspend"}
11821 ,
11822 {WE_SET_WLAN_RESUME,
11823 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11824 0, "wlan_resume"}
11825 ,
11826#endif
Govind Singha471e5e2015-10-12 17:11:14 +053011827 {WE_ENABLE_FW_PROFILE,
11828 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11829 0, "enableProfile"}
11830 ,
11831 {WE_SET_FW_PROFILE_HIST_INTVL,
11832 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11833 0, "set_hist_intvl"}
11834 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011835 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
11836 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11837 0, "set_fw_mode_cfg"}
11838 ,
11839 {WE_DUMP_DP_TRACE_LEVEL,
11840 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11841 0, "dump_dp_trace"}
11842 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011843 {WE_SET_MON_MODE_CHAN,
11844 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11845 0, "setMonChan"}
11846 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070011847
11848 {WE_GET_ROAM_SYNCH_DELAY,
11849 0,
11850 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11851 "hostroamdelay"}
11852 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011853};
11854
11855const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053011856 .num_standard = QDF_ARRAY_SIZE(we_handler),
11857 .num_private = QDF_ARRAY_SIZE(we_private),
11858 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011859
11860 .standard = (iw_handler *) we_handler,
11861 .private = (iw_handler *) we_private,
11862 .private_args = we_private_args,
11863 .get_wireless_stats = NULL,
11864};
11865
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011866/* hdd_set_wext() - configures bss parameters
11867 * @pAdapter: handle to adapter context
11868 *
11869 * Returns: none
11870 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011871static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011872{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011873 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11874 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011875
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011876 ENTER();
11877
11878 if (!pwextBuf) {
11879 hdd_err("ERROR: pwextBuf is NULL");
11880 return QDF_STATUS_E_FAILURE;
11881 }
11882
11883 if (!pHddStaCtx) {
11884 hdd_err("ERROR: pHddStaCtx is NULL");
11885 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011886 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011887
11888 /* Now configure the roaming profile links. To SSID and bssid. */
11889 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011890 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011891
11892 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011893 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011894
11895 /*Set the numOfChannels to zero to scan all the channels */
11896 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11897 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11898
11899 /* Default is no encryption */
11900 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11901 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
11902 eCSR_ENCRYPT_TYPE_NONE;
11903
11904 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11905 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
11906 eCSR_ENCRYPT_TYPE_NONE;
11907
11908 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11909
11910 /* Default is no authentication */
11911 pwextBuf->roamProfile.AuthType.numEntries = 1;
11912 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11913
11914 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
11915 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11916
11917 /*Set the default scan mode */
11918 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
11919
11920 hdd_clear_roam_profile_ie(pAdapter);
11921
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011922 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011923 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011924
11925}
11926
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011927/**
11928 * hdd_register_wext() - register wext context
11929 * @dev: net device handle
11930 *
11931 * Registers wext interface context for a given net device
11932 *
11933 * Returns: 0 on success, errno on failure
11934 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011935int hdd_register_wext(struct net_device *dev)
11936{
11937 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011938 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011939 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011940
11941 ENTER();
11942
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011943 if (!pwextBuf) {
11944 hdd_err(FL("ERROR: pwextBuf is NULL"));
11945 return QDF_STATUS_E_FAILURE;
11946 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011947
11948 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011949 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
11950
11951 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->
11952 completion_var);
11953
11954 status = hdd_set_wext(pAdapter);
11955
Anurag Chouhance0dc992016-02-16 18:18:03 +053011956 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011957
Jeff Johnson99bac312016-06-28 10:38:18 -070011958 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011959 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011960 }
11961
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011962 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011963 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011964 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011965 }
11966
Anurag Chouhance0dc992016-02-16 18:18:03 +053011967 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->scanevent))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011968 hdd_err("ERROR: HDD scan event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011969 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011970 }
11971 /* Register as a wireless device */
11972 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11973
11974 EXIT();
11975 return 0;
11976}
11977
11978int hdd_unregister_wext(struct net_device *dev)
11979{
Jeff Johnson99bac312016-06-28 10:38:18 -070011980 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011981
11982 if (dev != NULL) {
11983 rtnl_lock();
11984 dev->wireless_handlers = NULL;
11985 rtnl_unlock();
11986 }
11987
11988 return 0;
11989}