blob: 4d68d78741bdb2a7189706e160a438ba8b901526 [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{
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003140 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 hdd_wext_state_t *pWextState;
3142 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3143 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3144 hdd_context_t *hdd_ctx;
3145 int ret;
3146
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003147 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148
3149 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3150 ret = wlan_hdd_validate_context(hdd_ctx);
3151 if (0 != ret)
3152 return ret;
3153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
3155 wrqu->bitrate.value = 0;
3156 } else {
3157 status =
3158 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
3159 eCSR_HDD,
3160 SME_SUMMARY_STATS |
3161 SME_GLOBAL_CLASSA_STATS |
3162 SME_GLOBAL_CLASSB_STATS |
3163 SME_GLOBAL_CLASSC_STATS |
3164 SME_GLOBAL_CLASSD_STATS |
3165 SME_PER_STA_STATS,
3166 hdd_statistics_cb, 0,
3167 false,
3168 pHddStaCtx->conn_info.staId[0],
3169 pAdapter, pAdapter->sessionId);
3170
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303171 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003172 hdd_err("Unable to retrieve statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003173 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 }
3175
3176 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3177
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003178 status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303179 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 WLAN_WAIT_TIME_STATS);
3181
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003182 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003183 hdd_err("SME timeout while retrieving statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003184 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 }
3186
3187 wrqu->bitrate.value =
3188 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
3189 }
3190
3191 EXIT();
3192
Jeff Johnsonf25ac102017-02-07 09:16:02 -08003193 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194}
3195
3196/**
3197 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
3198 * @dev: pointer to net_device
3199 * @info: pointer to iw_request_info
3200 * @wrqu: pointer to iwreq_data
3201 * @extra: pointer to extra ioctl payload
3202 *
3203 * Return: 0 on success, error number otherwise
3204 */
3205static int iw_get_bitrate(struct net_device *dev,
3206 struct iw_request_info *info,
3207 union iwreq_data *wrqu, char *extra)
3208{
3209 int ret;
3210
3211 cds_ssr_protect(__func__);
3212 ret = __iw_get_bitrate(dev, info, wrqu, extra);
3213 cds_ssr_unprotect(__func__);
3214
3215 return ret;
3216}
3217
3218/**
3219 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
3220 * @dev: device upon which the ioctl was received
3221 * @info: ioctl request information
3222 * @wrqu: ioctl request data
3223 * @extra: ioctl extra data
3224 *
3225 * Return: 0 on success, non-zero on error
3226 */
3227static int __iw_set_bitrate(struct net_device *dev,
3228 struct iw_request_info *info,
3229 union iwreq_data *wrqu, char *extra)
3230{
3231 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3232 hdd_wext_state_t *pWextState;
3233 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3234 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
3235 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
3236 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
3237 uint32_t i, rate;
3238 uint32_t valid_rate = false, active_phy_mode = 0;
3239 hdd_context_t *hdd_ctx;
3240 int ret;
3241
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003242 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243
3244 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3245 ret = wlan_hdd_validate_context(hdd_ctx);
3246 if (0 != ret)
3247 return ret;
3248
3249 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3250
3251 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
3252 return -ENXIO;
3253 }
3254
3255 rate = wrqu->bitrate.value;
3256
3257 if (rate == -1) {
3258 rate = WNI_CFG_FIXED_RATE_AUTO;
3259 valid_rate = true;
3260 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
3261 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303262 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
3264 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
3265 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
3266 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
3267 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303268 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 &&
3270 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
3271 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303272 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 for (i = 0; i < (b_len + a_len); ++i) {
3274 /* supported rates returned is double
3275 * the actual rate so we divide it by 2
3276 */
3277 if ((supp_rates[i] & 0x7F) / 2 ==
3278 rate) {
3279 valid_rate = true;
3280 rate = i +
3281 WNI_CFG_FIXED_RATE_1MBPS;
3282 break;
3283 }
3284 }
3285 }
3286 }
3287 }
3288 if (valid_rate != true) {
3289 return -EINVAL;
3290 }
3291 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303292 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003293 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 return -EIO;
3295 }
3296 return 0;
3297}
3298
3299/**
3300 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
3301 * @dev: pointer to net_device
3302 * @info: pointer to iw_request_info
3303 * @wrqu: pointer to iwreq_data
3304 * @extra: pointer to extra ioctl payload
3305 *
3306 * Return: 0 on success, error number otherwise
3307 */
3308static int iw_set_bitrate(struct net_device *dev,
3309 struct iw_request_info *info,
3310 union iwreq_data *wrqu, char *extra)
3311{
3312 int ret;
3313
3314 cds_ssr_protect(__func__);
3315 ret = __iw_set_bitrate(dev, info, wrqu, extra);
3316 cds_ssr_unprotect(__func__);
3317
3318 return ret;
3319}
3320
3321/**
3322 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
3323 * @dev: device upon which the ioctl was received
3324 * @info: ioctl request information
3325 * @wrqu: ioctl request data
3326 * @extra: ioctl extra data
3327 *
3328 * Return: 0 on success, non-zero on error
3329 */
3330static int __iw_set_genie(struct net_device *dev,
3331 struct iw_request_info *info,
3332 union iwreq_data *wrqu, char *extra)
3333{
3334 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3335 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3336 uint8_t *genie = NULL;
3337 uint8_t *base_genie = NULL;
3338 uint16_t remLen;
3339 hdd_context_t *hdd_ctx;
3340 int ret;
3341
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003342 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003343
3344 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3345 ret = wlan_hdd_validate_context(hdd_ctx);
3346 if (0 != ret)
3347 return ret;
3348
3349 if (!wrqu->data.length) {
3350 hdd_clear_roam_profile_ie(pAdapter);
3351 EXIT();
3352 return 0;
3353 }
3354
3355 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
3356 wrqu->data.length);
3357 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003358 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 return -ENOMEM;
3360 }
3361
3362 genie = base_genie;
3363
3364 remLen = wrqu->data.length;
3365
Jeff Johnson99bac312016-06-28 10:38:18 -07003366 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 genie[1]);
3368
3369 /* clear any previous genIE before this call */
3370 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
3371
3372 while (remLen >= 2) {
3373 uint16_t eLen = 0;
3374 uint8_t elementId;
3375 elementId = *genie++;
3376 eLen = *genie++;
3377 remLen -= 2;
3378
Jeff Johnson99bac312016-06-28 10:38:18 -07003379 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380
3381 switch (elementId) {
3382 case IE_EID_VENDOR:
3383 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 +05303384 ret = -EINVAL;
3385 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 }
3387
3388 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
3389 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07003390 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
3391 genie[0], genie[1], genie[2],
3392 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393
3394 if (SIR_MAC_MAX_IE_LENGTH <
3395 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003396 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303397 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303398 ret = -ENOMEM;
3399 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 }
3401 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
3402 memcpy(pWextState->genIE.addIEdata +
3403 curGenIELen, genie - 2, eLen + 2);
3404 pWextState->genIE.length += eLen + 2;
3405 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003406 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303407 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
3408 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
3409 ret = -EINVAL;
3410 QDF_ASSERT(0);
3411 goto exit;
3412 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 memset(pWextState->WPARSNIE, 0,
3414 MAX_WPA_RSN_IE_LEN);
3415 memcpy(pWextState->WPARSNIE, genie - 2,
3416 (eLen + 2));
3417 pWextState->roamProfile.pWPAReqIE =
3418 pWextState->WPARSNIE;
3419 pWextState->roamProfile.nWPAReqIELength =
3420 eLen + 2;
3421 } else { /* any vendorId except WPA IE should be accumulated to genIE */
3422
3423 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07003424 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
3425 genie[0], genie[1], genie[2],
3426 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427
3428 if (SIR_MAC_MAX_IE_LENGTH <
3429 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003430 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303431 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303432 ret = -ENOMEM;
3433 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 }
3435 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
3436 memcpy(pWextState->genIE.addIEdata +
3437 curGenIELen, genie - 2, eLen + 2);
3438 pWextState->genIE.length += eLen + 2;
3439 }
3440 break;
3441 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07003442 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303443 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
3444 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
3445 ret = -EINVAL;
3446 QDF_ASSERT(0);
3447 goto exit;
3448 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
3450 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
3451 pWextState->roamProfile.pRSNReqIE =
3452 pWextState->WPARSNIE;
3453 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
3454 break;
3455
3456 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003457 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303458 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459 }
3460 genie += eLen;
3461 remLen -= eLen;
3462 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303463exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07003465 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05303466 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467}
3468
3469/**
3470 * iw_set_genie() - SSR wrapper for __iw_set_genie()
3471 * @dev: pointer to net_device
3472 * @info: pointer to iw_request_info
3473 * @wrqu: pointer to iwreq_data
3474 * @extra: pointer to extra ioctl payload
3475 *
3476 * Return: 0 on success, error number otherwise
3477 */
3478static int iw_set_genie(struct net_device *dev,
3479 struct iw_request_info *info,
3480 union iwreq_data *wrqu, char *extra)
3481{
3482 int ret;
3483
3484 cds_ssr_protect(__func__);
3485 ret = __iw_set_genie(dev, info, wrqu, extra);
3486 cds_ssr_unprotect(__func__);
3487
3488 return ret;
3489}
3490
3491/**
3492 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
3493 * @dev: device upon which the ioctl was received
3494 * @info: ioctl request information
3495 * @wrqu: ioctl request data
3496 * @extra: ioctl extra data
3497 *
3498 * Return: 0 on success, non-zero on error
3499 */
3500static int __iw_get_genie(struct net_device *dev,
3501 struct iw_request_info *info,
3502 union iwreq_data *wrqu, char *extra)
3503{
3504 hdd_wext_state_t *pWextState;
3505 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3506 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303507 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
3509 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
3510 hdd_context_t *hdd_ctx;
3511 int ret;
3512
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003513 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514
3515 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3516 ret = wlan_hdd_validate_context(hdd_ctx);
3517 if (0 != ret)
3518 return ret;
3519
Jeff Johnson99bac312016-06-28 10:38:18 -07003520 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521
3522 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3523
3524 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
3525 return -ENXIO;
3526 }
3527
3528 /* Return something ONLY if we are associated with an RSN or
3529 * WPA network
3530 */
3531 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
3532 return -ENXIO;
3533 }
3534
3535 /* Actually retrieve the RSN IE from CSR. (We previously sent
3536 * it down in the CSR Roam Profile.)
3537 */
3538 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
3539 pAdapter->sessionId,
3540 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05303541 if (QDF_STATUS_SUCCESS != status) {
3542 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 return -EFAULT;
3544 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05303546 if (length > DOT11F_IE_RSN_MAX_LEN) {
3547 hdd_notice("invalid buffer length length:%d", length);
3548 return -E2BIG;
3549 }
3550 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551
Jeff Johnson99bac312016-06-28 10:38:18 -07003552 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 wrqu->data.length);
3554
3555 EXIT();
3556
3557 return 0;
3558}
3559
3560/**
3561 * iw_get_genie() - SSR wrapper for __iw_get_genie()
3562 * @dev: pointer to net_device
3563 * @info: pointer to iw_request_info
3564 * @wrqu: pointer to iwreq_data
3565 * @extra: pointer to extra ioctl payload
3566 *
3567 * Return: 0 on success, error number otherwise
3568 */
3569static int iw_get_genie(struct net_device *dev,
3570 struct iw_request_info *info,
3571 union iwreq_data *wrqu, char *extra)
3572{
3573 int ret;
3574
3575 cds_ssr_protect(__func__);
3576 ret = __iw_get_genie(dev, info, wrqu, extra);
3577 cds_ssr_unprotect(__func__);
3578
3579 return ret;
3580}
3581
3582/**
3583 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
3584 * @dev: device upon which the ioctl was received
3585 * @info: ioctl request information
3586 * @wrqu: ioctl request data
3587 * @extra: ioctl extra data
3588 *
3589 * Return: 0 on success, non-zero on error
3590 */
3591static int __iw_get_encode(struct net_device *dev,
3592 struct iw_request_info *info,
3593 struct iw_point *dwrq, char *extra)
3594{
3595 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3596 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3597 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3598 int keyId;
3599 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
3600 int i;
3601 hdd_context_t *hdd_ctx;
3602 int ret;
3603
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003604 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605
3606 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3607 ret = wlan_hdd_validate_context(hdd_ctx);
3608 if (0 != ret)
3609 return ret;
3610
3611 keyId = pRoamProfile->Keys.defaultIndex;
3612
3613 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003614 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 return -EINVAL;
3616 }
3617
3618 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
3619 dwrq->flags |= IW_ENCODE_ENABLED;
3620 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303621 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 pRoamProfile->Keys.KeyLength[keyId]);
3623
3624 dwrq->flags |= (keyId + 1);
3625
3626 } else {
3627 dwrq->flags |= IW_ENCODE_DISABLED;
3628 }
3629
3630 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08003631 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632 continue;
3633 } else {
3634 break;
3635 }
3636 }
3637
3638 if (MAX_WEP_KEYS == i) {
3639 dwrq->flags |= IW_ENCODE_NOKEY;
3640 }
3641
3642 authType =
3643 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
3644 conn_info.authType;
3645
3646 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
3647 dwrq->flags |= IW_ENCODE_OPEN;
3648 } else {
3649 dwrq->flags |= IW_ENCODE_RESTRICTED;
3650 }
3651 EXIT();
3652 return 0;
3653}
3654
3655/**
3656 * iw_get_encode() - SSR wrapper for __iw_get_encode()
3657 * @dev: pointer to net_device
3658 * @info: pointer to iw_request_info
3659 * @dwrq: pointer to encoding information
3660 * @extra: pointer to extra ioctl payload
3661 *
3662 * Return: 0 on success, error number otherwise
3663 */
3664static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
3665 struct iw_point *dwrq, char *extra)
3666{
3667 int ret;
3668
3669 cds_ssr_protect(__func__);
3670 ret = __iw_get_encode(dev, info, dwrq, extra);
3671 cds_ssr_unprotect(__func__);
3672
3673 return ret;
3674}
3675
3676/**
3677 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
3678 * @dev: device upon which the ioctl was received
3679 * @info: ioctl request information
3680 * @wrqu: ioctl request data
3681 * @extra: ioctl extra data
3682 *
3683 * Return: 0 on success, non-zero on error
3684 */
3685static int __iw_get_rts_threshold(struct net_device *dev,
3686 struct iw_request_info *info,
3687 union iwreq_data *wrqu, char *extra)
3688{
3689 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3690 uint32_t status = 0;
3691
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003692 ENTER_DEV(dev);
3693
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694 status = hdd_wlan_get_rts_threshold(pAdapter, wrqu);
3695
3696 return status;
3697}
3698
3699/**
3700 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
3701 * @dev: device upon which the ioctl was received
3702 * @info: ioctl request information
3703 * @wrqu: ioctl request data
3704 * @extra: ioctl extra data
3705 *
3706 * Return: 0 on success, non-zero on error
3707 */
3708static int __iw_set_rts_threshold(struct net_device *dev,
3709 struct iw_request_info *info,
3710 union iwreq_data *wrqu, char *extra)
3711{
3712 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3713 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3714 hdd_context_t *hdd_ctx;
3715 int ret;
3716
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003717 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718
3719 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3720 ret = wlan_hdd_validate_context(hdd_ctx);
3721 if (0 != ret)
3722 return ret;
3723
3724 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
3725 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
3726 return -EINVAL;
3727 }
3728
3729 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303730 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003731 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732 return -EIO;
3733 }
3734
3735 EXIT();
3736
3737 return 0;
3738}
3739
3740/**
3741 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
3742 * @dev: pointer to net_device
3743 * @info: pointer to iw_request_info
3744 * @wrqu: pointer to iwreq_data
3745 * @extra: pointer to extra ioctl payload
3746 *
3747 * Return: 0 on success, error number otherwise
3748 */
3749static int iw_get_rts_threshold(struct net_device *dev,
3750 struct iw_request_info *info,
3751 union iwreq_data *wrqu, char *extra)
3752{
3753 int ret;
3754
3755 cds_ssr_protect(__func__);
3756 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
3757 cds_ssr_unprotect(__func__);
3758
3759 return ret;
3760}
3761
3762/**
3763 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
3764 * @dev: pointer to net_device
3765 * @info: pointer to iw_request_info
3766 * @wrqu: pointer to iwreq_data
3767 * @extra: pointer to extra ioctl payload
3768 *
3769 * Return: 0 on success, error number otherwise
3770 */
3771static int iw_set_rts_threshold(struct net_device *dev,
3772 struct iw_request_info *info,
3773 union iwreq_data *wrqu, char *extra)
3774{
3775 int ret;
3776
3777 cds_ssr_protect(__func__);
3778 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
3779 cds_ssr_unprotect(__func__);
3780
3781 return ret;
3782}
3783
3784/**
3785 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
3786 * @dev: device upon which the ioctl was received
3787 * @info: ioctl request information
3788 * @wrqu: ioctl request data
3789 * @extra: ioctl extra data
3790 *
3791 * Return: 0 on success, non-zero on error
3792 */
3793static int __iw_get_frag_threshold(struct net_device *dev,
3794 struct iw_request_info *info,
3795 union iwreq_data *wrqu, char *extra)
3796{
3797 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3798 uint32_t status = 0;
3799
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003800 ENTER_DEV(dev);
3801
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802 status = hdd_wlan_get_frag_threshold(pAdapter, wrqu);
3803
3804 return status;
3805}
3806
3807/**
3808 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
3809 * @dev: pointer to net_device
3810 * @info: pointer to iw_request_info
3811 * @wrqu: pointer to iwreq_data
3812 * @extra: pointer to extra ioctl payload
3813 *
3814 * Return: 0 on success, error number otherwise
3815 */
3816static int iw_get_frag_threshold(struct net_device *dev,
3817 struct iw_request_info *info,
3818 union iwreq_data *wrqu, char *extra)
3819{
3820 int ret;
3821
3822 cds_ssr_protect(__func__);
3823 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
3824 cds_ssr_unprotect(__func__);
3825
3826 return ret;
3827}
3828
3829/**
3830 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
3831 * @dev: device upon which the ioctl was received
3832 * @info: ioctl request information
3833 * @wrqu: ioctl request data
3834 * @extra: ioctl extra data
3835 *
3836 * Return: 0 on success, non-zero on error
3837 */
3838static int __iw_set_frag_threshold(struct net_device *dev,
3839 struct iw_request_info *info,
3840 union iwreq_data *wrqu, char *extra)
3841{
3842 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3843 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3844 hdd_context_t *hdd_ctx;
3845 int ret;
3846
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003847 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848
3849 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3850 ret = wlan_hdd_validate_context(hdd_ctx);
3851 if (0 != ret)
3852 return ret;
3853
3854 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
3855 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
3856 return -EINVAL;
3857 }
3858
3859 if (sme_cfg_set_int
3860 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303861 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003862 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863 return -EIO;
3864 }
3865
3866 EXIT();
3867
3868 return 0;
3869}
3870
3871/**
3872 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
3873 * @dev: pointer to net_device
3874 * @info: pointer to iw_request_info
3875 * @wrqu: pointer to iwreq_data
3876 * @extra: pointer to extra ioctl payload
3877 *
3878 * Return: 0 on success, error number otherwise
3879 */
3880static int iw_set_frag_threshold(struct net_device *dev,
3881 struct iw_request_info *info,
3882 union iwreq_data *wrqu, char *extra)
3883{
3884 int ret;
3885
3886 cds_ssr_protect(__func__);
3887 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
3888 cds_ssr_unprotect(__func__);
3889
3890 return ret;
3891}
3892
3893/**
3894 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
3895 * @dev: device upon which the ioctl was received
3896 * @info: ioctl request information
3897 * @wrqu: ioctl request data
3898 * @extra: ioctl extra data
3899 *
3900 * Return: 0 on success, non-zero on error
3901 */
3902static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003903 struct iw_request_info *info,
3904 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905{
3906 hdd_adapter_t *adapter;
3907 hdd_context_t *hdd_ctx;
3908 int ret;
3909
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003910 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911
3912 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3913 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3914 ret = wlan_hdd_validate_context(hdd_ctx);
3915 if (0 != ret)
3916 return ret;
3917
3918 return -EOPNOTSUPP;
3919}
3920
3921/**
3922 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
3923 * @dev: pointer to net_device
3924 * @info: pointer to iw_request_info
3925 * @wrqu: pointer to iwreq_data
3926 * @extra: extra
3927 *
3928 * Return: 0 on success, error number otherwise
3929 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003930static int iw_get_power_mode(struct net_device *dev,
3931 struct iw_request_info *info,
3932 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003933{
3934 int ret;
3935
3936 cds_ssr_protect(__func__);
3937 ret = __iw_get_power_mode(dev, info, wrqu, extra);
3938 cds_ssr_unprotect(__func__);
3939
3940 return ret;
3941}
3942
3943/**
3944 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
3945 * @dev: device upon which the ioctl was received
3946 * @info: ioctl request information
3947 * @wrqu: ioctl request data
3948 * @extra: ioctl extra data
3949 *
3950 * Return: 0 on success, non-zero on error
3951 */
3952static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003953 struct iw_request_info *info,
3954 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955{
3956 hdd_adapter_t *adapter;
3957 hdd_context_t *hdd_ctx;
3958 int ret;
3959
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003960 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003961
3962 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3963 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3964 ret = wlan_hdd_validate_context(hdd_ctx);
3965 if (0 != ret)
3966 return ret;
3967
3968 return -EOPNOTSUPP;
3969}
3970
3971/**
3972 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
3973 * @dev: pointer to net_device
3974 * @info: pointer to iw_request_info
3975 * @wrqu: pointer to iwreq_data
3976 * @extra: extra
3977 *
3978 * Return: 0 on success, error number otherwise
3979 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003980static int iw_set_power_mode(struct net_device *dev,
3981 struct iw_request_info *info,
3982 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983{
3984 int ret;
3985
3986 cds_ssr_protect(__func__);
3987 ret = __iw_set_power_mode(dev, info, wrqu, extra);
3988 cds_ssr_unprotect(__func__);
3989
3990 return ret;
3991}
3992
3993/**
3994 * __iw_get_range() - SIOCGIWRANGE ioctl handler
3995 * @dev: device upon which the ioctl was received
3996 * @info: ioctl request information
3997 * @wrqu: ioctl request data
3998 * @extra: ioctl extra data
3999 *
4000 * Return: 0 on success, non-zero on error
4001 */
4002static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
4003 union iwreq_data *wrqu, char *extra)
4004{
4005 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4006 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4007 struct iw_range *range = (struct iw_range *)extra;
4008
4009 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4010
4011 uint32_t num_channels = sizeof(channels);
4012 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4013 uint32_t a_len;
4014 uint32_t b_len;
4015 uint32_t active_phy_mode = 0;
4016 uint8_t index = 0, i;
4017 hdd_context_t *hdd_ctx;
4018 int ret;
4019
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004020 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021
4022 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4023 ret = wlan_hdd_validate_context(hdd_ctx);
4024 if (0 != ret)
4025 return ret;
4026
4027 wrqu->data.length = sizeof(struct iw_range);
4028 memset(range, 0, sizeof(struct iw_range));
4029
4030
4031 /*Get the phy mode */
4032 if (sme_cfg_get_int(hHal,
4033 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304034 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004035 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036
4037 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
4038 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
4039 /*Get the supported rates for 11G band */
4040 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4041 if (sme_cfg_get_str(hHal,
4042 WNI_CFG_SUPPORTED_RATES_11A,
4043 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304044 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
4046 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4047 }
4048 for (i = 0; i < a_len; i++) {
4049 range->bitrate[i] =
4050 ((supp_rates[i] & 0x7F) / 2) *
4051 1000000;
4052 }
4053 range->num_bitrates = a_len;
4054 } else {
4055 return -EIO;
4056 }
4057 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
4058 /*Get the supported rates for 11B band */
4059 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4060 if (sme_cfg_get_str(hHal,
4061 WNI_CFG_SUPPORTED_RATES_11B,
4062 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304063 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
4065 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4066 }
4067 for (i = 0; i < b_len; i++) {
4068 range->bitrate[i] =
4069 ((supp_rates[i] & 0x7F) / 2) *
4070 1000000;
4071 }
4072 range->num_bitrates = b_len;
4073 } else {
4074 return -EIO;
4075 }
4076 }
4077 }
4078
4079 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
4080 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
4081 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
4082
4083 range->encoding_size[0] = 5;
4084 range->encoding_size[1] = 13;
4085 range->num_encoding_sizes = 2;
4086 range->max_encoding_tokens = MAX_WEP_KEYS;
4087
4088 /* we support through Wireless Extensions 22 */
4089 range->we_version_compiled = WIRELESS_EXT;
4090 range->we_version_source = 22;
4091
4092 /*Supported Channels and Frequencies */
4093 if (sme_cfg_get_str
4094 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304095 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004096 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097 return -EIO;
4098 }
4099 if (num_channels > IW_MAX_FREQUENCIES) {
4100 num_channels = IW_MAX_FREQUENCIES;
4101 }
4102
4103 range->num_channels = num_channels;
4104 range->num_frequency = num_channels;
4105
4106 for (index = 0; index < num_channels; index++) {
4107 uint32_t frq_indx = 0;
4108
4109 range->freq[index].i = channels[index];
4110 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
4111 if (channels[index] == freq_chan_map[frq_indx].chan) {
4112 range->freq[index].m =
4113 freq_chan_map[frq_indx].freq * 100000;
4114 range->freq[index].e = 1;
4115 break;
4116 }
4117 frq_indx++;
4118 }
4119 }
4120
4121 /* Event capability (kernel + driver) */
4122 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
4123 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
4124 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
4125 range->event_capa[1] = IW_EVENT_CAPA_K_1;
4126
4127 /*Encryption capability */
4128 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
4129 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
4130
4131 /* Txpower capability */
4132 range->txpower_capa = IW_TXPOW_MWATT;
4133
4134 /*Scanning capability */
4135#if WIRELESS_EXT >= 22
4136 range->scan_capa =
4137 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
4138#endif
4139
4140 EXIT();
4141 return 0;
4142}
4143
4144/**
4145 * iw_get_range() - SSR wrapper for __iw_get_range()
4146 * @dev: pointer to net_device
4147 * @info: pointer to iw_request_info
4148 * @wrqu: pointer to iwreq_data
4149 * @extra: pointer to extra ioctl payload
4150 *
4151 * Return: 0 on success, error number otherwise
4152 */
4153static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
4154 union iwreq_data *wrqu, char *extra)
4155{
4156 int ret;
4157
4158 cds_ssr_protect(__func__);
4159 ret = __iw_get_range(dev, info, wrqu, extra);
4160 cds_ssr_unprotect(__func__);
4161
4162 return ret;
4163}
4164
4165/**
4166 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
4167 * @pStats: pointer to Class A stats
4168 * @pContext: user context originally registered with SME
4169 *
4170 * Return: None
4171 */
4172static void hdd_get_class_a_statistics_cb(void *pStats, void *pContext)
4173{
4174 struct statsContext *pStatsContext;
4175 tCsrGlobalClassAStatsInfo *pClassAStats;
4176 hdd_adapter_t *pAdapter;
4177
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004179 hdd_err("Bad param, pStats [%p] pContext [%p]",
4180 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 return;
4182 }
4183
4184 pClassAStats = pStats;
4185 pStatsContext = pContext;
4186 pAdapter = pStatsContext->pAdapter;
4187
4188 /* there is a race condition that exists between this callback
4189 * function and the caller since the caller could time out
4190 * either before or while this code is executing. we use a
4191 * spinlock to serialize these actions
4192 */
4193 spin_lock(&hdd_context_lock);
4194
4195 if ((NULL == pAdapter) ||
4196 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
4197 /* the caller presumably timed out so there is nothing
4198 * we can do
4199 */
4200 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07004201 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
4202 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 return;
4204 }
4205
4206 /* context is valid so caller is still waiting */
4207
4208 /* paranoia: invalidate the magic */
4209 pStatsContext->magic = 0;
4210
4211 /* copy over the stats. do so as a struct copy */
4212 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
4213
4214 /* notify the caller */
4215 complete(&pStatsContext->completion);
4216
4217 /* serialization is complete */
4218 spin_unlock(&hdd_context_lock);
4219}
4220
4221/**
4222 * wlan_hdd_get_class_astats() - Get Class A statistics
4223 * @pAdapter: adapter for which statistics are desired
4224 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304225 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304227QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228{
4229 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304230 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 unsigned long rc;
Houston Hoffman59c097f2016-11-09 15:50:25 -08004232 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233
4234 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004235 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304236 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08004238 if (cds_is_driver_recovering()) {
4239 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
4240 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304241 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004242 }
4243
4244 /* we are connected so prepare our callback context */
4245 init_completion(&context.completion);
4246 context.pAdapter = pAdapter;
4247 context.magic = STATS_CONTEXT_MAGIC;
4248 /* query only for Class A statistics (which include link speed) */
4249 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4250 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
4251 hdd_get_class_a_statistics_cb,
4252 0, /* not periodic */
4253 false, /* non-cached results */
4254 pHddStaCtx->conn_info.staId[0],
4255 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304256 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07004257 hdd_warn("Unable to retrieve Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 /* we'll returned a cached value below */
4259 } else {
4260 /* request was sent -- wait for the response */
4261 rc = wait_for_completion_timeout
4262 (&context.completion,
4263 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4264 if (!rc) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07004265 hdd_warn("SME timed out while retrieving Class A statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266 }
4267 }
4268
4269 /* either we never sent a request, we sent a request and
4270 * received a response or we sent a request and timed out. if
4271 * we never sent a request or if we sent a request and got a
4272 * response, we want to clear the magic out of paranoia. if
4273 * we timed out there is a race condition such that the
4274 * callback function could be executing at the same time we
4275 * are. of primary concern is if the callback function had
4276 * already verified the "magic" but had not yet set the
4277 * completion variable when a timeout occurred. we serialize
4278 * these activities by invalidating the magic while holding a
4279 * shared spinlock which will cause us to block if the
4280 * callback is currently executing
4281 */
4282 spin_lock(&hdd_context_lock);
4283 context.magic = 0;
4284 spin_unlock(&hdd_context_lock);
4285
4286 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304287 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288}
4289
4290/**
4291 * hdd_get_station_statistics_cb() - Get stats callback function
4292 * @pStats: pointer to Class A stats
4293 * @pContext: user context originally registered with SME
4294 *
4295 * Return: None
4296 */
4297static void hdd_get_station_statistics_cb(void *pStats, void *pContext)
4298{
4299 struct statsContext *pStatsContext;
4300 tCsrSummaryStatsInfo *pSummaryStats;
4301 tCsrGlobalClassAStatsInfo *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304302 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004303 hdd_adapter_t *pAdapter;
4304
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 if ((NULL == pStats) || (NULL == pContext)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004306 hdd_err("Bad param, pStats [%p] pContext [%p]",
4307 pStats, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 return;
4309 }
4310
4311 /* there is a race condition that exists between this callback
4312 * function and the caller since the caller could time out
4313 * either before or while this code is executing. we use a
4314 * spinlock to serialize these actions
4315 */
4316 spin_lock(&hdd_context_lock);
4317
4318 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
4319 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304320 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
4321 (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 pStatsContext = pContext;
4323 pAdapter = pStatsContext->pAdapter;
4324 if ((NULL == pAdapter) ||
4325 (STATS_CONTEXT_MAGIC != pStatsContext->magic)) {
4326 /* the caller presumably timed out so there is nothing
4327 * we can do
4328 */
4329 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07004330 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
4331 pAdapter, pStatsContext->magic);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004332 return;
4333 }
4334
4335 /* context is valid so caller is still waiting */
4336
4337 /* paranoia: invalidate the magic */
4338 pStatsContext->magic = 0;
4339
4340 /* copy over the stats. do so as a struct copy */
4341 pAdapter->hdd_stats.summary_stat = *pSummaryStats;
4342 pAdapter->hdd_stats.ClassA_stat = *pClassAStats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304343 pAdapter->hdd_stats.per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344
4345 /* notify the caller */
4346 complete(&pStatsContext->completion);
4347
4348 /* serialization is complete */
4349 spin_unlock(&hdd_context_lock);
4350}
4351
4352/**
4353 * wlan_hdd_get_station_stats() - Get station statistics
4354 * @pAdapter: adapter for which statistics are desired
4355 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304356 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004357 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304358QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359{
4360 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304361 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 unsigned long rc;
Jeff Johnson5aacdf92016-11-04 18:08:11 -07004363 static struct statsContext context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364
4365 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004366 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304367 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368 }
4369
4370 /* we are connected so prepare our callback context */
4371 init_completion(&context.completion);
4372 context.pAdapter = pAdapter;
4373 context.magic = STATS_CONTEXT_MAGIC;
4374
4375 /* query only for Summary & Class A statistics */
4376 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4377 eCSR_HDD,
4378 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304379 SME_GLOBAL_CLASSA_STATS |
4380 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 hdd_get_station_statistics_cb,
4382 0, /* not periodic */
4383 false, /* non-cached results */
4384 pHddStaCtx->conn_info.staId[0],
4385 &context, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304386 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004387 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388 /* we'll return with cached values */
4389 } else {
4390 /* request was sent -- wait for the response */
4391 rc = wait_for_completion_timeout
4392 (&context.completion,
4393 msecs_to_jiffies(WLAN_WAIT_TIME_STATS));
4394
4395 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004396 hdd_err("SME timed out while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004397 }
4398 }
4399
4400 /* either we never sent a request, we sent a request and
4401 * received a response or we sent a request and timed out. if
4402 * we never sent a request or if we sent a request and got a
4403 * response, we want to clear the magic out of paranoia. if
4404 * we timed out there is a race condition such that the
4405 * callback function could be executing at the same time we
4406 * are. of primary concern is if the callback function had
4407 * already verified the "magic" but had not yet set the
4408 * completion variable when a timeout occurred. we serialize
4409 * these activities by invalidating the magic while holding a
4410 * shared spinlock which will cause us to block if the
4411 * callback is currently executing
4412 */
4413 spin_lock(&hdd_context_lock);
4414 context.magic = 0;
4415 spin_unlock(&hdd_context_lock);
4416
4417 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304418 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419}
4420
4421/**
4422 * iw_get_linkspeed() - Get current link speed ioctl
4423 * @dev: device upon which the ioctl was received
4424 * @info: ioctl request information
4425 * @wrqu: ioctl request data
4426 * @extra: extra ioctl buffer
4427 *
4428 * Return: 0 on success, non-zero on error
4429 */
4430static int __iw_get_linkspeed(struct net_device *dev,
4431 struct iw_request_info *info,
4432 union iwreq_data *wrqu, char *extra)
4433{
4434 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4435 char *pLinkSpeed = (char *)extra;
4436 int len = sizeof(uint32_t) + 1;
4437 uint32_t link_speed = 0;
4438 hdd_context_t *hdd_ctx;
4439 int rc, valid;
4440
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08004441 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05304442
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4444 valid = wlan_hdd_validate_context(hdd_ctx);
4445 if (0 != valid)
4446 return valid;
4447
4448 rc = wlan_hdd_get_link_speed(pAdapter, &link_speed);
4449 if (0 != rc) {
4450 return rc;
4451 }
4452
4453 wrqu->data.length = len;
4454 /* return the linkspeed as a string */
4455 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
4456 if ((rc < 0) || (rc >= len)) {
4457 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07004458 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459 return -EIO;
4460 }
4461
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05304462 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463 /* a value is being successfully returned */
4464 return 0;
4465}
4466
4467static int iw_get_linkspeed(struct net_device *dev,
4468 struct iw_request_info *info,
4469 union iwreq_data *wrqu, char *extra)
4470{
4471 int ret;
4472
4473 cds_ssr_protect(__func__);
4474 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
4475 cds_ssr_unprotect(__func__);
4476
4477 return ret;
4478}
4479
4480/**
4481 * wlan_hdd_change_country_code_callback() - Change country code callback
4482 * @context: opaque context originally passed to SME. All functions
4483 * which use this callback pass the adapter upon which the country
4484 * code change is active
4485 *
4486 * This function is registered as the callback function when
4487 * sme_change_country_code() is invoked. Callers of
4488 * sme_change_country_code() subsequently wait for the adapter's
4489 * @change_country_code completion variable, so all this function
4490 * needs to do is set that completion variable so that execution can
4491 * continue.
4492 *
4493 * Return: none
4494 */
4495void wlan_hdd_change_country_code_callback(void *context)
4496{
4497
4498 hdd_adapter_t *adapter = context;
4499
4500 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
4501 complete(&adapter->change_country_code);
4502
4503 return;
4504}
4505
4506/**
4507 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
4508 * @dev: device upon which the ioctl was received
4509 * @info: ioctl request information
4510 * @wrqu: ioctl request data
4511 * @extra: ioctl extra data
4512 *
4513 * Return: 0 on success, non-zero on error
4514 */
4515static int __iw_set_nick(struct net_device *dev,
4516 struct iw_request_info *info,
4517 union iwreq_data *wrqu, char *extra)
4518{
4519 hdd_adapter_t *adapter;
4520 hdd_context_t *hdd_ctx;
4521 int ret;
4522
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004523 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524
4525 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4526 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4527 ret = wlan_hdd_validate_context(hdd_ctx);
4528 if (0 != ret)
4529 return ret;
4530
4531 return 0;
4532}
4533
4534/**
4535 * iw_set_nick() - SSR wrapper for __iw_set_nick
4536 * @dev: pointer to net_device
4537 * @info: pointer to iw_request_info
4538 * @wrqu: pointer to iwreq_data
4539 * @extra: extra
4540 *
4541 * Return: 0 on success, error number otherwise
4542 */
4543static int iw_set_nick(struct net_device *dev,
4544 struct iw_request_info *info,
4545 union iwreq_data *wrqu, char *extra)
4546{
4547 int ret;
4548
4549 cds_ssr_protect(__func__);
4550 ret = __iw_set_nick(dev, info, wrqu, extra);
4551 cds_ssr_unprotect(__func__);
4552
4553 return ret;
4554}
4555
4556/**
4557 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
4558 * @dev: device upon which the ioctl was received
4559 * @info: ioctl request information
4560 * @wrqu: ioctl request data
4561 * @extra: ioctl extra data
4562 *
4563 * Return: 0 on success, non-zero on error
4564 */
4565static int __iw_get_nick(struct net_device *dev,
4566 struct iw_request_info *info,
4567 union iwreq_data *wrqu, char *extra)
4568{
4569 hdd_adapter_t *adapter;
4570 hdd_context_t *hdd_ctx;
4571 int ret;
4572
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004573 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574
4575 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4576 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4577 ret = wlan_hdd_validate_context(hdd_ctx);
4578 if (0 != ret)
4579 return ret;
4580
4581 return 0;
4582}
4583
4584/**
4585 * iw_get_nick() - SSR wrapper for __iw_get_nick
4586 * @dev: pointer to net_device
4587 * @info: pointer to iw_request_info
4588 * @wrqu: pointer to iwreq_data
4589 * @extra: extra
4590 *
4591 * Return: 0 on success, error number otherwise
4592 */
4593static int iw_get_nick(struct net_device *dev,
4594 struct iw_request_info *info,
4595 union iwreq_data *wrqu, char *extra)
4596{
4597 int ret;
4598
4599 cds_ssr_protect(__func__);
4600 ret = __iw_get_nick(dev, info, wrqu, extra);
4601 cds_ssr_unprotect(__func__);
4602
4603 return ret;
4604}
4605
4606/**
4607 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
4608 * @dev: device upon which the ioctl was received
4609 * @info: ioctl request information
4610 * @wrqu: ioctl request data
4611 * @extra: ioctl extra data
4612 *
4613 * Return: 0 on success, non-zero on error
4614 */
4615static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4616 union iwreq_data *wrqu, char *extra)
4617{
4618 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4619 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4620 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4621 hdd_context_t *hdd_ctx;
4622 struct iw_point *encoderq = &(wrqu->encoding);
4623 uint32_t keyId;
4624 uint8_t key_length;
4625 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4626 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304627 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628 int ret;
4629
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004630 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631
4632 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4633 ret = wlan_hdd_validate_context(hdd_ctx);
4634 if (0 != ret)
4635 return ret;
4636
4637 keyId = encoderq->flags & IW_ENCODE_INDEX;
4638
4639 if (keyId) {
4640 if (keyId > MAX_WEP_KEYS) {
4641 return -EINVAL;
4642 }
4643
4644 fKeyPresent = 1;
4645 keyId--;
4646 } else {
4647 fKeyPresent = 0;
4648 }
4649
4650 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004651 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08004653 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
4654 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 }
4656 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4657 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4658 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4659 eCSR_ENCRYPT_TYPE_NONE;
4660 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4661 eCSR_ENCRYPT_TYPE_NONE;
4662
4663 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4664 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4665
4666 if (eConnectionState_Associated ==
4667 pHddStaCtx->conn_info.connState) {
4668 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4669 status =
4670 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4671 pAdapter->sessionId,
4672 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304673 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674 unsigned long rc;
4675 rc = wait_for_completion_timeout(&pAdapter->
4676 disconnect_comp_var,
4677 msecs_to_jiffies
4678 (WLAN_WAIT_TIME_DISCONNECT));
4679 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004680 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 }
4682 }
4683
4684 return status;
4685
4686 }
4687
4688 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004689 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690
4691 pHddStaCtx->conn_info.authType =
4692 (encoderq->
4693 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
4694 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4695
4696 }
4697
4698 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004699 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700
4701 key_length = wrqu->data.length;
4702
4703 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
4704
4705 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004706 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 key_length);
4708
4709 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4710 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4711 pHddStaCtx->conn_info.authType)) {
4712 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4713 } else {
4714 encryptionType =
4715 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4716 }
4717 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004718 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 key_length);
4720
4721 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
4722 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4723 pHddStaCtx->conn_info.authType)) {
4724 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4725 } else {
4726 encryptionType =
4727 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4728 }
4729 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07004730 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731 key_length);
4732 return -EINVAL;
4733 }
4734
4735 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4736 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4737 pWextState->roamProfile.EncryptionType.numEntries = 1;
4738 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4739 encryptionType;
4740 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4741 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4742 encryptionType;
4743
4744 if ((eConnectionState_NotConnected ==
4745 pHddStaCtx->conn_info.connState)
4746 &&
4747 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
4748 pHddStaCtx->conn_info.authType)
4749 || (eCSR_AUTH_TYPE_SHARED_KEY ==
4750 pHddStaCtx->conn_info.authType))) {
4751
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304752 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753 KeyMaterial[keyId][0], extra, key_length);
4754
4755 pWextState->roamProfile.Keys.KeyLength[keyId] =
4756 (uint8_t) key_length;
4757 pWextState->roamProfile.Keys.defaultIndex =
4758 (uint8_t) keyId;
4759
4760 return status;
4761 }
4762 }
4763
4764 return 0;
4765}
4766
4767/**
4768 * iw_set_encode() - SSR wrapper for __iw_set_encode()
4769 * @dev: pointer to net_device
4770 * @info: pointer to iw_request_info
4771 * @wrqu: pointer to iwreq_data
4772 * @extra: pointer to extra ioctl payload
4773 *
4774 * Return: 0 on success, error number otherwise
4775 */
4776static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
4777 union iwreq_data *wrqu, char *extra)
4778{
4779 int ret;
4780
4781 cds_ssr_protect(__func__);
4782 ret = __iw_set_encode(dev, info, wrqu, extra);
4783 cds_ssr_unprotect(__func__);
4784
4785 return ret;
4786}
4787
4788/**
4789 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
4790 * @dev: device upon which the ioctl was received
4791 * @info: ioctl request information
4792 * @wrqu: ioctl request data
4793 * @extra: ioctl extra data
4794 *
4795 * Return: 0 on success, non-zero on error
4796 */
4797static int __iw_get_encodeext(struct net_device *dev,
4798 struct iw_request_info *info,
4799 struct iw_point *dwrq, char *extra)
4800{
4801 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4802 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4803 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4804 int keyId;
4805 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4806 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4807 int i, ret;
4808 hdd_context_t *hdd_ctx;
4809
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004810 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811
4812 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4813 ret = wlan_hdd_validate_context(hdd_ctx);
4814 if (0 != ret)
4815 return ret;
4816
4817 keyId = pRoamProfile->Keys.defaultIndex;
4818
4819 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004820 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004821 return -EINVAL;
4822 }
4823
4824 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
4825 dwrq->flags |= IW_ENCODE_ENABLED;
4826 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304827 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828 pRoamProfile->Keys.KeyLength[keyId]);
4829 } else {
4830 dwrq->flags |= IW_ENCODE_DISABLED;
4831 }
4832
4833 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08004834 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 continue;
4836 } else {
4837 break;
4838 }
4839 }
4840
4841 if (MAX_WEP_KEYS == i) {
4842 dwrq->flags |= IW_ENCODE_NOKEY;
4843 } else {
4844 dwrq->flags |= IW_ENCODE_ENABLED;
4845 }
4846
4847 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
4848
4849 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
4850 dwrq->flags |= IW_ENCODE_DISABLED;
4851 }
4852
4853 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
4854
4855 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
4856 dwrq->flags |= IW_ENCODE_OPEN;
4857 } else {
4858 dwrq->flags |= IW_ENCODE_RESTRICTED;
4859 }
4860 EXIT();
4861 return 0;
4862
4863}
4864
4865/**
4866 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
4867 * @dev: pointer to net_device
4868 * @info: pointer to iw_request_info
4869 * @dwrq: pointer to encoding information
4870 * @extra: pointer to extra ioctl payload
4871 *
4872 * Return: 0 on success, error number otherwise
4873 */
4874static int iw_get_encodeext(struct net_device *dev,
4875 struct iw_request_info *info,
4876 struct iw_point *dwrq, char *extra)
4877{
4878 int ret;
4879
4880 cds_ssr_protect(__func__);
4881 ret = __iw_get_encodeext(dev, info, dwrq, extra);
4882 cds_ssr_unprotect(__func__);
4883
4884 return ret;
4885}
4886
4887/**
4888 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
4889 * @dev: device upon which the ioctl was received
4890 * @info: ioctl request information
4891 * @wrqu: ioctl request data
4892 * @extra: ioctl extra data
4893 *
4894 * Return: 0 on success, non-zero on error
4895 */
4896static int __iw_set_encodeext(struct net_device *dev,
4897 struct iw_request_info *info,
4898 union iwreq_data *wrqu, char *extra)
4899{
4900 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4901 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4902 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4903 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304904 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4906 int ret;
4907 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
4908 int key_index;
4909 struct iw_point *encoding = &wrqu->encoding;
4910 tCsrRoamSetKey setKey;
4911 uint32_t roamId = 0xFF;
4912
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004913 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914
4915 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4916 ret = wlan_hdd_validate_context(hdd_ctx);
4917 if (0 != ret)
4918 return ret;
4919
4920 key_index = encoding->flags & IW_ENCODE_INDEX;
4921
4922 if (key_index > 0) {
4923
4924 /*Convert from 1-based to 0-based keying */
4925 key_index--;
4926 }
4927 if (!ext->key_len) {
4928
4929 /*Set the encrytion type to NONE */
4930 pRoamProfile->EncryptionType.encryptionType[0] =
4931 eCSR_ENCRYPT_TYPE_NONE;
4932 return ret;
4933 }
4934
4935 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
4936 (IW_ENCODE_ALG_WEP == ext->alg)) {
4937 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
4938
Jeff Johnson99bac312016-06-28 10:38:18 -07004939 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004940 return -EINVAL;
4941 } else {
4942 /*Static wep, update the roam profile with the keys */
Yingying Tang3cc6b792016-10-20 17:00:37 +08004943 if (ext->key_len
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 && (ext->key_len <=
4945 eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES)
4946 && key_index < CSR_MAX_NUM_KEY) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304947 qdf_mem_copy(&pRoamProfile->Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948 KeyMaterial[key_index][0],
4949 ext->key, ext->key_len);
4950 pRoamProfile->Keys.KeyLength[key_index] =
4951 (uint8_t) ext->key_len;
4952
4953 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
4954 pRoamProfile->Keys.defaultIndex =
4955 (uint8_t) key_index;
4956
4957 }
4958 }
4959 return ret;
4960 }
4961
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304962 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004963
4964 setKey.keyId = key_index;
4965 setKey.keyLength = ext->key_len;
4966
4967 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304968 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969 }
4970
4971 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
4972 /*Key direction for group is RX only */
4973 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05304974 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004975 } else {
4976
4977 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304978 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304979 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 }
4981
4982 /*For supplicant pae role is zero */
4983 setKey.paeRole = 0;
4984
4985 switch (ext->alg) {
4986 case IW_ENCODE_ALG_NONE:
4987 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
4988 break;
4989
4990 case IW_ENCODE_ALG_WEP:
4991 setKey.encType =
4992 (ext->key_len ==
4993 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
4994 break;
4995
4996 case IW_ENCODE_ALG_TKIP:
4997 {
4998 uint8_t *pKey = &setKey.Key[0];
4999
5000 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5001
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305002 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005003
5004 /* Supplicant sends the 32bytes key in this order
5005 * |--------------|----------|----------|
5006 * | Tk1 | TX MIC | RX MIC |
5007 * |--------------|----------|----------|
5008 * <---16bytes---><--8bytes--><--8bytes-->
5009 *
5010 *
5011 * Sme expects the 32 bytes key to be in the below order
5012 * |--------------|----------|----------|
5013 * | Tk1 | RX MIC | TX MIC |
5014 * |--------------|----------|----------|
5015 * <---16bytes---><--8bytes--><--8bytes-->
5016 */
5017
5018 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305019 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005020
5021 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305022 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005023
5024 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305025 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005026
5027 }
5028 break;
5029
5030 case IW_ENCODE_ALG_CCMP:
5031 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5032 break;
5033
5034#ifdef FEATURE_WLAN_ESE
5035#define IW_ENCODE_ALG_KRK 6
5036 case IW_ENCODE_ALG_KRK:
5037 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5038 break;
5039#endif /* FEATURE_WLAN_ESE */
5040
5041 default:
5042 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5043 break;
5044 }
5045
Jeff Johnson99bac312016-06-28 10:38:18 -07005046 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
5047 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005049 /* The supplicant may attempt to set the PTK once
5050 * pre-authentication is done. Save the key in the UMAC and
5051 * include it in the ADD BSS request
5052 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305053 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005054 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305055 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005056 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005057 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305058 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005059 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 return -EINVAL;
5061 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005062
5063 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5064
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305065 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005066 pAdapter->sessionId,
5067 &setKey, &roamId);
5068
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305069 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005070 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305071 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005072
5073 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5074 }
5075
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305076 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077}
5078
5079/**
5080 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
5081 * @dev: pointer to net_device
5082 * @info: pointer to iw_request_info
5083 * @wrqu: pointer to iwreq_data
5084 * @extra: pointer to extra ioctl payload
5085 *
5086 * Return: 0 on success, error number otherwise
5087 */
5088static int iw_set_encodeext(struct net_device *dev,
5089 struct iw_request_info *info,
5090 union iwreq_data *wrqu, char *extra)
5091{
5092 int ret;
5093
5094 cds_ssr_protect(__func__);
5095 ret = __iw_set_encodeext(dev, info, wrqu, extra);
5096 cds_ssr_unprotect(__func__);
5097
5098 return ret;
5099}
5100
5101/**
5102 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
5103 * @dev: device upon which the ioctl was received
5104 * @info: ioctl request information
5105 * @wrqu: ioctl request data
5106 * @extra: ioctl extra data
5107 *
5108 * Return: 0 on success, non-zero on error
5109 */
5110static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
5111 union iwreq_data *wrqu, char *extra)
5112{
5113 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5114 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5115 hdd_context_t *hdd_ctx;
5116 int ret;
5117
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005118 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119
5120 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5121 ret = wlan_hdd_validate_context(hdd_ctx);
5122 if (0 != ret)
5123 return ret;
5124
5125 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
5126 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
5127
Jeff Johnson99bac312016-06-28 10:38:18 -07005128 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129
5130 return -EINVAL;
5131 }
5132
5133 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
5134
5135 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
5136 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
5137 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305138 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005139 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005140 return -EIO;
5141 }
5142 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
5143 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
5144 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305145 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05305146 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 return -EIO;
5148 }
5149 }
5150 } else {
5151 return -EOPNOTSUPP;
5152 }
5153
Jeff Johnson99bac312016-06-28 10:38:18 -07005154 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155
5156 EXIT();
5157
5158 return 0;
5159
5160}
5161
5162/**
5163 * iw_set_retry() - SSR wrapper for __iw_set_retry()
5164 * @dev: pointer to net_device
5165 * @info: pointer to iw_request_info
5166 * @wrqu: pointer to iwreq_data
5167 * @extra: pointer to extra ioctl payload
5168 *
5169 * Return: 0 on success, error number otherwise
5170 */
5171static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
5172 union iwreq_data *wrqu, char *extra)
5173{
5174 int ret;
5175
5176 cds_ssr_protect(__func__);
5177 ret = __iw_set_retry(dev, info, wrqu, extra);
5178 cds_ssr_unprotect(__func__);
5179
5180 return ret;
5181}
5182
5183/**
5184 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
5185 * @dev: device upon which the ioctl was received
5186 * @info: ioctl request information
5187 * @wrqu: ioctl request data
5188 * @extra: ioctl extra data
5189 *
5190 * Return: 0 on success, non-zero on error
5191 */
5192static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
5193 union iwreq_data *wrqu, char *extra)
5194{
5195 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5196 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5197 uint32_t retry = 0;
5198 hdd_context_t *hdd_ctx;
5199 int ret;
5200
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005201 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202
5203 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5204 ret = wlan_hdd_validate_context(hdd_ctx);
5205 if (0 != ret)
5206 return ret;
5207
5208 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
5209 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
5210
5211 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305212 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005213 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005214 return -EIO;
5215 }
5216
5217 wrqu->retry.value = retry;
5218 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
5219 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
5220
5221 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305222 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05305223 hdd_warn("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224 return -EIO;
5225 }
5226
5227 wrqu->retry.value = retry;
5228 } else {
5229 return -EOPNOTSUPP;
5230 }
5231
Jeff Johnson99bac312016-06-28 10:38:18 -07005232 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005233
5234 EXIT();
5235
5236 return 0;
5237}
5238
5239/**
5240 * iw_get_retry() - SSR wrapper for __iw_get_retry()
5241 * @dev: pointer to net_device
5242 * @info: pointer to iw_request_info
5243 * @wrqu: pointer to iwreq_data
5244 * @extra: pointer to extra ioctl payload
5245 *
5246 * Return: 0 on success, error number otherwise
5247 */
5248static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
5249 union iwreq_data *wrqu, char *extra)
5250{
5251 int ret;
5252
5253 cds_ssr_protect(__func__);
5254 ret = __iw_get_retry(dev, info, wrqu, extra);
5255 cds_ssr_unprotect(__func__);
5256
5257 return ret;
5258}
5259
5260/**
5261 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
5262 * @dev: device upon which the ioctl was received
5263 * @info: ioctl request information
5264 * @wrqu: ioctl request data
5265 * @extra: ioctl extra data
5266 *
5267 * Return: 0 on success, non-zero on error
5268 */
5269static int __iw_set_mlme(struct net_device *dev,
5270 struct iw_request_info *info,
5271 union iwreq_data *wrqu, char *extra)
5272{
5273 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5274 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5275 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305276 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005277 hdd_context_t *hdd_ctx;
5278 int ret;
5279
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005280 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281
5282 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5283 ret = wlan_hdd_validate_context(hdd_ctx);
5284 if (0 != ret)
5285 return ret;
5286
5287 /* reason_code is unused. By default it is set to
5288 * eCSR_DISCONNECT_REASON_UNSPECIFIED
5289 */
5290 switch (mlme->cmd) {
5291 case IW_MLME_DISASSOC:
5292 case IW_MLME_DEAUTH:
5293
5294 if (pHddStaCtx->conn_info.connState ==
5295 eConnectionState_Associated) {
5296 eCsrRoamDisconnectReason reason =
5297 eCSR_DISCONNECT_REASON_UNSPECIFIED;
5298
5299 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
5300 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
5301
5302 INIT_COMPLETION(pAdapter->disconnect_comp_var);
5303 status =
5304 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
5305 pAdapter->sessionId, reason);
5306
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305307 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308 unsigned long rc;
5309 rc = wait_for_completion_timeout(&pAdapter->
5310 disconnect_comp_var,
5311 msecs_to_jiffies
5312 (WLAN_WAIT_TIME_DISCONNECT));
5313 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07005314 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07005316 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
5317 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318
5319 /* Resetting authKeyMgmt */
5320 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
5321 0;
5322
Jeff Johnson99bac312016-06-28 10:38:18 -07005323 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324 wlan_hdd_netif_queue_control(pAdapter,
5325 WLAN_NETIF_TX_DISABLE_N_CARRIER,
5326 WLAN_CONTROL_PATH);
5327
5328 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07005329 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
5330 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331 }
5332 break;
5333 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005334 hdd_err("%d Command should be Disassociate/Deauthenticate",
5335 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336 return -EINVAL;
5337 } /* end of switch */
5338
5339 EXIT();
5340
5341 return status;
5342
5343}
5344
5345/**
5346 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
5347 * @dev: pointer to net_device
5348 * @info: pointer to iw_request_info
5349 * @wrqu: pointer to iwreq_data
5350 * @extra: pointer to extra ioctl payload
5351 *
5352 * Return: 0 on success, error number otherwise
5353 */
5354static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
5355 union iwreq_data *wrqu, char *extra)
5356{
5357 int ret;
5358
5359 cds_ssr_protect(__func__);
5360 ret = __iw_set_mlme(dev, info, wrqu, extra);
5361 cds_ssr_unprotect(__func__);
5362
5363 return ret;
5364}
5365
5366/**
5367 * wlan_hdd_update_phymode() - handle change in PHY mode
5368 * @net: device upon which PHY mode change was received
5369 * @hal: umac handle for the driver
5370 * @new_phymode: new PHY mode for the device
5371 * @phddctx: pointer to the HDD context
5372 *
5373 * This function is called when the device is set to a new PHY mode.
5374 * It takes a holistic look at the desired PHY mode along with the
5375 * configured capabilities of the driver and the reported capabilities
5376 * of the hardware in order to correctly configure all PHY-related
5377 * parameters.
5378 *
5379 * Return: 0 on success, negative errno value on error
5380 */
5381int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
5382 int new_phymode, hdd_context_t *phddctx)
5383{
5384#ifdef QCA_HT_2040_COEX
5385 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305386 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387#endif
5388 bool band_24 = false, band_5g = false;
5389 bool ch_bond24 = false, ch_bond5g = false;
5390 tSmeConfigParams smeconfig;
5391 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005392 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005393 eCsrPhyMode phymode = -EIO, old_phymode;
5394 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
5395 eCsrBand curr_band = eCSR_BAND_ALL;
5396
5397 old_phymode = sme_get_phy_mode(hal);
5398
5399 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5400 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5401 nChannelBondingMode24GHz))
5402 ch_bond24 = true;
5403
5404 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5405 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5406 nChannelBondingMode5GHz))
5407 ch_bond5g = true;
5408
5409 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
5410 band_24 = band_5g = true;
5411 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
5412 band_24 = true;
5413 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
5414 band_5g = true;
5415 }
5416
5417 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07005418 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 -08005419 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
5420
5421 switch (new_phymode) {
5422 case IEEE80211_MODE_AUTO:
5423 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
5424 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
5425 phymode = eCSR_DOT11_MODE_AUTO;
5426 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5427 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5428 curr_band = eCSR_BAND_ALL;
5429 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5430 } else {
5431 sme_set_phy_mode(hal, old_phymode);
5432 return -EIO;
5433 }
5434 break;
5435 case IEEE80211_MODE_11A:
5436 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
5437 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5438 phymode = eCSR_DOT11_MODE_11a;
5439 hdd_dot11mode = eHDD_DOT11_MODE_11a;
5440 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5441 curr_band = eCSR_BAND_5G;
5442 } else {
5443 sme_set_phy_mode(hal, old_phymode);
5444 return -EIO;
5445 }
5446 break;
5447 case IEEE80211_MODE_11B:
5448 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
5449 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5450 phymode = eCSR_DOT11_MODE_11b;
5451 hdd_dot11mode = eHDD_DOT11_MODE_11b;
5452 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5453 curr_band = eCSR_BAND_24;
5454 } else {
5455 sme_set_phy_mode(hal, old_phymode);
5456 return -EIO;
5457 }
5458 break;
5459 case IEEE80211_MODE_11G:
5460 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
5461 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5462 phymode = eCSR_DOT11_MODE_11g;
5463 hdd_dot11mode = eHDD_DOT11_MODE_11g;
5464 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5465 curr_band = eCSR_BAND_24;
5466 } else {
5467 sme_set_phy_mode(hal, old_phymode);
5468 return -EIO;
5469 }
5470 break;
5471 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
5472 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
5473 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
5474 */
5475 case IEEE80211_MODE_11NA_HT20:
5476 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5477 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5478 phymode = eCSR_DOT11_MODE_11n;
5479 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5480 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5481 curr_band = eCSR_BAND_5G;
5482 } else {
5483 sme_set_phy_mode(hal, old_phymode);
5484 return -EIO;
5485 }
5486 break;
5487 case IEEE80211_MODE_11NA_HT40:
5488 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5489 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5490 phymode = eCSR_DOT11_MODE_11n;
5491 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5492 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5493 curr_band = eCSR_BAND_5G;
5494 } else {
5495 sme_set_phy_mode(hal, old_phymode);
5496 return -EIO;
5497 }
5498 break;
5499 case IEEE80211_MODE_11NG_HT20:
5500 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5501 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5502 phymode = eCSR_DOT11_MODE_11n;
5503 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5504 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5505 curr_band = eCSR_BAND_24;
5506 } else {
5507 sme_set_phy_mode(hal, old_phymode);
5508 return -EIO;
5509 }
5510 break;
5511 case IEEE80211_MODE_11NG_HT40:
5512 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5513 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5514 phymode = eCSR_DOT11_MODE_11n;
5515 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5516 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5517 curr_band = eCSR_BAND_24;
5518 } else {
5519 sme_set_phy_mode(hal, old_phymode);
5520 return -EIO;
5521 }
5522 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005523 case IEEE80211_MODE_11AC_VHT20:
5524 case IEEE80211_MODE_11AC_VHT40:
5525 case IEEE80211_MODE_11AC_VHT80:
5526 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
5527 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5528 phymode = eCSR_DOT11_MODE_11ac;
5529 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
5530 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5531 curr_band = eCSR_BAND_5G;
5532 } else {
5533 sme_set_phy_mode(hal, old_phymode);
5534 return -EIO;
5535 }
5536 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005537 case IEEE80211_MODE_2G_AUTO:
5538 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
5539 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
5540 phymode = eCSR_DOT11_MODE_AUTO;
5541 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5542 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5543 curr_band = eCSR_BAND_24;
5544 } else {
5545 sme_set_phy_mode(hal, old_phymode);
5546 return -EIO;
5547 }
5548 break;
5549 case IEEE80211_MODE_5G_AUTO:
5550 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
5551 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
5552 phymode = eCSR_DOT11_MODE_AUTO;
5553 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5554 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5555 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5556 curr_band = eCSR_BAND_5G;
5557 } else {
5558 sme_set_phy_mode(hal, old_phymode);
5559 return -EIO;
5560 }
5561 break;
5562 case IEEE80211_MODE_11AGN:
5563 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
5564 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
5565 phymode = eCSR_DOT11_MODE_11n;
5566 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5567 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5568 curr_band = eCSR_BAND_ALL;
5569 } else {
5570 sme_set_phy_mode(hal, old_phymode);
5571 return -EIO;
5572 }
5573 break;
5574 default:
5575 return -EIO;
5576 }
5577
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 switch (new_phymode) {
5579 case IEEE80211_MODE_11AC_VHT20:
5580 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5581 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5582 break;
5583 case IEEE80211_MODE_11AC_VHT40:
5584 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5585 break;
5586 case IEEE80211_MODE_11AC_VHT80:
5587 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5588 break;
5589 default:
5590 vhtchanwidth = phddctx->config->vhtChannelWidth;
5591 break;
5592 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593
5594 if (phymode != -EIO) {
5595 sme_get_config_param(hal, &smeconfig);
5596 smeconfig.csrConfig.phyMode = phymode;
5597#ifdef QCA_HT_2040_COEX
5598 if (phymode == eCSR_DOT11_MODE_11n &&
5599 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
5600 smeconfig.csrConfig.obssEnabled = false;
5601 halStatus = sme_set_ht2040_mode(hal,
5602 pAdapter->sessionId,
5603 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305604 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005605 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606 return -EIO;
5607 }
5608 } else if (phymode == eCSR_DOT11_MODE_11n &&
5609 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
5610 smeconfig.csrConfig.obssEnabled = true;
5611 halStatus = sme_set_ht2040_mode(hal,
5612 pAdapter->sessionId,
5613 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305614 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005615 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616 return -EIO;
5617 }
5618 }
5619#endif
5620 smeconfig.csrConfig.eBand = curr_band;
5621 smeconfig.csrConfig.bandCapability = curr_band;
5622 if (curr_band == eCSR_BAND_24)
5623 smeconfig.csrConfig.Is11hSupportEnabled = 0;
5624 else
5625 smeconfig.csrConfig.Is11hSupportEnabled =
5626 phddctx->config->Is11hSupportEnabled;
5627 if (curr_band == eCSR_BAND_24)
5628 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5629 else if (curr_band == eCSR_BAND_24)
5630 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5631 else {
5632 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
5633 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
5634 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005635 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636 sme_update_config(hal, &smeconfig);
5637
5638 phddctx->config->dot11Mode = hdd_dot11mode;
5639 phddctx->config->nBandCapability = curr_band;
5640 phddctx->config->nChannelBondingMode24GHz =
5641 smeconfig.csrConfig.channelBondingMode24GHz;
5642 phddctx->config->nChannelBondingMode5GHz =
5643 smeconfig.csrConfig.channelBondingMode5GHz;
5644 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005645 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005646 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647 return -EIO;
5648 }
5649 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07005650 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5652 else
Dustin Browna30892e2016-10-12 17:28:36 -07005653 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5655
Jeff Johnson99bac312016-06-28 10:38:18 -07005656 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 phymode, chwidth, curr_band, vhtchanwidth);
5658 }
5659
5660 return 0;
5661}
5662
5663/**
5664 * hdd_get_temperature_cb() - "Get Temperature" callback function
5665 * @temperature: measured temperature
5666 * @pContext: callback context
5667 *
5668 * This function is passed to sme_get_temperature() as the callback
5669 * function to be invoked when the temperature measurement is
5670 * available.
5671 *
5672 * Return: None
5673 */
5674static void hdd_get_temperature_cb(int temperature, void *pContext)
5675{
5676 struct statsContext *pTempContext;
5677 hdd_adapter_t *pAdapter;
5678 ENTER();
5679 if (NULL == pContext) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005680 hdd_err("pContext is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005681 return;
5682 }
5683 pTempContext = pContext;
5684 pAdapter = pTempContext->pAdapter;
5685 spin_lock(&hdd_context_lock);
5686 if ((NULL == pAdapter) || (TEMP_CONTEXT_MAGIC != pTempContext->magic)) {
5687 spin_unlock(&hdd_context_lock);
Jeff Johnson99bac312016-06-28 10:38:18 -07005688 hdd_warn("Invalid context, pAdapter [%p] magic [%08x]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005689 pAdapter, pTempContext->magic);
5690 return;
5691 }
5692 if (temperature != 0) {
5693 pAdapter->temperature = temperature;
5694 }
5695 complete(&pTempContext->completion);
5696 spin_unlock(&hdd_context_lock);
5697 EXIT();
5698}
5699
5700/**
5701 * wlan_hdd_get_temperature() - get current device temperature
5702 * @pAdapter: device upon which the request was made
5703 * @temperature: pointer to where the temperature is to be returned
5704 *
5705 * Return: 0 if a temperature value (either current or cached) was
5706 * returned, otherwise a negative errno is returned.
5707 *
5708 */
5709int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
5710{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305711 QDF_STATUS status;
Houston Hoffman59c097f2016-11-09 15:50:25 -08005712 static struct statsContext tempContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 unsigned long rc;
5714
5715 ENTER();
5716 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005717 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005718 return -EPERM;
5719 }
5720 init_completion(&tempContext.completion);
5721 tempContext.pAdapter = pAdapter;
5722 tempContext.magic = TEMP_CONTEXT_MAGIC;
5723 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
5724 &tempContext, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305725 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005726 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727 } else {
5728 rc = wait_for_completion_timeout(&tempContext.completion,
5729 msecs_to_jiffies
5730 (WLAN_WAIT_TIME_STATS));
5731 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005732 hdd_err("SME timed out while retrieving temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005733 }
5734 }
5735 spin_lock(&hdd_context_lock);
5736 tempContext.magic = 0;
5737 spin_unlock(&hdd_context_lock);
5738 *temperature = pAdapter->temperature;
5739 EXIT();
5740 return 0;
5741}
5742
5743/**
5744 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5745 * @dev: device upon which the ioctl was received
5746 * @info: ioctl request information
5747 * @wrqu: ioctl request data
5748 * @extra: ioctl extra data
5749 *
5750 * Return: 0 on success, non-zero on error
5751 */
5752static int __iw_setint_getnone(struct net_device *dev,
5753 struct iw_request_info *info,
5754 union iwreq_data *wrqu, char *extra)
5755{
5756 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5757 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5758 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5759 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5760 hdd_context_t *hdd_ctx;
5761 tSmeConfigParams smeConfig;
5762 int *value = (int *)extra;
5763 int sub_cmd = value[0];
5764 int set_value = value[1];
5765 int ret;
5766 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305767 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005769 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771 INIT_COMPLETION(pWextState->completion_var);
Mukul Sharma81661ae2015-10-30 20:26:02 +05305772 memset(&smeConfig, 0x00, sizeof(smeConfig));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773
5774 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5775 ret = wlan_hdd_validate_context(hdd_ctx);
5776 if (0 != ret)
5777 return ret;
5778
5779 switch (sub_cmd) {
5780 case WE_SET_11D_STATE:
5781 {
5782 if ((ENABLE_11D == set_value)
5783 || (DISABLE_11D == set_value)) {
5784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005785 sme_get_config_param(hHal, &smeConfig);
5786 smeConfig.csrConfig.Is11dSupportEnabled =
5787 (bool) set_value;
5788
Jeff Johnson99bac312016-06-28 10:38:18 -07005789 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 smeConfig.csrConfig.
5791 Is11dSupportEnabled);
5792
5793 sme_update_config(hHal, &smeConfig);
5794 } else {
5795 return -EINVAL;
5796 }
5797 break;
5798 }
5799
5800 case WE_WOWL:
5801 {
5802 switch (set_value) {
5803 case 0x00:
5804 hdd_exit_wowl(pAdapter);
5805 break;
5806 case 0x01:
5807 case 0x02:
5808 case 0x03:
5809 enable_mp = (set_value & 0x01) ? 1 : 0;
5810 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07005811 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812 (enable_mp ? "YES" : "NO"),
5813 (enable_pbm ? "YES" : "NO"));
5814 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
5815 break;
5816 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005817 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818 set_value);
5819 ret = -EINVAL;
5820 break;
5821 }
5822
5823 break;
5824 }
5825 case WE_SET_POWER:
5826 {
5827 switch (set_value) {
5828 case 1:
5829 /* Enable PowerSave */
5830 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5831 SME_PS_ENABLE);
5832 break;
5833 case 2:
5834 /* Disable PowerSave */
5835 sme_ps_enable_disable(hHal, pAdapter->sessionId,
5836 SME_PS_DISABLE);
5837 break;
5838 case 3: /* Enable UASPD */
5839 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
5840 break;
5841 case 4: /* Disable UASPD */
5842 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
5843 break;
5844 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005845 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005846 set_value);
5847 ret = -EINVAL;
5848 break;
5849 }
5850 break;
5851 }
5852
5853 case WE_SET_MAX_ASSOC:
5854 {
5855 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5856 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5857 ret = -EINVAL;
5858 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5859 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305860 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005861 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005862 ret = -EIO;
5863 }
5864 break;
5865 }
5866
5867 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5868 if (set_value == 0 || set_value == 1)
5869 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
5870 set_value;
5871 else
5872 ret = -EINVAL;
5873 break;
5874
5875 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005876 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5877 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
5878 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
5879 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305880 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005881 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005882 ret = -EINVAL;
5883 }
5884 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005885 case WE_SET_MC_RATE:
5886 {
5887 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
5888 break;
5889 }
5890 case WE_SET_TX_POWER:
5891 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305892 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005893
Anurag Chouhanc5548422016-02-24 18:33:27 +05305894 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005895 if (sme_set_tx_power
5896 (hHal, pAdapter->sessionId, bssid,
5897 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305898 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005899 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005900 return -EIO;
5901 }
5902 break;
5903 }
5904 case WE_SET_MAX_TX_POWER:
5905 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305906 struct qdf_mac_addr bssid;
5907 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005908
Jeff Johnson99bac312016-06-28 10:38:18 -07005909 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005910 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305911 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
5912 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005913
5914 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305915 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005916 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005917 return -EIO;
5918 }
5919
5920 break;
5921 }
5922 case WE_SET_MAX_TX_POWER_2_4:
5923 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005924 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
5925 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005926 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305927 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005928 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005929 return -EIO;
5930 }
5931
5932 break;
5933 }
5934 case WE_SET_MAX_TX_POWER_5_0:
5935 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005936 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
5937 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305939 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005940 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005941 return -EIO;
5942 }
5943
5944 break;
5945 }
5946 case WE_SET_HIGHER_DTIM_TRANSITION:
5947 {
5948 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005949 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005950 set_value);
5951 ret = -EINVAL;
5952 } else {
5953 if (pAdapter->higherDtimTransition != set_value) {
5954 pAdapter->higherDtimTransition =
5955 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07005956 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957 pAdapter->higherDtimTransition);
5958 }
5959 }
5960
5961 break;
5962 }
5963
5964 case WE_SET_TM_LEVEL:
5965 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005966 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005967 (void)sme_set_thermal_level(hHal, set_value);
5968 break;
5969 }
5970
5971 case WE_SET_PHYMODE:
5972 {
5973 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
5974
5975 ret =
5976 wlan_hdd_update_phymode(dev, hHal, set_value,
5977 phddctx);
5978 break;
5979 }
5980
5981 case WE_SET_NSS:
5982 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005983 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005985 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986 ret = -EINVAL;
5987 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305988 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005989 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
5990 set_value))
5991 ret = -EINVAL;
5992 }
5993 break;
5994 }
5995
5996 case WE_SET_GTX_HT_MCS:
5997 {
Jeff Johnson99bac312016-06-28 10:38:18 -07005998 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 ret = wma_cli_set_command(pAdapter->sessionId,
6000 WMI_VDEV_PARAM_GTX_HT_MCS,
6001 set_value, GTX_CMD);
6002 break;
6003 }
6004
6005 case WE_SET_GTX_VHT_MCS:
6006 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006007 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006008 set_value);
6009 ret = wma_cli_set_command(pAdapter->sessionId,
6010 WMI_VDEV_PARAM_GTX_VHT_MCS,
6011 set_value, GTX_CMD);
6012 break;
6013 }
6014
6015 case WE_SET_GTX_USRCFG:
6016 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006017 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006018 set_value);
6019 ret = wma_cli_set_command(pAdapter->sessionId,
6020 WMI_VDEV_PARAM_GTX_USR_CFG,
6021 set_value, GTX_CMD);
6022 break;
6023 }
6024
6025 case WE_SET_GTX_THRE:
6026 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006027 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006028 ret = wma_cli_set_command(pAdapter->sessionId,
6029 WMI_VDEV_PARAM_GTX_THRE,
6030 set_value, GTX_CMD);
6031 break;
6032 }
6033
6034 case WE_SET_GTX_MARGIN:
6035 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006036 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037 ret = wma_cli_set_command(pAdapter->sessionId,
6038 WMI_VDEV_PARAM_GTX_MARGIN,
6039 set_value, GTX_CMD);
6040 break;
6041 }
6042
6043 case WE_SET_GTX_STEP:
6044 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006045 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 ret = wma_cli_set_command(pAdapter->sessionId,
6047 WMI_VDEV_PARAM_GTX_STEP,
6048 set_value, GTX_CMD);
6049 break;
6050 }
6051
6052 case WE_SET_GTX_MINTPC:
6053 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006054 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055 ret = wma_cli_set_command(pAdapter->sessionId,
6056 WMI_VDEV_PARAM_GTX_MINTPC,
6057 set_value, GTX_CMD);
6058 break;
6059 }
6060
6061 case WE_SET_GTX_BWMASK:
6062 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006063 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006064 ret = wma_cli_set_command(pAdapter->sessionId,
6065 WMI_VDEV_PARAM_GTX_BW_MASK,
6066 set_value, GTX_CMD);
6067 break;
6068 }
6069
6070 case WE_SET_LDPC:
6071 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306072 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006073 break;
6074 }
6075
6076 case WE_SET_TX_STBC:
6077 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306078 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006079 break;
6080 }
6081
6082 case WE_SET_RX_STBC:
6083 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05306084 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006085 break;
6086 }
6087
6088 case WE_SET_SHORT_GI:
6089 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006090 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
6092 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
6093 set_value);
6094 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07006095 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006096 break;
6097 }
6098
6099 case WE_SET_RTSCTS:
6100 {
6101 uint32_t value;
6102
Jeff Johnson99bac312016-06-28 10:38:18 -07006103 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006104 set_value);
6105
6106 if ((set_value & HDD_RTSCTS_EN_MASK) ==
6107 HDD_RTSCTS_ENABLE)
6108 value =
6109 (WLAN_HDD_GET_CTX(pAdapter))->config->
6110 RTSThreshold;
6111 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
6112 || ((set_value & HDD_RTSCTS_EN_MASK) ==
6113 HDD_CTS_ENABLE))
6114 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
6115 else
6116 return -EIO;
6117
6118 ret = wma_cli_set_command(pAdapter->sessionId,
6119 WMI_VDEV_PARAM_ENABLE_RTSCTS,
6120 set_value, VDEV_CMD);
6121 if (!ret) {
6122 if (sme_cfg_set_int
6123 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306124 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006125 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126 return -EIO;
6127 }
6128 }
6129
6130 break;
6131 }
6132
6133 case WE_SET_CHWIDTH:
6134 {
6135 bool chwidth = false;
6136 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
6137 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07006138 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006139 set_value);
6140 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006141 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006142 return -EINVAL;
6143 }
6144
6145 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
6146 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
6147 nChannelBondingMode5GHz)))
6148 chwidth = true;
6149
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006150 sme_get_config_param(hHal, &smeConfig);
6151 switch (set_value) {
6152 case eHT_CHANNEL_WIDTH_20MHZ:
6153 smeConfig.csrConfig.channelBondingMode5GHz =
6154 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
6155 break;
6156 case eHT_CHANNEL_WIDTH_40MHZ:
6157 if (chwidth)
6158 smeConfig.csrConfig.
6159 channelBondingMode5GHz =
6160 phddctx->config->
6161 nChannelBondingMode5GHz;
6162 else
6163 return -EINVAL;
6164
6165 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006166 case eHT_CHANNEL_WIDTH_80MHZ:
6167 if (chwidth)
6168 smeConfig.csrConfig.
6169 channelBondingMode5GHz =
6170 phddctx->config->
6171 nChannelBondingMode5GHz;
6172 else
6173 return -EINVAL;
6174
6175 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006176
6177 default:
6178 return -EINVAL;
6179 }
6180
6181 ret = wma_cli_set_command(pAdapter->sessionId,
6182 WMI_VDEV_PARAM_CHWIDTH,
6183 set_value, VDEV_CMD);
6184 if (!ret)
6185 sme_update_config(hHal, &smeConfig);
6186
6187 break;
6188 }
6189
6190 case WE_SET_ANI_EN_DIS:
6191 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006192 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006193 set_value);
6194 ret = wma_cli_set_command(pAdapter->sessionId,
6195 WMI_PDEV_PARAM_ANI_ENABLE,
6196 set_value, PDEV_CMD);
6197 break;
6198 }
6199
6200 case WE_SET_ANI_POLL_PERIOD:
6201 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006202 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 set_value);
6204 ret = wma_cli_set_command(pAdapter->sessionId,
6205 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6206 set_value, PDEV_CMD);
6207 break;
6208 }
6209
6210 case WE_SET_ANI_LISTEN_PERIOD:
6211 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006212 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006213 set_value);
6214 ret = wma_cli_set_command(pAdapter->sessionId,
6215 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6216 set_value, PDEV_CMD);
6217 break;
6218 }
6219
6220 case WE_SET_ANI_OFDM_LEVEL:
6221 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006222 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006223 set_value);
6224 ret = wma_cli_set_command(pAdapter->sessionId,
6225 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6226 set_value, PDEV_CMD);
6227 break;
6228 }
6229
6230 case WE_SET_ANI_CCK_LEVEL:
6231 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006232 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006233 set_value);
6234 ret = wma_cli_set_command(pAdapter->sessionId,
6235 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6236 set_value, PDEV_CMD);
6237 break;
6238 }
6239
6240 case WE_SET_DYNAMIC_BW:
6241 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006242 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006243 set_value);
6244 ret = wma_cli_set_command(pAdapter->sessionId,
6245 WMI_PDEV_PARAM_DYNAMIC_BW,
6246 set_value, PDEV_CMD);
6247 break;
6248 }
6249
6250 case WE_SET_CTS_CBW:
6251 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006252 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006253 ret = wma_cli_set_command(pAdapter->sessionId,
6254 WMI_PDEV_PARAM_CTS_CBW,
6255 set_value, PDEV_CMD);
6256 break;
6257 }
6258
6259 case WE_SET_11N_RATE:
6260 {
6261 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07006262 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006263 set_value);
6264
6265 if (set_value != 0xff) {
6266 rix = RC_2_RATE_IDX(set_value);
6267 if (set_value & 0x80) {
6268 preamble = WMI_RATE_PREAMBLE_HT;
6269 nss = HT_RC_2_STREAMS(set_value) - 1;
6270 } else {
6271 nss = 0;
6272 rix = RC_2_RATE_IDX(set_value);
6273 if (set_value & 0x10) {
6274 preamble =
6275 WMI_RATE_PREAMBLE_CCK;
6276 if (rix != 0x3)
6277 /* Enable Short
6278 * preamble always for
6279 * CCK except 1mbps
6280 */
6281 rix |= 0x4;
6282 } else {
6283 preamble =
6284 WMI_RATE_PREAMBLE_OFDM;
6285 }
6286 }
6287 set_value = (preamble << 6) | (nss << 4) | rix;
6288 }
6289 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
6290 set_value, rix, preamble, nss);
6291
6292 ret = wma_cli_set_command(pAdapter->sessionId,
6293 WMI_VDEV_PARAM_FIXED_RATE,
6294 set_value, VDEV_CMD);
6295 break;
6296 }
6297
6298 case WE_SET_VHT_RATE:
6299 {
6300 uint8_t preamble = 0, nss = 0, rix = 0;
6301
6302 if (set_value != 0xff) {
6303 rix = RC_2_RATE_IDX_11AC(set_value);
6304 preamble = WMI_RATE_PREAMBLE_VHT;
6305 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
6306
6307 set_value = (preamble << 6) | (nss << 4) | rix;
6308 }
6309 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
6310 set_value, rix, preamble, nss);
6311 ret = wma_cli_set_command(pAdapter->sessionId,
6312 WMI_VDEV_PARAM_FIXED_RATE,
6313 set_value, VDEV_CMD);
6314 break;
6315 }
6316
6317 case WE_SET_AMPDU:
6318 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006319 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006320 ret = wma_cli_set_command(pAdapter->sessionId,
6321 GEN_VDEV_PARAM_AMPDU,
6322 set_value, GEN_CMD);
6323 break;
6324 }
6325
6326 case WE_SET_AMSDU:
6327 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006328 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006329 ret = wma_cli_set_command(pAdapter->sessionId,
6330 GEN_VDEV_PARAM_AMSDU,
6331 set_value, GEN_CMD);
6332 break;
6333 }
6334
6335 case WE_SET_BURST_ENABLE:
6336 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006337 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006338 if ((set_value == 0) || (set_value == 1)) {
6339 ret = wma_cli_set_command(pAdapter->sessionId,
6340 WMI_PDEV_PARAM_BURST_ENABLE,
6341 set_value, PDEV_CMD);
6342 } else
6343 ret = -EINVAL;
6344 break;
6345 }
6346 case WE_SET_BURST_DUR:
6347 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006348 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07006349 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006350 ret = wma_cli_set_command(pAdapter->sessionId,
6351 WMI_PDEV_PARAM_BURST_DUR,
6352 set_value, PDEV_CMD);
6353 else
6354 ret = -EINVAL;
6355 break;
6356 }
6357
6358 case WE_SET_TX_CHAINMASK:
6359 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006360 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006361 set_value);
6362 ret = wma_cli_set_command(pAdapter->sessionId,
6363 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6364 set_value, PDEV_CMD);
6365 break;
6366 }
6367
6368 case WE_SET_RX_CHAINMASK:
6369 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006370 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006371 set_value);
6372 ret = wma_cli_set_command(pAdapter->sessionId,
6373 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6374 set_value, PDEV_CMD);
6375 break;
6376 }
6377
6378 case WE_SET_TXPOW_2G:
6379 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006380 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006381 set_value);
6382 ret = wma_cli_set_command(pAdapter->sessionId,
6383 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6384 set_value, PDEV_CMD);
6385 break;
6386 }
6387
6388 case WE_SET_TXPOW_5G:
6389 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006390 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006391 set_value);
6392 ret = wma_cli_set_command(pAdapter->sessionId,
6393 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6394 set_value, PDEV_CMD);
6395 break;
6396 }
6397
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006398 /* Firmware debug log */
6399 case WE_DBGLOG_LOG_LEVEL:
6400 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006401 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006402 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
6403 ret = wma_cli_set_command(pAdapter->sessionId,
6404 WMI_DBGLOG_LOG_LEVEL,
6405 set_value, DBG_CMD);
6406 break;
6407 }
6408
6409 case WE_DBGLOG_VAP_ENABLE:
6410 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006411 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006412 ret = wma_cli_set_command(pAdapter->sessionId,
6413 WMI_DBGLOG_VAP_ENABLE,
6414 set_value, DBG_CMD);
6415 break;
6416 }
6417
6418 case WE_DBGLOG_VAP_DISABLE:
6419 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006420 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006421 ret = wma_cli_set_command(pAdapter->sessionId,
6422 WMI_DBGLOG_VAP_DISABLE,
6423 set_value, DBG_CMD);
6424 break;
6425 }
6426
6427 case WE_DBGLOG_MODULE_ENABLE:
6428 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006429 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006430 set_value);
6431 hdd_ctx->fw_log_settings.enable = set_value;
6432 ret = wma_cli_set_command(pAdapter->sessionId,
6433 WMI_DBGLOG_MODULE_ENABLE,
6434 set_value, DBG_CMD);
6435 break;
6436 }
6437
6438 case WE_DBGLOG_MODULE_DISABLE:
6439 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006440 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006441 set_value);
6442 hdd_ctx->fw_log_settings.enable = set_value;
6443 ret = wma_cli_set_command(pAdapter->sessionId,
6444 WMI_DBGLOG_MODULE_DISABLE,
6445 set_value, DBG_CMD);
6446 break;
6447 }
6448 case WE_DBGLOG_MOD_LOG_LEVEL:
6449 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006450 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006451 set_value);
6452
6453 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
6454 hdd_ctx->fw_log_settings.index = 0;
6455
6456 hdd_ctx->fw_log_settings.
6457 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
6458 set_value;
6459 hdd_ctx->fw_log_settings.index++;
6460
6461 ret = wma_cli_set_command(pAdapter->sessionId,
6462 WMI_DBGLOG_MOD_LOG_LEVEL,
6463 set_value, DBG_CMD);
6464 break;
6465 }
6466
6467 case WE_DBGLOG_TYPE:
6468 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006469 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006470 hdd_ctx->fw_log_settings.dl_type = set_value;
6471 ret = wma_cli_set_command(pAdapter->sessionId,
6472 WMI_DBGLOG_TYPE,
6473 set_value, DBG_CMD);
6474 break;
6475 }
6476 case WE_DBGLOG_REPORT_ENABLE:
6477 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006478 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006479 set_value);
6480 hdd_ctx->fw_log_settings.dl_report = set_value;
6481 ret = wma_cli_set_command(pAdapter->sessionId,
6482 WMI_DBGLOG_REPORT_ENABLE,
6483 set_value, DBG_CMD);
6484 break;
6485 }
6486
6487 case WE_SET_TXRX_FWSTATS:
6488 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006489 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006490 ret = wma_cli_set_command(pAdapter->sessionId,
6491 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
6492 set_value, VDEV_CMD);
6493 break;
6494 }
6495
6496 case WE_TXRX_FWSTATS_RESET:
6497 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006498 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006499 ret = wma_cli_set_command(pAdapter->sessionId,
6500 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
6501 set_value, VDEV_CMD);
6502 break;
6503 }
6504
6505 case WE_DUMP_STATS:
6506 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006507 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006508 hdd_wlan_dump_stats(pAdapter, set_value);
6509 break;
6510 }
6511
6512 case WE_CLEAR_STATS:
6513 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006514 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006515 switch (set_value) {
6516 case WLAN_HDD_STATS:
6517 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
6518 memset(&pAdapter->hdd_stats, 0,
6519 sizeof(pAdapter->hdd_stats));
6520 break;
6521 case WLAN_TXRX_HIST_STATS:
6522 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
6523 break;
6524 case WLAN_HDD_NETIF_OPER_HISTORY:
6525 wlan_hdd_clear_netif_queue_history(hdd_ctx);
6526 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05306527 case WLAN_HIF_STATS:
6528 hdd_clear_hif_stats();
6529 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006530 default:
Leo Changfdb45c32016-10-28 11:09:23 -07006531 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
6532 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006533 }
6534 break;
6535 }
6536
6537 case WE_PPS_PAID_MATCH:
6538 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006539 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006540 return EINVAL;
6541
Jeff Johnson99bac312016-06-28 10:38:18 -07006542 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006543 set_value);
6544 ret = wma_cli_set_command(pAdapter->sessionId,
6545 WMI_VDEV_PPS_PAID_MATCH,
6546 set_value, PPS_CMD);
6547 break;
6548 }
6549
6550 case WE_PPS_GID_MATCH:
6551 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006552 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006553 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006554 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006555 set_value);
6556 ret = wma_cli_set_command(pAdapter->sessionId,
6557 WMI_VDEV_PPS_GID_MATCH,
6558 set_value, PPS_CMD);
6559 break;
6560 }
6561
6562 case WE_PPS_EARLY_TIM_CLEAR:
6563 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006564 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006565 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006566 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006567 set_value);
6568 ret = wma_cli_set_command(pAdapter->sessionId,
6569 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6570 set_value, PPS_CMD);
6571 break;
6572 }
6573
6574 case WE_PPS_EARLY_DTIM_CLEAR:
6575 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006576 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006577 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006578 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006579 set_value);
6580 ret = wma_cli_set_command(pAdapter->sessionId,
6581 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6582 set_value, PPS_CMD);
6583 break;
6584 }
6585
6586 case WE_PPS_EOF_PAD_DELIM:
6587 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006588 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006589 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006590 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006591 set_value);
6592 ret = wma_cli_set_command(pAdapter->sessionId,
6593 WMI_VDEV_PPS_EOF_PAD_DELIM,
6594 set_value, PPS_CMD);
6595 break;
6596 }
6597
6598 case WE_PPS_MACADDR_MISMATCH:
6599 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006600 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006601 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006602 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006603 set_value);
6604 ret = wma_cli_set_command(pAdapter->sessionId,
6605 WMI_VDEV_PPS_MACADDR_MISMATCH,
6606 set_value, PPS_CMD);
6607 break;
6608 }
6609
6610 case WE_PPS_DELIM_CRC_FAIL:
6611 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006612 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006613 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006614 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006615 set_value);
6616 ret = wma_cli_set_command(pAdapter->sessionId,
6617 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6618 set_value, PPS_CMD);
6619 break;
6620 }
6621
6622 case WE_PPS_GID_NSTS_ZERO:
6623 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006624 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006625 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006626 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006627 set_value);
6628 ret = wma_cli_set_command(pAdapter->sessionId,
6629 WMI_VDEV_PPS_GID_NSTS_ZERO,
6630 set_value, PPS_CMD);
6631 break;
6632 }
6633
6634 case WE_PPS_RSSI_CHECK:
6635 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006636 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006637 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07006638 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006639 set_value);
6640 ret = wma_cli_set_command(pAdapter->sessionId,
6641 WMI_VDEV_PPS_RSSI_CHECK,
6642 set_value, PPS_CMD);
6643 break;
6644 }
6645
6646 case WE_PPS_5G_EBT:
6647 {
Krunal Sonif07bb382016-03-10 13:02:11 -08006648 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006649 return -EINVAL;
6650
Jeff Johnson99bac312016-06-28 10:38:18 -07006651 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006652 ret = wma_cli_set_command(pAdapter->sessionId,
6653 WMI_VDEV_PPS_5G_EBT,
6654 set_value, PPS_CMD);
6655 break;
6656 }
6657
6658 case WE_SET_HTSMPS:
6659 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006660 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006661 ret = wma_cli_set_command(pAdapter->sessionId,
6662 WMI_STA_SMPS_FORCE_MODE_CMDID,
6663 set_value, VDEV_CMD);
6664 break;
6665 }
6666
6667 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6668 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006669 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006670 set_value);
6671 ret = wma_cli_set_command(pAdapter->sessionId,
6672 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6673 set_value, QPOWER_CMD);
6674 break;
6675 }
6676
6677 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6678 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006679 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006680 set_value);
6681 ret = wma_cli_set_command(
6682 pAdapter->sessionId,
6683 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6684 set_value, QPOWER_CMD);
6685 break;
6686 }
6687
6688 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6689 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006690 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006691 set_value);
6692 ret = wma_cli_set_command(
6693 pAdapter->sessionId,
6694 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6695 set_value, QPOWER_CMD);
6696 break;
6697 }
6698
6699 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6700 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006701 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006702 set_value);
6703 ret = wma_cli_set_command(
6704 pAdapter->sessionId,
6705 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6706 set_value, QPOWER_CMD);
6707 break;
6708 }
6709
6710 case WE_MCC_CONFIG_LATENCY:
6711 {
6712 cds_set_mcc_latency(pAdapter, set_value);
6713 break;
6714 }
6715
6716 case WE_MCC_CONFIG_QUOTA:
6717 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006718 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006719 set_value);
6720 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
6721 break;
6722 }
6723 case WE_SET_DEBUG_LOG:
6724 {
6725 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05306726
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006727 hdd_ctx->config->gEnableDebugLog = set_value;
6728 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6729 break;
6730 }
6731 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6732 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006733 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006734 if ((set_value == 0) || (set_value == 1))
6735 ret = wma_cli_set_command(
6736 pAdapter->sessionId,
6737 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6738 set_value, VDEV_CMD);
6739 else
6740 ret = -EINVAL;
6741 break;
6742 }
6743 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6744 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006745 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006746 ret = wma_cli_set_command(pAdapter->sessionId,
6747 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6748 set_value, VDEV_CMD);
6749 break;
6750 }
6751 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6752 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006753 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006754 set_value);
6755 ret = wma_cli_set_command(
6756 pAdapter->sessionId,
6757 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6758 set_value, VDEV_CMD);
6759 break;
6760 }
6761 case WE_SET_EARLY_RX_SLOP_STEP:
6762 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006763 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006764 set_value);
6765 ret = wma_cli_set_command(pAdapter->sessionId,
6766 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6767 set_value, VDEV_CMD);
6768 break;
6769 }
6770 case WE_SET_EARLY_RX_INIT_SLOP:
6771 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006772 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006773 set_value);
6774 ret = wma_cli_set_command(pAdapter->sessionId,
6775 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6776 set_value, VDEV_CMD);
6777 break;
6778 }
6779 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6780 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006781 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006782 if ((set_value == 0) || (set_value == 1))
6783 ret = wma_cli_set_command(
6784 pAdapter->sessionId,
6785 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6786 set_value, VDEV_CMD);
6787 else
6788 ret = -EINVAL;
6789 break;
6790 }
6791 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6792 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006793 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006794 ret = wma_cli_set_command(pAdapter->sessionId,
6795 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6796 set_value, VDEV_CMD);
6797 break;
6798 }
6799 case WE_SET_SCAN_DISABLE:
6800 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006801 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006802 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
6803 break;
6804 }
Govind Singha471e5e2015-10-12 17:11:14 +05306805 case WE_START_FW_PROFILE:
6806 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006807 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05306808 ret = wma_cli_set_command(pAdapter->sessionId,
6809 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6810 set_value, DBG_CMD);
6811 break;
6812 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306813 case WE_SET_CHANNEL:
6814 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006815 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306816 pAdapter->sessionId, pAdapter->device_mode);
6817
Krunal Sonif07bb382016-03-10 13:02:11 -08006818 if ((QDF_STA_MODE == pAdapter->device_mode) ||
6819 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306820
6821 status = sme_ext_change_channel(hHal,
6822 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306823 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006824 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306825 status);
6826 ret = -EINVAL;
6827 }
6828 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006829 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306830 pAdapter->device_mode);
6831 ret = -EINVAL;
6832 }
6833 break;
6834 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306835 case WE_SET_CONC_SYSTEM_PREF:
6836 {
6837 hdd_info("New preference: %d", set_value);
6838 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6839 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6840 hdd_err("Invalid system preference %d", set_value);
6841 return -EINVAL;
6842 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306843
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306844 /* hdd_ctx, hdd_ctx->config are already checked for null */
6845 hdd_ctx->config->conc_system_pref = set_value;
6846 break;
6847 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006848 default:
6849 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006850 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006851 sub_cmd);
6852 ret = -EINVAL;
6853 break;
6854 }
6855 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306856 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006857 return ret;
6858}
6859
6860static int iw_setint_getnone(struct net_device *dev,
6861 struct iw_request_info *info,
6862 union iwreq_data *wrqu,
6863 char *extra)
6864{
6865 int ret;
6866
6867 cds_ssr_protect(__func__);
6868 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6869 cds_ssr_unprotect(__func__);
6870
6871 return ret;
6872}
6873
6874/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006875 * __iw_setnone_get_threeint() - return three value to up layer.
6876 *
6877 * @dev: pointer of net_device of this wireless card
6878 * @info: meta data about Request sent
6879 * @wrqu: include request info
6880 * @extra: buf used for in/Output
6881 *
6882 * Return: execute result
6883 */
6884static int __iw_setnone_get_threeint(struct net_device *dev,
6885 struct iw_request_info *info,
6886 union iwreq_data *wrqu, char *extra)
6887{
6888 int ret = 0; /* success */
6889 uint32_t *value = (int *)extra;
6890 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6891 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6892
6893 ENTER_DEV(dev);
6894 ret = wlan_hdd_validate_context(hdd_ctx);
6895 if (0 != ret)
6896 return ret;
6897
Jeff Johnson99bac312016-06-28 10:38:18 -07006898 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006899 switch (value[0]) {
6900 case WE_GET_TSF:
6901 ret = hdd_indicate_tsf(adapter, value, 3);
6902 break;
6903 default:
6904 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6905 break;
6906 }
6907 return ret;
6908}
6909
6910/**
6911 * iw_setnone_get_threeint() - return three value to up layer.
6912 *
6913 * @dev: pointer of net_device of this wireless card
6914 * @info: meta data about Request sent
6915 * @wrqu: include request info
6916 * @extra: buf used for in/Output
6917 *
6918 * Return: execute result
6919 */
6920static int iw_setnone_get_threeint(struct net_device *dev,
6921 struct iw_request_info *info,
6922 union iwreq_data *wrqu, char *extra)
6923{
6924 int ret;
6925
6926 cds_ssr_protect(__func__);
6927 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6928 cds_ssr_unprotect(__func__);
6929
6930 return ret;
6931}
6932
6933/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006934 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6935 * @dev: device upon which the ioctl was received
6936 * @info: ioctl request information
6937 * @wrqu: ioctl request data
6938 * @extra: ioctl extra data
6939 *
6940 * Return: 0 on success, non-zero on error
6941 */
6942static int __iw_setchar_getnone(struct net_device *dev,
6943 struct iw_request_info *info,
6944 union iwreq_data *wrqu, char *extra)
6945{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306946 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006947 int sub_cmd;
6948 int ret;
6949 char *pBuffer = NULL;
6950 hdd_adapter_t *pAdapter = (netdev_priv(dev));
6951 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006952 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006953 struct iw_point s_priv_data;
6954
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006955 ENTER_DEV(dev);
6956
Mukul Sharma34777c62015-11-02 20:22:30 +05306957 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006958 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306959 return -EPERM;
6960 }
6961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006962 ret = wlan_hdd_validate_context(hdd_ctx);
6963 if (0 != ret)
6964 return ret;
6965
6966 /* helper function to get iwreq_data with compat handling. */
6967 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
6968 return -EINVAL;
6969 }
6970
6971 /* make sure all params are correctly passed to function */
6972 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
6973 return -EINVAL;
6974 }
6975
6976 sub_cmd = s_priv_data.flags;
6977
6978 /* ODD number is used for set, copy data using copy_from_user */
6979 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6980 s_priv_data.length);
6981 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006982 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006983 return -ENOMEM;
6984 }
6985
Jeff Johnson99bac312016-06-28 10:38:18 -07006986 hdd_notice("Received length %d", s_priv_data.length);
6987 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006988
6989 switch (sub_cmd) {
6990 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006991 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006992 hdd_add_wowl_ptrn(pAdapter, pBuffer);
6993 break;
6994 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07006995 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006996 hdd_del_wowl_ptrn(pAdapter, pBuffer);
6997 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006998 case WE_NEIGHBOR_REPORT_REQUEST:
6999 {
7000 tRrmNeighborReq neighborReq;
7001 tRrmNeighborRspCallbackInfo callbackInfo;
7002
7003 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007004 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007005 neighborReq.no_ssid =
7006 (s_priv_data.length - 1) ? false : true;
7007 if (!neighborReq.no_ssid) {
7008 neighborReq.ssid.length =
7009 (s_priv_data.length - 1) >
7010 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307011 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007012 pBuffer,
7013 neighborReq.ssid.length);
7014 }
7015
7016 callbackInfo.neighborRspCallback = NULL;
7017 callbackInfo.neighborRspCallbackContext = NULL;
7018 callbackInfo.timeout = 5000; /* 5 seconds */
7019 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
7020 (pAdapter),
7021 pAdapter->sessionId,
7022 &neighborReq,
7023 &callbackInfo);
7024 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07007025 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007026 ret = -EINVAL;
7027 }
7028 }
7029 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007030 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07007031 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007032 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
7033 s_priv_data.length);
7034 break;
7035 case WE_SET_CONFIG:
7036 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307037 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007038 ret = -EINVAL;
7039 }
7040 break;
7041 default:
7042 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007043 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007044 sub_cmd);
7045 ret = -EINVAL;
7046 break;
7047 }
7048 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07007049 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307050 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007051 return ret;
7052}
7053
7054static int iw_setchar_getnone(struct net_device *dev,
7055 struct iw_request_info *info,
7056 union iwreq_data *wrqu, char *extra)
7057{
7058 int ret;
7059
7060 cds_ssr_protect(__func__);
7061 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
7062 cds_ssr_unprotect(__func__);
7063
7064 return ret;
7065}
7066
7067/**
7068 * iw_setnone_getint() - Generic "get integer" private ioctl handler
7069 * @dev: device upon which the ioctl was received
7070 * @info: ioctl request information
7071 * @wrqu: ioctl request data
7072 * @extra: ioctl extra data
7073 *
7074 * Return: 0 on success, non-zero on error
7075 */
7076static int __iw_setnone_getint(struct net_device *dev,
7077 struct iw_request_info *info,
7078 union iwreq_data *wrqu, char *extra)
7079{
7080 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7081 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7082 int *value = (int *)extra;
7083 int ret;
7084 tSmeConfigParams smeConfig;
7085 hdd_context_t *hdd_ctx;
7086
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007087 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307088
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007089 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7090 ret = wlan_hdd_validate_context(hdd_ctx);
7091 if (0 != ret)
7092 return ret;
7093
7094 switch (value[0]) {
7095 case WE_GET_11D_STATE:
7096 {
7097 sme_get_config_param(hHal, &smeConfig);
7098
7099 *value = smeConfig.csrConfig.Is11dSupportEnabled;
7100
Jeff Johnson99bac312016-06-28 10:38:18 -07007101 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007102
7103 break;
7104 }
7105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007106 case WE_GET_WLAN_DBG:
7107 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307108 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007109 *value = 0;
7110 break;
7111 }
7112 case WE_GET_MAX_ASSOC:
7113 {
7114 if (sme_cfg_get_int
7115 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307116 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007117 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007118 ret = -EIO;
7119 }
7120 break;
7121 }
7122 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
7123 *value = (WLAN_HDD_GET_CTX(
7124 pAdapter))->config->force_sap_acs;
7125 break;
7126
7127 case WE_GET_CONCURRENCY_MODE:
7128 {
7129 *value = cds_get_concurrency_mode();
7130
Jeff Johnson99bac312016-06-28 10:38:18 -07007131 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007132 break;
7133 }
7134
7135 case WE_GET_NSS:
7136 {
7137 sme_get_config_param(hHal, &smeConfig);
7138 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07007139 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007140 break;
7141 }
7142
7143 case WE_GET_GTX_HT_MCS:
7144 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007145 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007146 *value = wma_cli_get_command(pAdapter->sessionId,
7147 WMI_VDEV_PARAM_GTX_HT_MCS,
7148 GTX_CMD);
7149 break;
7150 }
7151
7152 case WE_GET_GTX_VHT_MCS:
7153 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007154 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007155 *value = wma_cli_get_command(pAdapter->sessionId,
7156 WMI_VDEV_PARAM_GTX_VHT_MCS,
7157 GTX_CMD);
7158 break;
7159 }
7160
7161 case WE_GET_GTX_USRCFG:
7162 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007163 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007164 *value = wma_cli_get_command(pAdapter->sessionId,
7165 WMI_VDEV_PARAM_GTX_USR_CFG,
7166 GTX_CMD);
7167 break;
7168 }
7169
7170 case WE_GET_GTX_THRE:
7171 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007172 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007173 *value = wma_cli_get_command(pAdapter->sessionId,
7174 WMI_VDEV_PARAM_GTX_THRE,
7175 GTX_CMD);
7176 break;
7177 }
7178
7179 case WE_GET_GTX_MARGIN:
7180 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007181 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007182 *value = wma_cli_get_command(pAdapter->sessionId,
7183 WMI_VDEV_PARAM_GTX_MARGIN,
7184 GTX_CMD);
7185 break;
7186 }
7187
7188 case WE_GET_GTX_STEP:
7189 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007190 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007191 *value = wma_cli_get_command(pAdapter->sessionId,
7192 WMI_VDEV_PARAM_GTX_STEP,
7193 GTX_CMD);
7194 break;
7195 }
7196
7197 case WE_GET_GTX_MINTPC:
7198 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007199 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007200 *value = wma_cli_get_command(pAdapter->sessionId,
7201 WMI_VDEV_PARAM_GTX_MINTPC,
7202 GTX_CMD);
7203 break;
7204 }
7205
7206 case WE_GET_GTX_BWMASK:
7207 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007208 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007209 *value = wma_cli_get_command(pAdapter->sessionId,
7210 WMI_VDEV_PARAM_GTX_BW_MASK,
7211 GTX_CMD);
7212 break;
7213 }
7214
7215 case WE_GET_LDPC:
7216 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307217 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007218 break;
7219 }
7220
7221 case WE_GET_TX_STBC:
7222 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307223 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007224 break;
7225 }
7226
7227 case WE_GET_RX_STBC:
7228 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307229 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007230 break;
7231 }
7232
7233 case WE_GET_SHORT_GI:
7234 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007235 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007236 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
7237 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
7238 break;
7239 }
7240
7241 case WE_GET_RTSCTS:
7242 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007243 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007244 *value = wma_cli_get_command(pAdapter->sessionId,
7245 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7246 VDEV_CMD);
7247 break;
7248 }
7249
7250 case WE_GET_CHWIDTH:
7251 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007252 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007253 *value = wma_cli_get_command(pAdapter->sessionId,
7254 WMI_VDEV_PARAM_CHWIDTH,
7255 VDEV_CMD);
7256 break;
7257 }
7258
7259 case WE_GET_ANI_EN_DIS:
7260 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007261 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007262 *value = wma_cli_get_command(pAdapter->sessionId,
7263 WMI_PDEV_PARAM_ANI_ENABLE,
7264 PDEV_CMD);
7265 break;
7266 }
7267
7268 case WE_GET_ANI_POLL_PERIOD:
7269 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007270 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007271 *value = wma_cli_get_command(pAdapter->sessionId,
7272 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
7273 PDEV_CMD);
7274 break;
7275 }
7276
7277 case WE_GET_ANI_LISTEN_PERIOD:
7278 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007279 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007280 *value = wma_cli_get_command(pAdapter->sessionId,
7281 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
7282 PDEV_CMD);
7283 break;
7284 }
7285
7286 case WE_GET_ANI_OFDM_LEVEL:
7287 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007288 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007289 *value = wma_cli_get_command(pAdapter->sessionId,
7290 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
7291 PDEV_CMD);
7292 break;
7293 }
7294
7295 case WE_GET_ANI_CCK_LEVEL:
7296 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007297 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007298 *value = wma_cli_get_command(pAdapter->sessionId,
7299 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
7300 PDEV_CMD);
7301 break;
7302 }
7303
7304 case WE_GET_DYNAMIC_BW:
7305 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007306 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007307 *value = wma_cli_get_command(pAdapter->sessionId,
7308 WMI_PDEV_PARAM_DYNAMIC_BW,
7309 PDEV_CMD);
7310 break;
7311 }
7312
7313 case WE_GET_11N_RATE:
7314 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007315 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007316 *value = wma_cli_get_command(pAdapter->sessionId,
7317 WMI_VDEV_PARAM_FIXED_RATE,
7318 VDEV_CMD);
7319 break;
7320 }
7321
7322 case WE_GET_AMPDU:
7323 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007324 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007325 *value = wma_cli_get_command(pAdapter->sessionId,
7326 GEN_VDEV_PARAM_AMPDU,
7327 GEN_CMD);
7328 break;
7329 }
7330
7331 case WE_GET_AMSDU:
7332 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007333 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007334 *value = wma_cli_get_command(pAdapter->sessionId,
7335 GEN_VDEV_PARAM_AMSDU,
7336 GEN_CMD);
7337 break;
7338 }
7339
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007340 case WE_GET_ROAM_SYNCH_DELAY:
7341 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007342 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007343 *value = wma_cli_get_command(pAdapter->sessionId,
7344 GEN_VDEV_ROAM_SYNCH_DELAY,
7345 GEN_CMD);
7346 break;
7347 }
7348
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007349 case WE_GET_BURST_ENABLE:
7350 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007351 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007352 *value = wma_cli_get_command(pAdapter->sessionId,
7353 WMI_PDEV_PARAM_BURST_ENABLE,
7354 PDEV_CMD);
7355 break;
7356 }
7357 case WE_GET_BURST_DUR:
7358 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007359 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007360 *value = wma_cli_get_command(pAdapter->sessionId,
7361 WMI_PDEV_PARAM_BURST_DUR,
7362 PDEV_CMD);
7363 break;
7364 }
7365
7366 case WE_GET_TX_CHAINMASK:
7367 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007368 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007369 *value = wma_cli_get_command(pAdapter->sessionId,
7370 WMI_PDEV_PARAM_TX_CHAIN_MASK,
7371 PDEV_CMD);
7372 break;
7373 }
7374
7375 case WE_GET_RX_CHAINMASK:
7376 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007377 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007378 *value = wma_cli_get_command(pAdapter->sessionId,
7379 WMI_PDEV_PARAM_RX_CHAIN_MASK,
7380 PDEV_CMD);
7381 break;
7382 }
7383
7384 case WE_GET_TXPOW_2G:
7385 {
7386 uint32_t txpow2g = 0;
7387 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07007388 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007389 *value = wma_cli_get_command(pAdapter->sessionId,
7390 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
7391 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307392 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007393 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7394 &txpow2g)) {
7395 return -EIO;
7396 }
Jeff Johnson99bac312016-06-28 10:38:18 -07007397 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007398 break;
7399 }
7400
7401 case WE_GET_TXPOW_5G:
7402 {
7403 uint32_t txpow5g = 0;
7404 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07007405 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007406 *value = wma_cli_get_command(pAdapter->sessionId,
7407 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
7408 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307409 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007410 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7411 &txpow5g)) {
7412 return -EIO;
7413 }
Jeff Johnson99bac312016-06-28 10:38:18 -07007414 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007415 break;
7416 }
7417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007418 case WE_GET_PPS_PAID_MATCH:
7419 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007420 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007421 *value = wma_cli_get_command(pAdapter->sessionId,
7422 WMI_VDEV_PPS_PAID_MATCH,
7423 PPS_CMD);
7424 break;
7425 }
7426
7427 case WE_GET_PPS_GID_MATCH:
7428 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007429 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007430 *value = wma_cli_get_command(pAdapter->sessionId,
7431 WMI_VDEV_PPS_GID_MATCH,
7432 PPS_CMD);
7433 break;
7434 }
7435
7436 case WE_GET_PPS_EARLY_TIM_CLEAR:
7437 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007438 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007439 *value = wma_cli_get_command(pAdapter->sessionId,
7440 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
7441 PPS_CMD);
7442 break;
7443 }
7444
7445 case WE_GET_PPS_EARLY_DTIM_CLEAR:
7446 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007447 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007448 *value = wma_cli_get_command(pAdapter->sessionId,
7449 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
7450 PPS_CMD);
7451 break;
7452 }
7453
7454 case WE_GET_PPS_EOF_PAD_DELIM:
7455 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007456 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007457 *value = wma_cli_get_command(pAdapter->sessionId,
7458 WMI_VDEV_PPS_EOF_PAD_DELIM,
7459 PPS_CMD);
7460 break;
7461 }
7462
7463 case WE_GET_PPS_MACADDR_MISMATCH:
7464 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007465 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007466 *value = wma_cli_get_command(pAdapter->sessionId,
7467 WMI_VDEV_PPS_MACADDR_MISMATCH,
7468 PPS_CMD);
7469 break;
7470 }
7471
7472 case WE_GET_PPS_DELIM_CRC_FAIL:
7473 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007474 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007475 *value = wma_cli_get_command(pAdapter->sessionId,
7476 WMI_VDEV_PPS_DELIM_CRC_FAIL,
7477 PPS_CMD);
7478 break;
7479 }
7480
7481 case WE_GET_PPS_GID_NSTS_ZERO:
7482 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007483 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007484 *value = wma_cli_get_command(pAdapter->sessionId,
7485 WMI_VDEV_PPS_GID_NSTS_ZERO,
7486 PPS_CMD);
7487 break;
7488 }
7489
7490 case WE_GET_PPS_RSSI_CHECK:
7491 {
7492
Jeff Johnson99bac312016-06-28 10:38:18 -07007493 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007494 *value = wma_cli_get_command(pAdapter->sessionId,
7495 WMI_VDEV_PPS_RSSI_CHECK,
7496 PPS_CMD);
7497 break;
7498 }
7499
7500 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
7501 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007502 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007503 *value = wma_cli_get_command(pAdapter->sessionId,
7504 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
7505 QPOWER_CMD);
7506 break;
7507 }
7508
7509 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
7510 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007511 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007512 *value = wma_cli_get_command(pAdapter->sessionId,
7513 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
7514 QPOWER_CMD);
7515 break;
7516 }
7517
7518 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
7519 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007520 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007521 *value = wma_cli_get_command(pAdapter->sessionId,
7522 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
7523 QPOWER_CMD);
7524 break;
7525 }
7526
7527 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
7528 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007529 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007530 *value = wma_cli_get_command(pAdapter->sessionId,
7531 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
7532 QPOWER_CMD);
7533 break;
7534 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07007535 case WE_CAP_TSF:
7536 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
7537 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007538 case WE_GET_TEMPERATURE:
7539 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007540 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007541 ret = wlan_hdd_get_temperature(pAdapter, value);
7542 break;
7543 }
7544 default:
7545 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007546 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007547 value[0]);
7548 break;
7549 }
7550 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307551 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007552 return ret;
7553}
7554
7555static int iw_setnone_getint(struct net_device *dev,
7556 struct iw_request_info *info,
7557 union iwreq_data *wrqu, char *extra)
7558{
7559 int ret;
7560
7561 cds_ssr_protect(__func__);
7562 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7563 cds_ssr_unprotect(__func__);
7564
7565 return ret;
7566}
7567
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307568static int hdd_set_fwtest(int argc, int cmd, int value)
7569{
7570 struct set_fwtest_params *fw_test;
7571
7572 /* check for max number of arguments */
7573 if (argc > (WMA_MAX_NUM_ARGS) ||
7574 argc != HDD_FWTEST_PARAMS) {
7575 hdd_err("Too Many args %d", argc);
7576 return -EINVAL;
7577 }
7578 /*
7579 * check if number of arguments are 3 then, check
7580 * then set the default value for sounding interval.
7581 */
7582 if (HDD_FWTEST_PARAMS == argc) {
7583 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7584 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7585 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7586 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7587 }
7588 /* check sounding interval value should not exceed to max */
7589 if (value > HDD_FWTEST_MAX_VALUE) {
7590 hdd_err("Invalid arguments value should not exceed max: %d",
7591 value);
7592 return -EINVAL;
7593 }
7594 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7595 if (NULL == fw_test) {
7596 hdd_err("qdf_mem_malloc failed for fw_test");
7597 return -ENOMEM;
7598 }
7599 fw_test->arg = cmd;
7600 fw_test->value = value;
7601 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7602 qdf_mem_free(fw_test);
7603 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7604 return -EINVAL;
7605 }
7606 return 0;
7607}
7608
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007609/**
7610 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7611 * @dev: device upon which the ioctl was received
7612 * @info: ioctl request information
7613 * @wrqu: ioctl request data
7614 * @extra: ioctl extra data
7615 *
7616 * Return: 0 on success, non-zero on error
7617 */
7618static int __iw_set_three_ints_getnone(struct net_device *dev,
7619 struct iw_request_info *info,
7620 union iwreq_data *wrqu, char *extra)
7621{
7622 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7623 int *value = (int *)extra;
7624 int sub_cmd = value[0];
7625 int ret;
7626 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7627
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007628 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307629
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007630 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007631 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007632 return -EPERM;
7633 }
7634
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007635 ret = wlan_hdd_validate_context(hdd_ctx);
7636 if (0 != ret)
7637 return ret;
7638
7639 switch (sub_cmd) {
7640
7641 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307642 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007643 break;
7644 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307645 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007646 break;
7647
7648 /* value[3] the acs band is not required as start and end channels are
7649 * enough but this cmd is maintained under set three ints for historic
7650 * reasons.
7651 */
7652 case WE_SET_SAP_CHANNELS:
7653 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307654 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007655 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307656 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007657 ret = -EINVAL;
7658 } else {
7659 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7660 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7661 }
7662 break;
7663 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7664 hdd_debug("Ioctl to set dual mac scan config");
7665 if (hdd_ctx->config->dual_mac_feature_disable) {
7666 hdd_err("Dual mac feature is disabled from INI");
7667 return -EPERM;
7668 }
7669 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08007670 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007671 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307672 case WE_SET_FW_TEST:
7673 {
7674 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7675 if (ret) {
7676 hdd_err("Not able to set fwtest %d", ret);
7677 return ret;
7678 }
7679 }
7680 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007681 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007682 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007683 break;
7684
7685 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307686 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007687 return ret;
7688}
7689
7690int iw_set_three_ints_getnone(struct net_device *dev,
7691 struct iw_request_info *info,
7692 union iwreq_data *wrqu, char *extra)
7693{
7694 int ret;
7695
7696 cds_ssr_protect(__func__);
7697 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7698 cds_ssr_unprotect(__func__);
7699
7700 return ret;
7701}
7702
7703/**
7704 * hdd_connection_state_string() - Get connection state string
7705 * @connection_state: enum to be converted to a string
7706 *
7707 * Return: the string equivalent of @connection_state
7708 */
7709static const char *
7710hdd_connection_state_string(eConnectionState connection_state)
7711{
7712 switch (connection_state) {
7713 CASE_RETURN_STRING(eConnectionState_NotConnected);
7714 CASE_RETURN_STRING(eConnectionState_Connecting);
7715 CASE_RETURN_STRING(eConnectionState_Associated);
7716 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7717 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7718 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7719 default:
7720 return "UNKNOWN";
7721 }
7722}
7723
7724/**
7725 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7726 * @dev: device upon which the ioctl was received
7727 * @info: ioctl request information
7728 * @wrqu: ioctl request data
7729 * @extra: ioctl extra data
7730 *
7731 * Return: 0 on success, non-zero on error
7732 */
7733static int __iw_get_char_setnone(struct net_device *dev,
7734 struct iw_request_info *info,
7735 union iwreq_data *wrqu, char *extra)
7736{
7737 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7738 int sub_cmd = wrqu->data.flags;
7739 hdd_context_t *hdd_ctx;
7740 int ret;
7741#ifdef WLAN_FEATURE_11W
7742 hdd_wext_state_t *pWextState;
7743#endif
7744
7745#ifdef WLAN_FEATURE_11W
7746 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7747#endif
7748
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007749 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007751 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7752 ret = wlan_hdd_validate_context(hdd_ctx);
7753 if (0 != ret)
7754 return ret;
7755
7756 switch (sub_cmd) {
7757 case WE_WLAN_VERSION:
7758 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307759 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007760 break;
7761 }
7762
7763 case WE_GET_STATS:
7764 {
7765 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
7766 extra, WE_MAX_STR_LEN);
7767 break;
7768 }
7769
Dustin Brownd9322482017-01-09 12:46:03 -08007770 case WE_GET_SUSPEND_RESUME_STATS:
7771 {
7772 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
7773 WE_MAX_STR_LEN);
7774 if (ret >= 0) {
7775 wrqu->data.length = ret;
7776 ret = 0;
7777 }
7778
7779 break;
7780 }
7781
Govind Singha471e5e2015-10-12 17:11:14 +05307782 case WE_LIST_FW_PROFILE:
7783 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7784 extra, WE_MAX_STR_LEN);
7785 break;
7786
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007787 /* The case prints the current state of the HDD, SME, CSR, PE,
7788 * TL it can be extended for WDI Global State as well. And
7789 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7790 * and P2P_GO have not been added as of now.
7791 */
7792 case WE_GET_STATES:
7793 {
7794 int buf = 0, len = 0;
7795 int adapter_num = 0;
7796 int count = 0, check = 1;
7797
7798 tHalHandle hHal = NULL;
7799 tpAniSirGlobal pMac = NULL;
7800 hdd_station_ctx_t *pHddStaCtx = NULL;
7801
7802 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7803 hdd_adapter_t *useAdapter = NULL;
7804
7805 /* Print wlan0 or p2p0 states based on the adapter_num
7806 * by using the correct adapter
7807 */
7808 while (adapter_num < 2) {
7809 if (WLAN_ADAPTER == adapter_num) {
7810 useAdapter = pAdapter;
7811 buf =
7812 scnprintf(extra + len,
7813 WE_MAX_STR_LEN - len,
7814 "\n\n wlan0 States:-");
7815 len += buf;
7816 } else if (P2P_ADAPTER == adapter_num) {
7817 buf =
7818 scnprintf(extra + len,
7819 WE_MAX_STR_LEN - len,
7820 "\n\n p2p0 States:-");
7821 len += buf;
7822
7823 if (!pHddCtx) {
7824 buf =
7825 scnprintf(extra + len,
7826 WE_MAX_STR_LEN -
7827 len,
7828 "\n pHddCtx is NULL");
7829 len += buf;
7830 break;
7831 }
7832
7833 /* Printing p2p0 states only in the
7834 * case when the device is configured
7835 * as a p2p_client
7836 */
7837 useAdapter =
7838 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007839 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007840 if (!useAdapter) {
7841 buf =
7842 scnprintf(extra + len,
7843 WE_MAX_STR_LEN -
7844 len,
7845 "\n Device not configured as P2P_CLIENT.");
7846 len += buf;
7847 break;
7848 }
7849 }
7850
7851 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7852 if (!hHal) {
7853 buf =
7854 scnprintf(extra + len,
7855 WE_MAX_STR_LEN - len,
7856 "\n pMac is NULL");
7857 len += buf;
7858 break;
7859 }
7860 pMac = PMAC_STRUCT(hHal);
7861 if (!pMac) {
7862 buf =
7863 scnprintf(extra + len,
7864 WE_MAX_STR_LEN - len,
7865 "\n pMac is NULL");
7866 len += buf;
7867 break;
7868 }
7869 pHddStaCtx =
7870 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7871
7872
7873 buf =
7874 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7875 "\n HDD Conn State - %s "
7876 "\n \n SME State:"
7877 "\n Neighbour Roam State - %s"
7878 "\n CSR State - %s"
7879 "\n CSR Substate - %s",
7880 hdd_connection_state_string
7881 (pHddStaCtx->conn_info.connState),
7882 mac_trace_get_neighbour_roam_state
7883 (sme_get_neighbor_roam_state
7884 (hHal, useAdapter->sessionId)),
7885 mac_trace_getcsr_roam_state
7886 (sme_get_current_roam_state
7887 (hHal, useAdapter->sessionId)),
7888 mac_trace_getcsr_roam_sub_state
7889 (sme_get_current_roam_sub_state
7890 (hHal, useAdapter->sessionId))
7891 );
7892 len += buf;
7893 adapter_num++;
7894 }
7895
Mukul Sharma81661ae2015-10-30 20:26:02 +05307896 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007897 /* Printing Lim State starting with global lim states */
7898 buf =
7899 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7900 "\n \n LIM STATES:-"
7901 "\n Global Sme State - %s "
7902 "\n Global mlm State - %s " "\n",
7903 mac_trace_get_lim_sme_state
7904 (sme_get_lim_sme_state(hHal)),
7905 mac_trace_get_lim_mlm_state
7906 (sme_get_lim_sme_state(hHal))
7907 );
7908 len += buf;
7909
7910 /* Printing the PE Sme and Mlm states for valid lim sessions */
7911 while (check < 3 && count < 255) {
7912 if (sme_is_lim_session_valid(hHal, count)) {
7913 buf =
7914 scnprintf(extra + len,
7915 WE_MAX_STR_LEN -
7916 len,
7917 "\n Lim Valid Session %d:-"
7918 "\n PE Sme State - %s "
7919 "\n PE Mlm State - %s "
7920 "\n", check,
7921 mac_trace_get_lim_sme_state
7922 (sme_get_lim_sme_session_state
7923 (hHal, count)),
7924 mac_trace_get_lim_mlm_state
7925 (sme_get_lim_mlm_session_state
7926 (hHal, count))
7927 );
7928
7929 len += buf;
7930 check++;
7931 }
7932 count++;
7933 }
7934 }
7935
7936 wrqu->data.length = strlen(extra) + 1;
7937 break;
7938 }
7939
7940 case WE_GET_CFG:
7941 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007942 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007943 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
7944 extra,
7945 QCSAP_IOCTL_MAX_STR_LEN);
7946 wrqu->data.length = strlen(extra) + 1;
7947 break;
7948 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007949 case WE_GET_RSSI:
7950 {
7951 int8_t s7Rssi = 0;
7952 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
7953 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7954 wrqu->data.length = strlen(extra) + 1;
7955 break;
7956 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007957
7958 case WE_GET_WMM_STATUS:
7959 {
7960 snprintf(extra, WE_MAX_STR_LEN,
7961 "\nDir: 0=up, 1=down, 3=both\n"
7962 "|------------------------|\n"
7963 "|AC | ACM |Admitted| Dir |\n"
7964 "|------------------------|\n"
7965 "|VO | %d | %3s | %d |\n"
7966 "|VI | %d | %3s | %d |\n"
7967 "|BE | %d | %3s | %d |\n"
7968 "|BK | %d | %3s | %d |\n"
7969 "|------------------------|\n",
7970 pAdapter->hddWmmStatus.
7971 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
7972 pAdapter->hddWmmStatus.
7973 wmmAcStatus[SME_AC_VO].
7974 wmmAcAccessAllowed ? "YES" : "NO",
7975 pAdapter->hddWmmStatus.
7976 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
7977 ts_info.direction,
7978 pAdapter->hddWmmStatus.
7979 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
7980 pAdapter->hddWmmStatus.
7981 wmmAcStatus[SME_AC_VI].
7982 wmmAcAccessAllowed ? "YES" : "NO",
7983 pAdapter->hddWmmStatus.
7984 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
7985 ts_info.direction,
7986 pAdapter->hddWmmStatus.
7987 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
7988 pAdapter->hddWmmStatus.
7989 wmmAcStatus[SME_AC_BE].
7990 wmmAcAccessAllowed ? "YES" : "NO",
7991 pAdapter->hddWmmStatus.
7992 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
7993 ts_info.direction,
7994 pAdapter->hddWmmStatus.
7995 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
7996 pAdapter->hddWmmStatus.
7997 wmmAcStatus[SME_AC_BK].
7998 wmmAcAccessAllowed ? "YES" : "NO",
7999 pAdapter->hddWmmStatus.
8000 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
8001 ts_info.direction);
8002
8003 wrqu->data.length = strlen(extra) + 1;
8004 break;
8005 }
8006 case WE_GET_CHANNEL_LIST:
8007 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308008 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008009 uint8_t i, len;
8010 char *buf;
8011 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
8012 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
8013 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8014
8015 tChannelListInfo channel_list;
8016
8017 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05308018 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008019 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308020 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008021 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008022 return -EINVAL;
8023 }
8024 buf = extra;
8025 /*
8026 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
8027 * Maximum buffer needed = 5 * number of channels.
8028 * Check ifsufficient buffer is available and then
8029 * proceed to fill the buffer.
8030 */
8031 if (WE_MAX_STR_LEN <
8032 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008033 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008034 return -EINVAL;
8035 }
8036 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
8037 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308038 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008039 ubuf, &ubuf_len)) {
8040 /* Printing Country code in getChannelList */
8041 for (i = 0; i < (ubuf_len - 1); i++)
8042 len += scnprintf(buf + len,
8043 WE_MAX_STR_LEN - len,
8044 "%c", ubuf[i]);
8045 }
8046 for (i = 0; i < channel_list.num_channels; i++) {
8047 len +=
8048 scnprintf(buf + len, WE_MAX_STR_LEN - len,
8049 " %u", channel_list.channels[i]);
8050 }
8051 wrqu->data.length = strlen(extra) + 1;
8052
8053 break;
8054 }
8055#ifdef FEATURE_WLAN_TDLS
8056 case WE_GET_TDLS_PEERS:
8057 {
8058 wrqu->data.length =
8059 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
8060 WE_MAX_STR_LEN) + 1;
8061 break;
8062 }
8063#endif
8064#ifdef WLAN_FEATURE_11W
8065 case WE_GET_11W_INFO:
8066 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008067 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008068 pWextState->roamProfile.MFPEnabled);
8069
8070 snprintf(extra, WE_MAX_STR_LEN,
8071 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
8072 "\n Number of Unprotected Disassocs %d"
8073 "\n Number of Unprotected Deauths %d",
8074 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
8075 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
8076 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
8077 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
8078 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
8079 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
8080 pWextState->roamProfile.MFPEnabled,
8081 pAdapter->hdd_stats.hddPmfStats.
8082 numUnprotDisassocRx,
8083 pAdapter->hdd_stats.hddPmfStats.
8084 numUnprotDeauthRx);
8085
8086 wrqu->data.length = strlen(extra) + 1;
8087 break;
8088 }
8089#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008090 case WE_GET_IBSS_STA_INFO:
8091 {
8092 hdd_station_ctx_t *pHddStaCtx =
8093 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8094 int idx = 0;
8095 int length = 0, buf = 0;
8096
Naveen Rawatc45d1622016-07-05 12:20:09 -07008097 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008098 if (0 != pHddStaCtx->conn_info.staId[idx]) {
8099 buf = snprintf
8100 ((extra + length),
8101 WE_MAX_STR_LEN - length,
8102 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
8103 pHddStaCtx->conn_info.staId[idx],
8104 pHddStaCtx->conn_info.
8105 peerMacAddress[idx].bytes[0],
8106 pHddStaCtx->conn_info.
8107 peerMacAddress[idx].bytes[1],
8108 pHddStaCtx->conn_info.
8109 peerMacAddress[idx].bytes[2],
8110 pHddStaCtx->conn_info.
8111 peerMacAddress[idx].bytes[3],
8112 pHddStaCtx->conn_info.
8113 peerMacAddress[idx].bytes[4],
8114 pHddStaCtx->conn_info.
8115 peerMacAddress[idx].bytes[5]
8116 );
8117 length += buf;
8118 }
8119 }
8120 wrqu->data.length = strlen(extra) + 1;
8121 break;
8122 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008123 case WE_GET_PHYMODE:
8124 {
8125 bool ch_bond24 = false, ch_bond5g = false;
8126 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
8127 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8128 eCsrPhyMode phymode;
8129 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008130 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008131
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008132 sme_config = qdf_mem_malloc(sizeof(*sme_config));
8133 if (!sme_config) {
8134 hdd_err("Out of memory");
8135 ret = -ENOMEM;
8136 break;
8137 }
8138
8139 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008140 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008141 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008142 ch_bond24 = true;
8143
8144 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008145 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008146 ch_bond5g = true;
8147
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008148 qdf_mem_free(sme_config);
8149
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008150 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308151 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008152 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008153 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008154 return -EIO;
8155 }
8156
8157 switch (phymode) {
8158 case eCSR_DOT11_MODE_AUTO:
8159 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
8160 break;
8161 case eCSR_DOT11_MODE_11n:
8162 case eCSR_DOT11_MODE_11n_ONLY:
8163 if (currBand == eCSR_BAND_24) {
8164 if (ch_bond24)
8165 snprintf(extra, WE_MAX_STR_LEN,
8166 "11NGHT40");
8167 else
8168 snprintf(extra, WE_MAX_STR_LEN,
8169 "11NGHT20");
8170 } else if (currBand == eCSR_BAND_5G) {
8171 if (ch_bond5g)
8172 snprintf(extra, WE_MAX_STR_LEN,
8173 "11NAHT40");
8174 else
8175 snprintf(extra, WE_MAX_STR_LEN,
8176 "11NAHT20");
8177 } else {
8178 snprintf(extra, WE_MAX_STR_LEN, "11N");
8179 }
8180 break;
8181 case eCSR_DOT11_MODE_abg:
8182 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
8183 break;
8184 case eCSR_DOT11_MODE_11a:
8185 snprintf(extra, WE_MAX_STR_LEN, "11A");
8186 break;
8187 case eCSR_DOT11_MODE_11b:
8188 case eCSR_DOT11_MODE_11b_ONLY:
8189 snprintf(extra, WE_MAX_STR_LEN, "11B");
8190 break;
8191 case eCSR_DOT11_MODE_11g:
8192 case eCSR_DOT11_MODE_11g_ONLY:
8193 snprintf(extra, WE_MAX_STR_LEN, "11G");
8194 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008195 case eCSR_DOT11_MODE_11ac:
8196 case eCSR_DOT11_MODE_11ac_ONLY:
8197 if (hddctx->config->vhtChannelWidth ==
8198 eHT_CHANNEL_WIDTH_20MHZ)
8199 snprintf(extra, WE_MAX_STR_LEN,
8200 "11ACVHT20");
8201 else if (hddctx->config->vhtChannelWidth ==
8202 eHT_CHANNEL_WIDTH_40MHZ)
8203 snprintf(extra, WE_MAX_STR_LEN,
8204 "11ACVHT40");
8205 else if (hddctx->config->vhtChannelWidth ==
8206 eHT_CHANNEL_WIDTH_80MHZ)
8207 snprintf(extra, WE_MAX_STR_LEN,
8208 "11ACVHT80");
8209 else if (hddctx->config->vhtChannelWidth ==
8210 eHT_CHANNEL_WIDTH_160MHZ)
8211 snprintf(extra, WE_MAX_STR_LEN,
8212 "11ACVHT160");
8213 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008214 }
8215
8216 wrqu->data.length = strlen(extra) + 1;
8217 break;
8218 }
8219
8220#ifdef FEATURE_OEM_DATA_SUPPORT
8221 case WE_GET_OEM_DATA_CAP:
8222 {
8223 return iw_get_oem_data_cap(dev, info, wrqu, extra);
8224 }
8225#endif /* FEATURE_OEM_DATA_SUPPORT */
8226 case WE_GET_SNR:
8227 {
8228 int8_t s7snr = 0;
8229 int status = 0;
8230 hdd_context_t *pHddCtx;
8231 hdd_station_ctx_t *pHddStaCtx;
8232 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8233 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308234 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008235 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308236
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008237 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8238 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
8239 eConnectionState_Associated !=
8240 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008241 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008242 pHddCtx->config->fEnableSNRMonitoring,
8243 pHddStaCtx->conn_info.connState);
8244 return -ENONET;
8245 }
8246 wlan_hdd_get_snr(pAdapter, &s7snr);
8247 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
8248 wrqu->data.length = strlen(extra) + 1;
8249 break;
8250 }
8251 default:
8252 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008253 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008254 sub_cmd);
8255 break;
8256 }
8257 }
Dustin Brownd9322482017-01-09 12:46:03 -08008258
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308259 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -08008260 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008261}
8262
8263static int iw_get_char_setnone(struct net_device *dev,
8264 struct iw_request_info *info,
8265 union iwreq_data *wrqu, char *extra)
8266{
8267 int ret;
8268
8269 cds_ssr_protect(__func__);
8270 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
8271 cds_ssr_unprotect(__func__);
8272
8273 return ret;
8274}
8275
8276/**
8277 * iw_setnone_getnone() - Generic "action" private ioctl handler
8278 * @dev: device upon which the ioctl was received
8279 * @info: ioctl request information
8280 * @wrqu: ioctl request data
8281 * @extra: ioctl extra data
8282 *
8283 * Return: 0 on success, non-zero on error
8284 */
8285static int __iw_setnone_getnone(struct net_device *dev,
8286 struct iw_request_info *info,
8287 union iwreq_data *wrqu, char *extra)
8288{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008289 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008290 hdd_context_t *hdd_ctx;
8291 int ret;
8292 int sub_cmd;
8293
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008294 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308295
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008296 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008297 ret = wlan_hdd_validate_context(hdd_ctx);
8298 if (0 != ret)
8299 return ret;
8300
8301#ifdef CONFIG_COMPAT
8302 /* this ioctl is a special case where a sub-ioctl is used and both
8303 * the number of get and set args is 0. in this specific case the
8304 * logic in iwpriv places the sub_cmd in the data.flags portion of
8305 * the iwreq. unfortunately the location of this field will be
8306 * different between 32-bit and 64-bit userspace, and the standard
8307 * compat support in the kernel does not handle this case. so we
8308 * need to explicitly handle it here.
8309 */
8310 if (is_compat_task()) {
8311 struct compat_iw_point *compat_iw_point =
8312 (struct compat_iw_point *)&wrqu->data;
8313 sub_cmd = compat_iw_point->flags;
8314 } else {
8315 sub_cmd = wrqu->data.flags;
8316 }
8317#else
8318 sub_cmd = wrqu->data.flags;
8319#endif
8320
8321 switch (sub_cmd) {
8322 case WE_GET_RECOVERY_STAT:
8323 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008324 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008325 sme_get_recovery_stats(hal);
8326 break;
8327 }
8328
Govind Singha471e5e2015-10-12 17:11:14 +05308329 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008330 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05308331 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
8332 0, DBG_CMD);
8333 break;
8334
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008335 case WE_IBSS_GET_PEER_INFO_ALL:
8336 {
8337 hdd_wlan_get_ibss_peer_info_all(adapter);
8338 break;
8339 }
8340
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008341 case WE_SET_REASSOC_TRIGGER:
8342 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008343 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8344 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308345 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008346 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308347 uint8_t operating_ch =
8348 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008349 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008350
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008351 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008352 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308353 if (roaming_offload_enabled(hdd_ctx)) {
8354 qdf_mem_copy(bssid,
8355 &adapter->sessionCtx.station.conn_info.bssId,
8356 sizeof(bssid));
8357 hdd_wma_send_fastreassoc_cmd((int)adapter->sessionId,
8358 bssid, operating_ch);
8359 } else {
8360 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
8361 NULL, modProfileFields, &roamId, 1);
8362 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008363 return 0;
8364 }
8365
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008366 case WE_STOP_OBSS_SCAN:
8367 {
8368 /*
8369 * 1.OBSS Scan is mandatory while operating in 2.4GHz
8370 * 2.OBSS scan is stopped by Firmware during the disassociation
8371 * 3.OBSS stop comamnd is added for debugging purpose
8372 */
8373 tHalHandle hal;
8374
8375 hal = WLAN_HDD_GET_HAL_CTX(adapter);
8376 if (hal == NULL) {
8377 hdd_err("hal context is NULL");
8378 return -EINVAL;
8379 }
8380 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
8381 }
8382 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008383 default:
8384 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008385 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008386 break;
8387 }
8388 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308389 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008390 return ret;
8391}
8392
8393static int iw_setnone_getnone(struct net_device *dev,
8394 struct iw_request_info *info,
8395 union iwreq_data *wrqu, char *extra)
8396{
8397 int ret;
8398
8399 cds_ssr_protect(__func__);
8400 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
8401 cds_ssr_unprotect(__func__);
8402
8403 return ret;
8404}
8405
Krunal Sonia6e505b2017-01-12 12:25:18 -08008406#ifdef MPC_UT_FRAMEWORK
8407static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
8408 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
8409{
8410 switch(sub_cmd) {
8411 case WE_POLICY_MANAGER_CLIST_CMD:
8412 {
8413 hdd_err("<iwpriv wlan0 pm_clist> is called");
8414 cds_incr_connection_count_utfw(apps_args[0],
8415 apps_args[1], apps_args[2], apps_args[3],
8416 apps_args[4], apps_args[5], apps_args[6],
8417 apps_args[7]);
8418 }
8419 break;
8420
8421 case WE_POLICY_MANAGER_DLIST_CMD:
8422 {
8423 hdd_err("<iwpriv wlan0 pm_dlist> is called");
8424 cds_decr_connection_count_utfw(apps_args[0],
8425 apps_args[1]);
8426 }
8427 break;
8428
8429 case WE_POLICY_MANAGER_ULIST_CMD:
8430 {
8431 hdd_err("<iwpriv wlan0 pm_ulist> is called");
8432 cds_update_connection_info_utfw(apps_args[0],
8433 apps_args[1], apps_args[2], apps_args[3],
8434 apps_args[4], apps_args[5], apps_args[6],
8435 apps_args[7]);
8436 }
8437 break;
8438
8439 case WE_POLICY_MANAGER_DBS_CMD:
8440 {
8441 hdd_err("<iwpriv wlan0 pm_dbs> is called");
8442 if (apps_args[0] == 0)
8443 wma_set_dbs_capability_ut(0);
8444 else
8445 wma_set_dbs_capability_ut(1);
8446
8447 if (apps_args[1] >= CDS_THROUGHPUT &&
8448 apps_args[1] <= CDS_LATENCY) {
8449 pr_info("setting system pref to [%d]\n", apps_args[1]);
8450 hdd_ctx->config->conc_system_pref = apps_args[1];
8451 }
8452 }
8453 break;
8454
8455 case WE_POLICY_MANAGER_PCL_CMD:
8456 {
8457 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8458 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
8459 uint32_t pcl_len = 0, i = 0;
8460
8461 hdd_err("<iwpriv wlan0 pm_pcl> is called");
8462
8463 cds_get_pcl(apps_args[0],
8464 pcl, &pcl_len,
8465 weight_list, QDF_ARRAY_SIZE(weight_list));
8466 pr_info("PCL list for role[%d] is {", apps_args[0]);
8467 for (i = 0 ; i < pcl_len; i++)
8468 pr_info(" %d, ", pcl[i]);
8469 pr_info("}--------->\n");
8470 }
8471 break;
8472
8473 case WE_POLICY_SET_HW_MODE_CMD:
8474 {
8475 if (apps_args[0] == 0) {
8476 hdd_err("set hw mode for single mac");
8477 cds_pdev_set_hw_mode(
8478 adapter->sessionId,
8479 HW_MODE_SS_2x2,
8480 HW_MODE_80_MHZ,
8481 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8482 HW_MODE_DBS_NONE,
8483 HW_MODE_AGILE_DFS_NONE,
8484 HW_MODE_SBS_NONE,
8485 SIR_UPDATE_REASON_UT);
8486 } else if (apps_args[0] == 1) {
8487 hdd_err("set hw mode for dual mac");
8488 cds_pdev_set_hw_mode(
8489 adapter->sessionId,
8490 HW_MODE_SS_1x1,
8491 HW_MODE_80_MHZ,
8492 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8493 HW_MODE_DBS,
8494 HW_MODE_AGILE_DFS_NONE,
8495 HW_MODE_SBS_NONE,
8496 SIR_UPDATE_REASON_UT);
8497 }
8498 }
8499 break;
8500
8501 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8502 {
8503 enum cds_conc_next_action action;
8504 hdd_notice("<iwpriv wlan0 pm_query_action> is called");
8505 action = cds_current_connections_update(adapter->sessionId,
8506 apps_args[0],
8507 SIR_UPDATE_REASON_UT);
8508 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8509 }
8510 break;
8511
8512 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8513 {
8514 bool allow;
8515 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
8516 allow = cds_allow_concurrency(
8517 apps_args[0], apps_args[1], apps_args[2]);
8518 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8519 }
8520 break;
8521
8522 case WE_POLICY_MANAGER_SCENARIO_CMD:
8523 {
8524 clean_report(hdd_ctx);
8525 if (apps_args[0] == 1) {
8526 wlan_hdd_one_connection_scenario(hdd_ctx);
8527 } else if (apps_args[0] == 2) {
8528 wlan_hdd_two_connections_scenario(hdd_ctx,
8529 6, CDS_TWO_TWO);
8530 wlan_hdd_two_connections_scenario(hdd_ctx,
8531 36, CDS_TWO_TWO);
8532 wlan_hdd_two_connections_scenario(hdd_ctx,
8533 6, CDS_ONE_ONE);
8534 wlan_hdd_two_connections_scenario(hdd_ctx,
8535 36, CDS_ONE_ONE);
8536 } else if (apps_args[0] == 3) {
8537 /* MCC on same band with 2x2 same mac*/
8538 wlan_hdd_three_connections_scenario(hdd_ctx,
8539 6, 11, CDS_TWO_TWO, 0);
8540 /* MCC on diff band with 2x2 same mac*/
8541 wlan_hdd_three_connections_scenario(hdd_ctx,
8542 6, 36, CDS_TWO_TWO, 0);
8543 /* MCC on diff band with 1x1 diff mac */
8544 wlan_hdd_three_connections_scenario(hdd_ctx,
8545 36, 6, CDS_ONE_ONE, 0);
8546 /* MCC on diff band with 1x1 same mac */
8547 wlan_hdd_three_connections_scenario(hdd_ctx,
8548 36, 6, CDS_ONE_ONE, 1);
8549 /* SCC on same band with 2x2 same mac */
8550 wlan_hdd_three_connections_scenario(hdd_ctx,
8551 36, 36, CDS_TWO_TWO, 0);
8552 /* SCC on same band with 1x1 same mac */
8553 wlan_hdd_three_connections_scenario(hdd_ctx,
8554 36, 36, CDS_ONE_ONE, 1);
8555 /* MCC on same band with 2x2 same mac */
8556 wlan_hdd_three_connections_scenario(hdd_ctx,
8557 36, 149, CDS_TWO_TWO, 0);
8558 /* MCC on same band with 1x1 same mac */
8559 wlan_hdd_three_connections_scenario(hdd_ctx,
8560 36, 149, CDS_ONE_ONE, 1);
8561 }
8562 print_report(hdd_ctx);
8563 }
8564 break;
8565 }
8566 return 0;
8567}
8568#else
8569static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
8570 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
8571{
8572 return 0;
8573}
8574#endif
8575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008576/**
8577 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8578 * @dev: device upon which the ioctl was received
8579 * @info: ioctl request information
8580 * @wrqu: ioctl request data
8581 * @extra: ioctl extra data
8582 *
8583 * This is an SSR-protected generic handler for private ioctls which
8584 * take multiple arguments. Note that this implementation is also
8585 * somewhat unique in that it is shared by both STA-mode and SAP-mode
8586 * interfaces.
8587 *
8588 * Return: 0 on success, non-zero on error
8589 */
8590static int __iw_set_var_ints_getnone(struct net_device *dev,
8591 struct iw_request_info *info,
8592 union iwreq_data *wrqu, char *extra)
8593{
8594 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8595 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8596 int sub_cmd;
8597 int *apps_args = (int *) extra;
8598 hdd_context_t *hdd_ctx;
8599 int ret, num_args;
8600
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008601 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008603 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8604 ret = wlan_hdd_validate_context(hdd_ctx);
8605 if (0 != ret)
8606 return ret;
8607
8608 if (extra == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008609 hdd_err("NULL extra buffer pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008610 return -EINVAL;
8611 }
8612
8613 sub_cmd = wrqu->data.flags;
8614 num_args = wrqu->data.length;
8615
Jeff Johnson99bac312016-06-28 10:38:18 -07008616 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008617
8618 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008619 case WE_IBSS_GET_PEER_INFO:
8620 {
8621 pr_info("Station ID = %d\n", apps_args[0]);
8622 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
8623 }
8624 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008625
8626 case WE_P2P_NOA_CMD:
8627 {
8628 p2p_app_setP2pPs_t p2pNoA;
8629
Krunal Sonif07bb382016-03-10 13:02:11 -08008630 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08008631 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
8632 hdd_device_mode_to_string(
8633 pAdapter->device_mode),
8634 pAdapter->device_mode);
8635 return -EINVAL;
8636 }
8637
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008638 p2pNoA.opp_ps = apps_args[0];
8639 p2pNoA.ctWindow = apps_args[1];
8640 p2pNoA.duration = apps_args[2];
8641 p2pNoA.interval = apps_args[3];
8642 p2pNoA.count = apps_args[4];
8643 p2pNoA.single_noa_duration = apps_args[5];
8644 p2pNoA.psSelection = apps_args[6];
8645
Jeff Johnson99bac312016-06-28 10:38:18 -07008646 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
8647 apps_args[0], apps_args[1], apps_args[2],
8648 apps_args[3], apps_args[4],
8649 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008650
8651 hdd_set_p2p_ps(dev, &p2pNoA);
8652
8653 }
8654 break;
8655
8656 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8657 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008658 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
8659 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308660 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008661 }
8662 break;
8663
8664 case WE_MTRACE_DUMP_CMD:
8665 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008666 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
8667 apps_args[0], apps_args[1],
8668 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308669 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008670 apps_args[1], apps_args[2],
8671 apps_args[3]);
8672
8673 }
8674 break;
8675
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008676 case WE_POLICY_MANAGER_CINFO_CMD:
8677 {
8678 struct cds_conc_connection_info *conn_info;
8679 uint32_t i = 0, len = 0;
8680
Krunal Sonia6e505b2017-01-12 12:25:18 -08008681 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08008682 conn_info = cds_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008683 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008684 for (i = 0; i < len; i++) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08008685 pr_info("|table_index[%d]\t\t\n", i);
8686 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
8687 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
8688 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
8689 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
8690 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
8691 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
8692 pr_info("+--------------------------+\n");
8693 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008694 }
8695 }
8696 break;
8697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008698
8699#ifdef FEATURE_WLAN_TDLS
8700 case WE_TDLS_CONFIG_PARAMS:
8701 {
8702 tdls_config_params_t tdlsParams;
8703
8704 tdlsParams.tdls = apps_args[0];
8705 tdlsParams.tx_period_t = apps_args[1];
8706 tdlsParams.tx_packet_n = apps_args[2];
8707 /* ignore args[3] as discovery_period is not used anymore */
8708 tdlsParams.discovery_tries_n = apps_args[4];
8709 /* ignore args[5] as idle_timeout is not used anymore */
8710 tdlsParams.idle_packet_n = apps_args[6];
8711 /* ignore args[7] as rssi_hysteresis is not used anymore */
8712 tdlsParams.rssi_trigger_threshold = apps_args[8];
8713 tdlsParams.rssi_teardown_threshold = apps_args[9];
8714 tdlsParams.rssi_delta = apps_args[10];
8715
8716 wlan_hdd_tdls_set_params(dev, &tdlsParams);
8717 }
8718 break;
8719#endif
8720 case WE_UNIT_TEST_CMD:
8721 {
8722 t_wma_unit_test_cmd *unitTestArgs;
Rajeev Kumarea95edd2017-01-11 20:49:36 -08008723 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008724 int i, j;
8725 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8726 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008727 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008728 apps_args[0]);
8729 return -EINVAL;
8730 }
Anurag Chouhan77564182016-09-03 16:38:01 +05308731 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
8732 (apps_args[1] < 0)) {
8733 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008734 apps_args[1]);
8735 return -EINVAL;
8736 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308737 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008738 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008739 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008740 return -ENOMEM;
8741 }
8742 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
8743 unitTestArgs->module_id = apps_args[0];
8744 unitTestArgs->num_args = apps_args[1];
8745 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
8746 unitTestArgs->args[i] = apps_args[j];
8747 }
8748 msg.type = SIR_HAL_UNIT_TEST_CMD;
8749 msg.reserved = 0;
8750 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308751 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarea95edd2017-01-11 20:49:36 -08008752 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308753 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -07008754 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008755 return -EINVAL;
8756 }
8757 }
8758 break;
8759#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8760 case WE_LED_FLASHING_PARAM:
8761 {
8762 int i;
8763 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008764 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008765 return -EINVAL;
8766 }
8767 for (i = 0; i < num_args; i++) {
8768 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008769 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008770 return -EINVAL;
8771 }
8772 }
8773 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8774 0, apps_args[0], apps_args[1]);
8775 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
8776 1, apps_args[2], apps_args[3]);
8777 }
8778 break;
8779#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05308780 case WE_SET_PKTLOG:
8781 {
8782 int ret;
8783
8784 if (num_args < 1 || num_args > 2) {
8785 hdd_err("pktlog: either 1 or 2 parameters are required");
8786 return -EINVAL;
8787 }
8788
8789 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
8790 apps_args[1]);
8791 if (ret)
8792 return ret;
8793 break;
8794 }
8795
Manjeet Singhf82ed072016-07-08 11:40:00 +05308796 case WE_MAC_PWR_DEBUG_CMD:
8797 {
8798 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
8799 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8800 int i, j;
8801
8802 if (num_args < 3) {
8803 hdd_err("number of arguments can't be null %d",
8804 num_args);
8805 return -EINVAL;
8806 }
8807 if (num_args - 3 != apps_args[2]) {
8808 hdd_err("arg list of size %d doesn't match num_args %d",
8809 num_args-3, apps_args[2]);
8810 return -EINVAL;
8811 }
8812 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8813 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8814 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8815 return -EINVAL;
8816 }
8817 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8818 hdd_err("Too Many args %d", apps_args[2]);
8819 return -EINVAL;
8820 }
8821 mac_pwr_dbg_args.pdev_id = apps_args[0];
8822 mac_pwr_dbg_args.module_id = apps_args[1];
8823 mac_pwr_dbg_args.num_args = apps_args[2];
8824
8825 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8826 mac_pwr_dbg_args.args[i] = apps_args[j];
8827
8828 if (QDF_STATUS_SUCCESS !=
8829 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
8830 &mac_pwr_dbg_args)) {
8831 return -EINVAL;
8832 }
8833 }
8834 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -08008835 case WE_POLICY_MANAGER_CLIST_CMD:
8836 case WE_POLICY_MANAGER_DLIST_CMD:
8837 case WE_POLICY_MANAGER_ULIST_CMD:
8838 case WE_POLICY_MANAGER_DBS_CMD:
8839 case WE_POLICY_MANAGER_PCL_CMD:
8840 case WE_POLICY_SET_HW_MODE_CMD:
8841 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8842 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8843 case WE_POLICY_MANAGER_SCENARIO_CMD:
8844 {
8845 iw_get_policy_manager_ut_ops(hdd_ctx, pAdapter,
8846 sub_cmd, apps_args);
8847 }
8848 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008849 default:
8850 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008851 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008852 }
8853 break;
8854 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308855 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008856 return 0;
8857}
8858
8859/**
8860 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8861 * @dev: pointer to net_device structure
8862 * @info: pointer to iw_request_info structure
8863 * @wrqu: pointer to iwreq_data
8864 * @extra; extra
8865 *
8866 * Return: 0 on success, error number otherwise
8867 *
8868 */
8869static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8870 struct iw_request_info *info,
8871 union iwreq_data *wrqu, char *extra)
8872{
8873 union iwreq_data u_priv_wrqu;
8874 int apps_args[MAX_VAR_ARGS] = {0};
8875 int ret, num_args;
8876
Mukul Sharma64a70e82015-11-02 20:05:09 +05308877 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008878 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308879 return -EPERM;
8880 }
8881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008882 /* Helper function to get iwreq_data with compat handling. */
8883 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8884 return -EINVAL;
8885
8886 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008887 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008888 return -EINVAL;
8889 }
8890
8891 num_args = u_priv_wrqu.data.length;
8892 if (num_args > MAX_VAR_ARGS)
8893 num_args = MAX_VAR_ARGS;
8894
8895 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8896 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008897 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008898 return -EFAULT;
8899 }
8900
8901 cds_ssr_protect(__func__);
8902 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8903 (char *)&apps_args);
8904 cds_ssr_unprotect(__func__);
8905 return ret;
8906}
8907
8908/**
8909 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8910 * @dev: device upon which the ioctl was received
8911 * @info: ioctl request information
8912 * @wrqu: ioctl request data
8913 * @extra: ioctl extra data
8914 *
8915 * This is a generic handler for private ioctls which take multiple
8916 * arguments. Note that this implementation is also somewhat unique
8917 * in that it is shared by both STA-mode and SAP-mode interfaces.
8918 *
8919 * Return: 0 on success, non-zero on error
8920 */
8921int iw_set_var_ints_getnone(struct net_device *dev,
8922 struct iw_request_info *info,
8923 union iwreq_data *wrqu, char *extra)
8924{
8925 int ret;
8926
8927 cds_ssr_protect(__func__);
8928 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8929 cds_ssr_unprotect(__func__);
8930 return ret;
8931}
8932
8933/**
8934 * iw_add_tspec - Add TSpec private ioctl handler
8935 * @dev: device upon which the ioctl was received
8936 * @info: ioctl request information
8937 * @wrqu: ioctl request data
8938 * @extra: ioctl extra data
8939 *
8940 * Return: 0 on success, non-zero on error
8941 */
8942static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
8943 union iwreq_data *wrqu, char *extra)
8944{
8945 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8946 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8947 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8948 int params[HDD_WLAN_WMM_PARAM_COUNT];
8949 sme_QosWmmTspecInfo tSpec;
8950 uint32_t handle;
8951 struct iw_point s_priv_data;
8952 hdd_context_t *hdd_ctx;
8953 int ret;
8954
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008955 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008957 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8958 ret = wlan_hdd_validate_context(hdd_ctx);
8959 if (0 != ret)
8960 return ret;
8961
8962 /* make sure the application is sufficiently priviledged */
8963 /* note that the kernel will do this for "set" ioctls, but since */
8964 /* this ioctl wants to return status to user space it must be */
8965 /* defined as a "get" ioctl */
8966 if (!capable(CAP_NET_ADMIN)) {
8967 return -EPERM;
8968 }
8969
8970 /* we must be associated in order to add a tspec */
8971 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
8972 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8973 return 0;
8974 }
8975 /* since we are defined to be a "get" ioctl, and since the number */
8976 /* of params exceeds the number of params that wireless extensions */
8977 /* will pass down in the iwreq_data, we must copy the "set" params. */
8978 /* We must handle the compat for iwreq_data in 32U/64K environment. */
8979
8980 /* helper function to get iwreq_data with compat handling. */
8981 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8982 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8983 return 0;
8984 }
8985 /* make sure all params are correctly passed to function */
8986 if ((NULL == s_priv_data.pointer) ||
8987 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
8988 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8989 return 0;
8990 }
8991 /* from user space ourselves */
8992 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
8993 /* hmmm, can't get them */
8994 return -EIO;
8995 }
8996 /* clear the tspec */
8997 memset(&tSpec, 0, sizeof(tSpec));
8998
8999 /* validate the handle */
9000 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9001 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9002 /* that one is reserved */
9003 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9004 return 0;
9005 }
9006 /* validate the TID */
9007 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
9008 /* out of range */
9009 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9010 return 0;
9011 }
9012 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
9013
9014 /* validate the direction */
9015 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
9016 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
9017 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
9018 break;
9019
9020 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
9021 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
9022 break;
9023
9024 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
9025 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
9026 break;
9027
9028 default:
9029 /* unknown */
9030 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9031 return 0;
9032 }
9033
9034 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
9035
9036 /* validate the user priority */
9037 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
9038 /* out of range */
9039 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9040 return 0;
9041 }
9042 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
9043 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009044 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009045 return 0;
9046 }
9047
Jeff Johnson99bac312016-06-28 10:38:18 -07009048 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009049 tSpec.ts_info.psb, tSpec.ts_info.up);
9050
9051 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
9052 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
9053 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
9054 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
9055 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
9056 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
9057 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
9058 tSpec.surplus_bw_allowance =
9059 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
9060 tSpec.min_service_interval =
9061 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
9062 tSpec.max_service_interval =
9063 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
9064 tSpec.suspension_interval =
9065 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
9066 tSpec.inactivity_interval =
9067 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
9068
9069 tSpec.ts_info.burst_size_defn =
9070 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
9071
9072 /* validate the ts info ack policy */
9073 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
9074 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
9075 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
9076 break;
9077
9078 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
9079 tSpec.ts_info.ack_policy =
9080 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
9081 break;
9082
9083 default:
9084 /* unknown */
9085 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9086 return 0;
9087 }
9088
9089 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309090 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009091 return 0;
9092}
9093
9094static int iw_add_tspec(struct net_device *dev,
9095 struct iw_request_info *info,
9096 union iwreq_data *wrqu, char *extra)
9097{
9098 int ret;
9099
9100 cds_ssr_protect(__func__);
9101 ret = __iw_add_tspec(dev, info, wrqu, extra);
9102 cds_ssr_unprotect(__func__);
9103
9104 return ret;
9105}
9106
9107/**
9108 * iw_del_tspec - Delete TSpec private ioctl handler
9109 * @dev: device upon which the ioctl was received
9110 * @info: ioctl request information
9111 * @wrqu: ioctl request data
9112 * @extra: ioctl extra data
9113 *
9114 * Return: 0 on success, non-zero on error
9115 */
9116static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
9117 union iwreq_data *wrqu, char *extra)
9118{
9119 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9120 hdd_context_t *hdd_ctx;
9121 int *params = (int *)extra;
9122 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9123 uint32_t handle;
9124 int ret;
9125
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009126 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309127
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009128 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9129 ret = wlan_hdd_validate_context(hdd_ctx);
9130 if (0 != ret)
9131 return ret;
9132
9133 /* make sure the application is sufficiently priviledged */
9134 /* note that the kernel will do this for "set" ioctls, but since */
9135 /* this ioctl wants to return status to user space it must be */
9136 /* defined as a "get" ioctl */
9137 if (!capable(CAP_NET_ADMIN)) {
9138 return -EPERM;
9139 }
9140
9141 /* although we are defined to be a "get" ioctl, the params we require */
9142 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9143 /* is no need to copy the params from user space */
9144
9145 /* validate the handle */
9146 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9147 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9148 /* that one is reserved */
9149 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9150 return 0;
9151 }
9152
9153 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309154 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009155 return 0;
9156}
9157
9158static int iw_del_tspec(struct net_device *dev,
9159 struct iw_request_info *info,
9160 union iwreq_data *wrqu, char *extra)
9161{
9162 int ret;
9163
9164 cds_ssr_protect(__func__);
9165 ret = __iw_del_tspec(dev, info, wrqu, extra);
9166 cds_ssr_unprotect(__func__);
9167
9168 return ret;
9169}
9170
9171/**
9172 * iw_get_tspec - Get TSpec private ioctl handler
9173 * @dev: device upon which the ioctl was received
9174 * @info: ioctl request information
9175 * @wrqu: ioctl request data
9176 * @extra: ioctl extra data
9177 *
9178 * Return: 0 on success, non-zero on error
9179 */
9180static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
9181 union iwreq_data *wrqu, char *extra)
9182{
9183 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9184 hdd_context_t *hdd_ctx;
9185 int *params = (int *)extra;
9186 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9187 uint32_t handle;
9188 int ret;
9189
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009190 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009192 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9193 ret = wlan_hdd_validate_context(hdd_ctx);
9194 if (0 != ret)
9195 return ret;
9196
9197 /* although we are defined to be a "get" ioctl, the params we require */
9198 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9199 /* is no need to copy the params from user space */
9200
9201 /* validate the handle */
9202 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9203 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9204 /* that one is reserved */
9205 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9206 return 0;
9207 }
9208
9209 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309210 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009211 return 0;
9212}
9213
9214static int iw_get_tspec(struct net_device *dev,
9215 struct iw_request_info *info,
9216 union iwreq_data *wrqu, char *extra)
9217{
9218 int ret;
9219
9220 cds_ssr_protect(__func__);
9221 ret = __iw_get_tspec(dev, info, wrqu, extra);
9222 cds_ssr_unprotect(__func__);
9223
9224 return ret;
9225}
9226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009227/**
9228 * iw_set_fties - Set FT IEs private ioctl handler
9229 * @dev: device upon which the ioctl was received
9230 * @info: ioctl request information
9231 * @wrqu: ioctl request data
9232 * @extra: ioctl extra data
9233 *
9234 * Each time the supplicant has the auth_request or reassoc request
9235 * IEs ready they are pushed to the driver. The driver will in turn
9236 * use it to send out the auth req and reassoc req for 11r FT Assoc.
9237 *
9238 * Return: 0 on success, non-zero on error
9239 */
9240static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
9241 union iwreq_data *wrqu, char *extra)
9242{
9243 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9244 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9245 hdd_context_t *hdd_ctx;
9246 int ret;
9247
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009248 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309249
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009250 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9251 ret = wlan_hdd_validate_context(hdd_ctx);
9252 if (0 != ret)
9253 return ret;
9254
9255 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009256 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009257 return -EINVAL;
9258 }
9259 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009260 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009261 return -EINVAL;
9262 }
9263 /* Added for debug on reception of Re-assoc Req. */
9264 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009265 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009266 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -07009267 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009268 }
Jeff Johnson99bac312016-06-28 10:38:18 -07009269 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009270
9271 /* Pass the received FT IEs to SME */
9272 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
9273 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309274 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009275 return 0;
9276}
9277
9278static int iw_set_fties(struct net_device *dev,
9279 struct iw_request_info *info,
9280 union iwreq_data *wrqu, char *extra)
9281{
9282 int ret;
9283
9284 cds_ssr_protect(__func__);
9285 ret = __iw_set_fties(dev, info, wrqu, extra);
9286 cds_ssr_unprotect(__func__);
9287
9288 return ret;
9289}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009290
Dustin Brown0cbc7572016-12-16 13:54:40 -08009291/**
9292 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
9293 * @dev: device upon which the ioctl was received
9294 * @info: ioctl request information
9295 * @wrqu: ioctl request data
9296 * @extra: ioctl extra data
9297 *
Dustin Brown860566f2017-01-31 15:24:43 -08009298 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
9299 * time being to provide guidance in migrating to standard APIs.
9300 *
Dustin Brown0cbc7572016-12-16 13:54:40 -08009301 * Return: 0 on success, non-zero on error
9302 */
9303static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
9304 struct iw_request_info *info,
9305 union iwreq_data *wrqu,
9306 char *extra)
9307{
Dustin Brown860566f2017-01-31 15:24:43 -08009308 hdd_err("\n"
9309 "setMCBCFilter is obsolete. Use the following instead:\n"
9310 "Configure multicast filtering via the ‘ip’ command.\n"
9311 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
9312 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
9313 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
9314 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
9315 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Dustin Brown0cbc7572016-12-16 13:54:40 -08009316
Dustin Brown860566f2017-01-31 15:24:43 -08009317 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -08009318}
9319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009320/**
9321 * iw_set_host_offload - Set host offload ioctl handler
9322 * @dev: device upon which the ioctl was received
9323 * @info: ioctl request information
9324 * @wrqu: ioctl request data
9325 * @extra: ioctl extra data
9326 *
9327 * Return: 0 on success, non-zero on error
9328 */
9329static int __iw_set_host_offload(struct net_device *dev,
9330 struct iw_request_info *info,
9331 union iwreq_data *wrqu, char *extra)
9332{
9333 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9334 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
9335 tSirHostOffloadReq offloadRequest;
9336 hdd_context_t *hdd_ctx;
9337 int ret;
9338
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009339 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309340
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009341 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9342 ret = wlan_hdd_validate_context(hdd_ctx);
9343 if (0 != ret)
9344 return ret;
9345
9346 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009347 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009348 return -EINVAL;
9349 }
9350
9351 /* Debug display of request components. */
9352 switch (pRequest->offloadType) {
9353 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07009354 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009355 switch (pRequest->enableOrDisable) {
9356 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009357 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009358 break;
9359 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009360 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009361 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009362 hdd_warn(" ARP offload enable");
9363 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009364 pRequest->params.hostIpv4Addr[0],
9365 pRequest->params.hostIpv4Addr[1],
9366 pRequest->params.hostIpv4Addr[2],
9367 pRequest->params.hostIpv4Addr[3]);
9368 }
9369 break;
9370
9371 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -07009372 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009373 switch (pRequest->enableOrDisable) {
9374 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009375 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009376 break;
9377 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -07009378 hdd_info(" enable");
9379 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009380 *(uint16_t *) (pRequest->params.hostIpv6Addr),
9381 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9382 2),
9383 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9384 4),
9385 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9386 6),
9387 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9388 8),
9389 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9390 10),
9391 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9392 12),
9393 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9394 14));
9395 }
9396 }
9397
9398 /* Execute offload request. The reason that we can copy the
9399 * request information from the ioctl structure to the SME
9400 * structure is that they are laid out exactly the same.
9401 * Otherwise, each piece of information would have to be
9402 * copied individually.
9403 */
9404 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309405 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009406 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
9407 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009408 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009409 return -EINVAL;
9410 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309411 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009412 return 0;
9413}
9414
9415static int iw_set_host_offload(struct net_device *dev,
9416 struct iw_request_info *info,
9417 union iwreq_data *wrqu, char *extra)
9418{
9419 int ret;
9420
9421 cds_ssr_protect(__func__);
9422 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9423 cds_ssr_unprotect(__func__);
9424
9425 return ret;
9426}
9427
9428/**
9429 * iw_set_keepalive_params - Set keepalive params ioctl handler
9430 * @dev: device upon which the ioctl was received
9431 * @info: ioctl request information
9432 * @wrqu: ioctl request data
9433 * @extra: ioctl extra data
9434 *
9435 * Return: 0 on success, non-zero on error
9436 */
9437static int __iw_set_keepalive_params(struct net_device *dev,
9438 struct iw_request_info *info,
9439 union iwreq_data *wrqu, char *extra)
9440{
9441 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009442 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009443 hdd_context_t *hdd_ctx;
9444 int ret;
9445
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009446 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309447
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009448 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9449 ret = wlan_hdd_validate_context(hdd_ctx);
9450 if (0 != ret)
9451 return ret;
9452
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009453 if (wrqu->data.length != sizeof(*request)) {
9454 hdd_err("Invalid length %d", wrqu->data.length);
9455 return -EINVAL;
9456 }
9457
9458 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
9459 hdd_err("Value of timePeriod %d exceed Max limit %d",
9460 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009461 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
9462 return -EINVAL;
9463 }
9464
9465 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009466 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
9467 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009468
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009469 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009470 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009471 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009472 break;
9473
9474 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009475 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009476
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009477 hdd_info("Host IP address: %d.%d.%d.%d",
9478 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
9479 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009480
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009481 hdd_info("Dest IP address: %d.%d.%d.%d",
9482 request->destIpv4Addr[0], request->destIpv4Addr[1],
9483 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009484
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08009485 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
9486 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009487 break;
9488 }
9489
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009490 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009491
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309492 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009493 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009494 pAdapter->sessionId, request)) {
9495 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009496 return -EINVAL;
9497 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309498 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009499 return 0;
9500}
9501
9502static int iw_set_keepalive_params(struct net_device *dev,
9503 struct iw_request_info *info,
9504 union iwreq_data *wrqu,
9505 char *extra)
9506{
9507 int ret;
9508
9509 cds_ssr_protect(__func__);
9510 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9511 cds_ssr_unprotect(__func__);
9512
9513 return ret;
9514}
9515
9516#ifdef WLAN_FEATURE_PACKET_FILTERING
9517/**
9518 * wlan_hdd_set_filter() - Set packet filter
9519 * @hdd_ctx: Global HDD context
9520 * @request: Packet filter request struct
9521 * @sessionId: Target session for the request
9522 *
9523 * Return: 0 on success, non-zero on error
9524 */
9525static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
9526 struct pkt_filter_cfg *request,
9527 uint8_t sessionId)
9528{
9529 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
9530 tSirRcvFltPktClearParam packetFilterClrReq = {0};
9531 int i = 0;
9532
9533 if (hdd_ctx->config->disablePacketFilter) {
9534 hdd_err("packet filtering disabled in ini returning");
9535 return 0;
9536 }
9537
9538 /* Debug display of request components. */
9539 hdd_info("Packet Filter Request : FA %d params %d",
9540 request->filter_action, request->num_params);
9541
9542 switch (request->filter_action) {
9543 case HDD_RCV_FILTER_SET:
9544 hdd_info("Set Packet Filter Request for Id: %d",
9545 request->filter_id);
9546
9547 packetFilterSetReq.filterId = request->filter_id;
9548 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
9549 hdd_err("Number of Params exceed Max limit %d",
9550 request->num_params);
9551 return -EINVAL;
9552 }
9553 packetFilterSetReq.numFieldParams = request->num_params;
9554 packetFilterSetReq.coalesceTime = 0;
9555 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
9556 for (i = 0; i < request->num_params; i++) {
9557 packetFilterSetReq.paramsData[i].protocolLayer =
9558 request->params_data[i].protocol_layer;
9559 packetFilterSetReq.paramsData[i].cmpFlag =
9560 request->params_data[i].compare_flag;
9561 packetFilterSetReq.paramsData[i].dataOffset =
9562 request->params_data[i].data_offset;
9563 packetFilterSetReq.paramsData[i].dataLength =
9564 request->params_data[i].data_length;
9565 packetFilterSetReq.paramsData[i].reserved = 0;
9566
Dustin Brown4d1e8462016-12-14 12:12:24 -08009567 if (request->params_data[i].data_offset >
9568 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
9569 hdd_err("Invalid data offset %u for param %d (max = %d)",
9570 request->params_data[i].data_offset,
9571 i,
9572 SIR_MAX_FILTER_TEST_DATA_OFFSET);
9573 return -EINVAL;
9574 }
9575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009576 if (request->params_data[i].data_length >
9577 SIR_MAX_FILTER_TEST_DATA_LEN) {
9578 hdd_err("Error invalid data length %d",
9579 request->params_data[i].data_length);
9580 return -EINVAL;
9581 }
9582
9583 hdd_info("Proto %d Comp Flag %d Filter Type %d",
9584 request->params_data[i].protocol_layer,
9585 request->params_data[i].compare_flag,
9586 packetFilterSetReq.filterType);
9587
9588 hdd_info("Data Offset %d Data Len %d",
9589 request->params_data[i].data_offset,
9590 request->params_data[i].data_length);
9591
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07009592 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
9593 < (request->params_data[i].data_length)) {
9594 hdd_err("Error invalid data length %d",
9595 request->params_data[i].data_length);
9596 return -EINVAL;
9597 }
9598
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009599 memcpy(&packetFilterSetReq.paramsData[i].compareData,
9600 request->params_data[i].compare_data,
9601 request->params_data[i].data_length);
9602 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
9603 request->params_data[i].data_mask,
9604 request->params_data[i].data_length);
9605
9606 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
9607 request->params_data[i].compare_data[0],
9608 request->params_data[i].compare_data[1],
9609 request->params_data[i].compare_data[2],
9610 request->params_data[i].compare_data[3],
9611 request->params_data[i].compare_data[4],
9612 request->params_data[i].compare_data[5]);
9613
9614 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
9615 request->params_data[i].data_mask[0],
9616 request->params_data[i].data_mask[1],
9617 request->params_data[i].data_mask[2],
9618 request->params_data[i].data_mask[3],
9619 request->params_data[i].data_mask[4],
9620 request->params_data[i].data_mask[5]);
9621 }
9622
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309623 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009624 sme_receive_filter_set_filter(hdd_ctx->hHal,
9625 &packetFilterSetReq,
9626 sessionId)) {
9627 hdd_err("Failure to execute Set Filter");
9628 return -EINVAL;
9629 }
9630
9631 break;
9632
9633 case HDD_RCV_FILTER_CLEAR:
9634
9635 hdd_info("Clear Packet Filter Request for Id: %d",
9636 request->filter_id);
9637 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309638 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009639 sme_receive_filter_clear_filter(hdd_ctx->hHal,
9640 &packetFilterClrReq,
9641 sessionId)) {
9642 hdd_err("Failure to execute Clear Filter");
9643 return -EINVAL;
9644 }
9645 break;
9646
9647 default:
9648 hdd_err("Packet Filter Request: Invalid %d",
9649 request->filter_action);
9650 return -EINVAL;
9651 }
9652 return 0;
9653}
9654
9655/**
9656 * __iw_set_packet_filter_params() - set packet filter parameters in target
9657 * @dev: Pointer to netdev
9658 * @info: Pointer to iw request info
9659 * @wrqu: Pointer to data
9660 * @extra: Pointer to extra data
9661 *
9662 * Return: 0 on success, non-zero on error
9663 */
9664static int __iw_set_packet_filter_params(struct net_device *dev,
9665 struct iw_request_info *info,
9666 union iwreq_data *wrqu, char *extra)
9667{
9668 int ret;
9669 hdd_context_t *hdd_ctx;
9670 struct iw_point priv_data;
9671 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9672 struct pkt_filter_cfg *request = NULL;
9673
Mukul Sharma472382f2015-11-02 20:16:31 +05309674 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009675 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309676 return -EPERM;
9677 }
9678
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009679 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009681 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9682 ret = wlan_hdd_validate_context(hdd_ctx);
9683 if (0 != ret)
9684 return ret;
9685
9686 if (hdd_priv_get_data(&priv_data, wrqu)) {
9687 hdd_err("failed to get priv data");
9688 return -EINVAL;
9689 }
9690
9691 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
9692 hdd_err("invalid priv data %p or invalid priv data length %d",
9693 priv_data.pointer, priv_data.length);
9694 return -EINVAL;
9695 }
9696
9697 /* copy data using copy_from_user */
9698 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9699 priv_data.length);
9700 if (NULL == request) {
9701 hdd_err("mem_alloc_copy_from_user_helper fail");
9702 return -ENOMEM;
9703 }
9704
9705 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
9706
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07009707 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309708 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009709 return ret;
9710}
9711
9712/**
9713 * iw_set_packet_filter_params() - set packet filter parameters in target
9714 * @dev: Pointer to netdev
9715 * @info: Pointer to iw request info
9716 * @wrqu: Pointer to data
9717 * @extra: Pointer to extra data
9718 *
9719 * Return: 0 on success, non-zero on error
9720 */
9721static int iw_set_packet_filter_params(struct net_device *dev,
9722 struct iw_request_info *info,
9723 union iwreq_data *wrqu, char *extra)
9724{
9725 int ret;
9726
9727 cds_ssr_protect(__func__);
9728 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9729 cds_ssr_unprotect(__func__);
9730
9731 return ret;
9732}
9733#endif
9734
9735
9736static int __iw_get_statistics(struct net_device *dev,
9737 struct iw_request_info *info,
9738 union iwreq_data *wrqu, char *extra)
9739{
9740
Anurag Chouhance0dc992016-02-16 18:18:03 +05309741 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309742 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009743 hdd_wext_state_t *pWextState;
9744 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9745 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9746 char *p = extra;
9747 int tlen = 0;
9748 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
9749 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
9750 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
9751 int ret;
9752
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009753 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009754
9755 ret = wlan_hdd_validate_context(hdd_ctx);
9756 if (0 != ret)
9757 return ret;
9758
9759 if (eConnectionState_Associated !=
9760 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
9761
9762 wrqu->txpower.value = 0;
9763 } else {
9764 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9765 SME_SUMMARY_STATS |
9766 SME_GLOBAL_CLASSA_STATS |
9767 SME_GLOBAL_CLASSB_STATS |
9768 SME_GLOBAL_CLASSC_STATS |
9769 SME_GLOBAL_CLASSD_STATS |
9770 SME_PER_STA_STATS,
9771 hdd_statistics_cb, 0, false,
9772 (WLAN_HDD_GET_STATION_CTX_PTR
9773 (pAdapter))->conn_info.staId[0],
9774 pAdapter, pAdapter->sessionId);
9775
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309776 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009777 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009778 return -EINVAL;
9779 }
9780
9781 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9782
Anurag Chouhance0dc992016-02-16 18:18:03 +05309783 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05309784 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009785 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +05309786 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009787 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009788 /*Remove the SME statistics list by passing NULL in callback argument */
9789 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9790 SME_SUMMARY_STATS |
9791 SME_GLOBAL_CLASSA_STATS |
9792 SME_GLOBAL_CLASSB_STATS |
9793 SME_GLOBAL_CLASSC_STATS |
9794 SME_GLOBAL_CLASSD_STATS |
9795 SME_PER_STA_STATS,
9796 NULL, 0, false,
9797 (WLAN_HDD_GET_STATION_CTX_PTR
9798 (pAdapter))->conn_info.
9799 staId[0], pAdapter,
9800 pAdapter->sessionId);
9801
9802 return -EINVAL;
9803 }
9804 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
9805 (uint8_t) sizeof(pStats->retry_cnt),
9806 (char *)&(pStats->retry_cnt[0]), tlen);
9807
9808 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
9809 (uint8_t) sizeof(pStats->multiple_retry_cnt),
9810 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
9811
9812 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
9813 (uint8_t) sizeof(pStats->tx_frm_cnt),
9814 (char *)&(pStats->tx_frm_cnt[0]), tlen);
9815
9816 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
9817 (uint8_t) sizeof(pStats->rx_frm_cnt),
9818 (char *)&(pStats->rx_frm_cnt), tlen);
9819
9820 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
9821 (uint8_t) sizeof(pStats->frm_dup_cnt),
9822 (char *)&(pStats->frm_dup_cnt), tlen);
9823
9824 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
9825 (uint8_t) sizeof(pStats->fail_cnt),
9826 (char *)&(pStats->fail_cnt[0]), tlen);
9827
9828 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
9829 (uint8_t) sizeof(pStats->rts_fail_cnt),
9830 (char *)&(pStats->rts_fail_cnt), tlen);
9831
9832 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
9833 (uint8_t) sizeof(pStats->ack_fail_cnt),
9834 (char *)&(pStats->ack_fail_cnt), tlen);
9835
9836 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
9837 (uint8_t) sizeof(pStats->rts_succ_cnt),
9838 (char *)&(pStats->rts_succ_cnt), tlen);
9839
9840 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
9841 (uint8_t) sizeof(pStats->rx_discard_cnt),
9842 (char *)&(pStats->rx_discard_cnt), tlen);
9843
9844 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
9845 (uint8_t) sizeof(pStats->rx_error_cnt),
9846 (char *)&(pStats->rx_error_cnt), tlen);
9847
9848 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
9849 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9850 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9851
9852 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
9853 (uint8_t) sizeof(dStats->rx_byte_cnt),
9854 (char *)&(dStats->rx_byte_cnt), tlen);
9855
9856 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
9857 (uint8_t) sizeof(dStats->rx_rate),
9858 (char *)&(dStats->rx_rate), tlen);
9859
9860 /* Transmit rate, in units of 500 kbit/sec */
9861 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
9862 (uint8_t) sizeof(aStats->tx_rate),
9863 (char *)&(aStats->tx_rate), tlen);
9864
9865 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
9866 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
9867 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
9868 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
9869 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
9870 (char *)&(dStats->rx_mc_byte_cnt), tlen);
9871 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
9872 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
9873 (char *)&(dStats->rx_bc_byte_cnt), tlen);
9874 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
9875 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
9876 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
9877 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
9878 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
9879 (char *)&(dStats->tx_mc_byte_cnt), tlen);
9880 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
9881 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
9882 (char *)&(dStats->tx_bc_byte_cnt), tlen);
9883
9884 wrqu->data.length = tlen;
9885
9886 }
9887
9888 EXIT();
9889
9890 return 0;
9891}
9892
9893static int iw_get_statistics(struct net_device *dev,
9894 struct iw_request_info *info,
9895 union iwreq_data *wrqu, char *extra)
9896{
9897 int ret;
9898
9899 cds_ssr_protect(__func__);
9900 ret = __iw_get_statistics(dev, info, wrqu, extra);
9901 cds_ssr_unprotect(__func__);
9902
9903 return ret;
9904}
9905
9906#ifdef FEATURE_WLAN_SCAN_PNO
9907
9908/*Max Len for PNO notification*/
9909#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07009910static void found_pref_network_cb(void *callbackContext,
9911 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009912{
9913 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
9914 union iwreq_data wrqu;
9915 char buf[MAX_PNO_NOTIFY_LEN + 1];
9916
Jeff Johnson99bac312016-06-28 10:38:18 -07009917 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009918 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
9919
9920 /* create the event */
9921 memset(&wrqu, 0, sizeof(wrqu));
9922 memset(buf, 0, sizeof(buf));
9923
9924 snprintf(buf, MAX_PNO_NOTIFY_LEN,
9925 "QCOM: Found preferred network: %s with RSSI of -%u",
9926 pPrefNetworkFoundInd->ssId.ssId,
9927 (unsigned int)pPrefNetworkFoundInd->rssi);
9928
9929 wrqu.data.pointer = buf;
9930 wrqu.data.length = strlen(buf);
9931
9932 /* send the event */
9933
9934 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
9935
9936}
9937
9938/**
9939 * __iw_set_pno() - Preferred Network Offload ioctl handler
9940 * @dev: device upon which the ioctl was received
9941 * @info: ioctl request information
9942 * @wrqu: ioctl request data
9943 * @extra: ioctl extra data
9944 *
9945 * This function parses a Preferred Network Offload command
9946 * Input is string based and expected to be of the form:
9947 *
9948 * <enable(1) | disable(0)>
9949 * when enabling:
9950 * <number of networks>
9951 * for each network:
9952 * <ssid_len> <ssid> <authentication> <encryption>
9953 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -07009954 * <scan_time (seconds)>
9955 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009956 * <suspend mode>
9957 *
9958 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -07009959 * 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 -08009960 *
9961 * this translates into:
9962 * -----------------------------
9963 * enable PNO
9964 * 2 networks
9965 * Network 1:
9966 * test - with authentication type 0 and encryption type 0,
9967 * search on 3 channels: 1 6 and 11,
9968 * SSID bcast type is unknown (directed probe will be sent if
9969 * AP not found) and must meet -40dBm RSSI
9970 * Network 2:
9971 * test2 - with authentication type 4 and encryption type 4,
9972 * search on 6 channels 1, 2, 3, 4, 5 and 6
9973 * bcast type is non-bcast (directed probe will be sent)
9974 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009975 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -07009976 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009977 */
9978static int __iw_set_pno(struct net_device *dev,
9979 struct iw_request_info *info,
9980 union iwreq_data *wrqu, char *extra)
9981{
9982 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9983 hdd_context_t *hdd_ctx;
9984 int ret;
9985 int offset;
9986 char *ptr;
9987 uint8_t i, j, params, mode;
9988
9989 /* request is a large struct, so we make it static to avoid
9990 * stack overflow. This API is only invoked via ioctl, so it
9991 * is serialized by the kernel rtnl_lock and hence does not
9992 * need to be reentrant
9993 */
9994 static tSirPNOScanReq request;
9995
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009996 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009997
9998 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9999 ret = wlan_hdd_validate_context(hdd_ctx);
10000 if (ret)
10001 return ret;
10002
10003 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
10004
10005 request.enable = 0;
10006 request.ucNetworksCount = 0;
10007
10008 ptr = extra;
10009
10010 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
10011 hdd_err("PNO enable input is not valid %s", ptr);
10012 return -EINVAL;
10013 }
10014
10015 if (0 == request.enable) {
10016 /* Disable PNO, ignore any other params */
10017 memset(&request, 0, sizeof(request));
10018 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
10019 &request, adapter->sessionId,
10020 found_pref_network_cb, adapter);
10021 return 0;
10022 }
10023
10024 ptr += offset;
10025
10026 if (1 !=
10027 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
10028 hdd_err("PNO count input not valid %s", ptr);
10029 return -EINVAL;
10030
10031 }
10032
10033 hdd_info("PNO enable %d networks count %d offset %d",
10034 request.enable, request.ucNetworksCount, offset);
10035
10036 if ((0 == request.ucNetworksCount) ||
10037 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
10038 hdd_err("Network count %d invalid",
10039 request.ucNetworksCount);
10040 return -EINVAL;
10041 }
10042
10043 ptr += offset;
10044
10045 for (i = 0; i < request.ucNetworksCount; i++) {
10046
10047 request.aNetworks[i].ssId.length = 0;
10048
10049 params = sscanf(ptr, "%hhu %n",
10050 &(request.aNetworks[i].ssId.length),
10051 &offset);
10052
10053 if (1 != params) {
10054 hdd_err("PNO ssid length input is not valid %s", ptr);
10055 return -EINVAL;
10056 }
10057
10058 if ((0 == request.aNetworks[i].ssId.length) ||
10059 (request.aNetworks[i].ssId.length > 32)) {
10060 hdd_err("SSID Len %d is not correct for network %d",
10061 request.aNetworks[i].ssId.length, i);
10062 return -EINVAL;
10063 }
10064
10065 /* Advance to SSID */
10066 ptr += offset;
10067
10068 memcpy(request.aNetworks[i].ssId.ssId, ptr,
10069 request.aNetworks[i].ssId.length);
10070 ptr += request.aNetworks[i].ssId.length;
10071
10072 params = sscanf(ptr, "%u %u %hhu %n",
10073 &(request.aNetworks[i].authentication),
10074 &(request.aNetworks[i].encryption),
10075 &(request.aNetworks[i].ucChannelCount),
10076 &offset);
10077
10078 if (3 != params) {
10079 hdd_warn("Incorrect cmd %s", ptr);
10080 return -EINVAL;
10081 }
10082
10083 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
10084 request.aNetworks[i].ssId.length,
10085 request.aNetworks[i].ssId.length,
10086 request.aNetworks[i].ssId.ssId,
10087 request.aNetworks[i].authentication,
10088 request.aNetworks[i].encryption,
10089 request.aNetworks[i].ucChannelCount, offset);
10090
10091 /* Advance to channel list */
10092 ptr += offset;
10093
10094 if (SIR_PNO_MAX_NETW_CHANNELS <
10095 request.aNetworks[i].ucChannelCount) {
10096 hdd_warn("Incorrect number of channels");
10097 return -EINVAL;
10098 }
10099
10100 if (0 != request.aNetworks[i].ucChannelCount) {
10101 for (j = 0; j < request.aNetworks[i].ucChannelCount;
10102 j++) {
10103 if (1 !=
10104 sscanf(ptr, "%hhu %n",
10105 &(request.aNetworks[i].
10106 aChannels[j]), &offset)) {
10107 hdd_err("PNO network channel input is not valid %s",
10108 ptr);
10109 return -EINVAL;
10110 }
10111 /* Advance to next channel number */
10112 ptr += offset;
10113 }
10114 }
10115
10116 if (1 != sscanf(ptr, "%u %n",
10117 &(request.aNetworks[i].bcastNetwType),
10118 &offset)) {
10119 hdd_err("PNO broadcast network type input is not valid %s",
10120 ptr);
10121 return -EINVAL;
10122 }
10123
10124 hdd_notice("PNO bcastNetwType %d offset %d",
10125 request.aNetworks[i].bcastNetwType, offset);
10126
10127 /* Advance to rssi Threshold */
10128 ptr += offset;
10129 if (1 != sscanf(ptr, "%d %n",
10130 &(request.aNetworks[i].rssiThreshold),
10131 &offset)) {
10132 hdd_err("PNO rssi threshold input is not valid %s",
10133 ptr);
10134 return -EINVAL;
10135 }
10136 hdd_notice("PNO rssi %d offset %d",
10137 request.aNetworks[i].rssiThreshold, offset);
10138 /* Advance to next network */
10139 ptr += offset;
10140 } /* For ucNetworkCount */
10141
Dustin Brown43e87292016-10-10 10:38:25 -070010142 request.fast_scan_period = 0;
10143 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
10144 request.fast_scan_period *= MSEC_PER_SEC;
10145 ptr += offset;
10146 }
10147
10148 request.fast_scan_max_cycles = 0;
10149 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
10150 &offset) > 0)
10151 ptr += offset;
10152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010153 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
10154
10155 request.modePNO = mode;
10156 /* for LA we just expose suspend option */
10157 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
10158 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
10159 }
10160
10161 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
10162 &request,
10163 adapter->sessionId,
10164 found_pref_network_cb, adapter);
10165
10166 return 0;
10167}
10168
10169static int iw_set_pno(struct net_device *dev,
10170 struct iw_request_info *info,
10171 union iwreq_data *wrqu, char *extra)
10172{
10173 int ret;
10174
10175 cds_ssr_protect(__func__);
10176 ret = __iw_set_pno(dev, info, wrqu, extra);
10177 cds_ssr_unprotect(__func__);
10178
10179 return ret;
10180}
10181#endif /* FEATURE_WLAN_SCAN_PNO */
10182
10183/* Common function to SetBand */
10184int hdd_set_band(struct net_device *dev, u8 ui_band)
10185{
10186 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10187 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10188 eCsrBand band;
10189
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010190 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010191 hdd_context_t *pHddCtx;
10192 hdd_adapter_list_node_t *pAdapterNode, *pNext;
10193 eCsrBand currBand = eCSR_BAND_MAX;
10194 eCsrBand connectedBand;
10195
10196 pAdapterNode = NULL;
10197 pNext = NULL;
10198 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10199
10200 switch (ui_band) {
10201 case WLAN_HDD_UI_BAND_AUTO:
10202 band = eCSR_BAND_ALL;
10203 break;
10204 case WLAN_HDD_UI_BAND_5_GHZ:
10205 band = eCSR_BAND_5G;
10206 break;
10207 case WLAN_HDD_UI_BAND_2_4_GHZ:
10208 band = eCSR_BAND_24;
10209 break;
10210 default:
10211 band = eCSR_BAND_MAX;
10212 }
10213
Jeff Johnson99bac312016-06-28 10:38:18 -070010214 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010215
10216 if (band == eCSR_BAND_MAX) {
10217 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -070010218 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010219 return -EINVAL;
10220 }
10221
10222 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
10223 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010224 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010225 band, pHddCtx->config->nBandCapability);
10226 return -EIO;
10227 }
10228
10229 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010230 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010231 pHddCtx->config->nBandCapability);
10232 band = pHddCtx->config->nBandCapability;
10233 }
10234
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010235 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010236 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010237 return -EIO;
10238 }
10239
10240 if (currBand != band) {
10241 /* Change band request received.
10242 * Abort pending scan requests, flush the existing scan results,
10243 * and change the band capability
10244 */
Jeff Johnson99bac312016-06-28 10:38:18 -070010245 hdd_notice("Current band value = %u, new setting %u ",
10246 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010247
10248 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010249 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010250 pAdapter = pAdapterNode->pAdapter;
10251 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10252 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053010253 INVALID_SCAN_ID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010254 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
10255 connectedBand =
10256 hdd_conn_get_connected_band
10257 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
10258
10259 /* Handling is done only for STA and P2P */
10260 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -080010261 ((pAdapter->device_mode == QDF_STA_MODE)
10262 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010263 &&
10264 (hdd_conn_is_connected
10265 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
10266 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010267 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010268 long lrc;
10269
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010270 /* STA already connected on current
10271 * band, So issue disconnect first,
10272 * then change the band
10273 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010274
Jeff Johnson99bac312016-06-28 10:38:18 -070010275 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010276 hdd_device_mode_to_string(pAdapter->device_mode),
10277 pAdapter->device_mode, currBand, band);
10278 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10279
10280 status =
10281 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
10282 (pAdapter),
10283 pAdapter->sessionId,
10284 eCSR_DISCONNECT_REASON_UNSPECIFIED);
10285
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010286 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010287 hdd_err("csr_roam_disconnect failure, returned %d",
10288 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010289 return -EINVAL;
10290 }
10291
10292 lrc =
10293 wait_for_completion_timeout(&pAdapter->
10294 disconnect_comp_var,
10295 msecs_to_jiffies
10296 (WLAN_WAIT_TIME_DISCONNECT));
10297
10298 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010299 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010300 return -ETIMEDOUT;
10301 }
10302 }
10303
10304 sme_scan_flush_result(hHal);
10305
10306 status =
10307 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
10308 pAdapterNode = pNext;
10309 }
10310
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010311 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010312 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010313 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010314 band);
10315 return -EINVAL;
10316 }
10317 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
10318 }
10319 return 0;
10320}
10321
10322int hdd_set_band_helper(struct net_device *dev, const char *command)
10323{
10324 uint8_t band;
10325 int ret;
10326
10327 /* Convert the band value from ascii to integer */
10328 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
10329 ret = kstrtou8(command, 10, &band);
10330 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010331 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010332 return -EINVAL;
10333 }
10334
10335 return hdd_set_band(dev, band);
10336}
10337
10338static int __iw_set_band_config(struct net_device *dev,
10339 struct iw_request_info *info,
10340 union iwreq_data *wrqu, char *extra)
10341{
10342 int *value = (int *)extra;
10343
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010344 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010345
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010346 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010347 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010348 return -EPERM;
10349 }
10350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010351 return hdd_set_band(dev, value[0]);
10352}
10353
10354static int iw_set_band_config(struct net_device *dev,
10355 struct iw_request_info *info,
10356 union iwreq_data *wrqu, char *extra)
10357{
10358 int ret;
10359
10360 cds_ssr_protect(__func__);
10361 ret = __iw_set_band_config(dev, info, wrqu, extra);
10362 cds_ssr_unprotect(__func__);
10363
10364 return ret;
10365}
10366
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010367/**
10368 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
10369 * @adapter: Handle to adapter
10370 * @chan: Monitor mode channel
10371 * @bandwidth: Capture channel bandwidth
10372 *
10373 * Return: 0 on success else error code.
10374 */
10375static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
10376 uint32_t bandwidth)
10377{
10378 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10379 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
10380 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
10381 QDF_STATUS status;
10382 tHalHandle hal_hdl = hdd_ctx->hHal;
10383 struct qdf_mac_addr bssid;
10384 tCsrRoamProfile roam_profile;
10385 struct ch_params_s ch_params;
10386
10387 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
10388 hdd_err("Not supported, device is not in monitor mode");
10389 return -EINVAL;
10390 }
10391
10392 hdd_info("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080010393 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010394 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
10395 roam_profile.ChannelInfo.numOfChannels = 1;
10396 roam_profile.phyMode = ch_info->phy_mode;
10397 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070010398 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010399
10400 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
10401 QDF_MAC_ADDR_SIZE);
10402
10403 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -070010404 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010405 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
10406 &roam_profile);
10407 if (status) {
10408 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
10409 status);
10410 }
10411
10412 return qdf_status_to_os_return(status);
10413}
10414
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010415static int __iw_set_two_ints_getnone(struct net_device *dev,
10416 struct iw_request_info *info,
10417 union iwreq_data *wrqu, char *extra)
10418{
10419 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10420 int *value = (int *)extra;
10421 int sub_cmd = value[0];
10422 int ret;
10423 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10424
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010425 ENTER_DEV(dev);
10426
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010427 ret = wlan_hdd_validate_context(hdd_ctx);
10428 if (0 != ret)
10429 return ret;
10430
10431 switch (sub_cmd) {
10432 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -070010433 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010434 ret = wma_cli_set_command(pAdapter->sessionId,
10435 WMI_STA_SMPS_PARAM_CMDID,
10436 value[1] << WMA_SMPS_PARAM_VALUE_S
10437 | value[2],
10438 VDEV_CMD);
10439 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070010440#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010441 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -070010442 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010443 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053010444 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
10445 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010446 ret = wma_cli_set2_command(pAdapter->sessionId,
10447 GEN_PARAM_CRASH_INJECT,
10448 value[1], value[2], GEN_CMD);
10449 break;
10450#endif
Govind Singha471e5e2015-10-12 17:11:14 +053010451 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010452 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010453 value[1], value[2]);
10454 ret = wma_cli_set2_command(pAdapter->sessionId,
10455 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
10456 value[1], value[2], DBG_CMD);
10457 break;
10458 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070010459 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %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_SET_HIST_INTVL_CMDID,
10463 value[1], value[2], DBG_CMD);
10464 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010465 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
10466 hdd_debug("Ioctl to set dual fw mode config");
10467 if (hdd_ctx->config->dual_mac_feature_disable) {
10468 hdd_err("Dual mac feature is disabled from INI");
10469 return -EPERM;
10470 }
10471 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -080010472 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010473 break;
10474 case WE_DUMP_DP_TRACE_LEVEL:
10475 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
10476 value[1], value[2]);
10477 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010478 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053010479 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
10480 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053010481 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
10482 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010483 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010484 case WE_SET_MON_MODE_CHAN:
10485 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
10486 break;
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010487 case WE_SET_WLAN_SUSPEND:
Dustin Brownbc81a472016-10-26 16:56:59 -070010488 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010489 break;
10490 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070010491 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010492 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010493 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070010494 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010495 break;
10496 }
10497
10498 return ret;
10499}
10500
10501static int iw_set_two_ints_getnone(struct net_device *dev,
10502 struct iw_request_info *info,
10503 union iwreq_data *wrqu, char *extra)
10504{
10505 int ret;
10506
10507 cds_ssr_protect(__func__);
10508 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
10509 cds_ssr_unprotect(__func__);
10510
10511 return ret;
10512}
10513
10514/* Define the Wireless Extensions to the Linux Network Device structure */
10515/* A number of these routines are NULL (meaning they are not implemented.) */
10516
10517static const iw_handler we_handler[] = {
10518 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10519 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10520 (iw_handler) NULL, /* SIOCSIWNWID */
10521 (iw_handler) NULL, /* SIOCGIWNWID */
10522 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
10523 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
10524 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
10525 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
10526 (iw_handler) NULL, /* SIOCSIWSENS */
10527 (iw_handler) NULL, /* SIOCGIWSENS */
10528 (iw_handler) NULL, /* SIOCSIWRANGE */
10529 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10530 (iw_handler) NULL, /* SIOCSIWPRIV */
10531 (iw_handler) NULL, /* SIOCGIWPRIV */
10532 (iw_handler) NULL, /* SIOCSIWSTATS */
10533 (iw_handler) NULL, /* SIOCGIWSTATS */
10534 (iw_handler) NULL, /* SIOCSIWSPY */
10535 (iw_handler) NULL, /* SIOCGIWSPY */
10536 (iw_handler) NULL, /* SIOCSIWTHRSPY */
10537 (iw_handler) NULL, /* SIOCGIWTHRSPY */
10538 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
10539 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
10540 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
10541 (iw_handler) NULL, /* SIOCGIWAPLIST */
10542 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
10543 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
10544 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
10545 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
10546 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
10547 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
10548 (iw_handler) NULL, /* -- hole -- */
10549 (iw_handler) NULL, /* -- hole -- */
10550 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
10551 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
10552 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
10553 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
10554 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
10555 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
10556 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
10557 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
10558 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
10559 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
10560 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
10561 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
10562 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
10563 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
10564 (iw_handler) NULL, /* -- hole -- */
10565 (iw_handler) NULL, /* -- hole -- */
10566 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
10567 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
10568 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
10569 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
10570 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
10571 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
10572 (iw_handler) NULL, /* SIOCSIWPMKSA */
10573};
10574
10575static const iw_handler we_private[] = {
10576
10577 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
10578 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
10579 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
10580 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10581 iw_set_three_ints_getnone,
10582 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
10583 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
10584 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10585 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010586 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
10587 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010588 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10589 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10590 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010591 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010592 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10593 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10594 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
10595 iw_set_keepalive_params,
10596#ifdef WLAN_FEATURE_PACKET_FILTERING
10597 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
10598 iw_set_packet_filter_params,
10599#endif
10600#ifdef FEATURE_WLAN_SCAN_PNO
10601 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
10602#endif
10603 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080010604 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
10605 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010606 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
10607 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10608 iw_set_two_ints_getnone,
10609 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
10610 iw_set_dot11p_channel_sched,
10611};
10612
10613/*Maximum command length can be only 15 */
10614static const struct iw_priv_args we_private_args[] = {
10615
10616 /* handlers for main ioctl */
10617 {WLAN_PRIV_SET_INT_GET_NONE,
10618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10619 0,
10620 ""},
10621
10622 /* handlers for sub-ioctl */
10623 {WE_SET_11D_STATE,
10624 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10625 0,
10626 "set11Dstate"},
10627
10628 {WE_WOWL,
10629 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10630 0,
10631 "wowl"},
10632
10633 {WE_SET_POWER,
10634 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10635 0,
10636 "setPower"},
10637
10638 {WE_SET_MAX_ASSOC,
10639 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10640 0,
10641 "setMaxAssoc"},
10642
10643 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10644 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10645 "setAutoChannel" },
10646
10647 {WE_SET_SCAN_DISABLE,
10648 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10649 0,
10650 "scan_disable"},
10651
10652 {WE_SET_DATA_INACTIVITY_TO,
10653 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10654 0,
10655 "inactivityTO"},
10656
10657 {WE_SET_MAX_TX_POWER,
10658 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10659 0,
10660 "setMaxTxPower"},
10661
10662 {WE_SET_TX_POWER,
10663 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10664 0,
10665 "setTxPower"},
10666
10667 {WE_SET_MC_RATE,
10668 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10669 0,
10670 "setMcRate"},
10671
10672 {WE_SET_MAX_TX_POWER_2_4,
10673 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10674 0,
10675 "setTxMaxPower2G"},
10676
10677 {WE_SET_MAX_TX_POWER_5_0,
10678 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10679 0,
10680 "setTxMaxPower5G"},
10681
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010682 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010683 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010684 0,
10685 "pktlog"},
10686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10688 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010689 * will support both
10690 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010691 {WE_SET_MAX_TX_POWER,
10692 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10693 0,
10694 "setTxMaxPower"},
10695
10696 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010697 * 1 = enable and 0 = disable
10698 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010699 {
10700 WE_SET_HIGHER_DTIM_TRANSITION,
10701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10702 0,
10703 "setHDtimTransn"
10704 },
10705
10706 {WE_SET_TM_LEVEL,
10707 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10708 0,
10709 "setTmLevel"},
10710
10711 {WE_SET_PHYMODE,
10712 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10713 0,
10714 "setphymode"},
10715
10716 {WE_SET_NSS,
10717 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10718 0,
10719 "nss"},
10720
10721 {WE_SET_LDPC,
10722 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10723 0,
10724 "ldpc"},
10725
10726 {WE_SET_TX_STBC,
10727 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10728 0,
10729 "tx_stbc"},
10730
10731 {WE_SET_RX_STBC,
10732 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10733 0,
10734 "rx_stbc"},
10735
10736 {WE_SET_SHORT_GI,
10737 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10738 0,
10739 "shortgi"},
10740
10741 {WE_SET_RTSCTS,
10742 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10743 0,
10744 "enablertscts"},
10745
10746 {WE_SET_CHWIDTH,
10747 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10748 0,
10749 "chwidth"},
10750
10751 {WE_SET_ANI_EN_DIS,
10752 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10753 0,
10754 "anienable"},
10755
10756 {WE_SET_ANI_POLL_PERIOD,
10757 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10758 0,
10759 "aniplen"},
10760
10761 {WE_SET_ANI_LISTEN_PERIOD,
10762 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10763 0,
10764 "anilislen"},
10765
10766 {WE_SET_ANI_OFDM_LEVEL,
10767 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10768 0,
10769 "aniofdmlvl"},
10770
10771 {WE_SET_ANI_CCK_LEVEL,
10772 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10773 0,
10774 "aniccklvl"},
10775
10776 {WE_SET_DYNAMIC_BW,
10777 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10778 0,
10779 "cwmenable"},
10780
10781 {WE_SET_CTS_CBW,
10782 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10783 0,
10784 "cts_cbw" },
10785
10786 {WE_SET_GTX_HT_MCS,
10787 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10788 0,
10789 "gtxHTMcs"},
10790
10791 {WE_SET_GTX_VHT_MCS,
10792 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10793 0,
10794 "gtxVHTMcs"},
10795
10796 {WE_SET_GTX_USRCFG,
10797 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10798 0,
10799 "gtxUsrCfg"},
10800
10801 {WE_SET_GTX_THRE,
10802 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10803 0,
10804 "gtxThre"},
10805
10806 {WE_SET_GTX_MARGIN,
10807 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10808 0,
10809 "gtxMargin"},
10810
10811 {WE_SET_GTX_STEP,
10812 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10813 0,
10814 "gtxStep"},
10815
10816 {WE_SET_GTX_MINTPC,
10817 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10818 0,
10819 "gtxMinTpc"},
10820
10821 {WE_SET_GTX_BWMASK,
10822 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10823 0,
10824 "gtxBWMask"},
10825
10826 {WE_SET_TX_CHAINMASK,
10827 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10828 0,
10829 "txchainmask"},
10830
10831 {WE_SET_RX_CHAINMASK,
10832 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10833 0,
10834 "rxchainmask"},
10835
10836 {WE_SET_11N_RATE,
10837 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10838 0,
10839 "set11NRates"},
10840
10841 {WE_SET_VHT_RATE,
10842 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10843 0,
10844 "set11ACRates"},
10845
10846 {WE_SET_AMPDU,
10847 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10848 0,
10849 "ampdu"},
10850
10851 {WE_SET_AMSDU,
10852 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10853 0,
10854 "amsdu"},
10855
10856 {WE_SET_BURST_ENABLE,
10857 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10858 0,
10859 "burst_enable"},
10860
10861 {WE_SET_BURST_DUR,
10862 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10863 0,
10864 "burst_dur"},
10865
10866 {WE_SET_TXPOW_2G,
10867 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10868 0,
10869 "txpow2g"},
10870
10871 {WE_SET_TXPOW_5G,
10872 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10873 0,
10874 "txpow5g"},
10875
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010876 /* Sub-cmds DBGLOG specific commands */
10877 {WE_DBGLOG_LOG_LEVEL,
10878 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10879 0,
10880 "dl_loglevel"},
10881
10882 {WE_DBGLOG_VAP_ENABLE,
10883 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10884 0,
10885 "dl_vapon"},
10886
10887 {WE_DBGLOG_VAP_DISABLE,
10888 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10889 0,
10890 "dl_vapoff"},
10891
10892 {WE_DBGLOG_MODULE_ENABLE,
10893 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10894 0,
10895 "dl_modon"},
10896
10897 {WE_DBGLOG_MODULE_DISABLE,
10898 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10899 0,
10900 "dl_modoff"},
10901
10902 {WE_DBGLOG_MOD_LOG_LEVEL,
10903 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10904 0,
10905 "dl_mod_loglevel"},
10906
10907 {WE_DBGLOG_TYPE,
10908 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10909 0,
10910 "dl_type"},
10911 {WE_DBGLOG_REPORT_ENABLE,
10912 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10913 0,
10914 "dl_report"},
10915
10916 {WE_SET_TXRX_FWSTATS,
10917 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10918 0,
10919 "txrx_fw_stats"},
10920
10921 {WE_TXRX_FWSTATS_RESET,
10922 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10923 0,
10924 "txrx_fw_st_rst"},
10925
10926 {WE_PPS_PAID_MATCH,
10927 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10928 0, "paid_match"},
10929
10930 {WE_PPS_GID_MATCH,
10931 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10932 0, "gid_match"},
10933
10934 {WE_PPS_EARLY_TIM_CLEAR,
10935 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10936 0, "tim_clear"},
10937
10938 {WE_PPS_EARLY_DTIM_CLEAR,
10939 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10940 0, "dtim_clear"},
10941
10942 {WE_PPS_EOF_PAD_DELIM,
10943 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10944 0, "eof_delim"},
10945
10946 {WE_PPS_MACADDR_MISMATCH,
10947 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10948 0, "mac_match"},
10949
10950 {WE_PPS_DELIM_CRC_FAIL,
10951 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10952 0, "delim_fail"},
10953
10954 {WE_PPS_GID_NSTS_ZERO,
10955 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10956 0, "nsts_zero"},
10957
10958 {WE_PPS_RSSI_CHECK,
10959 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10960 0, "rssi_chk"},
10961
10962 {WE_PPS_5G_EBT,
10963 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10964 0, "5g_ebt"},
10965
10966 {WE_SET_HTSMPS,
10967 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10968 0, "htsmps"},
10969
10970 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
10971 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10972 0, "set_qpspollcnt"},
10973
10974 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
10975 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10976 0, "set_qtxwake"},
10977
10978 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
10979 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10980 0, "set_qwakeintv"},
10981
10982 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
10983 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10984 0, "set_qnodatapoll"},
10985
10986 /* handlers for MCC time quota and latency sub ioctls */
10987 {WE_MCC_CONFIG_LATENCY,
10988 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10989 0, "setMccLatency"},
10990
10991 {WE_MCC_CONFIG_QUOTA,
10992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10993 0, "setMccQuota"},
10994
10995 {WE_SET_DEBUG_LOG,
10996 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10997 0, "setDbgLvl"},
10998
10999 /* handlers for early_rx power save */
11000 {WE_SET_EARLY_RX_ADJUST_ENABLE,
11001 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11002 0, "erx_enable"},
11003
11004 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
11005 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11006 0, "erx_bmiss_val"},
11007
11008 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
11009 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11010 0, "erx_bmiss_smpl"},
11011
11012 {WE_SET_EARLY_RX_SLOP_STEP,
11013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11014 0, "erx_slop_step"},
11015
11016 {WE_SET_EARLY_RX_INIT_SLOP,
11017 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11018 0, "erx_init_slop"},
11019
11020 {WE_SET_EARLY_RX_ADJUST_PAUSE,
11021 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11022 0, "erx_adj_pause"},
11023
11024 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
11025 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11026 0, "erx_dri_sample"},
11027
11028 {WE_DUMP_STATS,
11029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11030 0, "dumpStats"},
11031
11032 {WE_CLEAR_STATS,
11033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11034 0, "clearStats"},
11035
Govind Singha471e5e2015-10-12 17:11:14 +053011036 {WE_START_FW_PROFILE,
11037 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11038 0, "startProfile"},
11039
Abhishek Singh1bdb1572015-10-16 16:24:19 +053011040 {WE_SET_CHANNEL,
11041 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11042 0, "setChanChange" },
11043
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053011044 {WE_SET_CONC_SYSTEM_PREF,
11045 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11046 0, "setConcSysPref" },
11047
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011048 {WLAN_PRIV_SET_NONE_GET_INT,
11049 0,
11050 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11051 ""},
11052
11053 /* handlers for sub-ioctl */
11054 {WE_GET_11D_STATE,
11055 0,
11056 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11057 "get11Dstate"},
11058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011059 {WE_GET_WLAN_DBG,
11060 0,
11061 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11062 "getwlandbg"},
11063
11064 {WE_GET_MAX_ASSOC,
11065 0,
11066 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11067 "getMaxAssoc"},
11068
11069 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11070 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11071 "getAutoChannel" },
11072
11073 {WE_GET_CONCURRENCY_MODE,
11074 0,
11075 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11076 "getconcurrency"},
11077
11078 {WE_GET_NSS,
11079 0,
11080 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11081 "get_nss"},
11082
11083 {WE_GET_LDPC,
11084 0,
11085 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11086 "get_ldpc"},
11087
11088 {WE_GET_TX_STBC,
11089 0,
11090 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11091 "get_tx_stbc"},
11092
11093 {WE_GET_RX_STBC,
11094 0,
11095 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11096 "get_rx_stbc"},
11097
11098 {WE_GET_SHORT_GI,
11099 0,
11100 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11101 "get_shortgi"},
11102
11103 {WE_GET_RTSCTS,
11104 0,
11105 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11106 "get_rtscts"},
11107
11108 {WE_GET_CHWIDTH,
11109 0,
11110 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11111 "get_chwidth"},
11112
11113 {WE_GET_ANI_EN_DIS,
11114 0,
11115 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11116 "get_anienable"},
11117
11118 {WE_GET_ANI_POLL_PERIOD,
11119 0,
11120 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11121 "get_aniplen"},
11122
11123 {WE_GET_ANI_LISTEN_PERIOD,
11124 0,
11125 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11126 "get_anilislen"},
11127
11128 {WE_GET_ANI_OFDM_LEVEL,
11129 0,
11130 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11131 "get_aniofdmlvl"},
11132
11133 {WE_GET_ANI_CCK_LEVEL,
11134 0,
11135 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11136 "get_aniccklvl"},
11137
11138 {WE_GET_DYNAMIC_BW,
11139 0,
11140 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11141 "get_cwmenable"},
11142
11143 {WE_GET_GTX_HT_MCS,
11144 0,
11145 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11146 "get_gtxHTMcs"},
11147
11148 {WE_GET_GTX_VHT_MCS,
11149 0,
11150 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11151 "get_gtxVHTMcs"},
11152
11153 {WE_GET_GTX_USRCFG,
11154 0,
11155 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11156 "get_gtxUsrCfg"},
11157
11158 {WE_GET_GTX_THRE,
11159 0,
11160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11161 "get_gtxThre"},
11162
11163 {WE_GET_GTX_MARGIN,
11164 0,
11165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11166 "get_gtxMargin"},
11167
11168 {WE_GET_GTX_STEP,
11169 0,
11170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11171 "get_gtxStep"},
11172
11173 {WE_GET_GTX_MINTPC,
11174 0,
11175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11176 "get_gtxMinTpc"},
11177
11178 {WE_GET_GTX_BWMASK,
11179 0,
11180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11181 "get_gtxBWMask"},
11182
11183 {WE_GET_TX_CHAINMASK,
11184 0,
11185 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11186 "get_txchainmask"},
11187
11188 {WE_GET_RX_CHAINMASK,
11189 0,
11190 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11191 "get_rxchainmask"},
11192
11193 {WE_GET_11N_RATE,
11194 0,
11195 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11196 "get_11nrate"},
11197
11198 {WE_GET_AMPDU,
11199 0,
11200 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11201 "get_ampdu"},
11202
11203 {WE_GET_AMSDU,
11204 0,
11205 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11206 "get_amsdu"},
11207
11208 {WE_GET_BURST_ENABLE,
11209 0,
11210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11211 "get_burst_en"},
11212
11213 {WE_GET_BURST_DUR,
11214 0,
11215 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11216 "get_burst_dur"},
11217
11218 {WE_GET_TXPOW_2G,
11219 0,
11220 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11221 "get_txpow2g"},
11222
11223 {WE_GET_TXPOW_5G,
11224 0,
11225 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11226 "get_txpow5g"},
11227
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011228 {WE_GET_PPS_PAID_MATCH,
11229 0,
11230 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11231 "get_paid_match"},
11232
11233 {WE_GET_PPS_GID_MATCH,
11234 0,
11235 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11236 "get_gid_match"},
11237
11238 {WE_GET_PPS_EARLY_TIM_CLEAR,
11239 0,
11240 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11241 "get_tim_clear"},
11242
11243 {WE_GET_PPS_EARLY_DTIM_CLEAR,
11244 0,
11245 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11246 "get_dtim_clear"},
11247
11248 {WE_GET_PPS_EOF_PAD_DELIM,
11249 0,
11250 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11251 "get_eof_delim"},
11252
11253 {WE_GET_PPS_MACADDR_MISMATCH,
11254 0,
11255 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11256 "get_mac_match"},
11257
11258 {WE_GET_PPS_DELIM_CRC_FAIL,
11259 0,
11260 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11261 "get_delim_fail"},
11262
11263 {WE_GET_PPS_GID_NSTS_ZERO,
11264 0,
11265 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11266 "get_nsts_zero"},
11267
11268 {WE_GET_PPS_RSSI_CHECK,
11269 0,
11270 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11271 "get_rssi_chk"},
11272
11273 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
11274 0,
11275 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11276 "get_qpspollcnt"},
11277
11278 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
11279 0,
11280 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11281 "get_qtxwake"},
11282
11283 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
11284 0,
11285 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11286 "get_qwakeintv"},
11287
11288 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
11289 0,
11290 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11291 "get_qnodatapoll"},
11292
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011293 {WE_CAP_TSF,
11294 0,
11295 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11296 "cap_tsf"},
11297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011298 {WE_GET_TEMPERATURE,
11299 0,
11300 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11301 "get_temp"},
11302 /* handlers for main ioctl */
11303 {WLAN_PRIV_SET_CHAR_GET_NONE,
11304 IW_PRIV_TYPE_CHAR | 512,
11305 0,
11306 ""},
11307
11308 /* handlers for sub-ioctl */
11309 {WE_WOWL_ADD_PTRN,
11310 IW_PRIV_TYPE_CHAR | 512,
11311 0,
11312 "wowlAddPtrn"},
11313
11314 {WE_WOWL_DEL_PTRN,
11315 IW_PRIV_TYPE_CHAR | 512,
11316 0,
11317 "wowlDelPtrn"},
11318
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011319 /* handlers for sub-ioctl */
11320 {WE_NEIGHBOR_REPORT_REQUEST,
11321 IW_PRIV_TYPE_CHAR | 512,
11322 0,
11323 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080011324
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011325 {WE_SET_AP_WPS_IE,
11326 IW_PRIV_TYPE_CHAR | 512,
11327 0,
11328 "set_ap_wps_ie"},
11329
11330 {WE_SET_CONFIG,
11331 IW_PRIV_TYPE_CHAR | 512,
11332 0,
11333 "setConfig"},
11334
11335 /* handlers for main ioctl */
11336 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
11337 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11338 0,
11339 ""},
11340
11341 /* handlers for sub-ioctl */
11342 {WE_SET_WLAN_DBG,
11343 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11344 0,
11345 "setwlandbg"},
11346
11347 /* handlers for sub-ioctl */
11348 {WE_SET_DP_TRACE,
11349 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11350 0,
11351 "set_dp_trace"},
11352
11353 {WE_SET_SAP_CHANNELS,
11354 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11355 0,
11356 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053011357
11358 {WE_SET_FW_TEST,
11359 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11360 0, "fw_test"},
11361
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011362 /* handlers for main ioctl */
11363 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
11364 0,
11365 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11366 "" },
11367 {WE_GET_TSF,
11368 0,
11369 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11370 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011371
11372 {WE_SET_DUAL_MAC_SCAN_CONFIG,
11373 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11374 0,
11375 "set_scan_cfg"},
11376
11377 /* handlers for main ioctl */
11378 {WLAN_PRIV_GET_CHAR_SET_NONE,
11379 0,
11380 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11381 ""},
11382
11383 /* handlers for sub-ioctl */
11384 {WE_WLAN_VERSION,
11385 0,
11386 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11387 "version"},
11388 {WE_GET_STATS,
11389 0,
11390 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11391 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080011392 {WE_GET_SUSPEND_RESUME_STATS,
11393 0,
11394 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11395 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053011396 {WE_LIST_FW_PROFILE,
11397 0,
11398 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11399 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011400 {WE_GET_STATES,
11401 0,
11402 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11403 "getHostStates"},
11404 {WE_GET_CFG,
11405 0,
11406 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11407 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011408 {WE_GET_RSSI,
11409 0,
11410 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11411 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011412 {WE_GET_WMM_STATUS,
11413 0,
11414 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11415 "getWmmStatus"},
11416 {
11417 WE_GET_CHANNEL_LIST,
11418 0,
11419 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11420 "getChannelList"
11421 },
11422#ifdef FEATURE_WLAN_TDLS
11423 {
11424 WE_GET_TDLS_PEERS,
11425 0,
11426 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11427 "getTdlsPeers"
11428 },
11429#endif
11430#ifdef WLAN_FEATURE_11W
11431 {
11432 WE_GET_11W_INFO,
11433 0,
11434 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11435 "getPMFInfo"
11436 },
11437#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011438 {
11439 WE_GET_IBSS_STA_INFO,
11440 0,
11441 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11442 "getIbssSTAs"
11443 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011444 {WE_GET_PHYMODE,
11445 0,
11446 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11447 "getphymode"},
11448#ifdef FEATURE_OEM_DATA_SUPPORT
11449 {WE_GET_OEM_DATA_CAP,
11450 0,
11451 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11452 "getOemDataCap"},
11453#endif /* FEATURE_OEM_DATA_SUPPORT */
11454 {WE_GET_SNR,
11455 0,
11456 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11457 "getSNR"},
11458
11459 /* handlers for main ioctl */
11460 {WLAN_PRIV_SET_NONE_GET_NONE,
11461 0,
11462 0,
11463 ""},
11464
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011465 /* handlers for sub-ioctl */
11466 {
11467 WE_IBSS_GET_PEER_INFO_ALL,
11468 0,
11469 0,
11470 "ibssPeerInfoAll"
11471 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011472 {WE_GET_RECOVERY_STAT,
11473 0,
11474 0,
11475 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053011476
11477 {WE_GET_FW_PROFILE_DATA,
11478 0,
11479 0,
11480 "getProfileData"},
11481
11482 {WE_SET_REASSOC_TRIGGER,
11483 0,
11484 0,
11485 "reassoc"},
11486
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080011487 {WE_STOP_OBSS_SCAN,
11488 0,
11489 0,
11490 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011491 /* handlers for main ioctl */
11492 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
11493 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11494 0,
11495 ""},
11496
11497 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011498 {WE_IBSS_GET_PEER_INFO,
11499 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11500 0,
11501 "ibssPeerInfo"},
11502
11503 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011504 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11505 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11506 0,
11507 "setdumplog"},
11508
11509 {WE_MTRACE_DUMP_CMD,
11510 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11511 0,
11512 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080011513
11514 {WE_POLICY_MANAGER_CINFO_CMD,
11515 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11516 0,
11517 "pm_cinfo"},
11518
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011519#ifdef MPC_UT_FRAMEWORK
11520 {WE_POLICY_MANAGER_CLIST_CMD,
11521 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11522 0,
11523 "pm_clist"},
11524
11525 {WE_POLICY_MANAGER_DLIST_CMD,
11526 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11527 0,
11528 "pm_dlist"},
11529
11530 {WE_POLICY_MANAGER_DBS_CMD,
11531 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11532 0,
11533 "pm_dbs"},
11534
11535 {WE_POLICY_MANAGER_PCL_CMD,
11536 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11537 0,
11538 "pm_pcl"},
11539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011540 {WE_POLICY_MANAGER_ULIST_CMD,
11541 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11542 0,
11543 "pm_ulist"},
11544
11545 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
11546 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11547 0,
11548 "pm_query_action"},
11549
11550 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
11551 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11552 0,
11553 "pm_query_allow"},
11554
11555 {WE_POLICY_MANAGER_SCENARIO_CMD,
11556 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11557 0,
11558 "pm_run_scenario"},
11559
11560 {WE_POLICY_SET_HW_MODE_CMD,
11561 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11562 0,
11563 "pm_set_hw_mode"},
11564#endif
11565#ifdef FEATURE_WLAN_TDLS
11566 /* handlers for sub ioctl */
11567 {
11568 WE_TDLS_CONFIG_PARAMS,
11569 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11570 0,
11571 "setTdlsConfig"
11572 },
11573#endif
11574 {
11575 WE_UNIT_TEST_CMD,
11576 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11577 0,
11578 "setUnitTestCmd"
11579 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053011580 {
11581 WE_MAC_PWR_DEBUG_CMD,
11582 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11583 0,
11584 "halPwrDebug"
11585 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011586
11587#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11588 {WE_LED_FLASHING_PARAM,
11589 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11590 0,
11591 "gpio_control"},
11592#endif
11593 /* handlers for main ioctl */
11594 {WLAN_PRIV_ADD_TSPEC,
11595 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11596 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11597 "addTspec"},
11598
11599 /* handlers for main ioctl */
11600 {WLAN_PRIV_DEL_TSPEC,
11601 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11602 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11603 "delTspec"},
11604
11605 /* handlers for main ioctl */
11606 {WLAN_PRIV_GET_TSPEC,
11607 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11609 "getTspec"},
11610
11611 /* handlers for main ioctl - host offload */
11612 {
11613 WLAN_PRIV_SET_HOST_OFFLOAD,
11614 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
11615 0,
11616 "setHostOffload"
11617 }
11618 ,
11619
11620 {
11621 WLAN_GET_WLAN_STATISTICS,
11622 0,
11623 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11624 "getWlanStats"
11625 }
11626 ,
11627
11628 {
11629 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011630 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11631 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011632 0,
11633 "setKeepAlive"
11634 }
11635 ,
11636#ifdef WLAN_FEATURE_PACKET_FILTERING
11637 {
11638 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053011639 IW_PRIV_TYPE_BYTE |
11640 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011641 0,
11642 "setPktFilter"
11643 }
11644 ,
11645#endif
11646#ifdef FEATURE_WLAN_SCAN_PNO
11647 {
11648 WLAN_SET_PNO,
11649 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11650 0,
11651 "setpno"
11652 }
11653 ,
11654#endif
11655 {
11656 WLAN_SET_BAND_CONFIG,
11657 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11658 0,
11659 "SETBAND"
11660 }
11661 ,
11662 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080011663 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080011664 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011665 0,
11666 "setMCBCFilter"
11667 }
11668 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011669
11670 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011671 WLAN_GET_LINK_SPEED,
11672 IW_PRIV_TYPE_CHAR | 18,
11673 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11674 }
11675 ,
11676
11677 /* handlers for main ioctl */
11678 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
11679 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11680 0,
11681 ""}
11682 ,
11683 {WE_SET_SMPS_PARAM,
11684 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11685 0, "set_smps_param"}
11686 ,
11687 {WLAN_SET_DOT11P_CHANNEL_SCHED,
11688 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
11689 0, "set_dot11p" }
11690 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070011691#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011692 {WE_SET_FW_CRASH_INJECT,
11693 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11694 0, "crash_inject"}
11695 ,
11696#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070011697#ifdef WLAN_SUSPEND_RESUME_TEST
11698 {WE_SET_WLAN_SUSPEND,
11699 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11700 0, "wlan_suspend"}
11701 ,
11702 {WE_SET_WLAN_RESUME,
11703 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11704 0, "wlan_resume"}
11705 ,
11706#endif
Govind Singha471e5e2015-10-12 17:11:14 +053011707 {WE_ENABLE_FW_PROFILE,
11708 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11709 0, "enableProfile"}
11710 ,
11711 {WE_SET_FW_PROFILE_HIST_INTVL,
11712 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11713 0, "set_hist_intvl"}
11714 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011715 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
11716 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11717 0, "set_fw_mode_cfg"}
11718 ,
11719 {WE_DUMP_DP_TRACE_LEVEL,
11720 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11721 0, "dump_dp_trace"}
11722 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011723 {WE_SET_MON_MODE_CHAN,
11724 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11725 0, "setMonChan"}
11726 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070011727
11728 {WE_GET_ROAM_SYNCH_DELAY,
11729 0,
11730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11731 "hostroamdelay"}
11732 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011733};
11734
11735const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053011736 .num_standard = QDF_ARRAY_SIZE(we_handler),
11737 .num_private = QDF_ARRAY_SIZE(we_private),
11738 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011739
11740 .standard = (iw_handler *) we_handler,
11741 .private = (iw_handler *) we_private,
11742 .private_args = we_private_args,
11743 .get_wireless_stats = NULL,
11744};
11745
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011746/* hdd_set_wext() - configures bss parameters
11747 * @pAdapter: handle to adapter context
11748 *
11749 * Returns: none
11750 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011751static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011752{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011753 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11754 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011755
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011756 ENTER();
11757
11758 if (!pwextBuf) {
11759 hdd_err("ERROR: pwextBuf is NULL");
11760 return QDF_STATUS_E_FAILURE;
11761 }
11762
11763 if (!pHddStaCtx) {
11764 hdd_err("ERROR: pHddStaCtx is NULL");
11765 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011766 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011767
11768 /* Now configure the roaming profile links. To SSID and bssid. */
11769 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011770 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011771
11772 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011773 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011774
11775 /*Set the numOfChannels to zero to scan all the channels */
11776 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
11777 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
11778
11779 /* Default is no encryption */
11780 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
11781 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
11782 eCSR_ENCRYPT_TYPE_NONE;
11783
11784 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
11785 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
11786 eCSR_ENCRYPT_TYPE_NONE;
11787
11788 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
11789
11790 /* Default is no authentication */
11791 pwextBuf->roamProfile.AuthType.numEntries = 1;
11792 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11793
11794 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
11795 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11796
11797 /*Set the default scan mode */
11798 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
11799
11800 hdd_clear_roam_profile_ie(pAdapter);
11801
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011802 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011803 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011804
11805}
11806
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011807/**
11808 * hdd_register_wext() - register wext context
11809 * @dev: net device handle
11810 *
11811 * Registers wext interface context for a given net device
11812 *
11813 * Returns: 0 on success, errno on failure
11814 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011815int hdd_register_wext(struct net_device *dev)
11816{
11817 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011818 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011819 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011820
11821 ENTER();
11822
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070011823 if (!pwextBuf) {
11824 hdd_err(FL("ERROR: pwextBuf is NULL"));
11825 return QDF_STATUS_E_FAILURE;
11826 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070011827
11828 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011829 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
11830
11831 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->
11832 completion_var);
11833
11834 status = hdd_set_wext(pAdapter);
11835
Anurag Chouhance0dc992016-02-16 18:18:03 +053011836 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011837
Jeff Johnson99bac312016-06-28 10:38:18 -070011838 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011839 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011840 }
11841
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011842 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011843 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011844 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011845 }
11846
Anurag Chouhance0dc992016-02-16 18:18:03 +053011847 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->scanevent))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011848 hdd_err("ERROR: HDD scan event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011849 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011850 }
11851 /* Register as a wireless device */
11852 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
11853
11854 EXIT();
11855 return 0;
11856}
11857
11858int hdd_unregister_wext(struct net_device *dev)
11859{
Jeff Johnson99bac312016-06-28 10:38:18 -070011860 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011861
11862 if (dev != NULL) {
11863 rtnl_lock();
11864 dev->wireless_handlers = NULL;
11865 rtnl_unlock();
11866 }
11867
11868 return 0;
11869}