blob: 2b49c2d7010faa137318affd8682b4b63603ec9b [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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098#define HDD_FINISH_ULA_TIME_OUT 800
99#define HDD_SET_MCBC_FILTERS_TO_FW 1
100#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
101
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102/* To Validate Channel against the Frequency and Vice-Versa */
103static const hdd_freq_chan_map_t freq_chan_map[] = {
104 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
105 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
106 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
107 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
108 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
109 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
110 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
111 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
112 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
113 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
114 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
115 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
116
117#define FREQ_CHAN_MAP_TABLE_SIZE \
118 (sizeof(freq_chan_map) / sizeof(freq_chan_map[0]))
119
120/* Private ioctls and their sub-ioctls */
121#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
122#define WE_SET_11D_STATE 1
123#define WE_WOWL 2
124#define WE_SET_POWER 3
125#define WE_SET_MAX_ASSOC 4
126#define WE_SET_SCAN_DISABLE 5
127#define WE_SET_DATA_INACTIVITY_TO 6
128#define WE_SET_MAX_TX_POWER 7
129#define WE_SET_HIGHER_DTIM_TRANSITION 8
130#define WE_SET_TM_LEVEL 9
131#define WE_SET_PHYMODE 10
132#define WE_SET_NSS 11
133#define WE_SET_LDPC 12
134#define WE_SET_TX_STBC 13
135#define WE_SET_RX_STBC 14
136#define WE_SET_SHORT_GI 15
137#define WE_SET_RTSCTS 16
138#define WE_SET_CHWIDTH 17
139#define WE_SET_ANI_EN_DIS 18
140#define WE_SET_ANI_POLL_PERIOD 19
141#define WE_SET_ANI_LISTEN_PERIOD 20
142#define WE_SET_ANI_OFDM_LEVEL 21
143#define WE_SET_ANI_CCK_LEVEL 22
144#define WE_SET_DYNAMIC_BW 23
145#define WE_SET_TX_CHAINMASK 24
146#define WE_SET_RX_CHAINMASK 25
147#define WE_SET_11N_RATE 26
148#define WE_SET_AMPDU 27
149#define WE_SET_AMSDU 28
150#define WE_SET_TXPOW_2G 29
151#define WE_SET_TXPOW_5G 30
152/* Private ioctl for firmware debug log */
153#define WE_DBGLOG_LOG_LEVEL 31
154#define WE_DBGLOG_VAP_ENABLE 32
155#define WE_DBGLOG_VAP_DISABLE 33
156#define WE_DBGLOG_MODULE_ENABLE 34
157#define WE_DBGLOG_MODULE_DISABLE 35
158#define WE_DBGLOG_MOD_LOG_LEVEL 36
159#define WE_DBGLOG_TYPE 37
160#define WE_SET_TXRX_FWSTATS 38
161#define WE_SET_VHT_RATE 39
162#define WE_DBGLOG_REPORT_ENABLE 40
163#define WE_TXRX_FWSTATS_RESET 41
164#define WE_SET_MAX_TX_POWER_2_4 42
165#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800166#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167/* Private ioctl for packet powe save */
168#define WE_PPS_PAID_MATCH 45
169#define WE_PPS_GID_MATCH 46
170#define WE_PPS_EARLY_TIM_CLEAR 47
171#define WE_PPS_EARLY_DTIM_CLEAR 48
172#define WE_PPS_EOF_PAD_DELIM 49
173#define WE_PPS_MACADDR_MISMATCH 50
174#define WE_PPS_DELIM_CRC_FAIL 51
175#define WE_PPS_GID_NSTS_ZERO 52
176#define WE_PPS_RSSI_CHECK 53
177#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
178#define WE_SET_HTSMPS 55
179/* Private ioctl for QPower */
180#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
181#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
182#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
183#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
184
185#define WE_SET_BURST_ENABLE 60
186#define WE_SET_BURST_DUR 61
187/* GTX Commands */
188#define WE_SET_GTX_HT_MCS 62
189#define WE_SET_GTX_VHT_MCS 63
190#define WE_SET_GTX_USRCFG 64
191#define WE_SET_GTX_THRE 65
192#define WE_SET_GTX_MARGIN 66
193#define WE_SET_GTX_STEP 67
194#define WE_SET_GTX_MINTPC 68
195#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530196
197/*
198 * <ioctl>
199 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
200 *
201 * @INPUT: set_value
202 *
203 * @OUTPUT: None
204 *
205 * This IOCTL is used to set the MCC latency value in milliseconds
206 * during STA-P2P concurrency.
207 *
208 * If 0ms latency is provided, then FW will set to a default.
209 * Otherwise, latency must be at least 30ms.
210 *
211 * @E.g: iwpriv wlan0 setMccLatency 40
212 *
213 *
214 * Supported Feature: Concurrency
215 *
216 * Usage: Internal/External
217 *
218 * </ioctl>
219 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530221
222/*
223 * <ioctl>
224 * setMccQuota- Set the quota for P2P cases
225 *
226 * @INPUT: set_value [0,100]
227 *
228 * @OUTPUT: None
229 *
230 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
231 *
232 * Currently used to set time quota for 2 MCC vdevs/adapters using
233 * (operating channel, quota) for each mode.
234 * The info is provided run time using iwpriv command:
235 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
236 * Note: the quota provided in command is for the same mode in cmd.
237 * HDD checks if MCC mode is active, gets the second mode and its
238 * operating chan.
239 * Quota for the 2nd role is calculated as 100 - quota of first mode.
240 *
241 * @E.g: iwpriv wlan0 setMccQuota 50
242 * iwpriv p2p0 setMccQuota 50
243 *
244 * Supported Feature: Concurrency
245 *
246 * Usage: Internal/External
247 *
248 * </ioctl>
249 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250#define WE_MCC_CONFIG_QUOTA 71
251/* Private IOCTL for debug connection issues */
252#define WE_SET_DEBUG_LOG 72
253#ifdef WE_SET_TX_POWER
254#undef WE_SET_TX_POWER
255#endif
256#define WE_SET_TX_POWER 74
257/* Private ioctl for earlyrx power save feature */
258#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
259#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
260#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
261#define WE_SET_EARLY_RX_SLOP_STEP 78
262#define WE_SET_EARLY_RX_INIT_SLOP 79
263#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
264#define WE_SET_MC_RATE 81
265#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
266/* Private ioctl for packet power save */
267#define WE_PPS_5G_EBT 83
268#define WE_SET_CTS_CBW 84
269#define WE_DUMP_STATS 85
270#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530271/* Private sub ioctl for starting/stopping the profiling */
272#define WE_START_FW_PROFILE 87
Abhishek Singh3c507012016-12-01 11:15:42 +0530273/*
274 * <ioctl>
275 * setChanChange - Initiate channel change
276 *
277 * @INPUT: channel number to switch to.
278 *
279 * @OUTPUT: None
280 *
281 * This IOCTL is used to initiate a channel change.
282 * If called on STA/CLI interface it will send the
283 * ECSA action frame to the connected SAP/GO asking to
284 * initiate the ECSA, if supported.
285 * If called on SAP/GO interface it will initiate
286 * ECSA and ask connected peers to move to new channel.
287 *
288 * @E.g: iwpriv wlan0 setChanChange <channel>
289 * iwpriv wlan0 setChanChange 1
290 *
291 * Supported Feature: ECSA
292 *
293 * Usage: Internal/External
294 *
295 * </ioctl>
296 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +0530297#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +0530298#define WE_SET_CONC_SYSTEM_PREF 89
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299
300/* Private ioctls and their sub-ioctls */
301#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
302#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303#define WE_SET_SAP_CHANNELS 3
304#define WE_GET_WLAN_DBG 4
305#define WE_GET_MAX_ASSOC 6
306/* 7 is unused */
307#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530308
309/*
310 * <ioctl>
311 * getconcurrency - Get concurrency mode
312 *
313 * @INPUT: None
314 *
315 * @OUTPUT: It shows concurrency value
316 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
317 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
318 * 8:OCB 9:EPPING 10:QVIT 11:NDI
319 *
320 * This IOCTL is used to retrieve concurrency mode.
321 *
322 * @E.g: iwpriv wlan0 getconcurrency
323 * wlan0 getconcurrency:5
324 * Above value shows STA+P2P_Client
325 *
326 * Supported Feature: Concurrency
327 *
328 * Usage: Internal/External
329 *
330 * </ioctl>
331 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332#define WE_GET_CONCURRENCY_MODE 9
333#define WE_GET_NSS 11
334#define WE_GET_LDPC 12
335#define WE_GET_TX_STBC 13
336#define WE_GET_RX_STBC 14
337#define WE_GET_SHORT_GI 15
338#define WE_GET_RTSCTS 16
339#define WE_GET_CHWIDTH 17
340#define WE_GET_ANI_EN_DIS 18
341#define WE_GET_ANI_POLL_PERIOD 19
342#define WE_GET_ANI_LISTEN_PERIOD 20
343#define WE_GET_ANI_OFDM_LEVEL 21
344#define WE_GET_ANI_CCK_LEVEL 22
345#define WE_GET_DYNAMIC_BW 23
346#define WE_GET_TX_CHAINMASK 24
347#define WE_GET_RX_CHAINMASK 25
348#define WE_GET_11N_RATE 26
349#define WE_GET_AMPDU 27
350#define WE_GET_AMSDU 28
351#define WE_GET_TXPOW_2G 29
352#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -0800353/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354#define WE_GET_PPS_PAID_MATCH 32
355#define WE_GET_PPS_GID_MATCH 33
356#define WE_GET_PPS_EARLY_TIM_CLEAR 34
357#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
358#define WE_GET_PPS_EOF_PAD_DELIM 36
359#define WE_GET_PPS_MACADDR_MISMATCH 37
360#define WE_GET_PPS_DELIM_CRC_FAIL 38
361#define WE_GET_PPS_GID_NSTS_ZERO 39
362#define WE_GET_PPS_RSSI_CHECK 40
363/* Private ioctl for QPower */
364#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
365#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
366#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
367#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
368#define WE_GET_BURST_ENABLE 45
369#define WE_GET_BURST_DUR 46
370/* GTX Commands */
371#define WE_GET_GTX_HT_MCS 47
372#define WE_GET_GTX_VHT_MCS 48
373#define WE_GET_GTX_USRCFG 49
374#define WE_GET_GTX_THRE 50
375#define WE_GET_GTX_MARGIN 51
376#define WE_GET_GTX_STEP 52
377#define WE_GET_GTX_MINTPC 53
378#define WE_GET_GTX_BWMASK 54
379#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700380#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -0700381#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382
383/* Private ioctls and their sub-ioctls */
384#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
385
386/* Private ioctls and their sub-ioctls */
387#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
388#define WE_WOWL_ADD_PTRN 1
389#define WE_WOWL_DEL_PTRN 2
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390#define WE_NEIGHBOR_REPORT_REQUEST 3
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391#define WE_SET_AP_WPS_IE 4 /* This is called in station mode to set probe rsp ie. */
392#define WE_SET_CONFIG 5
393
394/* Private ioctls and their sub-ioctls */
395#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
396#define WE_SET_WLAN_DBG 1
397#define WE_SET_DP_TRACE 2
398#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +0530399#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400
401/* Private ioctls and their sub-ioctls */
402#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
403#define WE_WLAN_VERSION 1
404#define WE_GET_STATS 2
405#define WE_GET_CFG 3
406#define WE_GET_WMM_STATUS 4
407#define WE_GET_CHANNEL_LIST 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -0800409
410/*
411 * <ioctl>
412 * getSuspendStats - Get suspend/resume stats
413 *
414 * @INPUT: None
415 *
416 * @OUTPUT: character string containing formatted suspend/resume stats
417 *
418 * This ioctl is used to get suspend/resume stats formatted for display.
419 * Currently it includes suspend/resume counts, wow wake up reasons, and
420 * suspend fail reasons.
421 *
422 * @E.g: iwpriv wlan0 getSuspendStats
423 * iwpriv wlan0 getSuspendStats
424 *
425 * Supported Feature: suspend/resume
426 *
427 * Usage: Internal
428 *
429 * </ioctl>
430 */
431#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +0530433/*
434 * <ioctl>
435 * getTdlsPeers - Get all TDLS peers.
436 *
437 * @INPUT: None
438 *
439 * @OUTPUT: Returns the MAC address of all the TDLS peers
440 * wlan0 getTdlsPeers:
441 * MAC Id cap up RSSI
442 * ---------------------------------
443 * 00:0a:f5:0e:bd:18 2 Y Y -44
444 * 00:0a:f5:bf:0e:12 0 N N 0
445 *
446 * This IOCTL is used to get all TDLS peers.
447 *
448 * @E.g: iwpriv wlan0 getTdlsPeers
449 *
450 * Supported Feature: TDLS
451 *
452 * Usage: Internal/External
453 *
454 * </ioctl>
455 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456#define WE_GET_TDLS_PEERS 8
457#endif
458#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +0530459/*
460 * <ioctl>
461 * getPMFInfo - get the PMF info of the connected session
462 *
463 * @INPUT: None
464 *
465 * @OUTPUT:
466 * wlan0 getPMFInfo:
467 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
468 * Number of Unprotected Disassocs 0
469 * Number of Unprotected Deauths 0
470 *
471 * This IOCTL is used to get the PMF stats/status of the current
472 * connection.
473 *
474 * @e.g:iwpriv wlan0 getPMFInfo
475 *
476 * Supported Feature: PMF
477 *
478 * Usage: Internal/External
479 *
480 * </ioctl>
481 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482#define WE_GET_11W_INFO 9
483#endif
484#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +0530485/*
486 * <ioctl>
487 * getIbssSTAs - get ibss sta info
488 *
489 * @INPUT: None
490 *
491 * @OUTPUT: Give the MAC of the IBSS STA
492 * wlan0 getIbssSTAs:
493 * 1 .8c:fd:f0:01:9c:bf
494 *
495 * This IOCTL is used to get ibss sta info
496 *
497 * @E.g: iwpriv wlan0 getIbssSTAs
498 *
499 * Supported Feature: IBSS
500 *
501 * Usage: Internal/External
502 *
503 * </ioctl>
504 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800505#define WE_GET_IBSS_STA_INFO 11
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506#define WE_GET_PHYMODE 12
507#ifdef FEATURE_OEM_DATA_SUPPORT
508#define WE_GET_OEM_DATA_CAP 13
509#endif
510#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +0530511#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512
513/* Private ioctls and their sub-ioctls */
514#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
515#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +0530516/*
517 * <ioctl>
518 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
519 *
520 * @INPUT: None
521 *
522 * @OUTPUT: print ibss peer in info logs
523 * pPeerInfo->numIBSSPeers = 1
524 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
525 *
526 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
527 * in info logs
528 *
529 * @E.g: iwpriv wlan0 ibssPeerInfoAll
530 *
531 * Supported Feature: IBSS
532 *
533 * Usage: Internal/External
534 *
535 * </ioctl>
536 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800537#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -0800538/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -0800540#define WE_GET_FW_PROFILE_DATA 18
541#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800542
543/* Private ioctls and their sub-ioctls */
544#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
545
546#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +0530547/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800548
Manjeet Singhf82ed072016-07-08 11:40:00 +0530549#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550
551#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +0530552/*
553 * <ioctl>
554 * setTdlsConfig - Set TDLS configuration parameters.
555 *
556 * @INPUT: 11 TDLS configuration parameters
557 * @args[0]: tdls: [0..2]
558 * @args[1]: tx_period_t: [1000..4294967295UL]
559 * @args[2]: tx_packet_n: [0..4294967295UL]
560 * @args[3]: [discovery_period is not used anymore]
561 * @args[4]: discovery_tries_n: [1..100]
562 * @args[5]: [idle_timeout is not used anymore]
563 * @args[6]: idle_packet_n: [0..40000]
564 * @args[7]: [rssi_hysteresis is not used anymore]
565 * @args[8]: rssi_trigger_threshold: [-120..0]
566 * @args[9]: rssi_teardown_threshold: [-120..0]
567 * @args[10]: rssi_delta: [-30..0]
568 *
569 * @OUTPUT: None
570 *
571 * This IOCTL is used to set the TDLS configuration parameters.
572 *
573 * @E.g: iwpriv wlan0 setTdlsConfig tdls tx_period_t tx_packet_n
574 * discovery_period discovery_tries_n idle_timeout
575 * idle_packet_n rssi_hysteresis rssi_trigger_threshold
576 * rssi_teardown_threshold rssi_delta
577 * iwpriv wlan0 setTdlsConfig 1 1500 40 1 5 1 5 0 -70 -70 -10
578 *
579 * Supported Feature: TDLS
580 *
581 * Usage: Internal/External
582 *
583 * </ioctl>
584 */
585
586
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800587#define WE_TDLS_CONFIG_PARAMS 5
588#endif
Abhishek Singh49b654e2016-12-01 16:11:17 +0530589/*
590 * <ioctl>
591 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
592 *
593 * @INPUT: staid
594 *
595 * @OUTPUT: print ibss peer corresponding to staid in info logs
596 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
597 *
598 * This IOCTL is used to print the specific ibss peers's MAC,
599 * rate and RSSI in info logs
600 *
601 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
602 * iwpriv wlan0 ibssPeerInfo 0
603 *
604 * Supported Feature: IBSS
605 *
606 * Usage: Internal/External
607 *
608 * </ioctl>
609 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800610#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611#define WE_UNIT_TEST_CMD 7
612
613#define WE_MTRACE_DUMP_CMD 8
614#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
615
616
617#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
618#define WE_LED_FLASHING_PARAM 10
619#endif
620
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530621/*
622 * <ioctl>
623 * pm_clist - Increments the index value of the concurrent connection list
624 * and update with the input parameters provided.
625 *
626 * @INPUT: Following 8 arguments:
627 * @vdev_id: vdev id
628 * @tx_streams: TX streams
629 * @rx_streams: RX streams
630 * @chain_mask: Chain mask
631 * @type: vdev_type
632 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
633 * @sub_type: vdev_subtype
634 * P2P_Device:1 P2P_Client:2 P2P_GO:3
635 * Proxy_STA:4 Mesh:5 Mesh_11s:6
636 * @channel: Channel
637 * @mac: Mac id
638 *
639 * @OUTPUT: None
640 *
641 * This IOCTL is used to increments the index value of the concurrent connection
642 * list and update with the input parameters provided.
643 *
644 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
645 * sub_type channel mac
646 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
647 *
648 * Supported Feature: DBS
649 *
650 * Usage: Internal/External
651 *
652 * </ioctl>
653 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530655
656/*
657 * <ioctl>
658 * pm_dlist - Delete the index from the concurrent connection list that is
659 * present in the given vdev_id.
660 *
661 * @INPUT: delete_all, vdev_id
662 * @delete_all: delete all indices
663 * @vdev_id: vdev id
664 *
665 * @OUTPUT: None
666 *
667 * This IOCTL is used to delete the index from the concurrent connection list
668 * that is present in the given vdev_id.
669 *
670 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
671 * iwpriv wlan0 pm_dlist 0 1
672 *
673 * Supported Feature: DBS
674 *
675 * Usage: Internal/External
676 *
677 * </ioctl>
678 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530680
681/*
682 * <ioctl>
683 * pm_dbs - Set dbs capability and system preference
684 *
685 * @INPUT: dbs, system_pref
686 * @dbs: Value of DBS capability to be set
687 * @system_pref: System preference
688 * 0:CDS_THROUGHPUT 1: CDS_POWERSAVE 2: CDS_LATENCY
689 *
690 * @OUTPUT: None
691 *
692 * This IOCTL is used to set dbs capability and system preference.
693 *
694 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
695 * iwpriv wlan0 pm_dbs 1 0
696 *
697 * Supported Feature: DBS
698 *
699 * Usage: Internal/External
700 *
701 * </ioctl>
702 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800703#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530704
705/*
706 * <ioctl>
707 * pm_pcl - Set pcl for concurrency mode.
708 *
709 * @INPUT: cds_con_mode
710 * @cds_con_mode: concurrency mode for PCL table
711 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
712 *
713 * @OUTPUT: None
714 *
715 * This IOCTL is used to set pcl for concurrency mode.
716 *
717 * @E.g: iwpriv wlan0 pm_pcl cds_con_mode
718 * iwpriv wlan0 pm_pcl 0
719 *
720 * Supported Feature: DBS
721 *
722 * Usage: Internal/External
723 *
724 * </ioctl>
725 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800726#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530727
728/*
729 * <ioctl>
730 * pm_cinfo - Shows the concurrent connection list.
731 *
732 * @INPUT: None
733 *
734 * @OUTPUT: None
735 *
736 * This IOCTL is used to show the concurrent connection list.
737 *
738 * @E.g: iwpriv wlan0 pm_cinfo
739 *
740 * Supported Feature: DBS
741 *
742 * Usage: Internal/External
743 *
744 * </ioctl>
745 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530747
748/*
749 * <ioctl>
750 * pm_ulist - Updates the index value of the concurrent connection list
751 * with the input parameters provided.
752 *
753 * @INPUT: Following 8 arguments:
754 * @vdev_id: vdev id
755 * @tx_streams: TX streams
756 * @rx_streams: RX streams
757 * @chain_mask: Chain mask
758 * @type: vdev_type
759 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
760 * @sub_type: vdev_subtype
761 * P2P_Device:1 P2P_Client:2 P2P_GO:3
762 * Proxy_STA:4 Mesh:5 Mesh_11s:6
763 * @channel: Channel
764 * @mac: Mac id
765 *
766 * @OUTPUT: None
767 *
768 * This IOCTL is used to updates the index value of the concurrent
769 * connection list with the input parameters provided.
770 *
771 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
772 * sub_type channel mac
773 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
774 *
775 * Supported Feature: DBS
776 *
777 * Usage: Internal/External
778 *
779 * </ioctl>
780 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530782
783/*
784 * <ioctl>
785 * pm_query_action - Initiate actions needed on current connections as
786 * per the channel provided.
787 *
788 * @INPUT: channel
789 * @channel: Channel on which new connection will be.
790 *
791 * @OUTPUT: None
792 *
793 * This IOCTL is used to initiate actions needed on current connections
794 * as per the channel provided.
795 *
796 * @E.g: iwpriv wlan0 pm_query_action channel
797 * iwpriv wlan0 pm_query_action 6
798 *
799 * Supported Feature: DBS
800 *
801 * Usage: Internal/External
802 *
803 * </ioctl>
804 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530806
807/*
808 * <ioctl>
809 * pm_query_allow - Checks for allowed concurrency combination
810 *
811 * @INPUT: mode, channel, bandwidth
812 * @mode: new connection mode
813 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
814 * @channel: channel on which new connection is coming up
815 * @bandwidth: Bandwidth requested by the connection
816 * 0:None 1:5MHz 2:10MHz 3:20MHz
817 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
818 *
819 * @OUTPUT: None
820 *
821 * This IOCTL is used to checks for allowed concurrency combination.
822 *
823 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
824 * iwpriv wlan0 pm_query_allow 0 6 4
825 *
826 * Supported Feature: DBS
827 *
828 * Usage: Internal/External
829 *
830 * </ioctl>
831 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530833
834/*
835 * <ioctl>
836 * pm_run_scenario - Create scenario with number of connections provided.
837 *
838 * @INPUT: num_of_conn
839 * @num_of_conn: the number of connections (values: 1~3)
840 *
841 * @OUTPUT: None
842 *
843 * This IOCTL is used to create scenario with the number of connections
844 * provided.
845 *
846 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
847 * iwpriv wlan0 pm_run_scenario 1
848 *
849 * Supported Feature: DBS
850 *
851 * Usage: Internal/External
852 *
853 * </ioctl>
854 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530856
857/*
858 * <ioctl>
859 * pm_set_hw_mode - Set hardware for single/dual mac.
860 *
861 * @INPUT: hw_mode
862 * 0:single mac 1:dual mac
863 *
864 * @OUTPUT: None
865 *
866 * This IOCTL is used to set hardware for single/dual mac.
867 *
868 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
869 * iwpriv wlan0 pm_set_hw_mode 1
870 *
871 * Supported Feature: DBS
872 *
873 * Usage: Internal/External
874 *
875 * </ioctl>
876 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877#define WE_POLICY_SET_HW_MODE_CMD 20
878
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530879/*
880 * <ioctl>
881 * set_scan_cfg - Set dual MAC scan config parameters.
882 *
883 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
884 * @dbs: Value of DBS bit
885 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
886 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
887 *
888 * @OUTPUT: None
889 *
890 * This IOCTL is used to set the dual MAC scan config.
891 *
892 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
893 * single_mac_scan_with_dbs
894 * iwpriv wlan0 set_scan_cfg 1 0 1
895 *
896 * Supported Feature: DBS
897 *
898 * Usage: Internal/External
899 *
900 * </ioctl>
901 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +0530903
904/*
905 * <ioctl>
906 * set_fw_mode_cfg - Sets the dual mac FW mode config
907 *
908 * @INPUT: dbs, dfs
909 * @dbs: DBS bit
910 * @dfs: Agile DFS bit
911 *
912 * @OUTPUT: None
913 *
914 * This IOCTL is used to set the dual mac FW mode config.
915 *
916 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
917 * iwpriv wlan0 set_fw_mode_cfg 1 1
918 *
919 * Supported Feature: DBS
920 *
921 * Usage: Internal/External
922 *
923 * </ioctl>
924 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -0700926#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927
928#ifdef FEATURE_WLAN_TDLS
929#undef MAX_VAR_ARGS
930#define MAX_VAR_ARGS 11
931#else
932#undef MAX_VAR_ARGS
933#define MAX_VAR_ARGS 9
934#endif
935
936/* Private ioctls (with no sub-ioctls) */
937/* note that they must be odd so that they have "get" semantics */
938#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
939#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
940#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
941
942/* (SIOCIWFIRSTPRIV + 8) is currently unused */
943/* (SIOCIWFIRSTPRIV + 10) is currently unused */
944/* (SIOCIWFIRSTPRIV + 12) is currently unused */
945/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -0700946#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
947#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948/* (SIOCIWFIRSTPRIV + 16) is currently unused */
949/* (SIOCIWFIRSTPRIV + 17) is currently unused */
950/* (SIOCIWFIRSTPRIV + 19) is currently unused */
951
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953
954/* Private ioctl for setting the host offload feature */
955#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
956
957/* Private ioctl to get the statistics */
958#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
959
960/* Private ioctl to set the Keep Alive Params */
961#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
962
963#ifdef WLAN_FEATURE_PACKET_FILTERING
964/* Private ioctl to set the packet filtering params */
965#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
966#endif
967
968
969#ifdef FEATURE_WLAN_SCAN_PNO
970/* Private ioctl to get the statistics */
971#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
972#endif
973
974#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
975
Dustin Brown0cbc7572016-12-16 13:54:40 -0800976#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -0800977/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978
979/* Private ioctls and their sub-ioctls */
980#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
981#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -0700982#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983#define WE_SET_FW_CRASH_INJECT 2
984#endif
985#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +0530986/* Private sub ioctl for enabling and setting histogram interval of profiling */
987#define WE_ENABLE_FW_PROFILE 4
988#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989
Rajeev Kumar9bb2e852016-09-24 12:29:25 -0700990/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700991#define WE_SET_WLAN_SUSPEND 6
992#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -0700993
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994/* (SIOCIWFIRSTPRIV + 29) is currently unused */
995
996/* 802.11p IOCTL */
997#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
998
999#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
1000
1001#define WLAN_STATS_INVALID 0
1002#define WLAN_STATS_RETRY_CNT 1
1003#define WLAN_STATS_MUL_RETRY_CNT 2
1004#define WLAN_STATS_TX_FRM_CNT 3
1005#define WLAN_STATS_RX_FRM_CNT 4
1006#define WLAN_STATS_FRM_DUP_CNT 5
1007#define WLAN_STATS_FAIL_CNT 6
1008#define WLAN_STATS_RTS_FAIL_CNT 7
1009#define WLAN_STATS_ACK_FAIL_CNT 8
1010#define WLAN_STATS_RTS_SUC_CNT 9
1011#define WLAN_STATS_RX_DISCARD_CNT 10
1012#define WLAN_STATS_RX_ERROR_CNT 11
1013#define WLAN_STATS_TX_BYTE_CNT 12
1014
1015#define WLAN_STATS_RX_BYTE_CNT 13
1016#define WLAN_STATS_RX_RATE 14
1017#define WLAN_STATS_TX_RATE 15
1018
1019#define WLAN_STATS_RX_UC_BYTE_CNT 16
1020#define WLAN_STATS_RX_MC_BYTE_CNT 17
1021#define WLAN_STATS_RX_BC_BYTE_CNT 18
1022#define WLAN_STATS_TX_UC_BYTE_CNT 19
1023#define WLAN_STATS_TX_MC_BYTE_CNT 20
1024#define WLAN_STATS_TX_BC_BYTE_CNT 21
1025
1026#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
1027 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
1028 *__p++ = __type; \
1029 *__p++ = __size; \
1030 memcpy(__p, __val, __size); \
1031 __p += __size; \
1032 __tlen += __size + 2; \
1033 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07001034 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 } \
1036 } while (0)
1037
1038#define VERSION_VALUE_MAX_LEN 32
1039
1040#define TX_PER_TRACKING_DEFAULT_RATIO 5
1041#define TX_PER_TRACKING_MAX_RATIO 10
1042#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
1043
1044#define WLAN_ADAPTER 0
1045#define P2P_ADAPTER 1
1046
1047/**
1048 * mem_alloc_copy_from_user_helper - copy from user helper
1049 * @wrqu_data: wireless extensions request data
1050 * @len: length of @wrqu_data
1051 *
1052 * Helper function to allocate buffer and copy user data.
1053 *
1054 * Return: On success return a pointer to a kernel buffer containing a
1055 * copy of the userspace data (with an additional NUL character
1056 * appended for safety). On failure return %NULL.
1057 */
1058void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
1059{
1060 u8 *ptr = NULL;
1061
1062 /* in order to protect the code, an extra byte is post
1063 * appended to the buffer and the null termination is added.
1064 * However, when allocating (len+1) byte of memory, we need to
1065 * make sure that there is no uint overflow when doing
1066 * addition. In theory check len < UINT_MAX protects the uint
1067 * overflow. For wlan private ioctl, the buffer size is much
1068 * less than UINT_MAX, as a good guess, now, it is assumed
1069 * that the private command buffer size is no greater than 4K
1070 * (4096 bytes). So we use 4096 as the upper boundary for now.
1071 */
1072 if (len > MAX_USER_COMMAND_SIZE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001073 hdd_err("Invalid length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 return NULL;
1075 }
1076
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001077 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001079 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 return NULL;
1081 }
1082
1083 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001084 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001085 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 return NULL;
1087 }
1088 ptr[len] = '\0';
1089 return ptr;
1090}
1091
1092/**
1093 * hdd_priv_get_data() - Get pointer to ioctl private data
1094 * @p_priv_data: pointer to iw_point struct to be filled
1095 * @wrqu: Pointer to IOCTL Data received from userspace
1096 *
1097 * Helper function to get compatible struct iw_point passed to ioctl
1098 *
1099 * Return - 0 if p_priv_data successfully filled, error otherwise
1100 */
1101int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
1102{
1103 if ((NULL == p_priv_data) || (NULL == wrqu)) {
1104 return -EINVAL;
1105 }
1106#ifdef CONFIG_COMPAT
1107 if (is_compat_task()) {
1108 struct compat_iw_point *p_compat_priv_data;
1109
1110 /* Compat task:
1111 * typecast to compat structure and copy the members.
1112 */
1113 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
1114
1115 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
1116 p_priv_data->length = p_compat_priv_data->length;
1117 p_priv_data->flags = p_compat_priv_data->flags;
1118 } else {
1119#endif /* #ifdef CONFIG_COMPAT */
1120
1121 /* Non compat task: directly copy the structure. */
1122 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
1123
1124#ifdef CONFIG_COMPAT
1125 }
1126#endif /* #ifdef CONFIG_COMPAT */
1127
1128 return 0;
1129}
1130
1131
1132/**
1133 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
1134 * @pAdapter: Pointer to the hdd adapter.
1135 * @length: Size of the data copied
1136 * @buffer: Pointer to char buffer.
1137 * @buf_len: Length of the char buffer.
1138 *
1139 * This function called when the "iwpriv wlan0 get_stats" command is given.
1140 * It used to collect the txrx stats when the device is configured in SAP mode.
1141 *
1142 * Return - none
1143 */
1144void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
1145 char *buffer, uint16_t buf_len)
1146{
1147 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
1148 uint32_t len = 0;
1149 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
1150 uint32_t total_rx_delv = 0, total_rx_refused = 0;
1151 int i = 0;
1152
1153 for (; i < NUM_CPUS; i++) {
1154 total_rx_pkt += pStats->rxPackets[i];
1155 total_rx_dropped += pStats->rxDropped[i];
1156 total_rx_delv += pStats->rxDelivered[i];
1157 total_rx_refused += pStats->rxRefused[i];
1158 }
1159
1160 len = scnprintf(buffer, buf_len,
1161 "\nTransmit"
1162 "\ncalled %u, dropped %u,"
1163 "\n dropped BK %u, BE %u, VI %u, VO %u"
1164 "\n classified BK %u, BE %u, VI %u, VO %u"
1165 "\ncompleted %u,"
1166 "\n\nReceive Total"
1167 "\n packets %u, dropped %u, delivered %u, refused %u"
1168 "\n",
1169 pStats->txXmitCalled,
1170 pStats->txXmitDropped,
1171
1172 pStats->txXmitDroppedAC[SME_AC_BK],
1173 pStats->txXmitDroppedAC[SME_AC_BE],
1174 pStats->txXmitDroppedAC[SME_AC_VI],
1175 pStats->txXmitDroppedAC[SME_AC_VO],
1176
1177 pStats->txXmitClassifiedAC[SME_AC_BK],
1178 pStats->txXmitClassifiedAC[SME_AC_BE],
1179 pStats->txXmitClassifiedAC[SME_AC_VI],
1180 pStats->txXmitClassifiedAC[SME_AC_VO],
1181
1182 pStats->txCompleted,
1183 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
1184 );
1185
1186 for (i = 0; i < NUM_CPUS; i++) {
1187 len += scnprintf(buffer + len, buf_len - len,
1188 "\nReceive CPU: %d"
1189 "\n packets %u, dropped %u, delivered %u, refused %u",
1190 i, pStats->rxPackets[i], pStats->rxDropped[i],
1191 pStats->rxDelivered[i], pStats->rxRefused[i]);
1192 }
1193
1194 len += scnprintf(buffer + len, buf_len - len,
1195 "\n\nTX_FLOW"
1196 "\nCurrent status: %s"
1197 "\ntx-flow timer start count %u"
1198 "\npause count %u, unpause count %u",
1199 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
1200 pStats->txflow_timer_cnt,
1201 pStats->txflow_pause_cnt,
1202 pStats->txflow_unpause_cnt);
1203
Leo Changfdb45c32016-10-28 11:09:23 -07001204 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
1205 pAdapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206
1207 len += hdd_napi_stats(buffer + len, buf_len - len,
1208 NULL, hdd_napi_get_all());
1209
1210 *length = len + 1;
1211}
1212
1213/**
Dustin Brownd9322482017-01-09 12:46:03 -08001214 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
1215 * @hdd_ctx: The Hdd context owning the stats to be written
1216 * @buffer: The char buffer to write to
1217 * @max_len: The maximum number of chars to write
1218 *
1219 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
1220 *
1221 * Return - length of written content, negative number on error
1222 */
1223static int wlan_hdd_write_suspend_resume_stats(hdd_context_t *hdd_ctx,
1224 char *buffer, uint16_t max_len)
1225{
1226 QDF_STATUS status;
1227 struct suspend_resume_stats *sr_stats;
1228 struct sir_wake_lock_stats wow_stats;
1229
1230 sr_stats = &hdd_ctx->suspend_resume_stats;
1231
1232 status = wma_get_wakelock_stats(&wow_stats);
1233 if (QDF_IS_STATUS_ERROR(status)) {
1234 hdd_err("Failed to get WoW stats");
1235 return qdf_status_to_os_return(status);
1236 }
1237
1238 return scnprintf(buffer, max_len,
1239 "\n"
1240 "Suspends: %u\n"
1241 "Resumes: %u\n"
1242 "\n"
1243 "Suspend Fail Reasons\n"
1244 "\tIPA: %u\n"
1245 "\tRadar: %u\n"
1246 "\tRoam: %u\n"
1247 "\tScan: %u\n"
1248 "\tInitial Wakeup: %u\n"
1249 "\n"
1250 "WoW Wake Reasons\n"
1251 "\tunicast: %u\n"
1252 "\tbroadcast: %u\n"
1253 "\tIPv4 multicast: %u\n"
1254 "\tIPv6 multicast: %u\n"
1255 "\tIPv6 multicast RA: %u\n"
1256 "\tIPv6 multicast NS: %u\n"
1257 "\tIPv6 multicast NA: %u\n"
1258 "\tICMPv4: %u\n"
1259 "\tICMPv6: %u\n"
1260 "\tRSSI Breach: %u\n"
1261 "\tLow RSSI: %u\n"
1262 "\tG-Scan: %u\n"
1263 "\tPNO Complete: %u\n"
1264 "\tPNO Match: %u\n",
1265 sr_stats->suspends,
1266 sr_stats->resumes,
1267 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
1268 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
1269 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
1270 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
1271 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
1272 wow_stats.wow_ucast_wake_up_count,
1273 wow_stats.wow_bcast_wake_up_count,
1274 wow_stats.wow_ipv4_mcast_wake_up_count,
1275 wow_stats.wow_ipv6_mcast_wake_up_count,
1276 wow_stats.wow_ipv6_mcast_ra_stats,
1277 wow_stats.wow_ipv6_mcast_ns_stats,
1278 wow_stats.wow_ipv6_mcast_na_stats,
1279 wow_stats.wow_icmpv4_count,
1280 wow_stats.wow_icmpv6_count,
1281 wow_stats.wow_rssi_breach_wake_up_count,
1282 wow_stats.wow_low_rssi_wake_up_count,
1283 wow_stats.wow_gscan_wake_up_count,
1284 wow_stats.wow_pno_complete_wake_up_count,
1285 wow_stats.wow_pno_match_wake_up_count);
1286}
1287
1288/**
Govind Singha471e5e2015-10-12 17:11:14 +05301289 * hdd_wlan_list_fw_profile() - Get fw profiling points
1290 * @length: Size of the data copied
1291 * @buffer: Pointer to char buffer.
1292 * @buf_len: Length of the char buffer.
1293 *
1294 * This function called when the "iwpriv wlan0 listProfile" command is given.
1295 * It is used to get the supported profiling points in FW.
1296 *
1297 * Return - none
1298 */
1299void hdd_wlan_list_fw_profile(uint16_t *length,
1300 char *buffer, uint16_t buf_len)
1301{
1302 uint32_t len = 0;
1303
1304 len = scnprintf(buffer, buf_len,
1305 "PROF_CPU_IDLE: %u\n"
1306 "PROF_PPDU_PROC: %u\n"
1307 "PROF_PPDU_POST: %u\n"
1308 "PROF_HTT_TX_INPUT: %u\n"
1309 "PROF_MSDU_ENQ: %u\n"
1310 "PROF_PPDU_POST_HAL: %u\n"
1311 "PROF_COMPUTE_TX_TIME: %u\n",
1312 PROF_CPU_IDLE,
1313 PROF_PPDU_PROC,
1314 PROF_PPDU_POST,
1315 PROF_HTT_TX_INPUT,
1316 PROF_MSDU_ENQ,
1317 PROF_PPDU_POST_HAL,
1318 PROF_COMPUTE_TX_TIME);
1319
1320 *length = len + 1;
1321}
1322
1323/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 * hdd_wlan_dump_stats() - display dump Stats
1325 * @adapter: adapter handle
1326 * @value: value from user
1327 *
1328 * Return: none
1329 */
1330void hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value)
1331{
1332 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
1333
1334 switch (value) {
1335
1336 case WLAN_TXRX_HIST_STATS:
1337 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
1338 break;
1339 case WLAN_HDD_NETIF_OPER_HISTORY:
1340 wlan_hdd_display_netif_queue_history(hdd_ctx);
1341 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05301342 case WLAN_HIF_STATS:
1343 hdd_display_hif_stats();
1344 break;
Dhanashri Atree7d442a2016-07-14 18:20:29 -07001345 case WLAN_LRO_STATS:
1346 hdd_lro_display_stats(hdd_ctx);
1347 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 default:
Leo Changfdb45c32016-10-28 11:09:23 -07001349 cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350 break;
1351 }
1352}
1353
1354/**
1355 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301356 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 * @wrqu: Pointer to IOCTL REQUEST Data.
1358 * @extra: Pointer to destination buffer
1359 *
1360 * This function is used to get Wlan Driver, Firmware, & Hardware
1361 * Version information. If @wrqu and @extra are specified, then the
1362 * version string is returned. Otherwise it is simply printed to the
1363 * kernel log.
1364 *
1365 * Return: none
1366 */
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301367void hdd_wlan_get_version(hdd_context_t *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 char *extra)
1369{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301370 tSirVersionString wcnss_sw_version;
1371 const char *swversion;
1372 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001373 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301375 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001376 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 goto error;
1378 }
1379
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301380 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
1381 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301383 swversion = wcnss_sw_version;
1384 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
1385 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
1386 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
1387 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001388 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389
Arun Khandavallia96c2c02016-05-17 19:15:34 +05301390 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001391
1392 if (wrqu && extra) {
1393 wrqu->data.length =
1394 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001395 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001397 msp_id, mspid, siid, crmid,
1398 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001400 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07001402 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403 }
1404error:
1405 return;
1406}
1407
1408/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001409 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
1410 * @pAdapter: Adapter upon which the IBSS client is active
1411 * @staIdx: Station index of the IBSS peer
1412 *
1413 * Return: a pointer to the MAC address of the IBSS peer if the peer is
1414 * found, otherwise %NULL.
1415 */
1416struct qdf_mac_addr *
1417hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
1418 uint8_t staIdx)
1419{
1420 uint8_t idx;
1421 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1422
Naveen Rawatc45d1622016-07-05 12:20:09 -07001423 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001424 if (0 != pHddStaCtx->conn_info.staId[idx] &&
1425 staIdx == pHddStaCtx->conn_info.staId[idx]) {
1426 return &pHddStaCtx->conn_info.peerMacAddress[idx];
1427 }
1428 }
1429 return NULL;
1430}
1431
1432/**
1433 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
1434 * @pAdapter: Adapter upon which the IBSS client is active
1435 * @staIdx: Station index of the IBSS peer
1436 *
1437 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
1438 * otherwise an appropriate QDF_STATUS_E_* failure code.
1439 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001440static QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter,
1441 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001442{
1443 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1444 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1445 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001446 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001447
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001448 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08001449 status = sme_request_ibss_peer_info(hHal, pAdapter,
1450 hdd_get_ibss_peer_info_cb,
1451 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001452
1453 if (QDF_STATUS_SUCCESS == status) {
1454 unsigned long rc;
1455 rc = wait_for_completion_timeout
1456 (&pAdapter->ibss_peer_info_comp,
1457 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
1458 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001459 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001460 return QDF_STATUS_E_FAILURE;
1461 }
1462
1463 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001464 hdd_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001465 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001466 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
1467 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001468
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001469 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
1470 mac_addr, sizeof(mac_addr));
1471 hdd_info("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
1472 mac_addr, (int)tx_rate,
1473 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001474 }
1475 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07001476 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001477 }
1478
1479 return status;
1480}
1481
1482/**
1483 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
1484 * @pAdapter: Adapter upon which the IBSS clients are active
1485 *
1486 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
1487 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
1488 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07001489static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001490{
1491 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1492 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1493 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001494 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001495 int i;
1496
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001497 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08001498 status = sme_request_ibss_peer_info(hHal, pAdapter,
1499 hdd_get_ibss_peer_info_cb,
1500 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001501
1502 if (QDF_STATUS_SUCCESS == status) {
1503 unsigned long rc;
1504 rc = wait_for_completion_timeout
1505 (&pAdapter->ibss_peer_info_comp,
1506 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
1507 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001508 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001509 return QDF_STATUS_E_FAILURE;
1510 }
1511
1512 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001513 hdd_info("pPeerInfo->numIBSSPeers = %d ",
1514 (int)pPeerInfo->numPeers);
1515 for (i = 0; i < pPeerInfo->numPeers; i++) {
1516 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
1517 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001518
Rajeev Kumar94c9b452016-03-24 12:58:47 -07001519 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
1520 qdf_mem_copy(mac_addr,
1521 pPeerInfo->peerInfoParams[i].mac_addr,
1522 sizeof(mac_addr));
1523
1524 hdd_info(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
1525 mac_addr, (int)tx_rate,
1526 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001527 }
1528 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07001529 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001530 }
1531
1532 return status;
1533}
1534
1535/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 * hdd_wlan_get_rts_threshold() - Get RTS threshold
1537 * @pAdapter: adapter upon which the request was received
1538 * @wrqu: pointer to the ioctl request
1539 *
1540 * This function retrieves the current RTS threshold value and stores
1541 * it in the ioctl request structure
1542 *
1543 * Return: 0 if valid data was returned, non-zero on error
1544 */
1545int hdd_wlan_get_rts_threshold(hdd_adapter_t *pAdapter, union iwreq_data *wrqu)
1546{
1547 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1548 uint32_t threshold = 0;
1549 hdd_context_t *hdd_ctx;
1550 int ret = 0;
1551
1552 ENTER();
1553
1554 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001555 hdd_err("Adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 return -EINVAL;
1557 }
1558
1559 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
1560 ret = wlan_hdd_validate_context(hdd_ctx);
1561 if (0 != ret)
1562 return ret;
1563
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301564 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 sme_cfg_get_int(hHal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001566 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 return -EIO;
1568 }
1569 wrqu->rts.value = threshold;
1570
Jeff Johnson99bac312016-06-28 10:38:18 -07001571 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572
1573 EXIT();
1574
1575 return 0;
1576}
1577
1578/**
1579 * hdd_wlan_get_frag_threshold() - Get fragmentation threshold
1580 * @pAdapter: adapter upon which the request was received
1581 * @wrqu: pointer to the ioctl request
1582 *
1583 * This function retrieves the current fragmentation threshold value
1584 * and stores it in the ioctl request structure
1585 *
1586 * Return: 0 if valid data was returned, non-zero on error
1587 */
1588int hdd_wlan_get_frag_threshold(hdd_adapter_t *pAdapter,
1589 union iwreq_data *wrqu)
1590{
1591 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1592 uint32_t threshold = 0, status = 0;
1593 hdd_context_t *hdd_ctx;
1594
1595 ENTER();
1596
1597 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001598 hdd_err("Adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599 return -EINVAL;
1600 }
1601
1602 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
1603 status = wlan_hdd_validate_context(hdd_ctx);
1604 if (0 != status)
1605 return status;
1606
1607 if (sme_cfg_get_int(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301608 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001609 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610 return -EIO;
1611 }
1612 wrqu->frag.value = threshold;
1613
Jeff Johnson99bac312016-06-28 10:38:18 -07001614 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615
1616 EXIT();
1617
1618 return 0;
1619}
1620
1621/**
1622 * hdd_wlan_get_freq() - Convert channel to frequency
1623 * @channel: channel to be converted
1624 * @pfreq: where to store the frequency
1625 *
1626 * Return: 1 on success, otherwise a negative errno
1627 */
1628int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
1629{
1630 int i;
1631 if (channel > 0) {
1632 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
1633 if (channel == freq_chan_map[i].chan) {
1634 *pfreq = freq_chan_map[i].freq;
1635 return 1;
1636 }
1637 }
1638 }
Jeff Johnson99bac312016-06-28 10:38:18 -07001639 hdd_notice("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 return -EINVAL;
1641}
1642
1643/**
1644 * hdd_is_auth_type_rsn() - RSN authentication type check
1645 * @authType: authentication type to be checked
1646 *
1647 * Return: true if @authType is an RSN authentication type,
1648 * false if it is not
1649 */
1650static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
1651{
1652 bool rsnType = false;
1653 /* is the authType supported? */
1654 switch (authType) {
1655 case eCSR_AUTH_TYPE_NONE: /* never used */
1656 rsnType = false;
1657 break;
1658 /* MAC layer authentication types */
1659 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
1660 rsnType = false;
1661 break;
1662 case eCSR_AUTH_TYPE_SHARED_KEY:
1663 rsnType = false;
1664 break;
1665 case eCSR_AUTH_TYPE_AUTOSWITCH:
1666 rsnType = false;
1667 break;
1668
1669 /* Upper layer authentication types */
1670 case eCSR_AUTH_TYPE_WPA:
1671 rsnType = true;
1672 break;
1673 case eCSR_AUTH_TYPE_WPA_PSK:
1674 rsnType = true;
1675 break;
1676 case eCSR_AUTH_TYPE_WPA_NONE:
1677 rsnType = true;
1678 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680 case eCSR_AUTH_TYPE_RSN:
1681 rsnType = true;
1682 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 case eCSR_AUTH_TYPE_RSN_PSK:
1685#ifdef WLAN_FEATURE_11W
1686 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
1687 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
1688#endif
1689 rsnType = true;
1690 break;
1691 /* case eCSR_AUTH_TYPE_FAILED: */
1692 case eCSR_AUTH_TYPE_UNKNOWN:
1693 rsnType = false;
1694 break;
1695 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07001696 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 authType);
1698 rsnType = false;
1699 break;
1700 }
Jeff Johnson99bac312016-06-28 10:38:18 -07001701 hdd_notice("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 authType, rsnType);
1703 return rsnType;
1704}
1705
1706/**
1707 * hdd_get_rssi_cb() - "Get RSSI" callback function
1708 * @rssi: Current RSSI of the station
1709 * @staId: ID of the station
1710 * @pContext: opaque context originally passed to SME. HDD always passes
1711 * a &struct statsContext
1712 *
1713 * Return: None
1714 */
1715static void hdd_get_rssi_cb(int8_t rssi, uint32_t staId, void *pContext)
1716{
1717 struct statsContext *pStatsContext;
1718 hdd_adapter_t *pAdapter;
1719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001721 hdd_err("Bad param");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001722 return;
1723 }
1724
1725 pStatsContext = pContext;
1726 pAdapter = pStatsContext->pAdapter;
1727
1728 /* there is a race condition that exists between this callback
1729 * function and the caller since the caller could time out
1730 * either before or while this code is executing. we use a
1731 * spinlock to serialize these actions
1732 */
1733 spin_lock(&hdd_context_lock);
1734
1735 if ((NULL == pAdapter) ||
1736 (RSSI_CONTEXT_MAGIC != pStatsContext->magic)) {
1737 /* the caller presumably timed out so there is nothing
1738 * we can do
1739 */
1740 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07001741 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1742 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 return;
1744 }
1745
1746 /* context is valid so caller is still waiting */
1747
1748 /* paranoia: invalidate the magic */
1749 pStatsContext->magic = 0;
1750
1751 /* copy over the rssi */
1752 pAdapter->rssi = rssi;
1753
Sachin Ahujabef8c102015-11-16 15:15:49 +05301754 if (pAdapter->rssi > 0)
1755 pAdapter->rssi = 0;
1756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 /* notify the caller */
1758 complete(&pStatsContext->completion);
1759
1760 /* serialization is complete */
1761 spin_unlock(&hdd_context_lock);
1762}
1763
1764/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765 * wlan_hdd_get_rssi() - Get the current RSSI
1766 * @pAdapter: adapter upon which the measurement is requested
1767 * @rssi_value: pointer to where the RSSI should be returned
1768 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301769 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301771QDF_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772{
Houston Hoffman59c097f2016-11-09 15:50:25 -08001773 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 hdd_context_t *pHddCtx;
1775 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301776 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 unsigned long rc;
1778
1779 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001780 hdd_warn("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301781 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08001783 if (cds_is_driver_recovering()) {
1784 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
1785 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 /* return a cached value */
1787 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301788 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 }
1790
1791 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1792 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1793
1794 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301795 hdd_err("Not associated!, rssi on disconnect %d",
1796 pAdapter->rssi_on_disconnect);
1797 *rssi_value = pAdapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301798 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 }
1800
1801 if (pHddStaCtx->hdd_ReassocScenario) {
1802 hdd_info("Roaming in progress, return cached RSSI");
1803 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301804 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 }
1806
1807 init_completion(&context.completion);
1808 context.pAdapter = pAdapter;
1809 context.magic = RSSI_CONTEXT_MAGIC;
1810
1811 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
1812 pHddStaCtx->conn_info.staId[0],
1813 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
1814 &context, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301815 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001816 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 /* we'll returned a cached value below */
1818 } else {
1819 /* request was sent -- wait for the response */
1820 rc = wait_for_completion_timeout(&context.completion,
1821 msecs_to_jiffies
1822 (WLAN_WAIT_TIME_STATS));
1823 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001824 hdd_err("SME timed out while retrieving RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825 /* we'll now returned a cached value below */
1826 }
1827 }
1828
1829 /* either we never sent a request, we sent a request and
1830 * received a response or we sent a request and timed out. if
1831 * we never sent a request or if we sent a request and got a
1832 * response, we want to clear the magic out of paranoia. if
1833 * we timed out there is a race condition such that the
1834 * callback function could be executing at the same time we
1835 * are. of primary concern is if the callback function had
1836 * already verified the "magic" but had not yet set the
1837 * completion variable when a timeout occurred. we serialize
1838 * these activities by invalidating the magic while holding a
1839 * shared spinlock which will cause us to block if the
1840 * callback is currently executing
1841 */
1842 spin_lock(&hdd_context_lock);
1843 context.magic = 0;
1844 spin_unlock(&hdd_context_lock);
1845
1846 *rssi_value = pAdapter->rssi;
1847
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301848 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849}
1850
1851/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08001852 * hdd_get_snr_cb() - "Get SNR" callback function
1853 * @snr: Current SNR of the station
1854 * @staId: ID of the station
1855 * @pContext: opaque context originally passed to SME. HDD always passes
1856 * a &struct statsContext
1857 *
1858 * Return: None
1859 */
1860static void hdd_get_snr_cb(int8_t snr, uint32_t staId, void *pContext)
1861{
1862 struct statsContext *pStatsContext;
1863 hdd_adapter_t *pAdapter;
1864
1865 if (NULL == pContext) {
1866 hdd_err("Bad param");
1867 return;
1868 }
1869
1870 pStatsContext = pContext;
1871 pAdapter = pStatsContext->pAdapter;
1872
1873 /* there is a race condition that exists between this callback
1874 * function and the caller since the caller could time out
1875 * either before or while this code is executing. we use a
1876 * spinlock to serialize these actions
1877 */
1878 spin_lock(&hdd_context_lock);
1879
1880 if ((NULL == pAdapter) || (SNR_CONTEXT_MAGIC != pStatsContext->magic)) {
1881 /* the caller presumably timed out so there is nothing
1882 * we can do
1883 */
1884 spin_unlock(&hdd_context_lock);
1885 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
1886 pAdapter, pStatsContext->magic);
1887 return;
1888 }
1889
1890 /* context is valid so caller is still waiting */
1891
1892 /* paranoia: invalidate the magic */
1893 pStatsContext->magic = 0;
1894
1895 /* copy over the snr */
1896 pAdapter->snr = snr;
1897
1898 /* notify the caller */
1899 complete(&pStatsContext->completion);
1900
1901 /* serialization is complete */
1902 spin_unlock(&hdd_context_lock);
1903}
1904
1905/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 * wlan_hdd_get_snr() - Get the current SNR
1907 * @pAdapter: adapter upon which the measurement is requested
1908 * @snr: pointer to where the SNR should be returned
1909 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301910 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301912QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913{
Houston Hoffman59c097f2016-11-09 15:50:25 -08001914 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 hdd_context_t *pHddCtx;
1916 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301917 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 unsigned long rc;
1919 int valid;
1920
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301921 ENTER();
1922
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001924 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301925 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926 }
1927
1928 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1929
1930 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301931 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301932 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933
1934 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1935
1936 init_completion(&context.completion);
1937 context.pAdapter = pAdapter;
1938 context.magic = SNR_CONTEXT_MAGIC;
1939
1940 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
1941 pHddStaCtx->conn_info.staId[0],
1942 pHddStaCtx->conn_info.bssId, &context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301943 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001944 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 /* we'll returned a cached value below */
1946 } else {
1947 /* request was sent -- wait for the response */
1948 rc = wait_for_completion_timeout(&context.completion,
1949 msecs_to_jiffies
1950 (WLAN_WAIT_TIME_STATS));
1951 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07001952 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 /* we'll now returned a cached value below */
1954 }
1955 }
1956
1957 /* either we never sent a request, we sent a request and
1958 * received a response or we sent a request and timed out. if
1959 * we never sent a request or if we sent a request and got a
1960 * response, we want to clear the magic out of paranoia. if
1961 * we timed out there is a race condition such that the
1962 * callback function could be executing at the same time we
1963 * are. of primary concern is if the callback function had
1964 * already verified the "magic" but had not yet set the
1965 * completion variable when a timeout occurred. we serialize
1966 * these activities by invalidating the magic while holding a
1967 * shared spinlock which will cause us to block if the
1968 * callback is currently executing
1969 */
1970 spin_lock(&hdd_context_lock);
1971 context.magic = 0;
1972 spin_unlock(&hdd_context_lock);
1973
1974 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05301975 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301976 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977}
1978
1979/**
1980 * hdd_get_link_speed_cb() - Get link speed callback function
1981 * @pLinkSpeed: pointer to the link speed record
1982 * @pContext: pointer to the user context passed to SME
1983 *
1984 * This function is passed as the callback function to
1985 * sme_get_link_speed() by wlan_hdd_get_linkspeed_for_peermac(). By
1986 * agreement a &struct linkspeedContext is passed as @pContext. If
1987 * the context is valid, then the contents of @pLinkSpeed are copied
1988 * into the adapter record referenced by @pContext where they can be
1989 * subsequently retrieved. If the context is invalid, then this
1990 * function does nothing since it is assumed the caller has already
1991 * timed-out and destroyed the context.
1992 *
1993 * Return: None.
1994 */
1995static void
1996hdd_get_link_speed_cb(tSirLinkSpeedInfo *pLinkSpeed, void *pContext)
1997{
1998 struct linkspeedContext *pLinkSpeedContext;
1999 hdd_adapter_t *pAdapter;
2000
2001 if ((NULL == pLinkSpeed) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002002 hdd_err("Bad param, pLinkSpeed [%p] pContext [%p]",
2003 pLinkSpeed, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 return;
2005 }
2006 spin_lock(&hdd_context_lock);
2007 pLinkSpeedContext = pContext;
2008 pAdapter = pLinkSpeedContext->pAdapter;
2009
2010 /* there is a race condition that exists between this callback
2011 * function and the caller since the caller could time out either
2012 * before or while this code is executing. we use a spinlock to
2013 * serialize these actions
2014 */
2015
2016 if ((NULL == pAdapter) ||
2017 (LINK_CONTEXT_MAGIC != pLinkSpeedContext->magic)) {
2018 /* the caller presumably timed out so there is nothing
2019 * we can do
2020 */
2021 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07002022 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
2023 pAdapter, pLinkSpeedContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 return;
2025 }
2026
2027 /* context is valid so caller is still waiting */
2028
2029 /* paranoia: invalidate the magic */
2030 pLinkSpeedContext->magic = 0;
2031
2032 /* copy over the stats. do so as a struct copy */
2033 pAdapter->ls_stats = *pLinkSpeed;
2034
2035 /* notify the caller */
2036 complete(&pLinkSpeedContext->completion);
2037
2038 /* serialization is complete */
2039 spin_unlock(&hdd_context_lock);
2040}
2041
2042/**
2043 * wlan_hdd_get_linkspeed_for_peermac() - Get link speed for a peer
2044 * @pAdapter: adapter upon which the peer is active
2045 * @macAddress: MAC address of the peer
2046 *
2047 * This function will send a query to SME for the linkspeed of the
2048 * given peer, and then wait for the callback to be invoked.
2049 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302050 * Return: QDF_STATUS_SUCCESS if linkspeed data is available,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302051 * otherwise a QDF_STATUS_E_** error.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302053QDF_STATUS wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302054 struct qdf_mac_addr macAddress) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302055 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 unsigned long rc;
Houston Hoffman59c097f2016-11-09 15:50:25 -08002057 static struct linkspeedContext context;
Jeff Johnsona5317a62017-01-26 08:51:25 -08002058 tSirLinkSpeedInfo linkspeed_req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059
2060 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002061 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302062 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 init_completion(&context.completion);
2065 context.pAdapter = pAdapter;
2066 context.magic = LINK_CONTEXT_MAGIC;
2067
Jeff Johnsona5317a62017-01-26 08:51:25 -08002068 qdf_copy_macaddr(&linkspeed_req.peer_macaddr, &macAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnsona5317a62017-01-26 08:51:25 -08002070 &linkspeed_req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071 &context, hdd_get_link_speed_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302072 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002073 hdd_err("Unable to retrieve statistics for link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 } else {
2075 rc = wait_for_completion_timeout
2076 (&context.completion,
2077 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
2078 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002079 hdd_err("SME timed out while retrieving link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 }
2081 }
2082
2083 /* either we never sent a request, we sent a request and
2084 * received a response or we sent a request and timed out. if
2085 * we never sent a request or if we sent a request and got a
2086 * response, we want to clear the magic out of paranoia. if
2087 * we timed out there is a race condition such that the
2088 * callback function could be executing at the same time we
2089 * are. of primary concern is if the callback function had
2090 * already verified the "magic" but had not yet set the
2091 * completion variable when a timeout occurred. we serialize
2092 * these activities by invalidating the magic while holding a
2093 * shared spinlock which will cause us to block if the
2094 * callback is currently executing
2095 */
2096 spin_lock(&hdd_context_lock);
2097 context.magic = 0;
2098 spin_unlock(&hdd_context_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302099 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100}
2101
2102/**
2103 * wlan_hdd_get_link_speed() - get link speed
2104 * @pAdapter: pointer to the adapter
2105 * @link_speed: pointer to link speed
2106 *
2107 * This function fetches per bssid link speed.
2108 *
2109 * Return: if associated, link speed shall be returned.
2110 * if not associated, link speed of 0 is returned.
2111 * On error, error number will be returned.
2112 */
2113int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
2114{
2115 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
2116 hdd_station_ctx_t *hdd_stactx =
2117 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
2118 int ret;
2119
2120 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05302121 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05302124 /* Linkspeed is allowed only for P2P mode */
2125 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
2126 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
2127 hdd_device_mode_to_string(sta_adapter->device_mode),
2128 sta_adapter->device_mode);
2129 return -ENOTSUPP;
2130 }
2131
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
2133 /* we are not connected so we don't have a classAstats */
2134 *link_speed = 0;
2135 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302136 QDF_STATUS status;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302137 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138
Anurag Chouhanc5548422016-02-24 18:33:27 +05302139 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140
2141 status = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302142 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002143 hdd_err("Unable to retrieve SME linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 return -EINVAL;
2145 }
2146 *link_speed = sta_adapter->ls_stats.estLinkSpeed;
2147 /* linkspeed in units of 500 kbps */
2148 *link_speed = (*link_speed) / 500;
2149 }
2150 return 0;
2151}
2152
2153/**
2154 * hdd_statistics_cb() - "Get statistics" callback function
2155 * @pStats: statistics payload
2156 * @pContext: opaque context originally passed to SME. HDD always passes
2157 * a pointer to an adapter
2158 *
2159 * Return: None
2160 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07002161static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002162{
2163 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
2164 hdd_stats_t *pStatsCache = NULL;
2165 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05302166 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167
2168 tCsrSummaryStatsInfo *pSummaryStats = NULL;
2169 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
2170 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
2171 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
2172 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
2173 tCsrPerStaStatsInfo *pPerStaStats = NULL;
2174
2175 if (pAdapter != NULL)
2176 pStatsCache = &pAdapter->hdd_stats;
2177
2178 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
2179 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
2180 pClassBStats = (tCsrGlobalClassBStatsInfo *) (pClassAStats + 1);
2181 pClassCStats = (tCsrGlobalClassCStatsInfo *) (pClassBStats + 1);
2182 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassCStats + 1);
2183 pPerStaStats = (tCsrPerStaStatsInfo *) (pClassDStats + 1);
2184
2185 if (pStatsCache != NULL) {
2186 /* copy the stats into the cache we keep in the
2187 * adapter instance structure
2188 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302189 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302191 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302193 qdf_mem_copy(&pStatsCache->ClassB_stat, pClassBStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 sizeof(pStatsCache->ClassB_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302195 qdf_mem_copy(&pStatsCache->ClassC_stat, pClassCStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196 sizeof(pStatsCache->ClassC_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302197 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 sizeof(pStatsCache->ClassD_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302199 qdf_mem_copy(&pStatsCache->perStaStats, pPerStaStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 sizeof(pStatsCache->perStaStats));
2201 }
2202
2203 if (pAdapter) {
2204 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302205 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05302206 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002207 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 return;
2209 }
2210 }
2211}
2212
2213/**
2214 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
2215 * @pAdapter: adapter who's IEs are to be cleared
2216 *
2217 * Return: None
2218 */
2219void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
2220{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07002221 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07002222
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07002223 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002224
2225 /* clear WPA/RSN/WSC IE information in the profile */
2226 pWextState->roamProfile.nWPAReqIELength = 0;
2227 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
2228 pWextState->roamProfile.nRSNReqIELength = 0;
2229 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
2230
2231#ifdef FEATURE_WLAN_WAPI
2232 pWextState->roamProfile.nWAPIReqIELength = 0;
2233 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
2234#endif
2235
2236 pWextState->roamProfile.bWPSAssociation = false;
2237 pWextState->roamProfile.bOSENAssociation = false;
2238 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
2239 pWextState->roamProfile.nAddIEScanLength = 0;
2240 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
2241 pWextState->roamProfile.nAddIEAssocLength = 0;
2242
2243 pWextState->roamProfile.EncryptionType.numEntries = 1;
2244 pWextState->roamProfile.EncryptionType.encryptionType[0]
2245 = eCSR_ENCRYPT_TYPE_NONE;
2246
2247 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
2248 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
2249 = eCSR_ENCRYPT_TYPE_NONE;
2250
2251 pWextState->roamProfile.AuthType.numEntries = 1;
2252 pWextState->roamProfile.AuthType.authType[0] =
2253 eCSR_AUTH_TYPE_OPEN_SYSTEM;
2254
Abhishek Singh3c9910e2017-01-06 17:56:47 +05302255 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
2256 QDF_MAC_ADDR_SIZE);
2257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258#ifdef WLAN_FEATURE_11W
2259 pWextState->roamProfile.MFPEnabled = false;
2260 pWextState->roamProfile.MFPRequired = 0;
2261 pWextState->roamProfile.MFPCapable = 0;
2262#endif
2263
2264 pWextState->authKeyMgmt = 0;
2265
Yingying Tang3cc6b792016-10-20 17:00:37 +08002266 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
2267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002268#ifdef FEATURE_WLAN_WAPI
2269 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
2270 pAdapter->wapi_info.nWapiMode = 0;
2271#endif
2272
Anurag Chouhanc5548422016-02-24 18:33:27 +05302273 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07002274 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275}
2276
2277/**
2278 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
2279 * @oui: The OUI that is being searched for
2280 * @oui_size: The length of @oui
2281 * @ie: The set of IEs within which we're trying to find @oui
2282 * @ie_len: The length of @ie
2283 *
2284 * This function will scan the IEs contained within @ie looking for @oui.
2285 *
2286 * Return: Pointer to @oui embedded within @ie if it is present, NULL
2287 * if @oui is not present within @ie.
2288 */
2289uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
2290 uint8_t *ie, int ie_len)
2291{
2292 int left = ie_len;
2293 uint8_t *ptr = ie;
2294 uint8_t elem_id, elem_len;
2295 uint8_t eid = 0xDD;
2296
2297 if (NULL == ie || 0 == ie_len)
2298 return NULL;
2299
2300 while (left >= 2) {
2301 elem_id = ptr[0];
2302 elem_len = ptr[1];
2303 left -= 2;
2304 if (elem_len > left) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002305 hdd_alert("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 eid, elem_len, left);
2307 return NULL;
2308 }
2309 if (elem_id == eid) {
2310 if (memcmp(&ptr[2], oui, oui_size) == 0)
2311 return ptr;
2312 }
2313
2314 left -= elem_len;
2315 ptr += (elem_len + 2);
2316 }
2317 return NULL;
2318}
2319
2320/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05302321 * hdd_get_ldpc() - Get adapter LDPC
2322 * @adapter: adapter being queried
2323 * @value: where to store the value
2324 *
2325 * Return: 0 on success, negative errno on failure
2326 */
2327int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
2328{
2329 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2330 int ret;
2331
2332 ENTER();
2333 ret = sme_get_ht_config(hal, adapter->sessionId,
2334 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
2335 if (ret < 0) {
2336 hdd_alert("Failed to get LDPC value");
2337 } else {
2338 *value = ret;
2339 ret = 0;
2340 }
2341 return ret;
2342}
2343
2344/**
2345 * hdd_set_ldpc() - Set adapter LDPC
2346 * @adapter: adapter being modified
2347 * @value: new LDPC value
2348 *
2349 * Return: 0 on success, negative errno on failure
2350 */
2351int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
2352{
2353 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2354 int ret;
2355
2356 hdd_alert("%d", value);
2357 if (value) {
2358 /* make sure HT capabilities allow this */
2359 QDF_STATUS status;
2360 uint32_t cfg_value;
2361 union {
2362 uint16_t cfg_value16;
2363 tSirMacHTCapabilityInfo ht_cap_info;
2364 } u;
2365
2366 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
2367 if (QDF_STATUS_SUCCESS != status) {
2368 hdd_alert("Failed to get HT capability info");
2369 return -EIO;
2370 }
2371 u.cfg_value16 = cfg_value & 0xFFFF;
2372 if (!u.ht_cap_info.advCodingCap) {
2373 hdd_alert("LDCP not supported");
2374 return -EINVAL;
2375 }
2376 }
2377
2378 ret = sme_update_ht_config(hal, adapter->sessionId,
2379 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
2380 value);
2381 if (ret)
2382 hdd_alert("Failed to set LDPC value");
2383
2384 return ret;
2385}
2386
2387/**
2388 * hdd_get_tx_stbc() - Get adapter TX STBC
2389 * @adapter: adapter being queried
2390 * @value: where to store the value
2391 *
2392 * Return: 0 on success, negative errno on failure
2393 */
2394int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
2395{
2396 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2397 int ret;
2398
2399 ENTER();
2400 ret = sme_get_ht_config(hal, adapter->sessionId,
2401 WNI_CFG_HT_CAP_INFO_TX_STBC);
2402 if (ret < 0) {
2403 hdd_alert("Failed to get TX STBC value");
2404 } else {
2405 *value = ret;
2406 ret = 0;
2407 }
2408
2409 return ret;
2410}
2411
2412/**
2413 * hdd_set_tx_stbc() - Set adapter TX STBC
2414 * @adapter: adapter being modified
2415 * @value: new TX STBC value
2416 *
2417 * Return: 0 on success, negative errno on failure
2418 */
2419int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
2420{
2421 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2422 int ret;
2423
2424 hdd_alert("%d", value);
2425 if (value) {
2426 /* make sure HT capabilities allow this */
2427 QDF_STATUS status;
2428 uint32_t cfg_value;
2429 union {
2430 uint16_t cfg_value16;
2431 tSirMacHTCapabilityInfo ht_cap_info;
2432 } u;
2433
2434 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
2435 if (QDF_STATUS_SUCCESS != status) {
2436 hdd_alert("Failed to get HT capability info");
2437 return -EIO;
2438 }
2439 u.cfg_value16 = cfg_value & 0xFFFF;
2440 if (!u.ht_cap_info.txSTBC) {
2441 hdd_alert("TX STBC not supported");
2442 return -EINVAL;
2443 }
2444 }
2445 ret = sme_update_ht_config(hal, adapter->sessionId,
2446 WNI_CFG_HT_CAP_INFO_TX_STBC,
2447 value);
2448 if (ret)
2449 hdd_alert("Failed to set TX STBC value");
2450
2451 return ret;
2452}
2453
2454/**
2455 * hdd_get_rx_stbc() - Get adapter RX STBC
2456 * @adapter: adapter being queried
2457 * @value: where to store the value
2458 *
2459 * Return: 0 on success, negative errno on failure
2460 */
2461int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
2462{
2463 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2464 int ret;
2465
2466 ENTER();
2467 ret = sme_get_ht_config(hal, adapter->sessionId,
2468 WNI_CFG_HT_CAP_INFO_RX_STBC);
2469 if (ret < 0) {
2470 hdd_alert("Failed to get RX STBC value");
2471 } else {
2472 *value = ret;
2473 ret = 0;
2474 }
2475
2476 return ret;
2477}
2478
2479/**
2480 * hdd_set_rx_stbc() - Set adapter RX STBC
2481 * @adapter: adapter being modified
2482 * @value: new RX STBC value
2483 *
2484 * Return: 0 on success, negative errno on failure
2485 */
2486int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
2487{
2488 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
2489 int ret;
2490
2491 hdd_alert("%d", value);
2492 if (value) {
2493 /* make sure HT capabilities allow this */
2494 QDF_STATUS status;
2495 uint32_t cfg_value;
2496 union {
2497 uint16_t cfg_value16;
2498 tSirMacHTCapabilityInfo ht_cap_info;
2499 } u;
2500
2501 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
2502 if (QDF_STATUS_SUCCESS != status) {
2503 hdd_alert("Failed to get HT capability info");
2504 return -EIO;
2505 }
2506 u.cfg_value16 = cfg_value & 0xFFFF;
2507 if (!u.ht_cap_info.rxSTBC) {
2508 hdd_alert("RX STBC not supported");
2509 return -EINVAL;
2510 }
2511 }
2512 ret = sme_update_ht_config(hal, adapter->sessionId,
2513 WNI_CFG_HT_CAP_INFO_RX_STBC,
2514 value);
2515 if (ret)
2516 hdd_alert("Failed to set RX STBC value");
2517
2518 return ret;
2519}
2520
2521/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
2523 * @dev: device upon which the ioctl was received
2524 * @info: ioctl request information
2525 * @wrqu: ioctl request data
2526 * @extra: ioctl extra data
2527 *
2528 * Return: 0 on success, non-zero on error
2529 */
2530static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
2531 union iwreq_data *wrqu, char *extra)
2532{
2533 hdd_adapter_t *adapter;
2534 hdd_context_t *hdd_ctx;
2535 int ret;
2536
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002537 ENTER_DEV(dev);
2538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
2540 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
2541 ret = wlan_hdd_validate_context(hdd_ctx);
2542 if (0 != ret)
2543 return ret;
2544
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 /* Do nothing for now */
2546 return 0;
2547}
2548
2549/**
2550 * iw_set_commit() - SSR wrapper function for __iw_set_commit
2551 * @dev: pointer to net_device
2552 * @info: pointer to iw_request_info
2553 * @wrqu: pointer to iwreq_data
2554 * @extra: extra
2555 *
2556 * Return: 0 on success, error number otherwise
2557 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07002558static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559 union iwreq_data *wrqu, char *extra)
2560{
2561 int ret;
2562
2563 cds_ssr_protect(__func__);
2564 ret = __iw_set_commit(dev, info, wrqu, extra);
2565 cds_ssr_unprotect(__func__);
2566
2567 return ret;
2568}
2569
2570/**
2571 * __iw_get_name() - SIOCGIWNAME ioctl handler
2572 * @dev: device upon which the ioctl was received
2573 * @info: ioctl request information
2574 * @wrqu: ioctl request data
2575 * @extra: ioctl extra data
2576 *
2577 * Return: 0 on success, non-zero on error
2578 */
2579static int __iw_get_name(struct net_device *dev,
2580 struct iw_request_info *info, char *wrqu, char *extra)
2581{
2582 hdd_adapter_t *adapter;
2583 hdd_context_t *hdd_ctx;
2584 int ret;
2585
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002586 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587
2588 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
2589 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
2590 ret = wlan_hdd_validate_context(hdd_ctx);
2591 if (0 != ret)
2592 return ret;
2593
2594 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
2595 EXIT();
2596 return 0;
2597}
2598
2599/**
2600 * __iw_get_name() - SSR wrapper for __iw_get_name
2601 * @dev: pointer to net_device
2602 * @info: pointer to iw_request_info
2603 * @wrqu: pointer to iwreq_data
2604 * @extra: extra
2605 *
2606 * Return: 0 on success, error number otherwise
2607 */
2608static int iw_get_name(struct net_device *dev,
2609 struct iw_request_info *info,
2610 char *wrqu, char *extra)
2611{
2612 int ret;
2613
2614 cds_ssr_protect(__func__);
2615 ret = __iw_get_name(dev, info, wrqu, extra);
2616 cds_ssr_unprotect(__func__);
2617
2618 return ret;
2619}
2620
2621/**
2622 * __iw_set_mode() - ioctl handler
2623 * @dev: device upon which the ioctl was received
2624 * @info: ioctl request information
2625 * @wrqu: ioctl request data
2626 * @extra: ioctl extra data
2627 *
2628 * Return: 0 on success, non-zero on error
2629 */
2630static int __iw_set_mode(struct net_device *dev,
2631 struct iw_request_info *info,
2632 union iwreq_data *wrqu, char *extra)
2633{
2634 hdd_wext_state_t *pWextState;
2635 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2636 hdd_context_t *hdd_ctx;
2637 tCsrRoamProfile *pRoamProfile;
2638 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639 struct hdd_config *pConfig;
2640 struct wireless_dev *wdev;
2641 int ret;
2642
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002643 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644
2645 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2646 ret = wlan_hdd_validate_context(hdd_ctx);
2647 if (0 != ret)
2648 return ret;
2649
2650 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2651 wdev = dev->ieee80211_ptr;
2652 pRoamProfile = &pWextState->roamProfile;
2653 LastBSSType = pRoamProfile->BSSType;
2654
Jeff Johnson99bac312016-06-28 10:38:18 -07002655 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656
2657 switch (wrqu->mode) {
2658 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07002659 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2661 /* Set the phymode correctly for IBSS. */
2662 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
2663 pWextState->roamProfile.phyMode =
2664 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08002665 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 wdev->iftype = NL80211_IFTYPE_ADHOC;
2667 break;
2668 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07002669 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2671 wdev->iftype = NL80211_IFTYPE_STATION;
2672 break;
2673 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07002674 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
2676 break;
2677 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002678 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 return -EOPNOTSUPP;
2680 }
2681
2682 if (LastBSSType != pRoamProfile->BSSType) {
2683 /* the BSS mode changed. We need to issue disconnect
2684 * if connected or in IBSS disconnect state
2685 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07002686 if (hdd_conn_is_connected
2687 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302689 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 /* need to issue a disconnect to CSR. */
2691 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302692 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
2694 pAdapter->sessionId,
2695 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302696 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697 unsigned long rc;
2698 rc = wait_for_completion_timeout(&pAdapter->
2699 disconnect_comp_var,
2700 msecs_to_jiffies
2701 (WLAN_WAIT_TIME_DISCONNECT));
2702 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07002703 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 }
2705 }
2706 }
2707
2708 EXIT();
2709 return 0;
2710}
2711
2712/**
2713 * iw_set_mode() - SSR wrapper for __iw_set_mode()
2714 * @dev: pointer to net_device
2715 * @info: pointer to iw_request_info
2716 * @wrqu: pointer to iwreq_data
2717 * @extra: pointer to extra ioctl payload
2718 *
2719 * Return: 0 on success, error number otherwise
2720 */
2721static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
2722 union iwreq_data *wrqu, char *extra)
2723{
2724 int ret;
2725
2726 cds_ssr_protect(__func__);
2727 ret = __iw_set_mode(dev, info, wrqu, extra);
2728 cds_ssr_unprotect(__func__);
2729
2730 return ret;
2731}
2732
2733/**
2734 * __iw_get_mode() - SIOCGIWMODE ioctl handler
2735 * @dev: device upon which the ioctl was received
2736 * @info: ioctl request information
2737 * @wrqu: ioctl request data
2738 * @extra: ioctl extra data
2739 *
2740 * Return: 0 on success, non-zero on error
2741 */
2742static int
2743__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2744 union iwreq_data *wrqu, char *extra)
2745{
2746 hdd_wext_state_t *pWextState;
2747 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2748 hdd_context_t *hdd_ctx;
2749 int ret;
2750
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002751 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002752
2753 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2754 ret = wlan_hdd_validate_context(hdd_ctx);
2755 if (0 != ret)
2756 return ret;
2757
2758 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2759
2760 switch (pWextState->roamProfile.BSSType) {
2761 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07002762 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 wrqu->mode = IW_MODE_INFRA;
2764 break;
2765 case eCSR_BSS_TYPE_IBSS:
2766 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07002767 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 wrqu->mode = IW_MODE_ADHOC;
2769 break;
2770 case eCSR_BSS_TYPE_ANY:
2771 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07002772 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 wrqu->mode = IW_MODE_AUTO;
2774 break;
2775 }
2776
2777 EXIT();
2778 return 0;
2779}
2780
2781/**
2782 * iw_get_mode() - SSR wrapper for __iw_get_mode()
2783 * @dev: pointer to net_device
2784 * @info: pointer to iw_request_info
2785 * @wrqu: pointer to iwreq_data
2786 * @extra: pointer to extra ioctl payload
2787 *
2788 * Return: 0 on success, error number otherwise
2789 */
2790static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
2791 union iwreq_data *wrqu, char *extra)
2792{
2793 int ret;
2794
2795 cds_ssr_protect(__func__);
2796 ret = __iw_get_mode(dev, info, wrqu, extra);
2797 cds_ssr_unprotect(__func__);
2798
2799 return ret;
2800}
2801
2802/**
2803 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
2804 * @dev: device upon which the ioctl was received
2805 * @info: ioctl request information
2806 * @wrqu: ioctl request data
2807 * @extra: ioctl extra data
2808 *
2809 * Return: 0 on success, non-zero on error
2810 */
2811static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2812 union iwreq_data *wrqu, char *extra)
2813{
2814 uint32_t numChans = 0;
2815 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2816 uint32_t indx = 0;
2817 int ret;
2818 hdd_wext_state_t *pWextState;
2819 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2820 hdd_context_t *hdd_ctx;
2821 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2822 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2823 tCsrRoamProfile *pRoamProfile;
2824
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002825 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826
2827 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2828 ret = wlan_hdd_validate_context(hdd_ctx);
2829 if (0 != ret)
2830 return ret;
2831
2832 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2833
2834 pRoamProfile = &pWextState->roamProfile;
2835
Jeff Johnson99bac312016-06-28 10:38:18 -07002836 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837
2838 /* Link is up then return cant set channel */
2839 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
2840 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002841 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 return -EOPNOTSUPP;
2843 }
2844
2845 /* Settings by Frequency as input */
2846 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
2847 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
2848 uint32_t freq = wrqu->freq.m / 100000;
2849
2850 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
2851 && (freq != freq_chan_map[indx].freq))
2852 indx++;
2853 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
2854 return -EINVAL;
2855 }
2856 wrqu->freq.e = 0;
2857 wrqu->freq.m = freq_chan_map[indx].chan;
2858
2859 }
2860
2861 if (wrqu->freq.e == 0) {
2862 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
2863 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002864 hdd_notice("Channel %d is outside valid range from %d to %d",
2865 wrqu->freq.m,
2866 WNI_CFG_CURRENT_CHANNEL_STAMIN,
2867 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868 return -EINVAL;
2869 }
2870
2871 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2872
2873 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2874 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302875 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002876 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 return -EIO;
2878 }
2879
2880 for (indx = 0; indx < numChans; indx++) {
2881 if (wrqu->freq.m == validChan[indx]) {
2882 break;
2883 }
2884 }
2885 } else {
2886
2887 return -EINVAL;
2888 }
2889
2890 if (indx >= numChans) {
2891 return -EINVAL;
2892 }
2893
2894 /* Set the Operational Channel */
2895 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
2896 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
2897 pRoamProfile->ChannelInfo.ChannelList =
2898 &pHddStaCtx->conn_info.operationChannel;
2899
Jeff Johnson99bac312016-06-28 10:38:18 -07002900 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901
2902 EXIT();
2903
2904 return ret;
2905}
2906
2907/**
2908 * iw_set_freq() - SSR wrapper for __iw_set_freq()
2909 * @dev: pointer to net_device
2910 * @info: pointer to iw_request_info
2911 * @wrqu: pointer to iwreq_data
2912 * @extra: pointer to extra ioctl payload
2913 *
2914 * Return: 0 on success, error number otherwise
2915 */
2916static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
2917 union iwreq_data *wrqu, char *extra)
2918{
2919 int ret;
2920
2921 cds_ssr_protect(__func__);
2922 ret = __iw_set_freq(dev, info, wrqu, extra);
2923 cds_ssr_unprotect(__func__);
2924
2925 return ret;
2926}
2927
2928/**
2929 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
2930 * @dev: device upon which the ioctl was received
2931 * @info: ioctl request information
2932 * @wrqu: ioctl request data
2933 * @extra: ioctl extra data
2934 *
2935 * Return: 0 on success, non-zero on error
2936 */
2937static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
2938 struct iw_freq *fwrq, char *extra)
2939{
2940 uint32_t status = false, channel = 0, freq = 0;
2941 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2942 tHalHandle hHal;
2943 hdd_wext_state_t *pWextState;
2944 tCsrRoamProfile *pRoamProfile;
2945 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2946 hdd_context_t *hdd_ctx;
2947 int ret;
2948
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08002949 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950
2951 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
2952 ret = wlan_hdd_validate_context(hdd_ctx);
2953 if (0 != ret)
2954 return ret;
2955
2956 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2957 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2958
2959 pRoamProfile = &pWextState->roamProfile;
2960
2961 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
2962 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302963 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002964 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 pAdapter->sessionId);
2966 return -EIO;
2967 } else {
2968 status = hdd_wlan_get_freq(channel, &freq);
2969 if (true == status) {
2970 /* Set Exponent parameter as 6 (MHZ)
2971 * in struct iw_freq iwlist & iwconfig
2972 * command shows frequency into proper
2973 * format (2.412 GHz instead of 246.2
2974 * MHz)
2975 */
2976 fwrq->m = freq;
2977 fwrq->e = MHZ;
2978 }
2979 }
2980 } else {
2981 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
2982 * iwlist & iwconfig command shows frequency into proper
2983 * format (2.412 GHz instead of 246.2 MHz)
2984 */
2985 fwrq->m = 0;
2986 fwrq->e = MHZ;
2987 }
2988 return 0;
2989}
2990
2991/**
2992 * iw_get_freq() - SSR wrapper for __iw_get_freq()
2993 * @dev: pointer to net_device
2994 * @info: pointer to iw_request_info
2995 * @fwrq: pointer to frequency data
2996 * @extra: pointer to extra ioctl payload
2997 *
2998 * Return: 0 on success, error number otherwise
2999 */
3000static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
3001 struct iw_freq *fwrq, char *extra)
3002{
3003 int ret;
3004
3005 cds_ssr_protect(__func__);
3006 ret = __iw_get_freq(dev, info, fwrq, extra);
3007 cds_ssr_unprotect(__func__);
3008
3009 return ret;
3010}
3011
3012/**
3013 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
3014 * @dev: device upon which the ioctl was received
3015 * @info: ioctl request information
3016 * @wrqu: ioctl request data
3017 * @extra: ioctl extra data
3018 *
3019 * Return: 0 on success, non-zero on error
3020 */
3021static int __iw_get_tx_power(struct net_device *dev,
3022 struct iw_request_info *info,
3023 union iwreq_data *wrqu, char *extra)
3024{
3025
3026 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3027 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3028 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3029 int ret;
3030
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003031 ENTER_DEV(dev);
3032
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 ret = wlan_hdd_validate_context(hdd_ctx);
3034 if (0 != ret)
3035 return ret;
3036
3037 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
3038 wrqu->txpower.value = 0;
3039 return 0;
3040 }
3041 wlan_hdd_get_class_astats(pAdapter);
3042 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
3043
3044 return 0;
3045}
3046
3047/**
3048 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
3049 * @dev: pointer to net_device
3050 * @info: pointer to iw_request_info
3051 * @wrqu: pointer to iwreq_data
3052 * @extra: pointer to extra ioctl payload
3053 *
3054 * Return: 0 on success, error number otherwise
3055 */
3056static int iw_get_tx_power(struct net_device *dev,
3057 struct iw_request_info *info,
3058 union iwreq_data *wrqu, char *extra)
3059{
3060 int ret;
3061
3062 cds_ssr_protect(__func__);
3063 ret = __iw_get_tx_power(dev, info, wrqu, extra);
3064 cds_ssr_unprotect(__func__);
3065
3066 return ret;
3067}
3068
3069/**
3070 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
3071 * @dev: device upon which the ioctl was received
3072 * @info: ioctl request information
3073 * @wrqu: ioctl request data
3074 * @extra: ioctl extra data
3075 *
3076 * Return: 0 on success, non-zero on error
3077 */
3078static int __iw_set_tx_power(struct net_device *dev,
3079 struct iw_request_info *info,
3080 union iwreq_data *wrqu, char *extra)
3081{
3082 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3083 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3084 hdd_context_t *hdd_ctx;
3085 int ret;
3086
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003087 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088
3089 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3090 ret = wlan_hdd_validate_context(hdd_ctx);
3091 if (0 != ret)
3092 return ret;
3093
3094 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303095 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003096 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 return -EIO;
3098 }
3099
3100 EXIT();
3101
3102 return 0;
3103}
3104
3105/**
3106 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
3107 * @dev: pointer to net_device
3108 * @info: pointer to iw_request_info
3109 * @wrqu: pointer to iwreq_data
3110 * @extra: pointer to extra ioctl payload
3111 *
3112 * Return: 0 on success, error number otherwise
3113 */
3114static int iw_set_tx_power(struct net_device *dev,
3115 struct iw_request_info *info,
3116 union iwreq_data *wrqu, char *extra)
3117{
3118 int ret;
3119
3120 cds_ssr_protect(__func__);
3121 ret = __iw_set_tx_power(dev, info, wrqu, extra);
3122 cds_ssr_unprotect(__func__);
3123
3124 return ret;
3125}
3126
3127/**
3128 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
3129 * @dev: device upon which the ioctl was received
3130 * @info: ioctl request information
3131 * @wrqu: ioctl request data
3132 * @extra: ioctl extra data
3133 *
3134 * Return: 0 on success, non-zero on error
3135 */
3136static int __iw_get_bitrate(struct net_device *dev,
3137 struct iw_request_info *info,
3138 union iwreq_data *wrqu, char *extra)
3139{
Anurag Chouhance0dc992016-02-16 18:18:03 +05303140 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303141 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142 hdd_wext_state_t *pWextState;
3143 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3144 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3145 hdd_context_t *hdd_ctx;
3146 int ret;
3147
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003148 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149
3150 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3151 ret = wlan_hdd_validate_context(hdd_ctx);
3152 if (0 != ret)
3153 return ret;
3154
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003155 if (cds_is_driver_recovering()) {
3156 hdd_alert("Recovery in Progress. State: 0x%x Ignore!!!",
3157 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 return status;
3159 }
3160
3161 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
3162 wrqu->bitrate.value = 0;
3163 } else {
3164 status =
3165 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3166 eCSR_HDD,
3167 SME_SUMMARY_STATS |
3168 SME_GLOBAL_CLASSA_STATS |
3169 SME_GLOBAL_CLASSB_STATS |
3170 SME_GLOBAL_CLASSC_STATS |
3171 SME_GLOBAL_CLASSD_STATS |
3172 SME_PER_STA_STATS,
3173 hdd_statistics_cb, 0,
3174 false,
3175 pHddStaCtx->conn_info.staId[0],
3176 pAdapter, pAdapter->sessionId);
3177
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303178 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003179 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 return status;
3181 }
3182
3183 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3184
Anurag Chouhance0dc992016-02-16 18:18:03 +05303185 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303186 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 WLAN_WAIT_TIME_STATS);
3188
Anurag Chouhance0dc992016-02-16 18:18:03 +05303189 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003190 hdd_err("SME timeout while retrieving statistics");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303191 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 }
3193
3194 wrqu->bitrate.value =
3195 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
3196 }
3197
3198 EXIT();
3199
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303200 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201}
3202
3203/**
3204 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
3205 * @dev: pointer to net_device
3206 * @info: pointer to iw_request_info
3207 * @wrqu: pointer to iwreq_data
3208 * @extra: pointer to extra ioctl payload
3209 *
3210 * Return: 0 on success, error number otherwise
3211 */
3212static int iw_get_bitrate(struct net_device *dev,
3213 struct iw_request_info *info,
3214 union iwreq_data *wrqu, char *extra)
3215{
3216 int ret;
3217
3218 cds_ssr_protect(__func__);
3219 ret = __iw_get_bitrate(dev, info, wrqu, extra);
3220 cds_ssr_unprotect(__func__);
3221
3222 return ret;
3223}
3224
3225/**
3226 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
3227 * @dev: device upon which the ioctl was received
3228 * @info: ioctl request information
3229 * @wrqu: ioctl request data
3230 * @extra: ioctl extra data
3231 *
3232 * Return: 0 on success, non-zero on error
3233 */
3234static int __iw_set_bitrate(struct net_device *dev,
3235 struct iw_request_info *info,
3236 union iwreq_data *wrqu, char *extra)
3237{
3238 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3239 hdd_wext_state_t *pWextState;
3240 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3241 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3242 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3243 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3244 uint32_t i, rate;
3245 uint32_t valid_rate = false, active_phy_mode = 0;
3246 hdd_context_t *hdd_ctx;
3247 int ret;
3248
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003249 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250
3251 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3252 ret = wlan_hdd_validate_context(hdd_ctx);
3253 if (0 != ret)
3254 return ret;
3255
3256 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3257
3258 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
3259 return -ENXIO;
3260 }
3261
3262 rate = wrqu->bitrate.value;
3263
3264 if (rate == -1) {
3265 rate = WNI_CFG_FIXED_RATE_AUTO;
3266 valid_rate = true;
3267 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
3268 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303269 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
3271 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
3272 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
3273 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
3274 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303275 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276 &&
3277 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
3278 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303279 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 for (i = 0; i < (b_len + a_len); ++i) {
3281 /* supported rates returned is double
3282 * the actual rate so we divide it by 2
3283 */
3284 if ((supp_rates[i] & 0x7F) / 2 ==
3285 rate) {
3286 valid_rate = true;
3287 rate = i +
3288 WNI_CFG_FIXED_RATE_1MBPS;
3289 break;
3290 }
3291 }
3292 }
3293 }
3294 }
3295 if (valid_rate != true) {
3296 return -EINVAL;
3297 }
3298 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303299 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003300 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301 return -EIO;
3302 }
3303 return 0;
3304}
3305
3306/**
3307 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
3308 * @dev: pointer to net_device
3309 * @info: pointer to iw_request_info
3310 * @wrqu: pointer to iwreq_data
3311 * @extra: pointer to extra ioctl payload
3312 *
3313 * Return: 0 on success, error number otherwise
3314 */
3315static int iw_set_bitrate(struct net_device *dev,
3316 struct iw_request_info *info,
3317 union iwreq_data *wrqu, char *extra)
3318{
3319 int ret;
3320
3321 cds_ssr_protect(__func__);
3322 ret = __iw_set_bitrate(dev, info, wrqu, extra);
3323 cds_ssr_unprotect(__func__);
3324
3325 return ret;
3326}
3327
3328/**
3329 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
3330 * @dev: device upon which the ioctl was received
3331 * @info: ioctl request information
3332 * @wrqu: ioctl request data
3333 * @extra: ioctl extra data
3334 *
3335 * Return: 0 on success, non-zero on error
3336 */
3337static int __iw_set_genie(struct net_device *dev,
3338 struct iw_request_info *info,
3339 union iwreq_data *wrqu, char *extra)
3340{
3341 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3342 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3343 uint8_t *genie = NULL;
3344 uint8_t *base_genie = NULL;
3345 uint16_t remLen;
3346 hdd_context_t *hdd_ctx;
3347 int ret;
3348
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003349 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350
3351 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3352 ret = wlan_hdd_validate_context(hdd_ctx);
3353 if (0 != ret)
3354 return ret;
3355
3356 if (!wrqu->data.length) {
3357 hdd_clear_roam_profile_ie(pAdapter);
3358 EXIT();
3359 return 0;
3360 }
3361
3362 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3363 wrqu->data.length);
3364 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003365 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 return -ENOMEM;
3367 }
3368
3369 genie = base_genie;
3370
3371 remLen = wrqu->data.length;
3372
Jeff Johnson99bac312016-06-28 10:38:18 -07003373 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 genie[1]);
3375
3376 /* clear any previous genIE before this call */
3377 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
3378
3379 while (remLen >= 2) {
3380 uint16_t eLen = 0;
3381 uint8_t elementId;
3382 elementId = *genie++;
3383 eLen = *genie++;
3384 remLen -= 2;
3385
Jeff Johnson99bac312016-06-28 10:38:18 -07003386 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387
3388 switch (elementId) {
3389 case IE_EID_VENDOR:
3390 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 +05303391 ret = -EINVAL;
3392 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393 }
3394
3395 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
3396 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07003397 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
3398 genie[0], genie[1], genie[2],
3399 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400
3401 if (SIR_MAC_MAX_IE_LENGTH <
3402 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003403 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303404 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303405 ret = -ENOMEM;
3406 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 }
3408 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
3409 memcpy(pWextState->genIE.addIEdata +
3410 curGenIELen, genie - 2, eLen + 2);
3411 pWextState->genIE.length += eLen + 2;
3412 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003413 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303414 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
3415 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
3416 ret = -EINVAL;
3417 QDF_ASSERT(0);
3418 goto exit;
3419 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 memset(pWextState->WPARSNIE, 0,
3421 MAX_WPA_RSN_IE_LEN);
3422 memcpy(pWextState->WPARSNIE, genie - 2,
3423 (eLen + 2));
3424 pWextState->roamProfile.pWPAReqIE =
3425 pWextState->WPARSNIE;
3426 pWextState->roamProfile.nWPAReqIELength =
3427 eLen + 2;
3428 } else { /* any vendorId except WPA IE should be accumulated to genIE */
3429
3430 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07003431 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
3432 genie[0], genie[1], genie[2],
3433 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434
3435 if (SIR_MAC_MAX_IE_LENGTH <
3436 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003437 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303438 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303439 ret = -ENOMEM;
3440 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441 }
3442 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
3443 memcpy(pWextState->genIE.addIEdata +
3444 curGenIELen, genie - 2, eLen + 2);
3445 pWextState->genIE.length += eLen + 2;
3446 }
3447 break;
3448 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07003449 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303450 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
3451 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
3452 ret = -EINVAL;
3453 QDF_ASSERT(0);
3454 goto exit;
3455 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
3457 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
3458 pWextState->roamProfile.pRSNReqIE =
3459 pWextState->WPARSNIE;
3460 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
3461 break;
3462
3463 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003464 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303465 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 }
3467 genie += eLen;
3468 remLen -= eLen;
3469 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303470exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07003472 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303473 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474}
3475
3476/**
3477 * iw_set_genie() - SSR wrapper for __iw_set_genie()
3478 * @dev: pointer to net_device
3479 * @info: pointer to iw_request_info
3480 * @wrqu: pointer to iwreq_data
3481 * @extra: pointer to extra ioctl payload
3482 *
3483 * Return: 0 on success, error number otherwise
3484 */
3485static int iw_set_genie(struct net_device *dev,
3486 struct iw_request_info *info,
3487 union iwreq_data *wrqu, char *extra)
3488{
3489 int ret;
3490
3491 cds_ssr_protect(__func__);
3492 ret = __iw_set_genie(dev, info, wrqu, extra);
3493 cds_ssr_unprotect(__func__);
3494
3495 return ret;
3496}
3497
3498/**
3499 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
3500 * @dev: device upon which the ioctl was received
3501 * @info: ioctl request information
3502 * @wrqu: ioctl request data
3503 * @extra: ioctl extra data
3504 *
3505 * Return: 0 on success, non-zero on error
3506 */
3507static int __iw_get_genie(struct net_device *dev,
3508 struct iw_request_info *info,
3509 union iwreq_data *wrqu, char *extra)
3510{
3511 hdd_wext_state_t *pWextState;
3512 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3513 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303514 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
3516 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
3517 hdd_context_t *hdd_ctx;
3518 int ret;
3519
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003520 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521
3522 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3523 ret = wlan_hdd_validate_context(hdd_ctx);
3524 if (0 != ret)
3525 return ret;
3526
Jeff Johnson99bac312016-06-28 10:38:18 -07003527 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528
3529 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3530
3531 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
3532 return -ENXIO;
3533 }
3534
3535 /* Return something ONLY if we are associated with an RSN or
3536 * WPA network
3537 */
3538 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
3539 return -ENXIO;
3540 }
3541
3542 /* Actually retrieve the RSN IE from CSR. (We previously sent
3543 * it down in the CSR Roam Profile.)
3544 */
3545 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
3546 pAdapter->sessionId,
3547 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05303548 if (QDF_STATUS_SUCCESS != status) {
3549 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 return -EFAULT;
3551 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05303553 if (length > DOT11F_IE_RSN_MAX_LEN) {
3554 hdd_notice("invalid buffer length length:%d", length);
3555 return -E2BIG;
3556 }
3557 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558
Jeff Johnson99bac312016-06-28 10:38:18 -07003559 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 wrqu->data.length);
3561
3562 EXIT();
3563
3564 return 0;
3565}
3566
3567/**
3568 * iw_get_genie() - SSR wrapper for __iw_get_genie()
3569 * @dev: pointer to net_device
3570 * @info: pointer to iw_request_info
3571 * @wrqu: pointer to iwreq_data
3572 * @extra: pointer to extra ioctl payload
3573 *
3574 * Return: 0 on success, error number otherwise
3575 */
3576static int iw_get_genie(struct net_device *dev,
3577 struct iw_request_info *info,
3578 union iwreq_data *wrqu, char *extra)
3579{
3580 int ret;
3581
3582 cds_ssr_protect(__func__);
3583 ret = __iw_get_genie(dev, info, wrqu, extra);
3584 cds_ssr_unprotect(__func__);
3585
3586 return ret;
3587}
3588
3589/**
3590 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
3591 * @dev: device upon which the ioctl was received
3592 * @info: ioctl request information
3593 * @wrqu: ioctl request data
3594 * @extra: ioctl extra data
3595 *
3596 * Return: 0 on success, non-zero on error
3597 */
3598static int __iw_get_encode(struct net_device *dev,
3599 struct iw_request_info *info,
3600 struct iw_point *dwrq, char *extra)
3601{
3602 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3603 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3604 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3605 int keyId;
3606 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3607 int i;
3608 hdd_context_t *hdd_ctx;
3609 int ret;
3610
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003611 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612
3613 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3614 ret = wlan_hdd_validate_context(hdd_ctx);
3615 if (0 != ret)
3616 return ret;
3617
3618 keyId = pRoamProfile->Keys.defaultIndex;
3619
3620 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003621 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 return -EINVAL;
3623 }
3624
3625 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
3626 dwrq->flags |= IW_ENCODE_ENABLED;
3627 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303628 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 pRoamProfile->Keys.KeyLength[keyId]);
3630
3631 dwrq->flags |= (keyId + 1);
3632
3633 } else {
3634 dwrq->flags |= IW_ENCODE_DISABLED;
3635 }
3636
3637 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08003638 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 continue;
3640 } else {
3641 break;
3642 }
3643 }
3644
3645 if (MAX_WEP_KEYS == i) {
3646 dwrq->flags |= IW_ENCODE_NOKEY;
3647 }
3648
3649 authType =
3650 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
3651 conn_info.authType;
3652
3653 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
3654 dwrq->flags |= IW_ENCODE_OPEN;
3655 } else {
3656 dwrq->flags |= IW_ENCODE_RESTRICTED;
3657 }
3658 EXIT();
3659 return 0;
3660}
3661
3662/**
3663 * iw_get_encode() - SSR wrapper for __iw_get_encode()
3664 * @dev: pointer to net_device
3665 * @info: pointer to iw_request_info
3666 * @dwrq: pointer to encoding information
3667 * @extra: pointer to extra ioctl payload
3668 *
3669 * Return: 0 on success, error number otherwise
3670 */
3671static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
3672 struct iw_point *dwrq, char *extra)
3673{
3674 int ret;
3675
3676 cds_ssr_protect(__func__);
3677 ret = __iw_get_encode(dev, info, dwrq, extra);
3678 cds_ssr_unprotect(__func__);
3679
3680 return ret;
3681}
3682
3683/**
3684 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
3685 * @dev: device upon which the ioctl was received
3686 * @info: ioctl request information
3687 * @wrqu: ioctl request data
3688 * @extra: ioctl extra data
3689 *
3690 * Return: 0 on success, non-zero on error
3691 */
3692static int __iw_get_rts_threshold(struct net_device *dev,
3693 struct iw_request_info *info,
3694 union iwreq_data *wrqu, char *extra)
3695{
3696 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3697 uint32_t status = 0;
3698
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003699 ENTER_DEV(dev);
3700
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 status = hdd_wlan_get_rts_threshold(pAdapter, wrqu);
3702
3703 return status;
3704}
3705
3706/**
3707 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
3708 * @dev: device upon which the ioctl was received
3709 * @info: ioctl request information
3710 * @wrqu: ioctl request data
3711 * @extra: ioctl extra data
3712 *
3713 * Return: 0 on success, non-zero on error
3714 */
3715static int __iw_set_rts_threshold(struct net_device *dev,
3716 struct iw_request_info *info,
3717 union iwreq_data *wrqu, char *extra)
3718{
3719 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3720 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3721 hdd_context_t *hdd_ctx;
3722 int ret;
3723
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003724 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725
3726 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3727 ret = wlan_hdd_validate_context(hdd_ctx);
3728 if (0 != ret)
3729 return ret;
3730
3731 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
3732 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
3733 return -EINVAL;
3734 }
3735
3736 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303737 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003738 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 return -EIO;
3740 }
3741
3742 EXIT();
3743
3744 return 0;
3745}
3746
3747/**
3748 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
3749 * @dev: pointer to net_device
3750 * @info: pointer to iw_request_info
3751 * @wrqu: pointer to iwreq_data
3752 * @extra: pointer to extra ioctl payload
3753 *
3754 * Return: 0 on success, error number otherwise
3755 */
3756static int iw_get_rts_threshold(struct net_device *dev,
3757 struct iw_request_info *info,
3758 union iwreq_data *wrqu, char *extra)
3759{
3760 int ret;
3761
3762 cds_ssr_protect(__func__);
3763 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
3764 cds_ssr_unprotect(__func__);
3765
3766 return ret;
3767}
3768
3769/**
3770 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
3771 * @dev: pointer to net_device
3772 * @info: pointer to iw_request_info
3773 * @wrqu: pointer to iwreq_data
3774 * @extra: pointer to extra ioctl payload
3775 *
3776 * Return: 0 on success, error number otherwise
3777 */
3778static int iw_set_rts_threshold(struct net_device *dev,
3779 struct iw_request_info *info,
3780 union iwreq_data *wrqu, char *extra)
3781{
3782 int ret;
3783
3784 cds_ssr_protect(__func__);
3785 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
3786 cds_ssr_unprotect(__func__);
3787
3788 return ret;
3789}
3790
3791/**
3792 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
3793 * @dev: device upon which the ioctl was received
3794 * @info: ioctl request information
3795 * @wrqu: ioctl request data
3796 * @extra: ioctl extra data
3797 *
3798 * Return: 0 on success, non-zero on error
3799 */
3800static int __iw_get_frag_threshold(struct net_device *dev,
3801 struct iw_request_info *info,
3802 union iwreq_data *wrqu, char *extra)
3803{
3804 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3805 uint32_t status = 0;
3806
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003807 ENTER_DEV(dev);
3808
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 status = hdd_wlan_get_frag_threshold(pAdapter, wrqu);
3810
3811 return status;
3812}
3813
3814/**
3815 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
3816 * @dev: pointer to net_device
3817 * @info: pointer to iw_request_info
3818 * @wrqu: pointer to iwreq_data
3819 * @extra: pointer to extra ioctl payload
3820 *
3821 * Return: 0 on success, error number otherwise
3822 */
3823static int iw_get_frag_threshold(struct net_device *dev,
3824 struct iw_request_info *info,
3825 union iwreq_data *wrqu, char *extra)
3826{
3827 int ret;
3828
3829 cds_ssr_protect(__func__);
3830 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3831 cds_ssr_unprotect(__func__);
3832
3833 return ret;
3834}
3835
3836/**
3837 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
3838 * @dev: device upon which the ioctl was received
3839 * @info: ioctl request information
3840 * @wrqu: ioctl request data
3841 * @extra: ioctl extra data
3842 *
3843 * Return: 0 on success, non-zero on error
3844 */
3845static int __iw_set_frag_threshold(struct net_device *dev,
3846 struct iw_request_info *info,
3847 union iwreq_data *wrqu, char *extra)
3848{
3849 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3850 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3851 hdd_context_t *hdd_ctx;
3852 int ret;
3853
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003854 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855
3856 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3857 ret = wlan_hdd_validate_context(hdd_ctx);
3858 if (0 != ret)
3859 return ret;
3860
3861 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
3862 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
3863 return -EINVAL;
3864 }
3865
3866 if (sme_cfg_set_int
3867 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303868 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003869 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870 return -EIO;
3871 }
3872
3873 EXIT();
3874
3875 return 0;
3876}
3877
3878/**
3879 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
3880 * @dev: pointer to net_device
3881 * @info: pointer to iw_request_info
3882 * @wrqu: pointer to iwreq_data
3883 * @extra: pointer to extra ioctl payload
3884 *
3885 * Return: 0 on success, error number otherwise
3886 */
3887static int iw_set_frag_threshold(struct net_device *dev,
3888 struct iw_request_info *info,
3889 union iwreq_data *wrqu, char *extra)
3890{
3891 int ret;
3892
3893 cds_ssr_protect(__func__);
3894 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3895 cds_ssr_unprotect(__func__);
3896
3897 return ret;
3898}
3899
3900/**
3901 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
3902 * @dev: device upon which the ioctl was received
3903 * @info: ioctl request information
3904 * @wrqu: ioctl request data
3905 * @extra: ioctl extra data
3906 *
3907 * Return: 0 on success, non-zero on error
3908 */
3909static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003910 struct iw_request_info *info,
3911 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912{
3913 hdd_adapter_t *adapter;
3914 hdd_context_t *hdd_ctx;
3915 int ret;
3916
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003917 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918
3919 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3920 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3921 ret = wlan_hdd_validate_context(hdd_ctx);
3922 if (0 != ret)
3923 return ret;
3924
3925 return -EOPNOTSUPP;
3926}
3927
3928/**
3929 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
3930 * @dev: pointer to net_device
3931 * @info: pointer to iw_request_info
3932 * @wrqu: pointer to iwreq_data
3933 * @extra: extra
3934 *
3935 * Return: 0 on success, error number otherwise
3936 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003937static int iw_get_power_mode(struct net_device *dev,
3938 struct iw_request_info *info,
3939 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940{
3941 int ret;
3942
3943 cds_ssr_protect(__func__);
3944 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3945 cds_ssr_unprotect(__func__);
3946
3947 return ret;
3948}
3949
3950/**
3951 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
3952 * @dev: device upon which the ioctl was received
3953 * @info: ioctl request information
3954 * @wrqu: ioctl request data
3955 * @extra: ioctl extra data
3956 *
3957 * Return: 0 on success, non-zero on error
3958 */
3959static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003960 struct iw_request_info *info,
3961 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003962{
3963 hdd_adapter_t *adapter;
3964 hdd_context_t *hdd_ctx;
3965 int ret;
3966
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003967 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968
3969 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3970 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3971 ret = wlan_hdd_validate_context(hdd_ctx);
3972 if (0 != ret)
3973 return ret;
3974
3975 return -EOPNOTSUPP;
3976}
3977
3978/**
3979 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
3980 * @dev: pointer to net_device
3981 * @info: pointer to iw_request_info
3982 * @wrqu: pointer to iwreq_data
3983 * @extra: extra
3984 *
3985 * Return: 0 on success, error number otherwise
3986 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003987static int iw_set_power_mode(struct net_device *dev,
3988 struct iw_request_info *info,
3989 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990{
3991 int ret;
3992
3993 cds_ssr_protect(__func__);
3994 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3995 cds_ssr_unprotect(__func__);
3996
3997 return ret;
3998}
3999
4000/**
4001 * __iw_get_range() - SIOCGIWRANGE ioctl handler
4002 * @dev: device upon which the ioctl was received
4003 * @info: ioctl request information
4004 * @wrqu: ioctl request data
4005 * @extra: ioctl extra data
4006 *
4007 * Return: 0 on success, non-zero on error
4008 */
4009static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
4010 union iwreq_data *wrqu, char *extra)
4011{
4012 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4013 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4014 struct iw_range *range = (struct iw_range *)extra;
4015
4016 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4017
4018 uint32_t num_channels = sizeof(channels);
4019 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4020 uint32_t a_len;
4021 uint32_t b_len;
4022 uint32_t active_phy_mode = 0;
4023 uint8_t index = 0, i;
4024 hdd_context_t *hdd_ctx;
4025 int ret;
4026
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004027 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028
4029 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4030 ret = wlan_hdd_validate_context(hdd_ctx);
4031 if (0 != ret)
4032 return ret;
4033
4034 wrqu->data.length = sizeof(struct iw_range);
4035 memset(range, 0, sizeof(struct iw_range));
4036
4037
4038 /*Get the phy mode */
4039 if (sme_cfg_get_int(hHal,
4040 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304041 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004042 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043
4044 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
4045 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
4046 /*Get the supported rates for 11G band */
4047 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4048 if (sme_cfg_get_str(hHal,
4049 WNI_CFG_SUPPORTED_RATES_11A,
4050 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304051 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
4053 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4054 }
4055 for (i = 0; i < a_len; i++) {
4056 range->bitrate[i] =
4057 ((supp_rates[i] & 0x7F) / 2) *
4058 1000000;
4059 }
4060 range->num_bitrates = a_len;
4061 } else {
4062 return -EIO;
4063 }
4064 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
4065 /*Get the supported rates for 11B band */
4066 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4067 if (sme_cfg_get_str(hHal,
4068 WNI_CFG_SUPPORTED_RATES_11B,
4069 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304070 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
4072 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4073 }
4074 for (i = 0; i < b_len; i++) {
4075 range->bitrate[i] =
4076 ((supp_rates[i] & 0x7F) / 2) *
4077 1000000;
4078 }
4079 range->num_bitrates = b_len;
4080 } else {
4081 return -EIO;
4082 }
4083 }
4084 }
4085
4086 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
4087 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
4088 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
4089
4090 range->encoding_size[0] = 5;
4091 range->encoding_size[1] = 13;
4092 range->num_encoding_sizes = 2;
4093 range->max_encoding_tokens = MAX_WEP_KEYS;
4094
4095 /* we support through Wireless Extensions 22 */
4096 range->we_version_compiled = WIRELESS_EXT;
4097 range->we_version_source = 22;
4098
4099 /*Supported Channels and Frequencies */
4100 if (sme_cfg_get_str
4101 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304102 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004103 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 return -EIO;
4105 }
4106 if (num_channels > IW_MAX_FREQUENCIES) {
4107 num_channels = IW_MAX_FREQUENCIES;
4108 }
4109
4110 range->num_channels = num_channels;
4111 range->num_frequency = num_channels;
4112
4113 for (index = 0; index < num_channels; index++) {
4114 uint32_t frq_indx = 0;
4115
4116 range->freq[index].i = channels[index];
4117 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
4118 if (channels[index] == freq_chan_map[frq_indx].chan) {
4119 range->freq[index].m =
4120 freq_chan_map[frq_indx].freq * 100000;
4121 range->freq[index].e = 1;
4122 break;
4123 }
4124 frq_indx++;
4125 }
4126 }
4127
4128 /* Event capability (kernel + driver) */
4129 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
4130 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
4131 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
4132 range->event_capa[1] = IW_EVENT_CAPA_K_1;
4133
4134 /*Encryption capability */
4135 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
4136 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
4137
4138 /* Txpower capability */
4139 range->txpower_capa = IW_TXPOW_MWATT;
4140
4141 /*Scanning capability */
4142#if WIRELESS_EXT >= 22
4143 range->scan_capa =
4144 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
4145#endif
4146
4147 EXIT();
4148 return 0;
4149}
4150
4151/**
4152 * iw_get_range() - SSR wrapper for __iw_get_range()
4153 * @dev: pointer to net_device
4154 * @info: pointer to iw_request_info
4155 * @wrqu: pointer to iwreq_data
4156 * @extra: pointer to extra ioctl payload
4157 *
4158 * Return: 0 on success, error number otherwise
4159 */
4160static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
4161 union iwreq_data *wrqu, char *extra)
4162{
4163 int ret;
4164
4165 cds_ssr_protect(__func__);
4166 ret = __iw_get_range(dev, info, wrqu, extra);
4167 cds_ssr_unprotect(__func__);
4168
4169 return ret;
4170}
4171
4172/**
4173 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
4174 * @pStats: pointer to Class A stats
4175 * @pContext: user context originally registered with SME
4176 *
4177 * Return: None
4178 */
4179static void hdd_get_class_a_statistics_cb(void *pStats, void *pContext)
4180{
4181 struct statsContext *pStatsContext;
4182 tCsrGlobalClassAStatsInfo *pClassAStats;
4183 hdd_adapter_t *pAdapter;
4184
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004186 hdd_err("Bad param, pStats [%p] pContext [%p]",
4187 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004188 return;
4189 }
4190
4191 pClassAStats = pStats;
4192 pStatsContext = pContext;
4193 pAdapter = pStatsContext->pAdapter;
4194
4195 /* there is a race condition that exists between this callback
4196 * function and the caller since the caller could time out
4197 * either before or while this code is executing. we use a
4198 * spinlock to serialize these actions
4199 */
4200 spin_lock(&hdd_context_lock);
4201
4202 if ((NULL == pAdapter) ||
4203 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
4204 /* the caller presumably timed out so there is nothing
4205 * we can do
4206 */
4207 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07004208 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
4209 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210 return;
4211 }
4212
4213 /* context is valid so caller is still waiting */
4214
4215 /* paranoia: invalidate the magic */
4216 pStatsContext->magic = 0;
4217
4218 /* copy over the stats. do so as a struct copy */
4219 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
4220
4221 /* notify the caller */
4222 complete(&pStatsContext->completion);
4223
4224 /* serialization is complete */
4225 spin_unlock(&hdd_context_lock);
4226}
4227
4228/**
4229 * wlan_hdd_get_class_astats() - Get Class A statistics
4230 * @pAdapter: adapter for which statistics are desired
4231 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304232 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304234QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235{
4236 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304237 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238 unsigned long rc;
Houston Hoffman59c097f2016-11-09 15:50:25 -08004239 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240
4241 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004242 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304243 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08004245 if (cds_is_driver_recovering()) {
4246 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
4247 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304248 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 }
4250
4251 /* we are connected so prepare our callback context */
4252 init_completion(&context.completion);
4253 context.pAdapter = pAdapter;
4254 context.magic = STATS_CONTEXT_MAGIC;
4255 /* query only for Class A statistics (which include link speed) */
4256 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4257 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
4258 hdd_get_class_a_statistics_cb,
4259 0, /* not periodic */
4260 false, /* non-cached results */
4261 pHddStaCtx->conn_info.staId[0],
4262 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304263 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07004264 hdd_warn("Unable to retrieve Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 /* we'll returned a cached value below */
4266 } else {
4267 /* request was sent -- wait for the response */
4268 rc = wait_for_completion_timeout
4269 (&context.completion,
4270 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4271 if (!rc) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07004272 hdd_warn("SME timed out while retrieving Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 }
4274 }
4275
4276 /* either we never sent a request, we sent a request and
4277 * received a response or we sent a request and timed out. if
4278 * we never sent a request or if we sent a request and got a
4279 * response, we want to clear the magic out of paranoia. if
4280 * we timed out there is a race condition such that the
4281 * callback function could be executing at the same time we
4282 * are. of primary concern is if the callback function had
4283 * already verified the "magic" but had not yet set the
4284 * completion variable when a timeout occurred. we serialize
4285 * these activities by invalidating the magic while holding a
4286 * shared spinlock which will cause us to block if the
4287 * callback is currently executing
4288 */
4289 spin_lock(&hdd_context_lock);
4290 context.magic = 0;
4291 spin_unlock(&hdd_context_lock);
4292
4293 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304294 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295}
4296
4297/**
4298 * hdd_get_station_statistics_cb() - Get stats callback function
4299 * @pStats: pointer to Class A stats
4300 * @pContext: user context originally registered with SME
4301 *
4302 * Return: None
4303 */
4304static void hdd_get_station_statistics_cb(void *pStats, void *pContext)
4305{
4306 struct statsContext *pStatsContext;
4307 tCsrSummaryStatsInfo *pSummaryStats;
4308 tCsrGlobalClassAStatsInfo *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304309 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310 hdd_adapter_t *pAdapter;
4311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004313 hdd_err("Bad param, pStats [%p] pContext [%p]",
4314 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 return;
4316 }
4317
4318 /* there is a race condition that exists between this callback
4319 * function and the caller since the caller could time out
4320 * either before or while this code is executing. we use a
4321 * spinlock to serialize these actions
4322 */
4323 spin_lock(&hdd_context_lock);
4324
4325 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
4326 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304327 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
4328 (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 pStatsContext = pContext;
4330 pAdapter = pStatsContext->pAdapter;
4331 if ((NULL == pAdapter) ||
4332 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
4333 /* the caller presumably timed out so there is nothing
4334 * we can do
4335 */
4336 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07004337 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
4338 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 return;
4340 }
4341
4342 /* context is valid so caller is still waiting */
4343
4344 /* paranoia: invalidate the magic */
4345 pStatsContext->magic = 0;
4346
4347 /* copy over the stats. do so as a struct copy */
4348 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
4349 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304350 pAdapter->hdd_stats.per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004351
4352 /* notify the caller */
4353 complete(&pStatsContext->completion);
4354
4355 /* serialization is complete */
4356 spin_unlock(&hdd_context_lock);
4357}
4358
4359/**
4360 * wlan_hdd_get_station_stats() - Get station statistics
4361 * @pAdapter: adapter for which statistics are desired
4362 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304363 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304365QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366{
4367 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304368 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369 unsigned long rc;
Jeff Johnson5aacdf92016-11-04 18:08:11 -07004370 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371
4372 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004373 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304374 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 }
4376
4377 /* we are connected so prepare our callback context */
4378 init_completion(&context.completion);
4379 context.pAdapter = pAdapter;
4380 context.magic = STATS_CONTEXT_MAGIC;
4381
4382 /* query only for Summary & Class A statistics */
4383 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4384 eCSR_HDD,
4385 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304386 SME_GLOBAL_CLASSA_STATS |
4387 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388 hdd_get_station_statistics_cb,
4389 0, /* not periodic */
4390 false, /* non-cached results */
4391 pHddStaCtx->conn_info.staId[0],
4392 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304393 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004394 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 /* we'll return with cached values */
4396 } else {
4397 /* request was sent -- wait for the response */
4398 rc = wait_for_completion_timeout
4399 (&context.completion,
4400 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4401
4402 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004403 hdd_err("SME timed out while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404 }
4405 }
4406
4407 /* either we never sent a request, we sent a request and
4408 * received a response or we sent a request and timed out. if
4409 * we never sent a request or if we sent a request and got a
4410 * response, we want to clear the magic out of paranoia. if
4411 * we timed out there is a race condition such that the
4412 * callback function could be executing at the same time we
4413 * are. of primary concern is if the callback function had
4414 * already verified the "magic" but had not yet set the
4415 * completion variable when a timeout occurred. we serialize
4416 * these activities by invalidating the magic while holding a
4417 * shared spinlock which will cause us to block if the
4418 * callback is currently executing
4419 */
4420 spin_lock(&hdd_context_lock);
4421 context.magic = 0;
4422 spin_unlock(&hdd_context_lock);
4423
4424 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304425 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426}
4427
4428/**
4429 * iw_get_linkspeed() - Get current link speed ioctl
4430 * @dev: device upon which the ioctl was received
4431 * @info: ioctl request information
4432 * @wrqu: ioctl request data
4433 * @extra: extra ioctl buffer
4434 *
4435 * Return: 0 on success, non-zero on error
4436 */
4437static int __iw_get_linkspeed(struct net_device *dev,
4438 struct iw_request_info *info,
4439 union iwreq_data *wrqu, char *extra)
4440{
4441 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4442 char *pLinkSpeed = (char *)extra;
4443 int len = sizeof(uint32_t) + 1;
4444 uint32_t link_speed = 0;
4445 hdd_context_t *hdd_ctx;
4446 int rc, valid;
4447
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08004448 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05304449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4451 valid = wlan_hdd_validate_context(hdd_ctx);
4452 if (0 != valid)
4453 return valid;
4454
4455 rc = wlan_hdd_get_link_speed(pAdapter, &link_speed);
4456 if (0 != rc) {
4457 return rc;
4458 }
4459
4460 wrqu->data.length = len;
4461 /* return the linkspeed as a string */
4462 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
4463 if ((rc < 0) || (rc >= len)) {
4464 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07004465 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466 return -EIO;
4467 }
4468
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05304469 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 /* a value is being successfully returned */
4471 return 0;
4472}
4473
4474static int iw_get_linkspeed(struct net_device *dev,
4475 struct iw_request_info *info,
4476 union iwreq_data *wrqu, char *extra)
4477{
4478 int ret;
4479
4480 cds_ssr_protect(__func__);
4481 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
4482 cds_ssr_unprotect(__func__);
4483
4484 return ret;
4485}
4486
4487/**
4488 * wlan_hdd_change_country_code_callback() - Change country code callback
4489 * @context: opaque context originally passed to SME. All functions
4490 * which use this callback pass the adapter upon which the country
4491 * code change is active
4492 *
4493 * This function is registered as the callback function when
4494 * sme_change_country_code() is invoked. Callers of
4495 * sme_change_country_code() subsequently wait for the adapter's
4496 * @change_country_code completion variable, so all this function
4497 * needs to do is set that completion variable so that execution can
4498 * continue.
4499 *
4500 * Return: none
4501 */
4502void wlan_hdd_change_country_code_callback(void *context)
4503{
4504
4505 hdd_adapter_t *adapter = context;
4506
4507 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
4508 complete(&adapter->change_country_code);
4509
4510 return;
4511}
4512
4513/**
4514 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
4515 * @dev: device upon which the ioctl was received
4516 * @info: ioctl request information
4517 * @wrqu: ioctl request data
4518 * @extra: ioctl extra data
4519 *
4520 * Return: 0 on success, non-zero on error
4521 */
4522static int __iw_set_nick(struct net_device *dev,
4523 struct iw_request_info *info,
4524 union iwreq_data *wrqu, char *extra)
4525{
4526 hdd_adapter_t *adapter;
4527 hdd_context_t *hdd_ctx;
4528 int ret;
4529
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004530 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531
4532 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4533 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4534 ret = wlan_hdd_validate_context(hdd_ctx);
4535 if (0 != ret)
4536 return ret;
4537
4538 return 0;
4539}
4540
4541/**
4542 * iw_set_nick() - SSR wrapper for __iw_set_nick
4543 * @dev: pointer to net_device
4544 * @info: pointer to iw_request_info
4545 * @wrqu: pointer to iwreq_data
4546 * @extra: extra
4547 *
4548 * Return: 0 on success, error number otherwise
4549 */
4550static int iw_set_nick(struct net_device *dev,
4551 struct iw_request_info *info,
4552 union iwreq_data *wrqu, char *extra)
4553{
4554 int ret;
4555
4556 cds_ssr_protect(__func__);
4557 ret = __iw_set_nick(dev, info, wrqu, extra);
4558 cds_ssr_unprotect(__func__);
4559
4560 return ret;
4561}
4562
4563/**
4564 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
4565 * @dev: device upon which the ioctl was received
4566 * @info: ioctl request information
4567 * @wrqu: ioctl request data
4568 * @extra: ioctl extra data
4569 *
4570 * Return: 0 on success, non-zero on error
4571 */
4572static int __iw_get_nick(struct net_device *dev,
4573 struct iw_request_info *info,
4574 union iwreq_data *wrqu, char *extra)
4575{
4576 hdd_adapter_t *adapter;
4577 hdd_context_t *hdd_ctx;
4578 int ret;
4579
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004580 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581
4582 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4583 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4584 ret = wlan_hdd_validate_context(hdd_ctx);
4585 if (0 != ret)
4586 return ret;
4587
4588 return 0;
4589}
4590
4591/**
4592 * iw_get_nick() - SSR wrapper for __iw_get_nick
4593 * @dev: pointer to net_device
4594 * @info: pointer to iw_request_info
4595 * @wrqu: pointer to iwreq_data
4596 * @extra: extra
4597 *
4598 * Return: 0 on success, error number otherwise
4599 */
4600static int iw_get_nick(struct net_device *dev,
4601 struct iw_request_info *info,
4602 union iwreq_data *wrqu, char *extra)
4603{
4604 int ret;
4605
4606 cds_ssr_protect(__func__);
4607 ret = __iw_get_nick(dev, info, wrqu, extra);
4608 cds_ssr_unprotect(__func__);
4609
4610 return ret;
4611}
4612
4613/**
4614 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
4615 * @dev: device upon which the ioctl was received
4616 * @info: ioctl request information
4617 * @wrqu: ioctl request data
4618 * @extra: ioctl extra data
4619 *
4620 * Return: 0 on success, non-zero on error
4621 */
4622static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4623 union iwreq_data *wrqu, char *extra)
4624{
4625 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4626 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4627 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4628 hdd_context_t *hdd_ctx;
4629 struct iw_point *encoderq = &(wrqu->encoding);
4630 uint32_t keyId;
4631 uint8_t key_length;
4632 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4633 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304634 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 int ret;
4636
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004637 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638
4639 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4640 ret = wlan_hdd_validate_context(hdd_ctx);
4641 if (0 != ret)
4642 return ret;
4643
4644 keyId = encoderq->flags & IW_ENCODE_INDEX;
4645
4646 if (keyId) {
4647 if (keyId > MAX_WEP_KEYS) {
4648 return -EINVAL;
4649 }
4650
4651 fKeyPresent = 1;
4652 keyId--;
4653 } else {
4654 fKeyPresent = 0;
4655 }
4656
4657 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004658 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08004660 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
4661 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662 }
4663 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4664 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4665 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4666 eCSR_ENCRYPT_TYPE_NONE;
4667 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4668 eCSR_ENCRYPT_TYPE_NONE;
4669
4670 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4671 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4672
4673 if (eConnectionState_Associated ==
4674 pHddStaCtx->conn_info.connState) {
4675 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4676 status =
4677 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4678 pAdapter->sessionId,
4679 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304680 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 unsigned long rc;
4682 rc = wait_for_completion_timeout(&pAdapter->
4683 disconnect_comp_var,
4684 msecs_to_jiffies
4685 (WLAN_WAIT_TIME_DISCONNECT));
4686 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004687 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688 }
4689 }
4690
4691 return status;
4692
4693 }
4694
4695 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004696 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004697
4698 pHddStaCtx->conn_info.authType =
4699 (encoderq->
4700 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
4701 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4702
4703 }
4704
4705 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004706 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707
4708 key_length = wrqu->data.length;
4709
4710 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
4711
4712 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004713 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 key_length);
4715
4716 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4717 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4718 pHddStaCtx->conn_info.authType)) {
4719 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4720 } else {
4721 encryptionType =
4722 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4723 }
4724 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004725 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726 key_length);
4727
4728 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4729 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4730 pHddStaCtx->conn_info.authType)) {
4731 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4732 } else {
4733 encryptionType =
4734 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4735 }
4736 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004737 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004738 key_length);
4739 return -EINVAL;
4740 }
4741
4742 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4743 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4744 pWextState->roamProfile.EncryptionType.numEntries = 1;
4745 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4746 encryptionType;
4747 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4748 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4749 encryptionType;
4750
4751 if ((eConnectionState_NotConnected ==
4752 pHddStaCtx->conn_info.connState)
4753 &&
4754 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4755 pHddStaCtx->conn_info.authType)
4756 || (eCSR_AUTH_TYPE_SHARED_KEY ==
4757 pHddStaCtx->conn_info.authType))) {
4758
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304759 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 KeyMaterial[keyId][0], extra, key_length);
4761
4762 pWextState->roamProfile.Keys.KeyLength[keyId] =
4763 (uint8_t) key_length;
4764 pWextState->roamProfile.Keys.defaultIndex =
4765 (uint8_t) keyId;
4766
4767 return status;
4768 }
4769 }
4770
4771 return 0;
4772}
4773
4774/**
4775 * iw_set_encode() - SSR wrapper for __iw_set_encode()
4776 * @dev: pointer to net_device
4777 * @info: pointer to iw_request_info
4778 * @wrqu: pointer to iwreq_data
4779 * @extra: pointer to extra ioctl payload
4780 *
4781 * Return: 0 on success, error number otherwise
4782 */
4783static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4784 union iwreq_data *wrqu, char *extra)
4785{
4786 int ret;
4787
4788 cds_ssr_protect(__func__);
4789 ret = __iw_set_encode(dev, info, wrqu, extra);
4790 cds_ssr_unprotect(__func__);
4791
4792 return ret;
4793}
4794
4795/**
4796 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
4797 * @dev: device upon which the ioctl was received
4798 * @info: ioctl request information
4799 * @wrqu: ioctl request data
4800 * @extra: ioctl extra data
4801 *
4802 * Return: 0 on success, non-zero on error
4803 */
4804static int __iw_get_encodeext(struct net_device *dev,
4805 struct iw_request_info *info,
4806 struct iw_point *dwrq, char *extra)
4807{
4808 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4809 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4810 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4811 int keyId;
4812 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4813 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4814 int i, ret;
4815 hdd_context_t *hdd_ctx;
4816
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004817 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004818
4819 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4820 ret = wlan_hdd_validate_context(hdd_ctx);
4821 if (0 != ret)
4822 return ret;
4823
4824 keyId = pRoamProfile->Keys.defaultIndex;
4825
4826 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004827 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828 return -EINVAL;
4829 }
4830
4831 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
4832 dwrq->flags |= IW_ENCODE_ENABLED;
4833 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304834 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 pRoamProfile->Keys.KeyLength[keyId]);
4836 } else {
4837 dwrq->flags |= IW_ENCODE_DISABLED;
4838 }
4839
4840 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08004841 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 continue;
4843 } else {
4844 break;
4845 }
4846 }
4847
4848 if (MAX_WEP_KEYS == i) {
4849 dwrq->flags |= IW_ENCODE_NOKEY;
4850 } else {
4851 dwrq->flags |= IW_ENCODE_ENABLED;
4852 }
4853
4854 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4855
4856 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
4857 dwrq->flags |= IW_ENCODE_DISABLED;
4858 }
4859
4860 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4861
4862 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
4863 dwrq->flags |= IW_ENCODE_OPEN;
4864 } else {
4865 dwrq->flags |= IW_ENCODE_RESTRICTED;
4866 }
4867 EXIT();
4868 return 0;
4869
4870}
4871
4872/**
4873 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
4874 * @dev: pointer to net_device
4875 * @info: pointer to iw_request_info
4876 * @dwrq: pointer to encoding information
4877 * @extra: pointer to extra ioctl payload
4878 *
4879 * Return: 0 on success, error number otherwise
4880 */
4881static int iw_get_encodeext(struct net_device *dev,
4882 struct iw_request_info *info,
4883 struct iw_point *dwrq, char *extra)
4884{
4885 int ret;
4886
4887 cds_ssr_protect(__func__);
4888 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4889 cds_ssr_unprotect(__func__);
4890
4891 return ret;
4892}
4893
4894/**
4895 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
4896 * @dev: device upon which the ioctl was received
4897 * @info: ioctl request information
4898 * @wrqu: ioctl request data
4899 * @extra: ioctl extra data
4900 *
4901 * Return: 0 on success, non-zero on error
4902 */
4903static int __iw_set_encodeext(struct net_device *dev,
4904 struct iw_request_info *info,
4905 union iwreq_data *wrqu, char *extra)
4906{
4907 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4908 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4909 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4910 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304911 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4913 int ret;
4914 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4915 int key_index;
4916 struct iw_point *encoding = &wrqu->encoding;
4917 tCsrRoamSetKey setKey;
4918 uint32_t roamId = 0xFF;
4919
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004920 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921
4922 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4923 ret = wlan_hdd_validate_context(hdd_ctx);
4924 if (0 != ret)
4925 return ret;
4926
4927 key_index = encoding->flags & IW_ENCODE_INDEX;
4928
4929 if (key_index > 0) {
4930
4931 /*Convert from 1-based to 0-based keying */
4932 key_index--;
4933 }
4934 if (!ext->key_len) {
4935
4936 /*Set the encrytion type to NONE */
4937 pRoamProfile->EncryptionType.encryptionType[0] =
4938 eCSR_ENCRYPT_TYPE_NONE;
4939 return ret;
4940 }
4941
4942 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4943 (IW_ENCODE_ALG_WEP == ext->alg)) {
4944 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4945
Jeff Johnson99bac312016-06-28 10:38:18 -07004946 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947 return -EINVAL;
4948 } else {
4949 /*Static wep, update the roam profile with the keys */
Yingying Tang3cc6b792016-10-20 17:00:37 +08004950 if (ext->key_len
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951 && (ext->key_len <=
4952 eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES)
4953 && key_index < CSR_MAX_NUM_KEY) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304954 qdf_mem_copy(&pRoamProfile->Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 KeyMaterial[key_index][0],
4956 ext->key, ext->key_len);
4957 pRoamProfile->Keys.KeyLength[key_index] =
4958 (uint8_t) ext->key_len;
4959
4960 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4961 pRoamProfile->Keys.defaultIndex =
4962 (uint8_t) key_index;
4963
4964 }
4965 }
4966 return ret;
4967 }
4968
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304969 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970
4971 setKey.keyId = key_index;
4972 setKey.keyLength = ext->key_len;
4973
4974 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304975 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 }
4977
4978 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4979 /*Key direction for group is RX only */
4980 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05304981 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004982 } else {
4983
4984 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304985 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304986 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987 }
4988
4989 /*For supplicant pae role is zero */
4990 setKey.paeRole = 0;
4991
4992 switch (ext->alg) {
4993 case IW_ENCODE_ALG_NONE:
4994 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4995 break;
4996
4997 case IW_ENCODE_ALG_WEP:
4998 setKey.encType =
4999 (ext->key_len ==
5000 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
5001 break;
5002
5003 case IW_ENCODE_ALG_TKIP:
5004 {
5005 uint8_t *pKey = &setKey.Key[0];
5006
5007 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5008
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305009 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010
5011 /* Supplicant sends the 32bytes key in this order
5012 * |--------------|----------|----------|
5013 * | Tk1 | TX MIC | RX MIC |
5014 * |--------------|----------|----------|
5015 * <---16bytes---><--8bytes--><--8bytes-->
5016 *
5017 *
5018 * Sme expects the 32 bytes key to be in the below order
5019 * |--------------|----------|----------|
5020 * | Tk1 | RX MIC | TX MIC |
5021 * |--------------|----------|----------|
5022 * <---16bytes---><--8bytes--><--8bytes-->
5023 */
5024
5025 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305026 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005027
5028 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305029 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030
5031 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305032 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033
5034 }
5035 break;
5036
5037 case IW_ENCODE_ALG_CCMP:
5038 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5039 break;
5040
5041#ifdef FEATURE_WLAN_ESE
5042#define IW_ENCODE_ALG_KRK 6
5043 case IW_ENCODE_ALG_KRK:
5044 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5045 break;
5046#endif /* FEATURE_WLAN_ESE */
5047
5048 default:
5049 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5050 break;
5051 }
5052
Jeff Johnson99bac312016-06-28 10:38:18 -07005053 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
5054 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005056 /* The supplicant may attempt to set the PTK once
5057 * pre-authentication is done. Save the key in the UMAC and
5058 * include it in the ADD BSS request
5059 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305060 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005061 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305062 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005063 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005064 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305065 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005066 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005067 return -EINVAL;
5068 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069
5070 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5071
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305072 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005073 pAdapter->sessionId,
5074 &setKey, &roamId);
5075
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305076 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005077 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305078 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079
5080 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5081 }
5082
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305083 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084}
5085
5086/**
5087 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
5088 * @dev: pointer to net_device
5089 * @info: pointer to iw_request_info
5090 * @wrqu: pointer to iwreq_data
5091 * @extra: pointer to extra ioctl payload
5092 *
5093 * Return: 0 on success, error number otherwise
5094 */
5095static int iw_set_encodeext(struct net_device *dev,
5096 struct iw_request_info *info,
5097 union iwreq_data *wrqu, char *extra)
5098{
5099 int ret;
5100
5101 cds_ssr_protect(__func__);
5102 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5103 cds_ssr_unprotect(__func__);
5104
5105 return ret;
5106}
5107
5108/**
5109 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
5110 * @dev: device upon which the ioctl was received
5111 * @info: ioctl request information
5112 * @wrqu: ioctl request data
5113 * @extra: ioctl extra data
5114 *
5115 * Return: 0 on success, non-zero on error
5116 */
5117static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
5118 union iwreq_data *wrqu, char *extra)
5119{
5120 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5121 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5122 hdd_context_t *hdd_ctx;
5123 int ret;
5124
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005125 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005126
5127 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5128 ret = wlan_hdd_validate_context(hdd_ctx);
5129 if (0 != ret)
5130 return ret;
5131
5132 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5133 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5134
Jeff Johnson99bac312016-06-28 10:38:18 -07005135 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136
5137 return -EINVAL;
5138 }
5139
5140 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
5141
5142 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
5143 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
5144 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305145 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005146 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 return -EIO;
5148 }
5149 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
5150 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
5151 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305152 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05305153 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005154 return -EIO;
5155 }
5156 }
5157 } else {
5158 return -EOPNOTSUPP;
5159 }
5160
Jeff Johnson99bac312016-06-28 10:38:18 -07005161 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162
5163 EXIT();
5164
5165 return 0;
5166
5167}
5168
5169/**
5170 * iw_set_retry() - SSR wrapper for __iw_set_retry()
5171 * @dev: pointer to net_device
5172 * @info: pointer to iw_request_info
5173 * @wrqu: pointer to iwreq_data
5174 * @extra: pointer to extra ioctl payload
5175 *
5176 * Return: 0 on success, error number otherwise
5177 */
5178static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
5179 union iwreq_data *wrqu, char *extra)
5180{
5181 int ret;
5182
5183 cds_ssr_protect(__func__);
5184 ret = __iw_set_retry(dev, info, wrqu, extra);
5185 cds_ssr_unprotect(__func__);
5186
5187 return ret;
5188}
5189
5190/**
5191 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
5192 * @dev: device upon which the ioctl was received
5193 * @info: ioctl request information
5194 * @wrqu: ioctl request data
5195 * @extra: ioctl extra data
5196 *
5197 * Return: 0 on success, non-zero on error
5198 */
5199static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
5200 union iwreq_data *wrqu, char *extra)
5201{
5202 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5203 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5204 uint32_t retry = 0;
5205 hdd_context_t *hdd_ctx;
5206 int ret;
5207
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005208 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005209
5210 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5211 ret = wlan_hdd_validate_context(hdd_ctx);
5212 if (0 != ret)
5213 return ret;
5214
5215 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
5216 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5217
5218 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305219 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005220 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005221 return -EIO;
5222 }
5223
5224 wrqu->retry.value = retry;
5225 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
5226 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5227
5228 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305229 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05305230 hdd_warn("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005231 return -EIO;
5232 }
5233
5234 wrqu->retry.value = retry;
5235 } else {
5236 return -EOPNOTSUPP;
5237 }
5238
Jeff Johnson99bac312016-06-28 10:38:18 -07005239 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005240
5241 EXIT();
5242
5243 return 0;
5244}
5245
5246/**
5247 * iw_get_retry() - SSR wrapper for __iw_get_retry()
5248 * @dev: pointer to net_device
5249 * @info: pointer to iw_request_info
5250 * @wrqu: pointer to iwreq_data
5251 * @extra: pointer to extra ioctl payload
5252 *
5253 * Return: 0 on success, error number otherwise
5254 */
5255static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
5256 union iwreq_data *wrqu, char *extra)
5257{
5258 int ret;
5259
5260 cds_ssr_protect(__func__);
5261 ret = __iw_get_retry(dev, info, wrqu, extra);
5262 cds_ssr_unprotect(__func__);
5263
5264 return ret;
5265}
5266
5267/**
5268 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
5269 * @dev: device upon which the ioctl was received
5270 * @info: ioctl request information
5271 * @wrqu: ioctl request data
5272 * @extra: ioctl extra data
5273 *
5274 * Return: 0 on success, non-zero on error
5275 */
5276static int __iw_set_mlme(struct net_device *dev,
5277 struct iw_request_info *info,
5278 union iwreq_data *wrqu, char *extra)
5279{
5280 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5281 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5282 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305283 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284 hdd_context_t *hdd_ctx;
5285 int ret;
5286
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005287 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005288
5289 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5290 ret = wlan_hdd_validate_context(hdd_ctx);
5291 if (0 != ret)
5292 return ret;
5293
5294 /* reason_code is unused. By default it is set to
5295 * eCSR_DISCONNECT_REASON_UNSPECIFIED
5296 */
5297 switch (mlme->cmd) {
5298 case IW_MLME_DISASSOC:
5299 case IW_MLME_DEAUTH:
5300
5301 if (pHddStaCtx->conn_info.connState ==
5302 eConnectionState_Associated) {
5303 eCsrRoamDisconnectReason reason =
5304 eCSR_DISCONNECT_REASON_UNSPECIFIED;
5305
5306 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
5307 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5308
5309 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5310 status =
5311 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
5312 pAdapter->sessionId, reason);
5313
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305314 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 unsigned long rc;
5316 rc = wait_for_completion_timeout(&pAdapter->
5317 disconnect_comp_var,
5318 msecs_to_jiffies
5319 (WLAN_WAIT_TIME_DISCONNECT));
5320 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07005321 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07005323 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
5324 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005325
5326 /* Resetting authKeyMgmt */
5327 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
5328 0;
5329
Jeff Johnson99bac312016-06-28 10:38:18 -07005330 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331 wlan_hdd_netif_queue_control(pAdapter,
5332 WLAN_NETIF_TX_DISABLE_N_CARRIER,
5333 WLAN_CONTROL_PATH);
5334
5335 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07005336 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
5337 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338 }
5339 break;
5340 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005341 hdd_err("%d Command should be Disassociate/Deauthenticate",
5342 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343 return -EINVAL;
5344 } /* end of switch */
5345
5346 EXIT();
5347
5348 return status;
5349
5350}
5351
5352/**
5353 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
5354 * @dev: pointer to net_device
5355 * @info: pointer to iw_request_info
5356 * @wrqu: pointer to iwreq_data
5357 * @extra: pointer to extra ioctl payload
5358 *
5359 * Return: 0 on success, error number otherwise
5360 */
5361static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
5362 union iwreq_data *wrqu, char *extra)
5363{
5364 int ret;
5365
5366 cds_ssr_protect(__func__);
5367 ret = __iw_set_mlme(dev, info, wrqu, extra);
5368 cds_ssr_unprotect(__func__);
5369
5370 return ret;
5371}
5372
5373/**
5374 * wlan_hdd_update_phymode() - handle change in PHY mode
5375 * @net: device upon which PHY mode change was received
5376 * @hal: umac handle for the driver
5377 * @new_phymode: new PHY mode for the device
5378 * @phddctx: pointer to the HDD context
5379 *
5380 * This function is called when the device is set to a new PHY mode.
5381 * It takes a holistic look at the desired PHY mode along with the
5382 * configured capabilities of the driver and the reported capabilities
5383 * of the hardware in order to correctly configure all PHY-related
5384 * parameters.
5385 *
5386 * Return: 0 on success, negative errno value on error
5387 */
5388int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
5389 int new_phymode, hdd_context_t *phddctx)
5390{
5391#ifdef QCA_HT_2040_COEX
5392 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305393 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394#endif
5395 bool band_24 = false, band_5g = false;
5396 bool ch_bond24 = false, ch_bond5g = false;
5397 tSmeConfigParams smeconfig;
5398 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400 eCsrPhyMode phymode = -EIO, old_phymode;
5401 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
5402 eCsrBand curr_band = eCSR_BAND_ALL;
5403
5404 old_phymode = sme_get_phy_mode(hal);
5405
5406 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5407 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5408 nChannelBondingMode24GHz))
5409 ch_bond24 = true;
5410
5411 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5412 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5413 nChannelBondingMode5GHz))
5414 ch_bond5g = true;
5415
5416 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
5417 band_24 = band_5g = true;
5418 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
5419 band_24 = true;
5420 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
5421 band_5g = true;
5422 }
5423
5424 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07005425 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 -08005426 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
5427
5428 switch (new_phymode) {
5429 case IEEE80211_MODE_AUTO:
5430 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
5431 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
5432 phymode = eCSR_DOT11_MODE_AUTO;
5433 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5434 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5435 curr_band = eCSR_BAND_ALL;
5436 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5437 } else {
5438 sme_set_phy_mode(hal, old_phymode);
5439 return -EIO;
5440 }
5441 break;
5442 case IEEE80211_MODE_11A:
5443 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
5444 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5445 phymode = eCSR_DOT11_MODE_11a;
5446 hdd_dot11mode = eHDD_DOT11_MODE_11a;
5447 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5448 curr_band = eCSR_BAND_5G;
5449 } else {
5450 sme_set_phy_mode(hal, old_phymode);
5451 return -EIO;
5452 }
5453 break;
5454 case IEEE80211_MODE_11B:
5455 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
5456 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5457 phymode = eCSR_DOT11_MODE_11b;
5458 hdd_dot11mode = eHDD_DOT11_MODE_11b;
5459 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5460 curr_band = eCSR_BAND_24;
5461 } else {
5462 sme_set_phy_mode(hal, old_phymode);
5463 return -EIO;
5464 }
5465 break;
5466 case IEEE80211_MODE_11G:
5467 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
5468 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5469 phymode = eCSR_DOT11_MODE_11g;
5470 hdd_dot11mode = eHDD_DOT11_MODE_11g;
5471 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5472 curr_band = eCSR_BAND_24;
5473 } else {
5474 sme_set_phy_mode(hal, old_phymode);
5475 return -EIO;
5476 }
5477 break;
5478 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
5479 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
5480 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
5481 */
5482 case IEEE80211_MODE_11NA_HT20:
5483 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5484 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5485 phymode = eCSR_DOT11_MODE_11n;
5486 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5487 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5488 curr_band = eCSR_BAND_5G;
5489 } else {
5490 sme_set_phy_mode(hal, old_phymode);
5491 return -EIO;
5492 }
5493 break;
5494 case IEEE80211_MODE_11NA_HT40:
5495 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5496 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5497 phymode = eCSR_DOT11_MODE_11n;
5498 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5499 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5500 curr_band = eCSR_BAND_5G;
5501 } else {
5502 sme_set_phy_mode(hal, old_phymode);
5503 return -EIO;
5504 }
5505 break;
5506 case IEEE80211_MODE_11NG_HT20:
5507 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5508 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5509 phymode = eCSR_DOT11_MODE_11n;
5510 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5511 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5512 curr_band = eCSR_BAND_24;
5513 } else {
5514 sme_set_phy_mode(hal, old_phymode);
5515 return -EIO;
5516 }
5517 break;
5518 case IEEE80211_MODE_11NG_HT40:
5519 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5520 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5521 phymode = eCSR_DOT11_MODE_11n;
5522 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5523 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5524 curr_band = eCSR_BAND_24;
5525 } else {
5526 sme_set_phy_mode(hal, old_phymode);
5527 return -EIO;
5528 }
5529 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530 case IEEE80211_MODE_11AC_VHT20:
5531 case IEEE80211_MODE_11AC_VHT40:
5532 case IEEE80211_MODE_11AC_VHT80:
5533 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
5534 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5535 phymode = eCSR_DOT11_MODE_11ac;
5536 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
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;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544 case IEEE80211_MODE_2G_AUTO:
5545 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
5546 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5547 phymode = eCSR_DOT11_MODE_AUTO;
5548 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5549 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
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_5G_AUTO:
5557 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
5558 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5559 phymode = eCSR_DOT11_MODE_AUTO;
5560 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5561 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5562 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5563 curr_band = eCSR_BAND_5G;
5564 } else {
5565 sme_set_phy_mode(hal, old_phymode);
5566 return -EIO;
5567 }
5568 break;
5569 case IEEE80211_MODE_11AGN:
5570 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5571 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
5572 phymode = eCSR_DOT11_MODE_11n;
5573 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5574 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5575 curr_band = eCSR_BAND_ALL;
5576 } else {
5577 sme_set_phy_mode(hal, old_phymode);
5578 return -EIO;
5579 }
5580 break;
5581 default:
5582 return -EIO;
5583 }
5584
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005585 switch (new_phymode) {
5586 case IEEE80211_MODE_11AC_VHT20:
5587 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5588 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5589 break;
5590 case IEEE80211_MODE_11AC_VHT40:
5591 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5592 break;
5593 case IEEE80211_MODE_11AC_VHT80:
5594 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5595 break;
5596 default:
5597 vhtchanwidth = phddctx->config->vhtChannelWidth;
5598 break;
5599 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005600
5601 if (phymode != -EIO) {
5602 sme_get_config_param(hal, &smeconfig);
5603 smeconfig.csrConfig.phyMode = phymode;
5604#ifdef QCA_HT_2040_COEX
5605 if (phymode == eCSR_DOT11_MODE_11n &&
5606 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
5607 smeconfig.csrConfig.obssEnabled = false;
5608 halStatus = sme_set_ht2040_mode(hal,
5609 pAdapter->sessionId,
5610 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305611 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005612 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613 return -EIO;
5614 }
5615 } else if (phymode == eCSR_DOT11_MODE_11n &&
5616 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
5617 smeconfig.csrConfig.obssEnabled = true;
5618 halStatus = sme_set_ht2040_mode(hal,
5619 pAdapter->sessionId,
5620 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305621 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005622 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 return -EIO;
5624 }
5625 }
5626#endif
5627 smeconfig.csrConfig.eBand = curr_band;
5628 smeconfig.csrConfig.bandCapability = curr_band;
5629 if (curr_band == eCSR_BAND_24)
5630 smeconfig.csrConfig.Is11hSupportEnabled = 0;
5631 else
5632 smeconfig.csrConfig.Is11hSupportEnabled =
5633 phddctx->config->Is11hSupportEnabled;
5634 if (curr_band == eCSR_BAND_24)
5635 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5636 else if (curr_band == eCSR_BAND_24)
5637 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5638 else {
5639 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5640 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5641 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 sme_update_config(hal, &smeconfig);
5644
5645 phddctx->config->dot11Mode = hdd_dot11mode;
5646 phddctx->config->nBandCapability = curr_band;
5647 phddctx->config->nChannelBondingMode24GHz =
5648 smeconfig.csrConfig.channelBondingMode24GHz;
5649 phddctx->config->nChannelBondingMode5GHz =
5650 smeconfig.csrConfig.channelBondingMode5GHz;
5651 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005652 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005653 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 return -EIO;
5655 }
5656 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07005657 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5659 else
Dustin Browna30892e2016-10-12 17:28:36 -07005660 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5662
Jeff Johnson99bac312016-06-28 10:38:18 -07005663 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664 phymode, chwidth, curr_band, vhtchanwidth);
5665 }
5666
5667 return 0;
5668}
5669
5670/**
5671 * hdd_get_temperature_cb() - "Get Temperature" callback function
5672 * @temperature: measured temperature
5673 * @pContext: callback context
5674 *
5675 * This function is passed to sme_get_temperature() as the callback
5676 * function to be invoked when the temperature measurement is
5677 * available.
5678 *
5679 * Return: None
5680 */
5681static void hdd_get_temperature_cb(int temperature, void *pContext)
5682{
5683 struct statsContext *pTempContext;
5684 hdd_adapter_t *pAdapter;
5685 ENTER();
5686 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005687 hdd_err("pContext is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005688 return;
5689 }
5690 pTempContext = pContext;
5691 pAdapter = pTempContext->pAdapter;
5692 spin_lock(&hdd_context_lock);
5693 if ((NULL == pAdapter) || (TEMP_CONTEXT_MAGIC != pTempContext->magic)) {
5694 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07005695 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696 pAdapter, pTempContext->magic);
5697 return;
5698 }
5699 if (temperature != 0) {
5700 pAdapter->temperature = temperature;
5701 }
5702 complete(&pTempContext->completion);
5703 spin_unlock(&hdd_context_lock);
5704 EXIT();
5705}
5706
5707/**
5708 * wlan_hdd_get_temperature() - get current device temperature
5709 * @pAdapter: device upon which the request was made
5710 * @temperature: pointer to where the temperature is to be returned
5711 *
5712 * Return: 0 if a temperature value (either current or cached) was
5713 * returned, otherwise a negative errno is returned.
5714 *
5715 */
5716int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
5717{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305718 QDF_STATUS status;
Houston Hoffman59c097f2016-11-09 15:50:25 -08005719 static struct statsContext tempContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720 unsigned long rc;
5721
5722 ENTER();
5723 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005724 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725 return -EPERM;
5726 }
5727 init_completion(&tempContext.completion);
5728 tempContext.pAdapter = pAdapter;
5729 tempContext.magic = TEMP_CONTEXT_MAGIC;
5730 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
5731 &tempContext, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305732 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005733 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734 } else {
5735 rc = wait_for_completion_timeout(&tempContext.completion,
5736 msecs_to_jiffies
5737 (WLAN_WAIT_TIME_STATS));
5738 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005739 hdd_err("SME timed out while retrieving temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005740 }
5741 }
5742 spin_lock(&hdd_context_lock);
5743 tempContext.magic = 0;
5744 spin_unlock(&hdd_context_lock);
5745 *temperature = pAdapter->temperature;
5746 EXIT();
5747 return 0;
5748}
5749
5750/**
5751 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5752 * @dev: device upon which the ioctl was received
5753 * @info: ioctl request information
5754 * @wrqu: ioctl request data
5755 * @extra: ioctl extra data
5756 *
5757 * Return: 0 on success, non-zero on error
5758 */
5759static int __iw_setint_getnone(struct net_device *dev,
5760 struct iw_request_info *info,
5761 union iwreq_data *wrqu, char *extra)
5762{
5763 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5764 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5765 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5766 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5767 hdd_context_t *hdd_ctx;
5768 tSmeConfigParams smeConfig;
5769 int *value = (int *)extra;
5770 int sub_cmd = value[0];
5771 int set_value = value[1];
5772 int ret;
5773 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305774 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005775
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005776 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305777
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005778 INIT_COMPLETION(pWextState->completion_var);
Mukul Sharma81661ae2015-10-30 20:26:02 +05305779 memset(&smeConfig, 0x00, sizeof(smeConfig));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005780
5781 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5782 ret = wlan_hdd_validate_context(hdd_ctx);
5783 if (0 != ret)
5784 return ret;
5785
5786 switch (sub_cmd) {
5787 case WE_SET_11D_STATE:
5788 {
5789 if ((ENABLE_11D == set_value)
5790 || (DISABLE_11D == set_value)) {
5791
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005792 sme_get_config_param(hHal, &smeConfig);
5793 smeConfig.csrConfig.Is11dSupportEnabled =
5794 (bool) set_value;
5795
Jeff Johnson99bac312016-06-28 10:38:18 -07005796 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005797 smeConfig.csrConfig.
5798 Is11dSupportEnabled);
5799
5800 sme_update_config(hHal, &smeConfig);
5801 } else {
5802 return -EINVAL;
5803 }
5804 break;
5805 }
5806
5807 case WE_WOWL:
5808 {
5809 switch (set_value) {
5810 case 0x00:
5811 hdd_exit_wowl(pAdapter);
5812 break;
5813 case 0x01:
5814 case 0x02:
5815 case 0x03:
5816 enable_mp = (set_value & 0x01) ? 1 : 0;
5817 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005818 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005819 (enable_mp ? "YES" : "NO"),
5820 (enable_pbm ? "YES" : "NO"));
5821 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5822 break;
5823 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005824 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005825 set_value);
5826 ret = -EINVAL;
5827 break;
5828 }
5829
5830 break;
5831 }
5832 case WE_SET_POWER:
5833 {
5834 switch (set_value) {
5835 case 1:
5836 /* Enable PowerSave */
5837 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5838 SME_PS_ENABLE);
5839 break;
5840 case 2:
5841 /* Disable PowerSave */
5842 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5843 SME_PS_DISABLE);
5844 break;
5845 case 3: /* Enable UASPD */
5846 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
5847 break;
5848 case 4: /* Disable UASPD */
5849 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
5850 break;
5851 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005852 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005853 set_value);
5854 ret = -EINVAL;
5855 break;
5856 }
5857 break;
5858 }
5859
5860 case WE_SET_MAX_ASSOC:
5861 {
5862 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5863 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5864 ret = -EINVAL;
5865 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5866 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305867 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005868 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005869 ret = -EIO;
5870 }
5871 break;
5872 }
5873
5874 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5875 if (set_value == 0 || set_value == 1)
5876 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
5877 set_value;
5878 else
5879 ret = -EINVAL;
5880 break;
5881
5882 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005883 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5884 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5885 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5886 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305887 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005888 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 ret = -EINVAL;
5890 }
5891 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005892 case WE_SET_MC_RATE:
5893 {
5894 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
5895 break;
5896 }
5897 case WE_SET_TX_POWER:
5898 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305899 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005900
Anurag Chouhanc5548422016-02-24 18:33:27 +05305901 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902 if (sme_set_tx_power
5903 (hHal, pAdapter->sessionId, bssid,
5904 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305905 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005906 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005907 return -EIO;
5908 }
5909 break;
5910 }
5911 case WE_SET_MAX_TX_POWER:
5912 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305913 struct qdf_mac_addr bssid;
5914 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005915
Jeff Johnson99bac312016-06-28 10:38:18 -07005916 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005917 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305918 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
5919 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005920
5921 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305922 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005923 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005924 return -EIO;
5925 }
5926
5927 break;
5928 }
5929 case WE_SET_MAX_TX_POWER_2_4:
5930 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005931 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
5932 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305934 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005935 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005936 return -EIO;
5937 }
5938
5939 break;
5940 }
5941 case WE_SET_MAX_TX_POWER_5_0:
5942 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005943 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
5944 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305946 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005947 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005948 return -EIO;
5949 }
5950
5951 break;
5952 }
5953 case WE_SET_HIGHER_DTIM_TRANSITION:
5954 {
5955 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005956 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957 set_value);
5958 ret = -EINVAL;
5959 } else {
5960 if (pAdapter->higherDtimTransition != set_value) {
5961 pAdapter->higherDtimTransition =
5962 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07005963 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964 pAdapter->higherDtimTransition);
5965 }
5966 }
5967
5968 break;
5969 }
5970
5971 case WE_SET_TM_LEVEL:
5972 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005973 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005974 (void)sme_set_thermal_level(hHal, set_value);
5975 break;
5976 }
5977
5978 case WE_SET_PHYMODE:
5979 {
5980 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5981
5982 ret =
5983 wlan_hdd_update_phymode(dev, hHal, set_value,
5984 phddctx);
5985 break;
5986 }
5987
5988 case WE_SET_NSS:
5989 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005990 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005991 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005992 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005993 ret = -EINVAL;
5994 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305995 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005996 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
5997 set_value))
5998 ret = -EINVAL;
5999 }
6000 break;
6001 }
6002
6003 case WE_SET_GTX_HT_MCS:
6004 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006005 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006006 ret = wma_cli_set_command(pAdapter->sessionId,
6007 WMI_VDEV_PARAM_GTX_HT_MCS,
6008 set_value, GTX_CMD);
6009 break;
6010 }
6011
6012 case WE_SET_GTX_VHT_MCS:
6013 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006014 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 set_value);
6016 ret = wma_cli_set_command(pAdapter->sessionId,
6017 WMI_VDEV_PARAM_GTX_VHT_MCS,
6018 set_value, GTX_CMD);
6019 break;
6020 }
6021
6022 case WE_SET_GTX_USRCFG:
6023 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006024 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025 set_value);
6026 ret = wma_cli_set_command(pAdapter->sessionId,
6027 WMI_VDEV_PARAM_GTX_USR_CFG,
6028 set_value, GTX_CMD);
6029 break;
6030 }
6031
6032 case WE_SET_GTX_THRE:
6033 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006034 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 ret = wma_cli_set_command(pAdapter->sessionId,
6036 WMI_VDEV_PARAM_GTX_THRE,
6037 set_value, GTX_CMD);
6038 break;
6039 }
6040
6041 case WE_SET_GTX_MARGIN:
6042 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006043 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044 ret = wma_cli_set_command(pAdapter->sessionId,
6045 WMI_VDEV_PARAM_GTX_MARGIN,
6046 set_value, GTX_CMD);
6047 break;
6048 }
6049
6050 case WE_SET_GTX_STEP:
6051 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006052 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006053 ret = wma_cli_set_command(pAdapter->sessionId,
6054 WMI_VDEV_PARAM_GTX_STEP,
6055 set_value, GTX_CMD);
6056 break;
6057 }
6058
6059 case WE_SET_GTX_MINTPC:
6060 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006061 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062 ret = wma_cli_set_command(pAdapter->sessionId,
6063 WMI_VDEV_PARAM_GTX_MINTPC,
6064 set_value, GTX_CMD);
6065 break;
6066 }
6067
6068 case WE_SET_GTX_BWMASK:
6069 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006070 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 ret = wma_cli_set_command(pAdapter->sessionId,
6072 WMI_VDEV_PARAM_GTX_BW_MASK,
6073 set_value, GTX_CMD);
6074 break;
6075 }
6076
6077 case WE_SET_LDPC:
6078 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306079 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006080 break;
6081 }
6082
6083 case WE_SET_TX_STBC:
6084 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306085 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006086 break;
6087 }
6088
6089 case WE_SET_RX_STBC:
6090 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306091 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 break;
6093 }
6094
6095 case WE_SET_SHORT_GI:
6096 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006097 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
6099 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
6100 set_value);
6101 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07006102 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006103 break;
6104 }
6105
6106 case WE_SET_RTSCTS:
6107 {
6108 uint32_t value;
6109
Jeff Johnson99bac312016-06-28 10:38:18 -07006110 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006111 set_value);
6112
6113 if ((set_value & HDD_RTSCTS_EN_MASK) ==
6114 HDD_RTSCTS_ENABLE)
6115 value =
6116 (WLAN_HDD_GET_CTX(pAdapter))->config->
6117 RTSThreshold;
6118 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
6119 || ((set_value & HDD_RTSCTS_EN_MASK) ==
6120 HDD_CTS_ENABLE))
6121 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
6122 else
6123 return -EIO;
6124
6125 ret = wma_cli_set_command(pAdapter->sessionId,
6126 WMI_VDEV_PARAM_ENABLE_RTSCTS,
6127 set_value, VDEV_CMD);
6128 if (!ret) {
6129 if (sme_cfg_set_int
6130 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306131 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006132 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006133 return -EIO;
6134 }
6135 }
6136
6137 break;
6138 }
6139
6140 case WE_SET_CHWIDTH:
6141 {
6142 bool chwidth = false;
6143 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
6144 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07006145 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006146 set_value);
6147 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006148 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006149 return -EINVAL;
6150 }
6151
6152 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
6153 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
6154 nChannelBondingMode5GHz)))
6155 chwidth = true;
6156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157 sme_get_config_param(hHal, &smeConfig);
6158 switch (set_value) {
6159 case eHT_CHANNEL_WIDTH_20MHZ:
6160 smeConfig.csrConfig.channelBondingMode5GHz =
6161 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
6162 break;
6163 case eHT_CHANNEL_WIDTH_40MHZ:
6164 if (chwidth)
6165 smeConfig.csrConfig.
6166 channelBondingMode5GHz =
6167 phddctx->config->
6168 nChannelBondingMode5GHz;
6169 else
6170 return -EINVAL;
6171
6172 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006173 case eHT_CHANNEL_WIDTH_80MHZ:
6174 if (chwidth)
6175 smeConfig.csrConfig.
6176 channelBondingMode5GHz =
6177 phddctx->config->
6178 nChannelBondingMode5GHz;
6179 else
6180 return -EINVAL;
6181
6182 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006183
6184 default:
6185 return -EINVAL;
6186 }
6187
6188 ret = wma_cli_set_command(pAdapter->sessionId,
6189 WMI_VDEV_PARAM_CHWIDTH,
6190 set_value, VDEV_CMD);
6191 if (!ret)
6192 sme_update_config(hHal, &smeConfig);
6193
6194 break;
6195 }
6196
6197 case WE_SET_ANI_EN_DIS:
6198 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006199 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006200 set_value);
6201 ret = wma_cli_set_command(pAdapter->sessionId,
6202 WMI_PDEV_PARAM_ANI_ENABLE,
6203 set_value, PDEV_CMD);
6204 break;
6205 }
6206
6207 case WE_SET_ANI_POLL_PERIOD:
6208 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006209 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210 set_value);
6211 ret = wma_cli_set_command(pAdapter->sessionId,
6212 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6213 set_value, PDEV_CMD);
6214 break;
6215 }
6216
6217 case WE_SET_ANI_LISTEN_PERIOD:
6218 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006219 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006220 set_value);
6221 ret = wma_cli_set_command(pAdapter->sessionId,
6222 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6223 set_value, PDEV_CMD);
6224 break;
6225 }
6226
6227 case WE_SET_ANI_OFDM_LEVEL:
6228 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006229 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006230 set_value);
6231 ret = wma_cli_set_command(pAdapter->sessionId,
6232 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6233 set_value, PDEV_CMD);
6234 break;
6235 }
6236
6237 case WE_SET_ANI_CCK_LEVEL:
6238 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006239 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006240 set_value);
6241 ret = wma_cli_set_command(pAdapter->sessionId,
6242 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6243 set_value, PDEV_CMD);
6244 break;
6245 }
6246
6247 case WE_SET_DYNAMIC_BW:
6248 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006249 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006250 set_value);
6251 ret = wma_cli_set_command(pAdapter->sessionId,
6252 WMI_PDEV_PARAM_DYNAMIC_BW,
6253 set_value, PDEV_CMD);
6254 break;
6255 }
6256
6257 case WE_SET_CTS_CBW:
6258 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006259 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006260 ret = wma_cli_set_command(pAdapter->sessionId,
6261 WMI_PDEV_PARAM_CTS_CBW,
6262 set_value, PDEV_CMD);
6263 break;
6264 }
6265
6266 case WE_SET_11N_RATE:
6267 {
6268 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07006269 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006270 set_value);
6271
6272 if (set_value != 0xff) {
6273 rix = RC_2_RATE_IDX(set_value);
6274 if (set_value & 0x80) {
6275 preamble = WMI_RATE_PREAMBLE_HT;
6276 nss = HT_RC_2_STREAMS(set_value) - 1;
6277 } else {
6278 nss = 0;
6279 rix = RC_2_RATE_IDX(set_value);
6280 if (set_value & 0x10) {
6281 preamble =
6282 WMI_RATE_PREAMBLE_CCK;
6283 if (rix != 0x3)
6284 /* Enable Short
6285 * preamble always for
6286 * CCK except 1mbps
6287 */
6288 rix |= 0x4;
6289 } else {
6290 preamble =
6291 WMI_RATE_PREAMBLE_OFDM;
6292 }
6293 }
6294 set_value = (preamble << 6) | (nss << 4) | rix;
6295 }
6296 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
6297 set_value, rix, preamble, nss);
6298
6299 ret = wma_cli_set_command(pAdapter->sessionId,
6300 WMI_VDEV_PARAM_FIXED_RATE,
6301 set_value, VDEV_CMD);
6302 break;
6303 }
6304
6305 case WE_SET_VHT_RATE:
6306 {
6307 uint8_t preamble = 0, nss = 0, rix = 0;
6308
6309 if (set_value != 0xff) {
6310 rix = RC_2_RATE_IDX_11AC(set_value);
6311 preamble = WMI_RATE_PREAMBLE_VHT;
6312 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
6313
6314 set_value = (preamble << 6) | (nss << 4) | rix;
6315 }
6316 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
6317 set_value, rix, preamble, nss);
6318 ret = wma_cli_set_command(pAdapter->sessionId,
6319 WMI_VDEV_PARAM_FIXED_RATE,
6320 set_value, VDEV_CMD);
6321 break;
6322 }
6323
6324 case WE_SET_AMPDU:
6325 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006326 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006327 ret = wma_cli_set_command(pAdapter->sessionId,
6328 GEN_VDEV_PARAM_AMPDU,
6329 set_value, GEN_CMD);
6330 break;
6331 }
6332
6333 case WE_SET_AMSDU:
6334 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006335 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006336 ret = wma_cli_set_command(pAdapter->sessionId,
6337 GEN_VDEV_PARAM_AMSDU,
6338 set_value, GEN_CMD);
6339 break;
6340 }
6341
6342 case WE_SET_BURST_ENABLE:
6343 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006344 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006345 if ((set_value == 0) || (set_value == 1)) {
6346 ret = wma_cli_set_command(pAdapter->sessionId,
6347 WMI_PDEV_PARAM_BURST_ENABLE,
6348 set_value, PDEV_CMD);
6349 } else
6350 ret = -EINVAL;
6351 break;
6352 }
6353 case WE_SET_BURST_DUR:
6354 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006355 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07006356 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006357 ret = wma_cli_set_command(pAdapter->sessionId,
6358 WMI_PDEV_PARAM_BURST_DUR,
6359 set_value, PDEV_CMD);
6360 else
6361 ret = -EINVAL;
6362 break;
6363 }
6364
6365 case WE_SET_TX_CHAINMASK:
6366 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006367 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006368 set_value);
6369 ret = wma_cli_set_command(pAdapter->sessionId,
6370 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6371 set_value, PDEV_CMD);
6372 break;
6373 }
6374
6375 case WE_SET_RX_CHAINMASK:
6376 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006377 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006378 set_value);
6379 ret = wma_cli_set_command(pAdapter->sessionId,
6380 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6381 set_value, PDEV_CMD);
6382 break;
6383 }
6384
6385 case WE_SET_TXPOW_2G:
6386 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006387 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006388 set_value);
6389 ret = wma_cli_set_command(pAdapter->sessionId,
6390 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6391 set_value, PDEV_CMD);
6392 break;
6393 }
6394
6395 case WE_SET_TXPOW_5G:
6396 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006397 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006398 set_value);
6399 ret = wma_cli_set_command(pAdapter->sessionId,
6400 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6401 set_value, PDEV_CMD);
6402 break;
6403 }
6404
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006405 /* Firmware debug log */
6406 case WE_DBGLOG_LOG_LEVEL:
6407 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006408 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006409 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
6410 ret = wma_cli_set_command(pAdapter->sessionId,
6411 WMI_DBGLOG_LOG_LEVEL,
6412 set_value, DBG_CMD);
6413 break;
6414 }
6415
6416 case WE_DBGLOG_VAP_ENABLE:
6417 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006418 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006419 ret = wma_cli_set_command(pAdapter->sessionId,
6420 WMI_DBGLOG_VAP_ENABLE,
6421 set_value, DBG_CMD);
6422 break;
6423 }
6424
6425 case WE_DBGLOG_VAP_DISABLE:
6426 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006427 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006428 ret = wma_cli_set_command(pAdapter->sessionId,
6429 WMI_DBGLOG_VAP_DISABLE,
6430 set_value, DBG_CMD);
6431 break;
6432 }
6433
6434 case WE_DBGLOG_MODULE_ENABLE:
6435 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006436 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006437 set_value);
6438 hdd_ctx->fw_log_settings.enable = set_value;
6439 ret = wma_cli_set_command(pAdapter->sessionId,
6440 WMI_DBGLOG_MODULE_ENABLE,
6441 set_value, DBG_CMD);
6442 break;
6443 }
6444
6445 case WE_DBGLOG_MODULE_DISABLE:
6446 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006447 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006448 set_value);
6449 hdd_ctx->fw_log_settings.enable = set_value;
6450 ret = wma_cli_set_command(pAdapter->sessionId,
6451 WMI_DBGLOG_MODULE_DISABLE,
6452 set_value, DBG_CMD);
6453 break;
6454 }
6455 case WE_DBGLOG_MOD_LOG_LEVEL:
6456 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006457 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006458 set_value);
6459
6460 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
6461 hdd_ctx->fw_log_settings.index = 0;
6462
6463 hdd_ctx->fw_log_settings.
6464 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
6465 set_value;
6466 hdd_ctx->fw_log_settings.index++;
6467
6468 ret = wma_cli_set_command(pAdapter->sessionId,
6469 WMI_DBGLOG_MOD_LOG_LEVEL,
6470 set_value, DBG_CMD);
6471 break;
6472 }
6473
6474 case WE_DBGLOG_TYPE:
6475 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006476 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006477 hdd_ctx->fw_log_settings.dl_type = set_value;
6478 ret = wma_cli_set_command(pAdapter->sessionId,
6479 WMI_DBGLOG_TYPE,
6480 set_value, DBG_CMD);
6481 break;
6482 }
6483 case WE_DBGLOG_REPORT_ENABLE:
6484 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006485 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486 set_value);
6487 hdd_ctx->fw_log_settings.dl_report = set_value;
6488 ret = wma_cli_set_command(pAdapter->sessionId,
6489 WMI_DBGLOG_REPORT_ENABLE,
6490 set_value, DBG_CMD);
6491 break;
6492 }
6493
6494 case WE_SET_TXRX_FWSTATS:
6495 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006496 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006497 ret = wma_cli_set_command(pAdapter->sessionId,
6498 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
6499 set_value, VDEV_CMD);
6500 break;
6501 }
6502
6503 case WE_TXRX_FWSTATS_RESET:
6504 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006505 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006506 ret = wma_cli_set_command(pAdapter->sessionId,
6507 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
6508 set_value, VDEV_CMD);
6509 break;
6510 }
6511
6512 case WE_DUMP_STATS:
6513 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006514 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006515 hdd_wlan_dump_stats(pAdapter, set_value);
6516 break;
6517 }
6518
6519 case WE_CLEAR_STATS:
6520 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006521 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006522 switch (set_value) {
6523 case WLAN_HDD_STATS:
6524 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6525 memset(&pAdapter->hdd_stats, 0,
6526 sizeof(pAdapter->hdd_stats));
6527 break;
6528 case WLAN_TXRX_HIST_STATS:
6529 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
6530 break;
6531 case WLAN_HDD_NETIF_OPER_HISTORY:
6532 wlan_hdd_clear_netif_queue_history(hdd_ctx);
6533 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05306534 case WLAN_HIF_STATS:
6535 hdd_clear_hif_stats();
6536 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006537 default:
Leo Changfdb45c32016-10-28 11:09:23 -07006538 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
6539 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006540 }
6541 break;
6542 }
6543
6544 case WE_PPS_PAID_MATCH:
6545 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006546 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006547 return EINVAL;
6548
Jeff Johnson99bac312016-06-28 10:38:18 -07006549 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006550 set_value);
6551 ret = wma_cli_set_command(pAdapter->sessionId,
6552 WMI_VDEV_PPS_PAID_MATCH,
6553 set_value, PPS_CMD);
6554 break;
6555 }
6556
6557 case WE_PPS_GID_MATCH:
6558 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006559 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006560 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006561 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006562 set_value);
6563 ret = wma_cli_set_command(pAdapter->sessionId,
6564 WMI_VDEV_PPS_GID_MATCH,
6565 set_value, PPS_CMD);
6566 break;
6567 }
6568
6569 case WE_PPS_EARLY_TIM_CLEAR:
6570 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006571 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006572 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006573 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006574 set_value);
6575 ret = wma_cli_set_command(pAdapter->sessionId,
6576 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6577 set_value, PPS_CMD);
6578 break;
6579 }
6580
6581 case WE_PPS_EARLY_DTIM_CLEAR:
6582 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006583 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006584 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006585 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006586 set_value);
6587 ret = wma_cli_set_command(pAdapter->sessionId,
6588 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6589 set_value, PPS_CMD);
6590 break;
6591 }
6592
6593 case WE_PPS_EOF_PAD_DELIM:
6594 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006595 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006596 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006597 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006598 set_value);
6599 ret = wma_cli_set_command(pAdapter->sessionId,
6600 WMI_VDEV_PPS_EOF_PAD_DELIM,
6601 set_value, PPS_CMD);
6602 break;
6603 }
6604
6605 case WE_PPS_MACADDR_MISMATCH:
6606 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006607 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006608 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006609 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006610 set_value);
6611 ret = wma_cli_set_command(pAdapter->sessionId,
6612 WMI_VDEV_PPS_MACADDR_MISMATCH,
6613 set_value, PPS_CMD);
6614 break;
6615 }
6616
6617 case WE_PPS_DELIM_CRC_FAIL:
6618 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006619 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006620 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006621 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006622 set_value);
6623 ret = wma_cli_set_command(pAdapter->sessionId,
6624 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6625 set_value, PPS_CMD);
6626 break;
6627 }
6628
6629 case WE_PPS_GID_NSTS_ZERO:
6630 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006631 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006632 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006633 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006634 set_value);
6635 ret = wma_cli_set_command(pAdapter->sessionId,
6636 WMI_VDEV_PPS_GID_NSTS_ZERO,
6637 set_value, PPS_CMD);
6638 break;
6639 }
6640
6641 case WE_PPS_RSSI_CHECK:
6642 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006643 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006644 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006645 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006646 set_value);
6647 ret = wma_cli_set_command(pAdapter->sessionId,
6648 WMI_VDEV_PPS_RSSI_CHECK,
6649 set_value, PPS_CMD);
6650 break;
6651 }
6652
6653 case WE_PPS_5G_EBT:
6654 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006655 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006656 return -EINVAL;
6657
Jeff Johnson99bac312016-06-28 10:38:18 -07006658 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006659 ret = wma_cli_set_command(pAdapter->sessionId,
6660 WMI_VDEV_PPS_5G_EBT,
6661 set_value, PPS_CMD);
6662 break;
6663 }
6664
6665 case WE_SET_HTSMPS:
6666 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006667 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006668 ret = wma_cli_set_command(pAdapter->sessionId,
6669 WMI_STA_SMPS_FORCE_MODE_CMDID,
6670 set_value, VDEV_CMD);
6671 break;
6672 }
6673
6674 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6675 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006676 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006677 set_value);
6678 ret = wma_cli_set_command(pAdapter->sessionId,
6679 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6680 set_value, QPOWER_CMD);
6681 break;
6682 }
6683
6684 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6685 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006686 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006687 set_value);
6688 ret = wma_cli_set_command(
6689 pAdapter->sessionId,
6690 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6691 set_value, QPOWER_CMD);
6692 break;
6693 }
6694
6695 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6696 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006697 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006698 set_value);
6699 ret = wma_cli_set_command(
6700 pAdapter->sessionId,
6701 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6702 set_value, QPOWER_CMD);
6703 break;
6704 }
6705
6706 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6707 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006708 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006709 set_value);
6710 ret = wma_cli_set_command(
6711 pAdapter->sessionId,
6712 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6713 set_value, QPOWER_CMD);
6714 break;
6715 }
6716
6717 case WE_MCC_CONFIG_LATENCY:
6718 {
6719 cds_set_mcc_latency(pAdapter, set_value);
6720 break;
6721 }
6722
6723 case WE_MCC_CONFIG_QUOTA:
6724 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006725 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006726 set_value);
6727 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
6728 break;
6729 }
6730 case WE_SET_DEBUG_LOG:
6731 {
6732 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05306733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006734 hdd_ctx->config->gEnableDebugLog = set_value;
6735 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6736 break;
6737 }
6738 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6739 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006740 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006741 if ((set_value == 0) || (set_value == 1))
6742 ret = wma_cli_set_command(
6743 pAdapter->sessionId,
6744 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6745 set_value, VDEV_CMD);
6746 else
6747 ret = -EINVAL;
6748 break;
6749 }
6750 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6751 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006752 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006753 ret = wma_cli_set_command(pAdapter->sessionId,
6754 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6755 set_value, VDEV_CMD);
6756 break;
6757 }
6758 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6759 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006760 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006761 set_value);
6762 ret = wma_cli_set_command(
6763 pAdapter->sessionId,
6764 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6765 set_value, VDEV_CMD);
6766 break;
6767 }
6768 case WE_SET_EARLY_RX_SLOP_STEP:
6769 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006770 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006771 set_value);
6772 ret = wma_cli_set_command(pAdapter->sessionId,
6773 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6774 set_value, VDEV_CMD);
6775 break;
6776 }
6777 case WE_SET_EARLY_RX_INIT_SLOP:
6778 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006779 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006780 set_value);
6781 ret = wma_cli_set_command(pAdapter->sessionId,
6782 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6783 set_value, VDEV_CMD);
6784 break;
6785 }
6786 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6787 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006788 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006789 if ((set_value == 0) || (set_value == 1))
6790 ret = wma_cli_set_command(
6791 pAdapter->sessionId,
6792 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6793 set_value, VDEV_CMD);
6794 else
6795 ret = -EINVAL;
6796 break;
6797 }
6798 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6799 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006800 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006801 ret = wma_cli_set_command(pAdapter->sessionId,
6802 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6803 set_value, VDEV_CMD);
6804 break;
6805 }
6806 case WE_SET_SCAN_DISABLE:
6807 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006808 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
6810 break;
6811 }
Govind Singha471e5e2015-10-12 17:11:14 +05306812 case WE_START_FW_PROFILE:
6813 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006814 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05306815 ret = wma_cli_set_command(pAdapter->sessionId,
6816 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6817 set_value, DBG_CMD);
6818 break;
6819 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306820 case WE_SET_CHANNEL:
6821 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006822 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306823 pAdapter->sessionId, pAdapter->device_mode);
6824
Krunal Sonif07bb382016-03-10 13:02:11 -08006825 if ((QDF_STA_MODE == pAdapter->device_mode) ||
6826 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306827
6828 status = sme_ext_change_channel(hHal,
6829 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306830 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006831 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306832 status);
6833 ret = -EINVAL;
6834 }
6835 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006836 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306837 pAdapter->device_mode);
6838 ret = -EINVAL;
6839 }
6840 break;
6841 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306842 case WE_SET_CONC_SYSTEM_PREF:
6843 {
6844 hdd_info("New preference: %d", set_value);
6845 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6846 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6847 hdd_err("Invalid system preference %d", set_value);
6848 return -EINVAL;
6849 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306850
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306851 /* hdd_ctx, hdd_ctx->config are already checked for null */
6852 hdd_ctx->config->conc_system_pref = set_value;
6853 break;
6854 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006855 default:
6856 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006857 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006858 sub_cmd);
6859 ret = -EINVAL;
6860 break;
6861 }
6862 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306863 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006864 return ret;
6865}
6866
6867static int iw_setint_getnone(struct net_device *dev,
6868 struct iw_request_info *info,
6869 union iwreq_data *wrqu,
6870 char *extra)
6871{
6872 int ret;
6873
6874 cds_ssr_protect(__func__);
6875 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6876 cds_ssr_unprotect(__func__);
6877
6878 return ret;
6879}
6880
6881/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006882 * __iw_setnone_get_threeint() - return three value to up layer.
6883 *
6884 * @dev: pointer of net_device of this wireless card
6885 * @info: meta data about Request sent
6886 * @wrqu: include request info
6887 * @extra: buf used for in/Output
6888 *
6889 * Return: execute result
6890 */
6891static int __iw_setnone_get_threeint(struct net_device *dev,
6892 struct iw_request_info *info,
6893 union iwreq_data *wrqu, char *extra)
6894{
6895 int ret = 0; /* success */
6896 uint32_t *value = (int *)extra;
6897 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6898 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6899
6900 ENTER_DEV(dev);
6901 ret = wlan_hdd_validate_context(hdd_ctx);
6902 if (0 != ret)
6903 return ret;
6904
Jeff Johnson99bac312016-06-28 10:38:18 -07006905 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006906 switch (value[0]) {
6907 case WE_GET_TSF:
6908 ret = hdd_indicate_tsf(adapter, value, 3);
6909 break;
6910 default:
6911 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6912 break;
6913 }
6914 return ret;
6915}
6916
6917/**
6918 * iw_setnone_get_threeint() - return three value to up layer.
6919 *
6920 * @dev: pointer of net_device of this wireless card
6921 * @info: meta data about Request sent
6922 * @wrqu: include request info
6923 * @extra: buf used for in/Output
6924 *
6925 * Return: execute result
6926 */
6927static int iw_setnone_get_threeint(struct net_device *dev,
6928 struct iw_request_info *info,
6929 union iwreq_data *wrqu, char *extra)
6930{
6931 int ret;
6932
6933 cds_ssr_protect(__func__);
6934 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6935 cds_ssr_unprotect(__func__);
6936
6937 return ret;
6938}
6939
6940/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006941 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6942 * @dev: device upon which the ioctl was received
6943 * @info: ioctl request information
6944 * @wrqu: ioctl request data
6945 * @extra: ioctl extra data
6946 *
6947 * Return: 0 on success, non-zero on error
6948 */
6949static int __iw_setchar_getnone(struct net_device *dev,
6950 struct iw_request_info *info,
6951 union iwreq_data *wrqu, char *extra)
6952{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306953 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006954 int sub_cmd;
6955 int ret;
6956 char *pBuffer = NULL;
6957 hdd_adapter_t *pAdapter = (netdev_priv(dev));
6958 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006959 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006960 struct iw_point s_priv_data;
6961
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006962 ENTER_DEV(dev);
6963
Mukul Sharma34777c62015-11-02 20:22:30 +05306964 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006965 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306966 return -EPERM;
6967 }
6968
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006969 ret = wlan_hdd_validate_context(hdd_ctx);
6970 if (0 != ret)
6971 return ret;
6972
6973 /* helper function to get iwreq_data with compat handling. */
6974 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
6975 return -EINVAL;
6976 }
6977
6978 /* make sure all params are correctly passed to function */
6979 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
6980 return -EINVAL;
6981 }
6982
6983 sub_cmd = s_priv_data.flags;
6984
6985 /* ODD number is used for set, copy data using copy_from_user */
6986 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6987 s_priv_data.length);
6988 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006989 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006990 return -ENOMEM;
6991 }
6992
Jeff Johnson99bac312016-06-28 10:38:18 -07006993 hdd_notice("Received length %d", s_priv_data.length);
6994 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006995
6996 switch (sub_cmd) {
6997 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006998 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006999 hdd_add_wowl_ptrn(pAdapter, pBuffer);
7000 break;
7001 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07007002 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007003 hdd_del_wowl_ptrn(pAdapter, pBuffer);
7004 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007005 case WE_NEIGHBOR_REPORT_REQUEST:
7006 {
7007 tRrmNeighborReq neighborReq;
7008 tRrmNeighborRspCallbackInfo callbackInfo;
7009
7010 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007011 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007012 neighborReq.no_ssid =
7013 (s_priv_data.length - 1) ? false : true;
7014 if (!neighborReq.no_ssid) {
7015 neighborReq.ssid.length =
7016 (s_priv_data.length - 1) >
7017 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307018 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007019 pBuffer,
7020 neighborReq.ssid.length);
7021 }
7022
7023 callbackInfo.neighborRspCallback = NULL;
7024 callbackInfo.neighborRspCallbackContext = NULL;
7025 callbackInfo.timeout = 5000; /* 5 seconds */
7026 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
7027 (pAdapter),
7028 pAdapter->sessionId,
7029 &neighborReq,
7030 &callbackInfo);
7031 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07007032 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007033 ret = -EINVAL;
7034 }
7035 }
7036 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007037 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07007038 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007039 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
7040 s_priv_data.length);
7041 break;
7042 case WE_SET_CONFIG:
7043 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307044 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007045 ret = -EINVAL;
7046 }
7047 break;
7048 default:
7049 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007050 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007051 sub_cmd);
7052 ret = -EINVAL;
7053 break;
7054 }
7055 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07007056 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307057 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007058 return ret;
7059}
7060
7061static int iw_setchar_getnone(struct net_device *dev,
7062 struct iw_request_info *info,
7063 union iwreq_data *wrqu, char *extra)
7064{
7065 int ret;
7066
7067 cds_ssr_protect(__func__);
7068 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
7069 cds_ssr_unprotect(__func__);
7070
7071 return ret;
7072}
7073
7074/**
7075 * iw_setnone_getint() - Generic "get integer" private ioctl handler
7076 * @dev: device upon which the ioctl was received
7077 * @info: ioctl request information
7078 * @wrqu: ioctl request data
7079 * @extra: ioctl extra data
7080 *
7081 * Return: 0 on success, non-zero on error
7082 */
7083static int __iw_setnone_getint(struct net_device *dev,
7084 struct iw_request_info *info,
7085 union iwreq_data *wrqu, char *extra)
7086{
7087 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7088 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7089 int *value = (int *)extra;
7090 int ret;
7091 tSmeConfigParams smeConfig;
7092 hdd_context_t *hdd_ctx;
7093
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007094 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307095
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007096 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7097 ret = wlan_hdd_validate_context(hdd_ctx);
7098 if (0 != ret)
7099 return ret;
7100
7101 switch (value[0]) {
7102 case WE_GET_11D_STATE:
7103 {
7104 sme_get_config_param(hHal, &smeConfig);
7105
7106 *value = smeConfig.csrConfig.Is11dSupportEnabled;
7107
Jeff Johnson99bac312016-06-28 10:38:18 -07007108 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007109
7110 break;
7111 }
7112
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007113 case WE_GET_WLAN_DBG:
7114 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307115 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007116 *value = 0;
7117 break;
7118 }
7119 case WE_GET_MAX_ASSOC:
7120 {
7121 if (sme_cfg_get_int
7122 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307123 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007124 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007125 ret = -EIO;
7126 }
7127 break;
7128 }
7129 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
7130 *value = (WLAN_HDD_GET_CTX(
7131 pAdapter))->config->force_sap_acs;
7132 break;
7133
7134 case WE_GET_CONCURRENCY_MODE:
7135 {
7136 *value = cds_get_concurrency_mode();
7137
Jeff Johnson99bac312016-06-28 10:38:18 -07007138 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007139 break;
7140 }
7141
7142 case WE_GET_NSS:
7143 {
7144 sme_get_config_param(hHal, &smeConfig);
7145 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07007146 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007147 break;
7148 }
7149
7150 case WE_GET_GTX_HT_MCS:
7151 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007152 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007153 *value = wma_cli_get_command(pAdapter->sessionId,
7154 WMI_VDEV_PARAM_GTX_HT_MCS,
7155 GTX_CMD);
7156 break;
7157 }
7158
7159 case WE_GET_GTX_VHT_MCS:
7160 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007161 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007162 *value = wma_cli_get_command(pAdapter->sessionId,
7163 WMI_VDEV_PARAM_GTX_VHT_MCS,
7164 GTX_CMD);
7165 break;
7166 }
7167
7168 case WE_GET_GTX_USRCFG:
7169 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007170 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007171 *value = wma_cli_get_command(pAdapter->sessionId,
7172 WMI_VDEV_PARAM_GTX_USR_CFG,
7173 GTX_CMD);
7174 break;
7175 }
7176
7177 case WE_GET_GTX_THRE:
7178 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007179 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007180 *value = wma_cli_get_command(pAdapter->sessionId,
7181 WMI_VDEV_PARAM_GTX_THRE,
7182 GTX_CMD);
7183 break;
7184 }
7185
7186 case WE_GET_GTX_MARGIN:
7187 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007188 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007189 *value = wma_cli_get_command(pAdapter->sessionId,
7190 WMI_VDEV_PARAM_GTX_MARGIN,
7191 GTX_CMD);
7192 break;
7193 }
7194
7195 case WE_GET_GTX_STEP:
7196 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007197 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007198 *value = wma_cli_get_command(pAdapter->sessionId,
7199 WMI_VDEV_PARAM_GTX_STEP,
7200 GTX_CMD);
7201 break;
7202 }
7203
7204 case WE_GET_GTX_MINTPC:
7205 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007206 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007207 *value = wma_cli_get_command(pAdapter->sessionId,
7208 WMI_VDEV_PARAM_GTX_MINTPC,
7209 GTX_CMD);
7210 break;
7211 }
7212
7213 case WE_GET_GTX_BWMASK:
7214 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007215 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007216 *value = wma_cli_get_command(pAdapter->sessionId,
7217 WMI_VDEV_PARAM_GTX_BW_MASK,
7218 GTX_CMD);
7219 break;
7220 }
7221
7222 case WE_GET_LDPC:
7223 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307224 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007225 break;
7226 }
7227
7228 case WE_GET_TX_STBC:
7229 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307230 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007231 break;
7232 }
7233
7234 case WE_GET_RX_STBC:
7235 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307236 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007237 break;
7238 }
7239
7240 case WE_GET_SHORT_GI:
7241 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007242 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007243 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
7244 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
7245 break;
7246 }
7247
7248 case WE_GET_RTSCTS:
7249 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007250 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007251 *value = wma_cli_get_command(pAdapter->sessionId,
7252 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7253 VDEV_CMD);
7254 break;
7255 }
7256
7257 case WE_GET_CHWIDTH:
7258 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007259 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007260 *value = wma_cli_get_command(pAdapter->sessionId,
7261 WMI_VDEV_PARAM_CHWIDTH,
7262 VDEV_CMD);
7263 break;
7264 }
7265
7266 case WE_GET_ANI_EN_DIS:
7267 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007268 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007269 *value = wma_cli_get_command(pAdapter->sessionId,
7270 WMI_PDEV_PARAM_ANI_ENABLE,
7271 PDEV_CMD);
7272 break;
7273 }
7274
7275 case WE_GET_ANI_POLL_PERIOD:
7276 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007277 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007278 *value = wma_cli_get_command(pAdapter->sessionId,
7279 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
7280 PDEV_CMD);
7281 break;
7282 }
7283
7284 case WE_GET_ANI_LISTEN_PERIOD:
7285 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007286 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007287 *value = wma_cli_get_command(pAdapter->sessionId,
7288 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
7289 PDEV_CMD);
7290 break;
7291 }
7292
7293 case WE_GET_ANI_OFDM_LEVEL:
7294 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007295 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007296 *value = wma_cli_get_command(pAdapter->sessionId,
7297 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
7298 PDEV_CMD);
7299 break;
7300 }
7301
7302 case WE_GET_ANI_CCK_LEVEL:
7303 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007304 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007305 *value = wma_cli_get_command(pAdapter->sessionId,
7306 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
7307 PDEV_CMD);
7308 break;
7309 }
7310
7311 case WE_GET_DYNAMIC_BW:
7312 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007313 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007314 *value = wma_cli_get_command(pAdapter->sessionId,
7315 WMI_PDEV_PARAM_DYNAMIC_BW,
7316 PDEV_CMD);
7317 break;
7318 }
7319
7320 case WE_GET_11N_RATE:
7321 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007322 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007323 *value = wma_cli_get_command(pAdapter->sessionId,
7324 WMI_VDEV_PARAM_FIXED_RATE,
7325 VDEV_CMD);
7326 break;
7327 }
7328
7329 case WE_GET_AMPDU:
7330 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007331 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007332 *value = wma_cli_get_command(pAdapter->sessionId,
7333 GEN_VDEV_PARAM_AMPDU,
7334 GEN_CMD);
7335 break;
7336 }
7337
7338 case WE_GET_AMSDU:
7339 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007340 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007341 *value = wma_cli_get_command(pAdapter->sessionId,
7342 GEN_VDEV_PARAM_AMSDU,
7343 GEN_CMD);
7344 break;
7345 }
7346
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007347 case WE_GET_ROAM_SYNCH_DELAY:
7348 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007349 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007350 *value = wma_cli_get_command(pAdapter->sessionId,
7351 GEN_VDEV_ROAM_SYNCH_DELAY,
7352 GEN_CMD);
7353 break;
7354 }
7355
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007356 case WE_GET_BURST_ENABLE:
7357 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007358 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007359 *value = wma_cli_get_command(pAdapter->sessionId,
7360 WMI_PDEV_PARAM_BURST_ENABLE,
7361 PDEV_CMD);
7362 break;
7363 }
7364 case WE_GET_BURST_DUR:
7365 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007366 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007367 *value = wma_cli_get_command(pAdapter->sessionId,
7368 WMI_PDEV_PARAM_BURST_DUR,
7369 PDEV_CMD);
7370 break;
7371 }
7372
7373 case WE_GET_TX_CHAINMASK:
7374 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007375 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007376 *value = wma_cli_get_command(pAdapter->sessionId,
7377 WMI_PDEV_PARAM_TX_CHAIN_MASK,
7378 PDEV_CMD);
7379 break;
7380 }
7381
7382 case WE_GET_RX_CHAINMASK:
7383 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007384 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007385 *value = wma_cli_get_command(pAdapter->sessionId,
7386 WMI_PDEV_PARAM_RX_CHAIN_MASK,
7387 PDEV_CMD);
7388 break;
7389 }
7390
7391 case WE_GET_TXPOW_2G:
7392 {
7393 uint32_t txpow2g = 0;
7394 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07007395 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007396 *value = wma_cli_get_command(pAdapter->sessionId,
7397 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
7398 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307399 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007400 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7401 &txpow2g)) {
7402 return -EIO;
7403 }
Jeff Johnson99bac312016-06-28 10:38:18 -07007404 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007405 break;
7406 }
7407
7408 case WE_GET_TXPOW_5G:
7409 {
7410 uint32_t txpow5g = 0;
7411 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07007412 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007413 *value = wma_cli_get_command(pAdapter->sessionId,
7414 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
7415 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307416 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007417 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7418 &txpow5g)) {
7419 return -EIO;
7420 }
Jeff Johnson99bac312016-06-28 10:38:18 -07007421 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007422 break;
7423 }
7424
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007425 case WE_GET_PPS_PAID_MATCH:
7426 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007427 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007428 *value = wma_cli_get_command(pAdapter->sessionId,
7429 WMI_VDEV_PPS_PAID_MATCH,
7430 PPS_CMD);
7431 break;
7432 }
7433
7434 case WE_GET_PPS_GID_MATCH:
7435 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007436 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007437 *value = wma_cli_get_command(pAdapter->sessionId,
7438 WMI_VDEV_PPS_GID_MATCH,
7439 PPS_CMD);
7440 break;
7441 }
7442
7443 case WE_GET_PPS_EARLY_TIM_CLEAR:
7444 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007445 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007446 *value = wma_cli_get_command(pAdapter->sessionId,
7447 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
7448 PPS_CMD);
7449 break;
7450 }
7451
7452 case WE_GET_PPS_EARLY_DTIM_CLEAR:
7453 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007454 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007455 *value = wma_cli_get_command(pAdapter->sessionId,
7456 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
7457 PPS_CMD);
7458 break;
7459 }
7460
7461 case WE_GET_PPS_EOF_PAD_DELIM:
7462 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007463 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007464 *value = wma_cli_get_command(pAdapter->sessionId,
7465 WMI_VDEV_PPS_EOF_PAD_DELIM,
7466 PPS_CMD);
7467 break;
7468 }
7469
7470 case WE_GET_PPS_MACADDR_MISMATCH:
7471 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007472 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007473 *value = wma_cli_get_command(pAdapter->sessionId,
7474 WMI_VDEV_PPS_MACADDR_MISMATCH,
7475 PPS_CMD);
7476 break;
7477 }
7478
7479 case WE_GET_PPS_DELIM_CRC_FAIL:
7480 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007481 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007482 *value = wma_cli_get_command(pAdapter->sessionId,
7483 WMI_VDEV_PPS_DELIM_CRC_FAIL,
7484 PPS_CMD);
7485 break;
7486 }
7487
7488 case WE_GET_PPS_GID_NSTS_ZERO:
7489 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007490 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007491 *value = wma_cli_get_command(pAdapter->sessionId,
7492 WMI_VDEV_PPS_GID_NSTS_ZERO,
7493 PPS_CMD);
7494 break;
7495 }
7496
7497 case WE_GET_PPS_RSSI_CHECK:
7498 {
7499
Jeff Johnson99bac312016-06-28 10:38:18 -07007500 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007501 *value = wma_cli_get_command(pAdapter->sessionId,
7502 WMI_VDEV_PPS_RSSI_CHECK,
7503 PPS_CMD);
7504 break;
7505 }
7506
7507 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
7508 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007509 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007510 *value = wma_cli_get_command(pAdapter->sessionId,
7511 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
7512 QPOWER_CMD);
7513 break;
7514 }
7515
7516 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
7517 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007518 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007519 *value = wma_cli_get_command(pAdapter->sessionId,
7520 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
7521 QPOWER_CMD);
7522 break;
7523 }
7524
7525 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
7526 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007527 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007528 *value = wma_cli_get_command(pAdapter->sessionId,
7529 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
7530 QPOWER_CMD);
7531 break;
7532 }
7533
7534 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
7535 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007536 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007537 *value = wma_cli_get_command(pAdapter->sessionId,
7538 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
7539 QPOWER_CMD);
7540 break;
7541 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07007542 case WE_CAP_TSF:
7543 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
7544 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007545 case WE_GET_TEMPERATURE:
7546 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007547 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007548 ret = wlan_hdd_get_temperature(pAdapter, value);
7549 break;
7550 }
7551 default:
7552 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007553 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007554 value[0]);
7555 break;
7556 }
7557 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307558 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007559 return ret;
7560}
7561
7562static int iw_setnone_getint(struct net_device *dev,
7563 struct iw_request_info *info,
7564 union iwreq_data *wrqu, char *extra)
7565{
7566 int ret;
7567
7568 cds_ssr_protect(__func__);
7569 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7570 cds_ssr_unprotect(__func__);
7571
7572 return ret;
7573}
7574
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307575static int hdd_set_fwtest(int argc, int cmd, int value)
7576{
7577 struct set_fwtest_params *fw_test;
7578
7579 /* check for max number of arguments */
7580 if (argc > (WMA_MAX_NUM_ARGS) ||
7581 argc != HDD_FWTEST_PARAMS) {
7582 hdd_err("Too Many args %d", argc);
7583 return -EINVAL;
7584 }
7585 /*
7586 * check if number of arguments are 3 then, check
7587 * then set the default value for sounding interval.
7588 */
7589 if (HDD_FWTEST_PARAMS == argc) {
7590 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7591 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7592 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7593 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7594 }
7595 /* check sounding interval value should not exceed to max */
7596 if (value > HDD_FWTEST_MAX_VALUE) {
7597 hdd_err("Invalid arguments value should not exceed max: %d",
7598 value);
7599 return -EINVAL;
7600 }
7601 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7602 if (NULL == fw_test) {
7603 hdd_err("qdf_mem_malloc failed for fw_test");
7604 return -ENOMEM;
7605 }
7606 fw_test->arg = cmd;
7607 fw_test->value = value;
7608 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7609 qdf_mem_free(fw_test);
7610 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7611 return -EINVAL;
7612 }
7613 return 0;
7614}
7615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007616/**
7617 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7618 * @dev: device upon which the ioctl was received
7619 * @info: ioctl request information
7620 * @wrqu: ioctl request data
7621 * @extra: ioctl extra data
7622 *
7623 * Return: 0 on success, non-zero on error
7624 */
7625static int __iw_set_three_ints_getnone(struct net_device *dev,
7626 struct iw_request_info *info,
7627 union iwreq_data *wrqu, char *extra)
7628{
7629 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7630 int *value = (int *)extra;
7631 int sub_cmd = value[0];
7632 int ret;
7633 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7634
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007635 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307636
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007637 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007638 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007639 return -EPERM;
7640 }
7641
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007642 ret = wlan_hdd_validate_context(hdd_ctx);
7643 if (0 != ret)
7644 return ret;
7645
7646 switch (sub_cmd) {
7647
7648 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307649 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007650 break;
7651 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307652 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007653 break;
7654
7655 /* value[3] the acs band is not required as start and end channels are
7656 * enough but this cmd is maintained under set three ints for historic
7657 * reasons.
7658 */
7659 case WE_SET_SAP_CHANNELS:
7660 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307661 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007662 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307663 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007664 ret = -EINVAL;
7665 } else {
7666 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7667 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7668 }
7669 break;
7670 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7671 hdd_debug("Ioctl to set dual mac scan config");
7672 if (hdd_ctx->config->dual_mac_feature_disable) {
7673 hdd_err("Dual mac feature is disabled from INI");
7674 return -EPERM;
7675 }
7676 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08007677 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007678 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307679 case WE_SET_FW_TEST:
7680 {
7681 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7682 if (ret) {
7683 hdd_err("Not able to set fwtest %d", ret);
7684 return ret;
7685 }
7686 }
7687 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007688 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007689 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007690 break;
7691
7692 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307693 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007694 return ret;
7695}
7696
7697int iw_set_three_ints_getnone(struct net_device *dev,
7698 struct iw_request_info *info,
7699 union iwreq_data *wrqu, char *extra)
7700{
7701 int ret;
7702
7703 cds_ssr_protect(__func__);
7704 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7705 cds_ssr_unprotect(__func__);
7706
7707 return ret;
7708}
7709
7710/**
7711 * hdd_connection_state_string() - Get connection state string
7712 * @connection_state: enum to be converted to a string
7713 *
7714 * Return: the string equivalent of @connection_state
7715 */
7716static const char *
7717hdd_connection_state_string(eConnectionState connection_state)
7718{
7719 switch (connection_state) {
7720 CASE_RETURN_STRING(eConnectionState_NotConnected);
7721 CASE_RETURN_STRING(eConnectionState_Connecting);
7722 CASE_RETURN_STRING(eConnectionState_Associated);
7723 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7724 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7725 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7726 default:
7727 return "UNKNOWN";
7728 }
7729}
7730
7731/**
7732 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7733 * @dev: device upon which the ioctl was received
7734 * @info: ioctl request information
7735 * @wrqu: ioctl request data
7736 * @extra: ioctl extra data
7737 *
7738 * Return: 0 on success, non-zero on error
7739 */
7740static int __iw_get_char_setnone(struct net_device *dev,
7741 struct iw_request_info *info,
7742 union iwreq_data *wrqu, char *extra)
7743{
7744 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7745 int sub_cmd = wrqu->data.flags;
7746 hdd_context_t *hdd_ctx;
7747 int ret;
7748#ifdef WLAN_FEATURE_11W
7749 hdd_wext_state_t *pWextState;
7750#endif
7751
7752#ifdef WLAN_FEATURE_11W
7753 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7754#endif
7755
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007756 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307757
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007758 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7759 ret = wlan_hdd_validate_context(hdd_ctx);
7760 if (0 != ret)
7761 return ret;
7762
7763 switch (sub_cmd) {
7764 case WE_WLAN_VERSION:
7765 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307766 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007767 break;
7768 }
7769
7770 case WE_GET_STATS:
7771 {
7772 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
7773 extra, WE_MAX_STR_LEN);
7774 break;
7775 }
7776
Dustin Brownd9322482017-01-09 12:46:03 -08007777 case WE_GET_SUSPEND_RESUME_STATS:
7778 {
7779 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
7780 WE_MAX_STR_LEN);
7781 if (ret >= 0) {
7782 wrqu->data.length = ret;
7783 ret = 0;
7784 }
7785
7786 break;
7787 }
7788
Govind Singha471e5e2015-10-12 17:11:14 +05307789 case WE_LIST_FW_PROFILE:
7790 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7791 extra, WE_MAX_STR_LEN);
7792 break;
7793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007794 /* The case prints the current state of the HDD, SME, CSR, PE,
7795 * TL it can be extended for WDI Global State as well. And
7796 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7797 * and P2P_GO have not been added as of now.
7798 */
7799 case WE_GET_STATES:
7800 {
7801 int buf = 0, len = 0;
7802 int adapter_num = 0;
7803 int count = 0, check = 1;
7804
7805 tHalHandle hHal = NULL;
7806 tpAniSirGlobal pMac = NULL;
7807 hdd_station_ctx_t *pHddStaCtx = NULL;
7808
7809 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7810 hdd_adapter_t *useAdapter = NULL;
7811
7812 /* Print wlan0 or p2p0 states based on the adapter_num
7813 * by using the correct adapter
7814 */
7815 while (adapter_num < 2) {
7816 if (WLAN_ADAPTER == adapter_num) {
7817 useAdapter = pAdapter;
7818 buf =
7819 scnprintf(extra + len,
7820 WE_MAX_STR_LEN - len,
7821 "\n\n wlan0 States:-");
7822 len += buf;
7823 } else if (P2P_ADAPTER == adapter_num) {
7824 buf =
7825 scnprintf(extra + len,
7826 WE_MAX_STR_LEN - len,
7827 "\n\n p2p0 States:-");
7828 len += buf;
7829
7830 if (!pHddCtx) {
7831 buf =
7832 scnprintf(extra + len,
7833 WE_MAX_STR_LEN -
7834 len,
7835 "\n pHddCtx is NULL");
7836 len += buf;
7837 break;
7838 }
7839
7840 /* Printing p2p0 states only in the
7841 * case when the device is configured
7842 * as a p2p_client
7843 */
7844 useAdapter =
7845 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007846 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007847 if (!useAdapter) {
7848 buf =
7849 scnprintf(extra + len,
7850 WE_MAX_STR_LEN -
7851 len,
7852 "\n Device not configured as P2P_CLIENT.");
7853 len += buf;
7854 break;
7855 }
7856 }
7857
7858 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7859 if (!hHal) {
7860 buf =
7861 scnprintf(extra + len,
7862 WE_MAX_STR_LEN - len,
7863 "\n pMac is NULL");
7864 len += buf;
7865 break;
7866 }
7867 pMac = PMAC_STRUCT(hHal);
7868 if (!pMac) {
7869 buf =
7870 scnprintf(extra + len,
7871 WE_MAX_STR_LEN - len,
7872 "\n pMac is NULL");
7873 len += buf;
7874 break;
7875 }
7876 pHddStaCtx =
7877 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7878
7879
7880 buf =
7881 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7882 "\n HDD Conn State - %s "
7883 "\n \n SME State:"
7884 "\n Neighbour Roam State - %s"
7885 "\n CSR State - %s"
7886 "\n CSR Substate - %s",
7887 hdd_connection_state_string
7888 (pHddStaCtx->conn_info.connState),
7889 mac_trace_get_neighbour_roam_state
7890 (sme_get_neighbor_roam_state
7891 (hHal, useAdapter->sessionId)),
7892 mac_trace_getcsr_roam_state
7893 (sme_get_current_roam_state
7894 (hHal, useAdapter->sessionId)),
7895 mac_trace_getcsr_roam_sub_state
7896 (sme_get_current_roam_sub_state
7897 (hHal, useAdapter->sessionId))
7898 );
7899 len += buf;
7900 adapter_num++;
7901 }
7902
Mukul Sharma81661ae2015-10-30 20:26:02 +05307903 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007904 /* Printing Lim State starting with global lim states */
7905 buf =
7906 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7907 "\n \n LIM STATES:-"
7908 "\n Global Sme State - %s "
7909 "\n Global mlm State - %s " "\n",
7910 mac_trace_get_lim_sme_state
7911 (sme_get_lim_sme_state(hHal)),
7912 mac_trace_get_lim_mlm_state
7913 (sme_get_lim_sme_state(hHal))
7914 );
7915 len += buf;
7916
7917 /* Printing the PE Sme and Mlm states for valid lim sessions */
7918 while (check < 3 && count < 255) {
7919 if (sme_is_lim_session_valid(hHal, count)) {
7920 buf =
7921 scnprintf(extra + len,
7922 WE_MAX_STR_LEN -
7923 len,
7924 "\n Lim Valid Session %d:-"
7925 "\n PE Sme State - %s "
7926 "\n PE Mlm State - %s "
7927 "\n", check,
7928 mac_trace_get_lim_sme_state
7929 (sme_get_lim_sme_session_state
7930 (hHal, count)),
7931 mac_trace_get_lim_mlm_state
7932 (sme_get_lim_mlm_session_state
7933 (hHal, count))
7934 );
7935
7936 len += buf;
7937 check++;
7938 }
7939 count++;
7940 }
7941 }
7942
7943 wrqu->data.length = strlen(extra) + 1;
7944 break;
7945 }
7946
7947 case WE_GET_CFG:
7948 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007949 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007950 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
7951 extra,
7952 QCSAP_IOCTL_MAX_STR_LEN);
7953 wrqu->data.length = strlen(extra) + 1;
7954 break;
7955 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956 case WE_GET_RSSI:
7957 {
7958 int8_t s7Rssi = 0;
7959 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7960 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7961 wrqu->data.length = strlen(extra) + 1;
7962 break;
7963 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007964
7965 case WE_GET_WMM_STATUS:
7966 {
7967 snprintf(extra, WE_MAX_STR_LEN,
7968 "\nDir: 0=up, 1=down, 3=both\n"
7969 "|------------------------|\n"
7970 "|AC | ACM |Admitted| Dir |\n"
7971 "|------------------------|\n"
7972 "|VO | %d | %3s | %d |\n"
7973 "|VI | %d | %3s | %d |\n"
7974 "|BE | %d | %3s | %d |\n"
7975 "|BK | %d | %3s | %d |\n"
7976 "|------------------------|\n",
7977 pAdapter->hddWmmStatus.
7978 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
7979 pAdapter->hddWmmStatus.
7980 wmmAcStatus[SME_AC_VO].
7981 wmmAcAccessAllowed ? "YES" : "NO",
7982 pAdapter->hddWmmStatus.
7983 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
7984 ts_info.direction,
7985 pAdapter->hddWmmStatus.
7986 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
7987 pAdapter->hddWmmStatus.
7988 wmmAcStatus[SME_AC_VI].
7989 wmmAcAccessAllowed ? "YES" : "NO",
7990 pAdapter->hddWmmStatus.
7991 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
7992 ts_info.direction,
7993 pAdapter->hddWmmStatus.
7994 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
7995 pAdapter->hddWmmStatus.
7996 wmmAcStatus[SME_AC_BE].
7997 wmmAcAccessAllowed ? "YES" : "NO",
7998 pAdapter->hddWmmStatus.
7999 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
8000 ts_info.direction,
8001 pAdapter->hddWmmStatus.
8002 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
8003 pAdapter->hddWmmStatus.
8004 wmmAcStatus[SME_AC_BK].
8005 wmmAcAccessAllowed ? "YES" : "NO",
8006 pAdapter->hddWmmStatus.
8007 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
8008 ts_info.direction);
8009
8010 wrqu->data.length = strlen(extra) + 1;
8011 break;
8012 }
8013 case WE_GET_CHANNEL_LIST:
8014 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308015 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008016 uint8_t i, len;
8017 char *buf;
8018 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
8019 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
8020 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8021
8022 tChannelListInfo channel_list;
8023
8024 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05308025 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008026 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308027 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008028 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008029 return -EINVAL;
8030 }
8031 buf = extra;
8032 /*
8033 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
8034 * Maximum buffer needed = 5 * number of channels.
8035 * Check ifsufficient buffer is available and then
8036 * proceed to fill the buffer.
8037 */
8038 if (WE_MAX_STR_LEN <
8039 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008040 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008041 return -EINVAL;
8042 }
8043 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
8044 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308045 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008046 ubuf, &ubuf_len)) {
8047 /* Printing Country code in getChannelList */
8048 for (i = 0; i < (ubuf_len - 1); i++)
8049 len += scnprintf(buf + len,
8050 WE_MAX_STR_LEN - len,
8051 "%c", ubuf[i]);
8052 }
8053 for (i = 0; i < channel_list.num_channels; i++) {
8054 len +=
8055 scnprintf(buf + len, WE_MAX_STR_LEN - len,
8056 " %u", channel_list.channels[i]);
8057 }
8058 wrqu->data.length = strlen(extra) + 1;
8059
8060 break;
8061 }
8062#ifdef FEATURE_WLAN_TDLS
8063 case WE_GET_TDLS_PEERS:
8064 {
8065 wrqu->data.length =
8066 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
8067 WE_MAX_STR_LEN) + 1;
8068 break;
8069 }
8070#endif
8071#ifdef WLAN_FEATURE_11W
8072 case WE_GET_11W_INFO:
8073 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008074 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008075 pWextState->roamProfile.MFPEnabled);
8076
8077 snprintf(extra, WE_MAX_STR_LEN,
8078 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
8079 "\n Number of Unprotected Disassocs %d"
8080 "\n Number of Unprotected Deauths %d",
8081 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
8082 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
8083 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
8084 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
8085 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
8086 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
8087 pWextState->roamProfile.MFPEnabled,
8088 pAdapter->hdd_stats.hddPmfStats.
8089 numUnprotDisassocRx,
8090 pAdapter->hdd_stats.hddPmfStats.
8091 numUnprotDeauthRx);
8092
8093 wrqu->data.length = strlen(extra) + 1;
8094 break;
8095 }
8096#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008097 case WE_GET_IBSS_STA_INFO:
8098 {
8099 hdd_station_ctx_t *pHddStaCtx =
8100 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8101 int idx = 0;
8102 int length = 0, buf = 0;
8103
Naveen Rawatc45d1622016-07-05 12:20:09 -07008104 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008105 if (0 != pHddStaCtx->conn_info.staId[idx]) {
8106 buf = snprintf
8107 ((extra + length),
8108 WE_MAX_STR_LEN - length,
8109 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
8110 pHddStaCtx->conn_info.staId[idx],
8111 pHddStaCtx->conn_info.
8112 peerMacAddress[idx].bytes[0],
8113 pHddStaCtx->conn_info.
8114 peerMacAddress[idx].bytes[1],
8115 pHddStaCtx->conn_info.
8116 peerMacAddress[idx].bytes[2],
8117 pHddStaCtx->conn_info.
8118 peerMacAddress[idx].bytes[3],
8119 pHddStaCtx->conn_info.
8120 peerMacAddress[idx].bytes[4],
8121 pHddStaCtx->conn_info.
8122 peerMacAddress[idx].bytes[5]
8123 );
8124 length += buf;
8125 }
8126 }
8127 wrqu->data.length = strlen(extra) + 1;
8128 break;
8129 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008130 case WE_GET_PHYMODE:
8131 {
8132 bool ch_bond24 = false, ch_bond5g = false;
8133 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
8134 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8135 eCsrPhyMode phymode;
8136 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008137 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008138
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008139 sme_config = qdf_mem_malloc(sizeof(*sme_config));
8140 if (!sme_config) {
8141 hdd_err("Out of memory");
8142 ret = -ENOMEM;
8143 break;
8144 }
8145
8146 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008147 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008148 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008149 ch_bond24 = true;
8150
8151 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008152 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008153 ch_bond5g = true;
8154
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008155 qdf_mem_free(sme_config);
8156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008157 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308158 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008159 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008160 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008161 return -EIO;
8162 }
8163
8164 switch (phymode) {
8165 case eCSR_DOT11_MODE_AUTO:
8166 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
8167 break;
8168 case eCSR_DOT11_MODE_11n:
8169 case eCSR_DOT11_MODE_11n_ONLY:
8170 if (currBand == eCSR_BAND_24) {
8171 if (ch_bond24)
8172 snprintf(extra, WE_MAX_STR_LEN,
8173 "11NGHT40");
8174 else
8175 snprintf(extra, WE_MAX_STR_LEN,
8176 "11NGHT20");
8177 } else if (currBand == eCSR_BAND_5G) {
8178 if (ch_bond5g)
8179 snprintf(extra, WE_MAX_STR_LEN,
8180 "11NAHT40");
8181 else
8182 snprintf(extra, WE_MAX_STR_LEN,
8183 "11NAHT20");
8184 } else {
8185 snprintf(extra, WE_MAX_STR_LEN, "11N");
8186 }
8187 break;
8188 case eCSR_DOT11_MODE_abg:
8189 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
8190 break;
8191 case eCSR_DOT11_MODE_11a:
8192 snprintf(extra, WE_MAX_STR_LEN, "11A");
8193 break;
8194 case eCSR_DOT11_MODE_11b:
8195 case eCSR_DOT11_MODE_11b_ONLY:
8196 snprintf(extra, WE_MAX_STR_LEN, "11B");
8197 break;
8198 case eCSR_DOT11_MODE_11g:
8199 case eCSR_DOT11_MODE_11g_ONLY:
8200 snprintf(extra, WE_MAX_STR_LEN, "11G");
8201 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008202 case eCSR_DOT11_MODE_11ac:
8203 case eCSR_DOT11_MODE_11ac_ONLY:
8204 if (hddctx->config->vhtChannelWidth ==
8205 eHT_CHANNEL_WIDTH_20MHZ)
8206 snprintf(extra, WE_MAX_STR_LEN,
8207 "11ACVHT20");
8208 else if (hddctx->config->vhtChannelWidth ==
8209 eHT_CHANNEL_WIDTH_40MHZ)
8210 snprintf(extra, WE_MAX_STR_LEN,
8211 "11ACVHT40");
8212 else if (hddctx->config->vhtChannelWidth ==
8213 eHT_CHANNEL_WIDTH_80MHZ)
8214 snprintf(extra, WE_MAX_STR_LEN,
8215 "11ACVHT80");
8216 else if (hddctx->config->vhtChannelWidth ==
8217 eHT_CHANNEL_WIDTH_160MHZ)
8218 snprintf(extra, WE_MAX_STR_LEN,
8219 "11ACVHT160");
8220 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008221 }
8222
8223 wrqu->data.length = strlen(extra) + 1;
8224 break;
8225 }
8226
8227#ifdef FEATURE_OEM_DATA_SUPPORT
8228 case WE_GET_OEM_DATA_CAP:
8229 {
8230 return iw_get_oem_data_cap(dev, info, wrqu, extra);
8231 }
8232#endif /* FEATURE_OEM_DATA_SUPPORT */
8233 case WE_GET_SNR:
8234 {
8235 int8_t s7snr = 0;
8236 int status = 0;
8237 hdd_context_t *pHddCtx;
8238 hdd_station_ctx_t *pHddStaCtx;
8239 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8240 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308241 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008242 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308243
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008244 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8245 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
8246 eConnectionState_Associated !=
8247 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008248 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008249 pHddCtx->config->fEnableSNRMonitoring,
8250 pHddStaCtx->conn_info.connState);
8251 return -ENONET;
8252 }
8253 wlan_hdd_get_snr(pAdapter, &s7snr);
8254 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
8255 wrqu->data.length = strlen(extra) + 1;
8256 break;
8257 }
8258 default:
8259 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008260 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008261 sub_cmd);
8262 break;
8263 }
8264 }
Dustin Brownd9322482017-01-09 12:46:03 -08008265
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308266 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -08008267 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008268}
8269
8270static int iw_get_char_setnone(struct net_device *dev,
8271 struct iw_request_info *info,
8272 union iwreq_data *wrqu, char *extra)
8273{
8274 int ret;
8275
8276 cds_ssr_protect(__func__);
8277 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
8278 cds_ssr_unprotect(__func__);
8279
8280 return ret;
8281}
8282
8283/**
8284 * iw_setnone_getnone() - Generic "action" private ioctl handler
8285 * @dev: device upon which the ioctl was received
8286 * @info: ioctl request information
8287 * @wrqu: ioctl request data
8288 * @extra: ioctl extra data
8289 *
8290 * Return: 0 on success, non-zero on error
8291 */
8292static int __iw_setnone_getnone(struct net_device *dev,
8293 struct iw_request_info *info,
8294 union iwreq_data *wrqu, char *extra)
8295{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008296 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008297 hdd_context_t *hdd_ctx;
8298 int ret;
8299 int sub_cmd;
8300
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008301 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308302
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008303 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008304 ret = wlan_hdd_validate_context(hdd_ctx);
8305 if (0 != ret)
8306 return ret;
8307
8308#ifdef CONFIG_COMPAT
8309 /* this ioctl is a special case where a sub-ioctl is used and both
8310 * the number of get and set args is 0. in this specific case the
8311 * logic in iwpriv places the sub_cmd in the data.flags portion of
8312 * the iwreq. unfortunately the location of this field will be
8313 * different between 32-bit and 64-bit userspace, and the standard
8314 * compat support in the kernel does not handle this case. so we
8315 * need to explicitly handle it here.
8316 */
8317 if (is_compat_task()) {
8318 struct compat_iw_point *compat_iw_point =
8319 (struct compat_iw_point *)&wrqu->data;
8320 sub_cmd = compat_iw_point->flags;
8321 } else {
8322 sub_cmd = wrqu->data.flags;
8323 }
8324#else
8325 sub_cmd = wrqu->data.flags;
8326#endif
8327
8328 switch (sub_cmd) {
8329 case WE_GET_RECOVERY_STAT:
8330 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008331 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008332 sme_get_recovery_stats(hal);
8333 break;
8334 }
8335
Govind Singha471e5e2015-10-12 17:11:14 +05308336 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008337 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05308338 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
8339 0, DBG_CMD);
8340 break;
8341
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008342 case WE_IBSS_GET_PEER_INFO_ALL:
8343 {
8344 hdd_wlan_get_ibss_peer_info_all(adapter);
8345 break;
8346 }
8347
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008348 case WE_SET_REASSOC_TRIGGER:
8349 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008350 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8351 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308352 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008353 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308354 uint8_t operating_ch =
8355 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008356 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008357
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008358 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008359 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308360 if (roaming_offload_enabled(hdd_ctx)) {
8361 qdf_mem_copy(bssid,
8362 &adapter->sessionCtx.station.conn_info.bssId,
8363 sizeof(bssid));
8364 hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId,
8365 bssid, operating_ch);
8366 } else {
8367 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
8368 NULL, modProfileFields, &roamId, 1);
8369 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008370 return 0;
8371 }
8372
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008373 case WE_STOP_OBSS_SCAN:
8374 {
8375 /*
8376 * 1.OBSS Scan is mandatory while operating in 2.4GHz
8377 * 2.OBSS scan is stopped by Firmware during the disassociation
8378 * 3.OBSS stop comamnd is added for debugging purpose
8379 */
8380 tHalHandle hal;
8381
8382 hal = WLAN_HDD_GET_HAL_CTX(adapter);
8383 if (hal == NULL) {
8384 hdd_err("hal context is NULL");
8385 return -EINVAL;
8386 }
8387 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
8388 }
8389 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008390 default:
8391 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008392 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008393 break;
8394 }
8395 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308396 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008397 return ret;
8398}
8399
8400static int iw_setnone_getnone(struct net_device *dev,
8401 struct iw_request_info *info,
8402 union iwreq_data *wrqu, char *extra)
8403{
8404 int ret;
8405
8406 cds_ssr_protect(__func__);
8407 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
8408 cds_ssr_unprotect(__func__);
8409
8410 return ret;
8411}
8412
Krunal Sonia6e505b2017-01-12 12:25:18 -08008413#ifdef MPC_UT_FRAMEWORK
8414static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
8415 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
8416{
8417 switch(sub_cmd) {
8418 case WE_POLICY_MANAGER_CLIST_CMD:
8419 {
8420 hdd_err("<iwpriv wlan0 pm_clist> is called");
8421 cds_incr_connection_count_utfw(apps_args[0],
8422 apps_args[1], apps_args[2], apps_args[3],
8423 apps_args[4], apps_args[5], apps_args[6],
8424 apps_args[7]);
8425 }
8426 break;
8427
8428 case WE_POLICY_MANAGER_DLIST_CMD:
8429 {
8430 hdd_err("<iwpriv wlan0 pm_dlist> is called");
8431 cds_decr_connection_count_utfw(apps_args[0],
8432 apps_args[1]);
8433 }
8434 break;
8435
8436 case WE_POLICY_MANAGER_ULIST_CMD:
8437 {
8438 hdd_err("<iwpriv wlan0 pm_ulist> is called");
8439 cds_update_connection_info_utfw(apps_args[0],
8440 apps_args[1], apps_args[2], apps_args[3],
8441 apps_args[4], apps_args[5], apps_args[6],
8442 apps_args[7]);
8443 }
8444 break;
8445
8446 case WE_POLICY_MANAGER_DBS_CMD:
8447 {
8448 hdd_err("<iwpriv wlan0 pm_dbs> is called");
8449 if (apps_args[0] == 0)
8450 wma_set_dbs_capability_ut(0);
8451 else
8452 wma_set_dbs_capability_ut(1);
8453
8454 if (apps_args[1] >= CDS_THROUGHPUT &&
8455 apps_args[1] <= CDS_LATENCY) {
8456 pr_info("setting system pref to [%d]\n", apps_args[1]);
8457 hdd_ctx->config->conc_system_pref = apps_args[1];
8458 }
8459 }
8460 break;
8461
8462 case WE_POLICY_MANAGER_PCL_CMD:
8463 {
8464 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8465 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
8466 uint32_t pcl_len = 0, i = 0;
8467
8468 hdd_err("<iwpriv wlan0 pm_pcl> is called");
8469
8470 cds_get_pcl(apps_args[0],
8471 pcl, &pcl_len,
8472 weight_list, QDF_ARRAY_SIZE(weight_list));
8473 pr_info("PCL list for role[%d] is {", apps_args[0]);
8474 for (i = 0 ; i < pcl_len; i++)
8475 pr_info(" %d, ", pcl[i]);
8476 pr_info("}--------->\n");
8477 }
8478 break;
8479
8480 case WE_POLICY_SET_HW_MODE_CMD:
8481 {
8482 if (apps_args[0] == 0) {
8483 hdd_err("set hw mode for single mac");
8484 cds_pdev_set_hw_mode(
8485 adapter->sessionId,
8486 HW_MODE_SS_2x2,
8487 HW_MODE_80_MHZ,
8488 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8489 HW_MODE_DBS_NONE,
8490 HW_MODE_AGILE_DFS_NONE,
8491 HW_MODE_SBS_NONE,
8492 SIR_UPDATE_REASON_UT);
8493 } else if (apps_args[0] == 1) {
8494 hdd_err("set hw mode for dual mac");
8495 cds_pdev_set_hw_mode(
8496 adapter->sessionId,
8497 HW_MODE_SS_1x1,
8498 HW_MODE_80_MHZ,
8499 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8500 HW_MODE_DBS,
8501 HW_MODE_AGILE_DFS_NONE,
8502 HW_MODE_SBS_NONE,
8503 SIR_UPDATE_REASON_UT);
8504 }
8505 }
8506 break;
8507
8508 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8509 {
8510 enum cds_conc_next_action action;
8511 hdd_notice("<iwpriv wlan0 pm_query_action> is called");
8512 action = cds_current_connections_update(adapter->sessionId,
8513 apps_args[0],
8514 SIR_UPDATE_REASON_UT);
8515 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8516 }
8517 break;
8518
8519 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8520 {
8521 bool allow;
8522 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
8523 allow = cds_allow_concurrency(
8524 apps_args[0], apps_args[1], apps_args[2]);
8525 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8526 }
8527 break;
8528
8529 case WE_POLICY_MANAGER_SCENARIO_CMD:
8530 {
8531 clean_report(hdd_ctx);
8532 if (apps_args[0] == 1) {
8533 wlan_hdd_one_connection_scenario(hdd_ctx);
8534 } else if (apps_args[0] == 2) {
8535 wlan_hdd_two_connections_scenario(hdd_ctx,
8536 6, CDS_TWO_TWO);
8537 wlan_hdd_two_connections_scenario(hdd_ctx,
8538 36, CDS_TWO_TWO);
8539 wlan_hdd_two_connections_scenario(hdd_ctx,
8540 6, CDS_ONE_ONE);
8541 wlan_hdd_two_connections_scenario(hdd_ctx,
8542 36, CDS_ONE_ONE);
8543 } else if (apps_args[0] == 3) {
8544 /* MCC on same band with 2x2 same mac*/
8545 wlan_hdd_three_connections_scenario(hdd_ctx,
8546 6, 11, CDS_TWO_TWO, 0);
8547 /* MCC on diff band with 2x2 same mac*/
8548 wlan_hdd_three_connections_scenario(hdd_ctx,
8549 6, 36, CDS_TWO_TWO, 0);
8550 /* MCC on diff band with 1x1 diff mac */
8551 wlan_hdd_three_connections_scenario(hdd_ctx,
8552 36, 6, CDS_ONE_ONE, 0);
8553 /* MCC on diff band with 1x1 same mac */
8554 wlan_hdd_three_connections_scenario(hdd_ctx,
8555 36, 6, CDS_ONE_ONE, 1);
8556 /* SCC on same band with 2x2 same mac */
8557 wlan_hdd_three_connections_scenario(hdd_ctx,
8558 36, 36, CDS_TWO_TWO, 0);
8559 /* SCC on same band with 1x1 same mac */
8560 wlan_hdd_three_connections_scenario(hdd_ctx,
8561 36, 36, CDS_ONE_ONE, 1);
8562 /* MCC on same band with 2x2 same mac */
8563 wlan_hdd_three_connections_scenario(hdd_ctx,
8564 36, 149, CDS_TWO_TWO, 0);
8565 /* MCC on same band with 1x1 same mac */
8566 wlan_hdd_three_connections_scenario(hdd_ctx,
8567 36, 149, CDS_ONE_ONE, 1);
8568 }
8569 print_report(hdd_ctx);
8570 }
8571 break;
8572 }
8573 return 0;
8574}
8575#else
8576static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
8577 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
8578{
8579 return 0;
8580}
8581#endif
8582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008583/**
8584 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8585 * @dev: device upon which the ioctl was received
8586 * @info: ioctl request information
8587 * @wrqu: ioctl request data
8588 * @extra: ioctl extra data
8589 *
8590 * This is an SSR-protected generic handler for private ioctls which
8591 * take multiple arguments. Note that this implementation is also
8592 * somewhat unique in that it is shared by both STA-mode and SAP-mode
8593 * interfaces.
8594 *
8595 * Return: 0 on success, non-zero on error
8596 */
8597static int __iw_set_var_ints_getnone(struct net_device *dev,
8598 struct iw_request_info *info,
8599 union iwreq_data *wrqu, char *extra)
8600{
8601 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8602 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8603 int sub_cmd;
8604 int *apps_args = (int *) extra;
8605 hdd_context_t *hdd_ctx;
8606 int ret, num_args;
8607
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008608 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308609
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008610 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8611 ret = wlan_hdd_validate_context(hdd_ctx);
8612 if (0 != ret)
8613 return ret;
8614
8615 if (extra == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008616 hdd_err("NULL extra buffer pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008617 return -EINVAL;
8618 }
8619
8620 sub_cmd = wrqu->data.flags;
8621 num_args = wrqu->data.length;
8622
Jeff Johnson99bac312016-06-28 10:38:18 -07008623 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008624
8625 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008626 case WE_IBSS_GET_PEER_INFO:
8627 {
8628 pr_info("Station ID = %d\n", apps_args[0]);
8629 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
8630 }
8631 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008632
8633 case WE_P2P_NOA_CMD:
8634 {
8635 p2p_app_setP2pPs_t p2pNoA;
8636
Krunal Sonif07bb382016-03-10 13:02:11 -08008637 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08008638 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
8639 hdd_device_mode_to_string(
8640 pAdapter->device_mode),
8641 pAdapter->device_mode);
8642 return -EINVAL;
8643 }
8644
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008645 p2pNoA.opp_ps = apps_args[0];
8646 p2pNoA.ctWindow = apps_args[1];
8647 p2pNoA.duration = apps_args[2];
8648 p2pNoA.interval = apps_args[3];
8649 p2pNoA.count = apps_args[4];
8650 p2pNoA.single_noa_duration = apps_args[5];
8651 p2pNoA.psSelection = apps_args[6];
8652
Jeff Johnson99bac312016-06-28 10:38:18 -07008653 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
8654 apps_args[0], apps_args[1], apps_args[2],
8655 apps_args[3], apps_args[4],
8656 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008657
8658 hdd_set_p2p_ps(dev, &p2pNoA);
8659
8660 }
8661 break;
8662
8663 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8664 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008665 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
8666 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308667 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008668 }
8669 break;
8670
8671 case WE_MTRACE_DUMP_CMD:
8672 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008673 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
8674 apps_args[0], apps_args[1],
8675 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308676 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008677 apps_args[1], apps_args[2],
8678 apps_args[3]);
8679
8680 }
8681 break;
8682
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008683 case WE_POLICY_MANAGER_CINFO_CMD:
8684 {
8685 struct cds_conc_connection_info *conn_info;
8686 uint32_t i = 0, len = 0;
8687
Krunal Sonia6e505b2017-01-12 12:25:18 -08008688 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008689 conn_info = cds_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008690 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008691 for (i = 0; i < len; i++) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08008692 pr_info("|table_index[%d]\t\t\n", i);
8693 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
8694 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
8695 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
8696 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
8697 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
8698 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
8699 pr_info("+--------------------------+\n");
8700 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008701 }
8702 }
8703 break;
8704
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008705
8706#ifdef FEATURE_WLAN_TDLS
8707 case WE_TDLS_CONFIG_PARAMS:
8708 {
8709 tdls_config_params_t tdlsParams;
8710
8711 tdlsParams.tdls = apps_args[0];
8712 tdlsParams.tx_period_t = apps_args[1];
8713 tdlsParams.tx_packet_n = apps_args[2];
8714 /* ignore args[3] as discovery_period is not used anymore */
8715 tdlsParams.discovery_tries_n = apps_args[4];
8716 /* ignore args[5] as idle_timeout is not used anymore */
8717 tdlsParams.idle_packet_n = apps_args[6];
8718 /* ignore args[7] as rssi_hysteresis is not used anymore */
8719 tdlsParams.rssi_trigger_threshold = apps_args[8];
8720 tdlsParams.rssi_teardown_threshold = apps_args[9];
8721 tdlsParams.rssi_delta = apps_args[10];
8722
8723 wlan_hdd_tdls_set_params(dev, &tdlsParams);
8724 }
8725 break;
8726#endif
8727 case WE_UNIT_TEST_CMD:
8728 {
8729 t_wma_unit_test_cmd *unitTestArgs;
Rajeev Kumarea95edd2017-01-11 20:49:36 -08008730 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008731 int i, j;
8732 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8733 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008734 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008735 apps_args[0]);
8736 return -EINVAL;
8737 }
Anurag Chouhan77564182016-09-03 16:38:01 +05308738 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
8739 (apps_args[1] < 0)) {
8740 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008741 apps_args[1]);
8742 return -EINVAL;
8743 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308744 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008745 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008746 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008747 return -ENOMEM;
8748 }
8749 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
8750 unitTestArgs->module_id = apps_args[0];
8751 unitTestArgs->num_args = apps_args[1];
8752 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
8753 unitTestArgs->args[i] = apps_args[j];
8754 }
8755 msg.type = SIR_HAL_UNIT_TEST_CMD;
8756 msg.reserved = 0;
8757 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308758 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarea95edd2017-01-11 20:49:36 -08008759 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308760 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -07008761 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008762 return -EINVAL;
8763 }
8764 }
8765 break;
8766#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8767 case WE_LED_FLASHING_PARAM:
8768 {
8769 int i;
8770 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008771 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008772 return -EINVAL;
8773 }
8774 for (i = 0; i < num_args; i++) {
8775 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008776 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008777 return -EINVAL;
8778 }
8779 }
8780 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8781 0, apps_args[0], apps_args[1]);
8782 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8783 1, apps_args[2], apps_args[3]);
8784 }
8785 break;
8786#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05308787 case WE_SET_PKTLOG:
8788 {
8789 int ret;
8790
8791 if (num_args < 1 || num_args > 2) {
8792 hdd_err("pktlog: either 1 or 2 parameters are required");
8793 return -EINVAL;
8794 }
8795
8796 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
8797 apps_args[1]);
8798 if (ret)
8799 return ret;
8800 break;
8801 }
8802
Manjeet Singhf82ed072016-07-08 11:40:00 +05308803 case WE_MAC_PWR_DEBUG_CMD:
8804 {
8805 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
8806 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8807 int i, j;
8808
8809 if (num_args < 3) {
8810 hdd_err("number of arguments can't be null %d",
8811 num_args);
8812 return -EINVAL;
8813 }
8814 if (num_args - 3 != apps_args[2]) {
8815 hdd_err("arg list of size %d doesn't match num_args %d",
8816 num_args-3, apps_args[2]);
8817 return -EINVAL;
8818 }
8819 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8820 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8821 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8822 return -EINVAL;
8823 }
8824 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8825 hdd_err("Too Many args %d", apps_args[2]);
8826 return -EINVAL;
8827 }
8828 mac_pwr_dbg_args.pdev_id = apps_args[0];
8829 mac_pwr_dbg_args.module_id = apps_args[1];
8830 mac_pwr_dbg_args.num_args = apps_args[2];
8831
8832 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8833 mac_pwr_dbg_args.args[i] = apps_args[j];
8834
8835 if (QDF_STATUS_SUCCESS !=
8836 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
8837 &mac_pwr_dbg_args)) {
8838 return -EINVAL;
8839 }
8840 }
8841 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -08008842 case WE_POLICY_MANAGER_CLIST_CMD:
8843 case WE_POLICY_MANAGER_DLIST_CMD:
8844 case WE_POLICY_MANAGER_ULIST_CMD:
8845 case WE_POLICY_MANAGER_DBS_CMD:
8846 case WE_POLICY_MANAGER_PCL_CMD:
8847 case WE_POLICY_SET_HW_MODE_CMD:
8848 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8849 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8850 case WE_POLICY_MANAGER_SCENARIO_CMD:
8851 {
8852 iw_get_policy_manager_ut_ops(hdd_ctx, pAdapter,
8853 sub_cmd, apps_args);
8854 }
8855 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008856 default:
8857 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008858 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008859 }
8860 break;
8861 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308862 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008863 return 0;
8864}
8865
8866/**
8867 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8868 * @dev: pointer to net_device structure
8869 * @info: pointer to iw_request_info structure
8870 * @wrqu: pointer to iwreq_data
8871 * @extra; extra
8872 *
8873 * Return: 0 on success, error number otherwise
8874 *
8875 */
8876static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8877 struct iw_request_info *info,
8878 union iwreq_data *wrqu, char *extra)
8879{
8880 union iwreq_data u_priv_wrqu;
8881 int apps_args[MAX_VAR_ARGS] = {0};
8882 int ret, num_args;
8883
Mukul Sharma64a70e82015-11-02 20:05:09 +05308884 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008885 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308886 return -EPERM;
8887 }
8888
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008889 /* Helper function to get iwreq_data with compat handling. */
8890 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8891 return -EINVAL;
8892
8893 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008894 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008895 return -EINVAL;
8896 }
8897
8898 num_args = u_priv_wrqu.data.length;
8899 if (num_args > MAX_VAR_ARGS)
8900 num_args = MAX_VAR_ARGS;
8901
8902 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8903 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008904 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008905 return -EFAULT;
8906 }
8907
8908 cds_ssr_protect(__func__);
8909 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8910 (char *)&apps_args);
8911 cds_ssr_unprotect(__func__);
8912 return ret;
8913}
8914
8915/**
8916 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8917 * @dev: device upon which the ioctl was received
8918 * @info: ioctl request information
8919 * @wrqu: ioctl request data
8920 * @extra: ioctl extra data
8921 *
8922 * This is a generic handler for private ioctls which take multiple
8923 * arguments. Note that this implementation is also somewhat unique
8924 * in that it is shared by both STA-mode and SAP-mode interfaces.
8925 *
8926 * Return: 0 on success, non-zero on error
8927 */
8928int iw_set_var_ints_getnone(struct net_device *dev,
8929 struct iw_request_info *info,
8930 union iwreq_data *wrqu, char *extra)
8931{
8932 int ret;
8933
8934 cds_ssr_protect(__func__);
8935 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8936 cds_ssr_unprotect(__func__);
8937 return ret;
8938}
8939
8940/**
8941 * iw_add_tspec - Add TSpec private ioctl handler
8942 * @dev: device upon which the ioctl was received
8943 * @info: ioctl request information
8944 * @wrqu: ioctl request data
8945 * @extra: ioctl extra data
8946 *
8947 * Return: 0 on success, non-zero on error
8948 */
8949static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
8950 union iwreq_data *wrqu, char *extra)
8951{
8952 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8953 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8954 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8955 int params[HDD_WLAN_WMM_PARAM_COUNT];
8956 sme_QosWmmTspecInfo tSpec;
8957 uint32_t handle;
8958 struct iw_point s_priv_data;
8959 hdd_context_t *hdd_ctx;
8960 int ret;
8961
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008962 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308963
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008964 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8965 ret = wlan_hdd_validate_context(hdd_ctx);
8966 if (0 != ret)
8967 return ret;
8968
8969 /* make sure the application is sufficiently priviledged */
8970 /* note that the kernel will do this for "set" ioctls, but since */
8971 /* this ioctl wants to return status to user space it must be */
8972 /* defined as a "get" ioctl */
8973 if (!capable(CAP_NET_ADMIN)) {
8974 return -EPERM;
8975 }
8976
8977 /* we must be associated in order to add a tspec */
8978 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
8979 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8980 return 0;
8981 }
8982 /* since we are defined to be a "get" ioctl, and since the number */
8983 /* of params exceeds the number of params that wireless extensions */
8984 /* will pass down in the iwreq_data, we must copy the "set" params. */
8985 /* We must handle the compat for iwreq_data in 32U/64K environment. */
8986
8987 /* helper function to get iwreq_data with compat handling. */
8988 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8989 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8990 return 0;
8991 }
8992 /* make sure all params are correctly passed to function */
8993 if ((NULL == s_priv_data.pointer) ||
8994 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
8995 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8996 return 0;
8997 }
8998 /* from user space ourselves */
8999 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
9000 /* hmmm, can't get them */
9001 return -EIO;
9002 }
9003 /* clear the tspec */
9004 memset(&tSpec, 0, sizeof(tSpec));
9005
9006 /* validate the handle */
9007 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9008 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9009 /* that one is reserved */
9010 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9011 return 0;
9012 }
9013 /* validate the TID */
9014 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
9015 /* out of range */
9016 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9017 return 0;
9018 }
9019 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
9020
9021 /* validate the direction */
9022 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
9023 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
9024 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
9025 break;
9026
9027 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
9028 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
9029 break;
9030
9031 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
9032 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
9033 break;
9034
9035 default:
9036 /* unknown */
9037 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9038 return 0;
9039 }
9040
9041 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
9042
9043 /* validate the user priority */
9044 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
9045 /* out of range */
9046 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9047 return 0;
9048 }
9049 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
9050 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009051 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009052 return 0;
9053 }
9054
Jeff Johnson99bac312016-06-28 10:38:18 -07009055 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009056 tSpec.ts_info.psb, tSpec.ts_info.up);
9057
9058 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
9059 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
9060 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
9061 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
9062 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
9063 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
9064 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
9065 tSpec.surplus_bw_allowance =
9066 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
9067 tSpec.min_service_interval =
9068 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
9069 tSpec.max_service_interval =
9070 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
9071 tSpec.suspension_interval =
9072 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
9073 tSpec.inactivity_interval =
9074 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
9075
9076 tSpec.ts_info.burst_size_defn =
9077 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
9078
9079 /* validate the ts info ack policy */
9080 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
9081 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
9082 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
9083 break;
9084
9085 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
9086 tSpec.ts_info.ack_policy =
9087 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
9088 break;
9089
9090 default:
9091 /* unknown */
9092 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9093 return 0;
9094 }
9095
9096 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309097 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009098 return 0;
9099}
9100
9101static int iw_add_tspec(struct net_device *dev,
9102 struct iw_request_info *info,
9103 union iwreq_data *wrqu, char *extra)
9104{
9105 int ret;
9106
9107 cds_ssr_protect(__func__);
9108 ret = __iw_add_tspec(dev, info, wrqu, extra);
9109 cds_ssr_unprotect(__func__);
9110
9111 return ret;
9112}
9113
9114/**
9115 * iw_del_tspec - Delete TSpec private ioctl handler
9116 * @dev: device upon which the ioctl was received
9117 * @info: ioctl request information
9118 * @wrqu: ioctl request data
9119 * @extra: ioctl extra data
9120 *
9121 * Return: 0 on success, non-zero on error
9122 */
9123static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
9124 union iwreq_data *wrqu, char *extra)
9125{
9126 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9127 hdd_context_t *hdd_ctx;
9128 int *params = (int *)extra;
9129 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9130 uint32_t handle;
9131 int ret;
9132
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009133 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309134
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009135 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9136 ret = wlan_hdd_validate_context(hdd_ctx);
9137 if (0 != ret)
9138 return ret;
9139
9140 /* make sure the application is sufficiently priviledged */
9141 /* note that the kernel will do this for "set" ioctls, but since */
9142 /* this ioctl wants to return status to user space it must be */
9143 /* defined as a "get" ioctl */
9144 if (!capable(CAP_NET_ADMIN)) {
9145 return -EPERM;
9146 }
9147
9148 /* although we are defined to be a "get" ioctl, the params we require */
9149 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9150 /* is no need to copy the params from user space */
9151
9152 /* validate the handle */
9153 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9154 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9155 /* that one is reserved */
9156 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9157 return 0;
9158 }
9159
9160 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309161 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009162 return 0;
9163}
9164
9165static int iw_del_tspec(struct net_device *dev,
9166 struct iw_request_info *info,
9167 union iwreq_data *wrqu, char *extra)
9168{
9169 int ret;
9170
9171 cds_ssr_protect(__func__);
9172 ret = __iw_del_tspec(dev, info, wrqu, extra);
9173 cds_ssr_unprotect(__func__);
9174
9175 return ret;
9176}
9177
9178/**
9179 * iw_get_tspec - Get TSpec private ioctl handler
9180 * @dev: device upon which the ioctl was received
9181 * @info: ioctl request information
9182 * @wrqu: ioctl request data
9183 * @extra: ioctl extra data
9184 *
9185 * Return: 0 on success, non-zero on error
9186 */
9187static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
9188 union iwreq_data *wrqu, char *extra)
9189{
9190 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9191 hdd_context_t *hdd_ctx;
9192 int *params = (int *)extra;
9193 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9194 uint32_t handle;
9195 int ret;
9196
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009197 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309198
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009199 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9200 ret = wlan_hdd_validate_context(hdd_ctx);
9201 if (0 != ret)
9202 return ret;
9203
9204 /* although we are defined to be a "get" ioctl, the params we require */
9205 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9206 /* is no need to copy the params from user space */
9207
9208 /* validate the handle */
9209 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9210 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9211 /* that one is reserved */
9212 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9213 return 0;
9214 }
9215
9216 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309217 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009218 return 0;
9219}
9220
9221static int iw_get_tspec(struct net_device *dev,
9222 struct iw_request_info *info,
9223 union iwreq_data *wrqu, char *extra)
9224{
9225 int ret;
9226
9227 cds_ssr_protect(__func__);
9228 ret = __iw_get_tspec(dev, info, wrqu, extra);
9229 cds_ssr_unprotect(__func__);
9230
9231 return ret;
9232}
9233
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009234/**
9235 * iw_set_fties - Set FT IEs private ioctl handler
9236 * @dev: device upon which the ioctl was received
9237 * @info: ioctl request information
9238 * @wrqu: ioctl request data
9239 * @extra: ioctl extra data
9240 *
9241 * Each time the supplicant has the auth_request or reassoc request
9242 * IEs ready they are pushed to the driver. The driver will in turn
9243 * use it to send out the auth req and reassoc req for 11r FT Assoc.
9244 *
9245 * Return: 0 on success, non-zero on error
9246 */
9247static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
9248 union iwreq_data *wrqu, char *extra)
9249{
9250 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9251 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9252 hdd_context_t *hdd_ctx;
9253 int ret;
9254
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009255 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309256
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009257 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9258 ret = wlan_hdd_validate_context(hdd_ctx);
9259 if (0 != ret)
9260 return ret;
9261
9262 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009263 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009264 return -EINVAL;
9265 }
9266 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009267 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009268 return -EINVAL;
9269 }
9270 /* Added for debug on reception of Re-assoc Req. */
9271 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009272 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009273 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -07009274 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009275 }
Jeff Johnson99bac312016-06-28 10:38:18 -07009276 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009277
9278 /* Pass the received FT IEs to SME */
9279 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
9280 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309281 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009282 return 0;
9283}
9284
9285static int iw_set_fties(struct net_device *dev,
9286 struct iw_request_info *info,
9287 union iwreq_data *wrqu, char *extra)
9288{
9289 int ret;
9290
9291 cds_ssr_protect(__func__);
9292 ret = __iw_set_fties(dev, info, wrqu, extra);
9293 cds_ssr_unprotect(__func__);
9294
9295 return ret;
9296}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009297
Dustin Brown0cbc7572016-12-16 13:54:40 -08009298/**
9299 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
9300 * @dev: device upon which the ioctl was received
9301 * @info: ioctl request information
9302 * @wrqu: ioctl request data
9303 * @extra: ioctl extra data
9304 *
Dustin Brown860566f2017-01-31 15:24:43 -08009305 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
9306 * time being to provide guidance in migrating to standard APIs.
9307 *
Dustin Brown0cbc7572016-12-16 13:54:40 -08009308 * Return: 0 on success, non-zero on error
9309 */
9310static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
9311 struct iw_request_info *info,
9312 union iwreq_data *wrqu,
9313 char *extra)
9314{
Dustin Brown860566f2017-01-31 15:24:43 -08009315 hdd_err("\n"
9316 "setMCBCFilter is obsolete. Use the following instead:\n"
9317 "Configure multicast filtering via the ‘ip’ command.\n"
9318 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
9319 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
9320 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
9321 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
9322 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Dustin Brown0cbc7572016-12-16 13:54:40 -08009323
Dustin Brown860566f2017-01-31 15:24:43 -08009324 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -08009325}
9326
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009327/**
9328 * iw_set_host_offload - Set host offload ioctl handler
9329 * @dev: device upon which the ioctl was received
9330 * @info: ioctl request information
9331 * @wrqu: ioctl request data
9332 * @extra: ioctl extra data
9333 *
9334 * Return: 0 on success, non-zero on error
9335 */
9336static int __iw_set_host_offload(struct net_device *dev,
9337 struct iw_request_info *info,
9338 union iwreq_data *wrqu, char *extra)
9339{
9340 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9341 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
9342 tSirHostOffloadReq offloadRequest;
9343 hdd_context_t *hdd_ctx;
9344 int ret;
9345
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009346 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309347
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009348 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9349 ret = wlan_hdd_validate_context(hdd_ctx);
9350 if (0 != ret)
9351 return ret;
9352
9353 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009354 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009355 return -EINVAL;
9356 }
9357
9358 /* Debug display of request components. */
9359 switch (pRequest->offloadType) {
9360 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07009361 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009362 switch (pRequest->enableOrDisable) {
9363 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009364 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009365 break;
9366 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009367 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009368 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009369 hdd_warn(" ARP offload enable");
9370 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009371 pRequest->params.hostIpv4Addr[0],
9372 pRequest->params.hostIpv4Addr[1],
9373 pRequest->params.hostIpv4Addr[2],
9374 pRequest->params.hostIpv4Addr[3]);
9375 }
9376 break;
9377
9378 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07009379 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009380 switch (pRequest->enableOrDisable) {
9381 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009382 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009383 break;
9384 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009385 hdd_info(" enable");
9386 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009387 *(uint16_t *) (pRequest->params.hostIpv6Addr),
9388 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9389 2),
9390 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9391 4),
9392 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9393 6),
9394 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9395 8),
9396 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9397 10),
9398 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9399 12),
9400 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9401 14));
9402 }
9403 }
9404
9405 /* Execute offload request. The reason that we can copy the
9406 * request information from the ioctl structure to the SME
9407 * structure is that they are laid out exactly the same.
9408 * Otherwise, each piece of information would have to be
9409 * copied individually.
9410 */
9411 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309412 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009413 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
9414 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009415 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009416 return -EINVAL;
9417 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309418 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009419 return 0;
9420}
9421
9422static int iw_set_host_offload(struct net_device *dev,
9423 struct iw_request_info *info,
9424 union iwreq_data *wrqu, char *extra)
9425{
9426 int ret;
9427
9428 cds_ssr_protect(__func__);
9429 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9430 cds_ssr_unprotect(__func__);
9431
9432 return ret;
9433}
9434
9435/**
9436 * iw_set_keepalive_params - Set keepalive params ioctl handler
9437 * @dev: device upon which the ioctl was received
9438 * @info: ioctl request information
9439 * @wrqu: ioctl request data
9440 * @extra: ioctl extra data
9441 *
9442 * Return: 0 on success, non-zero on error
9443 */
9444static int __iw_set_keepalive_params(struct net_device *dev,
9445 struct iw_request_info *info,
9446 union iwreq_data *wrqu, char *extra)
9447{
9448 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009449 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009450 hdd_context_t *hdd_ctx;
9451 int ret;
9452
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009453 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309454
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009455 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9456 ret = wlan_hdd_validate_context(hdd_ctx);
9457 if (0 != ret)
9458 return ret;
9459
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009460 if (wrqu->data.length != sizeof(*request)) {
9461 hdd_err("Invalid length %d", wrqu->data.length);
9462 return -EINVAL;
9463 }
9464
9465 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
9466 hdd_err("Value of timePeriod %d exceed Max limit %d",
9467 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009468 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
9469 return -EINVAL;
9470 }
9471
9472 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009473 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
9474 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009475
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009476 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009477 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009478 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009479 break;
9480
9481 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009482 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009483
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009484 hdd_info("Host IP address: %d.%d.%d.%d",
9485 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
9486 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009487
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009488 hdd_info("Dest IP address: %d.%d.%d.%d",
9489 request->destIpv4Addr[0], request->destIpv4Addr[1],
9490 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009491
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08009492 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
9493 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009494 break;
9495 }
9496
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009497 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009498
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309499 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009500 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009501 pAdapter->sessionId, request)) {
9502 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009503 return -EINVAL;
9504 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309505 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009506 return 0;
9507}
9508
9509static int iw_set_keepalive_params(struct net_device *dev,
9510 struct iw_request_info *info,
9511 union iwreq_data *wrqu,
9512 char *extra)
9513{
9514 int ret;
9515
9516 cds_ssr_protect(__func__);
9517 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9518 cds_ssr_unprotect(__func__);
9519
9520 return ret;
9521}
9522
9523#ifdef WLAN_FEATURE_PACKET_FILTERING
9524/**
9525 * wlan_hdd_set_filter() - Set packet filter
9526 * @hdd_ctx: Global HDD context
9527 * @request: Packet filter request struct
9528 * @sessionId: Target session for the request
9529 *
9530 * Return: 0 on success, non-zero on error
9531 */
9532static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
9533 struct pkt_filter_cfg *request,
9534 uint8_t sessionId)
9535{
9536 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9537 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9538 int i = 0;
9539
9540 if (hdd_ctx->config->disablePacketFilter) {
9541 hdd_err("packet filtering disabled in ini returning");
9542 return 0;
9543 }
9544
9545 /* Debug display of request components. */
9546 hdd_info("Packet Filter Request : FA %d params %d",
9547 request->filter_action, request->num_params);
9548
9549 switch (request->filter_action) {
9550 case HDD_RCV_FILTER_SET:
9551 hdd_info("Set Packet Filter Request for Id: %d",
9552 request->filter_id);
9553
9554 packetFilterSetReq.filterId = request->filter_id;
9555 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
9556 hdd_err("Number of Params exceed Max limit %d",
9557 request->num_params);
9558 return -EINVAL;
9559 }
9560 packetFilterSetReq.numFieldParams = request->num_params;
9561 packetFilterSetReq.coalesceTime = 0;
9562 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9563 for (i = 0; i < request->num_params; i++) {
9564 packetFilterSetReq.paramsData[i].protocolLayer =
9565 request->params_data[i].protocol_layer;
9566 packetFilterSetReq.paramsData[i].cmpFlag =
9567 request->params_data[i].compare_flag;
9568 packetFilterSetReq.paramsData[i].dataOffset =
9569 request->params_data[i].data_offset;
9570 packetFilterSetReq.paramsData[i].dataLength =
9571 request->params_data[i].data_length;
9572 packetFilterSetReq.paramsData[i].reserved = 0;
9573
Dustin Brown4d1e8462016-12-14 12:12:24 -08009574 if (request->params_data[i].data_offset >
9575 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
9576 hdd_err("Invalid data offset %u for param %d (max = %d)",
9577 request->params_data[i].data_offset,
9578 i,
9579 SIR_MAX_FILTER_TEST_DATA_OFFSET);
9580 return -EINVAL;
9581 }
9582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009583 if (request->params_data[i].data_length >
9584 SIR_MAX_FILTER_TEST_DATA_LEN) {
9585 hdd_err("Error invalid data length %d",
9586 request->params_data[i].data_length);
9587 return -EINVAL;
9588 }
9589
9590 hdd_info("Proto %d Comp Flag %d Filter Type %d",
9591 request->params_data[i].protocol_layer,
9592 request->params_data[i].compare_flag,
9593 packetFilterSetReq.filterType);
9594
9595 hdd_info("Data Offset %d Data Len %d",
9596 request->params_data[i].data_offset,
9597 request->params_data[i].data_length);
9598
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07009599 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
9600 < (request->params_data[i].data_length)) {
9601 hdd_err("Error invalid data length %d",
9602 request->params_data[i].data_length);
9603 return -EINVAL;
9604 }
9605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009606 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9607 request->params_data[i].compare_data,
9608 request->params_data[i].data_length);
9609 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9610 request->params_data[i].data_mask,
9611 request->params_data[i].data_length);
9612
9613 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
9614 request->params_data[i].compare_data[0],
9615 request->params_data[i].compare_data[1],
9616 request->params_data[i].compare_data[2],
9617 request->params_data[i].compare_data[3],
9618 request->params_data[i].compare_data[4],
9619 request->params_data[i].compare_data[5]);
9620
9621 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
9622 request->params_data[i].data_mask[0],
9623 request->params_data[i].data_mask[1],
9624 request->params_data[i].data_mask[2],
9625 request->params_data[i].data_mask[3],
9626 request->params_data[i].data_mask[4],
9627 request->params_data[i].data_mask[5]);
9628 }
9629
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309630 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009631 sme_receive_filter_set_filter(hdd_ctx->hHal,
9632 &packetFilterSetReq,
9633 sessionId)) {
9634 hdd_err("Failure to execute Set Filter");
9635 return -EINVAL;
9636 }
9637
9638 break;
9639
9640 case HDD_RCV_FILTER_CLEAR:
9641
9642 hdd_info("Clear Packet Filter Request for Id: %d",
9643 request->filter_id);
9644 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309645 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009646 sme_receive_filter_clear_filter(hdd_ctx->hHal,
9647 &packetFilterClrReq,
9648 sessionId)) {
9649 hdd_err("Failure to execute Clear Filter");
9650 return -EINVAL;
9651 }
9652 break;
9653
9654 default:
9655 hdd_err("Packet Filter Request: Invalid %d",
9656 request->filter_action);
9657 return -EINVAL;
9658 }
9659 return 0;
9660}
9661
9662/**
9663 * __iw_set_packet_filter_params() - set packet filter parameters in target
9664 * @dev: Pointer to netdev
9665 * @info: Pointer to iw request info
9666 * @wrqu: Pointer to data
9667 * @extra: Pointer to extra data
9668 *
9669 * Return: 0 on success, non-zero on error
9670 */
9671static int __iw_set_packet_filter_params(struct net_device *dev,
9672 struct iw_request_info *info,
9673 union iwreq_data *wrqu, char *extra)
9674{
9675 int ret;
9676 hdd_context_t *hdd_ctx;
9677 struct iw_point priv_data;
9678 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9679 struct pkt_filter_cfg *request = NULL;
9680
Mukul Sharma472382f2015-11-02 20:16:31 +05309681 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009682 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309683 return -EPERM;
9684 }
9685
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009686 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009688 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9689 ret = wlan_hdd_validate_context(hdd_ctx);
9690 if (0 != ret)
9691 return ret;
9692
9693 if (hdd_priv_get_data(&priv_data, wrqu)) {
9694 hdd_err("failed to get priv data");
9695 return -EINVAL;
9696 }
9697
9698 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
9699 hdd_err("invalid priv data %p or invalid priv data length %d",
9700 priv_data.pointer, priv_data.length);
9701 return -EINVAL;
9702 }
9703
9704 /* copy data using copy_from_user */
9705 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9706 priv_data.length);
9707 if (NULL == request) {
9708 hdd_err("mem_alloc_copy_from_user_helper fail");
9709 return -ENOMEM;
9710 }
9711
9712 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
9713
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07009714 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309715 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009716 return ret;
9717}
9718
9719/**
9720 * iw_set_packet_filter_params() - set packet filter parameters in target
9721 * @dev: Pointer to netdev
9722 * @info: Pointer to iw request info
9723 * @wrqu: Pointer to data
9724 * @extra: Pointer to extra data
9725 *
9726 * Return: 0 on success, non-zero on error
9727 */
9728static int iw_set_packet_filter_params(struct net_device *dev,
9729 struct iw_request_info *info,
9730 union iwreq_data *wrqu, char *extra)
9731{
9732 int ret;
9733
9734 cds_ssr_protect(__func__);
9735 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9736 cds_ssr_unprotect(__func__);
9737
9738 return ret;
9739}
9740#endif
9741
9742
9743static int __iw_get_statistics(struct net_device *dev,
9744 struct iw_request_info *info,
9745 union iwreq_data *wrqu, char *extra)
9746{
9747
Anurag Chouhance0dc992016-02-16 18:18:03 +05309748 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309749 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009750 hdd_wext_state_t *pWextState;
9751 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9752 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9753 char *p = extra;
9754 int tlen = 0;
9755 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
9756 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
9757 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
9758 int ret;
9759
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009760 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009761
9762 ret = wlan_hdd_validate_context(hdd_ctx);
9763 if (0 != ret)
9764 return ret;
9765
9766 if (eConnectionState_Associated !=
9767 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9768
9769 wrqu->txpower.value = 0;
9770 } else {
9771 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9772 SME_SUMMARY_STATS |
9773 SME_GLOBAL_CLASSA_STATS |
9774 SME_GLOBAL_CLASSB_STATS |
9775 SME_GLOBAL_CLASSC_STATS |
9776 SME_GLOBAL_CLASSD_STATS |
9777 SME_PER_STA_STATS,
9778 hdd_statistics_cb, 0, false,
9779 (WLAN_HDD_GET_STATION_CTX_PTR
9780 (pAdapter))->conn_info.staId[0],
9781 pAdapter, pAdapter->sessionId);
9782
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309783 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009784 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009785 return -EINVAL;
9786 }
9787
9788 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9789
Anurag Chouhance0dc992016-02-16 18:18:03 +05309790 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05309791 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009792 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +05309793 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009794 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009795 /*Remove the SME statistics list by passing NULL in callback argument */
9796 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9797 SME_SUMMARY_STATS |
9798 SME_GLOBAL_CLASSA_STATS |
9799 SME_GLOBAL_CLASSB_STATS |
9800 SME_GLOBAL_CLASSC_STATS |
9801 SME_GLOBAL_CLASSD_STATS |
9802 SME_PER_STA_STATS,
9803 NULL, 0, false,
9804 (WLAN_HDD_GET_STATION_CTX_PTR
9805 (pAdapter))->conn_info.
9806 staId[0], pAdapter,
9807 pAdapter->sessionId);
9808
9809 return -EINVAL;
9810 }
9811 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
9812 (uint8_t) sizeof(pStats->retry_cnt),
9813 (char *)&(pStats->retry_cnt[0]), tlen);
9814
9815 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
9816 (uint8_t) sizeof(pStats->multiple_retry_cnt),
9817 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
9818
9819 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
9820 (uint8_t) sizeof(pStats->tx_frm_cnt),
9821 (char *)&(pStats->tx_frm_cnt[0]), tlen);
9822
9823 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
9824 (uint8_t) sizeof(pStats->rx_frm_cnt),
9825 (char *)&(pStats->rx_frm_cnt), tlen);
9826
9827 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
9828 (uint8_t) sizeof(pStats->frm_dup_cnt),
9829 (char *)&(pStats->frm_dup_cnt), tlen);
9830
9831 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
9832 (uint8_t) sizeof(pStats->fail_cnt),
9833 (char *)&(pStats->fail_cnt[0]), tlen);
9834
9835 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
9836 (uint8_t) sizeof(pStats->rts_fail_cnt),
9837 (char *)&(pStats->rts_fail_cnt), tlen);
9838
9839 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
9840 (uint8_t) sizeof(pStats->ack_fail_cnt),
9841 (char *)&(pStats->ack_fail_cnt), tlen);
9842
9843 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
9844 (uint8_t) sizeof(pStats->rts_succ_cnt),
9845 (char *)&(pStats->rts_succ_cnt), tlen);
9846
9847 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
9848 (uint8_t) sizeof(pStats->rx_discard_cnt),
9849 (char *)&(pStats->rx_discard_cnt), tlen);
9850
9851 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
9852 (uint8_t) sizeof(pStats->rx_error_cnt),
9853 (char *)&(pStats->rx_error_cnt), tlen);
9854
9855 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
9856 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9857 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9858
9859 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
9860 (uint8_t) sizeof(dStats->rx_byte_cnt),
9861 (char *)&(dStats->rx_byte_cnt), tlen);
9862
9863 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
9864 (uint8_t) sizeof(dStats->rx_rate),
9865 (char *)&(dStats->rx_rate), tlen);
9866
9867 /* Transmit rate, in units of 500 kbit/sec */
9868 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
9869 (uint8_t) sizeof(aStats->tx_rate),
9870 (char *)&(aStats->tx_rate), tlen);
9871
9872 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
9873 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
9874 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
9875 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
9876 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
9877 (char *)&(dStats->rx_mc_byte_cnt), tlen);
9878 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
9879 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
9880 (char *)&(dStats->rx_bc_byte_cnt), tlen);
9881 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
9882 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9883 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9884 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
9885 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
9886 (char *)&(dStats->tx_mc_byte_cnt), tlen);
9887 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
9888 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
9889 (char *)&(dStats->tx_bc_byte_cnt), tlen);
9890
9891 wrqu->data.length = tlen;
9892
9893 }
9894
9895 EXIT();
9896
9897 return 0;
9898}
9899
9900static int iw_get_statistics(struct net_device *dev,
9901 struct iw_request_info *info,
9902 union iwreq_data *wrqu, char *extra)
9903{
9904 int ret;
9905
9906 cds_ssr_protect(__func__);
9907 ret = __iw_get_statistics(dev, info, wrqu, extra);
9908 cds_ssr_unprotect(__func__);
9909
9910 return ret;
9911}
9912
9913#ifdef FEATURE_WLAN_SCAN_PNO
9914
9915/*Max Len for PNO notification*/
9916#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07009917static void found_pref_network_cb(void *callbackContext,
9918 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009919{
9920 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
9921 union iwreq_data wrqu;
9922 char buf[MAX_PNO_NOTIFY_LEN + 1];
9923
Jeff Johnson99bac312016-06-28 10:38:18 -07009924 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009925 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9926
9927 /* create the event */
9928 memset(&wrqu, 0, sizeof(wrqu));
9929 memset(buf, 0, sizeof(buf));
9930
9931 snprintf(buf, MAX_PNO_NOTIFY_LEN,
9932 "QCOM: Found preferred network: %s with RSSI of -%u",
9933 pPrefNetworkFoundInd->ssId.ssId,
9934 (unsigned int)pPrefNetworkFoundInd->rssi);
9935
9936 wrqu.data.pointer = buf;
9937 wrqu.data.length = strlen(buf);
9938
9939 /* send the event */
9940
9941 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9942
9943}
9944
9945/**
9946 * __iw_set_pno() - Preferred Network Offload ioctl handler
9947 * @dev: device upon which the ioctl was received
9948 * @info: ioctl request information
9949 * @wrqu: ioctl request data
9950 * @extra: ioctl extra data
9951 *
9952 * This function parses a Preferred Network Offload command
9953 * Input is string based and expected to be of the form:
9954 *
9955 * <enable(1) | disable(0)>
9956 * when enabling:
9957 * <number of networks>
9958 * for each network:
9959 * <ssid_len> <ssid> <authentication> <encryption>
9960 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -07009961 * <scan_time (seconds)>
9962 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009963 * <suspend mode>
9964 *
9965 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -07009966 * 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 -08009967 *
9968 * this translates into:
9969 * -----------------------------
9970 * enable PNO
9971 * 2 networks
9972 * Network 1:
9973 * test - with authentication type 0 and encryption type 0,
9974 * search on 3 channels: 1 6 and 11,
9975 * SSID bcast type is unknown (directed probe will be sent if
9976 * AP not found) and must meet -40dBm RSSI
9977 * Network 2:
9978 * test2 - with authentication type 4 and encryption type 4,
9979 * search on 6 channels 1, 2, 3, 4, 5 and 6
9980 * bcast type is non-bcast (directed probe will be sent)
9981 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009982 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -07009983 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009984 */
9985static int __iw_set_pno(struct net_device *dev,
9986 struct iw_request_info *info,
9987 union iwreq_data *wrqu, char *extra)
9988{
9989 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9990 hdd_context_t *hdd_ctx;
9991 int ret;
9992 int offset;
9993 char *ptr;
9994 uint8_t i, j, params, mode;
9995
9996 /* request is a large struct, so we make it static to avoid
9997 * stack overflow. This API is only invoked via ioctl, so it
9998 * is serialized by the kernel rtnl_lock and hence does not
9999 * need to be reentrant
10000 */
10001 static tSirPNOScanReq request;
10002
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010003 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010004
10005 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10006 ret = wlan_hdd_validate_context(hdd_ctx);
10007 if (ret)
10008 return ret;
10009
10010 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
10011
10012 request.enable = 0;
10013 request.ucNetworksCount = 0;
10014
10015 ptr = extra;
10016
10017 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
10018 hdd_err("PNO enable input is not valid %s", ptr);
10019 return -EINVAL;
10020 }
10021
10022 if (0 == request.enable) {
10023 /* Disable PNO, ignore any other params */
10024 memset(&request, 0, sizeof(request));
10025 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
10026 &request, adapter->sessionId,
10027 found_pref_network_cb, adapter);
10028 return 0;
10029 }
10030
10031 ptr += offset;
10032
10033 if (1 !=
10034 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
10035 hdd_err("PNO count input not valid %s", ptr);
10036 return -EINVAL;
10037
10038 }
10039
10040 hdd_info("PNO enable %d networks count %d offset %d",
10041 request.enable, request.ucNetworksCount, offset);
10042
10043 if ((0 == request.ucNetworksCount) ||
10044 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
10045 hdd_err("Network count %d invalid",
10046 request.ucNetworksCount);
10047 return -EINVAL;
10048 }
10049
10050 ptr += offset;
10051
10052 for (i = 0; i < request.ucNetworksCount; i++) {
10053
10054 request.aNetworks[i].ssId.length = 0;
10055
10056 params = sscanf(ptr, "%hhu %n",
10057 &(request.aNetworks[i].ssId.length),
10058 &offset);
10059
10060 if (1 != params) {
10061 hdd_err("PNO ssid length input is not valid %s", ptr);
10062 return -EINVAL;
10063 }
10064
10065 if ((0 == request.aNetworks[i].ssId.length) ||
10066 (request.aNetworks[i].ssId.length > 32)) {
10067 hdd_err("SSID Len %d is not correct for network %d",
10068 request.aNetworks[i].ssId.length, i);
10069 return -EINVAL;
10070 }
10071
10072 /* Advance to SSID */
10073 ptr += offset;
10074
10075 memcpy(request.aNetworks[i].ssId.ssId, ptr,
10076 request.aNetworks[i].ssId.length);
10077 ptr += request.aNetworks[i].ssId.length;
10078
10079 params = sscanf(ptr, "%u %u %hhu %n",
10080 &(request.aNetworks[i].authentication),
10081 &(request.aNetworks[i].encryption),
10082 &(request.aNetworks[i].ucChannelCount),
10083 &offset);
10084
10085 if (3 != params) {
10086 hdd_warn("Incorrect cmd %s", ptr);
10087 return -EINVAL;
10088 }
10089
10090 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
10091 request.aNetworks[i].ssId.length,
10092 request.aNetworks[i].ssId.length,
10093 request.aNetworks[i].ssId.ssId,
10094 request.aNetworks[i].authentication,
10095 request.aNetworks[i].encryption,
10096 request.aNetworks[i].ucChannelCount, offset);
10097
10098 /* Advance to channel list */
10099 ptr += offset;
10100
10101 if (SIR_PNO_MAX_NETW_CHANNELS <
10102 request.aNetworks[i].ucChannelCount) {
10103 hdd_warn("Incorrect number of channels");
10104 return -EINVAL;
10105 }
10106
10107 if (0 != request.aNetworks[i].ucChannelCount) {
10108 for (j = 0; j < request.aNetworks[i].ucChannelCount;
10109 j++) {
10110 if (1 !=
10111 sscanf(ptr, "%hhu %n",
10112 &(request.aNetworks[i].
10113 aChannels[j]), &offset)) {
10114 hdd_err("PNO network channel input is not valid %s",
10115 ptr);
10116 return -EINVAL;
10117 }
10118 /* Advance to next channel number */
10119 ptr += offset;
10120 }
10121 }
10122
10123 if (1 != sscanf(ptr, "%u %n",
10124 &(request.aNetworks[i].bcastNetwType),
10125 &offset)) {
10126 hdd_err("PNO broadcast network type input is not valid %s",
10127 ptr);
10128 return -EINVAL;
10129 }
10130
10131 hdd_notice("PNO bcastNetwType %d offset %d",
10132 request.aNetworks[i].bcastNetwType, offset);
10133
10134 /* Advance to rssi Threshold */
10135 ptr += offset;
10136 if (1 != sscanf(ptr, "%d %n",
10137 &(request.aNetworks[i].rssiThreshold),
10138 &offset)) {
10139 hdd_err("PNO rssi threshold input is not valid %s",
10140 ptr);
10141 return -EINVAL;
10142 }
10143 hdd_notice("PNO rssi %d offset %d",
10144 request.aNetworks[i].rssiThreshold, offset);
10145 /* Advance to next network */
10146 ptr += offset;
10147 } /* For ucNetworkCount */
10148
Dustin Brown43e87292016-10-10 10:38:25 -070010149 request.fast_scan_period = 0;
10150 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
10151 request.fast_scan_period *= MSEC_PER_SEC;
10152 ptr += offset;
10153 }
10154
10155 request.fast_scan_max_cycles = 0;
10156 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
10157 &offset) > 0)
10158 ptr += offset;
10159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010160 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
10161
10162 request.modePNO = mode;
10163 /* for LA we just expose suspend option */
10164 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
10165 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10166 }
10167
10168 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
10169 &request,
10170 adapter->sessionId,
10171 found_pref_network_cb, adapter);
10172
10173 return 0;
10174}
10175
10176static int iw_set_pno(struct net_device *dev,
10177 struct iw_request_info *info,
10178 union iwreq_data *wrqu, char *extra)
10179{
10180 int ret;
10181
10182 cds_ssr_protect(__func__);
10183 ret = __iw_set_pno(dev, info, wrqu, extra);
10184 cds_ssr_unprotect(__func__);
10185
10186 return ret;
10187}
10188#endif /* FEATURE_WLAN_SCAN_PNO */
10189
10190/* Common function to SetBand */
10191int hdd_set_band(struct net_device *dev, u8 ui_band)
10192{
10193 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10194 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10195 eCsrBand band;
10196
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010197 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010198 hdd_context_t *pHddCtx;
10199 hdd_adapter_list_node_t *pAdapterNode, *pNext;
10200 eCsrBand currBand = eCSR_BAND_MAX;
10201 eCsrBand connectedBand;
10202
10203 pAdapterNode = NULL;
10204 pNext = NULL;
10205 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10206
10207 switch (ui_band) {
10208 case WLAN_HDD_UI_BAND_AUTO:
10209 band = eCSR_BAND_ALL;
10210 break;
10211 case WLAN_HDD_UI_BAND_5_GHZ:
10212 band = eCSR_BAND_5G;
10213 break;
10214 case WLAN_HDD_UI_BAND_2_4_GHZ:
10215 band = eCSR_BAND_24;
10216 break;
10217 default:
10218 band = eCSR_BAND_MAX;
10219 }
10220
Jeff Johnson99bac312016-06-28 10:38:18 -070010221 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010222
10223 if (band == eCSR_BAND_MAX) {
10224 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -070010225 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010226 return -EINVAL;
10227 }
10228
10229 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
10230 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010231 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010232 band, pHddCtx->config->nBandCapability);
10233 return -EIO;
10234 }
10235
10236 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010237 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010238 pHddCtx->config->nBandCapability);
10239 band = pHddCtx->config->nBandCapability;
10240 }
10241
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010242 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010243 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010244 return -EIO;
10245 }
10246
10247 if (currBand != band) {
10248 /* Change band request received.
10249 * Abort pending scan requests, flush the existing scan results,
10250 * and change the band capability
10251 */
Jeff Johnson99bac312016-06-28 10:38:18 -070010252 hdd_notice("Current band value = %u, new setting %u ",
10253 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010254
10255 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010256 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010257 pAdapter = pAdapterNode->pAdapter;
10258 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10259 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053010260 INVALID_SCAN_ID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010261 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10262 connectedBand =
10263 hdd_conn_get_connected_band
10264 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
10265
10266 /* Handling is done only for STA and P2P */
10267 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -080010268 ((pAdapter->device_mode == QDF_STA_MODE)
10269 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010270 &&
10271 (hdd_conn_is_connected
10272 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
10273 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010274 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010275 long lrc;
10276
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010277 /* STA already connected on current
10278 * band, So issue disconnect first,
10279 * then change the band
10280 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010281
Jeff Johnson99bac312016-06-28 10:38:18 -070010282 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010283 hdd_device_mode_to_string(pAdapter->device_mode),
10284 pAdapter->device_mode, currBand, band);
10285 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10286
10287 status =
10288 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
10289 (pAdapter),
10290 pAdapter->sessionId,
10291 eCSR_DISCONNECT_REASON_UNSPECIFIED);
10292
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010293 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010294 hdd_err("csr_roam_disconnect failure, returned %d",
10295 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010296 return -EINVAL;
10297 }
10298
10299 lrc =
10300 wait_for_completion_timeout(&pAdapter->
10301 disconnect_comp_var,
10302 msecs_to_jiffies
10303 (WLAN_WAIT_TIME_DISCONNECT));
10304
10305 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010306 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010307 return -ETIMEDOUT;
10308 }
10309 }
10310
10311 sme_scan_flush_result(hHal);
10312
10313 status =
10314 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
10315 pAdapterNode = pNext;
10316 }
10317
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010318 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010319 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010320 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010321 band);
10322 return -EINVAL;
10323 }
10324 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
10325 }
10326 return 0;
10327}
10328
10329int hdd_set_band_helper(struct net_device *dev, const char *command)
10330{
10331 uint8_t band;
10332 int ret;
10333
10334 /* Convert the band value from ascii to integer */
10335 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
10336 ret = kstrtou8(command, 10, &band);
10337 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010338 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010339 return -EINVAL;
10340 }
10341
10342 return hdd_set_band(dev, band);
10343}
10344
10345static int __iw_set_band_config(struct net_device *dev,
10346 struct iw_request_info *info,
10347 union iwreq_data *wrqu, char *extra)
10348{
10349 int *value = (int *)extra;
10350
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010351 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010352
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010353 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010354 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010355 return -EPERM;
10356 }
10357
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010358 return hdd_set_band(dev, value[0]);
10359}
10360
10361static int iw_set_band_config(struct net_device *dev,
10362 struct iw_request_info *info,
10363 union iwreq_data *wrqu, char *extra)
10364{
10365 int ret;
10366
10367 cds_ssr_protect(__func__);
10368 ret = __iw_set_band_config(dev, info, wrqu, extra);
10369 cds_ssr_unprotect(__func__);
10370
10371 return ret;
10372}
10373
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010374/**
10375 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
10376 * @adapter: Handle to adapter
10377 * @chan: Monitor mode channel
10378 * @bandwidth: Capture channel bandwidth
10379 *
10380 * Return: 0 on success else error code.
10381 */
10382static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
10383 uint32_t bandwidth)
10384{
10385 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10386 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
10387 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
10388 QDF_STATUS status;
10389 tHalHandle hal_hdl = hdd_ctx->hHal;
10390 struct qdf_mac_addr bssid;
10391 tCsrRoamProfile roam_profile;
10392 struct ch_params_s ch_params;
10393
10394 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
10395 hdd_err("Not supported, device is not in monitor mode");
10396 return -EINVAL;
10397 }
10398
10399 hdd_info("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080010400 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010401 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
10402 roam_profile.ChannelInfo.numOfChannels = 1;
10403 roam_profile.phyMode = ch_info->phy_mode;
10404 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070010405 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010406
10407 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
10408 QDF_MAC_ADDR_SIZE);
10409
10410 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -070010411 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010412 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
10413 &roam_profile);
10414 if (status) {
10415 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
10416 status);
10417 }
10418
10419 return qdf_status_to_os_return(status);
10420}
10421
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010422static int __iw_set_two_ints_getnone(struct net_device *dev,
10423 struct iw_request_info *info,
10424 union iwreq_data *wrqu, char *extra)
10425{
10426 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10427 int *value = (int *)extra;
10428 int sub_cmd = value[0];
10429 int ret;
10430 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10431
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010432 ENTER_DEV(dev);
10433
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010434 ret = wlan_hdd_validate_context(hdd_ctx);
10435 if (0 != ret)
10436 return ret;
10437
10438 switch (sub_cmd) {
10439 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -070010440 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010441 ret = wma_cli_set_command(pAdapter->sessionId,
10442 WMI_STA_SMPS_PARAM_CMDID,
10443 value[1] << WMA_SMPS_PARAM_VALUE_S
10444 | value[2],
10445 VDEV_CMD);
10446 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070010447#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010448 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -070010449 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010450 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053010451 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
10452 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010453 ret = wma_cli_set2_command(pAdapter->sessionId,
10454 GEN_PARAM_CRASH_INJECT,
10455 value[1], value[2], GEN_CMD);
10456 break;
10457#endif
Govind Singha471e5e2015-10-12 17:11:14 +053010458 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010459 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010460 value[1], value[2]);
10461 ret = wma_cli_set2_command(pAdapter->sessionId,
10462 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
10463 value[1], value[2], DBG_CMD);
10464 break;
10465 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070010466 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010467 value[1], value[2]);
10468 ret = wma_cli_set2_command(pAdapter->sessionId,
10469 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
10470 value[1], value[2], DBG_CMD);
10471 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010472 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
10473 hdd_debug("Ioctl to set dual fw mode config");
10474 if (hdd_ctx->config->dual_mac_feature_disable) {
10475 hdd_err("Dual mac feature is disabled from INI");
10476 return -EPERM;
10477 }
10478 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -080010479 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010480 break;
10481 case WE_DUMP_DP_TRACE_LEVEL:
10482 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
10483 value[1], value[2]);
10484 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010485 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053010486 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
10487 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053010488 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
10489 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010490 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010491 case WE_SET_MON_MODE_CHAN:
10492 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
10493 break;
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010494 case WE_SET_WLAN_SUSPEND:
Dustin Brownbc81a472016-10-26 16:56:59 -070010495 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010496 break;
10497 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070010498 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010499 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010500 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070010501 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010502 break;
10503 }
10504
10505 return ret;
10506}
10507
10508static int iw_set_two_ints_getnone(struct net_device *dev,
10509 struct iw_request_info *info,
10510 union iwreq_data *wrqu, char *extra)
10511{
10512 int ret;
10513
10514 cds_ssr_protect(__func__);
10515 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
10516 cds_ssr_unprotect(__func__);
10517
10518 return ret;
10519}
10520
10521/* Define the Wireless Extensions to the Linux Network Device structure */
10522/* A number of these routines are NULL (meaning they are not implemented.) */
10523
10524static const iw_handler we_handler[] = {
10525 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10526 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10527 (iw_handler) NULL, /* SIOCSIWNWID */
10528 (iw_handler) NULL, /* SIOCGIWNWID */
10529 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10530 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10531 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10532 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10533 (iw_handler) NULL, /* SIOCSIWSENS */
10534 (iw_handler) NULL, /* SIOCGIWSENS */
10535 (iw_handler) NULL, /* SIOCSIWRANGE */
10536 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10537 (iw_handler) NULL, /* SIOCSIWPRIV */
10538 (iw_handler) NULL, /* SIOCGIWPRIV */
10539 (iw_handler) NULL, /* SIOCSIWSTATS */
10540 (iw_handler) NULL, /* SIOCGIWSTATS */
10541 (iw_handler) NULL, /* SIOCSIWSPY */
10542 (iw_handler) NULL, /* SIOCGIWSPY */
10543 (iw_handler) NULL, /* SIOCSIWTHRSPY */
10544 (iw_handler) NULL, /* SIOCGIWTHRSPY */
10545 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10546 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10547 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10548 (iw_handler) NULL, /* SIOCGIWAPLIST */
10549 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10550 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10551 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10552 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10553 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10554 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10555 (iw_handler) NULL, /* -- hole -- */
10556 (iw_handler) NULL, /* -- hole -- */
10557 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10558 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10559 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
10560 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
10561 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10562 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10563 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10564 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10565 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10566 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10567 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10568 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10569 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10570 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10571 (iw_handler) NULL, /* -- hole -- */
10572 (iw_handler) NULL, /* -- hole -- */
10573 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10574 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10575 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10576 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10577 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10578 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10579 (iw_handler) NULL, /* SIOCSIWPMKSA */
10580};
10581
10582static const iw_handler we_private[] = {
10583
10584 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
10585 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
10586 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
10587 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10588 iw_set_three_ints_getnone,
10589 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10590 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
10591 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10592 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010593 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
10594 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010595 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10596 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10597 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010598 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010599 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10600 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10601 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
10602 iw_set_keepalive_params,
10603#ifdef WLAN_FEATURE_PACKET_FILTERING
10604 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
10605 iw_set_packet_filter_params,
10606#endif
10607#ifdef FEATURE_WLAN_SCAN_PNO
10608 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
10609#endif
10610 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080010611 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
10612 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010613 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
10614 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10615 iw_set_two_ints_getnone,
10616 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
10617 iw_set_dot11p_channel_sched,
10618};
10619
10620/*Maximum command length can be only 15 */
10621static const struct iw_priv_args we_private_args[] = {
10622
10623 /* handlers for main ioctl */
10624 {WLAN_PRIV_SET_INT_GET_NONE,
10625 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10626 0,
10627 ""},
10628
10629 /* handlers for sub-ioctl */
10630 {WE_SET_11D_STATE,
10631 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10632 0,
10633 "set11Dstate"},
10634
10635 {WE_WOWL,
10636 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10637 0,
10638 "wowl"},
10639
10640 {WE_SET_POWER,
10641 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10642 0,
10643 "setPower"},
10644
10645 {WE_SET_MAX_ASSOC,
10646 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10647 0,
10648 "setMaxAssoc"},
10649
10650 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10651 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10652 "setAutoChannel" },
10653
10654 {WE_SET_SCAN_DISABLE,
10655 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10656 0,
10657 "scan_disable"},
10658
10659 {WE_SET_DATA_INACTIVITY_TO,
10660 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10661 0,
10662 "inactivityTO"},
10663
10664 {WE_SET_MAX_TX_POWER,
10665 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10666 0,
10667 "setMaxTxPower"},
10668
10669 {WE_SET_TX_POWER,
10670 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10671 0,
10672 "setTxPower"},
10673
10674 {WE_SET_MC_RATE,
10675 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10676 0,
10677 "setMcRate"},
10678
10679 {WE_SET_MAX_TX_POWER_2_4,
10680 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10681 0,
10682 "setTxMaxPower2G"},
10683
10684 {WE_SET_MAX_TX_POWER_5_0,
10685 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10686 0,
10687 "setTxMaxPower5G"},
10688
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010689 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010690 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010691 0,
10692 "pktlog"},
10693
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010694 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10695 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010696 * will support both
10697 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010698 {WE_SET_MAX_TX_POWER,
10699 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10700 0,
10701 "setTxMaxPower"},
10702
10703 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010704 * 1 = enable and 0 = disable
10705 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010706 {
10707 WE_SET_HIGHER_DTIM_TRANSITION,
10708 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10709 0,
10710 "setHDtimTransn"
10711 },
10712
10713 {WE_SET_TM_LEVEL,
10714 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10715 0,
10716 "setTmLevel"},
10717
10718 {WE_SET_PHYMODE,
10719 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10720 0,
10721 "setphymode"},
10722
10723 {WE_SET_NSS,
10724 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10725 0,
10726 "nss"},
10727
10728 {WE_SET_LDPC,
10729 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10730 0,
10731 "ldpc"},
10732
10733 {WE_SET_TX_STBC,
10734 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10735 0,
10736 "tx_stbc"},
10737
10738 {WE_SET_RX_STBC,
10739 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10740 0,
10741 "rx_stbc"},
10742
10743 {WE_SET_SHORT_GI,
10744 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10745 0,
10746 "shortgi"},
10747
10748 {WE_SET_RTSCTS,
10749 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10750 0,
10751 "enablertscts"},
10752
10753 {WE_SET_CHWIDTH,
10754 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10755 0,
10756 "chwidth"},
10757
10758 {WE_SET_ANI_EN_DIS,
10759 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10760 0,
10761 "anienable"},
10762
10763 {WE_SET_ANI_POLL_PERIOD,
10764 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10765 0,
10766 "aniplen"},
10767
10768 {WE_SET_ANI_LISTEN_PERIOD,
10769 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10770 0,
10771 "anilislen"},
10772
10773 {WE_SET_ANI_OFDM_LEVEL,
10774 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10775 0,
10776 "aniofdmlvl"},
10777
10778 {WE_SET_ANI_CCK_LEVEL,
10779 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10780 0,
10781 "aniccklvl"},
10782
10783 {WE_SET_DYNAMIC_BW,
10784 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10785 0,
10786 "cwmenable"},
10787
10788 {WE_SET_CTS_CBW,
10789 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10790 0,
10791 "cts_cbw" },
10792
10793 {WE_SET_GTX_HT_MCS,
10794 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10795 0,
10796 "gtxHTMcs"},
10797
10798 {WE_SET_GTX_VHT_MCS,
10799 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10800 0,
10801 "gtxVHTMcs"},
10802
10803 {WE_SET_GTX_USRCFG,
10804 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10805 0,
10806 "gtxUsrCfg"},
10807
10808 {WE_SET_GTX_THRE,
10809 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10810 0,
10811 "gtxThre"},
10812
10813 {WE_SET_GTX_MARGIN,
10814 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10815 0,
10816 "gtxMargin"},
10817
10818 {WE_SET_GTX_STEP,
10819 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10820 0,
10821 "gtxStep"},
10822
10823 {WE_SET_GTX_MINTPC,
10824 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10825 0,
10826 "gtxMinTpc"},
10827
10828 {WE_SET_GTX_BWMASK,
10829 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10830 0,
10831 "gtxBWMask"},
10832
10833 {WE_SET_TX_CHAINMASK,
10834 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10835 0,
10836 "txchainmask"},
10837
10838 {WE_SET_RX_CHAINMASK,
10839 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10840 0,
10841 "rxchainmask"},
10842
10843 {WE_SET_11N_RATE,
10844 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10845 0,
10846 "set11NRates"},
10847
10848 {WE_SET_VHT_RATE,
10849 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10850 0,
10851 "set11ACRates"},
10852
10853 {WE_SET_AMPDU,
10854 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10855 0,
10856 "ampdu"},
10857
10858 {WE_SET_AMSDU,
10859 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10860 0,
10861 "amsdu"},
10862
10863 {WE_SET_BURST_ENABLE,
10864 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10865 0,
10866 "burst_enable"},
10867
10868 {WE_SET_BURST_DUR,
10869 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10870 0,
10871 "burst_dur"},
10872
10873 {WE_SET_TXPOW_2G,
10874 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10875 0,
10876 "txpow2g"},
10877
10878 {WE_SET_TXPOW_5G,
10879 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10880 0,
10881 "txpow5g"},
10882
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010883 /* Sub-cmds DBGLOG specific commands */
10884 {WE_DBGLOG_LOG_LEVEL,
10885 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10886 0,
10887 "dl_loglevel"},
10888
10889 {WE_DBGLOG_VAP_ENABLE,
10890 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10891 0,
10892 "dl_vapon"},
10893
10894 {WE_DBGLOG_VAP_DISABLE,
10895 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10896 0,
10897 "dl_vapoff"},
10898
10899 {WE_DBGLOG_MODULE_ENABLE,
10900 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10901 0,
10902 "dl_modon"},
10903
10904 {WE_DBGLOG_MODULE_DISABLE,
10905 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10906 0,
10907 "dl_modoff"},
10908
10909 {WE_DBGLOG_MOD_LOG_LEVEL,
10910 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10911 0,
10912 "dl_mod_loglevel"},
10913
10914 {WE_DBGLOG_TYPE,
10915 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10916 0,
10917 "dl_type"},
10918 {WE_DBGLOG_REPORT_ENABLE,
10919 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10920 0,
10921 "dl_report"},
10922
10923 {WE_SET_TXRX_FWSTATS,
10924 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10925 0,
10926 "txrx_fw_stats"},
10927
10928 {WE_TXRX_FWSTATS_RESET,
10929 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10930 0,
10931 "txrx_fw_st_rst"},
10932
10933 {WE_PPS_PAID_MATCH,
10934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10935 0, "paid_match"},
10936
10937 {WE_PPS_GID_MATCH,
10938 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10939 0, "gid_match"},
10940
10941 {WE_PPS_EARLY_TIM_CLEAR,
10942 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10943 0, "tim_clear"},
10944
10945 {WE_PPS_EARLY_DTIM_CLEAR,
10946 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10947 0, "dtim_clear"},
10948
10949 {WE_PPS_EOF_PAD_DELIM,
10950 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10951 0, "eof_delim"},
10952
10953 {WE_PPS_MACADDR_MISMATCH,
10954 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10955 0, "mac_match"},
10956
10957 {WE_PPS_DELIM_CRC_FAIL,
10958 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10959 0, "delim_fail"},
10960
10961 {WE_PPS_GID_NSTS_ZERO,
10962 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10963 0, "nsts_zero"},
10964
10965 {WE_PPS_RSSI_CHECK,
10966 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10967 0, "rssi_chk"},
10968
10969 {WE_PPS_5G_EBT,
10970 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10971 0, "5g_ebt"},
10972
10973 {WE_SET_HTSMPS,
10974 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10975 0, "htsmps"},
10976
10977 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
10978 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10979 0, "set_qpspollcnt"},
10980
10981 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
10982 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10983 0, "set_qtxwake"},
10984
10985 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10986 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10987 0, "set_qwakeintv"},
10988
10989 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10990 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10991 0, "set_qnodatapoll"},
10992
10993 /* handlers for MCC time quota and latency sub ioctls */
10994 {WE_MCC_CONFIG_LATENCY,
10995 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10996 0, "setMccLatency"},
10997
10998 {WE_MCC_CONFIG_QUOTA,
10999 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11000 0, "setMccQuota"},
11001
11002 {WE_SET_DEBUG_LOG,
11003 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11004 0, "setDbgLvl"},
11005
11006 /* handlers for early_rx power save */
11007 {WE_SET_EARLY_RX_ADJUST_ENABLE,
11008 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11009 0, "erx_enable"},
11010
11011 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
11012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11013 0, "erx_bmiss_val"},
11014
11015 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
11016 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11017 0, "erx_bmiss_smpl"},
11018
11019 {WE_SET_EARLY_RX_SLOP_STEP,
11020 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11021 0, "erx_slop_step"},
11022
11023 {WE_SET_EARLY_RX_INIT_SLOP,
11024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11025 0, "erx_init_slop"},
11026
11027 {WE_SET_EARLY_RX_ADJUST_PAUSE,
11028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11029 0, "erx_adj_pause"},
11030
11031 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
11032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11033 0, "erx_dri_sample"},
11034
11035 {WE_DUMP_STATS,
11036 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11037 0, "dumpStats"},
11038
11039 {WE_CLEAR_STATS,
11040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11041 0, "clearStats"},
11042
Govind Singha471e5e2015-10-12 17:11:14 +053011043 {WE_START_FW_PROFILE,
11044 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11045 0, "startProfile"},
11046
Abhishek Singh1bdb1572015-10-16 16:24:19 +053011047 {WE_SET_CHANNEL,
11048 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11049 0, "setChanChange" },
11050
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053011051 {WE_SET_CONC_SYSTEM_PREF,
11052 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11053 0, "setConcSysPref" },
11054
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011055 {WLAN_PRIV_SET_NONE_GET_INT,
11056 0,
11057 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11058 ""},
11059
11060 /* handlers for sub-ioctl */
11061 {WE_GET_11D_STATE,
11062 0,
11063 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11064 "get11Dstate"},
11065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011066 {WE_GET_WLAN_DBG,
11067 0,
11068 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11069 "getwlandbg"},
11070
11071 {WE_GET_MAX_ASSOC,
11072 0,
11073 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11074 "getMaxAssoc"},
11075
11076 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11077 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11078 "getAutoChannel" },
11079
11080 {WE_GET_CONCURRENCY_MODE,
11081 0,
11082 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11083 "getconcurrency"},
11084
11085 {WE_GET_NSS,
11086 0,
11087 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11088 "get_nss"},
11089
11090 {WE_GET_LDPC,
11091 0,
11092 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11093 "get_ldpc"},
11094
11095 {WE_GET_TX_STBC,
11096 0,
11097 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11098 "get_tx_stbc"},
11099
11100 {WE_GET_RX_STBC,
11101 0,
11102 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11103 "get_rx_stbc"},
11104
11105 {WE_GET_SHORT_GI,
11106 0,
11107 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11108 "get_shortgi"},
11109
11110 {WE_GET_RTSCTS,
11111 0,
11112 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11113 "get_rtscts"},
11114
11115 {WE_GET_CHWIDTH,
11116 0,
11117 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11118 "get_chwidth"},
11119
11120 {WE_GET_ANI_EN_DIS,
11121 0,
11122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11123 "get_anienable"},
11124
11125 {WE_GET_ANI_POLL_PERIOD,
11126 0,
11127 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11128 "get_aniplen"},
11129
11130 {WE_GET_ANI_LISTEN_PERIOD,
11131 0,
11132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11133 "get_anilislen"},
11134
11135 {WE_GET_ANI_OFDM_LEVEL,
11136 0,
11137 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11138 "get_aniofdmlvl"},
11139
11140 {WE_GET_ANI_CCK_LEVEL,
11141 0,
11142 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11143 "get_aniccklvl"},
11144
11145 {WE_GET_DYNAMIC_BW,
11146 0,
11147 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11148 "get_cwmenable"},
11149
11150 {WE_GET_GTX_HT_MCS,
11151 0,
11152 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11153 "get_gtxHTMcs"},
11154
11155 {WE_GET_GTX_VHT_MCS,
11156 0,
11157 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11158 "get_gtxVHTMcs"},
11159
11160 {WE_GET_GTX_USRCFG,
11161 0,
11162 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11163 "get_gtxUsrCfg"},
11164
11165 {WE_GET_GTX_THRE,
11166 0,
11167 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11168 "get_gtxThre"},
11169
11170 {WE_GET_GTX_MARGIN,
11171 0,
11172 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11173 "get_gtxMargin"},
11174
11175 {WE_GET_GTX_STEP,
11176 0,
11177 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11178 "get_gtxStep"},
11179
11180 {WE_GET_GTX_MINTPC,
11181 0,
11182 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11183 "get_gtxMinTpc"},
11184
11185 {WE_GET_GTX_BWMASK,
11186 0,
11187 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11188 "get_gtxBWMask"},
11189
11190 {WE_GET_TX_CHAINMASK,
11191 0,
11192 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11193 "get_txchainmask"},
11194
11195 {WE_GET_RX_CHAINMASK,
11196 0,
11197 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11198 "get_rxchainmask"},
11199
11200 {WE_GET_11N_RATE,
11201 0,
11202 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11203 "get_11nrate"},
11204
11205 {WE_GET_AMPDU,
11206 0,
11207 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11208 "get_ampdu"},
11209
11210 {WE_GET_AMSDU,
11211 0,
11212 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11213 "get_amsdu"},
11214
11215 {WE_GET_BURST_ENABLE,
11216 0,
11217 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11218 "get_burst_en"},
11219
11220 {WE_GET_BURST_DUR,
11221 0,
11222 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11223 "get_burst_dur"},
11224
11225 {WE_GET_TXPOW_2G,
11226 0,
11227 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11228 "get_txpow2g"},
11229
11230 {WE_GET_TXPOW_5G,
11231 0,
11232 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11233 "get_txpow5g"},
11234
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011235 {WE_GET_PPS_PAID_MATCH,
11236 0,
11237 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11238 "get_paid_match"},
11239
11240 {WE_GET_PPS_GID_MATCH,
11241 0,
11242 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11243 "get_gid_match"},
11244
11245 {WE_GET_PPS_EARLY_TIM_CLEAR,
11246 0,
11247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11248 "get_tim_clear"},
11249
11250 {WE_GET_PPS_EARLY_DTIM_CLEAR,
11251 0,
11252 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11253 "get_dtim_clear"},
11254
11255 {WE_GET_PPS_EOF_PAD_DELIM,
11256 0,
11257 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11258 "get_eof_delim"},
11259
11260 {WE_GET_PPS_MACADDR_MISMATCH,
11261 0,
11262 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11263 "get_mac_match"},
11264
11265 {WE_GET_PPS_DELIM_CRC_FAIL,
11266 0,
11267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11268 "get_delim_fail"},
11269
11270 {WE_GET_PPS_GID_NSTS_ZERO,
11271 0,
11272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11273 "get_nsts_zero"},
11274
11275 {WE_GET_PPS_RSSI_CHECK,
11276 0,
11277 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11278 "get_rssi_chk"},
11279
11280 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
11281 0,
11282 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11283 "get_qpspollcnt"},
11284
11285 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
11286 0,
11287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11288 "get_qtxwake"},
11289
11290 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
11291 0,
11292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11293 "get_qwakeintv"},
11294
11295 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
11296 0,
11297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11298 "get_qnodatapoll"},
11299
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011300 {WE_CAP_TSF,
11301 0,
11302 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11303 "cap_tsf"},
11304
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011305 {WE_GET_TEMPERATURE,
11306 0,
11307 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11308 "get_temp"},
11309 /* handlers for main ioctl */
11310 {WLAN_PRIV_SET_CHAR_GET_NONE,
11311 IW_PRIV_TYPE_CHAR | 512,
11312 0,
11313 ""},
11314
11315 /* handlers for sub-ioctl */
11316 {WE_WOWL_ADD_PTRN,
11317 IW_PRIV_TYPE_CHAR | 512,
11318 0,
11319 "wowlAddPtrn"},
11320
11321 {WE_WOWL_DEL_PTRN,
11322 IW_PRIV_TYPE_CHAR | 512,
11323 0,
11324 "wowlDelPtrn"},
11325
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011326 /* handlers for sub-ioctl */
11327 {WE_NEIGHBOR_REPORT_REQUEST,
11328 IW_PRIV_TYPE_CHAR | 512,
11329 0,
11330 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080011331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011332 {WE_SET_AP_WPS_IE,
11333 IW_PRIV_TYPE_CHAR | 512,
11334 0,
11335 "set_ap_wps_ie"},
11336
11337 {WE_SET_CONFIG,
11338 IW_PRIV_TYPE_CHAR | 512,
11339 0,
11340 "setConfig"},
11341
11342 /* handlers for main ioctl */
11343 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
11344 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11345 0,
11346 ""},
11347
11348 /* handlers for sub-ioctl */
11349 {WE_SET_WLAN_DBG,
11350 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11351 0,
11352 "setwlandbg"},
11353
11354 /* handlers for sub-ioctl */
11355 {WE_SET_DP_TRACE,
11356 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11357 0,
11358 "set_dp_trace"},
11359
11360 {WE_SET_SAP_CHANNELS,
11361 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11362 0,
11363 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053011364
11365 {WE_SET_FW_TEST,
11366 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11367 0, "fw_test"},
11368
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011369 /* handlers for main ioctl */
11370 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
11371 0,
11372 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11373 "" },
11374 {WE_GET_TSF,
11375 0,
11376 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11377 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011378
11379 {WE_SET_DUAL_MAC_SCAN_CONFIG,
11380 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11381 0,
11382 "set_scan_cfg"},
11383
11384 /* handlers for main ioctl */
11385 {WLAN_PRIV_GET_CHAR_SET_NONE,
11386 0,
11387 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11388 ""},
11389
11390 /* handlers for sub-ioctl */
11391 {WE_WLAN_VERSION,
11392 0,
11393 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11394 "version"},
11395 {WE_GET_STATS,
11396 0,
11397 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11398 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080011399 {WE_GET_SUSPEND_RESUME_STATS,
11400 0,
11401 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11402 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053011403 {WE_LIST_FW_PROFILE,
11404 0,
11405 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11406 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011407 {WE_GET_STATES,
11408 0,
11409 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11410 "getHostStates"},
11411 {WE_GET_CFG,
11412 0,
11413 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11414 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011415 {WE_GET_RSSI,
11416 0,
11417 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11418 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011419 {WE_GET_WMM_STATUS,
11420 0,
11421 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11422 "getWmmStatus"},
11423 {
11424 WE_GET_CHANNEL_LIST,
11425 0,
11426 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11427 "getChannelList"
11428 },
11429#ifdef FEATURE_WLAN_TDLS
11430 {
11431 WE_GET_TDLS_PEERS,
11432 0,
11433 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11434 "getTdlsPeers"
11435 },
11436#endif
11437#ifdef WLAN_FEATURE_11W
11438 {
11439 WE_GET_11W_INFO,
11440 0,
11441 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11442 "getPMFInfo"
11443 },
11444#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011445 {
11446 WE_GET_IBSS_STA_INFO,
11447 0,
11448 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11449 "getIbssSTAs"
11450 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011451 {WE_GET_PHYMODE,
11452 0,
11453 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11454 "getphymode"},
11455#ifdef FEATURE_OEM_DATA_SUPPORT
11456 {WE_GET_OEM_DATA_CAP,
11457 0,
11458 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11459 "getOemDataCap"},
11460#endif /* FEATURE_OEM_DATA_SUPPORT */
11461 {WE_GET_SNR,
11462 0,
11463 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11464 "getSNR"},
11465
11466 /* handlers for main ioctl */
11467 {WLAN_PRIV_SET_NONE_GET_NONE,
11468 0,
11469 0,
11470 ""},
11471
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011472 /* handlers for sub-ioctl */
11473 {
11474 WE_IBSS_GET_PEER_INFO_ALL,
11475 0,
11476 0,
11477 "ibssPeerInfoAll"
11478 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011479 {WE_GET_RECOVERY_STAT,
11480 0,
11481 0,
11482 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053011483
11484 {WE_GET_FW_PROFILE_DATA,
11485 0,
11486 0,
11487 "getProfileData"},
11488
11489 {WE_SET_REASSOC_TRIGGER,
11490 0,
11491 0,
11492 "reassoc"},
11493
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080011494 {WE_STOP_OBSS_SCAN,
11495 0,
11496 0,
11497 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011498 /* handlers for main ioctl */
11499 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
11500 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11501 0,
11502 ""},
11503
11504 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011505 {WE_IBSS_GET_PEER_INFO,
11506 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11507 0,
11508 "ibssPeerInfo"},
11509
11510 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011511 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11512 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11513 0,
11514 "setdumplog"},
11515
11516 {WE_MTRACE_DUMP_CMD,
11517 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11518 0,
11519 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080011520
11521 {WE_POLICY_MANAGER_CINFO_CMD,
11522 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11523 0,
11524 "pm_cinfo"},
11525
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011526#ifdef MPC_UT_FRAMEWORK
11527 {WE_POLICY_MANAGER_CLIST_CMD,
11528 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11529 0,
11530 "pm_clist"},
11531
11532 {WE_POLICY_MANAGER_DLIST_CMD,
11533 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11534 0,
11535 "pm_dlist"},
11536
11537 {WE_POLICY_MANAGER_DBS_CMD,
11538 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11539 0,
11540 "pm_dbs"},
11541
11542 {WE_POLICY_MANAGER_PCL_CMD,
11543 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11544 0,
11545 "pm_pcl"},
11546
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011547 {WE_POLICY_MANAGER_ULIST_CMD,
11548 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11549 0,
11550 "pm_ulist"},
11551
11552 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
11553 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11554 0,
11555 "pm_query_action"},
11556
11557 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
11558 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11559 0,
11560 "pm_query_allow"},
11561
11562 {WE_POLICY_MANAGER_SCENARIO_CMD,
11563 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11564 0,
11565 "pm_run_scenario"},
11566
11567 {WE_POLICY_SET_HW_MODE_CMD,
11568 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11569 0,
11570 "pm_set_hw_mode"},
11571#endif
11572#ifdef FEATURE_WLAN_TDLS
11573 /* handlers for sub ioctl */
11574 {
11575 WE_TDLS_CONFIG_PARAMS,
11576 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11577 0,
11578 "setTdlsConfig"
11579 },
11580#endif
11581 {
11582 WE_UNIT_TEST_CMD,
11583 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11584 0,
11585 "setUnitTestCmd"
11586 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053011587 {
11588 WE_MAC_PWR_DEBUG_CMD,
11589 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11590 0,
11591 "halPwrDebug"
11592 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011593
11594#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11595 {WE_LED_FLASHING_PARAM,
11596 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11597 0,
11598 "gpio_control"},
11599#endif
11600 /* handlers for main ioctl */
11601 {WLAN_PRIV_ADD_TSPEC,
11602 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11603 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11604 "addTspec"},
11605
11606 /* handlers for main ioctl */
11607 {WLAN_PRIV_DEL_TSPEC,
11608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11609 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11610 "delTspec"},
11611
11612 /* handlers for main ioctl */
11613 {WLAN_PRIV_GET_TSPEC,
11614 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11615 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11616 "getTspec"},
11617
11618 /* handlers for main ioctl - host offload */
11619 {
11620 WLAN_PRIV_SET_HOST_OFFLOAD,
11621 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11622 0,
11623 "setHostOffload"
11624 }
11625 ,
11626
11627 {
11628 WLAN_GET_WLAN_STATISTICS,
11629 0,
11630 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11631 "getWlanStats"
11632 }
11633 ,
11634
11635 {
11636 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011637 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11638 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011639 0,
11640 "setKeepAlive"
11641 }
11642 ,
11643#ifdef WLAN_FEATURE_PACKET_FILTERING
11644 {
11645 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053011646 IW_PRIV_TYPE_BYTE |
11647 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011648 0,
11649 "setPktFilter"
11650 }
11651 ,
11652#endif
11653#ifdef FEATURE_WLAN_SCAN_PNO
11654 {
11655 WLAN_SET_PNO,
11656 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11657 0,
11658 "setpno"
11659 }
11660 ,
11661#endif
11662 {
11663 WLAN_SET_BAND_CONFIG,
11664 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11665 0,
11666 "SETBAND"
11667 }
11668 ,
11669 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080011670 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080011671 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011672 0,
11673 "setMCBCFilter"
11674 }
11675 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011676
11677 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011678 WLAN_GET_LINK_SPEED,
11679 IW_PRIV_TYPE_CHAR | 18,
11680 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11681 }
11682 ,
11683
11684 /* handlers for main ioctl */
11685 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
11686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11687 0,
11688 ""}
11689 ,
11690 {WE_SET_SMPS_PARAM,
11691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11692 0, "set_smps_param"}
11693 ,
11694 {WLAN_SET_DOT11P_CHANNEL_SCHED,
11695 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
11696 0, "set_dot11p" }
11697 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070011698#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011699 {WE_SET_FW_CRASH_INJECT,
11700 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11701 0, "crash_inject"}
11702 ,
11703#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070011704#ifdef WLAN_SUSPEND_RESUME_TEST
11705 {WE_SET_WLAN_SUSPEND,
11706 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11707 0, "wlan_suspend"}
11708 ,
11709 {WE_SET_WLAN_RESUME,
11710 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11711 0, "wlan_resume"}
11712 ,
11713#endif
Govind Singha471e5e2015-10-12 17:11:14 +053011714 {WE_ENABLE_FW_PROFILE,
11715 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11716 0, "enableProfile"}
11717 ,
11718 {WE_SET_FW_PROFILE_HIST_INTVL,
11719 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11720 0, "set_hist_intvl"}
11721 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011722 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
11723 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11724 0, "set_fw_mode_cfg"}
11725 ,
11726 {WE_DUMP_DP_TRACE_LEVEL,
11727 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11728 0, "dump_dp_trace"}
11729 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011730 {WE_SET_MON_MODE_CHAN,
11731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11732 0, "setMonChan"}
11733 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070011734
11735 {WE_GET_ROAM_SYNCH_DELAY,
11736 0,
11737 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11738 "hostroamdelay"}
11739 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011740};
11741
11742const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053011743 .num_standard = QDF_ARRAY_SIZE(we_handler),
11744 .num_private = QDF_ARRAY_SIZE(we_private),
11745 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011746
11747 .standard = (iw_handler *) we_handler,
11748 .private = (iw_handler *) we_private,
11749 .private_args = we_private_args,
11750 .get_wireless_stats = NULL,
11751};
11752
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011753/* hdd_set_wext() - configures bss parameters
11754 * @pAdapter: handle to adapter context
11755 *
11756 * Returns: none
11757 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011758static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011759{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011760 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11761 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011762
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011763 ENTER();
11764
11765 if (!pwextBuf) {
11766 hdd_err("ERROR: pwextBuf is NULL");
11767 return QDF_STATUS_E_FAILURE;
11768 }
11769
11770 if (!pHddStaCtx) {
11771 hdd_err("ERROR: pHddStaCtx is NULL");
11772 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011773 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011774
11775 /* Now configure the roaming profile links. To SSID and bssid. */
11776 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011777 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011778
11779 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011780 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011781
11782 /*Set the numOfChannels to zero to scan all the channels */
11783 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11784 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11785
11786 /* Default is no encryption */
11787 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11788 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
11789 eCSR_ENCRYPT_TYPE_NONE;
11790
11791 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11792 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
11793 eCSR_ENCRYPT_TYPE_NONE;
11794
11795 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11796
11797 /* Default is no authentication */
11798 pwextBuf->roamProfile.AuthType.numEntries = 1;
11799 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11800
11801 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
11802 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11803
11804 /*Set the default scan mode */
11805 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
11806
11807 hdd_clear_roam_profile_ie(pAdapter);
11808
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011809 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011810 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011811
11812}
11813
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011814/**
11815 * hdd_register_wext() - register wext context
11816 * @dev: net device handle
11817 *
11818 * Registers wext interface context for a given net device
11819 *
11820 * Returns: 0 on success, errno on failure
11821 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011822int hdd_register_wext(struct net_device *dev)
11823{
11824 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011825 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011826 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011827
11828 ENTER();
11829
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011830 if (!pwextBuf) {
11831 hdd_err(FL("ERROR: pwextBuf is NULL"));
11832 return QDF_STATUS_E_FAILURE;
11833 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011834
11835 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011836 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
11837
11838 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->
11839 completion_var);
11840
11841 status = hdd_set_wext(pAdapter);
11842
Anurag Chouhance0dc992016-02-16 18:18:03 +053011843 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011844
Jeff Johnson99bac312016-06-28 10:38:18 -070011845 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011846 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011847 }
11848
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011849 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011850 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011851 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011852 }
11853
Anurag Chouhance0dc992016-02-16 18:18:03 +053011854 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->scanevent))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011855 hdd_err("ERROR: HDD scan event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011856 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011857 }
11858 /* Register as a wireless device */
11859 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11860
11861 EXIT();
11862 return 0;
11863}
11864
11865int hdd_unregister_wext(struct net_device *dev)
11866{
Jeff Johnson99bac312016-06-28 10:38:18 -070011867 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011868
11869 if (dev != NULL) {
11870 rtnl_lock();
11871 dev->wireless_handlers = NULL;
11872 rtnl_unlock();
11873 }
11874
11875 return 0;
11876}