blob: ab0ca494e6774edad42d820423ac845d71a5a0a3 [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>
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080044#include <cdp_txrx_cmn.h>
Manjunathappa Prakash3454fd62016-04-01 08:52:06 -070045#include <cdp_txrx_stats.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "sir_params.h"
47#include "csr_api.h"
48#include "csr_inside_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include "sme_rrm_internal.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include <ani_global.h>
51#include "dot11f.h"
52#include <wlan_hdd_wowl.h>
53#include <wlan_hdd_cfg.h>
54#include <wlan_hdd_wmm.h>
55#include "utils_api.h"
56#include "wlan_hdd_p2p.h"
57#ifdef FEATURE_WLAN_TDLS
58#include "wlan_hdd_tdls.h"
59#endif
60
61#include "cds_ieee80211_common.h"
62#include "ol_if_athvar.h"
63#include "dbglog_host.h"
64#include "wma.h"
65
66#include "wlan_hdd_power.h"
67#include "qwlan_version.h"
68#include "wlan_hdd_host_offload.h"
69
70#include <linux/wireless.h>
71#include <net/cfg80211.h>
72
73#include "wlan_hdd_misc.h"
74
75#include "qc_sap_ioctl.h"
76#include "sme_api.h"
77#include "wma_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053078#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079#include "wlan_hdd_assoc.h"
80#include "wlan_hdd_ioctl.h"
81#include "wlan_hdd_scan.h"
82#include "sme_power_save_api.h"
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080083#include "wlan_policy_mgr_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084#include "wlan_hdd_conc_ut.h"
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070085#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086#include "wlan_hdd_ocb.h"
87#include "wlan_hdd_napi.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080088#include "cdp_txrx_flow_ctrl_legacy.h"
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070089#include "wlan_hdd_nan_datapath.h"
Nirav Shahbf1b0332016-05-25 14:27:39 +053090#include "wlan_hdd_stats.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070091#ifdef WLAN_SUSPEND_RESUME_TEST
92#include "wlan_hdd_driver_ops.h"
93#include "hif.h"
Rajeev Kumar9bb2e852016-09-24 12:29:25 -070094#include "pld_common.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070095#endif
Dhanashri Atree7d442a2016-07-14 18:20:29 -070096#include "wlan_hdd_lro.h"
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053097#include "cds_utils.h"
Jeff Johnsona6ace5b2017-01-23 07:11:02 -080098#include "wlan_hdd_request_manager.h"
Naveen Rawat910726a2017-03-06 11:42:51 -080099#include "os_if_wifi_pos.h"
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -0800100#include <cdp_txrx_stats.h>
101#include <cds_api.h>
Abhishek Singh0481d662017-04-11 18:20:11 +0530102#include <wlan_osif_priv.h>
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700103#include "wlan_hdd_regulatory.h"
104#include "wlan_reg_ucfg_api.h"
Abhishek Singh0481d662017-04-11 18:20:11 +0530105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106#define HDD_FINISH_ULA_TIME_OUT 800
107#define HDD_SET_MCBC_FILTERS_TO_FW 1
108#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110/* To Validate Channel against the Frequency and Vice-Versa */
Srinivas Girigowda48592672017-03-25 14:58:44 -0700111static const struct ccp_freq_chan_map freq_chan_map[] = {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
113 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
114 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
115 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
116 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
117 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
118 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
119 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
120 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
121 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
122 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
123 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
124
Srinivas Girigowdafba82a02017-03-24 21:26:35 -0700125#define FREQ_CHAN_MAP_TABLE_SIZE QDF_ARRAY_SIZE(freq_chan_map)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800126
127/* Private ioctls and their sub-ioctls */
128#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
129#define WE_SET_11D_STATE 1
130#define WE_WOWL 2
131#define WE_SET_POWER 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530132/*
133 * <ioctl>
134 * setMaxAssoc - Sets the maximum number of associated stations
135 *
136 * @INPUT: 1 to 32
137 *
138 * @OUTPUT: None
139 *
140 * This IOTCL sets the maximum number of associated stations
141 *
142 * @E.g: iwpriv wlan0 setMaxAssoc <value>
143 *
144 * Supported Feature: STA
145 *
146 * Usage: Internal/External
147 *
148 * </ioctl>
149 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800150#define WE_SET_MAX_ASSOC 4
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +0530151/*
152 * <ioctl>
153 * scan_diable - Disable scan
154 *
155 * @INPUT: set_value
156 *
157 * @OUTPUT: None
158 *
159 * This IOCTL is used to set disable scan
160 *
161 * @E.g: iwpriv wlan0 scan_disable 1
162 *
163 * Supported Feature: Scan
164 *
165 * Usage: Internal/External
166 *
167 * </ioctl>
168 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169#define WE_SET_SCAN_DISABLE 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530170/*
171 * <ioctl>
172 * inactivityTO - sets the timeout value for inactivity data while
173 * in power save mode
174 *
175 * @INPUT: int1…..int255
176 *
177 * @OUTPUT: None
178 *
179 * This IOCTL set the timeout value for inactivity data in power save mode
180 *
181 * @E.g: iwpriv wlan0 inactivityTO 20
182 *
183 * Supported Feature: STA
184 *
185 * Usage: Internal/External
186 *
187 * </ioctl>
188 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189#define WE_SET_DATA_INACTIVITY_TO 6
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530190/*
191 * <ioctl>
192 * setMaxTxPower - Dynamically sets the maximum transmission power
193 *
194 * @INPUT: Transmission power in dBm
195 *
196 * @OUTPUT: None
197 *
198 * This IOCTL dynamically sets the maximum transmission power
199 * This setting does not persist over reboots
200 *
201 * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
202 *
203 * Supported Feature: STA
204 *
205 * Usage: Internal/External
206 *
207 * </ioctl>
208 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209#define WE_SET_MAX_TX_POWER 7
210#define WE_SET_HIGHER_DTIM_TRANSITION 8
211#define WE_SET_TM_LEVEL 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530212/*
213 * <ioctl>
214 * setphymode - Set the phymode dynamically
215 *
216 * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
217 *
218 * @OUTPUT: None
219 *
220 * This IOCTL sets the phymode dynamically
221 *
222 * @E.g: iwpriv wlan0 setphymode 10
223 *
224 * Supported Feature: STA
225 *
226 * Usage: Internal/External
227 *
228 * </ioctl>
229 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230#define WE_SET_PHYMODE 10
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530231/*
232 * <ioctl>
233 * nss - Set the number of spatial streams
234 *
235 * @INPUT: int1…..int3
236 *
237 * @OUTPUT: None
238 *
239 * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
240 *
241 * @E.g: iwpriv wlan0 nss 2
242 *
243 * Supported Feature: STA
244 *
245 * Usage: Internal/External
246 *
247 * </ioctl>
248 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249#define WE_SET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530250/*
251 * <ioctl>
252 * ldpc - Enables or disables LDPC
253 *
254 * @INPUT: 0 – Disable, 1 - Enable
255 *
256 * @OUTPUT: None
257 *
258 * This IOCTL enables or disables LDPC
259 *
260 * @E.g: iwpriv wlan0 ldpc 1
261 *
262 * Supported Feature: STA
263 *
264 * Usage: Internal/External
265 *
266 * </ioctl>
267 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268#define WE_SET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530269/*
270 * <ioctl>
271 * tx_stbc - Enables or disables tx_stbc
272 *
273 * @INPUT: Int 0 – Disable, 1 - Enable
274 *
275 * @OUTPUT: None
276 *
277 * This IOTCL used to enables or disables tx_stbc
278 *
279 * @E.g: iwpriv wlan0 tx_stbc <value>
280 *
281 * Supported Feature: STA
282 *
283 * Usage: Internal/External
284 *
285 * </ioctl>
286 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287#define WE_SET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530288/*
289 * <ioctl>
290 * rx_stbc - Set the rx_stbc parameter
291 *
292 * @INPUT: Int 0 – Disable, 1 - Enable
293 *
294 * @OUTPUT: None
295 *
296 * This IOTCL used to set rx_stbc parameter
297 *
298 * @E.g: iwpriv wlan0 rx_stbc <value>
299 *
300 * Supported Feature: STA
301 *
302 * Usage: Internal/External
303 *
304 * </ioctl>
305 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306#define WE_SET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530307/*
308 * <ioctl>
309 * shortgi - Enables or disables a short-guard interval
310 *
311 * @INPUT: Int 0 – Disable, 1 - Enable
312 *
313 * @OUTPUT: None
314 *
315 * This IOCTL enables or disables a short-guard interval.
316 *
317 * @E.g: iwpriv wlan0 shortgi <value>
318 *
319 * Supported Feature: STA
320 *
321 * Usage: Internal/External
322 *
323 * </ioctl>
324 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325#define WE_SET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530326/*
327 * <ioctl>
328 * enablertscts - enables or disables rts/cts.
329 *
330 * @INPUT: 1-Enable , 0-Disable
331 *
332 * @OUTPUT: None
333 *
334 * This IOCTL enables or disables rts/cts.
335 *
336 * @E.g: iwpriv wlan0 enablertscts <value>
337 *
338 * Supported Feature: STA
339 *
340 * Usage: Internal/External
341 *
342 * </ioctl>
343 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344#define WE_SET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530345/*
346 * <ioctl>
347 * chwidth - Set the channel bandwidth
348 *
349 * @INPUT: 0-20mhz to 3-160mhz
350 *
351 * @OUTPUT: None
352 *
353 * This IOTCL used to set the channel bandwidth
354 *
355 * @E.g: iwpriv wlan0 chwidth 1
356 *
357 * Supported Feature: STA
358 *
359 * Usage: Internal/External
360 *
361 * </ioctl>
362 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363#define WE_SET_CHWIDTH 17
364#define WE_SET_ANI_EN_DIS 18
365#define WE_SET_ANI_POLL_PERIOD 19
366#define WE_SET_ANI_LISTEN_PERIOD 20
367#define WE_SET_ANI_OFDM_LEVEL 21
368#define WE_SET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530369/*
370 * <ioctl>
371 * cwmenable - Enables or disables the dynamic channel bandwidth
372 *
373 * @INPUT: 0-Disable, 1-Enable
374 *
375 * @OUTPUT: None
376 *
377 * This IOTCL used to enables or disables the dynamic channel bandwidth
378 *
379 * @E.g: iwpriv wlan0 cwmenable <value>
380 *
381 * Supported Feature: STA
382 *
383 * Usage: Internal/External
384 *
385 * </ioctl>
386 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387#define WE_SET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530388/*
389 * <ioctl>
390 * txchainmask - This IOCTL sets the current Tx chain mask
391 *
392 * @INPUT: Mask Value
393 *
394 * @OUTPUT: None
395 *
396 * This IOCTL sets the current Tx chain mask
397 *
398 * @E.g: iwpriv wlan0 txchainmask 1
399 *
400 * Supported Feature: STA
401 *
402 * Usage: Internal/External
403 *
404 * </ioctl>
405 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406#define WE_SET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530407/*
408 * <ioctl>
409 * rxchainmask - Sets the current Rx chain mask
410 *
411 * @INPUT: Mask Value
412 *
413 * @OUTPUT: None
414 *
415 * This IOCTL sets the current Rx chain mask. This command is the
416 * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
417 *
418 * @E.g: iwpriv wlan0 rxchainmask <value>
419 *
420 * Supported Feature: STA
421 *
422 * Usage: Internal/External
423 *
424 * </ioctl>
425 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426#define WE_SET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530427/*
428 * <ioctl>
429 * set11NRates - Fixes the Tx data rate of the 11N mode.
430 *
431 * @INPUT: 0x1b to 0x8f
432 *
433 * @OUTPUT: None
434 *
435 * This IOCTL fixes the Tx data rate of the 11N mode.
436 *
437 * @E.g: iwpriv wlan0 set11NRates 0x85
438 *
439 * Supported Feature: STA
440 *
441 * Usage: Internal/External
442 *
443 * </ioctl>
444 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445#define WE_SET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530446/*
447 * <ioctl>
448 * ampdu - Set the the maximum subframe of ampdu
449 *
450 * @INPUT: int 1 to int 63
451 *
452 * @OUTPUT: None
453 *
454 * This IOCTL sets the maximum subframe of ampdu.
455 *
456 * @E.g: iwpriv wlan0 ampdu 9
457 *
458 * Supported Feature: STA
459 *
460 * Usage: Internal/External
461 *
462 * </ioctl>
463 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464#define WE_SET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530465/*
466 * <ioctl>
467 * amsdu - Sets the maximum subframe of amsdu.
468 *
469 * @INPUT: int 1 to int 31
470 *
471 * @OUTPUT: None
472 *
473 * This IOCTL sets the maximum subframe of amsdu.
474 *
475 * @E.g: iwpriv wlan0 amsdu 9
476 *
477 * Supported Feature: STA
478 *
479 * Usage: Internal/External
480 *
481 * </ioctl>
482 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483#define WE_SET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530484/*
485 * <ioctl>
486 * txpow2g - current 2 GHz Tx power setting
487 *
488 * @INPUT: Tx power in dBm
489 *
490 * @OUTPUT: None
491 *
492 * This IOTCL used to set 2 ghz tx power
493 *
494 * @E.g: iwpriv wlan0 txpow2g
495 *
496 * Supported Feature: STA
497 *
498 * Usage: Internal/External
499 *
500 * </ioctl>
501 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502#define WE_SET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530503/*
504 * <ioctl>
505 * txpow5g - Current 5 GHz tx power setting
506 *
507 * @INPUT: Tx power in dBm
508 *
509 * @OUTPUT: None
510 *
511 * This IOTCL used to set the 5 ghz txpower
512 *
513 * @E.g: iwpriv wlan0 txpow5g
514 *
515 * Supported Feature: STA
516 *
517 * Usage: Internal/External
518 *
519 * </ioctl>
520 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521#define WE_SET_TXPOW_5G 30
522/* Private ioctl for firmware debug log */
523#define WE_DBGLOG_LOG_LEVEL 31
524#define WE_DBGLOG_VAP_ENABLE 32
525#define WE_DBGLOG_VAP_DISABLE 33
526#define WE_DBGLOG_MODULE_ENABLE 34
527#define WE_DBGLOG_MODULE_DISABLE 35
528#define WE_DBGLOG_MOD_LOG_LEVEL 36
529#define WE_DBGLOG_TYPE 37
530#define WE_SET_TXRX_FWSTATS 38
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530531/*
532 * <ioctl>
533 * set11ACRates - Fixes the Tx data rate of 11AC
534 *
535 * @INPUT: 0x1 to 0x9
536 *
537 * @OUTPUT: None
538 *
539 * This IOCTL fixes the Tx data rate of 11AC.
540 *
541 * @E.g: iwpriv wlan0 set11ACRates 0x9
542 *
543 * Supported Feature: STA
544 *
545 * Usage: Internal/External
546 *
547 * </ioctl>
548 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549#define WE_SET_VHT_RATE 39
550#define WE_DBGLOG_REPORT_ENABLE 40
551#define WE_TXRX_FWSTATS_RESET 41
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530552/*
553 * <ioctl>
554 * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
555 *
556 * @INPUT: Transmission power in dBm
557 *
558 * @OUTPUT: None
559 *
560 * This IOCTL sets the maximum transmit power for the 2.4-GHz band
561 * This setting does not persist over reboots
562 *
563 * @E.g: iwpriv wlan0 setTxMaxPower2G 10
564 *
565 * Supported Feature: STA
566 *
567 * Usage: Internal/External
568 *
569 * </ioctl>
570 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571#define WE_SET_MAX_TX_POWER_2_4 42
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530572/*
573 * <ioctl>
574 * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
575 *
576 * @INPUT: Transmission power in dBm
577 *
578 * @OUTPUT: None
579 *
580 * This IOCTL sets the maximum transmit power for the 5-GHz band
581 * This setting does not persist over reboots
582 *
583 * @E.g: iwpriv wlan0 setTxMaxPower5G 10
584 *
585 * Supported Feature: STA
586 *
587 * Usage: Internal/External
588 *
589 * </ioctl>
590 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800592#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593/* Private ioctl for packet powe save */
594#define WE_PPS_PAID_MATCH 45
595#define WE_PPS_GID_MATCH 46
596#define WE_PPS_EARLY_TIM_CLEAR 47
597#define WE_PPS_EARLY_DTIM_CLEAR 48
598#define WE_PPS_EOF_PAD_DELIM 49
599#define WE_PPS_MACADDR_MISMATCH 50
600#define WE_PPS_DELIM_CRC_FAIL 51
601#define WE_PPS_GID_NSTS_ZERO 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530602/*
603 * <ioctl>
604 * rssi_chk - Chek the rssi
605 *
606 * @INPUT: One argument as input
607 *
608 * @OUTPUT: rssi
609 * wlan0 rssi_chk:56
610 *
611 * This IOTCL used to chek rssi
612 *
613 * @E.g: iwpriv wlan0 rssi_chk <value>
614 *
615 * Supported Feature: STA
616 *
617 * Usage: Internal/External
618 *
619 * </ioctl>
620 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621#define WE_PPS_RSSI_CHECK 53
622#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530623/*
624 * <ioctl>
625 * htsmps - Sets the htsmps
626 *
627 * @INPUT: Atleast one int argument
628 *
629 * @OUTPUT: None
630 *
631 * This IOTCL used to set htsmps
632 *
633 * @E.g: iwpriv wlan0 htsmps <value>
634 *
635 * Supported Feature: STA
636 *
637 * Usage: Internal/External
638 *
639 * </ioctl>
640 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641#define WE_SET_HTSMPS 55
642/* Private ioctl for QPower */
643#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
644#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
645#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
646#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530647/*
648 * <ioctl>
649 * burst_enable - Enables or disables the burst feature
650 *
651 * @INPUT: 0-Disable, 1-Enable
652 *
653 * @OUTPUT: None
654 *
655 * This IOCTL enables or disables the burst feature.
656 *
657 * @E.g: iwpriv wlan0 burst_enable 0
658 *
659 * Supported Feature: STA
660 *
661 * Usage: Internal/External
662 *
663 * </ioctl>
664 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665#define WE_SET_BURST_ENABLE 60
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530666/*
667 * <ioctl>
668 * burst_dur - Enables or disables the burst feature
669 *
670 * @INPUT: int 1…..int 8191 in microseconds
671 *
672 * @OUTPUT: None
673 *
674 * This IOCTL sets the burst duration.
675 *
676 * @E.g: iwpriv wlan0 burst_dur <value>
677 *
678 * Supported Feature: STA
679 *
680 * Usage: Internal/External
681 *
682 * </ioctl>
683 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684#define WE_SET_BURST_DUR 61
685/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530686/*
687 * <ioctl>
688 * gtxHTMcs - Set the tx HTM value
689 *
690 * @INPUT: Atleast one int orgument
691 *
692 * @OUTPUT: None
693 *
694 * This IOTCL sets htm tx value
695 *
696 * @E.g: iwpriv wlan0 gtxHTMcs <value>
697 *
698 * Supported Feature: STA
699 *
700 * Usage: Internal/External
701 *
702 * </ioctl>
703 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704#define WE_SET_GTX_HT_MCS 62
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530705/*
706 * <ioctl>
707 * gtxVHTMcs - Set gtxVHTMcs value
708 *
709 * @INPUT: Atleast one int argument
710 *
711 * @OUTPUT: None
712 *
713 * This IOTCL used to set gtxVHTMcs value
714 *
715 * @E.g: iwpriv wlan0 gtxVHTMcs <value>
716 *
717 * Supported Feature: STA
718 *
719 * Usage: Internal/External
720 *
721 * </ioctl>
722 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723#define WE_SET_GTX_VHT_MCS 63
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530724/*
725 * <ioctl>
726 * gtxUsrCfg - Host request for GTX mask
727 *
728 * @INPUT: Atleast one int orgument
729 *
730 * @OUTPUT: None
731 *
732 * This IOTCL used send the host request for GTX mask
733 *
734 * @E.g: iwpriv wlan0 gtxUsrCfg <value>
735 *
736 * Supported Feature: STA
737 *
738 * Usage: Internal/External
739 *
740 * </ioctl>
741 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742#define WE_SET_GTX_USRCFG 64
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530743/*
744 * <ioctl>
745 * gtxThre - Set the tx threshold
746 *
747 * @INPUT: Atleast one int argument
748 *
749 * @OUTPUT: None
750 *
751 * This IOTCL used to set tx threshold
752 *
753 * @E.g: iwpriv wlan0 gtxThre <value>
754 *
755 * Supported Feature: STA
756 *
757 * Usage: Internal/External
758 *
759 * </ioctl>
760 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761#define WE_SET_GTX_THRE 65
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530762/*
763 * <ioctl>
764 * gtxMargin - Set the gtxMargin
765 *
766 * @INPUT: 1 to 32
767 *
768 * @OUTPUT: None
769 *
770 * This IOTCL use dto set gtxMargin
771 *
772 * @E.g: iwpriv wlan0 gtxMargini <value>
773 *
774 * Supported Feature: STA
775 *
776 * Usage: Internal/External
777 *
778 * </ioctl>
779 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780#define WE_SET_GTX_MARGIN 66
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530781/*
782 * <ioctl>
783 * gtxStep - Set the gtxStep
784 *
785 * @INPUT: None
786 *
787 * @OUTPUT: None
788 *
789 * This IOTCL used to sets gtxStep
790 *
791 * @E.g: iwpriv wlan0 gtxStep <value>
792 *
793 * Supported Feature: STA
794 *
795 * Usage: Internal/External
796 *
797 * </ioctl>
798 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799#define WE_SET_GTX_STEP 67
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530800/*
801 * <ioctl>
802 * gtxMinTpc - Sets the gtxMinTpc
803 *
804 * @INPUT: Atleast one int argument
805 *
806 * @OUTPUT: None
807 *
808 * This IOTCL sets the tx MinTpc
809 *
810 * @E.g: iwpriv wlan0 gtxMinTpc <value>
811 *
812 * Supported Feature: STA
813 *
814 * Usage: Internal/External
815 *
816 * </ioctl>
817 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818#define WE_SET_GTX_MINTPC 68
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530819/*
820 * <ioctl>
821 * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
822 *
823 * @INPUT: Mask value
824 *
825 * @OUTPUT: None
826 *
827 * This IOTCL used to set gtxBWMask
828 *
829 * @E.g: iwpriv wlan0 gtxBWMask <value>
830 *
831 * Supported Feature: STA
832 *
833 * Usage: Internal/External
834 *
835 * </ioctl>
836 */
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530837
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530838#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530839/*
840 * <ioctl>
841 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
842 *
843 * @INPUT: set_value
844 *
845 * @OUTPUT: None
846 *
847 * This IOCTL is used to set the MCC latency value in milliseconds
848 * during STA-P2P concurrency.
849 *
850 * If 0ms latency is provided, then FW will set to a default.
851 * Otherwise, latency must be at least 30ms.
852 *
853 * @E.g: iwpriv wlan0 setMccLatency 40
854 *
855 *
856 * Supported Feature: Concurrency
857 *
858 * Usage: Internal/External
859 *
860 * </ioctl>
861 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530863
864/*
865 * <ioctl>
866 * setMccQuota- Set the quota for P2P cases
867 *
868 * @INPUT: set_value [0,100]
869 *
870 * @OUTPUT: None
871 *
872 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
873 *
874 * Currently used to set time quota for 2 MCC vdevs/adapters using
875 * (operating channel, quota) for each mode.
876 * The info is provided run time using iwpriv command:
877 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
878 * Note: the quota provided in command is for the same mode in cmd.
879 * HDD checks if MCC mode is active, gets the second mode and its
880 * operating chan.
881 * Quota for the 2nd role is calculated as 100 - quota of first mode.
882 *
883 * @E.g: iwpriv wlan0 setMccQuota 50
884 * iwpriv p2p0 setMccQuota 50
885 *
886 * Supported Feature: Concurrency
887 *
888 * Usage: Internal/External
889 *
890 * </ioctl>
891 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892#define WE_MCC_CONFIG_QUOTA 71
893/* Private IOCTL for debug connection issues */
894#define WE_SET_DEBUG_LOG 72
895#ifdef WE_SET_TX_POWER
896#undef WE_SET_TX_POWER
897#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530898/*
899 * <ioctl>
900 * setTxPower - Set the current transmit power
901 *
902 * @INPUT: Transmission power in dBm
903 *
904 * @OUTPUT: None
905 *
906 * This IOCTL sets the current transmit power.
907 * This setting does not persist over reboots.
908 *
909 * @E.g: iwpriv wlan0 setTxPower 10
910 *
911 * Supported Feature: STA
912 *
913 * Usage: Internal/External
914 *
915 * </ioctl>
916 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917#define WE_SET_TX_POWER 74
918/* Private ioctl for earlyrx power save feature */
919#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
920#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
921#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
922#define WE_SET_EARLY_RX_SLOP_STEP 78
923#define WE_SET_EARLY_RX_INIT_SLOP 79
924#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530925/*
926 * <ioctl>
927 * setMcRate - Set the data rate for multicast data
928 *
929 * @INPUT: 1 to 32
930 *
931 * @OUTPUT: None
932 *
933 * This IOCTL sets the data rate for multicast data. Note that this command
934 * is allowed only in STA, IBSS, or QCMobileAP mode
935 *
936 * @E.g: iwpriv wlan0 setMcRate <value>
937 *
938 * Supported Feature: STA
939 *
940 * Usage: Internal/External
941 *
942 * </ioctl>
943 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944#define WE_SET_MC_RATE 81
945#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
946/* Private ioctl for packet power save */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530947/*
948 * <ioctl>
949 * 5g_ebt - Sets the 5g_ebt
950 *
951 * @INPUT: <value>
952 *
953 * @OUTPUT: None
954 *
955 * This IOTCL used to set 5g_ebt
956 *
957 * @E.g: iwpriv wlan0 5g_ebt <value>
958 *
959 * Supported Feature: STA
960 *
961 * Usage: Internal/External
962 *
963 * </ioctl>
964 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965#define WE_PPS_5G_EBT 83
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530966/*
967 * <ioctl>
968 * cts_cbw - Set CTS channel BW for dynamic BW adjustment
969 *
970 * @INPUT: 20 t0 160
971 *
972 * @OUTPUT: None
973 *
974 * This IOTCL used to set CTS channel BW for dynamic BW adjustment
975 *
976 * @E.g: iwpriv wlan0 cts_cbw <value>
977 *
978 * Supported Feature: STA
979 *
980 * Usage: Internal/External
981 *
982 * </ioctl>
983 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984#define WE_SET_CTS_CBW 84
985#define WE_DUMP_STATS 85
986#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530987/* Private sub ioctl for starting/stopping the profiling */
988#define WE_START_FW_PROFILE 87
Mukul Sharmaed92f2f2017-04-20 00:06:28 +0530989
Abhishek Singh3c507012016-12-01 11:15:42 +0530990/*
991 * <ioctl>
992 * setChanChange - Initiate channel change
993 *
994 * @INPUT: channel number to switch to.
995 *
996 * @OUTPUT: None
997 *
998 * This IOCTL is used to initiate a channel change.
999 * If called on STA/CLI interface it will send the
1000 * ECSA action frame to the connected SAP/GO asking to
1001 * initiate the ECSA, if supported.
1002 * If called on SAP/GO interface it will initiate
1003 * ECSA and ask connected peers to move to new channel.
1004 *
1005 * @E.g: iwpriv wlan0 setChanChange <channel>
1006 * iwpriv wlan0 setChanChange 1
1007 *
1008 * Supported Feature: ECSA
1009 *
1010 * Usage: Internal/External
1011 *
1012 * </ioctl>
1013 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +05301014#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05301015#define WE_SET_CONC_SYSTEM_PREF 89
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08001016#define WE_SET_TXRX_STATS 90
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001017
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08001018/*
1019 * <ioctl>
1020 * set_11ax_rate - set 11ax rates to FW
1021 *
1022 * @INPUT: rate code
1023 *
1024 * @OUTPUT: None
1025 *
1026 * This IOCTL fixes the Tx data rate of 11AX.
1027 *
1028 * @E.g: iwpriv wlan0 set_11ax_rate <rate code>
1029 *
1030 * Supported Feature: STA/SAP
1031 *
1032 * Usage: Internal
1033 *
1034 * </ioctl>
1035 */
1036#define WE_SET_11AX_RATE 91
1037
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001038/*
1039 * <ioctl>
1040 * enable_dcm - enable Dual Carrier Modulation(DCM)
1041 *
1042 * @INPUT: 0/1
1043 *
1044 * @OUTPUT: None
1045 *
1046 * This IOCTL enables/disables DCM.
1047 *
1048 * @E.g: iwpriv wlan0 enable_dcm <0/1>
1049 *
1050 * Supported Feature: STA/SAP
1051 *
1052 * Usage: Internal
1053 *
1054 * </ioctl>
1055 */
1056#define WE_SET_DCM 92
1057
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001058/*
1059 * <ioctl>
1060 * enable_range_ext - enable Range extension
1061 *
1062 * @INPUT: 0/1
1063 *
1064 * @OUTPUT: None
1065 *
1066 * This IOCTL enables/disables Range extension.
1067 *
1068 * @E.g: iwpriv wlan0 enable_range_ext <0/1>
1069 *
1070 * Supported Feature: STA/SAP
1071 *
1072 * Usage: Internal
1073 *
1074 * </ioctl>
1075 */
1076#define WE_SET_RANGE_EXT 93
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001077
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301078/*
1079 * <ioctl>
1080 * wow_ito - sets the timeout value for inactivity data while
1081 * in power save mode during wow
1082 *
1083 * @INPUT: int
1084 *
1085 * @OUTPUT: None
1086 *
1087 * This IOCTL set the timeout value for inactivity data in power save mode
1088 *
1089 * @E.g: iwpriv wlan0 wow_ito 20
1090 *
1091 * Supported Feature: STA
1092 *
1093 * Usage: External
1094 *
1095 * </ioctl>
1096*/
1097#define WE_SET_WOW_DATA_INACTIVITY_TO 94
1098
1099
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001100/* Private ioctls and their sub-ioctls */
1101#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
1102#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103#define WE_SET_SAP_CHANNELS 3
1104#define WE_GET_WLAN_DBG 4
1105#define WE_GET_MAX_ASSOC 6
1106/* 7 is unused */
1107#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +05301108
1109/*
1110 * <ioctl>
1111 * getconcurrency - Get concurrency mode
1112 *
1113 * @INPUT: None
1114 *
1115 * @OUTPUT: It shows concurrency value
1116 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
1117 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
1118 * 8:OCB 9:EPPING 10:QVIT 11:NDI
1119 *
1120 * This IOCTL is used to retrieve concurrency mode.
1121 *
1122 * @E.g: iwpriv wlan0 getconcurrency
1123 * wlan0 getconcurrency:5
1124 * Above value shows STA+P2P_Client
1125 *
1126 * Supported Feature: Concurrency
1127 *
1128 * Usage: Internal/External
1129 *
1130 * </ioctl>
1131 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132#define WE_GET_CONCURRENCY_MODE 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301133/*
1134 * <ioctl>
1135 * get_nss - Get the number of spatial STBC streams (NSS)
1136 *
1137 * @INPUT: None
1138 *
1139 * @OUTPUT: NSS
1140 * wlan0 get_nss:2
1141 *
1142 * This IOTCL used to get the number of spatial STBC streams
1143 *
1144 * @E.g: iwpriv wlan0 get_nss
1145 *
1146 * Supported Feature: STA
1147 *
1148 * Usage: Internal/External
1149 *
1150 * </ioctl>
1151 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152#define WE_GET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301153/*
1154 * <ioctl>
1155 * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1156 *
1157 * @INPUT: None
1158 *
1159 * @OUTPUT: ldpc
1160 * wlan0 get_ldpc:1
1161 *
1162 * This IOTCL used to gets the low density parity check (LDPC)
1163 *
1164 * @E.g: iwpriv wlan0 get_ldpc
1165 *
1166 * Supported Feature: STA
1167 *
1168 * Usage: Internal/External
1169 *
1170 * </ioctl>
1171 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172#define WE_GET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301173/*
1174 * <ioctl>
1175 * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1176 *
1177 * @INPUT: None
1178 *
1179 * @OUTPUT: TXSTBC
1180 * wlan0 get_tx_stbc:1
1181 *
1182 * This IOTCL get the value of the current Tx space time block code (STBC)
1183 *
1184 * @E.g: iwpriv wlan0 get_tx_stbc
1185 *
1186 * Supported Feature: STA
1187 *
1188 * Usage: Internal/External
1189 *
1190 * </ioctl>
1191 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192#define WE_GET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301193/*
1194 * <ioctl>
1195 * get_rx_stbc - Gets the value of the current Rx STBC
1196 *
1197 * @INPUT: None
1198 *
1199 * @OUTPUT: Rx STBC
1200 * wlan0 get_rx_stbc:1
1201 *
1202 * This IOTCL used to get the value of the current Rx STBC
1203 *
1204 * @E.g: iwpriv wlan0 get_rx_stbc
1205 *
1206 * Supported Feature: STA
1207 *
1208 * Usage: Internal/External
1209 *
1210 * </ioctl>
1211 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212#define WE_GET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301213/*
1214 * <ioctl>
1215 * get_shortgi - Get the value of the current short GI setting
1216 *
1217 * @INPUT: None
1218 *
1219 * @OUTPUT: Enable/disable of shortgi
1220 * wlan0 get_shortgi:1
1221 *
1222 * This IOCTL gets the value of the current short GI setting
1223 *
1224 * @E.g: iwpriv wlan0 get_shortgi
1225 *
1226 * Supported Feature: STA
1227 *
1228 * Usage: Internal/External
1229 *
1230 * </ioctl>
1231 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232#define WE_GET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301233/*
1234 * <ioctl>
1235 * get_rtscts - Get the value of the current RTS/CTS setting.
1236 *
1237 * @INPUT: None
1238 *
1239 * @OUTPUT: Enable/disable of RTS/CTS
1240 * wlan0 get_rtscts:33
1241 *
1242 * This IOTCL get the value of the current RTS/CTS setting.
1243 *
1244 * @E.g: iwpriv wlan0 get_rtscts
1245 *
1246 * Supported Feature: STA
1247 *
1248 * Usage: Internal/External
1249 *
1250 * </ioctl>
1251 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252#define WE_GET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301253/*
1254 * <ioctl>
1255 * get_chwidth - Get the current channel width setting
1256 *
1257 * @INPUT: None
1258 *
1259 * @OUTPUT: channel width
1260 * wlan0 get_chwidth:0
1261 *
1262 * This IOTCL get the current channel width setting.
1263 *
1264 * @E.g: iwpriv wlan0 get_chwidth
1265 *
1266 * Supported Feature: STA
1267 *
1268 * Usage: Internal/External
1269 *
1270 * </ioctl>
1271 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272#define WE_GET_CHWIDTH 17
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301273/*
1274 * <ioctl>
1275 * get_anienable - Get the anienable
1276 *
1277 * @INPUT: None
1278 *
1279 * @OUTPUT:
1280 * wlan0 get_anienable:0
1281 *
1282 * This IOTCL get the anienable
1283 *
1284 * @E.g: iwpriv wlan0 get_anienable
1285 *
1286 * Supported Feature: STA
1287 *
1288 * Usage: Internal/External
1289 *
1290 * </ioctl>
1291 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292#define WE_GET_ANI_EN_DIS 18
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301293/*
1294 * <ioctl>
1295 * get_aniplen - Get the aniplen
1296 *
1297 * @INPUT: None
1298 *
1299 * @OUTPUT:
1300 * wlan0 get_aniplen:0
1301 *
1302 * This IOTCL get the aniplen
1303 *
1304 * @E.g: iwpriv wlan0 get_aniplen
1305 *
1306 * Supported Feature: STA
1307 *
1308 * Usage: Internal/External
1309 *
1310 * </ioctl>
1311 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312#define WE_GET_ANI_POLL_PERIOD 19
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301313/*
1314 * <ioctl>
1315 * get_anilislen- Get the anilislen
1316 *
1317 * @INPUT: None
1318 *
1319 * @OUTPUT:
1320 * wlan0 get_anilislen:0
1321 *
1322 * This IOTCL used to get anilislen
1323 *
1324 * @E.g: iwpriv wlan0 get_anilislen
1325 *
1326 * Supported Feature: STA
1327 *
1328 * Usage: Internal/External
1329 *
1330 * </ioctl>
1331 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332#define WE_GET_ANI_LISTEN_PERIOD 20
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301333/*
1334 * <ioctl>
1335 * get_aniofdmlvl - Get the OFDM level
1336 *
1337 * @INPUT: None
1338 *
1339 * @OUTPUT: OFDM
1340 * wlan0 get_aniofdmlvl:0
1341 *
1342 * This IOTCL used to get ofdm level
1343 *
1344 * @E.g: iwpriv wlan0 get_aniofdmlvl
1345 *
1346 * Supported Feature: STA
1347 *
1348 * Usage: Internal/External
1349 *
1350 * </ioctl>
1351 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352#define WE_GET_ANI_OFDM_LEVEL 21
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301353/*
1354 * <ioctl>
1355 * get_aniccklvl - Get the cck level
1356 *
1357 * @INPUT: None
1358 *
1359 * @OUTPUT:
1360 * wlan0 get_aniccklvl:0
1361 *
1362 * This IOTCL used to get cck level
1363 *
1364 * @E.g: iwpriv wlan0 get_aniccklvl
1365 *
1366 * Supported Feature: STA
1367 *
1368 * Usage: Internal/External
1369 *
1370 * </ioctl>
1371 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372#define WE_GET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301373/*
1374 * <ioctl>
1375 * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1376 *
1377 * @INPUT: None
1378 *
1379 * @OUTPUT: Enable/disable dynamic channel bandwidth
1380 * wlan0 get_cwmenable:0
1381 *
1382 * This IOTCL get the value of the dynamic channel bandwidth setting
1383 *
1384 * @E.g: iwpriv wlan0 get_cwmenable
1385 *
1386 * Supported Feature: STA
1387 *
1388 * Usage: Internal/External
1389 *
1390 * </ioctl>
1391 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392#define WE_GET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301393/*
1394 * <ioctl>
1395 * get_txchainmask - Get the txchainmask that was set
1396 *
1397 * @INPUT: None
1398 *
1399 * @OUTPUT: txchainmask
1400 * wlan0 get_txchainmask:1
1401 *
1402 * This IOCTL gets the txchainmask that was set
1403 * This command is useful if it was previously set
1404 *
1405 * @E.g: iwpriv wlan0 get_txchainmask
1406 *
1407 * Supported Feature: STA
1408 *
1409 * Usage: Internal/External
1410 *
1411 * </ioctl>
1412 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413#define WE_GET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301414/*
1415 * <ioctl>
1416 * get_rxchainmask - Get the rxchainmask that was set
1417 *
1418 * @INPUT: None
1419 *
1420 * @OUTPUT: rxchainmask
1421 * wlan0 get_rxchainmask:1
1422 *
1423 * This IOCTL gets the rxchainmask that was set
1424 * This command is useful only if it was previously set.
1425 *
1426 * @E.g: iwpriv wlan0 get_rxchainmask
1427 *
1428 * Supported Feature: STA
1429 *
1430 * Usage: Internal/External
1431 *
1432 * </ioctl>
1433 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434#define WE_GET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301435/*
1436 * <ioctl>
1437 * get_11nrate - Get the fixed Tx data rate
1438 *
1439 * @INPUT: None
1440 *
1441 * @OUTPUT: Using this command does not return the same value as set
1442 * wlan0 get_11nrate:0
1443 *
1444 * This IOCTL gets the fixed Tx data rate
1445 * This command is useful only if setting the fixed Tx rate.
1446 *
1447 * @E.g: iwpriv wlan0 get_11nrate
1448 *
1449 * Supported Feature: STA
1450 *
1451 * Usage: Internal/External
1452 *
1453 * </ioctl>
1454 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455#define WE_GET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301456/*
1457 * <ioctl>
1458 * get_ampdu - Get the maximum subframe of ampdu
1459 *
1460 * @INPUT: None
1461 *
1462 * @OUTPUT: Maximum subframe of ampdu
1463 * wlan0 get_ampdu:1
1464 *
1465 * This IOCTL gets the maximum subframe of ampdu
1466 * This command is useful only if setting ampdu.
1467 *
1468 * @E.g: iwpriv wlan0 get_ampdu
1469 *
1470 * Supported Feature: STA
1471 *
1472 * Usage: Internal/External
1473 *
1474 * </ioctl>
1475 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476#define WE_GET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301477/*
1478 * <ioctl>
1479 * get_amsdu - Get the maximum subframe of amsdu
1480 *
1481 * @INPUT: None
1482 *
1483 * @OUTPUT: Maximum subframe of amsdu
1484 * wlan0 get_amsdu:1
1485 *
1486 * This IOCTL gets the maximum subframe of amsdu.
1487 * This command is useful only if setting amsdu
1488 *
1489 * @E.g: iwpriv wlan0 get_amsdu
1490 *
1491 * Supported Feature: STA
1492 *
1493 * Usage: Internal/External
1494 *
1495 * </ioctl>
1496 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497#define WE_GET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301498/*
1499 * <ioctl>
1500 * get_txpow2g - Get the current 2 GHz Tx power setting
1501 *
1502 * @INPUT: None
1503 *
1504 * @OUTPUT: Tx Power in dbm
1505 * wlan0 get_txpow2g:0
1506 *
1507 * This IOCTL gets the current 2 GHz Tx power setting
1508 * This command is useful if setting Tx power
1509 *
1510 * @E.g: iwpriv wlan0 get_txpow2g
1511 *
1512 * Supported Feature: STA
1513 *
1514 * Usage: Internal/External
1515 *
1516 * </ioctl>
1517 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518#define WE_GET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301519/*
1520 * <ioctl>
1521 * get_txpow5g - Get the current 5 GHz Tx power setting
1522 *
1523 * @INPUT: None
1524 *
1525 * @OUTPUT: Tx Power in dbm
1526 * wlan0 get_txpow5g:0
1527 *
1528 * This IOCTL gets the current 5 GHz Tx power setting
1529 * This command is useful if setting Tx power
1530 *
1531 * @E.g: iwpriv wlan0 get_txpow5g
1532 *
1533 * Supported Feature: STA
1534 *
1535 * Usage: Internal/External
1536 *
1537 * </ioctl>
1538 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -08001540/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541#define WE_GET_PPS_PAID_MATCH 32
1542#define WE_GET_PPS_GID_MATCH 33
1543#define WE_GET_PPS_EARLY_TIM_CLEAR 34
1544#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
1545#define WE_GET_PPS_EOF_PAD_DELIM 36
1546#define WE_GET_PPS_MACADDR_MISMATCH 37
1547#define WE_GET_PPS_DELIM_CRC_FAIL 38
1548#define WE_GET_PPS_GID_NSTS_ZERO 39
1549#define WE_GET_PPS_RSSI_CHECK 40
1550/* Private ioctl for QPower */
1551#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
1552#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
1553#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
1554#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301555/*
1556 * <ioctl>
1557 * get_burst_en - Enables or disables the burst feature
1558 *
1559 * @INPUT: None
1560 *
1561 * @OUTPUT: Enable/disable of burst feature
1562 * wlan0 get_burst_en:1
1563 *
1564 * This IOCTL enables or disables the burst feature
1565 *
1566 * @E.g: iwpriv wlan0 get_burst_en
1567 *
1568 * Supported Feature:STA
1569 *
1570 * Usage: Internal/External
1571 *
1572 * </ioctl>
1573 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574#define WE_GET_BURST_ENABLE 45
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301575/*
1576 * <ioctl>
1577 * get_burst_dur - Get the burst duration
1578 *
1579 * @INPUT: None
1580 *
1581 * @OUTPUT: Duration in microseconds
1582 * wlan0 get_burst_dur:8160
1583 *
1584 * This IOCTL gets the burst duration
1585 * This command is useful if setting burst enable
1586 *
1587 * @E.g: iwpriv wlan0 get_burst_dur
1588 *
1589 * Supported Feature: STA
1590 *
1591 * Usage: Internal/External
1592 *
1593 * </ioctl>
1594 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595#define WE_GET_BURST_DUR 46
1596/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301597/*
1598 * <ioctl>
1599 * get_gtxHTMcs - Get the tx HTM
1600 *
1601 * @INPUT: None
1602 *
1603 * @OUTPUT: HTM
1604 * wlan0 get_gtxHTMcs:32896
1605 *
1606 * This IOTCL used to get HTM
1607 *
1608 * @E.g: iwpriv wlan0 get_gtxHTMcs
1609 *
1610 * Supported Feature: STA
1611 *
1612 * Usage: Internal/External
1613 *
1614 * </ioctl>
1615 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616#define WE_GET_GTX_HT_MCS 47
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301617/*
1618 * <ioctl>
1619 * get_gtxVHTMcs - Get the VHTM
1620 *
1621 * @INPUT: None
1622 *
1623 * @OUTPUT: VHTM
1624 * wlan0 get_gtxVHTMcs:524800
1625 *
1626 * This IOTCL used to get the VHTM
1627 *
1628 * @E.g: iwpriv wlan0 get_gtxVHTMcs
1629 *
1630 * Supported Feature: STA
1631 *
1632 * Usage: Internal/External
1633 *
1634 * </ioctl>
1635 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636#define WE_GET_GTX_VHT_MCS 48
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301637/*
1638 * <ioctl>
1639 * get_gtxUsrCfg - Get the tx cfg
1640 *
1641 * @INPUT: None
1642 *
1643 * @OUTPUT: TXCFG
1644 * wlan0 get_gtxUsrCfg:32
1645 *
1646 * This IOTCL used to get the tx cfg
1647 *
1648 * @E.g: iwpriv wlan0 get_gtxUsrCfg
1649 *
1650 * Supported Feature: STA
1651 *
1652 * Usage: Internal/External
1653 *
1654 * </ioctl>
1655 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656#define WE_GET_GTX_USRCFG 49
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301657/*
1658 * <ioctl>
1659 * get_gtxThre - Get the tx threshold
1660 *
1661 * @INPUT: None
1662 *
1663 * @OUTPUT: Threshold
1664 * wlan0 get_gtxThre:3
1665 *
1666 * This IOCTL is used to get tx threshold
1667 *
1668 * @E.g: iwpriv wlan0 get_gtxThre
1669 *
1670 * Supported Feature: STA
1671 *
1672 * Usage: Internal/External
1673 *
1674 * </ioctl>
1675 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676#define WE_GET_GTX_THRE 50
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301677/*
1678 * <ioctl>
1679 * get_gtxMargin - Get the tx margin
1680 *
1681 * @INPUT: None
1682 *
1683 * @OUTPUT: GTXMARGIN
1684 * wlan0 get_gtxMargin:2
1685 *
1686 * This IOCTL is used to set tx margin
1687 *
1688 * @E.g: iwpriv wlan0 get_gtxMargin
1689 *
1690 * Supported Feature: STA
1691 *
1692 * Usage: Internal/External
1693 *
1694 * </ioctl>
1695 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696#define WE_GET_GTX_MARGIN 51
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301697/*
1698 * <ioctl>
1699 * get_gtxStep - Get the tx step
1700 *
1701 * @INPUT: None
1702 *
1703 * @OUTPUT: GTXSTEP
1704 * wlan0 get_gtxStep:0
1705 *
1706 * This IOCTL is used to get the gtx step
1707 *
1708 * @E.g: iwpriv wlan0 get_gtxStep
1709 *
1710 * Supported Feature: STA
1711 *
1712 * Usage: Internal/External
1713 *
1714 * </ioctl>
1715 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716#define WE_GET_GTX_STEP 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301717/*
1718 * <ioctl>
1719 * get_gtxMinTpc - Get the tx miminum tpc
1720 *
1721 * @INPUT: None
1722 *
1723 * @OUTPUT: TPC
1724 * wlan0 get_gtxMinTpc:0
1725 *
1726 * This IOCTL is used to get tx miminum tpc
1727 *
1728 * @E.g: iwpriv wlan0 get_gtxMinTpc
1729 *
1730 * Supported Feature: STA
1731 *
1732 * Usage: Internal/External
1733 *
1734 * </ioctl>
1735 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736#define WE_GET_GTX_MINTPC 53
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301737/*
1738 * <ioctl>
1739 * get_gtxBWMask - Get the tx BW MASK
1740 *
1741 * @INPUT: None
1742 *
1743 * @OUTPUT: MASK
1744 * wlan0 get_gtxBWMask:15
1745 *
1746 * This IOCTL is used get gtx bw mask
1747 *
1748 * @E.g: iwpriv wlan0 get_gtxBWMask
1749 *
1750 * Supported Feature: STA
1751 *
1752 * Usage: Internal/External
1753 *
1754 * </ioctl>
1755 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756#define WE_GET_GTX_BWMASK 54
1757#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001758#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07001759#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001761/*
1762 * <ioctl>
1763 * get_dcm - Get dcm enablement value
1764 *
1765 * @INPUT: None
1766 *
1767 * @OUTPUT: 0/1
1768 * wlan0 get_dcm
1769 *
1770 * This IOCTL is used get dcm value
1771 *
1772 * Supported Feature: STA/SAP
1773 *
1774 * Usage: Internal
1775 *
1776 * </ioctl>
1777 */
1778#define WE_GET_DCM 60
1779
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001780/*
1781 * <ioctl>
1782 * get_dcm - Get range extension enablement value
1783 *
1784 * @INPUT: None
1785 *
1786 * @OUTPUT: 0/1
1787 * wlan0 get_range_ext
1788 *
1789 * This IOCTL is used get range_extension value
1790 *
1791 * Supported Feature: STA/SAP
1792 *
1793 * Usage: Internal
1794 *
1795 * </ioctl>
1796 */
1797#define WE_GET_RANGE_EXT 61
1798
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799/* Private ioctls and their sub-ioctls */
1800#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
1801
1802/* Private ioctls and their sub-ioctls */
1803#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
1804#define WE_WOWL_ADD_PTRN 1
1805#define WE_WOWL_DEL_PTRN 2
Sreelakshmi Konamkided64d72017-02-23 10:39:26 +05301806/*
1807 * <ioctl>
1808 * neighbor - Send neighbor report request
1809 *
1810 * @INPUT: string
1811 *
1812 * @OUTPUT: None
1813 *
1814 * This IOCTL create a Neighbor report request and send it to peer
1815 *
1816 * @E.g: iwpriv wlan0 neighbor "SSID"
1817 *
1818 * Supported Feature: 11k
1819 *
1820 * Usage: Internal/External
1821 *
1822 * </ioctl>
1823 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824#define WE_NEIGHBOR_REPORT_REQUEST 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301825/*
1826 * <ioctl>
1827 * set_ap_wps_ie - Set the P2P IE of the probe response
1828 *
1829 * @INPUT: string
1830 *
1831 * @OUTPUT: None
1832 *
1833 * This IOCTL sets the P2P IE of the probe response
1834 *
1835 * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1836 *
1837 * Supported Feature: STA
1838 *
1839 * Usage: Internal/External
1840 *
1841 * </ioctl>
1842 */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07001843#define WE_SET_AP_WPS_IE 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844#define WE_SET_CONFIG 5
1845
1846/* Private ioctls and their sub-ioctls */
1847#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
1848#define WE_SET_WLAN_DBG 1
1849#define WE_SET_DP_TRACE 2
1850#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05301851#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852
1853/* Private ioctls and their sub-ioctls */
1854#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
1855#define WE_WLAN_VERSION 1
1856#define WE_GET_STATS 2
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301857/*
1858 * <ioctl>
1859 * getConfig - gets the values of all configurations listed in WCNSS
1860 *
1861 * @INPUT: None
1862 *
1863 * @OUTPUT: Current configuration to the sys log
1864 * wlan0 getConfig: WLAN configuration written to system log
1865 *
1866 * This IOCTL gets the values of all configurations listed in WCNSS
1867 *
1868 * @E.g: iwpriv wlan0 getConfig
1869 *
1870 * Supported Feature: STA
1871 *
1872 * Usage: Internal/External
1873 *
1874 * </ioctl>
1875 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876#define WE_GET_CFG 3
1877#define WE_GET_WMM_STATUS 4
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301878/*
1879 * <ioctl>
1880 * getChannelList - Get the available channel list while in QCMobileAP
1881 *
1882 * @INPUT: None
1883 *
1884 * @OUTPUT: Channel list
1885 * wlan0 getChannelList:36 US 1..165
1886 *
1887 * This IOCTL gets the available channel list while in QCMobileAP
1888 *
1889 * @E.g: iwpriv wlan0 getChannelList
1890 *
1891 * Supported Feature: STA
1892 *
1893 * Usage: Internal/External
1894 *
1895 * </ioctl>
1896 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897#define WE_GET_CHANNEL_LIST 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301898/*
1899 * <ioctl>
1900 * getRSSI - Get the Received Signal Strength Indicator
1901 *
1902 * @INPUT: None
1903 *
1904 * @OUTPUT: RSSI
1905 * wlan0 getRSSI:rsssi=-32
1906 *
1907 * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1908 *
1909 * @E.g: iwpriv wlan0 getRSSI
1910 *
1911 * Supported Feature: STA
1912 *
1913 * Usage: Internal/External
1914 *
1915 * </ioctl>
1916 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -08001918
1919/*
1920 * <ioctl>
1921 * getSuspendStats - Get suspend/resume stats
1922 *
1923 * @INPUT: None
1924 *
1925 * @OUTPUT: character string containing formatted suspend/resume stats
1926 *
1927 * This ioctl is used to get suspend/resume stats formatted for display.
1928 * Currently it includes suspend/resume counts, wow wake up reasons, and
1929 * suspend fail reasons.
1930 *
1931 * @E.g: iwpriv wlan0 getSuspendStats
1932 * iwpriv wlan0 getSuspendStats
1933 *
1934 * Supported Feature: suspend/resume
1935 *
1936 * Usage: Internal
1937 *
1938 * </ioctl>
1939 */
1940#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05301942/*
1943 * <ioctl>
1944 * getTdlsPeers - Get all TDLS peers.
1945 *
1946 * @INPUT: None
1947 *
1948 * @OUTPUT: Returns the MAC address of all the TDLS peers
1949 * wlan0 getTdlsPeers:
1950 * MAC Id cap up RSSI
1951 * ---------------------------------
1952 * 00:0a:f5:0e:bd:18 2 Y Y -44
1953 * 00:0a:f5:bf:0e:12 0 N N 0
1954 *
1955 * This IOCTL is used to get all TDLS peers.
1956 *
1957 * @E.g: iwpriv wlan0 getTdlsPeers
1958 *
1959 * Supported Feature: TDLS
1960 *
1961 * Usage: Internal/External
1962 *
1963 * </ioctl>
1964 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965#define WE_GET_TDLS_PEERS 8
1966#endif
1967#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +05301968/*
1969 * <ioctl>
1970 * getPMFInfo - get the PMF info of the connected session
1971 *
1972 * @INPUT: None
1973 *
1974 * @OUTPUT:
1975 * wlan0 getPMFInfo:
1976 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
1977 * Number of Unprotected Disassocs 0
1978 * Number of Unprotected Deauths 0
1979 *
1980 * This IOCTL is used to get the PMF stats/status of the current
1981 * connection.
1982 *
1983 * @e.g:iwpriv wlan0 getPMFInfo
1984 *
1985 * Supported Feature: PMF
1986 *
1987 * Usage: Internal/External
1988 *
1989 * </ioctl>
1990 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991#define WE_GET_11W_INFO 9
1992#endif
1993#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +05301994/*
1995 * <ioctl>
1996 * getIbssSTAs - get ibss sta info
1997 *
1998 * @INPUT: None
1999 *
2000 * @OUTPUT: Give the MAC of the IBSS STA
2001 * wlan0 getIbssSTAs:
2002 * 1 .8c:fd:f0:01:9c:bf
2003 *
2004 * This IOCTL is used to get ibss sta info
2005 *
2006 * @E.g: iwpriv wlan0 getIbssSTAs
2007 *
2008 * Supported Feature: IBSS
2009 *
2010 * Usage: Internal/External
2011 *
2012 * </ioctl>
2013 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002014#define WE_GET_IBSS_STA_INFO 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302015/*
2016 * <ioctl>
2017 * getphymode - Get the current phymode.
2018 *
2019 * @INPUT: None
2020 *
2021 * @OUTPUT: In phymode
2022 * wlan0 getphymode:AUTO MODE
2023 *
2024 * This IOCTL used to gets the current phymode.
2025 *
2026 * @E.g: iwpriv wlan0 getphymode
2027 *
2028 * Supported Feature: STA
2029 *
2030 * Usage: Internal/External
2031 *
2032 * </ioctl>
2033 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034#define WE_GET_PHYMODE 12
Naveen Rawat910726a2017-03-06 11:42:51 -08002035
2036/*
2037 * <ioctl>
2038 * getOemDataCap - Get the oem data caps.
2039 *
2040 * @INPUT: None
2041 *
2042 * @OUTPUT: oem data capability
2043 *
2044 * This IOCTL used to gets the current oem data cap.
2045 *
2046 * @E.g: iwpriv wlan0 getOemDataCap
2047 *
2048 * Usage: Internal/External
2049 *
2050 * </ioctl>
2051 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052#define WE_GET_OEM_DATA_CAP 13
Naveen Rawat910726a2017-03-06 11:42:51 -08002053
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302054/*
2055 * <ioctl>
2056 * getSNR - Enable SNR Monitoring
2057 *
2058 * @INPUT: None
2059 *
2060 * @OUTPUT: Signal strength/ratio
2061 * wlan0 getSNR:1
2062 *
2063 * This IOCTL is used to get ibss sta info
2064 *
2065 * @E.g: iwpriv wlan0 getSNR
2066 *
2067 * Supported Feature: STA
2068 *
2069 * Usage: Internal/External
2070 *
2071 * </ioctl>
2072 */
Naveen Rawat910726a2017-03-06 11:42:51 -08002073
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +05302075#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076
2077/* Private ioctls and their sub-ioctls */
2078#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
Selvaraj, Sridharf7939832017-03-25 16:59:50 +05302079
2080/*
2081 * <ioctl>
2082 * reassoc - Trigger STA re-association to the connected AP
2083 *
2084 * @INPUT: None
2085 *
2086 * @OUTPUT: None
2087 *
2088 * This IOCTL is used to trigger STA reassociation to the connected AP.
2089 *
2090 * @E.g: iwpriv wlan0 reassoc
2091 *
2092 * Supported Feature: Roaming
2093 *
2094 * Usage: Internal
2095 *
2096 * </ioctl>
2097 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +05302099/*
2100 * <ioctl>
2101 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
2102 *
2103 * @INPUT: None
2104 *
2105 * @OUTPUT: print ibss peer in info logs
2106 * pPeerInfo->numIBSSPeers = 1
2107 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2108 *
2109 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
2110 * in info logs
2111 *
2112 * @E.g: iwpriv wlan0 ibssPeerInfoAll
2113 *
2114 * Supported Feature: IBSS
2115 *
2116 * Usage: Internal/External
2117 *
2118 * </ioctl>
2119 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002120#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -08002121/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002123#define WE_GET_FW_PROFILE_DATA 18
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +05302124/*
2125 * <ioctl>
2126 * stop_obss_scan - Stop obss scan
2127 *
2128 * @INPUT: None
2129 *
2130 * @OUTPUT: None
2131 *
2132 * This IOCTL is used to stop obss scan
2133 *
2134 * @E.g: iwpriv wlan0 stop_obss_scan
2135 *
2136 * Supported Feature: Scan
2137 *
2138 * Usage: Internal/External
2139 *
2140 * </ioctl>
2141 */
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002142#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143
2144/* Private ioctls and their sub-ioctls */
2145#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
2146
2147#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +05302148/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149
Manjeet Singhf82ed072016-07-08 11:40:00 +05302150#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151
2152#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302153/*
2154 * <ioctl>
2155 * setTdlsConfig - Set TDLS configuration parameters.
2156 *
2157 * @INPUT: 11 TDLS configuration parameters
2158 * @args[0]: tdls: [0..2]
2159 * @args[1]: tx_period_t: [1000..4294967295UL]
2160 * @args[2]: tx_packet_n: [0..4294967295UL]
2161 * @args[3]: [discovery_period is not used anymore]
2162 * @args[4]: discovery_tries_n: [1..100]
2163 * @args[5]: [idle_timeout is not used anymore]
2164 * @args[6]: idle_packet_n: [0..40000]
2165 * @args[7]: [rssi_hysteresis is not used anymore]
2166 * @args[8]: rssi_trigger_threshold: [-120..0]
2167 * @args[9]: rssi_teardown_threshold: [-120..0]
2168 * @args[10]: rssi_delta: [-30..0]
2169 *
2170 * @OUTPUT: None
2171 *
2172 * This IOCTL is used to set the TDLS configuration parameters.
2173 *
2174 * @E.g: iwpriv wlan0 setTdlsConfig tdls tx_period_t tx_packet_n
2175 * discovery_period discovery_tries_n idle_timeout
2176 * idle_packet_n rssi_hysteresis rssi_trigger_threshold
2177 * rssi_teardown_threshold rssi_delta
2178 * iwpriv wlan0 setTdlsConfig 1 1500 40 1 5 1 5 0 -70 -70 -10
2179 *
2180 * Supported Feature: TDLS
2181 *
2182 * Usage: Internal/External
2183 *
2184 * </ioctl>
2185 */
2186
2187
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188#define WE_TDLS_CONFIG_PARAMS 5
2189#endif
Abhishek Singh49b654e2016-12-01 16:11:17 +05302190/*
2191 * <ioctl>
2192 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
2193 *
2194 * @INPUT: staid
2195 *
2196 * @OUTPUT: print ibss peer corresponding to staid in info logs
2197 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2198 *
2199 * This IOCTL is used to print the specific ibss peers's MAC,
2200 * rate and RSSI in info logs
2201 *
2202 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
2203 * iwpriv wlan0 ibssPeerInfo 0
2204 *
2205 * Supported Feature: IBSS
2206 *
2207 * Usage: Internal/External
2208 *
2209 * </ioctl>
2210 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002211#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212#define WE_UNIT_TEST_CMD 7
2213
2214#define WE_MTRACE_DUMP_CMD 8
2215#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
2216
2217
2218#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2219#define WE_LED_FLASHING_PARAM 10
2220#endif
2221
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302222/*
2223 * <ioctl>
2224 * pm_clist - Increments the index value of the concurrent connection list
2225 * and update with the input parameters provided.
2226 *
2227 * @INPUT: Following 8 arguments:
2228 * @vdev_id: vdev id
2229 * @tx_streams: TX streams
2230 * @rx_streams: RX streams
2231 * @chain_mask: Chain mask
2232 * @type: vdev_type
2233 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2234 * @sub_type: vdev_subtype
2235 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2236 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2237 * @channel: Channel
2238 * @mac: Mac id
2239 *
2240 * @OUTPUT: None
2241 *
2242 * This IOCTL is used to increments the index value of the concurrent connection
2243 * list and update with the input parameters provided.
2244 *
2245 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
2246 * sub_type channel mac
2247 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
2248 *
2249 * Supported Feature: DBS
2250 *
2251 * Usage: Internal/External
2252 *
2253 * </ioctl>
2254 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302256
2257/*
2258 * <ioctl>
2259 * pm_dlist - Delete the index from the concurrent connection list that is
2260 * present in the given vdev_id.
2261 *
2262 * @INPUT: delete_all, vdev_id
2263 * @delete_all: delete all indices
2264 * @vdev_id: vdev id
2265 *
2266 * @OUTPUT: None
2267 *
2268 * This IOCTL is used to delete the index from the concurrent connection list
2269 * that is present in the given vdev_id.
2270 *
2271 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
2272 * iwpriv wlan0 pm_dlist 0 1
2273 *
2274 * Supported Feature: DBS
2275 *
2276 * Usage: Internal/External
2277 *
2278 * </ioctl>
2279 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302281
2282/*
2283 * <ioctl>
2284 * pm_dbs - Set dbs capability and system preference
2285 *
2286 * @INPUT: dbs, system_pref
2287 * @dbs: Value of DBS capability to be set
2288 * @system_pref: System preference
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002289 * 0:PM_THROUGHPUT 1: PM_POWERSAVE 2: PM_LATENCY
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302290 *
2291 * @OUTPUT: None
2292 *
2293 * This IOCTL is used to set dbs capability and system preference.
2294 *
2295 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
2296 * iwpriv wlan0 pm_dbs 1 0
2297 *
2298 * Supported Feature: DBS
2299 *
2300 * Usage: Internal/External
2301 *
2302 * </ioctl>
2303 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002304#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302305
2306/*
2307 * <ioctl>
2308 * pm_pcl - Set pcl for concurrency mode.
2309 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002310 * @INPUT: policy_mgr_con_mode
2311 * @policy_mgr_con_mode: concurrency mode for PCL table
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302312 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2313 *
2314 * @OUTPUT: None
2315 *
2316 * This IOCTL is used to set pcl for concurrency mode.
2317 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002318 * @E.g: iwpriv wlan0 pm_pcl policy_mgr_con_mode
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302319 * iwpriv wlan0 pm_pcl 0
2320 *
2321 * Supported Feature: DBS
2322 *
2323 * Usage: Internal/External
2324 *
2325 * </ioctl>
2326 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302328
2329/*
2330 * <ioctl>
2331 * pm_cinfo - Shows the concurrent connection list.
2332 *
2333 * @INPUT: None
2334 *
2335 * @OUTPUT: None
2336 *
2337 * This IOCTL is used to show the concurrent connection list.
2338 *
2339 * @E.g: iwpriv wlan0 pm_cinfo
2340 *
2341 * Supported Feature: DBS
2342 *
2343 * Usage: Internal/External
2344 *
2345 * </ioctl>
2346 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302348
2349/*
2350 * <ioctl>
2351 * pm_ulist - Updates the index value of the concurrent connection list
2352 * with the input parameters provided.
2353 *
2354 * @INPUT: Following 8 arguments:
2355 * @vdev_id: vdev id
2356 * @tx_streams: TX streams
2357 * @rx_streams: RX streams
2358 * @chain_mask: Chain mask
2359 * @type: vdev_type
2360 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2361 * @sub_type: vdev_subtype
2362 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2363 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2364 * @channel: Channel
2365 * @mac: Mac id
2366 *
2367 * @OUTPUT: None
2368 *
2369 * This IOCTL is used to updates the index value of the concurrent
2370 * connection list with the input parameters provided.
2371 *
2372 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
2373 * sub_type channel mac
2374 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
2375 *
2376 * Supported Feature: DBS
2377 *
2378 * Usage: Internal/External
2379 *
2380 * </ioctl>
2381 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302383
2384/*
2385 * <ioctl>
2386 * pm_query_action - Initiate actions needed on current connections as
2387 * per the channel provided.
2388 *
2389 * @INPUT: channel
2390 * @channel: Channel on which new connection will be.
2391 *
2392 * @OUTPUT: None
2393 *
2394 * This IOCTL is used to initiate actions needed on current connections
2395 * as per the channel provided.
2396 *
2397 * @E.g: iwpriv wlan0 pm_query_action channel
2398 * iwpriv wlan0 pm_query_action 6
2399 *
2400 * Supported Feature: DBS
2401 *
2402 * Usage: Internal/External
2403 *
2404 * </ioctl>
2405 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302407
2408/*
2409 * <ioctl>
2410 * pm_query_allow - Checks for allowed concurrency combination
2411 *
2412 * @INPUT: mode, channel, bandwidth
2413 * @mode: new connection mode
2414 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2415 * @channel: channel on which new connection is coming up
2416 * @bandwidth: Bandwidth requested by the connection
2417 * 0:None 1:5MHz 2:10MHz 3:20MHz
2418 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
2419 *
2420 * @OUTPUT: None
2421 *
2422 * This IOCTL is used to checks for allowed concurrency combination.
2423 *
2424 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
2425 * iwpriv wlan0 pm_query_allow 0 6 4
2426 *
2427 * Supported Feature: DBS
2428 *
2429 * Usage: Internal/External
2430 *
2431 * </ioctl>
2432 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302434
2435/*
2436 * <ioctl>
2437 * pm_run_scenario - Create scenario with number of connections provided.
2438 *
2439 * @INPUT: num_of_conn
2440 * @num_of_conn: the number of connections (values: 1~3)
2441 *
2442 * @OUTPUT: None
2443 *
2444 * This IOCTL is used to create scenario with the number of connections
2445 * provided.
2446 *
2447 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
2448 * iwpriv wlan0 pm_run_scenario 1
2449 *
2450 * Supported Feature: DBS
2451 *
2452 * Usage: Internal/External
2453 *
2454 * </ioctl>
2455 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302457
2458/*
2459 * <ioctl>
2460 * pm_set_hw_mode - Set hardware for single/dual mac.
2461 *
2462 * @INPUT: hw_mode
2463 * 0:single mac 1:dual mac
2464 *
2465 * @OUTPUT: None
2466 *
2467 * This IOCTL is used to set hardware for single/dual mac.
2468 *
2469 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
2470 * iwpriv wlan0 pm_set_hw_mode 1
2471 *
2472 * Supported Feature: DBS
2473 *
2474 * Usage: Internal/External
2475 *
2476 * </ioctl>
2477 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478#define WE_POLICY_SET_HW_MODE_CMD 20
2479
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302480/*
2481 * <ioctl>
2482 * set_scan_cfg - Set dual MAC scan config parameters.
2483 *
2484 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2485 * @dbs: Value of DBS bit
2486 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2487 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2488 *
2489 * @OUTPUT: None
2490 *
2491 * This IOCTL is used to set the dual MAC scan config.
2492 *
2493 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2494 * single_mac_scan_with_dbs
2495 * iwpriv wlan0 set_scan_cfg 1 0 1
2496 *
2497 * Supported Feature: DBS
2498 *
2499 * Usage: Internal/External
2500 *
2501 * </ioctl>
2502 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302504
2505/*
2506 * <ioctl>
2507 * set_fw_mode_cfg - Sets the dual mac FW mode config
2508 *
2509 * @INPUT: dbs, dfs
2510 * @dbs: DBS bit
2511 * @dfs: Agile DFS bit
2512 *
2513 * @OUTPUT: None
2514 *
2515 * This IOCTL is used to set the dual mac FW mode config.
2516 *
2517 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2518 * iwpriv wlan0 set_fw_mode_cfg 1 1
2519 *
2520 * Supported Feature: DBS
2521 *
2522 * Usage: Internal/External
2523 *
2524 * </ioctl>
2525 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07002527#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528
2529#ifdef FEATURE_WLAN_TDLS
2530#undef MAX_VAR_ARGS
2531#define MAX_VAR_ARGS 11
2532#else
2533#undef MAX_VAR_ARGS
2534#define MAX_VAR_ARGS 9
2535#endif
2536
2537/* Private ioctls (with no sub-ioctls) */
2538/* note that they must be odd so that they have "get" semantics */
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302539/*
2540 * <ioctl>
2541 * addTspec - Add TSPEC for each AC
2542 *
2543 * @INPUT: 19 TSPEC params
2544 * @[arg0]: handle
2545 * @[arg1]: tid
2546 * @[arg2]: dir
2547 * @[arg3]: psb
2548 * @[arg4]: up
2549 * @[arg5]: nomMsduSize
2550 * @[arg6]: maxMsduSize
2551 * @[arg7]: minDataRate
2552 * @[arg8]: meanDataRate
2553 * @[arg9]: peakDataRate
2554 * @[arg10]: maxBurstSize
2555 * @[arg11]: minPhyRate
2556 * @[arg12]: sba
2557 * @[arg13]: minServiceIntv
2558 * @[arg14]: suspendIntv
2559 * @[arg15]: burstSizeDefn
2560 * @[arg16]: ackPolicy
2561 * @[arg17]: inactivityPeriod
2562 * @[arg18]: maxServiceIntv
2563 *
2564 * @OUTPUT: Success/Failure
2565 *
2566 * This IOCTL is used to add TSPEC for each AC.
2567 *
2568 * @E.g: iwpriv wlan0 addTspec <handle> <tid> <dir> <psb> <up> <nomMsduSize>
2569 * <maxMsduSize> <minDataRate> <meanDataRate>
2570 * <peakDataRate> <maxBurstSize> <minPhyRate>
2571 * <sba> <minServiceIntv> <suspendIntv>
2572 * <burstSizeDefn> <ackPolicy> <inactivityPeriod>
2573 * <maxServiceIntv>
2574 * iwpriv wlan0 addTspec 7001 6 2 1 6 0x80D0 0x80D0 0x14500 0x14500 0x14500
2575 * 0 0x5B8D80 0x2001 20 2000 0 0 0 2000
2576 * wlan0 addTspec:3
2577 *
2578 * Supported Feature: WMM
2579 *
2580 * Usage: Internal/External
2581 *
2582 * </ioctl>
2583 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302585/*
2586 * <ioctl>
2587 * delTspec - Delete TSPEC entry for each AC
2588 *
2589 * @INPUT: 1 TSPEC param
2590 * @[arg0]: handle
2591 *
2592 * @OUTPUT: Success/Failure
2593 *
2594 * This IOCTL is used to delete TSPEC entry for each AC.
2595 *
2596 * @E.g: iwpriv wlan0 delTspec <handle>
2597 * iwpriv wlan0 delTspec 7001
2598 * wlan0 delTspec:16
2599 *
2600 * Supported Feature: WMM
2601 *
2602 * Usage: Internal/External
2603 *
2604 * </ioctl>
2605 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302607/*
2608 * <ioctl>
2609 * getTspec - Get TSPEC entry for each AC
2610 *
2611 * @INPUT: 1 TSPEC param
2612 * @[arg0]: handle
2613 *
2614 * @OUTPUT: Success/Failure
2615 *
2616 * This IOCTL is used to get TSPEC entry for each AC.
2617 *
2618 * @E.g: iwpriv wlan0 getTspec <handle>
2619 * iwpriv wlan0 getTspec 7001
2620 * wlan0 delTspec:18
2621 *
2622 * Supported Feature: WMM
2623 *
2624 * Usage: Internal/External
2625 *
2626 * </ioctl>
2627 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2629
2630/* (SIOCIWFIRSTPRIV + 8) is currently unused */
2631/* (SIOCIWFIRSTPRIV + 10) is currently unused */
2632/* (SIOCIWFIRSTPRIV + 12) is currently unused */
2633/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002634#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
2635#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636/* (SIOCIWFIRSTPRIV + 16) is currently unused */
2637/* (SIOCIWFIRSTPRIV + 17) is currently unused */
2638/* (SIOCIWFIRSTPRIV + 19) is currently unused */
2639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641
2642/* Private ioctl for setting the host offload feature */
2643#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2644
2645/* Private ioctl to get the statistics */
2646#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2647
2648/* Private ioctl to set the Keep Alive Params */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302649/*
2650 * <ioctl>
2651 * setKeepAlive - Set the keep alive feature
2652 *
2653 * @INPUT: 28 bytes of information in the order of packet type, time period
2654 * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2655 *
2656 * @OUTPUT: None
2657 *
2658 * This IOCTL sets the keep alive feature to send either NULL
2659 * or unsolicited ARP response packets
2660 *
2661 * @E.g: iwpriv wlan0 setKeepAlive
2662 *
2663 * Supported Feature: STA
2664 *
2665 * Usage: Internal/External
2666 *
2667 * </ioctl>
2668 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2670
2671#ifdef WLAN_FEATURE_PACKET_FILTERING
2672/* Private ioctl to set the packet filtering params */
2673#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2674#endif
2675
2676
2677#ifdef FEATURE_WLAN_SCAN_PNO
2678/* Private ioctl to get the statistics */
2679#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2680#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302681/*
2682 * <ioctl>
2683 * SETBAND - Set the operational band
2684 *
2685 * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2686 *
2687 * @OUTPUT: None
2688 *
2689 * This IOCTL Set the operational band If the new band is different from the
2690 * current operational band, it aborts the pending scan requests, flushes
2691 * the existing scan results, and then change * the band capability
2692 *
2693 * @E.g: iwpriv wlan0 SETBAND <value>
2694 *
2695 * Supported Feature: STA
2696 *
2697 * Usage: Internal/External
2698 *
2699 * </ioctl>
2700 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
2702
Dustin Brown0cbc7572016-12-16 13:54:40 -08002703#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -08002704/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705
2706/* Private ioctls and their sub-ioctls */
2707#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
2708#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -07002709#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710#define WE_SET_FW_CRASH_INJECT 2
2711#endif
2712#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +05302713/* Private sub ioctl for enabling and setting histogram interval of profiling */
2714#define WE_ENABLE_FW_PROFILE 4
2715#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07002717/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002718#define WE_SET_WLAN_SUSPEND 6
2719#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002720
Dustin Brown8d2d0f52017-04-03 17:02:08 -07002721/*
2722 * <ioctl>
2723 * log_buffer - prints host/target related communication logs via dmesg
2724 *
2725 * @INPUT: Log Id, Count
2726 *
2727 * Log Id:
2728 * 0) HTC_CREDIT_HISTORY_LOG
2729 * 1) COMMAND_LOG,
2730 * 2) COMMAND_TX_CMP_LOG,
2731 * 3) MGMT_COMMAND_LOG,
2732 * 4) MGMT_COMMAND_TX_CMP_LOG,
2733 * 5) EVENT_LOG,
2734 * 6) RX_EVENT_LOG,
2735 * 7) MGMT_EVENT_LOG
2736 *
2737 * @OUTPUT: None
2738 *
2739 * @E.g:
2740 * # print up to 10 of the most recent records from HTC Credit History
2741 * iwpriv wlan0 log_buffer 0 10
2742 * # print up to 3 of the most recent records from Event Log
2743 * iwpriv wlan0 log_buffer 5 3
2744 *
2745 * Supported Feature: WLAN Trace
2746 *
2747 * Usage: Internal/External
2748 *
2749 * </ioctl>
2750 */
2751#define WE_LOG_BUFFER 8
2752
2753enum host_target_comm_log {
2754 HTC_CREDIT_HISTORY_LOG = 0,
2755 COMMAND_LOG,
2756 COMMAND_TX_CMP_LOG,
2757 MGMT_COMMAND_LOG,
2758 MGMT_COMMAND_TX_CMP_LOG,
2759 EVENT_LOG,
2760 RX_EVENT_LOG,
2761 MGMT_EVENT_LOG
2762};
2763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764/* (SIOCIWFIRSTPRIV + 29) is currently unused */
2765
2766/* 802.11p IOCTL */
2767#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
2768
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302769/*
2770 * <ioctl>
2771 * getLinkSpeed - Gets the current link speed in Mbps
2772 *
2773 * @INPUT: None
2774 *
2775 * @OUTPUT: linkspeed in mbps
2776 * wlan0 getLinkSpeed:7
2777 *
2778 * This IOCTL is used get the current link speed in Mbps
2779 *
2780 * @E.g: iwpriv wlan0 getLinkSpeed
2781 *
2782 * Supported Feature: STA
2783 *
2784 * Usage: Internal/External
2785 *
2786 * </ioctl>
2787 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
2789
2790#define WLAN_STATS_INVALID 0
2791#define WLAN_STATS_RETRY_CNT 1
2792#define WLAN_STATS_MUL_RETRY_CNT 2
2793#define WLAN_STATS_TX_FRM_CNT 3
2794#define WLAN_STATS_RX_FRM_CNT 4
2795#define WLAN_STATS_FRM_DUP_CNT 5
2796#define WLAN_STATS_FAIL_CNT 6
2797#define WLAN_STATS_RTS_FAIL_CNT 7
2798#define WLAN_STATS_ACK_FAIL_CNT 8
2799#define WLAN_STATS_RTS_SUC_CNT 9
2800#define WLAN_STATS_RX_DISCARD_CNT 10
2801#define WLAN_STATS_RX_ERROR_CNT 11
2802#define WLAN_STATS_TX_BYTE_CNT 12
2803
2804#define WLAN_STATS_RX_BYTE_CNT 13
2805#define WLAN_STATS_RX_RATE 14
2806#define WLAN_STATS_TX_RATE 15
2807
2808#define WLAN_STATS_RX_UC_BYTE_CNT 16
2809#define WLAN_STATS_RX_MC_BYTE_CNT 17
2810#define WLAN_STATS_RX_BC_BYTE_CNT 18
2811#define WLAN_STATS_TX_UC_BYTE_CNT 19
2812#define WLAN_STATS_TX_MC_BYTE_CNT 20
2813#define WLAN_STATS_TX_BC_BYTE_CNT 21
2814
2815#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
2816 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
2817 *__p++ = __type; \
2818 *__p++ = __size; \
2819 memcpy(__p, __val, __size); \
2820 __p += __size; \
2821 __tlen += __size + 2; \
2822 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07002823 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 } \
2825 } while (0)
2826
2827#define VERSION_VALUE_MAX_LEN 32
2828
2829#define TX_PER_TRACKING_DEFAULT_RATIO 5
2830#define TX_PER_TRACKING_MAX_RATIO 10
2831#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
2832
2833#define WLAN_ADAPTER 0
2834#define P2P_ADAPTER 1
2835
2836/**
2837 * mem_alloc_copy_from_user_helper - copy from user helper
2838 * @wrqu_data: wireless extensions request data
2839 * @len: length of @wrqu_data
2840 *
2841 * Helper function to allocate buffer and copy user data.
2842 *
2843 * Return: On success return a pointer to a kernel buffer containing a
2844 * copy of the userspace data (with an additional NUL character
2845 * appended for safety). On failure return %NULL.
2846 */
2847void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2848{
2849 u8 *ptr = NULL;
2850
2851 /* in order to protect the code, an extra byte is post
2852 * appended to the buffer and the null termination is added.
2853 * However, when allocating (len+1) byte of memory, we need to
2854 * make sure that there is no uint overflow when doing
2855 * addition. In theory check len < UINT_MAX protects the uint
2856 * overflow. For wlan private ioctl, the buffer size is much
2857 * less than UINT_MAX, as a good guess, now, it is assumed
2858 * that the private command buffer size is no greater than 4K
2859 * (4096 bytes). So we use 4096 as the upper boundary for now.
2860 */
2861 if (len > MAX_USER_COMMAND_SIZE) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08002862 hdd_err("Invalid length: %zu max: %u",
2863 len, MAX_USER_COMMAND_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 return NULL;
2865 }
2866
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002867 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002869 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 return NULL;
2871 }
2872
2873 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002874 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002875 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 return NULL;
2877 }
2878 ptr[len] = '\0';
2879 return ptr;
2880}
2881
2882/**
2883 * hdd_priv_get_data() - Get pointer to ioctl private data
2884 * @p_priv_data: pointer to iw_point struct to be filled
2885 * @wrqu: Pointer to IOCTL Data received from userspace
2886 *
2887 * Helper function to get compatible struct iw_point passed to ioctl
2888 *
2889 * Return - 0 if p_priv_data successfully filled, error otherwise
2890 */
2891int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2892{
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002893 if ((NULL == p_priv_data) || (NULL == wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002894 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896#ifdef CONFIG_COMPAT
2897 if (is_compat_task()) {
2898 struct compat_iw_point *p_compat_priv_data;
2899
2900 /* Compat task:
2901 * typecast to compat structure and copy the members.
2902 */
2903 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2904
2905 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2906 p_priv_data->length = p_compat_priv_data->length;
2907 p_priv_data->flags = p_compat_priv_data->flags;
2908 } else {
2909#endif /* #ifdef CONFIG_COMPAT */
2910
2911 /* Non compat task: directly copy the structure. */
2912 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
2913
2914#ifdef CONFIG_COMPAT
2915 }
2916#endif /* #ifdef CONFIG_COMPAT */
2917
2918 return 0;
2919}
2920
Jeff Johnson441e1f72017-02-07 08:50:49 -08002921static int hdd_check_wext_control(enum hdd_wext_control wext_control,
2922 struct iw_request_info *info)
2923{
2924 switch (wext_control) {
2925 default:
2926 case hdd_wext_disabled:
2927 hdd_err("Rejecting disabled ioctl %x", info->cmd);
2928 return -ENOTSUPP;
2929 case hdd_wext_deprecated:
2930 hdd_warn("Using deprecated ioctl %x", info->cmd);
2931 return 0;
2932 case hdd_wext_enabled:
2933 return 0;
2934 }
2935}
2936
2937int hdd_check_standard_wext_control(struct hdd_context_s *hdd_ctx,
2938 struct iw_request_info *info)
2939{
2940 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
2941 info);
2942}
2943
2944int hdd_check_private_wext_control(struct hdd_context_s *hdd_ctx,
2945 struct iw_request_info *info)
2946{
2947 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
2948 info);
2949}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950
2951/**
2952 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
2953 * @pAdapter: Pointer to the hdd adapter.
2954 * @length: Size of the data copied
2955 * @buffer: Pointer to char buffer.
2956 * @buf_len: Length of the char buffer.
2957 *
2958 * This function called when the "iwpriv wlan0 get_stats" command is given.
2959 * It used to collect the txrx stats when the device is configured in SAP mode.
2960 *
2961 * Return - none
2962 */
2963void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
2964 char *buffer, uint16_t buf_len)
2965{
2966 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
2967 uint32_t len = 0;
2968 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
2969 uint32_t total_rx_delv = 0, total_rx_refused = 0;
2970 int i = 0;
2971
2972 for (; i < NUM_CPUS; i++) {
2973 total_rx_pkt += pStats->rxPackets[i];
2974 total_rx_dropped += pStats->rxDropped[i];
2975 total_rx_delv += pStats->rxDelivered[i];
2976 total_rx_refused += pStats->rxRefused[i];
2977 }
2978
2979 len = scnprintf(buffer, buf_len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002980 "\nTransmit[%lu] - "
Mohit Khannad0b63f52017-02-18 18:05:52 -08002981 "called %u, dropped %u orphan %u,"
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002982 "\n[dropped] BK %u, BE %u, VI %u, VO %u"
2983 "\n[classified] BK %u, BE %u, VI %u, VO %u"
2984 "\n\nReceive[%lu] - "
2985 "packets %u, dropped %u, delivered %u, refused %u"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 "\n",
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002987 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 pStats->txXmitCalled,
2989 pStats->txXmitDropped,
Mohit Khannad0b63f52017-02-18 18:05:52 -08002990 pStats->txXmitOrphaned,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002991
2992 pStats->txXmitDroppedAC[SME_AC_BK],
2993 pStats->txXmitDroppedAC[SME_AC_BE],
2994 pStats->txXmitDroppedAC[SME_AC_VI],
2995 pStats->txXmitDroppedAC[SME_AC_VO],
2996
2997 pStats->txXmitClassifiedAC[SME_AC_BK],
2998 pStats->txXmitClassifiedAC[SME_AC_BE],
2999 pStats->txXmitClassifiedAC[SME_AC_VI],
3000 pStats->txXmitClassifiedAC[SME_AC_VO],
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003001 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
3003 );
3004
3005 for (i = 0; i < NUM_CPUS; i++) {
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003006 if (pStats->rxPackets[i] == 0)
3007 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003009 "Rx CPU[%d]:"
3010 "packets %u, dropped %u, delivered %u, refused %u\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 i, pStats->rxPackets[i], pStats->rxDropped[i],
3012 pStats->rxDelivered[i], pStats->rxRefused[i]);
3013 }
3014
3015 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003016 "\nTX_FLOW"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 "\nCurrent status: %s"
3018 "\ntx-flow timer start count %u"
3019 "\npause count %u, unpause count %u",
3020 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
3021 pStats->txflow_timer_cnt,
3022 pStats->txflow_pause_cnt,
3023 pStats->txflow_unpause_cnt);
3024
Leo Changfdb45c32016-10-28 11:09:23 -07003025 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
3026 pAdapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 *length = len + 1;
3028}
3029
3030/**
Dustin Brownd9322482017-01-09 12:46:03 -08003031 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
3032 * @hdd_ctx: The Hdd context owning the stats to be written
3033 * @buffer: The char buffer to write to
3034 * @max_len: The maximum number of chars to write
3035 *
3036 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
3037 *
3038 * Return - length of written content, negative number on error
3039 */
3040static int wlan_hdd_write_suspend_resume_stats(hdd_context_t *hdd_ctx,
3041 char *buffer, uint16_t max_len)
3042{
3043 QDF_STATUS status;
3044 struct suspend_resume_stats *sr_stats;
3045 struct sir_wake_lock_stats wow_stats;
3046
3047 sr_stats = &hdd_ctx->suspend_resume_stats;
3048
3049 status = wma_get_wakelock_stats(&wow_stats);
3050 if (QDF_IS_STATUS_ERROR(status)) {
3051 hdd_err("Failed to get WoW stats");
3052 return qdf_status_to_os_return(status);
3053 }
3054
3055 return scnprintf(buffer, max_len,
3056 "\n"
3057 "Suspends: %u\n"
3058 "Resumes: %u\n"
3059 "\n"
3060 "Suspend Fail Reasons\n"
3061 "\tIPA: %u\n"
3062 "\tRadar: %u\n"
3063 "\tRoam: %u\n"
3064 "\tScan: %u\n"
3065 "\tInitial Wakeup: %u\n"
3066 "\n"
3067 "WoW Wake Reasons\n"
3068 "\tunicast: %u\n"
3069 "\tbroadcast: %u\n"
3070 "\tIPv4 multicast: %u\n"
3071 "\tIPv6 multicast: %u\n"
3072 "\tIPv6 multicast RA: %u\n"
3073 "\tIPv6 multicast NS: %u\n"
3074 "\tIPv6 multicast NA: %u\n"
3075 "\tICMPv4: %u\n"
3076 "\tICMPv6: %u\n"
3077 "\tRSSI Breach: %u\n"
3078 "\tLow RSSI: %u\n"
3079 "\tG-Scan: %u\n"
3080 "\tPNO Complete: %u\n"
3081 "\tPNO Match: %u\n",
3082 sr_stats->suspends,
3083 sr_stats->resumes,
3084 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
3085 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
3086 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
3087 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
3088 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
3089 wow_stats.wow_ucast_wake_up_count,
3090 wow_stats.wow_bcast_wake_up_count,
3091 wow_stats.wow_ipv4_mcast_wake_up_count,
3092 wow_stats.wow_ipv6_mcast_wake_up_count,
3093 wow_stats.wow_ipv6_mcast_ra_stats,
3094 wow_stats.wow_ipv6_mcast_ns_stats,
3095 wow_stats.wow_ipv6_mcast_na_stats,
3096 wow_stats.wow_icmpv4_count,
3097 wow_stats.wow_icmpv6_count,
3098 wow_stats.wow_rssi_breach_wake_up_count,
3099 wow_stats.wow_low_rssi_wake_up_count,
3100 wow_stats.wow_gscan_wake_up_count,
3101 wow_stats.wow_pno_complete_wake_up_count,
3102 wow_stats.wow_pno_match_wake_up_count);
3103}
3104
3105/**
Govind Singha471e5e2015-10-12 17:11:14 +05303106 * hdd_wlan_list_fw_profile() - Get fw profiling points
3107 * @length: Size of the data copied
3108 * @buffer: Pointer to char buffer.
3109 * @buf_len: Length of the char buffer.
3110 *
3111 * This function called when the "iwpriv wlan0 listProfile" command is given.
3112 * It is used to get the supported profiling points in FW.
3113 *
3114 * Return - none
3115 */
3116void hdd_wlan_list_fw_profile(uint16_t *length,
3117 char *buffer, uint16_t buf_len)
3118{
3119 uint32_t len = 0;
3120
3121 len = scnprintf(buffer, buf_len,
3122 "PROF_CPU_IDLE: %u\n"
3123 "PROF_PPDU_PROC: %u\n"
3124 "PROF_PPDU_POST: %u\n"
3125 "PROF_HTT_TX_INPUT: %u\n"
3126 "PROF_MSDU_ENQ: %u\n"
3127 "PROF_PPDU_POST_HAL: %u\n"
3128 "PROF_COMPUTE_TX_TIME: %u\n",
3129 PROF_CPU_IDLE,
3130 PROF_PPDU_PROC,
3131 PROF_PPDU_POST,
3132 PROF_HTT_TX_INPUT,
3133 PROF_MSDU_ENQ,
3134 PROF_PPDU_POST_HAL,
3135 PROF_COMPUTE_TX_TIME);
3136
3137 *length = len + 1;
3138}
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003139/**
3140 * hdd_display_stats_help() - print statistics help
3141 *
3142 * Return: none
3143 */
3144void hdd_display_stats_help(void)
3145{
3146 hdd_err("iwpriv wlan0 dumpStats [option] - dump statistics");
3147 hdd_err("iwpriv wlan0 clearStats [option] - clear statistics");
3148 hdd_err("options:");
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003149 hdd_err(" 1 -- TXRX PATH statistics");
3150 hdd_err(" 2 -- TXRX HIST statistics");
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003151 hdd_err(" 3 -- TSO statistics");
3152 hdd_err(" 4 -- Network queue statistics");
3153 hdd_err(" 5 -- Flow control statistics");
3154 hdd_err(" 6 -- Per Layer statistics");
3155 hdd_err(" 7 -- Copy engine interrupt statistics");
3156 hdd_err(" 8 -- LRO statistics");
3157 hdd_err(" 9 -- NAPI statistics");
3158}
Govind Singha471e5e2015-10-12 17:11:14 +05303159
3160/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161 * hdd_wlan_dump_stats() - display dump Stats
3162 * @adapter: adapter handle
3163 * @value: value from user
3164 *
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003165 * Return: 0 => success, error code on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 */
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003167int hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168{
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003169 int ret = 0;
3170 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003171 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3172
3173 switch (value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003174 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003175 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
3176 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003177 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 wlan_hdd_display_netif_queue_history(hdd_ctx);
3179 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003180 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05303181 hdd_display_hif_stats();
3182 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003183 case CDP_LRO_STATS:
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003184 hdd_lro_display_stats(hdd_ctx);
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003185 case CDP_NAPI_STATS:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003186 if (hdd_display_napi_stats()) {
3187 hdd_err("error displaying napi stats");
3188 ret = EFAULT;
3189 }
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003190 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191 default:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003192 status = cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC),
3193 value);
3194 if (status == QDF_STATUS_E_INVAL) {
3195 hdd_display_stats_help();
3196 ret = EINVAL;
3197 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 break;
3199 }
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003200 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201}
3202
3203/**
3204 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303205 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206 * @wrqu: Pointer to IOCTL REQUEST Data.
3207 * @extra: Pointer to destination buffer
3208 *
3209 * This function is used to get Wlan Driver, Firmware, & Hardware
3210 * Version information. If @wrqu and @extra are specified, then the
3211 * version string is returned. Otherwise it is simply printed to the
3212 * kernel log.
3213 *
3214 * Return: none
3215 */
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303216void hdd_wlan_get_version(hdd_context_t *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 char *extra)
3218{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303219 tSirVersionString wcnss_sw_version;
3220 const char *swversion;
3221 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003222 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303224 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003225 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 goto error;
3227 }
3228
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303229 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
3230 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303232 swversion = wcnss_sw_version;
3233 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
3234 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
3235 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
3236 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003237 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303239 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240
3241 if (wrqu && extra) {
3242 wrqu->data.length =
3243 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003244 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003246 msp_id, mspid, siid, crmid,
3247 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003249 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003251 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 }
3253error:
3254 return;
3255}
3256
3257/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003258 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
3259 * @pAdapter: Adapter upon which the IBSS client is active
3260 * @staIdx: Station index of the IBSS peer
3261 *
3262 * Return: a pointer to the MAC address of the IBSS peer if the peer is
3263 * found, otherwise %NULL.
3264 */
3265struct qdf_mac_addr *
3266hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
3267 uint8_t staIdx)
3268{
3269 uint8_t idx;
3270 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3271
Naveen Rawatc45d1622016-07-05 12:20:09 -07003272 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003273 if (0 != pHddStaCtx->conn_info.staId[idx] &&
3274 staIdx == pHddStaCtx->conn_info.staId[idx]) {
3275 return &pHddStaCtx->conn_info.peerMacAddress[idx];
3276 }
3277 }
3278 return NULL;
3279}
3280
3281/**
3282 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
3283 * @pAdapter: Adapter upon which the IBSS client is active
3284 * @staIdx: Station index of the IBSS peer
3285 *
3286 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
3287 * otherwise an appropriate QDF_STATUS_E_* failure code.
3288 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003289static QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter,
3290 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003291{
3292 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3293 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3294 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003295 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003296
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003297 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003298 status = sme_request_ibss_peer_info(hHal, pAdapter,
3299 hdd_get_ibss_peer_info_cb,
3300 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003301
3302 if (QDF_STATUS_SUCCESS == status) {
3303 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003304
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003305 rc = wait_for_completion_timeout
3306 (&pAdapter->ibss_peer_info_comp,
3307 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3308 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003309 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003310 return QDF_STATUS_E_FAILURE;
3311 }
3312
3313 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003314 hdd_debug("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003315 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003316 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3317 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003318
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003319 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
3320 mac_addr, sizeof(mac_addr));
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003321 hdd_debug("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003322 mac_addr, (int)tx_rate,
3323 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003324 }
3325 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003326 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003327 }
3328
3329 return status;
3330}
3331
3332/**
3333 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
3334 * @pAdapter: Adapter upon which the IBSS clients are active
3335 *
3336 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
3337 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
3338 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003339static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003340{
3341 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3342 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3343 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003344 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003345 int i;
3346
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003347 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003348 status = sme_request_ibss_peer_info(hHal, pAdapter,
3349 hdd_get_ibss_peer_info_cb,
3350 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003351
3352 if (QDF_STATUS_SUCCESS == status) {
3353 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003354
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003355 rc = wait_for_completion_timeout
3356 (&pAdapter->ibss_peer_info_comp,
3357 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3358 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003359 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003360 return QDF_STATUS_E_FAILURE;
3361 }
3362
3363 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003364 hdd_debug("pPeerInfo->numIBSSPeers = %d ",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003365 (int)pPeerInfo->numPeers);
3366 for (i = 0; i < pPeerInfo->numPeers; i++) {
3367 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3368 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003369
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003370 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
3371 qdf_mem_copy(mac_addr,
3372 pPeerInfo->peerInfoParams[i].mac_addr,
3373 sizeof(mac_addr));
3374
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003375 hdd_debug(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003376 mac_addr, (int)tx_rate,
3377 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003378 }
3379 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003380 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003381 }
3382
3383 return status;
3384}
3385
3386/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 * hdd_wlan_get_freq() - Convert channel to frequency
3388 * @channel: channel to be converted
3389 * @pfreq: where to store the frequency
3390 *
3391 * Return: 1 on success, otherwise a negative errno
3392 */
3393int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
3394{
3395 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003396
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003397 if (channel > 0) {
3398 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
3399 if (channel == freq_chan_map[i].chan) {
3400 *pfreq = freq_chan_map[i].freq;
3401 return 1;
3402 }
3403 }
3404 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003405 hdd_err("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 return -EINVAL;
3407}
3408
3409/**
3410 * hdd_is_auth_type_rsn() - RSN authentication type check
3411 * @authType: authentication type to be checked
3412 *
3413 * Return: true if @authType is an RSN authentication type,
3414 * false if it is not
3415 */
3416static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
3417{
3418 bool rsnType = false;
3419 /* is the authType supported? */
3420 switch (authType) {
3421 case eCSR_AUTH_TYPE_NONE: /* never used */
3422 rsnType = false;
3423 break;
3424 /* MAC layer authentication types */
3425 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3426 rsnType = false;
3427 break;
3428 case eCSR_AUTH_TYPE_SHARED_KEY:
3429 rsnType = false;
3430 break;
3431 case eCSR_AUTH_TYPE_AUTOSWITCH:
3432 rsnType = false;
3433 break;
3434
3435 /* Upper layer authentication types */
3436 case eCSR_AUTH_TYPE_WPA:
3437 rsnType = true;
3438 break;
3439 case eCSR_AUTH_TYPE_WPA_PSK:
3440 rsnType = true;
3441 break;
3442 case eCSR_AUTH_TYPE_WPA_NONE:
3443 rsnType = true;
3444 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 case eCSR_AUTH_TYPE_RSN:
3447 rsnType = true;
3448 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 case eCSR_AUTH_TYPE_RSN_PSK:
3451#ifdef WLAN_FEATURE_11W
3452 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3453 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
3454#endif
3455 rsnType = true;
3456 break;
3457 /* case eCSR_AUTH_TYPE_FAILED: */
3458 case eCSR_AUTH_TYPE_UNKNOWN:
3459 rsnType = false;
3460 break;
3461 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003462 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463 authType);
3464 rsnType = false;
3465 break;
3466 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003467 hdd_debug("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468 authType, rsnType);
3469 return rsnType;
3470}
3471
Jeff Johnsona5444942017-01-23 13:11:08 -08003472struct rssi_priv {
3473 int8_t rssi;
3474};
3475
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476/**
3477 * hdd_get_rssi_cb() - "Get RSSI" callback function
3478 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08003479 * @sta_id: ID of the station
3480 * @context: opaque context originally passed to SME. HDD always passes
3481 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 *
3483 * Return: None
3484 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003485static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486{
Jeff Johnsona5444942017-01-23 13:11:08 -08003487 struct hdd_request *request;
3488 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489
Jeff Johnsona5444942017-01-23 13:11:08 -08003490 request = hdd_request_get(context);
3491 if (!request) {
3492 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 return;
3494 }
3495
Jeff Johnsona5444942017-01-23 13:11:08 -08003496 priv = hdd_request_priv(request);
3497 priv->rssi = rssi;
3498 hdd_request_complete(request);
3499 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500}
3501
3502/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 * wlan_hdd_get_rssi() - Get the current RSSI
3504 * @pAdapter: adapter upon which the measurement is requested
3505 * @rssi_value: pointer to where the RSSI should be returned
3506 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303507 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303509QDF_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 hdd_context_t *pHddCtx;
3512 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303513 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08003514 int ret;
3515 void *cookie;
3516 struct hdd_request *request;
3517 struct rssi_priv *priv;
3518 static const struct hdd_request_params params = {
3519 .priv_size = sizeof(*priv),
3520 .timeout_ms = WLAN_WAIT_TIME_STATS,
3521 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522
3523 if (NULL == pAdapter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003524 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303525 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003527 if (cds_is_driver_recovering()) {
3528 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3529 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 /* return a cached value */
3531 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303532 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003533 }
3534
3535 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3536 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3537
3538 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003539 hdd_debug("Not associated!, rssi on disconnect %d",
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05303540 pAdapter->rssi_on_disconnect);
3541 *rssi_value = pAdapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303542 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 }
3544
3545 if (pHddStaCtx->hdd_ReassocScenario) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003546 hdd_debug("Roaming in progress, return cached RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303548 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 }
3550
Jeff Johnsona5444942017-01-23 13:11:08 -08003551 request = hdd_request_alloc(&params);
3552 if (!request) {
3553 hdd_err("Request allocation failure, return cached RSSI");
3554 *rssi_value = pAdapter->rssi;
3555 return QDF_STATUS_SUCCESS;
3556 }
3557 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558
3559 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
3560 pHddStaCtx->conn_info.staId[0],
3561 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
Jeff Johnsona5444942017-01-23 13:11:08 -08003562 cookie, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303563 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003564 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565 /* we'll returned a cached value below */
3566 } else {
3567 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08003568 ret = hdd_request_wait_for_response(request);
3569 if (ret) {
3570 hdd_warn("SME timed out while retrieving RSSI");
3571 /* we'll returned a cached value below */
3572 } else {
3573 /* update the adapter with the fresh results */
3574 priv = hdd_request_priv(request);
3575 pAdapter->rssi = priv->rssi;
3576 if (pAdapter->rssi > 0)
3577 pAdapter->rssi = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578 }
3579 }
3580
Jeff Johnsona5444942017-01-23 13:11:08 -08003581 /*
3582 * either we never sent a request, we sent a request and
3583 * received a response or we sent a request and timed out.
3584 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003586 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587
3588 *rssi_value = pAdapter->rssi;
3589
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303590 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591}
3592
Jeff Johnson002cb972017-01-23 14:59:07 -08003593struct snr_priv {
3594 int8_t snr;
3595};
3596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08003598 * hdd_get_snr_cb() - "Get SNR" callback function
3599 * @snr: Current SNR of the station
Jeff Johnson002cb972017-01-23 14:59:07 -08003600 * @sta_id: ID of the station
3601 * @context: opaque context originally passed to SME. HDD always passes
3602 * a cookie for the request context
Jeff Johnson8eaff302017-01-23 11:03:31 -08003603 *
3604 * Return: None
3605 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003606static void hdd_get_snr_cb(int8_t snr, uint32_t sta_id, void *context)
Jeff Johnson8eaff302017-01-23 11:03:31 -08003607{
Jeff Johnson002cb972017-01-23 14:59:07 -08003608 struct hdd_request *request;
3609 struct snr_priv *priv;
Jeff Johnson8eaff302017-01-23 11:03:31 -08003610
Jeff Johnson002cb972017-01-23 14:59:07 -08003611 request = hdd_request_get(context);
3612 if (!request) {
3613 hdd_err("Obsolete request");
Jeff Johnson8eaff302017-01-23 11:03:31 -08003614 return;
3615 }
3616
Jeff Johnson002cb972017-01-23 14:59:07 -08003617 /* propagate response back to requesting thread */
3618 priv = hdd_request_priv(request);
3619 priv->snr = snr;
3620 hdd_request_complete(request);
3621 hdd_request_put(request);
Jeff Johnson8eaff302017-01-23 11:03:31 -08003622}
3623
3624/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 * wlan_hdd_get_snr() - Get the current SNR
3626 * @pAdapter: adapter upon which the measurement is requested
3627 * @snr: pointer to where the SNR should be returned
3628 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303629 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303631QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 hdd_context_t *pHddCtx;
3634 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303635 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 int valid;
Jeff Johnson002cb972017-01-23 14:59:07 -08003637 int ret;
3638 void *cookie;
3639 struct hdd_request *request;
3640 struct snr_priv *priv;
3641 static const struct hdd_request_params params = {
3642 .priv_size = sizeof(*priv),
3643 .timeout_ms = WLAN_WAIT_TIME_STATS,
3644 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303646 ENTER();
3647
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003649 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303650 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 }
3652
3653 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3654
3655 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303656 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303657 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658
3659 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3660
Jeff Johnson002cb972017-01-23 14:59:07 -08003661 request = hdd_request_alloc(&params);
3662 if (!request) {
3663 hdd_err("Request allocation failure");
3664 return QDF_STATUS_E_FAULT;
3665 }
3666 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667
3668 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
3669 pHddStaCtx->conn_info.staId[0],
Jeff Johnson002cb972017-01-23 14:59:07 -08003670 pHddStaCtx->conn_info.bssId, cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303671 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003672 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 /* we'll returned a cached value below */
3674 } else {
3675 /* request was sent -- wait for the response */
Jeff Johnson002cb972017-01-23 14:59:07 -08003676 ret = hdd_request_wait_for_response(request);
3677 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003678 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679 /* we'll now returned a cached value below */
Jeff Johnson002cb972017-01-23 14:59:07 -08003680 } else {
3681 /* update the adapter with the fresh results */
3682 priv = hdd_request_priv(request);
3683 pAdapter->snr = priv->snr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 }
3685 }
3686
Jeff Johnson002cb972017-01-23 14:59:07 -08003687 /*
3688 * either we never sent a request, we sent a request and
3689 * received a response or we sent a request and timed out.
3690 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003692 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693
3694 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303695 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303696 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697}
3698
Jeff Johnsone50427c2017-01-26 10:54:49 -08003699struct linkspeed_priv {
3700 tSirLinkSpeedInfo linkspeed_info;
3701};
3702
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703static void
Jeff Johnsone50427c2017-01-26 10:54:49 -08003704hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705{
Jeff Johnsone50427c2017-01-26 10:54:49 -08003706 struct hdd_request *request;
3707 struct linkspeed_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708
Jeff Johnsone50427c2017-01-26 10:54:49 -08003709 if (!linkspeed_info) {
3710 hdd_err("NULL linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 return;
3712 }
3713
Jeff Johnsone50427c2017-01-26 10:54:49 -08003714 request = hdd_request_get(context);
3715 if (!request) {
3716 hdd_err("Obsolete request");
3717 return;
3718 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719
Jeff Johnsone50427c2017-01-26 10:54:49 -08003720 priv = hdd_request_priv(request);
3721 priv->linkspeed_info = *linkspeed_info;
3722 hdd_request_complete(request);
3723 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724}
3725
Jeff Johnsone50427c2017-01-26 10:54:49 -08003726int wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *adapter,
3727 struct qdf_mac_addr *mac_address,
3728 uint32_t *linkspeed)
3729{
3730 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303731 QDF_STATUS status;
Jeff Johnsone50427c2017-01-26 10:54:49 -08003732 void *cookie;
3733 tSirLinkSpeedInfo *linkspeed_info;
3734 struct hdd_request *request;
3735 struct linkspeed_priv *priv;
3736 static const struct hdd_request_params params = {
3737 .priv_size = sizeof(*priv),
3738 .timeout_ms = WLAN_WAIT_TIME_STATS,
3739 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003740
Jeff Johnsone50427c2017-01-26 10:54:49 -08003741 if ((!adapter) || (!linkspeed)) {
3742 hdd_err("NULL argument");
3743 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003744 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745
Jeff Johnsone50427c2017-01-26 10:54:49 -08003746 request = hdd_request_alloc(&params);
3747 if (!request) {
3748 hdd_err("Request allocation failure");
3749 ret = -ENOMEM;
3750 goto return_cached_value;
3751 }
3752
3753 cookie = hdd_request_cookie(request);
3754 priv = hdd_request_priv(request);
3755
3756 linkspeed_info = &priv->linkspeed_info;
3757 qdf_copy_macaddr(&linkspeed_info->peer_macaddr, mac_address);
3758 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(adapter),
3759 linkspeed_info,
3760 cookie, hdd_get_link_speed_cb);
3761 if (QDF_IS_STATUS_ERROR(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003762 hdd_err("Unable to retrieve statistics for link speed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003763 ret = qdf_status_to_os_return(status);
3764 goto cleanup;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 }
Jeff Johnsone50427c2017-01-26 10:54:49 -08003766 ret = hdd_request_wait_for_response(request);
3767 if (ret) {
3768 hdd_err("SME timed out while retrieving link speed");
3769 goto cleanup;
3770 }
3771 adapter->estimated_linkspeed = linkspeed_info->estLinkSpeed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772
Jeff Johnsone50427c2017-01-26 10:54:49 -08003773cleanup:
3774 /*
3775 * either we never sent a request, we sent a request and
3776 * received a response or we sent a request and timed out.
3777 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 */
Jeff Johnsone50427c2017-01-26 10:54:49 -08003779 hdd_request_put(request);
3780
3781return_cached_value:
3782 *linkspeed = adapter->estimated_linkspeed;
3783
3784 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785}
3786
3787/**
3788 * wlan_hdd_get_link_speed() - get link speed
3789 * @pAdapter: pointer to the adapter
3790 * @link_speed: pointer to link speed
3791 *
3792 * This function fetches per bssid link speed.
3793 *
3794 * Return: if associated, link speed shall be returned.
3795 * if not associated, link speed of 0 is returned.
3796 * On error, error number will be returned.
3797 */
3798int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
3799{
3800 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
3801 hdd_station_ctx_t *hdd_stactx =
3802 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
3803 int ret;
3804
3805 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05303806 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303809 /* Linkspeed is allowed only for P2P mode */
3810 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
3811 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
3812 hdd_device_mode_to_string(sta_adapter->device_mode),
3813 sta_adapter->device_mode);
3814 return -ENOTSUPP;
3815 }
3816
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
3818 /* we are not connected so we don't have a classAstats */
3819 *link_speed = 0;
3820 } else {
Anurag Chouhan6d760662016-02-20 16:05:43 +05303821 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822
Anurag Chouhanc5548422016-02-24 18:33:27 +05303823 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824
Jeff Johnsone50427c2017-01-26 10:54:49 -08003825 ret = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, &bssid,
3826 link_speed);
3827 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003828 hdd_err("Unable to retrieve SME linkspeed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003829 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831 /* linkspeed in units of 500 kbps */
3832 *link_speed = (*link_speed) / 500;
3833 }
3834 return 0;
3835}
3836
3837/**
3838 * hdd_statistics_cb() - "Get statistics" callback function
3839 * @pStats: statistics payload
3840 * @pContext: opaque context originally passed to SME. HDD always passes
3841 * a pointer to an adapter
3842 *
3843 * Return: None
3844 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003845static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003846{
3847 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
3848 hdd_stats_t *pStatsCache = NULL;
3849 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05303850 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851
3852 tCsrSummaryStatsInfo *pSummaryStats = NULL;
3853 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855
3856 if (pAdapter != NULL)
3857 pStatsCache = &pAdapter->hdd_stats;
3858
3859 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3860 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Jeff Johnsonf2dac4f2017-03-16 11:41:31 -07003861 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862
3863 if (pStatsCache != NULL) {
3864 /* copy the stats into the cache we keep in the
3865 * adapter instance structure
3866 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303867 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303869 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303871 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 sizeof(pStatsCache->ClassD_stat));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 }
3874
3875 if (pAdapter) {
3876 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303877 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05303878 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003879 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880 return;
3881 }
3882 }
3883}
3884
3885/**
3886 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
3887 * @pAdapter: adapter who's IEs are to be cleared
3888 *
3889 * Return: None
3890 */
3891void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
3892{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003893 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07003894
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003895 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896
3897 /* clear WPA/RSN/WSC IE information in the profile */
3898 pWextState->roamProfile.nWPAReqIELength = 0;
3899 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
3900 pWextState->roamProfile.nRSNReqIELength = 0;
3901 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
3902
3903#ifdef FEATURE_WLAN_WAPI
3904 pWextState->roamProfile.nWAPIReqIELength = 0;
3905 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
3906#endif
3907
3908 pWextState->roamProfile.bWPSAssociation = false;
3909 pWextState->roamProfile.bOSENAssociation = false;
3910 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
3911 pWextState->roamProfile.nAddIEScanLength = 0;
3912 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
3913 pWextState->roamProfile.nAddIEAssocLength = 0;
3914
3915 pWextState->roamProfile.EncryptionType.numEntries = 1;
3916 pWextState->roamProfile.EncryptionType.encryptionType[0]
3917 = eCSR_ENCRYPT_TYPE_NONE;
3918
3919 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3920 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
3921 = eCSR_ENCRYPT_TYPE_NONE;
3922
3923 pWextState->roamProfile.AuthType.numEntries = 1;
3924 pWextState->roamProfile.AuthType.authType[0] =
3925 eCSR_AUTH_TYPE_OPEN_SYSTEM;
3926
Abhishek Singh3c9910e2017-01-06 17:56:47 +05303927 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
3928 QDF_MAC_ADDR_SIZE);
3929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003930#ifdef WLAN_FEATURE_11W
3931 pWextState->roamProfile.MFPEnabled = false;
3932 pWextState->roamProfile.MFPRequired = 0;
3933 pWextState->roamProfile.MFPCapable = 0;
3934#endif
3935
3936 pWextState->authKeyMgmt = 0;
3937
Yingying Tang3cc6b792016-10-20 17:00:37 +08003938 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
3939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940#ifdef FEATURE_WLAN_WAPI
3941 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
3942 pAdapter->wapi_info.nWapiMode = 0;
3943#endif
3944
Anurag Chouhanc5548422016-02-24 18:33:27 +05303945 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003946 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947}
3948
3949/**
3950 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
3951 * @oui: The OUI that is being searched for
3952 * @oui_size: The length of @oui
3953 * @ie: The set of IEs within which we're trying to find @oui
3954 * @ie_len: The length of @ie
3955 *
3956 * This function will scan the IEs contained within @ie looking for @oui.
3957 *
3958 * Return: Pointer to @oui embedded within @ie if it is present, NULL
3959 * if @oui is not present within @ie.
3960 */
3961uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
3962 uint8_t *ie, int ie_len)
3963{
3964 int left = ie_len;
3965 uint8_t *ptr = ie;
3966 uint8_t elem_id, elem_len;
3967 uint8_t eid = 0xDD;
3968
3969 if (NULL == ie || 0 == ie_len)
3970 return NULL;
3971
3972 while (left >= 2) {
3973 elem_id = ptr[0];
3974 elem_len = ptr[1];
3975 left -= 2;
3976 if (elem_len > left) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003977 hdd_err("Invalid IEs eid: %d elem_len: %d left: %d",
3978 eid, elem_len, left);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 return NULL;
3980 }
3981 if (elem_id == eid) {
3982 if (memcmp(&ptr[2], oui, oui_size) == 0)
3983 return ptr;
3984 }
3985
3986 left -= elem_len;
3987 ptr += (elem_len + 2);
3988 }
3989 return NULL;
3990}
3991
3992/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303993 * hdd_get_ldpc() - Get adapter LDPC
3994 * @adapter: adapter being queried
3995 * @value: where to store the value
3996 *
3997 * Return: 0 on success, negative errno on failure
3998 */
3999int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
4000{
4001 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4002 int ret;
4003
4004 ENTER();
4005 ret = sme_get_ht_config(hal, adapter->sessionId,
4006 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
4007 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004008 hdd_err("Failed to get LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304009 } else {
4010 *value = ret;
4011 ret = 0;
4012 }
4013 return ret;
4014}
4015
4016/**
4017 * hdd_set_ldpc() - Set adapter LDPC
4018 * @adapter: adapter being modified
4019 * @value: new LDPC value
4020 *
4021 * Return: 0 on success, negative errno on failure
4022 */
4023int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
4024{
4025 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4026 int ret;
4027
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004028 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304029 if (value) {
4030 /* make sure HT capabilities allow this */
4031 QDF_STATUS status;
4032 uint32_t cfg_value;
4033 union {
4034 uint16_t cfg_value16;
4035 tSirMacHTCapabilityInfo ht_cap_info;
4036 } u;
4037
4038 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4039 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004040 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304041 return -EIO;
4042 }
4043 u.cfg_value16 = cfg_value & 0xFFFF;
4044 if (!u.ht_cap_info.advCodingCap) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004045 hdd_err("LDCP not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304046 return -EINVAL;
4047 }
4048 }
4049
4050 ret = sme_update_ht_config(hal, adapter->sessionId,
4051 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
4052 value);
4053 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004054 hdd_err("Failed to set LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304055
4056 return ret;
4057}
4058
4059/**
4060 * hdd_get_tx_stbc() - Get adapter TX STBC
4061 * @adapter: adapter being queried
4062 * @value: where to store the value
4063 *
4064 * Return: 0 on success, negative errno on failure
4065 */
4066int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
4067{
4068 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4069 int ret;
4070
4071 ENTER();
4072 ret = sme_get_ht_config(hal, adapter->sessionId,
4073 WNI_CFG_HT_CAP_INFO_TX_STBC);
4074 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004075 hdd_err("Failed to get TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304076 } else {
4077 *value = ret;
4078 ret = 0;
4079 }
4080
4081 return ret;
4082}
4083
4084/**
4085 * hdd_set_tx_stbc() - Set adapter TX STBC
4086 * @adapter: adapter being modified
4087 * @value: new TX STBC value
4088 *
4089 * Return: 0 on success, negative errno on failure
4090 */
4091int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
4092{
4093 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4094 int ret;
4095
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004096 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304097 if (value) {
4098 /* make sure HT capabilities allow this */
4099 QDF_STATUS status;
4100 uint32_t cfg_value;
4101 union {
4102 uint16_t cfg_value16;
4103 tSirMacHTCapabilityInfo ht_cap_info;
4104 } u;
4105
4106 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4107 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004108 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304109 return -EIO;
4110 }
4111 u.cfg_value16 = cfg_value & 0xFFFF;
4112 if (!u.ht_cap_info.txSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004113 hdd_err("TX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304114 return -EINVAL;
4115 }
4116 }
4117 ret = sme_update_ht_config(hal, adapter->sessionId,
4118 WNI_CFG_HT_CAP_INFO_TX_STBC,
4119 value);
4120 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004121 hdd_err("Failed to set TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304122
4123 return ret;
4124}
4125
4126/**
4127 * hdd_get_rx_stbc() - Get adapter RX STBC
4128 * @adapter: adapter being queried
4129 * @value: where to store the value
4130 *
4131 * Return: 0 on success, negative errno on failure
4132 */
4133int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
4134{
4135 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4136 int ret;
4137
4138 ENTER();
4139 ret = sme_get_ht_config(hal, adapter->sessionId,
4140 WNI_CFG_HT_CAP_INFO_RX_STBC);
4141 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004142 hdd_err("Failed to get RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304143 } else {
4144 *value = ret;
4145 ret = 0;
4146 }
4147
4148 return ret;
4149}
4150
4151/**
4152 * hdd_set_rx_stbc() - Set adapter RX STBC
4153 * @adapter: adapter being modified
4154 * @value: new RX STBC value
4155 *
4156 * Return: 0 on success, negative errno on failure
4157 */
4158int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
4159{
4160 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4161 int ret;
4162
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004163 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304164 if (value) {
4165 /* make sure HT capabilities allow this */
4166 QDF_STATUS status;
4167 uint32_t cfg_value;
4168 union {
4169 uint16_t cfg_value16;
4170 tSirMacHTCapabilityInfo ht_cap_info;
4171 } u;
4172
4173 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4174 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004175 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304176 return -EIO;
4177 }
4178 u.cfg_value16 = cfg_value & 0xFFFF;
4179 if (!u.ht_cap_info.rxSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004180 hdd_warn("RX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304181 return -EINVAL;
4182 }
4183 }
4184 ret = sme_update_ht_config(hal, adapter->sessionId,
4185 WNI_CFG_HT_CAP_INFO_RX_STBC,
4186 value);
4187 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004188 hdd_err("Failed to set RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304189
4190 return ret;
4191}
4192
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004193int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate)
4194{
4195 int set_value;
4196
4197 if (sme_is_feature_supported_by_fw(DOT11AX))
4198 set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble);
4199 else
4200 set_value = (preamble << 6) | (nss << 4) | rate;
4201
4202 return set_value;
4203}
4204
4205int hdd_set_11ax_rate(hdd_adapter_t *adapter, int set_value,
4206 struct sap_Config *sap_config)
4207{
4208 uint8_t preamble = 0, nss = 0, rix = 0;
4209 int ret;
4210
4211 if (!sap_config) {
4212 if (!sme_is_feature_supported_by_fw(DOT11AX)) {
4213 hdd_err("Target does not support 11ax");
4214 return -EIO;
4215 }
4216 } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax &&
4217 sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) {
4218 hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d",
4219 sap_config->SapHw_mode, sap_config->channel);
4220 return -EIO;
4221 }
4222
4223 if (set_value != 0xff) {
4224 rix = RC_2_RATE_IDX_11AX(set_value);
4225 preamble = WMI_RATE_PREAMBLE_HE;
4226 nss = HT_RC_2_STREAMS_11AX(set_value);
4227
4228 set_value = hdd_assemble_rate_code(preamble, nss, rix);
4229 }
4230
4231 hdd_notice("SET_11AX_RATE val %d rix %d preamble %x nss %d",
4232 set_value, rix, preamble, nss);
4233
4234 ret = wma_cli_set_command(adapter->sessionId,
4235 WMI_VDEV_PARAM_FIXED_RATE,
4236 set_value, VDEV_CMD);
4237
4238 return ret;
4239}
4240
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304241/**
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004242 * hdd_get_aid_rc() - Get AID and rate code passed from user
4243 * @aid: pointer to AID
4244 * @rc: pointer to rate code
4245 * @set_value: value passed from user
4246 *
4247 * If target is 11ax capable, set_value will have AID left shifted 16 bits
4248 * and 16 bits for rate code. If the target is not 11ax capable, rate code
4249 * will only be 8 bits.
4250 *
4251 * Return: None
4252 */
4253static void hdd_get_aid_rc(uint8_t *aid, uint16_t *rc, int set_value)
4254{
4255 uint8_t rc_bits;
4256
4257 if (sme_is_feature_supported_by_fw(DOT11AX))
4258 rc_bits = 16;
4259 else
4260 rc_bits = 8;
4261
4262 *aid = set_value >> rc_bits;
4263 *rc = set_value & ((1 << (rc_bits + 1)) - 1);
4264}
4265
4266int hdd_set_peer_rate(hdd_adapter_t *adapter, int set_value)
4267{
4268 uint8_t aid, *peer_mac;
4269 uint16_t rc;
4270 QDF_STATUS status;
4271
4272 if (adapter->device_mode != QDF_SAP_MODE) {
4273 hdd_err("Invalid devicde mode - %d", adapter->device_mode);
4274 return -EINVAL;
4275 }
4276
4277 hdd_get_aid_rc(&aid, &rc, set_value);
4278
4279 if ((adapter->aStaInfo[aid].isUsed) &&
4280 (OL_TXRX_PEER_STATE_CONN == adapter->aStaInfo[aid].tlSTAState)) {
4281 peer_mac =
4282 (uint8_t *)&(adapter->aStaInfo[aid].macAddrSTA.bytes[0]);
4283 hdd_info("Peer AID: %d MAC_ADDR: "MAC_ADDRESS_STR,
4284 aid, MAC_ADDR_ARRAY(peer_mac));
4285 } else {
4286 hdd_err("No matching peer found for AID: %d", aid);
4287 return -EINVAL;
4288 }
4289
4290 status = sme_set_peer_param(peer_mac, WMI_PEER_PARAM_FIXED_RATE,
4291 rc, adapter->sessionId);
4292 if (status != QDF_STATUS_SUCCESS) {
4293 hdd_err("Failed to set peer fixed rate - status: %d", status);
4294 return -EIO;
4295 }
4296
4297 return 0;
4298}
4299
4300/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
4302 * @dev: device upon which the ioctl was received
4303 * @info: ioctl request information
4304 * @wrqu: ioctl request data
4305 * @extra: ioctl extra data
4306 *
4307 * Return: 0 on success, non-zero on error
4308 */
4309static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
4310 union iwreq_data *wrqu, char *extra)
4311{
4312 hdd_adapter_t *adapter;
4313 hdd_context_t *hdd_ctx;
4314 int ret;
4315
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004316 ENTER_DEV(dev);
4317
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4319 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4320 ret = wlan_hdd_validate_context(hdd_ctx);
4321 if (0 != ret)
4322 return ret;
4323
Jeff Johnson441e1f72017-02-07 08:50:49 -08004324 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4325 if (0 != ret)
4326 return ret;
4327
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328 /* Do nothing for now */
4329 return 0;
4330}
4331
4332/**
4333 * iw_set_commit() - SSR wrapper function for __iw_set_commit
4334 * @dev: pointer to net_device
4335 * @info: pointer to iw_request_info
4336 * @wrqu: pointer to iwreq_data
4337 * @extra: extra
4338 *
4339 * Return: 0 on success, error number otherwise
4340 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004341static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342 union iwreq_data *wrqu, char *extra)
4343{
4344 int ret;
4345
4346 cds_ssr_protect(__func__);
4347 ret = __iw_set_commit(dev, info, wrqu, extra);
4348 cds_ssr_unprotect(__func__);
4349
4350 return ret;
4351}
4352
4353/**
4354 * __iw_get_name() - SIOCGIWNAME ioctl handler
4355 * @dev: device upon which the ioctl was received
4356 * @info: ioctl request information
4357 * @wrqu: ioctl request data
4358 * @extra: ioctl extra data
4359 *
4360 * Return: 0 on success, non-zero on error
4361 */
4362static int __iw_get_name(struct net_device *dev,
4363 struct iw_request_info *info, char *wrqu, char *extra)
4364{
4365 hdd_adapter_t *adapter;
4366 hdd_context_t *hdd_ctx;
4367 int ret;
4368
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004369 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370
4371 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4372 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4373 ret = wlan_hdd_validate_context(hdd_ctx);
4374 if (0 != ret)
4375 return ret;
4376
Jeff Johnson441e1f72017-02-07 08:50:49 -08004377 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4378 if (0 != ret)
4379 return ret;
4380
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
4382 EXIT();
4383 return 0;
4384}
4385
4386/**
4387 * __iw_get_name() - SSR wrapper for __iw_get_name
4388 * @dev: pointer to net_device
4389 * @info: pointer to iw_request_info
4390 * @wrqu: pointer to iwreq_data
4391 * @extra: extra
4392 *
4393 * Return: 0 on success, error number otherwise
4394 */
4395static int iw_get_name(struct net_device *dev,
4396 struct iw_request_info *info,
4397 char *wrqu, char *extra)
4398{
4399 int ret;
4400
4401 cds_ssr_protect(__func__);
4402 ret = __iw_get_name(dev, info, wrqu, extra);
4403 cds_ssr_unprotect(__func__);
4404
4405 return ret;
4406}
4407
4408/**
4409 * __iw_set_mode() - ioctl handler
4410 * @dev: device upon which the ioctl was received
4411 * @info: ioctl request information
4412 * @wrqu: ioctl request data
4413 * @extra: ioctl extra data
4414 *
4415 * Return: 0 on success, non-zero on error
4416 */
4417static int __iw_set_mode(struct net_device *dev,
4418 struct iw_request_info *info,
4419 union iwreq_data *wrqu, char *extra)
4420{
4421 hdd_wext_state_t *pWextState;
4422 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4423 hdd_context_t *hdd_ctx;
4424 tCsrRoamProfile *pRoamProfile;
4425 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 struct hdd_config *pConfig;
4427 struct wireless_dev *wdev;
4428 int ret;
4429
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004430 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431
4432 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4433 ret = wlan_hdd_validate_context(hdd_ctx);
4434 if (0 != ret)
4435 return ret;
4436
Jeff Johnson441e1f72017-02-07 08:50:49 -08004437 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4438 if (0 != ret)
4439 return ret;
4440
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4442 wdev = dev->ieee80211_ptr;
4443 pRoamProfile = &pWextState->roamProfile;
4444 LastBSSType = pRoamProfile->BSSType;
4445
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004446 hdd_debug("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447
4448 switch (wrqu->mode) {
4449 case IW_MODE_ADHOC:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004450 hdd_debug("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
4452 /* Set the phymode correctly for IBSS. */
4453 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
4454 pWextState->roamProfile.phyMode =
4455 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08004456 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457 wdev->iftype = NL80211_IFTYPE_ADHOC;
4458 break;
4459 case IW_MODE_INFRA:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004460 hdd_debug("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
4462 wdev->iftype = NL80211_IFTYPE_STATION;
4463 break;
4464 case IW_MODE_AUTO:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004465 hdd_debug("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
4467 break;
4468 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004469 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 return -EOPNOTSUPP;
4471 }
4472
4473 if (LastBSSType != pRoamProfile->BSSType) {
4474 /* the BSS mode changed. We need to issue disconnect
4475 * if connected or in IBSS disconnect state
4476 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07004477 if (hdd_conn_is_connected
4478 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004479 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304480 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 /* need to issue a disconnect to CSR. */
4482 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304483 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004484 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4485 pAdapter->sessionId,
4486 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304487 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004489
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 rc = wait_for_completion_timeout(&pAdapter->
4491 disconnect_comp_var,
4492 msecs_to_jiffies
4493 (WLAN_WAIT_TIME_DISCONNECT));
4494 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004495 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 }
4497 }
4498 }
4499
4500 EXIT();
4501 return 0;
4502}
4503
4504/**
4505 * iw_set_mode() - SSR wrapper for __iw_set_mode()
4506 * @dev: pointer to net_device
4507 * @info: pointer to iw_request_info
4508 * @wrqu: pointer to iwreq_data
4509 * @extra: pointer to extra ioctl payload
4510 *
4511 * Return: 0 on success, error number otherwise
4512 */
4513static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
4514 union iwreq_data *wrqu, char *extra)
4515{
4516 int ret;
4517
4518 cds_ssr_protect(__func__);
4519 ret = __iw_set_mode(dev, info, wrqu, extra);
4520 cds_ssr_unprotect(__func__);
4521
4522 return ret;
4523}
4524
4525/**
4526 * __iw_get_mode() - SIOCGIWMODE ioctl handler
4527 * @dev: device upon which the ioctl was received
4528 * @info: ioctl request information
4529 * @wrqu: ioctl request data
4530 * @extra: ioctl extra data
4531 *
4532 * Return: 0 on success, non-zero on error
4533 */
4534static int
4535__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4536 union iwreq_data *wrqu, char *extra)
4537{
4538 hdd_wext_state_t *pWextState;
4539 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4540 hdd_context_t *hdd_ctx;
4541 int ret;
4542
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004543 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004544
4545 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4546 ret = wlan_hdd_validate_context(hdd_ctx);
4547 if (0 != ret)
4548 return ret;
4549
Jeff Johnson441e1f72017-02-07 08:50:49 -08004550 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4551 if (0 != ret)
4552 return ret;
4553
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4555
4556 switch (pWextState->roamProfile.BSSType) {
4557 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004558 hdd_debug("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559 wrqu->mode = IW_MODE_INFRA;
4560 break;
4561 case eCSR_BSS_TYPE_IBSS:
4562 case eCSR_BSS_TYPE_START_IBSS:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004563 hdd_debug("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004564 wrqu->mode = IW_MODE_ADHOC;
4565 break;
4566 case eCSR_BSS_TYPE_ANY:
4567 default:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004568 hdd_debug("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 wrqu->mode = IW_MODE_AUTO;
4570 break;
4571 }
4572
4573 EXIT();
4574 return 0;
4575}
4576
4577/**
4578 * iw_get_mode() - SSR wrapper for __iw_get_mode()
4579 * @dev: pointer to net_device
4580 * @info: pointer to iw_request_info
4581 * @wrqu: pointer to iwreq_data
4582 * @extra: pointer to extra ioctl payload
4583 *
4584 * Return: 0 on success, error number otherwise
4585 */
4586static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4587 union iwreq_data *wrqu, char *extra)
4588{
4589 int ret;
4590
4591 cds_ssr_protect(__func__);
4592 ret = __iw_get_mode(dev, info, wrqu, extra);
4593 cds_ssr_unprotect(__func__);
4594
4595 return ret;
4596}
4597
4598/**
4599 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
4600 * @dev: device upon which the ioctl was received
4601 * @info: ioctl request information
4602 * @wrqu: ioctl request data
4603 * @extra: ioctl extra data
4604 *
4605 * Return: 0 on success, non-zero on error
4606 */
4607static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4608 union iwreq_data *wrqu, char *extra)
4609{
4610 uint32_t numChans = 0;
4611 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4612 uint32_t indx = 0;
4613 int ret;
4614 hdd_wext_state_t *pWextState;
4615 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4616 hdd_context_t *hdd_ctx;
4617 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4618 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4619 tCsrRoamProfile *pRoamProfile;
4620
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004621 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622
4623 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4624 ret = wlan_hdd_validate_context(hdd_ctx);
4625 if (0 != ret)
4626 return ret;
4627
Jeff Johnson441e1f72017-02-07 08:50:49 -08004628 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4629 if (0 != ret)
4630 return ret;
4631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4633
4634 pRoamProfile = &pWextState->roamProfile;
4635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 /* Link is up then return cant set channel */
4637 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
4638 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004639 hdd_debug("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 return -EOPNOTSUPP;
4641 }
4642
4643 /* Settings by Frequency as input */
4644 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
4645 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
4646 uint32_t freq = wrqu->freq.m / 100000;
4647
4648 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
4649 && (freq != freq_chan_map[indx].freq))
4650 indx++;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004651 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 wrqu->freq.e = 0;
4655 wrqu->freq.m = freq_chan_map[indx].chan;
4656
4657 }
4658
4659 if (wrqu->freq.e == 0) {
4660 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
4661 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004662 hdd_debug("Channel %d is not in range[%d to %d]",
Jeff Johnson99bac312016-06-28 10:38:18 -07004663 wrqu->freq.m,
4664 WNI_CFG_CURRENT_CHANNEL_STAMIN,
4665 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 return -EINVAL;
4667 }
4668
4669 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4670
4671 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
4672 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304673 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004674 hdd_err("WNI_CFG_VALID_CHANNEL_LIST failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 return -EIO;
4676 }
4677
4678 for (indx = 0; indx < numChans; indx++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004679 if (wrqu->freq.m == validChan[indx])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 }
4682 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004683 return -EINVAL;
4684 }
4685
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004686 if (indx >= numChans)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688
4689 /* Set the Operational Channel */
4690 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
4691 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
4692 pRoamProfile->ChannelInfo.ChannelList =
4693 &pHddStaCtx->conn_info.operationChannel;
4694
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004695 hdd_debug("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696
4697 EXIT();
4698
4699 return ret;
4700}
4701
4702/**
4703 * iw_set_freq() - SSR wrapper for __iw_set_freq()
4704 * @dev: pointer to net_device
4705 * @info: pointer to iw_request_info
4706 * @wrqu: pointer to iwreq_data
4707 * @extra: pointer to extra ioctl payload
4708 *
4709 * Return: 0 on success, error number otherwise
4710 */
4711static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4712 union iwreq_data *wrqu, char *extra)
4713{
4714 int ret;
4715
4716 cds_ssr_protect(__func__);
4717 ret = __iw_set_freq(dev, info, wrqu, extra);
4718 cds_ssr_unprotect(__func__);
4719
4720 return ret;
4721}
4722
4723/**
4724 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
4725 * @dev: device upon which the ioctl was received
4726 * @info: ioctl request information
4727 * @wrqu: ioctl request data
4728 * @extra: ioctl extra data
4729 *
4730 * Return: 0 on success, non-zero on error
4731 */
4732static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4733 struct iw_freq *fwrq, char *extra)
4734{
4735 uint32_t status = false, channel = 0, freq = 0;
4736 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4737 tHalHandle hHal;
4738 hdd_wext_state_t *pWextState;
4739 tCsrRoamProfile *pRoamProfile;
4740 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4741 hdd_context_t *hdd_ctx;
4742 int ret;
4743
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004744 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745
4746 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4747 ret = wlan_hdd_validate_context(hdd_ctx);
4748 if (0 != ret)
4749 return ret;
4750
Jeff Johnson441e1f72017-02-07 08:50:49 -08004751 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4752 if (0 != ret)
4753 return ret;
4754
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4756 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4757
4758 pRoamProfile = &pWextState->roamProfile;
4759
4760 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004761 if (sme_get_operation_channel(hHal, &channel,
4762 pAdapter->sessionId) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004763 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 pAdapter->sessionId);
4765 return -EIO;
Jeff Johnson68755312017-02-10 11:46:55 -08004766 }
Jeff Johnson68755312017-02-10 11:46:55 -08004767 status = hdd_wlan_get_freq(channel, &freq);
4768 if (true == status) {
4769 /* Set Exponent parameter as 6 (MHZ)
4770 * in struct iw_freq iwlist & iwconfig
4771 * command shows frequency into proper
4772 * format (2.412 GHz instead of 246.2
4773 * MHz)
4774 */
4775 fwrq->m = freq;
4776 fwrq->e = MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 }
4778 } else {
4779 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4780 * iwlist & iwconfig command shows frequency into proper
4781 * format (2.412 GHz instead of 246.2 MHz)
4782 */
4783 fwrq->m = 0;
4784 fwrq->e = MHZ;
4785 }
4786 return 0;
4787}
4788
4789/**
4790 * iw_get_freq() - SSR wrapper for __iw_get_freq()
4791 * @dev: pointer to net_device
4792 * @info: pointer to iw_request_info
4793 * @fwrq: pointer to frequency data
4794 * @extra: pointer to extra ioctl payload
4795 *
4796 * Return: 0 on success, error number otherwise
4797 */
4798static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4799 struct iw_freq *fwrq, char *extra)
4800{
4801 int ret;
4802
4803 cds_ssr_protect(__func__);
4804 ret = __iw_get_freq(dev, info, fwrq, extra);
4805 cds_ssr_unprotect(__func__);
4806
4807 return ret;
4808}
4809
4810/**
4811 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
4812 * @dev: device upon which the ioctl was received
4813 * @info: ioctl request information
4814 * @wrqu: ioctl request data
4815 * @extra: ioctl extra data
4816 *
4817 * Return: 0 on success, non-zero on error
4818 */
4819static int __iw_get_tx_power(struct net_device *dev,
4820 struct iw_request_info *info,
4821 union iwreq_data *wrqu, char *extra)
4822{
4823
4824 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4825 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4826 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4827 int ret;
4828
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004829 ENTER_DEV(dev);
4830
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 ret = wlan_hdd_validate_context(hdd_ctx);
4832 if (0 != ret)
4833 return ret;
4834
Jeff Johnson441e1f72017-02-07 08:50:49 -08004835 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4836 if (0 != ret)
4837 return ret;
4838
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4840 wrqu->txpower.value = 0;
4841 return 0;
4842 }
4843 wlan_hdd_get_class_astats(pAdapter);
4844 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
4845
4846 return 0;
4847}
4848
4849/**
4850 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
4851 * @dev: pointer to net_device
4852 * @info: pointer to iw_request_info
4853 * @wrqu: pointer to iwreq_data
4854 * @extra: pointer to extra ioctl payload
4855 *
4856 * Return: 0 on success, error number otherwise
4857 */
4858static int iw_get_tx_power(struct net_device *dev,
4859 struct iw_request_info *info,
4860 union iwreq_data *wrqu, char *extra)
4861{
4862 int ret;
4863
4864 cds_ssr_protect(__func__);
4865 ret = __iw_get_tx_power(dev, info, wrqu, extra);
4866 cds_ssr_unprotect(__func__);
4867
4868 return ret;
4869}
4870
4871/**
4872 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
4873 * @dev: device upon which the ioctl was received
4874 * @info: ioctl request information
4875 * @wrqu: ioctl request data
4876 * @extra: ioctl extra data
4877 *
4878 * Return: 0 on success, non-zero on error
4879 */
4880static int __iw_set_tx_power(struct net_device *dev,
4881 struct iw_request_info *info,
4882 union iwreq_data *wrqu, char *extra)
4883{
4884 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4885 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4886 hdd_context_t *hdd_ctx;
4887 int ret;
4888
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004889 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890
4891 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4892 ret = wlan_hdd_validate_context(hdd_ctx);
4893 if (0 != ret)
4894 return ret;
4895
Jeff Johnson441e1f72017-02-07 08:50:49 -08004896 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4897 if (0 != ret)
4898 return ret;
4899
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304901 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004902 hdd_err("WNI_CFG_CURRENT_TX_POWER_LEVEL failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903 return -EIO;
4904 }
4905
4906 EXIT();
4907
4908 return 0;
4909}
4910
4911/**
4912 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
4913 * @dev: pointer to net_device
4914 * @info: pointer to iw_request_info
4915 * @wrqu: pointer to iwreq_data
4916 * @extra: pointer to extra ioctl payload
4917 *
4918 * Return: 0 on success, error number otherwise
4919 */
4920static int iw_set_tx_power(struct net_device *dev,
4921 struct iw_request_info *info,
4922 union iwreq_data *wrqu, char *extra)
4923{
4924 int ret;
4925
4926 cds_ssr_protect(__func__);
4927 ret = __iw_set_tx_power(dev, info, wrqu, extra);
4928 cds_ssr_unprotect(__func__);
4929
4930 return ret;
4931}
4932
4933/**
4934 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
4935 * @dev: device upon which the ioctl was received
4936 * @info: ioctl request information
4937 * @wrqu: ioctl request data
4938 * @extra: ioctl extra data
4939 *
4940 * Return: 0 on success, non-zero on error
4941 */
4942static int __iw_get_bitrate(struct net_device *dev,
4943 struct iw_request_info *info,
4944 union iwreq_data *wrqu, char *extra)
4945{
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004946 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947 hdd_wext_state_t *pWextState;
4948 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4949 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4950 hdd_context_t *hdd_ctx;
4951 int ret;
4952
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004953 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004954
4955 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4956 ret = wlan_hdd_validate_context(hdd_ctx);
4957 if (0 != ret)
4958 return ret;
4959
Jeff Johnson441e1f72017-02-07 08:50:49 -08004960 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4961 if (0 != ret)
4962 return ret;
4963
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004964 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4965 wrqu->bitrate.value = 0;
4966 } else {
4967 status =
4968 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4969 eCSR_HDD,
4970 SME_SUMMARY_STATS |
4971 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -08004972 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004973 hdd_statistics_cb, 0,
4974 false,
4975 pHddStaCtx->conn_info.staId[0],
4976 pAdapter, pAdapter->sessionId);
4977
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304978 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004979 hdd_err("Unable to retrieve statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004980 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981 }
4982
4983 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4984
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004985 status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304986 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987 WLAN_WAIT_TIME_STATS);
4988
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004989 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004990 hdd_err("SME timeout while retrieving statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004991 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004992 }
4993
4994 wrqu->bitrate.value =
4995 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
4996 }
4997
4998 EXIT();
4999
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005000 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001}
5002
5003/**
5004 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
5005 * @dev: pointer to net_device
5006 * @info: pointer to iw_request_info
5007 * @wrqu: pointer to iwreq_data
5008 * @extra: pointer to extra ioctl payload
5009 *
5010 * Return: 0 on success, error number otherwise
5011 */
5012static int iw_get_bitrate(struct net_device *dev,
5013 struct iw_request_info *info,
5014 union iwreq_data *wrqu, char *extra)
5015{
5016 int ret;
5017
5018 cds_ssr_protect(__func__);
5019 ret = __iw_get_bitrate(dev, info, wrqu, extra);
5020 cds_ssr_unprotect(__func__);
5021
5022 return ret;
5023}
5024
5025/**
5026 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
5027 * @dev: device upon which the ioctl was received
5028 * @info: ioctl request information
5029 * @wrqu: ioctl request data
5030 * @extra: ioctl extra data
5031 *
5032 * Return: 0 on success, non-zero on error
5033 */
5034static int __iw_set_bitrate(struct net_device *dev,
5035 struct iw_request_info *info,
5036 union iwreq_data *wrqu, char *extra)
5037{
5038 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5039 hdd_wext_state_t *pWextState;
5040 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5041 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
5042 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5043 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5044 uint32_t i, rate;
5045 uint32_t valid_rate = false, active_phy_mode = 0;
5046 hdd_context_t *hdd_ctx;
5047 int ret;
5048
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005049 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005050
5051 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5052 ret = wlan_hdd_validate_context(hdd_ctx);
5053 if (0 != ret)
5054 return ret;
5055
Jeff Johnson441e1f72017-02-07 08:50:49 -08005056 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5057 if (0 != ret)
5058 return ret;
5059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5061
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005062 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005063 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005064
5065 rate = wrqu->bitrate.value;
5066
5067 if (rate == -1) {
5068 rate = WNI_CFG_FIXED_RATE_AUTO;
5069 valid_rate = true;
5070 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
5071 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305072 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005073 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5074 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
5075 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
5076 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
5077 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305078 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079 &&
5080 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
5081 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305082 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005083 for (i = 0; i < (b_len + a_len); ++i) {
5084 /* supported rates returned is double
5085 * the actual rate so we divide it by 2
5086 */
5087 if ((supp_rates[i] & 0x7F) / 2 ==
5088 rate) {
5089 valid_rate = true;
5090 rate = i +
5091 WNI_CFG_FIXED_RATE_1MBPS;
5092 break;
5093 }
5094 }
5095 }
5096 }
5097 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005098 if (valid_rate != true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005100
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005101 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305102 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005103 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005104 return -EIO;
5105 }
5106 return 0;
5107}
5108
5109/**
5110 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
5111 * @dev: pointer to net_device
5112 * @info: pointer to iw_request_info
5113 * @wrqu: pointer to iwreq_data
5114 * @extra: pointer to extra ioctl payload
5115 *
5116 * Return: 0 on success, error number otherwise
5117 */
5118static int iw_set_bitrate(struct net_device *dev,
5119 struct iw_request_info *info,
5120 union iwreq_data *wrqu, char *extra)
5121{
5122 int ret;
5123
5124 cds_ssr_protect(__func__);
5125 ret = __iw_set_bitrate(dev, info, wrqu, extra);
5126 cds_ssr_unprotect(__func__);
5127
5128 return ret;
5129}
5130
5131/**
5132 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
5133 * @dev: device upon which the ioctl was received
5134 * @info: ioctl request information
5135 * @wrqu: ioctl request data
5136 * @extra: ioctl extra data
5137 *
5138 * Return: 0 on success, non-zero on error
5139 */
5140static int __iw_set_genie(struct net_device *dev,
5141 struct iw_request_info *info,
5142 union iwreq_data *wrqu, char *extra)
5143{
5144 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5145 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5146 uint8_t *genie = NULL;
5147 uint8_t *base_genie = NULL;
5148 uint16_t remLen;
5149 hdd_context_t *hdd_ctx;
5150 int ret;
5151
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005152 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153
5154 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5155 ret = wlan_hdd_validate_context(hdd_ctx);
5156 if (0 != ret)
5157 return ret;
5158
Jeff Johnson441e1f72017-02-07 08:50:49 -08005159 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5160 if (0 != ret)
5161 return ret;
5162
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005163 if (!wrqu->data.length) {
5164 hdd_clear_roam_profile_ie(pAdapter);
5165 EXIT();
5166 return 0;
5167 }
5168
5169 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
5170 wrqu->data.length);
5171 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005172 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005173 return -ENOMEM;
5174 }
5175
5176 genie = base_genie;
5177
5178 remLen = wrqu->data.length;
5179
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005180 hdd_debug("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005181 genie[1]);
5182
5183 /* clear any previous genIE before this call */
5184 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5185
5186 while (remLen >= 2) {
5187 uint16_t eLen = 0;
5188 uint8_t elementId;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005189
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190 elementId = *genie++;
5191 eLen = *genie++;
5192 remLen -= 2;
5193
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005194 hdd_debug("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195
5196 switch (elementId) {
5197 case IE_EID_VENDOR:
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005198 /* should have at least OUI */
5199 if ((IE_LEN_SIZE + IE_EID_SIZE + IE_VENDOR_OUI_SIZE) > eLen) {
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305200 ret = -EINVAL;
5201 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202 }
5203
5204 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
5205 uint16_t curGenIELen = pWextState->genIE.length;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005206
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005207 hdd_debug("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
Jeff Johnson99bac312016-06-28 10:38:18 -07005208 genie[0], genie[1], genie[2],
5209 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210
5211 if (SIR_MAC_MAX_IE_LENGTH <
5212 (pWextState->genIE.length + eLen)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005213 hdd_err("genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305214 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305215 ret = -ENOMEM;
5216 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005218 /* save to Additional IE; it should be
5219 * accumulated to handle WPS IE + other IE
5220 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005221 memcpy(pWextState->genIE.addIEdata +
5222 curGenIELen, genie - 2, eLen + 2);
5223 pWextState->genIE.length += eLen + 2;
5224 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005225 hdd_debug("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305226 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005227 hdd_err("genIE, Need bigger buffer space");
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305228 ret = -EINVAL;
5229 QDF_ASSERT(0);
5230 goto exit;
5231 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005232 memset(pWextState->WPARSNIE, 0,
5233 MAX_WPA_RSN_IE_LEN);
5234 memcpy(pWextState->WPARSNIE, genie - 2,
5235 (eLen + 2));
5236 pWextState->roamProfile.pWPAReqIE =
5237 pWextState->WPARSNIE;
5238 pWextState->roamProfile.nWPAReqIELength =
5239 eLen + 2;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005240 } else {
5241 /* any vendorId except WPA IE should
5242 * be accumulated to genIE
5243 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244 uint16_t curGenIELen = pWextState->genIE.length;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005245
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005246 hdd_debug("Set OUI(%02x %02x %02x %02x) IE(len %d)",
Jeff Johnson99bac312016-06-28 10:38:18 -07005247 genie[0], genie[1], genie[2],
5248 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249
5250 if (SIR_MAC_MAX_IE_LENGTH <
5251 (pWextState->genIE.length + eLen)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005252 hdd_err("genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305253 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305254 ret = -ENOMEM;
5255 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005256 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005257 /* save to Additional IE; it should be
5258 * accumulated to handle WPS IE + other IE
5259 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260 memcpy(pWextState->genIE.addIEdata +
5261 curGenIELen, genie - 2, eLen + 2);
5262 pWextState->genIE.length += eLen + 2;
5263 }
5264 break;
5265 case DOT11F_EID_RSN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005266 hdd_debug("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305267 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005268 hdd_err("genIE, Need bigger buffer space");
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305269 ret = -EINVAL;
5270 QDF_ASSERT(0);
5271 goto exit;
5272 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005273 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
5274 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
5275 pWextState->roamProfile.pRSNReqIE =
5276 pWextState->WPARSNIE;
5277 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
5278 break;
5279
5280 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005281 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305282 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005283 }
5284 genie += eLen;
5285 remLen -= eLen;
5286 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305287exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005288 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07005289 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305290 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291}
5292
5293/**
5294 * iw_set_genie() - SSR wrapper for __iw_set_genie()
5295 * @dev: pointer to net_device
5296 * @info: pointer to iw_request_info
5297 * @wrqu: pointer to iwreq_data
5298 * @extra: pointer to extra ioctl payload
5299 *
5300 * Return: 0 on success, error number otherwise
5301 */
5302static int iw_set_genie(struct net_device *dev,
5303 struct iw_request_info *info,
5304 union iwreq_data *wrqu, char *extra)
5305{
5306 int ret;
5307
5308 cds_ssr_protect(__func__);
5309 ret = __iw_set_genie(dev, info, wrqu, extra);
5310 cds_ssr_unprotect(__func__);
5311
5312 return ret;
5313}
5314
5315/**
5316 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
5317 * @dev: device upon which the ioctl was received
5318 * @info: ioctl request information
5319 * @wrqu: ioctl request data
5320 * @extra: ioctl extra data
5321 *
5322 * Return: 0 on success, non-zero on error
5323 */
5324static int __iw_get_genie(struct net_device *dev,
5325 struct iw_request_info *info,
5326 union iwreq_data *wrqu, char *extra)
5327{
5328 hdd_wext_state_t *pWextState;
5329 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5330 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305331 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
5333 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
5334 hdd_context_t *hdd_ctx;
5335 int ret;
5336
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005337 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338
5339 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5340 ret = wlan_hdd_validate_context(hdd_ctx);
5341 if (0 != ret)
5342 return ret;
5343
Jeff Johnson441e1f72017-02-07 08:50:49 -08005344 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5345 if (0 != ret)
5346 return ret;
5347
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005348 hdd_debug("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349
5350 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5351
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005352 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354
5355 /* Return something ONLY if we are associated with an RSN or
5356 * WPA network
5357 */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005358 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005359 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360
5361 /* Actually retrieve the RSN IE from CSR. (We previously sent
5362 * it down in the CSR Roam Profile.)
5363 */
5364 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
5365 pAdapter->sessionId,
5366 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305367 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005368 hdd_err("Failed to get WPA-RSN IE data status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005369 return -EFAULT;
5370 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005371 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05305372 if (length > DOT11F_IE_RSN_MAX_LEN) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005373 hdd_err("Invalid buffer length: %d", length);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305374 return -E2BIG;
5375 }
5376 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005377
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005378 hdd_debug("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379 wrqu->data.length);
5380
5381 EXIT();
5382
5383 return 0;
5384}
5385
5386/**
5387 * iw_get_genie() - SSR wrapper for __iw_get_genie()
5388 * @dev: pointer to net_device
5389 * @info: pointer to iw_request_info
5390 * @wrqu: pointer to iwreq_data
5391 * @extra: pointer to extra ioctl payload
5392 *
5393 * Return: 0 on success, error number otherwise
5394 */
5395static int iw_get_genie(struct net_device *dev,
5396 struct iw_request_info *info,
5397 union iwreq_data *wrqu, char *extra)
5398{
5399 int ret;
5400
5401 cds_ssr_protect(__func__);
5402 ret = __iw_get_genie(dev, info, wrqu, extra);
5403 cds_ssr_unprotect(__func__);
5404
5405 return ret;
5406}
5407
5408/**
5409 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
5410 * @dev: device upon which the ioctl was received
5411 * @info: ioctl request information
5412 * @wrqu: ioctl request data
5413 * @extra: ioctl extra data
5414 *
5415 * Return: 0 on success, non-zero on error
5416 */
5417static int __iw_get_encode(struct net_device *dev,
5418 struct iw_request_info *info,
5419 struct iw_point *dwrq, char *extra)
5420{
5421 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5422 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5423 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5424 int keyId;
5425 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
5426 int i;
5427 hdd_context_t *hdd_ctx;
5428 int ret;
5429
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005430 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005431
5432 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5433 ret = wlan_hdd_validate_context(hdd_ctx);
5434 if (0 != ret)
5435 return ret;
5436
Jeff Johnson441e1f72017-02-07 08:50:49 -08005437 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5438 if (0 != ret)
5439 return ret;
5440
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441 keyId = pRoamProfile->Keys.defaultIndex;
5442
5443 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005444 hdd_err("Invalid keyId: %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 return -EINVAL;
5446 }
5447
5448 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
5449 dwrq->flags |= IW_ENCODE_ENABLED;
5450 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305451 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452 pRoamProfile->Keys.KeyLength[keyId]);
5453
5454 dwrq->flags |= (keyId + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455 } else {
5456 dwrq->flags |= IW_ENCODE_DISABLED;
5457 }
5458
5459 for (i = 0; i < MAX_WEP_KEYS; i++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005460 if (pRoamProfile->Keys.KeyLength[i] == 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005461 continue;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005462 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005464 }
5465
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005466 if (MAX_WEP_KEYS == i)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005467 dwrq->flags |= IW_ENCODE_NOKEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468
5469 authType =
5470 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
5471 conn_info.authType;
5472
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005473 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005474 dwrq->flags |= IW_ENCODE_OPEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005475 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005476 dwrq->flags |= IW_ENCODE_RESTRICTED;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005477
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005478 EXIT();
5479 return 0;
5480}
5481
5482/**
5483 * iw_get_encode() - SSR wrapper for __iw_get_encode()
5484 * @dev: pointer to net_device
5485 * @info: pointer to iw_request_info
5486 * @dwrq: pointer to encoding information
5487 * @extra: pointer to extra ioctl payload
5488 *
5489 * Return: 0 on success, error number otherwise
5490 */
5491static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
5492 struct iw_point *dwrq, char *extra)
5493{
5494 int ret;
5495
5496 cds_ssr_protect(__func__);
5497 ret = __iw_get_encode(dev, info, dwrq, extra);
5498 cds_ssr_unprotect(__func__);
5499
5500 return ret;
5501}
5502
5503/**
5504 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
5505 * @dev: device upon which the ioctl was received
5506 * @info: ioctl request information
5507 * @wrqu: ioctl request data
5508 * @extra: ioctl extra data
5509 *
5510 * Return: 0 on success, non-zero on error
5511 */
5512static int __iw_get_rts_threshold(struct net_device *dev,
5513 struct iw_request_info *info,
5514 union iwreq_data *wrqu, char *extra)
5515{
Jeff Johnson5b907622017-02-07 10:00:37 -08005516 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5517 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5518 uint32_t threshold = 0;
5519 hdd_context_t *hdd_ctx;
5520 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005522 ENTER_DEV(dev);
5523
Jeff Johnson5b907622017-02-07 10:00:37 -08005524 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5525 ret = wlan_hdd_validate_context(hdd_ctx);
5526 if (0 != ret)
5527 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005528
Jeff Johnson441e1f72017-02-07 08:50:49 -08005529 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5530 if (0 != ret)
5531 return ret;
5532
Jeff Johnson5b907622017-02-07 10:00:37 -08005533 if (QDF_STATUS_SUCCESS !=
5534 sme_cfg_get_int(hal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
5535 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
5536 return -EIO;
5537 }
5538 wrqu->rts.value = threshold;
5539
5540 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
5541
5542 EXIT();
5543
5544 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005545}
5546
5547/**
5548 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
5549 * @dev: device upon which the ioctl was received
5550 * @info: ioctl request information
5551 * @wrqu: ioctl request data
5552 * @extra: ioctl extra data
5553 *
5554 * Return: 0 on success, non-zero on error
5555 */
5556static int __iw_set_rts_threshold(struct net_device *dev,
5557 struct iw_request_info *info,
5558 union iwreq_data *wrqu, char *extra)
5559{
5560 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5561 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5562 hdd_context_t *hdd_ctx;
5563 int ret;
5564
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005565 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005566
5567 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5568 ret = wlan_hdd_validate_context(hdd_ctx);
5569 if (0 != ret)
5570 return ret;
5571
Jeff Johnson441e1f72017-02-07 08:50:49 -08005572 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5573 if (0 != ret)
5574 return ret;
5575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
5577 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
5578 return -EINVAL;
5579 }
5580
5581 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305582 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005583 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584 return -EIO;
5585 }
5586
5587 EXIT();
5588
5589 return 0;
5590}
5591
5592/**
5593 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
5594 * @dev: pointer to net_device
5595 * @info: pointer to iw_request_info
5596 * @wrqu: pointer to iwreq_data
5597 * @extra: pointer to extra ioctl payload
5598 *
5599 * Return: 0 on success, error number otherwise
5600 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005601int iw_get_rts_threshold(struct net_device *dev,
5602 struct iw_request_info *info,
5603 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604{
5605 int ret;
5606
5607 cds_ssr_protect(__func__);
5608 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
5609 cds_ssr_unprotect(__func__);
5610
5611 return ret;
5612}
5613
5614/**
5615 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
5616 * @dev: pointer to net_device
5617 * @info: pointer to iw_request_info
5618 * @wrqu: pointer to iwreq_data
5619 * @extra: pointer to extra ioctl payload
5620 *
5621 * Return: 0 on success, error number otherwise
5622 */
5623static int iw_set_rts_threshold(struct net_device *dev,
5624 struct iw_request_info *info,
5625 union iwreq_data *wrqu, char *extra)
5626{
5627 int ret;
5628
5629 cds_ssr_protect(__func__);
5630 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
5631 cds_ssr_unprotect(__func__);
5632
5633 return ret;
5634}
5635
5636/**
5637 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
5638 * @dev: device upon which the ioctl was received
5639 * @info: ioctl request information
5640 * @wrqu: ioctl request data
5641 * @extra: ioctl extra data
5642 *
5643 * Return: 0 on success, non-zero on error
5644 */
5645static int __iw_get_frag_threshold(struct net_device *dev,
5646 struct iw_request_info *info,
5647 union iwreq_data *wrqu, char *extra)
5648{
Jeff Johnson5b907622017-02-07 10:00:37 -08005649 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5650 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5651 uint32_t threshold = 0;
5652 hdd_context_t *hdd_ctx;
5653 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005655 ENTER_DEV(dev);
5656
Jeff Johnson5b907622017-02-07 10:00:37 -08005657 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5658 ret = wlan_hdd_validate_context(hdd_ctx);
5659 if (0 != ret)
5660 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661
Jeff Johnson441e1f72017-02-07 08:50:49 -08005662 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5663 if (0 != ret)
5664 return ret;
5665
Jeff Johnson5b907622017-02-07 10:00:37 -08005666 if (sme_cfg_get_int(hal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
5667 != QDF_STATUS_SUCCESS) {
5668 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
5669 return -EIO;
5670 }
5671 wrqu->frag.value = threshold;
5672
5673 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
5674
5675 EXIT();
5676
5677 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678}
5679
5680/**
5681 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
5682 * @dev: pointer to net_device
5683 * @info: pointer to iw_request_info
5684 * @wrqu: pointer to iwreq_data
5685 * @extra: pointer to extra ioctl payload
5686 *
5687 * Return: 0 on success, error number otherwise
5688 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005689int iw_get_frag_threshold(struct net_device *dev,
5690 struct iw_request_info *info,
5691 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692{
5693 int ret;
5694
5695 cds_ssr_protect(__func__);
5696 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
5697 cds_ssr_unprotect(__func__);
5698
5699 return ret;
5700}
5701
5702/**
5703 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
5704 * @dev: device upon which the ioctl was received
5705 * @info: ioctl request information
5706 * @wrqu: ioctl request data
5707 * @extra: ioctl extra data
5708 *
5709 * Return: 0 on success, non-zero on error
5710 */
5711static int __iw_set_frag_threshold(struct net_device *dev,
5712 struct iw_request_info *info,
5713 union iwreq_data *wrqu, char *extra)
5714{
5715 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5716 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5717 hdd_context_t *hdd_ctx;
5718 int ret;
5719
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005720 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721
5722 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5723 ret = wlan_hdd_validate_context(hdd_ctx);
5724 if (0 != ret)
5725 return ret;
5726
Jeff Johnson441e1f72017-02-07 08:50:49 -08005727 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5728 if (0 != ret)
5729 return ret;
5730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
5732 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
5733 return -EINVAL;
5734 }
5735
5736 if (sme_cfg_set_int
5737 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305738 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005739 hdd_err("WNI_CFG_FRAGMENTATION_THRESHOLD failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005740 return -EIO;
5741 }
5742
5743 EXIT();
5744
5745 return 0;
5746}
5747
5748/**
5749 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
5750 * @dev: pointer to net_device
5751 * @info: pointer to iw_request_info
5752 * @wrqu: pointer to iwreq_data
5753 * @extra: pointer to extra ioctl payload
5754 *
5755 * Return: 0 on success, error number otherwise
5756 */
5757static int iw_set_frag_threshold(struct net_device *dev,
5758 struct iw_request_info *info,
5759 union iwreq_data *wrqu, char *extra)
5760{
5761 int ret;
5762
5763 cds_ssr_protect(__func__);
5764 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
5765 cds_ssr_unprotect(__func__);
5766
5767 return ret;
5768}
5769
5770/**
5771 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
5772 * @dev: device upon which the ioctl was received
5773 * @info: ioctl request information
5774 * @wrqu: ioctl request data
5775 * @extra: ioctl extra data
5776 *
5777 * Return: 0 on success, non-zero on error
5778 */
5779static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005780 struct iw_request_info *info,
5781 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782{
5783 hdd_adapter_t *adapter;
5784 hdd_context_t *hdd_ctx;
5785 int ret;
5786
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005787 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788
5789 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5790 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5791 ret = wlan_hdd_validate_context(hdd_ctx);
5792 if (0 != ret)
5793 return ret;
5794
Jeff Johnson441e1f72017-02-07 08:50:49 -08005795 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5796 if (0 != ret)
5797 return ret;
5798
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799 return -EOPNOTSUPP;
5800}
5801
5802/**
5803 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
5804 * @dev: pointer to net_device
5805 * @info: pointer to iw_request_info
5806 * @wrqu: pointer to iwreq_data
5807 * @extra: extra
5808 *
5809 * Return: 0 on success, error number otherwise
5810 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005811static int iw_get_power_mode(struct net_device *dev,
5812 struct iw_request_info *info,
5813 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005814{
5815 int ret;
5816
5817 cds_ssr_protect(__func__);
5818 ret = __iw_get_power_mode(dev, info, wrqu, extra);
5819 cds_ssr_unprotect(__func__);
5820
5821 return ret;
5822}
5823
5824/**
5825 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
5826 * @dev: device upon which the ioctl was received
5827 * @info: ioctl request information
5828 * @wrqu: ioctl request data
5829 * @extra: ioctl extra data
5830 *
5831 * Return: 0 on success, non-zero on error
5832 */
5833static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005834 struct iw_request_info *info,
5835 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005836{
5837 hdd_adapter_t *adapter;
5838 hdd_context_t *hdd_ctx;
5839 int ret;
5840
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005841 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005842
5843 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5844 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5845 ret = wlan_hdd_validate_context(hdd_ctx);
5846 if (0 != ret)
5847 return ret;
5848
Jeff Johnson441e1f72017-02-07 08:50:49 -08005849 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5850 if (0 != ret)
5851 return ret;
5852
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005853 return -EOPNOTSUPP;
5854}
5855
5856/**
5857 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
5858 * @dev: pointer to net_device
5859 * @info: pointer to iw_request_info
5860 * @wrqu: pointer to iwreq_data
5861 * @extra: extra
5862 *
5863 * Return: 0 on success, error number otherwise
5864 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005865static int iw_set_power_mode(struct net_device *dev,
5866 struct iw_request_info *info,
5867 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868{
5869 int ret;
5870
5871 cds_ssr_protect(__func__);
5872 ret = __iw_set_power_mode(dev, info, wrqu, extra);
5873 cds_ssr_unprotect(__func__);
5874
5875 return ret;
5876}
5877
5878/**
5879 * __iw_get_range() - SIOCGIWRANGE ioctl handler
5880 * @dev: device upon which the ioctl was received
5881 * @info: ioctl request information
5882 * @wrqu: ioctl request data
5883 * @extra: ioctl extra data
5884 *
5885 * Return: 0 on success, non-zero on error
5886 */
5887static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
5888 union iwreq_data *wrqu, char *extra)
5889{
5890 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5891 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5892 struct iw_range *range = (struct iw_range *)extra;
5893
5894 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5895
5896 uint32_t num_channels = sizeof(channels);
5897 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
5898 uint32_t a_len;
5899 uint32_t b_len;
5900 uint32_t active_phy_mode = 0;
5901 uint8_t index = 0, i;
5902 hdd_context_t *hdd_ctx;
5903 int ret;
5904
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005905 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906
5907 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5908 ret = wlan_hdd_validate_context(hdd_ctx);
5909 if (0 != ret)
5910 return ret;
5911
Jeff Johnson441e1f72017-02-07 08:50:49 -08005912 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5913 if (0 != ret)
5914 return ret;
5915
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005916 wrqu->data.length = sizeof(struct iw_range);
5917 memset(range, 0, sizeof(struct iw_range));
5918
5919
5920 /*Get the phy mode */
5921 if (sme_cfg_get_int(hHal,
5922 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305923 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005924 hdd_debug("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005925
5926 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5927 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
5928 /*Get the supported rates for 11G band */
5929 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5930 if (sme_cfg_get_str(hHal,
5931 WNI_CFG_SUPPORTED_RATES_11A,
5932 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305933 &a_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005934 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005935 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005937 for (i = 0; i < a_len; i++) {
5938 range->bitrate[i] =
5939 ((supp_rates[i] & 0x7F) / 2) *
5940 1000000;
5941 }
5942 range->num_bitrates = a_len;
5943 } else {
5944 return -EIO;
5945 }
5946 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
5947 /*Get the supported rates for 11B band */
5948 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5949 if (sme_cfg_get_str(hHal,
5950 WNI_CFG_SUPPORTED_RATES_11B,
5951 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305952 &b_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005953 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005954 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005955
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956 for (i = 0; i < b_len; i++) {
5957 range->bitrate[i] =
5958 ((supp_rates[i] & 0x7F) / 2) *
5959 1000000;
5960 }
5961 range->num_bitrates = b_len;
5962 } else {
5963 return -EIO;
5964 }
5965 }
5966 }
5967
5968 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
5969 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
5970 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
5971
5972 range->encoding_size[0] = 5;
5973 range->encoding_size[1] = 13;
5974 range->num_encoding_sizes = 2;
5975 range->max_encoding_tokens = MAX_WEP_KEYS;
5976
5977 /* we support through Wireless Extensions 22 */
5978 range->we_version_compiled = WIRELESS_EXT;
5979 range->we_version_source = 22;
5980
5981 /*Supported Channels and Frequencies */
5982 if (sme_cfg_get_str
5983 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305984 &num_channels) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005985 hdd_err("Failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986 return -EIO;
5987 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005988 if (num_channels > IW_MAX_FREQUENCIES)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005989 num_channels = IW_MAX_FREQUENCIES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990
5991 range->num_channels = num_channels;
5992 range->num_frequency = num_channels;
5993
5994 for (index = 0; index < num_channels; index++) {
5995 uint32_t frq_indx = 0;
5996
5997 range->freq[index].i = channels[index];
5998 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
5999 if (channels[index] == freq_chan_map[frq_indx].chan) {
6000 range->freq[index].m =
6001 freq_chan_map[frq_indx].freq * 100000;
6002 range->freq[index].e = 1;
6003 break;
6004 }
6005 frq_indx++;
6006 }
6007 }
6008
6009 /* Event capability (kernel + driver) */
6010 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
6011 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
6012 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
6013 range->event_capa[1] = IW_EVENT_CAPA_K_1;
6014
6015 /*Encryption capability */
6016 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
6017 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
6018
6019 /* Txpower capability */
6020 range->txpower_capa = IW_TXPOW_MWATT;
6021
6022 /*Scanning capability */
6023#if WIRELESS_EXT >= 22
6024 range->scan_capa =
6025 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
6026#endif
6027
6028 EXIT();
6029 return 0;
6030}
6031
6032/**
6033 * iw_get_range() - SSR wrapper for __iw_get_range()
6034 * @dev: pointer to net_device
6035 * @info: pointer to iw_request_info
6036 * @wrqu: pointer to iwreq_data
6037 * @extra: pointer to extra ioctl payload
6038 *
6039 * Return: 0 on success, error number otherwise
6040 */
6041static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
6042 union iwreq_data *wrqu, char *extra)
6043{
6044 int ret;
6045
6046 cds_ssr_protect(__func__);
6047 ret = __iw_get_range(dev, info, wrqu, extra);
6048 cds_ssr_unprotect(__func__);
6049
6050 return ret;
6051}
6052
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006053struct class_a_stats {
6054 tCsrGlobalClassAStatsInfo class_a_stats;
6055};
6056
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006057/**
6058 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006059 * @stats: pointer to Class A stats
6060 * @context: user context originally registered with SME (always the
6061 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062 *
6063 * Return: None
6064 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006065static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006066{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006067 struct hdd_request *request;
6068 struct class_a_stats *priv;
6069 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006070
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006071 ENTER();
6072 if ((NULL == stats) || (NULL == context)) {
6073 hdd_err("Bad param, stats [%p] context [%p]",
6074 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006075 return;
6076 }
6077
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006078 request = hdd_request_get(context);
6079 if (!request) {
6080 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 return;
6082 }
6083
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006084 returned_stats = stats;
6085 priv = hdd_request_priv(request);
6086 priv->class_a_stats = *returned_stats;
6087 hdd_request_complete(request);
6088 hdd_request_put(request);
6089 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006090}
6091
6092/**
6093 * wlan_hdd_get_class_astats() - Get Class A statistics
6094 * @pAdapter: adapter for which statistics are desired
6095 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306096 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306098QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099{
6100 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306101 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006102 int ret;
6103 void *cookie;
6104 struct hdd_request *request;
6105 struct class_a_stats *priv;
6106 static const struct hdd_request_params params = {
6107 .priv_size = sizeof(*priv),
6108 .timeout_ms = WLAN_WAIT_TIME_STATS,
6109 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110
6111 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006112 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306113 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006114 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08006115 if (cds_is_driver_recovering()) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006116 hdd_debug("Recovery in Progress. State: 0x%x Ignore!!!",
Prashanth Bhatta9e143052015-12-04 11:56:47 -08006117 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306118 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006119 }
6120
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006121 request = hdd_request_alloc(&params);
6122 if (!request) {
6123 hdd_err("Request allocation failure");
6124 return QDF_STATUS_E_NOMEM;
6125 }
6126 cookie = hdd_request_cookie(request);
6127
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006128 /* query only for Class A statistics (which include link speed) */
6129 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
6130 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
6131 hdd_get_class_a_statistics_cb,
6132 0, /* not periodic */
6133 false, /* non-cached results */
6134 pHddStaCtx->conn_info.staId[0],
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006135 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306136 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07006137 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006138 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006139 }
6140
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006141 /* request was sent -- wait for the response */
6142 ret = hdd_request_wait_for_response(request);
6143 if (ret) {
6144 hdd_warn("SME timed out while retrieving Class A statistics");
6145 goto return_cached_results;
6146 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006147
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006148 /* update the adapter with the fresh results */
6149 priv = hdd_request_priv(request);
6150 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6151
6152return_cached_results:
6153 /*
6154 * either we never sent a request, we sent a request and
6155 * received a response or we sent a request and timed out.
6156 * regardless we are done with the request.
6157 */
6158 hdd_request_put(request);
6159
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306160 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006161}
6162
Jeff Johnsondda167c2017-01-23 10:37:57 -08006163struct station_stats {
6164 tCsrSummaryStatsInfo summary_stats;
6165 tCsrGlobalClassAStatsInfo class_a_stats;
6166 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
6167};
6168
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169/**
6170 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08006171 * @stats: pointer to combined station stats
6172 * @context: user context originally registered with SME (always the
6173 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006174 *
6175 * Return: None
6176 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006177static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006178{
Jeff Johnsondda167c2017-01-23 10:37:57 -08006179 struct hdd_request *request;
6180 struct station_stats *priv;
6181 tCsrSummaryStatsInfo *summary_stats;
6182 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306183 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184
Jeff Johnsondda167c2017-01-23 10:37:57 -08006185 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006186 hdd_err("Bad param, pStats [%p] pContext [%p]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08006187 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006188 return;
6189 }
6190
Jeff Johnsondda167c2017-01-23 10:37:57 -08006191 request = hdd_request_get(context);
6192 if (!request) {
6193 hdd_err("Obsolete request");
6194 return;
6195 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006196
Jeff Johnsondda167c2017-01-23 10:37:57 -08006197 summary_stats = (tCsrSummaryStatsInfo *) stats;
6198 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306199 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08006200 (class_a_stats + 1);
6201 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006202
6203 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006204 priv->summary_stats = *summary_stats;
6205 priv->class_a_stats = *class_a_stats;
6206 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006207
Jeff Johnsondda167c2017-01-23 10:37:57 -08006208 hdd_request_complete(request);
6209 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210}
6211
6212/**
6213 * wlan_hdd_get_station_stats() - Get station statistics
6214 * @pAdapter: adapter for which statistics are desired
6215 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306216 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006217 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306218QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006219{
6220 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306221 QDF_STATUS hstatus;
Jeff Johnsondda167c2017-01-23 10:37:57 -08006222 int ret;
6223 void *cookie;
6224 struct hdd_request *request;
6225 struct station_stats *priv;
6226 static const struct hdd_request_params params = {
6227 .priv_size = sizeof(*priv),
6228 .timeout_ms = WLAN_WAIT_TIME_STATS,
6229 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006230
6231 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006232 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306233 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006234 }
6235
Jeff Johnsondda167c2017-01-23 10:37:57 -08006236 request = hdd_request_alloc(&params);
6237 if (!request) {
6238 hdd_err("Request allocation failure");
6239 return QDF_STATUS_E_NOMEM;
6240 }
6241 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006242
6243 /* query only for Summary & Class A statistics */
6244 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
6245 eCSR_HDD,
6246 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306247 SME_GLOBAL_CLASSA_STATS |
6248 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006249 hdd_get_station_statistics_cb,
6250 0, /* not periodic */
6251 false, /* non-cached results */
6252 pHddStaCtx->conn_info.staId[0],
Jeff Johnsondda167c2017-01-23 10:37:57 -08006253 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306254 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006255 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006256 /* we'll return with cached values */
6257 } else {
6258 /* request was sent -- wait for the response */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006259 ret = hdd_request_wait_for_response(request);
6260 if (ret) {
6261 hdd_warn("SME timed out while retrieving statistics");
6262 /* we'll returned a cached value below */
6263 } else {
6264 /* update the adapter with the fresh results */
6265 priv = hdd_request_priv(request);
6266 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
6267 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6268 pAdapter->hdd_stats.per_chain_rssi_stats =
6269 priv->per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006270 }
6271 }
6272
Jeff Johnsondda167c2017-01-23 10:37:57 -08006273 /*
6274 * either we never sent a request, we sent a request and
6275 * received a response or we sent a request and timed out.
6276 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006277 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006278 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006279
6280 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306281 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006282}
6283
6284/**
6285 * iw_get_linkspeed() - Get current link speed ioctl
6286 * @dev: device upon which the ioctl was received
6287 * @info: ioctl request information
6288 * @wrqu: ioctl request data
6289 * @extra: extra ioctl buffer
6290 *
6291 * Return: 0 on success, non-zero on error
6292 */
6293static int __iw_get_linkspeed(struct net_device *dev,
6294 struct iw_request_info *info,
6295 union iwreq_data *wrqu, char *extra)
6296{
6297 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6298 char *pLinkSpeed = (char *)extra;
6299 int len = sizeof(uint32_t) + 1;
6300 uint32_t link_speed = 0;
6301 hdd_context_t *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08006302 int ret;
6303 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006304
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006305 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306306
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006307 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08006308 ret = wlan_hdd_validate_context(hdd_ctx);
6309 if (0 != ret)
6310 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006311
Jeff Johnson441e1f72017-02-07 08:50:49 -08006312 ret = hdd_check_private_wext_control(hdd_ctx, info);
6313 if (0 != ret)
6314 return ret;
6315
6316 ret = wlan_hdd_get_link_speed(pAdapter, &link_speed);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006317 if (0 != ret)
Jeff Johnson441e1f72017-02-07 08:50:49 -08006318 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006319
6320 wrqu->data.length = len;
6321 /* return the linkspeed as a string */
6322 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
6323 if ((rc < 0) || (rc >= len)) {
6324 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07006325 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006326 return -EIO;
6327 }
6328
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306329 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006330 /* a value is being successfully returned */
6331 return 0;
6332}
6333
6334static int iw_get_linkspeed(struct net_device *dev,
6335 struct iw_request_info *info,
6336 union iwreq_data *wrqu, char *extra)
6337{
6338 int ret;
6339
6340 cds_ssr_protect(__func__);
6341 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
6342 cds_ssr_unprotect(__func__);
6343
6344 return ret;
6345}
6346
6347/**
6348 * wlan_hdd_change_country_code_callback() - Change country code callback
6349 * @context: opaque context originally passed to SME. All functions
6350 * which use this callback pass the adapter upon which the country
6351 * code change is active
6352 *
6353 * This function is registered as the callback function when
6354 * sme_change_country_code() is invoked. Callers of
6355 * sme_change_country_code() subsequently wait for the adapter's
6356 * @change_country_code completion variable, so all this function
6357 * needs to do is set that completion variable so that execution can
6358 * continue.
6359 *
6360 * Return: none
6361 */
6362void wlan_hdd_change_country_code_callback(void *context)
6363{
6364
6365 hdd_adapter_t *adapter = context;
6366
6367 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
6368 complete(&adapter->change_country_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006369}
6370
6371/**
6372 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
6373 * @dev: device upon which the ioctl was received
6374 * @info: ioctl request information
6375 * @wrqu: ioctl request data
6376 * @extra: ioctl extra data
6377 *
6378 * Return: 0 on success, non-zero on error
6379 */
6380static int __iw_set_nick(struct net_device *dev,
6381 struct iw_request_info *info,
6382 union iwreq_data *wrqu, char *extra)
6383{
6384 hdd_adapter_t *adapter;
6385 hdd_context_t *hdd_ctx;
6386 int ret;
6387
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006388 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006389
6390 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6391 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6392 ret = wlan_hdd_validate_context(hdd_ctx);
6393 if (0 != ret)
6394 return ret;
6395
Jeff Johnson441e1f72017-02-07 08:50:49 -08006396 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6397 if (0 != ret)
6398 return ret;
6399
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006400 return 0;
6401}
6402
6403/**
6404 * iw_set_nick() - SSR wrapper for __iw_set_nick
6405 * @dev: pointer to net_device
6406 * @info: pointer to iw_request_info
6407 * @wrqu: pointer to iwreq_data
6408 * @extra: extra
6409 *
6410 * Return: 0 on success, error number otherwise
6411 */
6412static int iw_set_nick(struct net_device *dev,
6413 struct iw_request_info *info,
6414 union iwreq_data *wrqu, char *extra)
6415{
6416 int ret;
6417
6418 cds_ssr_protect(__func__);
6419 ret = __iw_set_nick(dev, info, wrqu, extra);
6420 cds_ssr_unprotect(__func__);
6421
6422 return ret;
6423}
6424
6425/**
6426 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
6427 * @dev: device upon which the ioctl was received
6428 * @info: ioctl request information
6429 * @wrqu: ioctl request data
6430 * @extra: ioctl extra data
6431 *
6432 * Return: 0 on success, non-zero on error
6433 */
6434static int __iw_get_nick(struct net_device *dev,
6435 struct iw_request_info *info,
6436 union iwreq_data *wrqu, char *extra)
6437{
6438 hdd_adapter_t *adapter;
6439 hdd_context_t *hdd_ctx;
6440 int ret;
6441
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006442 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006443
6444 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6445 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6446 ret = wlan_hdd_validate_context(hdd_ctx);
6447 if (0 != ret)
6448 return ret;
6449
Jeff Johnson441e1f72017-02-07 08:50:49 -08006450 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6451 if (0 != ret)
6452 return ret;
6453
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006454 return 0;
6455}
6456
6457/**
6458 * iw_get_nick() - SSR wrapper for __iw_get_nick
6459 * @dev: pointer to net_device
6460 * @info: pointer to iw_request_info
6461 * @wrqu: pointer to iwreq_data
6462 * @extra: extra
6463 *
6464 * Return: 0 on success, error number otherwise
6465 */
6466static int iw_get_nick(struct net_device *dev,
6467 struct iw_request_info *info,
6468 union iwreq_data *wrqu, char *extra)
6469{
6470 int ret;
6471
6472 cds_ssr_protect(__func__);
6473 ret = __iw_get_nick(dev, info, wrqu, extra);
6474 cds_ssr_unprotect(__func__);
6475
6476 return ret;
6477}
6478
6479/**
6480 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
6481 * @dev: device upon which the ioctl was received
6482 * @info: ioctl request information
6483 * @wrqu: ioctl request data
6484 * @extra: ioctl extra data
6485 *
6486 * Return: 0 on success, non-zero on error
6487 */
6488static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6489 union iwreq_data *wrqu, char *extra)
6490{
6491 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6492 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6493 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6494 hdd_context_t *hdd_ctx;
6495 struct iw_point *encoderq = &(wrqu->encoding);
6496 uint32_t keyId;
6497 uint8_t key_length;
6498 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6499 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306500 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006501 int ret;
6502
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006503 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006504
6505 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6506 ret = wlan_hdd_validate_context(hdd_ctx);
6507 if (0 != ret)
6508 return ret;
6509
Jeff Johnson441e1f72017-02-07 08:50:49 -08006510 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6511 if (0 != ret)
6512 return ret;
6513
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006514 keyId = encoderq->flags & IW_ENCODE_INDEX;
6515
6516 if (keyId) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006517 if (keyId > MAX_WEP_KEYS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006518 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006519
6520 fKeyPresent = 1;
6521 keyId--;
6522 } else {
6523 fKeyPresent = 0;
6524 }
6525
6526 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006527 hdd_debug("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006528 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006529 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
6530 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006531 }
6532 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6533 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6534 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6535 eCSR_ENCRYPT_TYPE_NONE;
6536 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6537 eCSR_ENCRYPT_TYPE_NONE;
6538
6539 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6540 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6541
6542 if (eConnectionState_Associated ==
6543 pHddStaCtx->conn_info.connState) {
6544 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6545 status =
6546 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
6547 pAdapter->sessionId,
6548 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306549 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006550 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006551
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006552 rc = wait_for_completion_timeout(&pAdapter->
6553 disconnect_comp_var,
6554 msecs_to_jiffies
6555 (WLAN_WAIT_TIME_DISCONNECT));
6556 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006557 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006558 }
6559 }
6560
6561 return status;
6562
6563 }
6564
6565 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006566 hdd_debug("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006567
6568 pHddStaCtx->conn_info.authType =
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006569 (encoderq->flags & IW_ENCODE_RESTRICTED) ?
6570 eCSR_AUTH_TYPE_SHARED_KEY :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006571 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6572
6573 }
6574
6575 if (wrqu->data.length > 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006576 hdd_debug("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006577
6578 key_length = wrqu->data.length;
6579
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006580 /* IW_ENCODING_TOKEN_MAX is the value that is set
6581 * for wrqu->data.length by iwconfig.c
6582 * when 'iwconfig wlan0 key on' is issued.
6583 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006584
6585 if (5 == key_length) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006586 hdd_debug("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006587 key_length);
6588
6589 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6590 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6591 pHddStaCtx->conn_info.authType)) {
6592 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
6593 } else {
6594 encryptionType =
6595 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6596 }
6597 } else if (13 == key_length) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006598 hdd_debug("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006599 key_length);
6600
6601 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6602 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6603 pHddStaCtx->conn_info.authType)) {
6604 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
6605 } else {
6606 encryptionType =
6607 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6608 }
6609 } else {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006610 hdd_err("Invalid WEP key length :%d", key_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006611 return -EINVAL;
6612 }
6613
6614 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6615 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
6616 pWextState->roamProfile.EncryptionType.numEntries = 1;
6617 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6618 encryptionType;
6619 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
6620 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6621 encryptionType;
6622
6623 if ((eConnectionState_NotConnected ==
6624 pHddStaCtx->conn_info.connState)
6625 &&
6626 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6627 pHddStaCtx->conn_info.authType)
6628 || (eCSR_AUTH_TYPE_SHARED_KEY ==
6629 pHddStaCtx->conn_info.authType))) {
6630
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306631 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006632 KeyMaterial[keyId][0], extra, key_length);
6633
6634 pWextState->roamProfile.Keys.KeyLength[keyId] =
6635 (uint8_t) key_length;
6636 pWextState->roamProfile.Keys.defaultIndex =
6637 (uint8_t) keyId;
6638
6639 return status;
6640 }
6641 }
6642
6643 return 0;
6644}
6645
6646/**
6647 * iw_set_encode() - SSR wrapper for __iw_set_encode()
6648 * @dev: pointer to net_device
6649 * @info: pointer to iw_request_info
6650 * @wrqu: pointer to iwreq_data
6651 * @extra: pointer to extra ioctl payload
6652 *
6653 * Return: 0 on success, error number otherwise
6654 */
6655static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6656 union iwreq_data *wrqu, char *extra)
6657{
6658 int ret;
6659
6660 cds_ssr_protect(__func__);
6661 ret = __iw_set_encode(dev, info, wrqu, extra);
6662 cds_ssr_unprotect(__func__);
6663
6664 return ret;
6665}
6666
6667/**
6668 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
6669 * @dev: device upon which the ioctl was received
6670 * @info: ioctl request information
6671 * @wrqu: ioctl request data
6672 * @extra: ioctl extra data
6673 *
6674 * Return: 0 on success, non-zero on error
6675 */
6676static int __iw_get_encodeext(struct net_device *dev,
6677 struct iw_request_info *info,
6678 struct iw_point *dwrq, char *extra)
6679{
6680 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6681 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6682 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
6683 int keyId;
6684 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6685 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
6686 int i, ret;
6687 hdd_context_t *hdd_ctx;
6688
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006689 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006690
6691 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6692 ret = wlan_hdd_validate_context(hdd_ctx);
6693 if (0 != ret)
6694 return ret;
6695
Jeff Johnson441e1f72017-02-07 08:50:49 -08006696 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6697 if (0 != ret)
6698 return ret;
6699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006700 keyId = pRoamProfile->Keys.defaultIndex;
6701
6702 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006703 hdd_err("Invalid keyId: %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006704 return -EINVAL;
6705 }
6706
6707 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
6708 dwrq->flags |= IW_ENCODE_ENABLED;
6709 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306710 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006711 pRoamProfile->Keys.KeyLength[keyId]);
6712 } else {
6713 dwrq->flags |= IW_ENCODE_DISABLED;
6714 }
6715
6716 for (i = 0; i < MAX_WEP_KEYS; i++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006717 if (pRoamProfile->Keys.KeyLength[i] == 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006718 continue;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006719 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006720 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006721 }
6722
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006723 if (MAX_WEP_KEYS == i)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006724 dwrq->flags |= IW_ENCODE_NOKEY;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006725 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006726 dwrq->flags |= IW_ENCODE_ENABLED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006727
6728 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
6729
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006730 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006731 dwrq->flags |= IW_ENCODE_DISABLED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006732
6733 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
6734
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006735 if (IW_AUTH_ALG_OPEN_SYSTEM == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006736 dwrq->flags |= IW_ENCODE_OPEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006737 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006738 dwrq->flags |= IW_ENCODE_RESTRICTED;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006739
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006740 EXIT();
6741 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006742}
6743
6744/**
6745 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
6746 * @dev: pointer to net_device
6747 * @info: pointer to iw_request_info
6748 * @dwrq: pointer to encoding information
6749 * @extra: pointer to extra ioctl payload
6750 *
6751 * Return: 0 on success, error number otherwise
6752 */
6753static int iw_get_encodeext(struct net_device *dev,
6754 struct iw_request_info *info,
6755 struct iw_point *dwrq, char *extra)
6756{
6757 int ret;
6758
6759 cds_ssr_protect(__func__);
6760 ret = __iw_get_encodeext(dev, info, dwrq, extra);
6761 cds_ssr_unprotect(__func__);
6762
6763 return ret;
6764}
6765
6766/**
6767 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
6768 * @dev: device upon which the ioctl was received
6769 * @info: ioctl request information
6770 * @wrqu: ioctl request data
6771 * @extra: ioctl extra data
6772 *
6773 * Return: 0 on success, non-zero on error
6774 */
6775static int __iw_set_encodeext(struct net_device *dev,
6776 struct iw_request_info *info,
6777 union iwreq_data *wrqu, char *extra)
6778{
6779 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6780 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6781 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6782 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306783 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006784 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6785 int ret;
6786 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6787 int key_index;
6788 struct iw_point *encoding = &wrqu->encoding;
6789 tCsrRoamSetKey setKey;
6790 uint32_t roamId = 0xFF;
6791
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006792 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006793
6794 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6795 ret = wlan_hdd_validate_context(hdd_ctx);
6796 if (0 != ret)
6797 return ret;
6798
Jeff Johnson441e1f72017-02-07 08:50:49 -08006799 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6800 if (0 != ret)
6801 return ret;
6802
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006803 key_index = encoding->flags & IW_ENCODE_INDEX;
6804
6805 if (key_index > 0) {
6806
6807 /*Convert from 1-based to 0-based keying */
6808 key_index--;
6809 }
6810 if (!ext->key_len) {
6811
6812 /*Set the encrytion type to NONE */
6813 pRoamProfile->EncryptionType.encryptionType[0] =
6814 eCSR_ENCRYPT_TYPE_NONE;
6815 return ret;
6816 }
6817
6818 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
6819 (IW_ENCODE_ALG_WEP == ext->alg)) {
6820 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
6821
Jeff Johnson99bac312016-06-28 10:38:18 -07006822 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006823 return -EINVAL;
Jeff Johnson68755312017-02-10 11:46:55 -08006824 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006825
Jeff Johnson68755312017-02-10 11:46:55 -08006826 /*Static wep, update the roam profile with the keys */
6827 if (ext->key_len &&
6828 (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
6829 key_index < CSR_MAX_NUM_KEY) {
6830 qdf_mem_copy(&pRoamProfile->Keys.
6831 KeyMaterial[key_index][0],
6832 ext->key, ext->key_len);
6833 pRoamProfile->Keys.KeyLength[key_index] =
6834 (uint8_t) ext->key_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006835
Jeff Johnson68755312017-02-10 11:46:55 -08006836 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
6837 pRoamProfile->Keys.defaultIndex =
6838 (uint8_t) key_index;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006839 }
6840 return ret;
6841 }
6842
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306843 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006844
6845 setKey.keyId = key_index;
6846 setKey.keyLength = ext->key_len;
6847
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006848 if (ext->key_len <= CSR_MAX_KEY_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306849 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006850
6851 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
6852 /*Key direction for group is RX only */
6853 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05306854 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006855 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006856 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306857 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306858 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006859 }
6860
6861 /*For supplicant pae role is zero */
6862 setKey.paeRole = 0;
6863
6864 switch (ext->alg) {
6865 case IW_ENCODE_ALG_NONE:
6866 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6867 break;
6868
6869 case IW_ENCODE_ALG_WEP:
6870 setKey.encType =
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006871 (ext->key_len == 5) ? eCSR_ENCRYPT_TYPE_WEP40 :
6872 eCSR_ENCRYPT_TYPE_WEP104;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006873 break;
6874
6875 case IW_ENCODE_ALG_TKIP:
6876 {
6877 uint8_t *pKey = &setKey.Key[0];
6878
6879 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
6880
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306881 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006882
6883 /* Supplicant sends the 32bytes key in this order
6884 * |--------------|----------|----------|
6885 * | Tk1 | TX MIC | RX MIC |
6886 * |--------------|----------|----------|
6887 * <---16bytes---><--8bytes--><--8bytes-->
6888 *
6889 *
6890 * Sme expects the 32 bytes key to be in the below order
6891 * |--------------|----------|----------|
6892 * | Tk1 | RX MIC | TX MIC |
6893 * |--------------|----------|----------|
6894 * <---16bytes---><--8bytes--><--8bytes-->
6895 */
6896
6897 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306898 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899
6900 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306901 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006902
6903 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306904 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006905
6906 }
6907 break;
6908
6909 case IW_ENCODE_ALG_CCMP:
6910 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
6911 break;
6912
6913#ifdef FEATURE_WLAN_ESE
6914#define IW_ENCODE_ALG_KRK 6
6915 case IW_ENCODE_ALG_KRK:
6916 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
6917 break;
6918#endif /* FEATURE_WLAN_ESE */
6919
6920 default:
6921 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6922 break;
6923 }
6924
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006925 hdd_debug("cipher_alg:%d key_len:%d EncryptionType:%d",
Jeff Johnson99bac312016-06-28 10:38:18 -07006926 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006927
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006928 /* The supplicant may attempt to set the PTK once
6929 * pre-authentication is done. Save the key in the UMAC and
6930 * include it in the ADD BSS request
6931 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306932 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006933 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306934 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006935 hdd_debug("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006936 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306937 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006938 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006939 return -EINVAL;
6940 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006941
6942 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6943
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306944 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006945 pAdapter->sessionId,
6946 &setKey, &roamId);
6947
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306948 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006949 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306950 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006951
6952 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6953 }
6954
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306955 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006956}
6957
6958/**
6959 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
6960 * @dev: pointer to net_device
6961 * @info: pointer to iw_request_info
6962 * @wrqu: pointer to iwreq_data
6963 * @extra: pointer to extra ioctl payload
6964 *
6965 * Return: 0 on success, error number otherwise
6966 */
6967static int iw_set_encodeext(struct net_device *dev,
6968 struct iw_request_info *info,
6969 union iwreq_data *wrqu, char *extra)
6970{
6971 int ret;
6972
6973 cds_ssr_protect(__func__);
6974 ret = __iw_set_encodeext(dev, info, wrqu, extra);
6975 cds_ssr_unprotect(__func__);
6976
6977 return ret;
6978}
6979
6980/**
6981 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
6982 * @dev: device upon which the ioctl was received
6983 * @info: ioctl request information
6984 * @wrqu: ioctl request data
6985 * @extra: ioctl extra data
6986 *
6987 * Return: 0 on success, non-zero on error
6988 */
6989static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
6990 union iwreq_data *wrqu, char *extra)
6991{
6992 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6993 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6994 hdd_context_t *hdd_ctx;
6995 int ret;
6996
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006997 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006998
6999 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7000 ret = wlan_hdd_validate_context(hdd_ctx);
7001 if (0 != ret)
7002 return ret;
7003
Jeff Johnson441e1f72017-02-07 08:50:49 -08007004 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7005 if (0 != ret)
7006 return ret;
7007
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007008 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
7009 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
7010
Jeff Johnson99bac312016-06-28 10:38:18 -07007011 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007012
7013 return -EINVAL;
7014 }
7015
7016 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
7017
7018 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
7019 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
7020 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307021 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007022 hdd_err("WNI_CFG_LONG_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007023 return -EIO;
7024 }
7025 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
7026 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
7027 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307028 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007029 hdd_err("WNI_CFG_SHORT_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007030 return -EIO;
7031 }
7032 }
7033 } else {
7034 return -EOPNOTSUPP;
7035 }
7036
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007037 hdd_debug("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007038
7039 EXIT();
7040
7041 return 0;
7042
7043}
7044
7045/**
7046 * iw_set_retry() - SSR wrapper for __iw_set_retry()
7047 * @dev: pointer to net_device
7048 * @info: pointer to iw_request_info
7049 * @wrqu: pointer to iwreq_data
7050 * @extra: pointer to extra ioctl payload
7051 *
7052 * Return: 0 on success, error number otherwise
7053 */
7054static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
7055 union iwreq_data *wrqu, char *extra)
7056{
7057 int ret;
7058
7059 cds_ssr_protect(__func__);
7060 ret = __iw_set_retry(dev, info, wrqu, extra);
7061 cds_ssr_unprotect(__func__);
7062
7063 return ret;
7064}
7065
7066/**
7067 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
7068 * @dev: device upon which the ioctl was received
7069 * @info: ioctl request information
7070 * @wrqu: ioctl request data
7071 * @extra: ioctl extra data
7072 *
7073 * Return: 0 on success, non-zero on error
7074 */
7075static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7076 union iwreq_data *wrqu, char *extra)
7077{
7078 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7079 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7080 uint32_t retry = 0;
7081 hdd_context_t *hdd_ctx;
7082 int ret;
7083
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007084 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007085
7086 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7087 ret = wlan_hdd_validate_context(hdd_ctx);
7088 if (0 != ret)
7089 return ret;
7090
Jeff Johnson441e1f72017-02-07 08:50:49 -08007091 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7092 if (0 != ret)
7093 return ret;
7094
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007095 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
7096 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
7097
7098 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307099 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007100 hdd_err("WNI_CFG_LONG_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007101 return -EIO;
7102 }
7103
7104 wrqu->retry.value = retry;
7105 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
7106 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
7107
7108 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307109 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007110 hdd_err("WNI_CFG_SHORT_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007111 return -EIO;
7112 }
7113
7114 wrqu->retry.value = retry;
7115 } else {
7116 return -EOPNOTSUPP;
7117 }
7118
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007119 hdd_debug("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007120
7121 EXIT();
7122
7123 return 0;
7124}
7125
7126/**
7127 * iw_get_retry() - SSR wrapper for __iw_get_retry()
7128 * @dev: pointer to net_device
7129 * @info: pointer to iw_request_info
7130 * @wrqu: pointer to iwreq_data
7131 * @extra: pointer to extra ioctl payload
7132 *
7133 * Return: 0 on success, error number otherwise
7134 */
7135static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7136 union iwreq_data *wrqu, char *extra)
7137{
7138 int ret;
7139
7140 cds_ssr_protect(__func__);
7141 ret = __iw_get_retry(dev, info, wrqu, extra);
7142 cds_ssr_unprotect(__func__);
7143
7144 return ret;
7145}
7146
7147/**
7148 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
7149 * @dev: device upon which the ioctl was received
7150 * @info: ioctl request information
7151 * @wrqu: ioctl request data
7152 * @extra: ioctl extra data
7153 *
7154 * Return: 0 on success, non-zero on error
7155 */
7156static int __iw_set_mlme(struct net_device *dev,
7157 struct iw_request_info *info,
7158 union iwreq_data *wrqu, char *extra)
7159{
7160 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7161 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7162 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307163 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007164 hdd_context_t *hdd_ctx;
7165 int ret;
7166
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007167 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007168
7169 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7170 ret = wlan_hdd_validate_context(hdd_ctx);
7171 if (0 != ret)
7172 return ret;
7173
Jeff Johnson441e1f72017-02-07 08:50:49 -08007174 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7175 if (0 != ret)
7176 return ret;
7177
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007178 /* reason_code is unused. By default it is set to
7179 * eCSR_DISCONNECT_REASON_UNSPECIFIED
7180 */
7181 switch (mlme->cmd) {
7182 case IW_MLME_DISASSOC:
7183 case IW_MLME_DEAUTH:
7184
7185 if (pHddStaCtx->conn_info.connState ==
7186 eConnectionState_Associated) {
7187 eCsrRoamDisconnectReason reason =
7188 eCSR_DISCONNECT_REASON_UNSPECIFIED;
7189
7190 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
7191 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
7192
7193 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7194 status =
7195 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
7196 pAdapter->sessionId, reason);
7197
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307198 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007199 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007200
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007201 rc = wait_for_completion_timeout(&pAdapter->
7202 disconnect_comp_var,
7203 msecs_to_jiffies
7204 (WLAN_WAIT_TIME_DISCONNECT));
7205 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007206 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007207 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07007208 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
7209 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007210
7211 /* Resetting authKeyMgmt */
7212 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
7213 0;
7214
Jeff Johnson99bac312016-06-28 10:38:18 -07007215 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007216 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05307217 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007218 WLAN_CONTROL_PATH);
7219
7220 } else {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007221 hdd_warn("%d Command Disassociate/Deauthenticate called but station is not in associated state",
Jeff Johnson99bac312016-06-28 10:38:18 -07007222 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007223 }
7224 break;
7225 default:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007226 hdd_err("Unexpected cmd: %d", (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007227 return -EINVAL;
7228 } /* end of switch */
7229
7230 EXIT();
7231
7232 return status;
7233
7234}
7235
7236/**
7237 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
7238 * @dev: pointer to net_device
7239 * @info: pointer to iw_request_info
7240 * @wrqu: pointer to iwreq_data
7241 * @extra: pointer to extra ioctl payload
7242 *
7243 * Return: 0 on success, error number otherwise
7244 */
7245static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
7246 union iwreq_data *wrqu, char *extra)
7247{
7248 int ret;
7249
7250 cds_ssr_protect(__func__);
7251 ret = __iw_set_mlme(dev, info, wrqu, extra);
7252 cds_ssr_unprotect(__func__);
7253
7254 return ret;
7255}
7256
7257/**
7258 * wlan_hdd_update_phymode() - handle change in PHY mode
7259 * @net: device upon which PHY mode change was received
7260 * @hal: umac handle for the driver
7261 * @new_phymode: new PHY mode for the device
7262 * @phddctx: pointer to the HDD context
7263 *
7264 * This function is called when the device is set to a new PHY mode.
7265 * It takes a holistic look at the desired PHY mode along with the
7266 * configured capabilities of the driver and the reported capabilities
7267 * of the hardware in order to correctly configure all PHY-related
7268 * parameters.
7269 *
7270 * Return: 0 on success, negative errno value on error
7271 */
7272int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
7273 int new_phymode, hdd_context_t *phddctx)
7274{
7275#ifdef QCA_HT_2040_COEX
7276 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307277 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007278#endif
7279 bool band_24 = false, band_5g = false;
7280 bool ch_bond24 = false, ch_bond5g = false;
7281 tSmeConfigParams smeconfig;
7282 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007283 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007284 eCsrPhyMode phymode = -EIO, old_phymode;
Srinivas Girigowda2fb677c2017-03-25 15:35:34 -07007285 enum hdd_dot11_mode hdd_dot11mode = phddctx->config->dot11Mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007286 eCsrBand curr_band = eCSR_BAND_ALL;
7287
7288 old_phymode = sme_get_phy_mode(hal);
7289
7290 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7291 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7292 nChannelBondingMode24GHz))
7293 ch_bond24 = true;
7294
7295 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7296 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7297 nChannelBondingMode5GHz))
7298 ch_bond5g = true;
7299
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007300 if (phddctx->config->nBandCapability == eCSR_BAND_ALL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007301 band_24 = band_5g = true;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007302 else if (phddctx->config->nBandCapability == eCSR_BAND_24)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007303 band_24 = true;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007304 else if (phddctx->config->nBandCapability == eCSR_BAND_5G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007305 band_5g = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007306
7307 vhtchanwidth = phddctx->config->vhtChannelWidth;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007308 hdd_debug("ch_bond24=%d ch_bond5g=%d band_24=%d band_5g=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007309 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
7310
7311 switch (new_phymode) {
7312 case IEEE80211_MODE_AUTO:
7313 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007314 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007315 phymode = eCSR_DOT11_MODE_AUTO;
7316 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7317 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7318 curr_band = eCSR_BAND_ALL;
7319 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7320 } else {
7321 sme_set_phy_mode(hal, old_phymode);
7322 return -EIO;
7323 }
7324 break;
7325 case IEEE80211_MODE_11A:
7326 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007327 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007328 phymode = eCSR_DOT11_MODE_11a;
7329 hdd_dot11mode = eHDD_DOT11_MODE_11a;
7330 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7331 curr_band = eCSR_BAND_5G;
7332 } else {
7333 sme_set_phy_mode(hal, old_phymode);
7334 return -EIO;
7335 }
7336 break;
7337 case IEEE80211_MODE_11B:
7338 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007339 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007340 phymode = eCSR_DOT11_MODE_11b;
7341 hdd_dot11mode = eHDD_DOT11_MODE_11b;
7342 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7343 curr_band = eCSR_BAND_24;
7344 } else {
7345 sme_set_phy_mode(hal, old_phymode);
7346 return -EIO;
7347 }
7348 break;
7349 case IEEE80211_MODE_11G:
7350 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007351 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007352 phymode = eCSR_DOT11_MODE_11g;
7353 hdd_dot11mode = eHDD_DOT11_MODE_11g;
7354 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7355 curr_band = eCSR_BAND_24;
7356 } else {
7357 sme_set_phy_mode(hal, old_phymode);
7358 return -EIO;
7359 }
7360 break;
7361 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
7362 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
7363 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
7364 */
7365 case IEEE80211_MODE_11NA_HT20:
7366 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007367 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007368 phymode = eCSR_DOT11_MODE_11n;
7369 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7370 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7371 curr_band = eCSR_BAND_5G;
7372 } else {
7373 sme_set_phy_mode(hal, old_phymode);
7374 return -EIO;
7375 }
7376 break;
7377 case IEEE80211_MODE_11NA_HT40:
7378 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007379 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007380 phymode = eCSR_DOT11_MODE_11n;
7381 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7382 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7383 curr_band = eCSR_BAND_5G;
7384 } else {
7385 sme_set_phy_mode(hal, old_phymode);
7386 return -EIO;
7387 }
7388 break;
7389 case IEEE80211_MODE_11NG_HT20:
7390 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007391 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007392 phymode = eCSR_DOT11_MODE_11n;
7393 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7394 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7395 curr_band = eCSR_BAND_24;
7396 } else {
7397 sme_set_phy_mode(hal, old_phymode);
7398 return -EIO;
7399 }
7400 break;
7401 case IEEE80211_MODE_11NG_HT40:
7402 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007403 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007404 phymode = eCSR_DOT11_MODE_11n;
7405 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7406 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7407 curr_band = eCSR_BAND_24;
7408 } else {
7409 sme_set_phy_mode(hal, old_phymode);
7410 return -EIO;
7411 }
7412 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007413 case IEEE80211_MODE_11AC_VHT20:
7414 case IEEE80211_MODE_11AC_VHT40:
7415 case IEEE80211_MODE_11AC_VHT80:
7416 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007417 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007418 phymode = eCSR_DOT11_MODE_11ac;
7419 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
7420 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7421 curr_band = eCSR_BAND_5G;
7422 } else {
7423 sme_set_phy_mode(hal, old_phymode);
7424 return -EIO;
7425 }
7426 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007427 case IEEE80211_MODE_2G_AUTO:
7428 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007429 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007430 phymode = eCSR_DOT11_MODE_AUTO;
7431 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7432 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7433 curr_band = eCSR_BAND_24;
7434 } else {
7435 sme_set_phy_mode(hal, old_phymode);
7436 return -EIO;
7437 }
7438 break;
7439 case IEEE80211_MODE_5G_AUTO:
7440 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007441 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007442 phymode = eCSR_DOT11_MODE_AUTO;
7443 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7444 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7445 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7446 curr_band = eCSR_BAND_5G;
7447 } else {
7448 sme_set_phy_mode(hal, old_phymode);
7449 return -EIO;
7450 }
7451 break;
7452 case IEEE80211_MODE_11AGN:
7453 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007454 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007455 phymode = eCSR_DOT11_MODE_11n;
7456 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7457 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7458 curr_band = eCSR_BAND_ALL;
7459 } else {
7460 sme_set_phy_mode(hal, old_phymode);
7461 return -EIO;
7462 }
7463 break;
7464 default:
7465 return -EIO;
7466 }
7467
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007468 switch (new_phymode) {
7469 case IEEE80211_MODE_11AC_VHT20:
7470 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7471 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
7472 break;
7473 case IEEE80211_MODE_11AC_VHT40:
7474 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
7475 break;
7476 case IEEE80211_MODE_11AC_VHT80:
7477 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7478 break;
7479 default:
7480 vhtchanwidth = phddctx->config->vhtChannelWidth;
7481 break;
7482 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007483
7484 if (phymode != -EIO) {
7485 sme_get_config_param(hal, &smeconfig);
7486 smeconfig.csrConfig.phyMode = phymode;
7487#ifdef QCA_HT_2040_COEX
7488 if (phymode == eCSR_DOT11_MODE_11n &&
7489 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
7490 smeconfig.csrConfig.obssEnabled = false;
7491 halStatus = sme_set_ht2040_mode(hal,
7492 pAdapter->sessionId,
7493 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307494 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007495 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007496 return -EIO;
7497 }
7498 } else if (phymode == eCSR_DOT11_MODE_11n &&
7499 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
7500 smeconfig.csrConfig.obssEnabled = true;
7501 halStatus = sme_set_ht2040_mode(hal,
7502 pAdapter->sessionId,
7503 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307504 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007505 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007506 return -EIO;
7507 }
7508 }
7509#endif
7510 smeconfig.csrConfig.eBand = curr_band;
7511 smeconfig.csrConfig.bandCapability = curr_band;
7512 if (curr_band == eCSR_BAND_24)
7513 smeconfig.csrConfig.Is11hSupportEnabled = 0;
7514 else
7515 smeconfig.csrConfig.Is11hSupportEnabled =
7516 phddctx->config->Is11hSupportEnabled;
7517 if (curr_band == eCSR_BAND_24)
7518 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7519 else if (curr_band == eCSR_BAND_24)
7520 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7521 else {
7522 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7523 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7524 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007525 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007526 sme_update_config(hal, &smeconfig);
7527
7528 phddctx->config->dot11Mode = hdd_dot11mode;
7529 phddctx->config->nBandCapability = curr_band;
7530 phddctx->config->nChannelBondingMode24GHz =
7531 smeconfig.csrConfig.channelBondingMode24GHz;
7532 phddctx->config->nChannelBondingMode5GHz =
7533 smeconfig.csrConfig.channelBondingMode5GHz;
7534 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07007535 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007536 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007537 return -EIO;
7538 }
7539 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07007540 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007541 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7542 else
Dustin Browna30892e2016-10-12 17:28:36 -07007543 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007544 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7545
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007546 hdd_debug("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007547 phymode, chwidth, curr_band, vhtchanwidth);
7548 }
7549
7550 return 0;
7551}
7552
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007553struct temperature_priv {
7554 int temperature;
7555};
7556
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007557/**
7558 * hdd_get_temperature_cb() - "Get Temperature" callback function
7559 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007560 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007561 *
7562 * This function is passed to sme_get_temperature() as the callback
7563 * function to be invoked when the temperature measurement is
7564 * available.
7565 *
7566 * Return: None
7567 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007568static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007569{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007570 struct hdd_request *request;
7571 struct temperature_priv *priv;
7572
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007573 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007574
7575 request = hdd_request_get(context);
7576 if (!request) {
7577 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007578 return;
7579 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007580
7581 priv = hdd_request_priv(request);
7582 priv->temperature = temperature;
7583 hdd_request_complete(request);
7584 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007585 EXIT();
7586}
7587
7588/**
7589 * wlan_hdd_get_temperature() - get current device temperature
7590 * @pAdapter: device upon which the request was made
7591 * @temperature: pointer to where the temperature is to be returned
7592 *
7593 * Return: 0 if a temperature value (either current or cached) was
7594 * returned, otherwise a negative errno is returned.
7595 *
7596 */
7597int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
7598{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307599 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007600 int ret;
7601 void *cookie;
7602 struct hdd_request *request;
7603 struct temperature_priv *priv;
7604 static const struct hdd_request_params params = {
7605 .priv_size = sizeof(*priv),
7606 .timeout_ms = WLAN_WAIT_TIME_STATS,
7607 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007608
7609 ENTER();
7610 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007611 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007612 return -EPERM;
7613 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007614
7615 request = hdd_request_alloc(&params);
7616 if (!request) {
7617 hdd_err("Request allocation failure");
7618 return -ENOMEM;
7619 }
7620 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007621 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007622 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307623 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007624 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007625 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007626 ret = hdd_request_wait_for_response(request);
7627 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007628 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007629 } else {
7630 /* update the adapter with the fresh results */
7631 priv = hdd_request_priv(request);
7632 if (priv->temperature)
7633 pAdapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007634 }
7635 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007636
7637 /*
7638 * either we never sent a request, we sent a request and
7639 * received a response or we sent a request and timed out.
7640 * regardless we are done with the request.
7641 */
7642 hdd_request_put(request);
7643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007644 *temperature = pAdapter->temperature;
7645 EXIT();
7646 return 0;
7647}
7648
7649/**
7650 * iw_setint_getnone() - Generic "set integer" private ioctl handler
7651 * @dev: device upon which the ioctl was received
7652 * @info: ioctl request information
7653 * @wrqu: ioctl request data
7654 * @extra: ioctl extra data
7655 *
7656 * Return: 0 on success, non-zero on error
7657 */
7658static int __iw_setint_getnone(struct net_device *dev,
7659 struct iw_request_info *info,
7660 union iwreq_data *wrqu, char *extra)
7661{
7662 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7663 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7664 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007665 hdd_context_t *hdd_ctx;
7666 tSmeConfigParams smeConfig;
7667 int *value = (int *)extra;
7668 int sub_cmd = value[0];
7669 int set_value = value[1];
7670 int ret;
7671 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307672 QDF_STATUS status;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08007673 void *soc = NULL;
7674 struct ol_txrx_stats_req req;
7675 struct cdp_pdev *pdev = NULL;
7676 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007677
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007678 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007680 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7681 ret = wlan_hdd_validate_context(hdd_ctx);
7682 if (0 != ret)
7683 return ret;
7684
Jeff Johnson441e1f72017-02-07 08:50:49 -08007685 ret = hdd_check_private_wext_control(hdd_ctx, info);
7686 if (0 != ret)
7687 return ret;
7688
Jeff Johnson441e1f72017-02-07 08:50:49 -08007689 memset(&smeConfig, 0x00, sizeof(smeConfig));
7690
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007691 switch (sub_cmd) {
7692 case WE_SET_11D_STATE:
7693 {
7694 if ((ENABLE_11D == set_value)
7695 || (DISABLE_11D == set_value)) {
7696
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007697 sme_get_config_param(hHal, &smeConfig);
7698 smeConfig.csrConfig.Is11dSupportEnabled =
7699 (bool) set_value;
7700
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007701 hdd_debug("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007702 smeConfig.csrConfig.
7703 Is11dSupportEnabled);
7704
7705 sme_update_config(hHal, &smeConfig);
7706 } else {
7707 return -EINVAL;
7708 }
7709 break;
7710 }
7711
7712 case WE_WOWL:
7713 {
7714 switch (set_value) {
7715 case 0x00:
7716 hdd_exit_wowl(pAdapter);
7717 break;
7718 case 0x01:
7719 case 0x02:
7720 case 0x03:
7721 enable_mp = (set_value & 0x01) ? 1 : 0;
7722 enable_pbm = (set_value & 0x02) ? 1 : 0;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007723 hdd_debug("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007724 (enable_mp ? "YES" : "NO"),
7725 (enable_pbm ? "YES" : "NO"));
7726 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
7727 break;
7728 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007729 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007730 set_value);
7731 ret = -EINVAL;
7732 break;
7733 }
7734
7735 break;
7736 }
7737 case WE_SET_POWER:
7738 {
7739 switch (set_value) {
7740 case 1:
7741 /* Enable PowerSave */
7742 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7743 SME_PS_ENABLE);
7744 break;
7745 case 2:
7746 /* Disable PowerSave */
7747 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7748 SME_PS_DISABLE);
7749 break;
7750 case 3: /* Enable UASPD */
7751 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
7752 break;
7753 case 4: /* Disable UASPD */
7754 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
7755 break;
7756 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007757 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007758 set_value);
7759 ret = -EINVAL;
7760 break;
7761 }
7762 break;
7763 }
7764
7765 case WE_SET_MAX_ASSOC:
7766 {
7767 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
7768 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
7769 ret = -EINVAL;
7770 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
7771 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307772 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007773 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007774 ret = -EIO;
7775 }
7776 break;
7777 }
7778
7779 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
7780 if (set_value == 0 || set_value == 1)
7781 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
7782 set_value;
7783 else
7784 ret = -EINVAL;
7785 break;
7786
7787 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007788 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
7789 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
7790 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7791 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307792 set_value) == QDF_STATUS_E_FAILURE)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007793 hdd_err("WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007794 ret = -EINVAL;
7795 }
7796 break;
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05307797 case WE_SET_WOW_DATA_INACTIVITY_TO:
7798 if (!hHal)
7799 return -EINVAL;
7800
7801 if ((set_value < CFG_WOW_DATA_INACTIVITY_TIMEOUT_MIN) ||
7802 (set_value > CFG_WOW_DATA_INACTIVITY_TIMEOUT_MAX) ||
7803 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7804 WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT,
7805 set_value) == QDF_STATUS_E_FAILURE)) {
7806 hdd_err("WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT fail");
7807 ret = -EINVAL;
7808 }
7809 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007810 case WE_SET_MC_RATE:
7811 {
7812 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
7813 break;
7814 }
7815 case WE_SET_TX_POWER:
7816 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307817 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007818
Anurag Chouhanc5548422016-02-24 18:33:27 +05307819 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007820 if (sme_set_tx_power
7821 (hHal, pAdapter->sessionId, bssid,
7822 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307823 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007824 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007825 return -EIO;
7826 }
7827 break;
7828 }
7829 case WE_SET_MAX_TX_POWER:
7830 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307831 struct qdf_mac_addr bssid;
7832 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007833
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007834
7835 hdd_debug("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007836 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05307837 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
7838 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007839
7840 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307841 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007842 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007843 return -EIO;
7844 }
7845
7846 break;
7847 }
7848 case WE_SET_MAX_TX_POWER_2_4:
7849 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007850 hdd_debug("Setting maximum tx power %d dBm for 2.4 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07007851 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007852 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307853 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007854 hdd_err("Setting max tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007855 return -EIO;
7856 }
7857
7858 break;
7859 }
7860 case WE_SET_MAX_TX_POWER_5_0:
7861 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007862 hdd_debug("Setting maximum tx power %d dBm for 5.0 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07007863 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007864 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307865 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007866 hdd_err("Setting max tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007867 return -EIO;
7868 }
7869
7870 break;
7871 }
7872 case WE_SET_HIGHER_DTIM_TRANSITION:
7873 {
7874 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007875 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007876 set_value);
7877 ret = -EINVAL;
7878 } else {
7879 if (pAdapter->higherDtimTransition != set_value) {
7880 pAdapter->higherDtimTransition =
7881 set_value;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007882 hdd_debug("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007883 pAdapter->higherDtimTransition);
7884 }
7885 }
7886
7887 break;
7888 }
7889
7890 case WE_SET_TM_LEVEL:
7891 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007892 hdd_debug("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007893 (void)sme_set_thermal_level(hHal, set_value);
7894 break;
7895 }
7896
7897 case WE_SET_PHYMODE:
7898 {
7899 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
7900
7901 ret =
7902 wlan_hdd_update_phymode(dev, hHal, set_value,
7903 phddctx);
7904 break;
7905 }
7906
7907 case WE_SET_NSS:
7908 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007909 hdd_debug("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007910 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007911 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007912 ret = -EINVAL;
7913 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307914 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007915 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
7916 set_value))
7917 ret = -EINVAL;
7918 }
7919 break;
7920 }
7921
7922 case WE_SET_GTX_HT_MCS:
7923 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007924 hdd_debug("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007925 ret = wma_cli_set_command(pAdapter->sessionId,
7926 WMI_VDEV_PARAM_GTX_HT_MCS,
7927 set_value, GTX_CMD);
7928 break;
7929 }
7930
7931 case WE_SET_GTX_VHT_MCS:
7932 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007933 hdd_debug("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007934 set_value);
7935 ret = wma_cli_set_command(pAdapter->sessionId,
7936 WMI_VDEV_PARAM_GTX_VHT_MCS,
7937 set_value, GTX_CMD);
7938 break;
7939 }
7940
7941 case WE_SET_GTX_USRCFG:
7942 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007943 hdd_debug("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007944 set_value);
7945 ret = wma_cli_set_command(pAdapter->sessionId,
7946 WMI_VDEV_PARAM_GTX_USR_CFG,
7947 set_value, GTX_CMD);
7948 break;
7949 }
7950
7951 case WE_SET_GTX_THRE:
7952 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007953 hdd_debug("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007954 ret = wma_cli_set_command(pAdapter->sessionId,
7955 WMI_VDEV_PARAM_GTX_THRE,
7956 set_value, GTX_CMD);
7957 break;
7958 }
7959
7960 case WE_SET_GTX_MARGIN:
7961 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007962 hdd_debug("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963 ret = wma_cli_set_command(pAdapter->sessionId,
7964 WMI_VDEV_PARAM_GTX_MARGIN,
7965 set_value, GTX_CMD);
7966 break;
7967 }
7968
7969 case WE_SET_GTX_STEP:
7970 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007971 hdd_debug("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007972 ret = wma_cli_set_command(pAdapter->sessionId,
7973 WMI_VDEV_PARAM_GTX_STEP,
7974 set_value, GTX_CMD);
7975 break;
7976 }
7977
7978 case WE_SET_GTX_MINTPC:
7979 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007980 hdd_debug("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007981 ret = wma_cli_set_command(pAdapter->sessionId,
7982 WMI_VDEV_PARAM_GTX_MINTPC,
7983 set_value, GTX_CMD);
7984 break;
7985 }
7986
7987 case WE_SET_GTX_BWMASK:
7988 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007989 hdd_debug("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007990 ret = wma_cli_set_command(pAdapter->sessionId,
7991 WMI_VDEV_PARAM_GTX_BW_MASK,
7992 set_value, GTX_CMD);
7993 break;
7994 }
7995
7996 case WE_SET_LDPC:
7997 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307998 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007999 break;
8000 }
8001
8002 case WE_SET_TX_STBC:
8003 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308004 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008005 break;
8006 }
8007
8008 case WE_SET_RX_STBC:
8009 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308010 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008011 break;
8012 }
8013
8014 case WE_SET_SHORT_GI:
8015 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008016 hdd_debug("WMI_VDEV_PARAM_SGI val %d", set_value);
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08008017 /*
8018 * wma_cli_set_command should be called instead of
8019 * sme_update_ht_config since SGI is used for HT/HE.
8020 * This should be refactored.
8021 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008022 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
8023 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
8024 set_value);
8025 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07008026 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008027 break;
8028 }
8029
8030 case WE_SET_RTSCTS:
8031 {
8032 uint32_t value;
8033
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008034 hdd_debug("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008035 set_value);
8036
8037 if ((set_value & HDD_RTSCTS_EN_MASK) ==
8038 HDD_RTSCTS_ENABLE)
8039 value =
8040 (WLAN_HDD_GET_CTX(pAdapter))->config->
8041 RTSThreshold;
8042 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
8043 || ((set_value & HDD_RTSCTS_EN_MASK) ==
8044 HDD_CTS_ENABLE))
8045 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
8046 else
8047 return -EIO;
8048
8049 ret = wma_cli_set_command(pAdapter->sessionId,
8050 WMI_VDEV_PARAM_ENABLE_RTSCTS,
8051 set_value, VDEV_CMD);
8052 if (!ret) {
8053 if (sme_cfg_set_int
8054 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308055 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008056 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008057 return -EIO;
8058 }
8059 }
8060
8061 break;
8062 }
8063
8064 case WE_SET_CHWIDTH:
8065 {
8066 bool chwidth = false;
8067 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008069 /*updating channel bonding only on 5Ghz */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008070 hdd_debug("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008071 set_value);
8072 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008073 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008074 return -EINVAL;
8075 }
8076
8077 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
8078 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
8079 nChannelBondingMode5GHz)))
8080 chwidth = true;
8081
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008082 sme_get_config_param(hHal, &smeConfig);
8083 switch (set_value) {
8084 case eHT_CHANNEL_WIDTH_20MHZ:
8085 smeConfig.csrConfig.channelBondingMode5GHz =
8086 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
8087 break;
8088 case eHT_CHANNEL_WIDTH_40MHZ:
8089 if (chwidth)
8090 smeConfig.csrConfig.
8091 channelBondingMode5GHz =
8092 phddctx->config->
8093 nChannelBondingMode5GHz;
8094 else
8095 return -EINVAL;
8096
8097 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008098 case eHT_CHANNEL_WIDTH_80MHZ:
8099 if (chwidth)
8100 smeConfig.csrConfig.
8101 channelBondingMode5GHz =
8102 phddctx->config->
8103 nChannelBondingMode5GHz;
8104 else
8105 return -EINVAL;
8106
8107 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008108
8109 default:
8110 return -EINVAL;
8111 }
8112
8113 ret = wma_cli_set_command(pAdapter->sessionId,
8114 WMI_VDEV_PARAM_CHWIDTH,
8115 set_value, VDEV_CMD);
8116 if (!ret)
8117 sme_update_config(hHal, &smeConfig);
8118
8119 break;
8120 }
8121
8122 case WE_SET_ANI_EN_DIS:
8123 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008124 hdd_debug("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008125 set_value);
8126 ret = wma_cli_set_command(pAdapter->sessionId,
8127 WMI_PDEV_PARAM_ANI_ENABLE,
8128 set_value, PDEV_CMD);
8129 break;
8130 }
8131
8132 case WE_SET_ANI_POLL_PERIOD:
8133 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008134 hdd_debug("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008135 set_value);
8136 ret = wma_cli_set_command(pAdapter->sessionId,
8137 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
8138 set_value, PDEV_CMD);
8139 break;
8140 }
8141
8142 case WE_SET_ANI_LISTEN_PERIOD:
8143 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008144 hdd_debug("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008145 set_value);
8146 ret = wma_cli_set_command(pAdapter->sessionId,
8147 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
8148 set_value, PDEV_CMD);
8149 break;
8150 }
8151
8152 case WE_SET_ANI_OFDM_LEVEL:
8153 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008154 hdd_debug("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008155 set_value);
8156 ret = wma_cli_set_command(pAdapter->sessionId,
8157 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
8158 set_value, PDEV_CMD);
8159 break;
8160 }
8161
8162 case WE_SET_ANI_CCK_LEVEL:
8163 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008164 hdd_debug("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008165 set_value);
8166 ret = wma_cli_set_command(pAdapter->sessionId,
8167 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
8168 set_value, PDEV_CMD);
8169 break;
8170 }
8171
8172 case WE_SET_DYNAMIC_BW:
8173 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008174 hdd_debug("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008175 set_value);
8176 ret = wma_cli_set_command(pAdapter->sessionId,
8177 WMI_PDEV_PARAM_DYNAMIC_BW,
8178 set_value, PDEV_CMD);
8179 break;
8180 }
8181
8182 case WE_SET_CTS_CBW:
8183 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008184 hdd_debug("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008185 ret = wma_cli_set_command(pAdapter->sessionId,
8186 WMI_PDEV_PARAM_CTS_CBW,
8187 set_value, PDEV_CMD);
8188 break;
8189 }
8190
8191 case WE_SET_11N_RATE:
8192 {
8193 uint8_t preamble = 0, nss = 0, rix = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008194
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008195 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008196 set_value);
8197
8198 if (set_value != 0xff) {
8199 rix = RC_2_RATE_IDX(set_value);
8200 if (set_value & 0x80) {
8201 preamble = WMI_RATE_PREAMBLE_HT;
8202 nss = HT_RC_2_STREAMS(set_value) - 1;
8203 } else {
8204 nss = 0;
8205 rix = RC_2_RATE_IDX(set_value);
8206 if (set_value & 0x10) {
8207 preamble =
8208 WMI_RATE_PREAMBLE_CCK;
8209 if (rix != 0x3)
8210 /* Enable Short
8211 * preamble always for
8212 * CCK except 1mbps
8213 */
8214 rix |= 0x4;
8215 } else {
8216 preamble =
8217 WMI_RATE_PREAMBLE_OFDM;
8218 }
8219 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008220 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008221 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008222 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008223 set_value, rix, preamble, nss);
8224
8225 ret = wma_cli_set_command(pAdapter->sessionId,
8226 WMI_VDEV_PARAM_FIXED_RATE,
8227 set_value, VDEV_CMD);
8228 break;
8229 }
8230
8231 case WE_SET_VHT_RATE:
8232 {
8233 uint8_t preamble = 0, nss = 0, rix = 0;
8234
8235 if (set_value != 0xff) {
8236 rix = RC_2_RATE_IDX_11AC(set_value);
8237 preamble = WMI_RATE_PREAMBLE_VHT;
8238 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
8239
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008240 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008241 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008242 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008243 set_value, rix, preamble, nss);
8244 ret = wma_cli_set_command(pAdapter->sessionId,
8245 WMI_VDEV_PARAM_FIXED_RATE,
8246 set_value, VDEV_CMD);
8247 break;
8248 }
8249
8250 case WE_SET_AMPDU:
8251 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008252 hdd_debug("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008253 ret = wma_cli_set_command(pAdapter->sessionId,
8254 GEN_VDEV_PARAM_AMPDU,
8255 set_value, GEN_CMD);
8256 break;
8257 }
8258
8259 case WE_SET_AMSDU:
8260 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008261 hdd_debug("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008262 ret = wma_cli_set_command(pAdapter->sessionId,
8263 GEN_VDEV_PARAM_AMSDU,
8264 set_value, GEN_CMD);
8265 break;
8266 }
8267
8268 case WE_SET_BURST_ENABLE:
8269 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008270 hdd_debug("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008271 if ((set_value == 0) || (set_value == 1)) {
8272 ret = wma_cli_set_command(pAdapter->sessionId,
8273 WMI_PDEV_PARAM_BURST_ENABLE,
8274 set_value, PDEV_CMD);
8275 } else
8276 ret = -EINVAL;
8277 break;
8278 }
8279 case WE_SET_BURST_DUR:
8280 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008281 hdd_debug("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07008282 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008283 ret = wma_cli_set_command(pAdapter->sessionId,
8284 WMI_PDEV_PARAM_BURST_DUR,
8285 set_value, PDEV_CMD);
8286 else
8287 ret = -EINVAL;
8288 break;
8289 }
8290
8291 case WE_SET_TX_CHAINMASK:
8292 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008293 hdd_debug("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008294 set_value);
8295 ret = wma_cli_set_command(pAdapter->sessionId,
8296 WMI_PDEV_PARAM_TX_CHAIN_MASK,
8297 set_value, PDEV_CMD);
8298 break;
8299 }
8300
8301 case WE_SET_RX_CHAINMASK:
8302 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008303 hdd_debug("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008304 set_value);
8305 ret = wma_cli_set_command(pAdapter->sessionId,
8306 WMI_PDEV_PARAM_RX_CHAIN_MASK,
8307 set_value, PDEV_CMD);
8308 break;
8309 }
8310
8311 case WE_SET_TXPOW_2G:
8312 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008313 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008314 set_value);
8315 ret = wma_cli_set_command(pAdapter->sessionId,
8316 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
8317 set_value, PDEV_CMD);
8318 break;
8319 }
8320
8321 case WE_SET_TXPOW_5G:
8322 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008323 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008324 set_value);
8325 ret = wma_cli_set_command(pAdapter->sessionId,
8326 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
8327 set_value, PDEV_CMD);
8328 break;
8329 }
8330
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008331 /* Firmware debug log */
8332 case WE_DBGLOG_LOG_LEVEL:
8333 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008334 hdd_debug("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008335 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
8336 ret = wma_cli_set_command(pAdapter->sessionId,
8337 WMI_DBGLOG_LOG_LEVEL,
8338 set_value, DBG_CMD);
8339 break;
8340 }
8341
8342 case WE_DBGLOG_VAP_ENABLE:
8343 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008344 hdd_debug("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008345 ret = wma_cli_set_command(pAdapter->sessionId,
8346 WMI_DBGLOG_VAP_ENABLE,
8347 set_value, DBG_CMD);
8348 break;
8349 }
8350
8351 case WE_DBGLOG_VAP_DISABLE:
8352 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008353 hdd_debug("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008354 ret = wma_cli_set_command(pAdapter->sessionId,
8355 WMI_DBGLOG_VAP_DISABLE,
8356 set_value, DBG_CMD);
8357 break;
8358 }
8359
8360 case WE_DBGLOG_MODULE_ENABLE:
8361 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008362 hdd_debug("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008363 set_value);
8364 hdd_ctx->fw_log_settings.enable = set_value;
8365 ret = wma_cli_set_command(pAdapter->sessionId,
8366 WMI_DBGLOG_MODULE_ENABLE,
8367 set_value, DBG_CMD);
8368 break;
8369 }
8370
8371 case WE_DBGLOG_MODULE_DISABLE:
8372 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008373 hdd_debug("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008374 set_value);
8375 hdd_ctx->fw_log_settings.enable = set_value;
8376 ret = wma_cli_set_command(pAdapter->sessionId,
8377 WMI_DBGLOG_MODULE_DISABLE,
8378 set_value, DBG_CMD);
8379 break;
8380 }
8381 case WE_DBGLOG_MOD_LOG_LEVEL:
8382 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008383 hdd_debug("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008384 set_value);
8385
8386 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
8387 hdd_ctx->fw_log_settings.index = 0;
8388
8389 hdd_ctx->fw_log_settings.
8390 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
8391 set_value;
8392 hdd_ctx->fw_log_settings.index++;
8393
8394 ret = wma_cli_set_command(pAdapter->sessionId,
8395 WMI_DBGLOG_MOD_LOG_LEVEL,
8396 set_value, DBG_CMD);
8397 break;
8398 }
8399
8400 case WE_DBGLOG_TYPE:
8401 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008402 hdd_debug("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008403 hdd_ctx->fw_log_settings.dl_type = set_value;
8404 ret = wma_cli_set_command(pAdapter->sessionId,
8405 WMI_DBGLOG_TYPE,
8406 set_value, DBG_CMD);
8407 break;
8408 }
8409 case WE_DBGLOG_REPORT_ENABLE:
8410 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008411 hdd_debug("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008412 set_value);
8413 hdd_ctx->fw_log_settings.dl_report = set_value;
8414 ret = wma_cli_set_command(pAdapter->sessionId,
8415 WMI_DBGLOG_REPORT_ENABLE,
8416 set_value, DBG_CMD);
8417 break;
8418 }
8419
8420 case WE_SET_TXRX_FWSTATS:
8421 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008422 hdd_debug("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008423 ret = wma_cli_set_command(pAdapter->sessionId,
8424 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
8425 set_value, VDEV_CMD);
8426 break;
8427 }
8428
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008429 case WE_SET_TXRX_STATS:
8430 {
8431 hdd_notice("WE_SET_TXRX_STATS val %d", set_value);
8432 ret = cds_get_datapath_handles(&soc, &pdev, &vdev,
8433 pAdapter->sessionId);
8434
8435 if (ret != 0)
8436 break;
8437
8438 qdf_mem_zero(&req, sizeof(req));
8439 ret = cdp_txrx_stats(soc, vdev, &req, set_value);
8440 break;
8441 }
8442
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008443 case WE_TXRX_FWSTATS_RESET:
8444 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008445 hdd_debug("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446 ret = wma_cli_set_command(pAdapter->sessionId,
8447 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
8448 set_value, VDEV_CMD);
8449 break;
8450 }
8451
8452 case WE_DUMP_STATS:
8453 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008454 hdd_debug("WE_DUMP_STATS val %d", set_value);
Mohit Khanna3e2115b2016-10-11 13:18:29 -07008455 ret = hdd_wlan_dump_stats(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008456 break;
8457 }
8458
8459 case WE_CLEAR_STATS:
8460 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008461 hdd_debug("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008462 switch (set_value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008463 case CDP_HDD_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008464 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
8465 memset(&pAdapter->hdd_stats, 0,
8466 sizeof(pAdapter->hdd_stats));
8467 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008468 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008469 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
8470 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008471 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008472 wlan_hdd_clear_netif_queue_history(hdd_ctx);
8473 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008474 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05308475 hdd_clear_hif_stats();
8476 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008477 default:
Leo Changfdb45c32016-10-28 11:09:23 -07008478 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
8479 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008480 }
8481 break;
8482 }
8483
8484 case WE_PPS_PAID_MATCH:
8485 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008486 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008487 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008488
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008489 hdd_debug("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008490 set_value);
8491 ret = wma_cli_set_command(pAdapter->sessionId,
8492 WMI_VDEV_PPS_PAID_MATCH,
8493 set_value, PPS_CMD);
8494 break;
8495 }
8496
8497 case WE_PPS_GID_MATCH:
8498 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008499 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008500 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008501 hdd_debug("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008502 set_value);
8503 ret = wma_cli_set_command(pAdapter->sessionId,
8504 WMI_VDEV_PPS_GID_MATCH,
8505 set_value, PPS_CMD);
8506 break;
8507 }
8508
8509 case WE_PPS_EARLY_TIM_CLEAR:
8510 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008511 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008512 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008513 hdd_debug(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008514 set_value);
8515 ret = wma_cli_set_command(pAdapter->sessionId,
8516 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
8517 set_value, PPS_CMD);
8518 break;
8519 }
8520
8521 case WE_PPS_EARLY_DTIM_CLEAR:
8522 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008523 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008524 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008525 hdd_debug("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008526 set_value);
8527 ret = wma_cli_set_command(pAdapter->sessionId,
8528 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
8529 set_value, PPS_CMD);
8530 break;
8531 }
8532
8533 case WE_PPS_EOF_PAD_DELIM:
8534 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008535 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008536 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008537 hdd_debug("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008538 set_value);
8539 ret = wma_cli_set_command(pAdapter->sessionId,
8540 WMI_VDEV_PPS_EOF_PAD_DELIM,
8541 set_value, PPS_CMD);
8542 break;
8543 }
8544
8545 case WE_PPS_MACADDR_MISMATCH:
8546 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008547 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008548 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008549 hdd_debug("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008550 set_value);
8551 ret = wma_cli_set_command(pAdapter->sessionId,
8552 WMI_VDEV_PPS_MACADDR_MISMATCH,
8553 set_value, PPS_CMD);
8554 break;
8555 }
8556
8557 case WE_PPS_DELIM_CRC_FAIL:
8558 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008559 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008560 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008561 hdd_debug("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008562 set_value);
8563 ret = wma_cli_set_command(pAdapter->sessionId,
8564 WMI_VDEV_PPS_DELIM_CRC_FAIL,
8565 set_value, PPS_CMD);
8566 break;
8567 }
8568
8569 case WE_PPS_GID_NSTS_ZERO:
8570 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008571 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008572 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008573 hdd_debug("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008574 set_value);
8575 ret = wma_cli_set_command(pAdapter->sessionId,
8576 WMI_VDEV_PPS_GID_NSTS_ZERO,
8577 set_value, PPS_CMD);
8578 break;
8579 }
8580
8581 case WE_PPS_RSSI_CHECK:
8582 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008583 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008584 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008585 hdd_debug("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008586 set_value);
8587 ret = wma_cli_set_command(pAdapter->sessionId,
8588 WMI_VDEV_PPS_RSSI_CHECK,
8589 set_value, PPS_CMD);
8590 break;
8591 }
8592
8593 case WE_PPS_5G_EBT:
8594 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008595 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008596 return -EINVAL;
8597
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008598 hdd_debug("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008599 ret = wma_cli_set_command(pAdapter->sessionId,
8600 WMI_VDEV_PPS_5G_EBT,
8601 set_value, PPS_CMD);
8602 break;
8603 }
8604
8605 case WE_SET_HTSMPS:
8606 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008607 hdd_debug("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008608 ret = wma_cli_set_command(pAdapter->sessionId,
8609 WMI_STA_SMPS_FORCE_MODE_CMDID,
8610 set_value, VDEV_CMD);
8611 break;
8612 }
8613
8614 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
8615 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008616 hdd_debug("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008617 set_value);
8618 ret = wma_cli_set_command(pAdapter->sessionId,
8619 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
8620 set_value, QPOWER_CMD);
8621 break;
8622 }
8623
8624 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
8625 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008626 hdd_debug("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008627 set_value);
8628 ret = wma_cli_set_command(
8629 pAdapter->sessionId,
8630 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
8631 set_value, QPOWER_CMD);
8632 break;
8633 }
8634
8635 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
8636 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008637 hdd_debug("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008638 set_value);
8639 ret = wma_cli_set_command(
8640 pAdapter->sessionId,
8641 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
8642 set_value, QPOWER_CMD);
8643 break;
8644 }
8645
8646 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
8647 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008648 hdd_debug("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008649 set_value);
8650 ret = wma_cli_set_command(
8651 pAdapter->sessionId,
8652 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
8653 set_value, QPOWER_CMD);
8654 break;
8655 }
8656
8657 case WE_MCC_CONFIG_LATENCY:
8658 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008659 wlan_hdd_set_mcc_latency(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008660 break;
8661 }
8662
8663 case WE_MCC_CONFIG_QUOTA:
8664 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008665 hdd_debug("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008666 set_value);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008667 ret = wlan_hdd_set_mcc_p2p_quota(pAdapter,
8668 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008669 break;
8670 }
8671 case WE_SET_DEBUG_LOG:
8672 {
8673 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05308674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008675 hdd_ctx->config->gEnableDebugLog = set_value;
8676 sme_update_connect_debug(hdd_ctx->hHal, set_value);
8677 break;
8678 }
8679 case WE_SET_EARLY_RX_ADJUST_ENABLE:
8680 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008681 hdd_debug("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008682 if ((set_value == 0) || (set_value == 1))
8683 ret = wma_cli_set_command(
8684 pAdapter->sessionId,
8685 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
8686 set_value, VDEV_CMD);
8687 else
8688 ret = -EINVAL;
8689 break;
8690 }
8691 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
8692 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008693 hdd_debug("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008694 ret = wma_cli_set_command(pAdapter->sessionId,
8695 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
8696 set_value, VDEV_CMD);
8697 break;
8698 }
8699 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
8700 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008701 hdd_debug("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008702 set_value);
8703 ret = wma_cli_set_command(
8704 pAdapter->sessionId,
8705 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
8706 set_value, VDEV_CMD);
8707 break;
8708 }
8709 case WE_SET_EARLY_RX_SLOP_STEP:
8710 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008711 hdd_debug("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008712 set_value);
8713 ret = wma_cli_set_command(pAdapter->sessionId,
8714 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
8715 set_value, VDEV_CMD);
8716 break;
8717 }
8718 case WE_SET_EARLY_RX_INIT_SLOP:
8719 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008720 hdd_debug("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008721 set_value);
8722 ret = wma_cli_set_command(pAdapter->sessionId,
8723 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
8724 set_value, VDEV_CMD);
8725 break;
8726 }
8727 case WE_SET_EARLY_RX_ADJUST_PAUSE:
8728 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008729 hdd_debug("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008730 if ((set_value == 0) || (set_value == 1))
8731 ret = wma_cli_set_command(
8732 pAdapter->sessionId,
8733 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
8734 set_value, VDEV_CMD);
8735 else
8736 ret = -EINVAL;
8737 break;
8738 }
8739 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
8740 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008741 hdd_debug("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008742 ret = wma_cli_set_command(pAdapter->sessionId,
8743 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
8744 set_value, VDEV_CMD);
8745 break;
8746 }
8747 case WE_SET_SCAN_DISABLE:
8748 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008749 hdd_debug("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008750 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
8751 break;
8752 }
Govind Singha471e5e2015-10-12 17:11:14 +05308753 case WE_START_FW_PROFILE:
8754 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008755 hdd_debug("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05308756 ret = wma_cli_set_command(pAdapter->sessionId,
8757 WMI_WLAN_PROFILE_TRIGGER_CMDID,
8758 set_value, DBG_CMD);
8759 break;
8760 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308761 case WE_SET_CHANNEL:
8762 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008763 hdd_debug("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308764 pAdapter->sessionId, pAdapter->device_mode);
8765
Krunal Sonif07bb382016-03-10 13:02:11 -08008766 if ((QDF_STA_MODE == pAdapter->device_mode) ||
8767 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308768
8769 status = sme_ext_change_channel(hHal,
8770 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308771 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008772 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308773 status);
8774 ret = -EINVAL;
8775 }
8776 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008777 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308778 pAdapter->device_mode);
8779 ret = -EINVAL;
8780 }
8781 break;
8782 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308783 case WE_SET_CONC_SYSTEM_PREF:
8784 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008785 hdd_debug("New preference: %d", set_value);
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308786 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
8787 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
8788 hdd_err("Invalid system preference %d", set_value);
8789 return -EINVAL;
8790 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308791
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308792 /* hdd_ctx, hdd_ctx->config are already checked for null */
8793 hdd_ctx->config->conc_system_pref = set_value;
8794 break;
8795 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008796 case WE_SET_11AX_RATE:
8797 ret = hdd_set_11ax_rate(pAdapter, set_value, NULL);
8798 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07008799 case WE_SET_DCM:
8800 hdd_notice("Set WMI_VDEV_PARAM_HE_DCM: %d", set_value);
8801 ret = wma_cli_set_command(pAdapter->sessionId,
8802 WMI_VDEV_PARAM_HE_DCM, set_value,
8803 VDEV_CMD);
8804 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07008805 case WE_SET_RANGE_EXT:
8806 hdd_notice("Set WMI_VDEV_PARAM_HE_RANGE_EXT: %d", set_value);
8807 ret = wma_cli_set_command(pAdapter->sessionId,
8808 WMI_VDEV_PARAM_HE_RANGE_EXT,
8809 set_value, VDEV_CMD);
8810 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008811 default:
8812 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008813 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008814 sub_cmd);
8815 ret = -EINVAL;
8816 break;
8817 }
8818 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308819 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008820 return ret;
8821}
8822
8823static int iw_setint_getnone(struct net_device *dev,
8824 struct iw_request_info *info,
8825 union iwreq_data *wrqu,
8826 char *extra)
8827{
8828 int ret;
8829
8830 cds_ssr_protect(__func__);
8831 ret = __iw_setint_getnone(dev, info, wrqu, extra);
8832 cds_ssr_unprotect(__func__);
8833
8834 return ret;
8835}
8836
8837/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008838 * __iw_setnone_get_threeint() - return three value to up layer.
8839 *
8840 * @dev: pointer of net_device of this wireless card
8841 * @info: meta data about Request sent
8842 * @wrqu: include request info
8843 * @extra: buf used for in/Output
8844 *
8845 * Return: execute result
8846 */
8847static int __iw_setnone_get_threeint(struct net_device *dev,
8848 struct iw_request_info *info,
8849 union iwreq_data *wrqu, char *extra)
8850{
8851 int ret = 0; /* success */
8852 uint32_t *value = (int *)extra;
8853 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8854 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8855
8856 ENTER_DEV(dev);
8857 ret = wlan_hdd_validate_context(hdd_ctx);
8858 if (0 != ret)
8859 return ret;
8860
Jeff Johnson441e1f72017-02-07 08:50:49 -08008861 ret = hdd_check_private_wext_control(hdd_ctx, info);
8862 if (0 != ret)
8863 return ret;
8864
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008865 hdd_debug("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008866 switch (value[0]) {
8867 case WE_GET_TSF:
8868 ret = hdd_indicate_tsf(adapter, value, 3);
8869 break;
8870 default:
8871 hdd_err("Invalid IOCTL get_value command %d", value[0]);
8872 break;
8873 }
8874 return ret;
8875}
8876
8877/**
8878 * iw_setnone_get_threeint() - return three value to up layer.
8879 *
8880 * @dev: pointer of net_device of this wireless card
8881 * @info: meta data about Request sent
8882 * @wrqu: include request info
8883 * @extra: buf used for in/Output
8884 *
8885 * Return: execute result
8886 */
8887static int iw_setnone_get_threeint(struct net_device *dev,
8888 struct iw_request_info *info,
8889 union iwreq_data *wrqu, char *extra)
8890{
8891 int ret;
8892
8893 cds_ssr_protect(__func__);
8894 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8895 cds_ssr_unprotect(__func__);
8896
8897 return ret;
8898}
8899
8900/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008901 * iw_setchar_getnone() - Generic "set string" private ioctl handler
8902 * @dev: device upon which the ioctl was received
8903 * @info: ioctl request information
8904 * @wrqu: ioctl request data
8905 * @extra: ioctl extra data
8906 *
8907 * Return: 0 on success, non-zero on error
8908 */
8909static int __iw_setchar_getnone(struct net_device *dev,
8910 struct iw_request_info *info,
8911 union iwreq_data *wrqu, char *extra)
8912{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308913 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008914 int sub_cmd;
8915 int ret;
8916 char *pBuffer = NULL;
8917 hdd_adapter_t *pAdapter = (netdev_priv(dev));
8918 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008919 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008920 struct iw_point s_priv_data;
8921
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008922 ENTER_DEV(dev);
8923
Mukul Sharma34777c62015-11-02 20:22:30 +05308924 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008925 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05308926 return -EPERM;
8927 }
8928
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008929 ret = wlan_hdd_validate_context(hdd_ctx);
8930 if (0 != ret)
8931 return ret;
8932
Jeff Johnson441e1f72017-02-07 08:50:49 -08008933 ret = hdd_check_private_wext_control(hdd_ctx, info);
8934 if (0 != ret)
8935 return ret;
8936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008937 /* helper function to get iwreq_data with compat handling. */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008938 if (hdd_priv_get_data(&s_priv_data, wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008939 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008940
8941 /* make sure all params are correctly passed to function */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008942 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008943 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008944
8945 sub_cmd = s_priv_data.flags;
8946
8947 /* ODD number is used for set, copy data using copy_from_user */
8948 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8949 s_priv_data.length);
8950 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008951 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008952 return -ENOMEM;
8953 }
8954
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008955 hdd_debug("Received length: %d data: %s",
8956 s_priv_data.length, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008957
8958 switch (sub_cmd) {
8959 case WE_WOWL_ADD_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008960 hdd_debug("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008961 hdd_add_wowl_ptrn(pAdapter, pBuffer);
8962 break;
8963 case WE_WOWL_DEL_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008964 hdd_debug("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008965 hdd_del_wowl_ptrn(pAdapter, pBuffer);
8966 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008967 case WE_NEIGHBOR_REPORT_REQUEST:
8968 {
8969 tRrmNeighborReq neighborReq;
8970 tRrmNeighborRspCallbackInfo callbackInfo;
8971
8972 if (pConfig->fRrmEnable) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008973 hdd_debug("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008974 neighborReq.no_ssid =
8975 (s_priv_data.length - 1) ? false : true;
8976 if (!neighborReq.no_ssid) {
8977 neighborReq.ssid.length =
8978 (s_priv_data.length - 1) >
8979 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308980 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008981 pBuffer,
8982 neighborReq.ssid.length);
8983 }
8984
8985 callbackInfo.neighborRspCallback = NULL;
8986 callbackInfo.neighborRspCallbackContext = NULL;
8987 callbackInfo.timeout = 5000; /* 5 seconds */
8988 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
8989 (pAdapter),
8990 pAdapter->sessionId,
8991 &neighborReq,
8992 &callbackInfo);
8993 } else {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008994 hdd_err("Ignoring neighbor request as RRM not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008995 ret = -EINVAL;
8996 }
8997 }
8998 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008999 case WE_SET_AP_WPS_IE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009000 hdd_debug("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009001 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
9002 s_priv_data.length);
9003 break;
9004 case WE_SET_CONFIG:
9005 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009006 if (QDF_STATUS_SUCCESS != vstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009007 ret = -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009009 break;
9010 default:
9011 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009012 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009013 sub_cmd);
9014 ret = -EINVAL;
9015 break;
9016 }
9017 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07009018 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309019 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009020 return ret;
9021}
9022
9023static int iw_setchar_getnone(struct net_device *dev,
9024 struct iw_request_info *info,
9025 union iwreq_data *wrqu, char *extra)
9026{
9027 int ret;
9028
9029 cds_ssr_protect(__func__);
9030 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
9031 cds_ssr_unprotect(__func__);
9032
9033 return ret;
9034}
9035
9036/**
9037 * iw_setnone_getint() - Generic "get integer" private ioctl handler
9038 * @dev: device upon which the ioctl was received
9039 * @info: ioctl request information
9040 * @wrqu: ioctl request data
9041 * @extra: ioctl extra data
9042 *
9043 * Return: 0 on success, non-zero on error
9044 */
9045static int __iw_setnone_getint(struct net_device *dev,
9046 struct iw_request_info *info,
9047 union iwreq_data *wrqu, char *extra)
9048{
9049 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9050 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9051 int *value = (int *)extra;
9052 int ret;
9053 tSmeConfigParams smeConfig;
9054 hdd_context_t *hdd_ctx;
9055
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009056 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309057
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009058 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9059 ret = wlan_hdd_validate_context(hdd_ctx);
9060 if (0 != ret)
9061 return ret;
9062
Jeff Johnson441e1f72017-02-07 08:50:49 -08009063 ret = hdd_check_private_wext_control(hdd_ctx, info);
9064 if (0 != ret)
9065 return ret;
9066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009067 switch (value[0]) {
9068 case WE_GET_11D_STATE:
9069 {
9070 sme_get_config_param(hHal, &smeConfig);
9071
9072 *value = smeConfig.csrConfig.Is11dSupportEnabled;
9073
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009074 hdd_debug("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009075
9076 break;
9077 }
9078
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009079 case WE_GET_WLAN_DBG:
9080 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309081 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009082 *value = 0;
9083 break;
9084 }
9085 case WE_GET_MAX_ASSOC:
9086 {
9087 if (sme_cfg_get_int
9088 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309089 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009090 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009091 ret = -EIO;
9092 }
9093 break;
9094 }
9095 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
9096 *value = (WLAN_HDD_GET_CTX(
9097 pAdapter))->config->force_sap_acs;
9098 break;
9099
9100 case WE_GET_CONCURRENCY_MODE:
9101 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08009102 *value = policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009103
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009104 hdd_debug("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009105 break;
9106 }
9107
9108 case WE_GET_NSS:
9109 {
9110 sme_get_config_param(hHal, &smeConfig);
9111 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009112 hdd_debug("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009113 break;
9114 }
9115
9116 case WE_GET_GTX_HT_MCS:
9117 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009118 hdd_debug("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009119 *value = wma_cli_get_command(pAdapter->sessionId,
9120 WMI_VDEV_PARAM_GTX_HT_MCS,
9121 GTX_CMD);
9122 break;
9123 }
9124
9125 case WE_GET_GTX_VHT_MCS:
9126 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009127 hdd_debug("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009128 *value = wma_cli_get_command(pAdapter->sessionId,
9129 WMI_VDEV_PARAM_GTX_VHT_MCS,
9130 GTX_CMD);
9131 break;
9132 }
9133
9134 case WE_GET_GTX_USRCFG:
9135 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009136 hdd_debug("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009137 *value = wma_cli_get_command(pAdapter->sessionId,
9138 WMI_VDEV_PARAM_GTX_USR_CFG,
9139 GTX_CMD);
9140 break;
9141 }
9142
9143 case WE_GET_GTX_THRE:
9144 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009145 hdd_debug("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009146 *value = wma_cli_get_command(pAdapter->sessionId,
9147 WMI_VDEV_PARAM_GTX_THRE,
9148 GTX_CMD);
9149 break;
9150 }
9151
9152 case WE_GET_GTX_MARGIN:
9153 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009154 hdd_debug("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009155 *value = wma_cli_get_command(pAdapter->sessionId,
9156 WMI_VDEV_PARAM_GTX_MARGIN,
9157 GTX_CMD);
9158 break;
9159 }
9160
9161 case WE_GET_GTX_STEP:
9162 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009163 hdd_debug("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009164 *value = wma_cli_get_command(pAdapter->sessionId,
9165 WMI_VDEV_PARAM_GTX_STEP,
9166 GTX_CMD);
9167 break;
9168 }
9169
9170 case WE_GET_GTX_MINTPC:
9171 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009172 hdd_debug("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009173 *value = wma_cli_get_command(pAdapter->sessionId,
9174 WMI_VDEV_PARAM_GTX_MINTPC,
9175 GTX_CMD);
9176 break;
9177 }
9178
9179 case WE_GET_GTX_BWMASK:
9180 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009181 hdd_debug("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009182 *value = wma_cli_get_command(pAdapter->sessionId,
9183 WMI_VDEV_PARAM_GTX_BW_MASK,
9184 GTX_CMD);
9185 break;
9186 }
9187
9188 case WE_GET_LDPC:
9189 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309190 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009191 break;
9192 }
9193
9194 case WE_GET_TX_STBC:
9195 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309196 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009197 break;
9198 }
9199
9200 case WE_GET_RX_STBC:
9201 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309202 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009203 break;
9204 }
9205
9206 case WE_GET_SHORT_GI:
9207 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009208 hdd_debug("GET WMI_VDEV_PARAM_SGI");
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009209 *value = wma_cli_get_command(pAdapter->sessionId,
9210 WMI_VDEV_PARAM_SGI,
9211 VDEV_CMD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009212 break;
9213 }
9214
9215 case WE_GET_RTSCTS:
9216 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009217 hdd_debug("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009218 *value = wma_cli_get_command(pAdapter->sessionId,
9219 WMI_VDEV_PARAM_ENABLE_RTSCTS,
9220 VDEV_CMD);
9221 break;
9222 }
9223
9224 case WE_GET_CHWIDTH:
9225 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009226 hdd_debug("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009227 *value = wma_cli_get_command(pAdapter->sessionId,
9228 WMI_VDEV_PARAM_CHWIDTH,
9229 VDEV_CMD);
9230 break;
9231 }
9232
9233 case WE_GET_ANI_EN_DIS:
9234 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009235 hdd_debug("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009236 *value = wma_cli_get_command(pAdapter->sessionId,
9237 WMI_PDEV_PARAM_ANI_ENABLE,
9238 PDEV_CMD);
9239 break;
9240 }
9241
9242 case WE_GET_ANI_POLL_PERIOD:
9243 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009244 hdd_debug("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009245 *value = wma_cli_get_command(pAdapter->sessionId,
9246 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
9247 PDEV_CMD);
9248 break;
9249 }
9250
9251 case WE_GET_ANI_LISTEN_PERIOD:
9252 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009253 hdd_debug("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009254 *value = wma_cli_get_command(pAdapter->sessionId,
9255 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
9256 PDEV_CMD);
9257 break;
9258 }
9259
9260 case WE_GET_ANI_OFDM_LEVEL:
9261 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009262 hdd_debug("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009263 *value = wma_cli_get_command(pAdapter->sessionId,
9264 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
9265 PDEV_CMD);
9266 break;
9267 }
9268
9269 case WE_GET_ANI_CCK_LEVEL:
9270 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009271 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009272 *value = wma_cli_get_command(pAdapter->sessionId,
9273 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
9274 PDEV_CMD);
9275 break;
9276 }
9277
9278 case WE_GET_DYNAMIC_BW:
9279 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009280 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009281 *value = wma_cli_get_command(pAdapter->sessionId,
9282 WMI_PDEV_PARAM_DYNAMIC_BW,
9283 PDEV_CMD);
9284 break;
9285 }
9286
9287 case WE_GET_11N_RATE:
9288 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009289 hdd_debug("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009290 *value = wma_cli_get_command(pAdapter->sessionId,
9291 WMI_VDEV_PARAM_FIXED_RATE,
9292 VDEV_CMD);
9293 break;
9294 }
9295
9296 case WE_GET_AMPDU:
9297 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009298 hdd_debug("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009299 *value = wma_cli_get_command(pAdapter->sessionId,
9300 GEN_VDEV_PARAM_AMPDU,
9301 GEN_CMD);
9302 break;
9303 }
9304
9305 case WE_GET_AMSDU:
9306 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009307 hdd_debug("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009308 *value = wma_cli_get_command(pAdapter->sessionId,
9309 GEN_VDEV_PARAM_AMSDU,
9310 GEN_CMD);
9311 break;
9312 }
9313
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009314 case WE_GET_ROAM_SYNCH_DELAY:
9315 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009316 hdd_debug("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009317 *value = wma_cli_get_command(pAdapter->sessionId,
9318 GEN_VDEV_ROAM_SYNCH_DELAY,
9319 GEN_CMD);
9320 break;
9321 }
9322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009323 case WE_GET_BURST_ENABLE:
9324 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009325 hdd_debug("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009326 *value = wma_cli_get_command(pAdapter->sessionId,
9327 WMI_PDEV_PARAM_BURST_ENABLE,
9328 PDEV_CMD);
9329 break;
9330 }
9331 case WE_GET_BURST_DUR:
9332 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009333 hdd_debug("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009334 *value = wma_cli_get_command(pAdapter->sessionId,
9335 WMI_PDEV_PARAM_BURST_DUR,
9336 PDEV_CMD);
9337 break;
9338 }
9339
9340 case WE_GET_TX_CHAINMASK:
9341 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009342 hdd_debug("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009343 *value = wma_cli_get_command(pAdapter->sessionId,
9344 WMI_PDEV_PARAM_TX_CHAIN_MASK,
9345 PDEV_CMD);
9346 break;
9347 }
9348
9349 case WE_GET_RX_CHAINMASK:
9350 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009351 hdd_debug("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009352 *value = wma_cli_get_command(pAdapter->sessionId,
9353 WMI_PDEV_PARAM_RX_CHAIN_MASK,
9354 PDEV_CMD);
9355 break;
9356 }
9357
9358 case WE_GET_TXPOW_2G:
9359 {
9360 uint32_t txpow2g = 0;
9361 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009362
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009363 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009364 *value = wma_cli_get_command(pAdapter->sessionId,
9365 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
9366 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309367 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009368 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9369 &txpow2g)) {
9370 return -EIO;
9371 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009372 hdd_debug("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009373 break;
9374 }
9375
9376 case WE_GET_TXPOW_5G:
9377 {
9378 uint32_t txpow5g = 0;
9379 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009380
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009381 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009382 *value = wma_cli_get_command(pAdapter->sessionId,
9383 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
9384 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309385 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009386 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9387 &txpow5g)) {
9388 return -EIO;
9389 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009390 hdd_debug("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009391 break;
9392 }
9393
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009394 case WE_GET_PPS_PAID_MATCH:
9395 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009396 hdd_debug("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009397 *value = wma_cli_get_command(pAdapter->sessionId,
9398 WMI_VDEV_PPS_PAID_MATCH,
9399 PPS_CMD);
9400 break;
9401 }
9402
9403 case WE_GET_PPS_GID_MATCH:
9404 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009405 hdd_debug("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009406 *value = wma_cli_get_command(pAdapter->sessionId,
9407 WMI_VDEV_PPS_GID_MATCH,
9408 PPS_CMD);
9409 break;
9410 }
9411
9412 case WE_GET_PPS_EARLY_TIM_CLEAR:
9413 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009414 hdd_debug("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009415 *value = wma_cli_get_command(pAdapter->sessionId,
9416 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
9417 PPS_CMD);
9418 break;
9419 }
9420
9421 case WE_GET_PPS_EARLY_DTIM_CLEAR:
9422 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009423 hdd_debug("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009424 *value = wma_cli_get_command(pAdapter->sessionId,
9425 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
9426 PPS_CMD);
9427 break;
9428 }
9429
9430 case WE_GET_PPS_EOF_PAD_DELIM:
9431 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009432 hdd_debug("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009433 *value = wma_cli_get_command(pAdapter->sessionId,
9434 WMI_VDEV_PPS_EOF_PAD_DELIM,
9435 PPS_CMD);
9436 break;
9437 }
9438
9439 case WE_GET_PPS_MACADDR_MISMATCH:
9440 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009441 hdd_debug("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009442 *value = wma_cli_get_command(pAdapter->sessionId,
9443 WMI_VDEV_PPS_MACADDR_MISMATCH,
9444 PPS_CMD);
9445 break;
9446 }
9447
9448 case WE_GET_PPS_DELIM_CRC_FAIL:
9449 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009450 hdd_debug("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009451 *value = wma_cli_get_command(pAdapter->sessionId,
9452 WMI_VDEV_PPS_DELIM_CRC_FAIL,
9453 PPS_CMD);
9454 break;
9455 }
9456
9457 case WE_GET_PPS_GID_NSTS_ZERO:
9458 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009459 hdd_debug("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009460 *value = wma_cli_get_command(pAdapter->sessionId,
9461 WMI_VDEV_PPS_GID_NSTS_ZERO,
9462 PPS_CMD);
9463 break;
9464 }
9465
9466 case WE_GET_PPS_RSSI_CHECK:
9467 {
9468
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009469 hdd_debug("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009470 *value = wma_cli_get_command(pAdapter->sessionId,
9471 WMI_VDEV_PPS_RSSI_CHECK,
9472 PPS_CMD);
9473 break;
9474 }
9475
9476 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
9477 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009478 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009479 *value = wma_cli_get_command(pAdapter->sessionId,
9480 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
9481 QPOWER_CMD);
9482 break;
9483 }
9484
9485 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
9486 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009487 hdd_debug("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009488 *value = wma_cli_get_command(pAdapter->sessionId,
9489 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
9490 QPOWER_CMD);
9491 break;
9492 }
9493
9494 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
9495 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009496 hdd_debug("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009497 *value = wma_cli_get_command(pAdapter->sessionId,
9498 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
9499 QPOWER_CMD);
9500 break;
9501 }
9502
9503 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
9504 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009505 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009506 *value = wma_cli_get_command(pAdapter->sessionId,
9507 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
9508 QPOWER_CMD);
9509 break;
9510 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009511 case WE_CAP_TSF:
9512 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
9513 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009514 case WE_GET_TEMPERATURE:
9515 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009516 hdd_debug("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009517 ret = wlan_hdd_get_temperature(pAdapter, value);
9518 break;
9519 }
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07009520 case WE_GET_DCM:
9521 hdd_notice("GET WMI_VDEV_PARAM_HE_DCM");
9522 *value = wma_cli_get_command(pAdapter->sessionId,
9523 WMI_VDEV_PARAM_HE_DCM,
9524 VDEV_CMD);
9525 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07009526 case WE_GET_RANGE_EXT:
9527 hdd_notice("GET WMI_VDEV_PARAM_HE_RANGE_EXT");
9528 *value = wma_cli_get_command(pAdapter->sessionId,
9529 WMI_VDEV_PARAM_HE_RANGE_EXT,
9530 VDEV_CMD);
9531 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009532 default:
9533 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009534 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009535 value[0]);
9536 break;
9537 }
9538 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309539 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009540 return ret;
9541}
9542
9543static int iw_setnone_getint(struct net_device *dev,
9544 struct iw_request_info *info,
9545 union iwreq_data *wrqu, char *extra)
9546{
9547 int ret;
9548
9549 cds_ssr_protect(__func__);
9550 ret = __iw_setnone_getint(dev, info, wrqu, extra);
9551 cds_ssr_unprotect(__func__);
9552
9553 return ret;
9554}
9555
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309556static int hdd_set_fwtest(int argc, int cmd, int value)
9557{
9558 struct set_fwtest_params *fw_test;
9559
9560 /* check for max number of arguments */
9561 if (argc > (WMA_MAX_NUM_ARGS) ||
9562 argc != HDD_FWTEST_PARAMS) {
9563 hdd_err("Too Many args %d", argc);
9564 return -EINVAL;
9565 }
9566 /*
9567 * check if number of arguments are 3 then, check
9568 * then set the default value for sounding interval.
9569 */
9570 if (HDD_FWTEST_PARAMS == argc) {
9571 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
9572 value = HDD_FWTEST_SU_DEFAULT_VALUE;
9573 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
9574 value = HDD_FWTEST_MU_DEFAULT_VALUE;
9575 }
9576 /* check sounding interval value should not exceed to max */
9577 if (value > HDD_FWTEST_MAX_VALUE) {
9578 hdd_err("Invalid arguments value should not exceed max: %d",
9579 value);
9580 return -EINVAL;
9581 }
9582 fw_test = qdf_mem_malloc(sizeof(*fw_test));
9583 if (NULL == fw_test) {
9584 hdd_err("qdf_mem_malloc failed for fw_test");
9585 return -ENOMEM;
9586 }
9587 fw_test->arg = cmd;
9588 fw_test->value = value;
9589 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
9590 qdf_mem_free(fw_test);
9591 hdd_err("Not able to post FW_TEST_CMD message to WMA");
9592 return -EINVAL;
9593 }
9594 return 0;
9595}
9596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009597/**
9598 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
9599 * @dev: device upon which the ioctl was received
9600 * @info: ioctl request information
9601 * @wrqu: ioctl request data
9602 * @extra: ioctl extra data
9603 *
9604 * Return: 0 on success, non-zero on error
9605 */
9606static int __iw_set_three_ints_getnone(struct net_device *dev,
9607 struct iw_request_info *info,
9608 union iwreq_data *wrqu, char *extra)
9609{
9610 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9611 int *value = (int *)extra;
9612 int sub_cmd = value[0];
9613 int ret;
9614 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9615
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009616 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309617
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009618 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009619 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009620 return -EPERM;
9621 }
9622
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009623 ret = wlan_hdd_validate_context(hdd_ctx);
9624 if (0 != ret)
9625 return ret;
9626
Jeff Johnson441e1f72017-02-07 08:50:49 -08009627 ret = hdd_check_private_wext_control(hdd_ctx, info);
9628 if (0 != ret)
9629 return ret;
9630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009631 switch (sub_cmd) {
9632
9633 case WE_SET_WLAN_DBG:
Dustin Brown36e2e5c2017-05-16 15:41:37 -07009634 qdf_print_set_category_verbose(qdf_get_pidx(), value[1],
9635 value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009636 break;
9637 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309638 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009639 break;
9640
9641 /* value[3] the acs band is not required as start and end channels are
9642 * enough but this cmd is maintained under set three ints for historic
9643 * reasons.
9644 */
9645 case WE_SET_SAP_CHANNELS:
9646 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309647 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009648 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309649 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009650 ret = -EINVAL;
9651 } else {
9652 hdd_ctx->config->force_sap_acs_st_ch = value[1];
9653 hdd_ctx->config->force_sap_acs_end_ch = value[2];
9654 }
9655 break;
9656 case WE_SET_DUAL_MAC_SCAN_CONFIG:
9657 hdd_debug("Ioctl to set dual mac scan config");
9658 if (hdd_ctx->config->dual_mac_feature_disable) {
9659 hdd_err("Dual mac feature is disabled from INI");
9660 return -EPERM;
9661 }
9662 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08009663 policy_mgr_set_dual_mac_scan_config(hdd_ctx->hdd_psoc,
9664 value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009665 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309666 case WE_SET_FW_TEST:
9667 {
9668 ret = hdd_set_fwtest(value[1], value[2], value[3]);
9669 if (ret) {
9670 hdd_err("Not able to set fwtest %d", ret);
9671 return ret;
9672 }
9673 }
9674 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009675 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009676 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009677 break;
9678
9679 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309680 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009681 return ret;
9682}
9683
9684int iw_set_three_ints_getnone(struct net_device *dev,
9685 struct iw_request_info *info,
9686 union iwreq_data *wrqu, char *extra)
9687{
9688 int ret;
9689
9690 cds_ssr_protect(__func__);
9691 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
9692 cds_ssr_unprotect(__func__);
9693
9694 return ret;
9695}
9696
9697/**
9698 * hdd_connection_state_string() - Get connection state string
9699 * @connection_state: enum to be converted to a string
9700 *
9701 * Return: the string equivalent of @connection_state
9702 */
9703static const char *
9704hdd_connection_state_string(eConnectionState connection_state)
9705{
9706 switch (connection_state) {
9707 CASE_RETURN_STRING(eConnectionState_NotConnected);
9708 CASE_RETURN_STRING(eConnectionState_Connecting);
9709 CASE_RETURN_STRING(eConnectionState_Associated);
9710 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
9711 CASE_RETURN_STRING(eConnectionState_IbssConnected);
9712 CASE_RETURN_STRING(eConnectionState_Disconnecting);
9713 default:
9714 return "UNKNOWN";
9715 }
9716}
9717
Naveen Rawat910726a2017-03-06 11:42:51 -08009718#if defined(FEATURE_OEM_DATA_SUPPORT)
9719/**
9720 * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
9721 * wifi_pos api to get oem data caps
9722 * @dev: net device upon which the request was received
9723 * @info: ioctl request information
9724 * @wrqu: ioctl request data
9725 * @extra: ioctl data payload
9726 *
9727 * Return: 0 for success, negative errno value on failure
9728 */
9729static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9730 struct iw_request_info *info,
9731 union iwreq_data *wrqu, char *extra)
9732{
9733 return iw_get_oem_data_cap(dev, info, wrqu, extra);
9734}
9735#elif defined(WIFI_POS_CONVERGED)
9736static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9737 struct iw_request_info *info,
9738 union iwreq_data *wrqu, char *extra)
9739{
9740 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9741 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9742
9743 return os_if_wifi_pos_populate_caps(hdd_ctx->hdd_psoc,
9744 (struct wifi_pos_driver_caps *)extra);
9745}
9746#else
9747static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9748 struct iw_request_info *info,
9749 union iwreq_data *wrqu, char *extra)
9750{
9751 return -ENOTSUPP;
9752}
9753#endif
9754
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009755/**
9756 * iw_get_char_setnone() - Generic "get string" private ioctl handler
9757 * @dev: device upon which the ioctl was received
9758 * @info: ioctl request information
9759 * @wrqu: ioctl request data
9760 * @extra: ioctl extra data
9761 *
9762 * Return: 0 on success, non-zero on error
9763 */
9764static int __iw_get_char_setnone(struct net_device *dev,
9765 struct iw_request_info *info,
9766 union iwreq_data *wrqu, char *extra)
9767{
9768 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9769 int sub_cmd = wrqu->data.flags;
9770 hdd_context_t *hdd_ctx;
9771 int ret;
9772#ifdef WLAN_FEATURE_11W
9773 hdd_wext_state_t *pWextState;
9774#endif
9775
9776#ifdef WLAN_FEATURE_11W
9777 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9778#endif
9779
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009780 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309781
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009782 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9783 ret = wlan_hdd_validate_context(hdd_ctx);
9784 if (0 != ret)
9785 return ret;
9786
Jeff Johnson441e1f72017-02-07 08:50:49 -08009787 ret = hdd_check_private_wext_control(hdd_ctx, info);
9788 if (0 != ret)
9789 return ret;
9790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009791 switch (sub_cmd) {
9792 case WE_WLAN_VERSION:
9793 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05309794 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009795 break;
9796 }
9797
9798 case WE_GET_STATS:
9799 {
9800 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
9801 extra, WE_MAX_STR_LEN);
9802 break;
9803 }
9804
Dustin Brownd9322482017-01-09 12:46:03 -08009805 case WE_GET_SUSPEND_RESUME_STATS:
9806 {
9807 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
9808 WE_MAX_STR_LEN);
9809 if (ret >= 0) {
9810 wrqu->data.length = ret;
9811 ret = 0;
9812 }
9813
9814 break;
9815 }
9816
Govind Singha471e5e2015-10-12 17:11:14 +05309817 case WE_LIST_FW_PROFILE:
9818 hdd_wlan_list_fw_profile(&(wrqu->data.length),
9819 extra, WE_MAX_STR_LEN);
9820 break;
9821
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009822 /* The case prints the current state of the HDD, SME, CSR, PE,
9823 * TL it can be extended for WDI Global State as well. And
9824 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
9825 * and P2P_GO have not been added as of now.
9826 */
9827 case WE_GET_STATES:
9828 {
9829 int buf = 0, len = 0;
9830 int adapter_num = 0;
9831 int count = 0, check = 1;
9832
9833 tHalHandle hHal = NULL;
9834 tpAniSirGlobal pMac = NULL;
9835 hdd_station_ctx_t *pHddStaCtx = NULL;
9836
9837 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9838 hdd_adapter_t *useAdapter = NULL;
9839
9840 /* Print wlan0 or p2p0 states based on the adapter_num
9841 * by using the correct adapter
9842 */
9843 while (adapter_num < 2) {
9844 if (WLAN_ADAPTER == adapter_num) {
9845 useAdapter = pAdapter;
9846 buf =
9847 scnprintf(extra + len,
9848 WE_MAX_STR_LEN - len,
9849 "\n\n wlan0 States:-");
9850 len += buf;
9851 } else if (P2P_ADAPTER == adapter_num) {
9852 buf =
9853 scnprintf(extra + len,
9854 WE_MAX_STR_LEN - len,
9855 "\n\n p2p0 States:-");
9856 len += buf;
9857
9858 if (!pHddCtx) {
9859 buf =
9860 scnprintf(extra + len,
9861 WE_MAX_STR_LEN -
9862 len,
9863 "\n pHddCtx is NULL");
9864 len += buf;
9865 break;
9866 }
9867
9868 /* Printing p2p0 states only in the
9869 * case when the device is configured
9870 * as a p2p_client
9871 */
9872 useAdapter =
9873 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08009874 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009875 if (!useAdapter) {
9876 buf =
9877 scnprintf(extra + len,
9878 WE_MAX_STR_LEN -
9879 len,
9880 "\n Device not configured as P2P_CLIENT.");
9881 len += buf;
9882 break;
9883 }
9884 }
9885
9886 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
9887 if (!hHal) {
9888 buf =
9889 scnprintf(extra + len,
9890 WE_MAX_STR_LEN - len,
9891 "\n pMac is NULL");
9892 len += buf;
9893 break;
9894 }
9895 pMac = PMAC_STRUCT(hHal);
9896 if (!pMac) {
9897 buf =
9898 scnprintf(extra + len,
9899 WE_MAX_STR_LEN - len,
9900 "\n pMac is NULL");
9901 len += buf;
9902 break;
9903 }
9904 pHddStaCtx =
9905 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
9906
9907
9908 buf =
9909 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9910 "\n HDD Conn State - %s "
9911 "\n \n SME State:"
9912 "\n Neighbour Roam State - %s"
9913 "\n CSR State - %s"
9914 "\n CSR Substate - %s",
9915 hdd_connection_state_string
9916 (pHddStaCtx->conn_info.connState),
9917 mac_trace_get_neighbour_roam_state
9918 (sme_get_neighbor_roam_state
9919 (hHal, useAdapter->sessionId)),
9920 mac_trace_getcsr_roam_state
9921 (sme_get_current_roam_state
9922 (hHal, useAdapter->sessionId)),
9923 mac_trace_getcsr_roam_sub_state
9924 (sme_get_current_roam_sub_state
9925 (hHal, useAdapter->sessionId))
9926 );
9927 len += buf;
9928 adapter_num++;
9929 }
9930
Mukul Sharma81661ae2015-10-30 20:26:02 +05309931 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009932 /* Printing Lim State starting with global lim states */
9933 buf =
9934 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9935 "\n \n LIM STATES:-"
9936 "\n Global Sme State - %s "
9937 "\n Global mlm State - %s " "\n",
9938 mac_trace_get_lim_sme_state
9939 (sme_get_lim_sme_state(hHal)),
9940 mac_trace_get_lim_mlm_state
9941 (sme_get_lim_sme_state(hHal))
9942 );
9943 len += buf;
9944
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009945 while (check < 3 && count < 255) {
9946 if (sme_is_lim_session_valid(hHal, count)) {
9947 buf =
9948 scnprintf(extra + len,
9949 WE_MAX_STR_LEN -
9950 len,
9951 "\n Lim Valid Session %d:-"
9952 "\n PE Sme State - %s "
9953 "\n PE Mlm State - %s "
9954 "\n", check,
9955 mac_trace_get_lim_sme_state
9956 (sme_get_lim_sme_session_state
9957 (hHal, count)),
9958 mac_trace_get_lim_mlm_state
9959 (sme_get_lim_mlm_session_state
9960 (hHal, count))
9961 );
9962
9963 len += buf;
9964 check++;
9965 }
9966 count++;
9967 }
9968 }
9969
9970 wrqu->data.length = strlen(extra) + 1;
9971 break;
9972 }
9973
9974 case WE_GET_CFG:
9975 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009976 hdd_debug("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009977 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
9978 extra,
9979 QCSAP_IOCTL_MAX_STR_LEN);
9980 wrqu->data.length = strlen(extra) + 1;
9981 break;
9982 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009983 case WE_GET_RSSI:
9984 {
9985 int8_t s7Rssi = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009986
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009987 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
9988 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
9989 wrqu->data.length = strlen(extra) + 1;
9990 break;
9991 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009992
9993 case WE_GET_WMM_STATUS:
9994 {
9995 snprintf(extra, WE_MAX_STR_LEN,
9996 "\nDir: 0=up, 1=down, 3=both\n"
9997 "|------------------------|\n"
9998 "|AC | ACM |Admitted| Dir |\n"
9999 "|------------------------|\n"
10000 "|VO | %d | %3s | %d |\n"
10001 "|VI | %d | %3s | %d |\n"
10002 "|BE | %d | %3s | %d |\n"
10003 "|BK | %d | %3s | %d |\n"
10004 "|------------------------|\n",
10005 pAdapter->hddWmmStatus.
10006 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
10007 pAdapter->hddWmmStatus.
10008 wmmAcStatus[SME_AC_VO].
10009 wmmAcAccessAllowed ? "YES" : "NO",
10010 pAdapter->hddWmmStatus.
10011 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
10012 ts_info.direction,
10013 pAdapter->hddWmmStatus.
10014 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
10015 pAdapter->hddWmmStatus.
10016 wmmAcStatus[SME_AC_VI].
10017 wmmAcAccessAllowed ? "YES" : "NO",
10018 pAdapter->hddWmmStatus.
10019 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
10020 ts_info.direction,
10021 pAdapter->hddWmmStatus.
10022 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
10023 pAdapter->hddWmmStatus.
10024 wmmAcStatus[SME_AC_BE].
10025 wmmAcAccessAllowed ? "YES" : "NO",
10026 pAdapter->hddWmmStatus.
10027 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
10028 ts_info.direction,
10029 pAdapter->hddWmmStatus.
10030 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
10031 pAdapter->hddWmmStatus.
10032 wmmAcStatus[SME_AC_BK].
10033 wmmAcAccessAllowed ? "YES" : "NO",
10034 pAdapter->hddWmmStatus.
10035 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
10036 ts_info.direction);
10037
10038 wrqu->data.length = strlen(extra) + 1;
10039 break;
10040 }
10041 case WE_GET_CHANNEL_LIST:
10042 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010043 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010044 uint8_t i, len;
10045 char *buf;
10046 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
10047 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
10048 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10049
Srinivas Girigowdac231df62017-03-24 18:27:57 -070010050 struct channel_list_info channel_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010051
10052 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +053010053 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010054 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010055 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010056 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010057 return -EINVAL;
10058 }
10059 buf = extra;
10060 /*
10061 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
10062 * Maximum buffer needed = 5 * number of channels.
10063 * Check ifsufficient buffer is available and then
10064 * proceed to fill the buffer.
10065 */
10066 if (WE_MAX_STR_LEN <
10067 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010068 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010069 return -EINVAL;
10070 }
10071 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
10072 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010073 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010074 ubuf, &ubuf_len)) {
10075 /* Printing Country code in getChannelList */
10076 for (i = 0; i < (ubuf_len - 1); i++)
10077 len += scnprintf(buf + len,
10078 WE_MAX_STR_LEN - len,
10079 "%c", ubuf[i]);
10080 }
10081 for (i = 0; i < channel_list.num_channels; i++) {
10082 len +=
10083 scnprintf(buf + len, WE_MAX_STR_LEN - len,
10084 " %u", channel_list.channels[i]);
10085 }
10086 wrqu->data.length = strlen(extra) + 1;
10087
10088 break;
10089 }
10090#ifdef FEATURE_WLAN_TDLS
10091 case WE_GET_TDLS_PEERS:
10092 {
10093 wrqu->data.length =
10094 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
10095 WE_MAX_STR_LEN) + 1;
10096 break;
10097 }
10098#endif
10099#ifdef WLAN_FEATURE_11W
10100 case WE_GET_11W_INFO:
10101 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010102 hdd_debug("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010103 pWextState->roamProfile.MFPEnabled);
10104
10105 snprintf(extra, WE_MAX_STR_LEN,
10106 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
10107 "\n Number of Unprotected Disassocs %d"
10108 "\n Number of Unprotected Deauths %d",
10109 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
10110 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
10111 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
10112 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
10113 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
10114 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
10115 pWextState->roamProfile.MFPEnabled,
10116 pAdapter->hdd_stats.hddPmfStats.
10117 numUnprotDisassocRx,
10118 pAdapter->hdd_stats.hddPmfStats.
10119 numUnprotDeauthRx);
10120
10121 wrqu->data.length = strlen(extra) + 1;
10122 break;
10123 }
10124#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010125 case WE_GET_IBSS_STA_INFO:
10126 {
10127 hdd_station_ctx_t *pHddStaCtx =
10128 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10129 int idx = 0;
10130 int length = 0, buf = 0;
10131
Naveen Rawatc45d1622016-07-05 12:20:09 -070010132 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010133 if (0 != pHddStaCtx->conn_info.staId[idx]) {
10134 buf = snprintf
10135 ((extra + length),
10136 WE_MAX_STR_LEN - length,
10137 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
10138 pHddStaCtx->conn_info.staId[idx],
10139 pHddStaCtx->conn_info.
10140 peerMacAddress[idx].bytes[0],
10141 pHddStaCtx->conn_info.
10142 peerMacAddress[idx].bytes[1],
10143 pHddStaCtx->conn_info.
10144 peerMacAddress[idx].bytes[2],
10145 pHddStaCtx->conn_info.
10146 peerMacAddress[idx].bytes[3],
10147 pHddStaCtx->conn_info.
10148 peerMacAddress[idx].bytes[4],
10149 pHddStaCtx->conn_info.
10150 peerMacAddress[idx].bytes[5]
10151 );
10152 length += buf;
10153 }
10154 }
10155 wrqu->data.length = strlen(extra) + 1;
10156 break;
10157 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010158 case WE_GET_PHYMODE:
10159 {
10160 bool ch_bond24 = false, ch_bond5g = false;
10161 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
10162 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10163 eCsrPhyMode phymode;
10164 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010165 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010166
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010167 sme_config = qdf_mem_malloc(sizeof(*sme_config));
10168 if (!sme_config) {
10169 hdd_err("Out of memory");
10170 ret = -ENOMEM;
10171 break;
10172 }
10173
10174 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010175 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010176 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010177 ch_bond24 = true;
10178
10179 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010180 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010181 ch_bond5g = true;
10182
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010183 qdf_mem_free(sme_config);
10184
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010185 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010186 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010187 sme_get_freq_band(hal, &currBand))) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010188 hdd_err("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010189 return -EIO;
10190 }
10191
10192 switch (phymode) {
10193 case eCSR_DOT11_MODE_AUTO:
10194 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
10195 break;
10196 case eCSR_DOT11_MODE_11n:
10197 case eCSR_DOT11_MODE_11n_ONLY:
10198 if (currBand == eCSR_BAND_24) {
10199 if (ch_bond24)
10200 snprintf(extra, WE_MAX_STR_LEN,
10201 "11NGHT40");
10202 else
10203 snprintf(extra, WE_MAX_STR_LEN,
10204 "11NGHT20");
10205 } else if (currBand == eCSR_BAND_5G) {
10206 if (ch_bond5g)
10207 snprintf(extra, WE_MAX_STR_LEN,
10208 "11NAHT40");
10209 else
10210 snprintf(extra, WE_MAX_STR_LEN,
10211 "11NAHT20");
10212 } else {
10213 snprintf(extra, WE_MAX_STR_LEN, "11N");
10214 }
10215 break;
10216 case eCSR_DOT11_MODE_abg:
10217 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
10218 break;
10219 case eCSR_DOT11_MODE_11a:
10220 snprintf(extra, WE_MAX_STR_LEN, "11A");
10221 break;
10222 case eCSR_DOT11_MODE_11b:
10223 case eCSR_DOT11_MODE_11b_ONLY:
10224 snprintf(extra, WE_MAX_STR_LEN, "11B");
10225 break;
10226 case eCSR_DOT11_MODE_11g:
10227 case eCSR_DOT11_MODE_11g_ONLY:
10228 snprintf(extra, WE_MAX_STR_LEN, "11G");
10229 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010230 case eCSR_DOT11_MODE_11ac:
10231 case eCSR_DOT11_MODE_11ac_ONLY:
10232 if (hddctx->config->vhtChannelWidth ==
10233 eHT_CHANNEL_WIDTH_20MHZ)
10234 snprintf(extra, WE_MAX_STR_LEN,
10235 "11ACVHT20");
10236 else if (hddctx->config->vhtChannelWidth ==
10237 eHT_CHANNEL_WIDTH_40MHZ)
10238 snprintf(extra, WE_MAX_STR_LEN,
10239 "11ACVHT40");
10240 else if (hddctx->config->vhtChannelWidth ==
10241 eHT_CHANNEL_WIDTH_80MHZ)
10242 snprintf(extra, WE_MAX_STR_LEN,
10243 "11ACVHT80");
10244 else if (hddctx->config->vhtChannelWidth ==
10245 eHT_CHANNEL_WIDTH_160MHZ)
10246 snprintf(extra, WE_MAX_STR_LEN,
10247 "11ACVHT160");
10248 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080010249 case eCSR_DOT11_MODE_11ax:
10250 case eCSR_DOT11_MODE_11ax_ONLY:
10251 /* currently using vhtChannelWidth */
10252 if (hddctx->config->vhtChannelWidth ==
10253 eHT_CHANNEL_WIDTH_20MHZ)
10254 snprintf(extra, WE_MAX_STR_LEN,
10255 "11AX_HE_20");
10256 else if (hddctx->config->vhtChannelWidth ==
10257 eHT_CHANNEL_WIDTH_40MHZ)
10258 snprintf(extra, WE_MAX_STR_LEN,
10259 "11AX_HE_40");
10260 else if (hddctx->config->vhtChannelWidth ==
10261 eHT_CHANNEL_WIDTH_80MHZ)
10262 snprintf(extra, WE_MAX_STR_LEN,
10263 "11AX_HE_80");
10264 else if (hddctx->config->vhtChannelWidth ==
10265 eHT_CHANNEL_WIDTH_160MHZ)
10266 snprintf(extra, WE_MAX_STR_LEN,
10267 "11AX_HE_160");
10268 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010269 }
10270
10271 wrqu->data.length = strlen(extra) + 1;
10272 break;
10273 }
10274
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010275 case WE_GET_OEM_DATA_CAP:
Naveen Rawat910726a2017-03-06 11:42:51 -080010276 return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010277 case WE_GET_SNR:
10278 {
10279 int8_t s7snr = 0;
10280 int status = 0;
10281 hdd_context_t *pHddCtx;
10282 hdd_station_ctx_t *pHddStaCtx;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010283
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010284 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10285 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010286 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010287 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010288
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010289 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10290 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
10291 eConnectionState_Associated !=
10292 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010293 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010294 pHddCtx->config->fEnableSNRMonitoring,
10295 pHddStaCtx->conn_info.connState);
10296 return -ENONET;
10297 }
10298 wlan_hdd_get_snr(pAdapter, &s7snr);
10299 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
10300 wrqu->data.length = strlen(extra) + 1;
10301 break;
10302 }
10303 default:
10304 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010305 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010306 sub_cmd);
10307 break;
10308 }
10309 }
Dustin Brownd9322482017-01-09 12:46:03 -080010310
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010311 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -080010312 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010313}
10314
10315static int iw_get_char_setnone(struct net_device *dev,
10316 struct iw_request_info *info,
10317 union iwreq_data *wrqu, char *extra)
10318{
10319 int ret;
10320
10321 cds_ssr_protect(__func__);
10322 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
10323 cds_ssr_unprotect(__func__);
10324
10325 return ret;
10326}
10327
10328/**
10329 * iw_setnone_getnone() - Generic "action" private ioctl handler
10330 * @dev: device upon which the ioctl was received
10331 * @info: ioctl request information
10332 * @wrqu: ioctl request data
10333 * @extra: ioctl extra data
10334 *
10335 * Return: 0 on success, non-zero on error
10336 */
10337static int __iw_setnone_getnone(struct net_device *dev,
10338 struct iw_request_info *info,
10339 union iwreq_data *wrqu, char *extra)
10340{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010341 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010342 hdd_context_t *hdd_ctx;
10343 int ret;
10344 int sub_cmd;
10345
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010346 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010347
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010348 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010349 ret = wlan_hdd_validate_context(hdd_ctx);
10350 if (0 != ret)
10351 return ret;
10352
Jeff Johnson441e1f72017-02-07 08:50:49 -080010353 ret = hdd_check_private_wext_control(hdd_ctx, info);
10354 if (0 != ret)
10355 return ret;
10356
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010357#ifdef CONFIG_COMPAT
10358 /* this ioctl is a special case where a sub-ioctl is used and both
10359 * the number of get and set args is 0. in this specific case the
10360 * logic in iwpriv places the sub_cmd in the data.flags portion of
10361 * the iwreq. unfortunately the location of this field will be
10362 * different between 32-bit and 64-bit userspace, and the standard
10363 * compat support in the kernel does not handle this case. so we
10364 * need to explicitly handle it here.
10365 */
10366 if (is_compat_task()) {
10367 struct compat_iw_point *compat_iw_point =
10368 (struct compat_iw_point *)&wrqu->data;
10369 sub_cmd = compat_iw_point->flags;
10370 } else {
10371 sub_cmd = wrqu->data.flags;
10372 }
10373#else
10374 sub_cmd = wrqu->data.flags;
10375#endif
10376
10377 switch (sub_cmd) {
10378 case WE_GET_RECOVERY_STAT:
10379 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010380 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010381
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010382 sme_get_recovery_stats(hal);
10383 break;
10384 }
10385
Govind Singha471e5e2015-10-12 17:11:14 +053010386 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010387 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +053010388 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
10389 0, DBG_CMD);
10390 break;
10391
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010392 case WE_IBSS_GET_PEER_INFO_ALL:
10393 {
10394 hdd_wlan_get_ibss_peer_info_all(adapter);
10395 break;
10396 }
10397
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010398 case WE_SET_REASSOC_TRIGGER:
10399 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010400 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010401
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010402 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010403 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010404 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010405 uint8_t operating_ch =
10406 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010407 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010408
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010409 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010410 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010411 if (roaming_offload_enabled(hdd_ctx)) {
10412 qdf_mem_copy(bssid,
10413 &adapter->sessionCtx.station.conn_info.bssId,
10414 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -080010415 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010416 bssid, operating_ch);
10417 } else {
10418 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
10419 NULL, modProfileFields, &roamId, 1);
10420 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010421 return 0;
10422 }
10423
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010424 case WE_STOP_OBSS_SCAN:
10425 {
10426 /*
10427 * 1.OBSS Scan is mandatory while operating in 2.4GHz
10428 * 2.OBSS scan is stopped by Firmware during the disassociation
10429 * 3.OBSS stop comamnd is added for debugging purpose
10430 */
10431 tHalHandle hal;
10432
10433 hal = WLAN_HDD_GET_HAL_CTX(adapter);
10434 if (hal == NULL) {
10435 hdd_err("hal context is NULL");
10436 return -EINVAL;
10437 }
10438 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
10439 }
10440 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010441 default:
10442 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010443 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010444 break;
10445 }
10446 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010447 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010448 return ret;
10449}
10450
10451static int iw_setnone_getnone(struct net_device *dev,
10452 struct iw_request_info *info,
10453 union iwreq_data *wrqu, char *extra)
10454{
10455 int ret;
10456
10457 cds_ssr_protect(__func__);
10458 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
10459 cds_ssr_unprotect(__func__);
10460
10461 return ret;
10462}
10463
Krunal Sonia6e505b2017-01-12 12:25:18 -080010464#ifdef MPC_UT_FRAMEWORK
10465static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10466 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10467{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -080010468 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010469 case WE_POLICY_MANAGER_CLIST_CMD:
10470 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010471 hdd_debug("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010472 policy_mgr_incr_connection_count_utfw(hdd_ctx->hdd_psoc,
10473 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
10474 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010475 }
10476 break;
10477
10478 case WE_POLICY_MANAGER_DLIST_CMD:
10479 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010480 hdd_debug("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010481 policy_mgr_decr_connection_count_utfw(hdd_ctx->hdd_psoc,
10482 apps_args[0], apps_args[1]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010483 }
10484 break;
10485
10486 case WE_POLICY_MANAGER_ULIST_CMD:
10487 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010488 hdd_debug("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010489 policy_mgr_update_connection_info_utfw(hdd_ctx->hdd_psoc,
10490 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
10491 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010492 }
10493 break;
10494
10495 case WE_POLICY_MANAGER_DBS_CMD:
10496 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010497 hdd_debug("<iwpriv wlan0 pm_dbs> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -080010498 if (apps_args[0] == 0)
10499 wma_set_dbs_capability_ut(0);
10500 else
10501 wma_set_dbs_capability_ut(1);
10502
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010503 if (apps_args[1] >= PM_THROUGHPUT &&
10504 apps_args[1] <= PM_LATENCY) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010505 pr_info("setting system pref to [%d]\n", apps_args[1]);
10506 hdd_ctx->config->conc_system_pref = apps_args[1];
10507 }
10508 }
10509 break;
10510
10511 case WE_POLICY_MANAGER_PCL_CMD:
10512 {
10513 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
10514 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
10515 uint32_t pcl_len = 0, i = 0;
10516
10517 hdd_err("<iwpriv wlan0 pm_pcl> is called");
10518
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010519 policy_mgr_get_pcl(hdd_ctx->hdd_psoc, apps_args[0],
Krunal Sonia6e505b2017-01-12 12:25:18 -080010520 pcl, &pcl_len,
10521 weight_list, QDF_ARRAY_SIZE(weight_list));
10522 pr_info("PCL list for role[%d] is {", apps_args[0]);
10523 for (i = 0 ; i < pcl_len; i++)
10524 pr_info(" %d, ", pcl[i]);
10525 pr_info("}--------->\n");
10526 }
10527 break;
10528
10529 case WE_POLICY_SET_HW_MODE_CMD:
10530 {
10531 if (apps_args[0] == 0) {
10532 hdd_err("set hw mode for single mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010533 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010534 adapter->sessionId,
10535 HW_MODE_SS_2x2,
10536 HW_MODE_80_MHZ,
10537 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
10538 HW_MODE_DBS_NONE,
10539 HW_MODE_AGILE_DFS_NONE,
10540 HW_MODE_SBS_NONE,
10541 SIR_UPDATE_REASON_UT);
10542 } else if (apps_args[0] == 1) {
10543 hdd_err("set hw mode for dual mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010544 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010545 adapter->sessionId,
10546 HW_MODE_SS_1x1,
10547 HW_MODE_80_MHZ,
10548 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
10549 HW_MODE_DBS,
10550 HW_MODE_AGILE_DFS_NONE,
10551 HW_MODE_SBS_NONE,
10552 SIR_UPDATE_REASON_UT);
10553 }
10554 }
10555 break;
10556
10557 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10558 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010559 enum policy_mgr_conc_next_action action;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010560
Krunal Sonia6e505b2017-01-12 12:25:18 -080010561 hdd_notice("<iwpriv wlan0 pm_query_action> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010562 action = policy_mgr_current_connections_update(
10563 hdd_ctx->hdd_psoc,
10564 adapter->sessionId, apps_args[0],
10565 SIR_UPDATE_REASON_UT);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010566 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
10567 }
10568 break;
10569
10570 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10571 {
10572 bool allow;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010573
10574 hdd_notice("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010575 allow = policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010576 apps_args[0], apps_args[1], apps_args[2]);
10577 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
10578 }
10579 break;
10580
10581 case WE_POLICY_MANAGER_SCENARIO_CMD:
10582 {
10583 clean_report(hdd_ctx);
10584 if (apps_args[0] == 1) {
10585 wlan_hdd_one_connection_scenario(hdd_ctx);
10586 } else if (apps_args[0] == 2) {
10587 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010588 6, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010589 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010590 36, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010591 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010592 6, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010593 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010594 36, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010595 } else if (apps_args[0] == 3) {
10596 /* MCC on same band with 2x2 same mac*/
10597 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010598 6, 11, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010599 /* MCC on diff band with 2x2 same mac*/
10600 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010601 6, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010602 /* MCC on diff band with 1x1 diff mac */
10603 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010604 36, 6, POLICY_MGR_ONE_ONE, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010605 /* MCC on diff band with 1x1 same mac */
10606 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010607 36, 6, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010608 /* SCC on same band with 2x2 same mac */
10609 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010610 36, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010611 /* SCC on same band with 1x1 same mac */
10612 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010613 36, 36, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010614 /* MCC on same band with 2x2 same mac */
10615 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010616 36, 149, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010617 /* MCC on same band with 1x1 same mac */
10618 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010619 36, 149, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010620 }
10621 print_report(hdd_ctx);
10622 }
10623 break;
10624 }
10625 return 0;
10626}
10627#else
10628static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10629 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10630{
10631 return 0;
10632}
10633#endif
10634
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010635/**
10636 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10637 * @dev: device upon which the ioctl was received
10638 * @info: ioctl request information
10639 * @wrqu: ioctl request data
10640 * @extra: ioctl extra data
10641 *
10642 * This is an SSR-protected generic handler for private ioctls which
10643 * take multiple arguments. Note that this implementation is also
10644 * somewhat unique in that it is shared by both STA-mode and SAP-mode
10645 * interfaces.
10646 *
10647 * Return: 0 on success, non-zero on error
10648 */
10649static int __iw_set_var_ints_getnone(struct net_device *dev,
10650 struct iw_request_info *info,
10651 union iwreq_data *wrqu, char *extra)
10652{
10653 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10654 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10655 int sub_cmd;
10656 int *apps_args = (int *) extra;
10657 hdd_context_t *hdd_ctx;
10658 int ret, num_args;
10659
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010660 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010662 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10663 ret = wlan_hdd_validate_context(hdd_ctx);
10664 if (0 != ret)
10665 return ret;
10666
Jeff Johnson441e1f72017-02-07 08:50:49 -080010667 ret = hdd_check_private_wext_control(hdd_ctx, info);
10668 if (0 != ret)
10669 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010670
10671 sub_cmd = wrqu->data.flags;
10672 num_args = wrqu->data.length;
10673
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010674 hdd_debug("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010675
10676 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010677 case WE_IBSS_GET_PEER_INFO:
10678 {
10679 pr_info("Station ID = %d\n", apps_args[0]);
10680 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
10681 }
10682 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010683
10684 case WE_P2P_NOA_CMD:
10685 {
Srinivas Girigowda5d5fdc52017-03-24 22:30:57 -070010686 struct p2p_app_set_ps p2pNoA;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687
Krunal Sonif07bb382016-03-10 13:02:11 -080010688 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -080010689 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
10690 hdd_device_mode_to_string(
10691 pAdapter->device_mode),
10692 pAdapter->device_mode);
10693 return -EINVAL;
10694 }
10695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010696 p2pNoA.opp_ps = apps_args[0];
10697 p2pNoA.ctWindow = apps_args[1];
10698 p2pNoA.duration = apps_args[2];
10699 p2pNoA.interval = apps_args[3];
10700 p2pNoA.count = apps_args[4];
10701 p2pNoA.single_noa_duration = apps_args[5];
10702 p2pNoA.psSelection = apps_args[6];
10703
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010704 hdd_debug("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
Jeff Johnson99bac312016-06-28 10:38:18 -070010705 apps_args[0], apps_args[1], apps_args[2],
10706 apps_args[3], apps_args[4],
10707 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010708
10709 hdd_set_p2p_ps(dev, &p2pNoA);
10710
10711 }
10712 break;
10713
10714 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
10715 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010716 hdd_debug("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
Jeff Johnson99bac312016-06-28 10:38:18 -070010717 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010718 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010719 }
10720 break;
10721
10722 case WE_MTRACE_DUMP_CMD:
10723 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010724 hdd_debug("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
Jeff Johnson99bac312016-06-28 10:38:18 -070010725 apps_args[0], apps_args[1],
10726 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010727 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010728 apps_args[1], apps_args[2],
10729 apps_args[3]);
10730
10731 }
10732 break;
10733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010734 case WE_POLICY_MANAGER_CINFO_CMD:
10735 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010736 struct policy_mgr_conc_connection_info *conn_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010737 uint32_t i = 0, len = 0;
10738
Krunal Sonia6e505b2017-01-12 12:25:18 -080010739 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010740 conn_info = policy_mgr_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010741 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010742 for (i = 0; i < len; i++) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010743 pr_info("|table_index[%d]\t\t\n", i);
10744 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
10745 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
10746 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
10747 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
10748 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
10749 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
10750 pr_info("+--------------------------+\n");
10751 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010752 }
10753 }
10754 break;
10755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010756
10757#ifdef FEATURE_WLAN_TDLS
10758 case WE_TDLS_CONFIG_PARAMS:
10759 {
10760 tdls_config_params_t tdlsParams;
10761
10762 tdlsParams.tdls = apps_args[0];
10763 tdlsParams.tx_period_t = apps_args[1];
10764 tdlsParams.tx_packet_n = apps_args[2];
10765 /* ignore args[3] as discovery_period is not used anymore */
10766 tdlsParams.discovery_tries_n = apps_args[4];
10767 /* ignore args[5] as idle_timeout is not used anymore */
10768 tdlsParams.idle_packet_n = apps_args[6];
10769 /* ignore args[7] as rssi_hysteresis is not used anymore */
10770 tdlsParams.rssi_trigger_threshold = apps_args[8];
10771 tdlsParams.rssi_teardown_threshold = apps_args[9];
10772 tdlsParams.rssi_delta = apps_args[10];
10773
10774 wlan_hdd_tdls_set_params(dev, &tdlsParams);
10775 }
10776 break;
10777#endif
10778 case WE_UNIT_TEST_CMD:
10779 {
10780 t_wma_unit_test_cmd *unitTestArgs;
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010781 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010782 int i, j;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010783
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010784 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
10785 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010786 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010787 apps_args[0]);
10788 return -EINVAL;
10789 }
Anurag Chouhan77564182016-09-03 16:38:01 +053010790 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
10791 (apps_args[1] < 0)) {
10792 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010793 apps_args[1]);
10794 return -EINVAL;
10795 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010796 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010797 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010798 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010799 return -ENOMEM;
10800 }
10801 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
10802 unitTestArgs->module_id = apps_args[0];
10803 unitTestArgs->num_args = apps_args[1];
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010804 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010805 unitTestArgs->args[i] = apps_args[j];
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010807 msg.type = SIR_HAL_UNIT_TEST_CMD;
10808 msg.reserved = 0;
10809 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010810 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010811 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010812 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -070010813 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010814 return -EINVAL;
10815 }
10816 }
10817 break;
10818#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
10819 case WE_LED_FLASHING_PARAM:
10820 {
10821 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010823 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010824 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010825 return -EINVAL;
10826 }
10827 for (i = 0; i < num_args; i++) {
10828 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010829 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010830 return -EINVAL;
10831 }
10832 }
10833 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10834 0, apps_args[0], apps_args[1]);
10835 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10836 1, apps_args[2], apps_args[3]);
10837 }
10838 break;
10839#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010840 case WE_SET_PKTLOG:
10841 {
10842 int ret;
10843
10844 if (num_args < 1 || num_args > 2) {
10845 hdd_err("pktlog: either 1 or 2 parameters are required");
10846 return -EINVAL;
10847 }
10848
10849 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
10850 apps_args[1]);
10851 if (ret)
10852 return ret;
10853 break;
10854 }
10855
Manjeet Singhf82ed072016-07-08 11:40:00 +053010856 case WE_MAC_PWR_DEBUG_CMD:
10857 {
10858 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
10859 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10860 int i, j;
10861
10862 if (num_args < 3) {
10863 hdd_err("number of arguments can't be null %d",
10864 num_args);
10865 return -EINVAL;
10866 }
10867 if (num_args - 3 != apps_args[2]) {
10868 hdd_err("arg list of size %d doesn't match num_args %d",
10869 num_args-3, apps_args[2]);
10870 return -EINVAL;
10871 }
10872 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
10873 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
10874 hdd_err("Invalid MODULE ID %d", apps_args[1]);
10875 return -EINVAL;
10876 }
10877 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
10878 hdd_err("Too Many args %d", apps_args[2]);
10879 return -EINVAL;
10880 }
10881 mac_pwr_dbg_args.pdev_id = apps_args[0];
10882 mac_pwr_dbg_args.module_id = apps_args[1];
10883 mac_pwr_dbg_args.num_args = apps_args[2];
10884
10885 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
10886 mac_pwr_dbg_args.args[i] = apps_args[j];
10887
10888 if (QDF_STATUS_SUCCESS !=
10889 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
10890 &mac_pwr_dbg_args)) {
10891 return -EINVAL;
10892 }
10893 }
10894 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -080010895 case WE_POLICY_MANAGER_CLIST_CMD:
10896 case WE_POLICY_MANAGER_DLIST_CMD:
10897 case WE_POLICY_MANAGER_ULIST_CMD:
10898 case WE_POLICY_MANAGER_DBS_CMD:
10899 case WE_POLICY_MANAGER_PCL_CMD:
10900 case WE_POLICY_SET_HW_MODE_CMD:
10901 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10902 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10903 case WE_POLICY_MANAGER_SCENARIO_CMD:
10904 {
10905 iw_get_policy_manager_ut_ops(hdd_ctx, pAdapter,
10906 sub_cmd, apps_args);
10907 }
10908 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010909 default:
10910 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010911 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010912 }
10913 break;
10914 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010915 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010916 return 0;
10917}
10918
10919/**
10920 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
10921 * @dev: pointer to net_device structure
10922 * @info: pointer to iw_request_info structure
10923 * @wrqu: pointer to iwreq_data
10924 * @extra; extra
10925 *
10926 * Return: 0 on success, error number otherwise
10927 *
10928 */
10929static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
10930 struct iw_request_info *info,
10931 union iwreq_data *wrqu, char *extra)
10932{
10933 union iwreq_data u_priv_wrqu;
10934 int apps_args[MAX_VAR_ARGS] = {0};
10935 int ret, num_args;
10936
Mukul Sharma64a70e82015-11-02 20:05:09 +053010937 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010938 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +053010939 return -EPERM;
10940 }
10941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010942 /* Helper function to get iwreq_data with compat handling. */
10943 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
10944 return -EINVAL;
10945
10946 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010947 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010948 return -EINVAL;
10949 }
10950
10951 num_args = u_priv_wrqu.data.length;
10952 if (num_args > MAX_VAR_ARGS)
10953 num_args = MAX_VAR_ARGS;
10954
10955 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
10956 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010957 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010958 return -EFAULT;
10959 }
10960
10961 cds_ssr_protect(__func__);
10962 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
10963 (char *)&apps_args);
10964 cds_ssr_unprotect(__func__);
10965 return ret;
10966}
10967
10968/**
10969 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10970 * @dev: device upon which the ioctl was received
10971 * @info: ioctl request information
10972 * @wrqu: ioctl request data
10973 * @extra: ioctl extra data
10974 *
10975 * This is a generic handler for private ioctls which take multiple
10976 * arguments. Note that this implementation is also somewhat unique
10977 * in that it is shared by both STA-mode and SAP-mode interfaces.
10978 *
10979 * Return: 0 on success, non-zero on error
10980 */
10981int iw_set_var_ints_getnone(struct net_device *dev,
10982 struct iw_request_info *info,
10983 union iwreq_data *wrqu, char *extra)
10984{
10985 int ret;
10986
10987 cds_ssr_protect(__func__);
10988 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
10989 cds_ssr_unprotect(__func__);
10990 return ret;
10991}
10992
10993/**
10994 * iw_add_tspec - Add TSpec private ioctl handler
10995 * @dev: device upon which the ioctl was received
10996 * @info: ioctl request information
10997 * @wrqu: ioctl request data
10998 * @extra: ioctl extra data
10999 *
11000 * Return: 0 on success, non-zero on error
11001 */
11002static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
11003 union iwreq_data *wrqu, char *extra)
11004{
11005 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11006 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11007 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11008 int params[HDD_WLAN_WMM_PARAM_COUNT];
11009 sme_QosWmmTspecInfo tSpec;
11010 uint32_t handle;
11011 struct iw_point s_priv_data;
11012 hdd_context_t *hdd_ctx;
11013 int ret;
11014
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011015 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011016
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011017 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11018 ret = wlan_hdd_validate_context(hdd_ctx);
11019 if (0 != ret)
11020 return ret;
11021
Jeff Johnson441e1f72017-02-07 08:50:49 -080011022 ret = hdd_check_private_wext_control(hdd_ctx, info);
11023 if (0 != ret)
11024 return ret;
11025
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011026 /* make sure the application is sufficiently priviledged */
11027 /* note that the kernel will do this for "set" ioctls, but since */
11028 /* this ioctl wants to return status to user space it must be */
11029 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011030 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011031 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011032
11033 /* we must be associated in order to add a tspec */
11034 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
11035 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11036 return 0;
11037 }
11038 /* since we are defined to be a "get" ioctl, and since the number */
11039 /* of params exceeds the number of params that wireless extensions */
11040 /* will pass down in the iwreq_data, we must copy the "set" params. */
11041 /* We must handle the compat for iwreq_data in 32U/64K environment. */
11042
11043 /* helper function to get iwreq_data with compat handling. */
11044 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
11045 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11046 return 0;
11047 }
11048 /* make sure all params are correctly passed to function */
11049 if ((NULL == s_priv_data.pointer) ||
11050 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
11051 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11052 return 0;
11053 }
11054 /* from user space ourselves */
11055 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
11056 /* hmmm, can't get them */
11057 return -EIO;
11058 }
11059 /* clear the tspec */
11060 memset(&tSpec, 0, sizeof(tSpec));
11061
11062 /* validate the handle */
11063 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11064 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11065 /* that one is reserved */
11066 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11067 return 0;
11068 }
11069 /* validate the TID */
11070 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
11071 /* out of range */
11072 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11073 return 0;
11074 }
11075 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
11076
11077 /* validate the direction */
11078 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
11079 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
11080 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
11081 break;
11082
11083 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
11084 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
11085 break;
11086
11087 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
11088 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
11089 break;
11090
11091 default:
11092 /* unknown */
11093 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11094 return 0;
11095 }
11096
11097 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
11098
11099 /* validate the user priority */
11100 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
11101 /* out of range */
11102 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11103 return 0;
11104 }
11105 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
11106 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011107 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011108 return 0;
11109 }
11110
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011111 hdd_debug("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011112 tSpec.ts_info.psb, tSpec.ts_info.up);
11113
11114 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
11115 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
11116 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
11117 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
11118 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
11119 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
11120 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
11121 tSpec.surplus_bw_allowance =
11122 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
11123 tSpec.min_service_interval =
11124 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
11125 tSpec.max_service_interval =
11126 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
11127 tSpec.suspension_interval =
11128 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
11129 tSpec.inactivity_interval =
11130 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
11131
11132 tSpec.ts_info.burst_size_defn =
11133 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
11134
11135 /* validate the ts info ack policy */
11136 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
11137 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
11138 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
11139 break;
11140
11141 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
11142 tSpec.ts_info.ack_policy =
11143 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
11144 break;
11145
11146 default:
11147 /* unknown */
11148 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11149 return 0;
11150 }
11151
11152 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011153 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011154 return 0;
11155}
11156
11157static int iw_add_tspec(struct net_device *dev,
11158 struct iw_request_info *info,
11159 union iwreq_data *wrqu, char *extra)
11160{
11161 int ret;
11162
11163 cds_ssr_protect(__func__);
11164 ret = __iw_add_tspec(dev, info, wrqu, extra);
11165 cds_ssr_unprotect(__func__);
11166
11167 return ret;
11168}
11169
11170/**
11171 * iw_del_tspec - Delete TSpec private ioctl handler
11172 * @dev: device upon which the ioctl was received
11173 * @info: ioctl request information
11174 * @wrqu: ioctl request data
11175 * @extra: ioctl extra data
11176 *
11177 * Return: 0 on success, non-zero on error
11178 */
11179static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
11180 union iwreq_data *wrqu, char *extra)
11181{
11182 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11183 hdd_context_t *hdd_ctx;
11184 int *params = (int *)extra;
11185 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11186 uint32_t handle;
11187 int ret;
11188
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011189 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011190
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011191 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11192 ret = wlan_hdd_validate_context(hdd_ctx);
11193 if (0 != ret)
11194 return ret;
11195
Jeff Johnson441e1f72017-02-07 08:50:49 -080011196 ret = hdd_check_private_wext_control(hdd_ctx, info);
11197 if (0 != ret)
11198 return ret;
11199
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011200 /* make sure the application is sufficiently priviledged */
11201 /* note that the kernel will do this for "set" ioctls, but since */
11202 /* this ioctl wants to return status to user space it must be */
11203 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011204 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011205 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011206
11207 /* although we are defined to be a "get" ioctl, the params we require */
11208 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11209 /* is no need to copy the params from user space */
11210
11211 /* validate the handle */
11212 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11213 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11214 /* that one is reserved */
11215 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11216 return 0;
11217 }
11218
11219 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011220 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011221 return 0;
11222}
11223
11224static int iw_del_tspec(struct net_device *dev,
11225 struct iw_request_info *info,
11226 union iwreq_data *wrqu, char *extra)
11227{
11228 int ret;
11229
11230 cds_ssr_protect(__func__);
11231 ret = __iw_del_tspec(dev, info, wrqu, extra);
11232 cds_ssr_unprotect(__func__);
11233
11234 return ret;
11235}
11236
11237/**
11238 * iw_get_tspec - Get TSpec private ioctl handler
11239 * @dev: device upon which the ioctl was received
11240 * @info: ioctl request information
11241 * @wrqu: ioctl request data
11242 * @extra: ioctl extra data
11243 *
11244 * Return: 0 on success, non-zero on error
11245 */
11246static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
11247 union iwreq_data *wrqu, char *extra)
11248{
11249 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11250 hdd_context_t *hdd_ctx;
11251 int *params = (int *)extra;
11252 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11253 uint32_t handle;
11254 int ret;
11255
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011256 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011258 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11259 ret = wlan_hdd_validate_context(hdd_ctx);
11260 if (0 != ret)
11261 return ret;
11262
Jeff Johnson441e1f72017-02-07 08:50:49 -080011263 ret = hdd_check_private_wext_control(hdd_ctx, info);
11264 if (0 != ret)
11265 return ret;
11266
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011267 /* although we are defined to be a "get" ioctl, the params we require */
11268 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11269 /* is no need to copy the params from user space */
11270
11271 /* validate the handle */
11272 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11273 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11274 /* that one is reserved */
11275 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11276 return 0;
11277 }
11278
11279 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011280 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011281 return 0;
11282}
11283
11284static int iw_get_tspec(struct net_device *dev,
11285 struct iw_request_info *info,
11286 union iwreq_data *wrqu, char *extra)
11287{
11288 int ret;
11289
11290 cds_ssr_protect(__func__);
11291 ret = __iw_get_tspec(dev, info, wrqu, extra);
11292 cds_ssr_unprotect(__func__);
11293
11294 return ret;
11295}
11296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011297/**
11298 * iw_set_fties - Set FT IEs private ioctl handler
11299 * @dev: device upon which the ioctl was received
11300 * @info: ioctl request information
11301 * @wrqu: ioctl request data
11302 * @extra: ioctl extra data
11303 *
11304 * Each time the supplicant has the auth_request or reassoc request
11305 * IEs ready they are pushed to the driver. The driver will in turn
11306 * use it to send out the auth req and reassoc req for 11r FT Assoc.
11307 *
11308 * Return: 0 on success, non-zero on error
11309 */
11310static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
11311 union iwreq_data *wrqu, char *extra)
11312{
11313 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11314 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11315 hdd_context_t *hdd_ctx;
11316 int ret;
11317
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011318 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011320 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11321 ret = wlan_hdd_validate_context(hdd_ctx);
11322 if (0 != ret)
11323 return ret;
11324
Jeff Johnson441e1f72017-02-07 08:50:49 -080011325 ret = hdd_check_private_wext_control(hdd_ctx, info);
11326 if (0 != ret)
11327 return ret;
11328
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011329 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011330 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011331 return -EINVAL;
11332 }
11333 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011334 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011335 return -EINVAL;
11336 }
11337 /* Added for debug on reception of Re-assoc Req. */
11338 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011339 hdd_debug("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011340 wrqu->data.length);
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011341 hdd_debug("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011342 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011343 hdd_debug("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011344
11345 /* Pass the received FT IEs to SME */
11346 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
11347 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011348 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011349 return 0;
11350}
11351
11352static int iw_set_fties(struct net_device *dev,
11353 struct iw_request_info *info,
11354 union iwreq_data *wrqu, char *extra)
11355{
11356 int ret;
11357
11358 cds_ssr_protect(__func__);
11359 ret = __iw_set_fties(dev, info, wrqu, extra);
11360 cds_ssr_unprotect(__func__);
11361
11362 return ret;
11363}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011364
Dustin Brown0cbc7572016-12-16 13:54:40 -080011365/**
11366 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
11367 * @dev: device upon which the ioctl was received
11368 * @info: ioctl request information
11369 * @wrqu: ioctl request data
11370 * @extra: ioctl extra data
11371 *
Dustin Brown860566f2017-01-31 15:24:43 -080011372 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
11373 * time being to provide guidance in migrating to standard APIs.
11374 *
Dustin Brown0cbc7572016-12-16 13:54:40 -080011375 * Return: 0 on success, non-zero on error
11376 */
11377static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
11378 struct iw_request_info *info,
11379 union iwreq_data *wrqu,
11380 char *extra)
11381{
Dustin Brown860566f2017-01-31 15:24:43 -080011382 hdd_err("\n"
11383 "setMCBCFilter is obsolete. Use the following instead:\n"
11384 "Configure multicast filtering via the ‘ip’ command.\n"
11385 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
11386 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
11387 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
11388 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
11389 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Mukul Sharma3ba26b82017-01-12 21:59:41 +053011390 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -080011391}
11392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011393/**
11394 * iw_set_host_offload - Set host offload ioctl handler
11395 * @dev: device upon which the ioctl was received
11396 * @info: ioctl request information
11397 * @wrqu: ioctl request data
11398 * @extra: ioctl extra data
11399 *
11400 * Return: 0 on success, non-zero on error
11401 */
11402static int __iw_set_host_offload(struct net_device *dev,
11403 struct iw_request_info *info,
11404 union iwreq_data *wrqu, char *extra)
11405{
11406 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowda077143e2017-03-25 10:47:27 -070011407 struct host_offload_req *pRequest = (struct host_offload_req *) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011408 tSirHostOffloadReq offloadRequest;
11409 hdd_context_t *hdd_ctx;
11410 int ret;
11411
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011412 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011413
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011414 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11415 ret = wlan_hdd_validate_context(hdd_ctx);
11416 if (0 != ret)
11417 return ret;
11418
Jeff Johnson441e1f72017-02-07 08:50:49 -080011419 ret = hdd_check_private_wext_control(hdd_ctx, info);
11420 if (0 != ret)
11421 return ret;
11422
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011423 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011424 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011425 return -EINVAL;
11426 }
11427
11428 /* Debug display of request components. */
11429 switch (pRequest->offloadType) {
11430 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011431 hdd_debug("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011432 switch (pRequest->enableOrDisable) {
11433 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011434 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011435 break;
11436 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011437 hdd_debug(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011438 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011439 hdd_debug(" ARP offload enable");
11440 hdd_debug(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011441 pRequest->params.hostIpv4Addr[0],
11442 pRequest->params.hostIpv4Addr[1],
11443 pRequest->params.hostIpv4Addr[2],
11444 pRequest->params.hostIpv4Addr[3]);
11445 }
11446 break;
11447
11448 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011449 hdd_debug("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011450 switch (pRequest->enableOrDisable) {
11451 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011452 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011453 break;
11454 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011455 hdd_debug(" enable");
11456 hdd_debug(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011457 *(uint16_t *) (pRequest->params.hostIpv6Addr),
11458 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11459 2),
11460 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11461 4),
11462 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11463 6),
11464 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11465 8),
11466 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11467 10),
11468 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11469 12),
11470 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11471 14));
11472 }
11473 }
11474
11475 /* Execute offload request. The reason that we can copy the
11476 * request information from the ioctl structure to the SME
11477 * structure is that they are laid out exactly the same.
11478 * Otherwise, each piece of information would have to be
11479 * copied individually.
11480 */
11481 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011482 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011483 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
11484 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011485 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011486 return -EINVAL;
11487 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011488 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011489 return 0;
11490}
11491
11492static int iw_set_host_offload(struct net_device *dev,
11493 struct iw_request_info *info,
11494 union iwreq_data *wrqu, char *extra)
11495{
11496 int ret;
11497
11498 cds_ssr_protect(__func__);
11499 ret = __iw_set_host_offload(dev, info, wrqu, extra);
11500 cds_ssr_unprotect(__func__);
11501
11502 return ret;
11503}
11504
11505/**
11506 * iw_set_keepalive_params - Set keepalive params ioctl handler
11507 * @dev: device upon which the ioctl was received
11508 * @info: ioctl request information
11509 * @wrqu: ioctl request data
11510 * @extra: ioctl extra data
11511 *
11512 * Return: 0 on success, non-zero on error
11513 */
11514static int __iw_set_keepalive_params(struct net_device *dev,
11515 struct iw_request_info *info,
11516 union iwreq_data *wrqu, char *extra)
11517{
11518 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011519 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011520 hdd_context_t *hdd_ctx;
11521 int ret;
11522
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011523 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011524
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011525 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11526 ret = wlan_hdd_validate_context(hdd_ctx);
11527 if (0 != ret)
11528 return ret;
11529
Jeff Johnson441e1f72017-02-07 08:50:49 -080011530 ret = hdd_check_private_wext_control(hdd_ctx, info);
11531 if (0 != ret)
11532 return ret;
11533
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011534 if (wrqu->data.length != sizeof(*request)) {
11535 hdd_err("Invalid length %d", wrqu->data.length);
11536 return -EINVAL;
11537 }
11538
11539 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
11540 hdd_err("Value of timePeriod %d exceed Max limit %d",
11541 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011542 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
11543 return -EINVAL;
11544 }
11545
11546 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011547 hdd_debug("Set Keep Alive Request : TimePeriod %d size %zu",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011548 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011549
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011550 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011551 case WLAN_KEEP_ALIVE_NULL_PKT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011552 hdd_debug("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011553 break;
11554
11555 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011556 hdd_debug("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011557
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011558 hdd_debug("Host IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011559 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
11560 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011561
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011562 hdd_debug("Dest IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011563 request->destIpv4Addr[0], request->destIpv4Addr[1],
11564 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011565
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011566 hdd_debug("Dest MAC address: "MAC_ADDRESS_STR,
Srinivas Girigowda9c330a92015-11-24 12:28:25 -080011567 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011568 break;
11569 }
11570
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011571 hdd_debug("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011572
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011573 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011574 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011575 pAdapter->sessionId, request)) {
11576 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011577 return -EINVAL;
11578 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011579 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011580 return 0;
11581}
11582
11583static int iw_set_keepalive_params(struct net_device *dev,
11584 struct iw_request_info *info,
11585 union iwreq_data *wrqu,
11586 char *extra)
11587{
11588 int ret;
11589
11590 cds_ssr_protect(__func__);
11591 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
11592 cds_ssr_unprotect(__func__);
11593
11594 return ret;
11595}
11596
11597#ifdef WLAN_FEATURE_PACKET_FILTERING
11598/**
11599 * wlan_hdd_set_filter() - Set packet filter
11600 * @hdd_ctx: Global HDD context
11601 * @request: Packet filter request struct
11602 * @sessionId: Target session for the request
11603 *
11604 * Return: 0 on success, non-zero on error
11605 */
11606static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
11607 struct pkt_filter_cfg *request,
11608 uint8_t sessionId)
11609{
11610 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
11611 tSirRcvFltPktClearParam packetFilterClrReq = {0};
11612 int i = 0;
11613
11614 if (hdd_ctx->config->disablePacketFilter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011615 hdd_warn("Packet filtering disabled in ini");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011616 return 0;
11617 }
11618
11619 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011620 hdd_debug("Packet Filter Request : FA %d params %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011621 request->filter_action, request->num_params);
11622
11623 switch (request->filter_action) {
11624 case HDD_RCV_FILTER_SET:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011625 hdd_debug("Set Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011626 request->filter_id);
11627
11628 packetFilterSetReq.filterId = request->filter_id;
11629 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
11630 hdd_err("Number of Params exceed Max limit %d",
11631 request->num_params);
11632 return -EINVAL;
11633 }
11634 packetFilterSetReq.numFieldParams = request->num_params;
11635 packetFilterSetReq.coalesceTime = 0;
11636 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
11637 for (i = 0; i < request->num_params; i++) {
11638 packetFilterSetReq.paramsData[i].protocolLayer =
11639 request->params_data[i].protocol_layer;
11640 packetFilterSetReq.paramsData[i].cmpFlag =
11641 request->params_data[i].compare_flag;
11642 packetFilterSetReq.paramsData[i].dataOffset =
11643 request->params_data[i].data_offset;
11644 packetFilterSetReq.paramsData[i].dataLength =
11645 request->params_data[i].data_length;
11646 packetFilterSetReq.paramsData[i].reserved = 0;
11647
Dustin Brown4d1e8462016-12-14 12:12:24 -080011648 if (request->params_data[i].data_offset >
11649 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
11650 hdd_err("Invalid data offset %u for param %d (max = %d)",
11651 request->params_data[i].data_offset,
11652 i,
11653 SIR_MAX_FILTER_TEST_DATA_OFFSET);
11654 return -EINVAL;
11655 }
11656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011657 if (request->params_data[i].data_length >
11658 SIR_MAX_FILTER_TEST_DATA_LEN) {
11659 hdd_err("Error invalid data length %d",
11660 request->params_data[i].data_length);
11661 return -EINVAL;
11662 }
11663
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011664 hdd_debug("Proto %d Comp Flag %d Filter Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011665 request->params_data[i].protocol_layer,
11666 request->params_data[i].compare_flag,
11667 packetFilterSetReq.filterType);
11668
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011669 hdd_debug("Data Offset %d Data Len %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011670 request->params_data[i].data_offset,
11671 request->params_data[i].data_length);
11672
Rajeev Kumarf5b6da22016-04-15 13:24:03 -070011673 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
11674 < (request->params_data[i].data_length)) {
11675 hdd_err("Error invalid data length %d",
11676 request->params_data[i].data_length);
11677 return -EINVAL;
11678 }
11679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011680 memcpy(&packetFilterSetReq.paramsData[i].compareData,
11681 request->params_data[i].compare_data,
11682 request->params_data[i].data_length);
11683 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
11684 request->params_data[i].data_mask,
11685 request->params_data[i].data_length);
11686
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011687 hdd_debug("CData %d CData %d CData %d CData %d CData %d CData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011688 request->params_data[i].compare_data[0],
11689 request->params_data[i].compare_data[1],
11690 request->params_data[i].compare_data[2],
11691 request->params_data[i].compare_data[3],
11692 request->params_data[i].compare_data[4],
11693 request->params_data[i].compare_data[5]);
11694
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011695 hdd_debug("MData %d MData %d MData %d MData %d MData %d MData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011696 request->params_data[i].data_mask[0],
11697 request->params_data[i].data_mask[1],
11698 request->params_data[i].data_mask[2],
11699 request->params_data[i].data_mask[3],
11700 request->params_data[i].data_mask[4],
11701 request->params_data[i].data_mask[5]);
11702 }
11703
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011704 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011705 sme_receive_filter_set_filter(hdd_ctx->hHal,
11706 &packetFilterSetReq,
11707 sessionId)) {
11708 hdd_err("Failure to execute Set Filter");
11709 return -EINVAL;
11710 }
11711
11712 break;
11713
11714 case HDD_RCV_FILTER_CLEAR:
11715
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011716 hdd_debug("Clear Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011717 request->filter_id);
11718 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011719 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011720 sme_receive_filter_clear_filter(hdd_ctx->hHal,
11721 &packetFilterClrReq,
11722 sessionId)) {
11723 hdd_err("Failure to execute Clear Filter");
11724 return -EINVAL;
11725 }
11726 break;
11727
11728 default:
11729 hdd_err("Packet Filter Request: Invalid %d",
11730 request->filter_action);
11731 return -EINVAL;
11732 }
11733 return 0;
11734}
11735
11736/**
11737 * __iw_set_packet_filter_params() - set packet filter parameters in target
11738 * @dev: Pointer to netdev
11739 * @info: Pointer to iw request info
11740 * @wrqu: Pointer to data
11741 * @extra: Pointer to extra data
11742 *
11743 * Return: 0 on success, non-zero on error
11744 */
11745static int __iw_set_packet_filter_params(struct net_device *dev,
11746 struct iw_request_info *info,
11747 union iwreq_data *wrqu, char *extra)
11748{
11749 int ret;
11750 hdd_context_t *hdd_ctx;
11751 struct iw_point priv_data;
11752 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
11753 struct pkt_filter_cfg *request = NULL;
11754
Mukul Sharma472382f2015-11-02 20:16:31 +053011755 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011756 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +053011757 return -EPERM;
11758 }
11759
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011760 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011761
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011762 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11763 ret = wlan_hdd_validate_context(hdd_ctx);
11764 if (0 != ret)
11765 return ret;
11766
Jeff Johnson441e1f72017-02-07 08:50:49 -080011767 ret = hdd_check_private_wext_control(hdd_ctx, info);
11768 if (0 != ret)
11769 return ret;
11770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011771 if (hdd_priv_get_data(&priv_data, wrqu)) {
11772 hdd_err("failed to get priv data");
11773 return -EINVAL;
11774 }
11775
11776 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
11777 hdd_err("invalid priv data %p or invalid priv data length %d",
11778 priv_data.pointer, priv_data.length);
11779 return -EINVAL;
11780 }
11781
11782 /* copy data using copy_from_user */
11783 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
11784 priv_data.length);
11785 if (NULL == request) {
11786 hdd_err("mem_alloc_copy_from_user_helper fail");
11787 return -ENOMEM;
11788 }
11789
11790 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
11791
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -070011792 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011793 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011794 return ret;
11795}
11796
11797/**
11798 * iw_set_packet_filter_params() - set packet filter parameters in target
11799 * @dev: Pointer to netdev
11800 * @info: Pointer to iw request info
11801 * @wrqu: Pointer to data
11802 * @extra: Pointer to extra data
11803 *
11804 * Return: 0 on success, non-zero on error
11805 */
11806static int iw_set_packet_filter_params(struct net_device *dev,
11807 struct iw_request_info *info,
11808 union iwreq_data *wrqu, char *extra)
11809{
11810 int ret;
11811
11812 cds_ssr_protect(__func__);
11813 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
11814 cds_ssr_unprotect(__func__);
11815
11816 return ret;
11817}
11818#endif
11819
11820
11821static int __iw_get_statistics(struct net_device *dev,
11822 struct iw_request_info *info,
11823 union iwreq_data *wrqu, char *extra)
11824{
11825
Anurag Chouhance0dc992016-02-16 18:18:03 +053011826 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011827 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011828 hdd_wext_state_t *pWextState;
11829 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11830 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11831 char *p = extra;
11832 int tlen = 0;
11833 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
11834 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
11835 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
11836 int ret;
11837
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011838 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011839
11840 ret = wlan_hdd_validate_context(hdd_ctx);
11841 if (0 != ret)
11842 return ret;
11843
Jeff Johnson441e1f72017-02-07 08:50:49 -080011844 ret = hdd_check_private_wext_control(hdd_ctx, info);
11845 if (0 != ret)
11846 return ret;
11847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011848 if (eConnectionState_Associated !=
11849 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
11850
11851 wrqu->txpower.value = 0;
11852 } else {
11853 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11854 SME_SUMMARY_STATS |
11855 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080011856 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011857 hdd_statistics_cb, 0, false,
11858 (WLAN_HDD_GET_STATION_CTX_PTR
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011859 (pAdapter))->conn_info.staId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011860 pAdapter, pAdapter->sessionId);
11861
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011862 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011863 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011864 return -EINVAL;
11865 }
11866
11867 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11868
Anurag Chouhance0dc992016-02-16 18:18:03 +053011869 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011870 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011871 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011872 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011873 hdd_err("SME timeout while retrieving statistics");
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011874 /* Remove the SME statistics list by
11875 * passing NULL in callback argument
11876 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011877 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11878 SME_SUMMARY_STATS |
11879 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080011880 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011881 NULL, 0, false,
11882 (WLAN_HDD_GET_STATION_CTX_PTR
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011883 (pAdapter))->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011884 staId[0], pAdapter,
11885 pAdapter->sessionId);
11886
11887 return -EINVAL;
11888 }
11889 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
11890 (uint8_t) sizeof(pStats->retry_cnt),
11891 (char *)&(pStats->retry_cnt[0]), tlen);
11892
11893 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
11894 (uint8_t) sizeof(pStats->multiple_retry_cnt),
11895 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
11896
11897 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
11898 (uint8_t) sizeof(pStats->tx_frm_cnt),
11899 (char *)&(pStats->tx_frm_cnt[0]), tlen);
11900
11901 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
11902 (uint8_t) sizeof(pStats->rx_frm_cnt),
11903 (char *)&(pStats->rx_frm_cnt), tlen);
11904
11905 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
11906 (uint8_t) sizeof(pStats->frm_dup_cnt),
11907 (char *)&(pStats->frm_dup_cnt), tlen);
11908
11909 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
11910 (uint8_t) sizeof(pStats->fail_cnt),
11911 (char *)&(pStats->fail_cnt[0]), tlen);
11912
11913 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
11914 (uint8_t) sizeof(pStats->rts_fail_cnt),
11915 (char *)&(pStats->rts_fail_cnt), tlen);
11916
11917 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
11918 (uint8_t) sizeof(pStats->ack_fail_cnt),
11919 (char *)&(pStats->ack_fail_cnt), tlen);
11920
11921 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
11922 (uint8_t) sizeof(pStats->rts_succ_cnt),
11923 (char *)&(pStats->rts_succ_cnt), tlen);
11924
11925 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
11926 (uint8_t) sizeof(pStats->rx_discard_cnt),
11927 (char *)&(pStats->rx_discard_cnt), tlen);
11928
11929 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
11930 (uint8_t) sizeof(pStats->rx_error_cnt),
11931 (char *)&(pStats->rx_error_cnt), tlen);
11932
11933 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
11934 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11935 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11936
11937 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
11938 (uint8_t) sizeof(dStats->rx_byte_cnt),
11939 (char *)&(dStats->rx_byte_cnt), tlen);
11940
11941 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
11942 (uint8_t) sizeof(dStats->rx_rate),
11943 (char *)&(dStats->rx_rate), tlen);
11944
11945 /* Transmit rate, in units of 500 kbit/sec */
11946 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
11947 (uint8_t) sizeof(aStats->tx_rate),
11948 (char *)&(aStats->tx_rate), tlen);
11949
11950 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
11951 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
11952 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
11953 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
11954 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
11955 (char *)&(dStats->rx_mc_byte_cnt), tlen);
11956 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
11957 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
11958 (char *)&(dStats->rx_bc_byte_cnt), tlen);
11959 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
11960 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11961 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11962 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
11963 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
11964 (char *)&(dStats->tx_mc_byte_cnt), tlen);
11965 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
11966 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
11967 (char *)&(dStats->tx_bc_byte_cnt), tlen);
11968
11969 wrqu->data.length = tlen;
11970
11971 }
11972
11973 EXIT();
11974
11975 return 0;
11976}
11977
11978static int iw_get_statistics(struct net_device *dev,
11979 struct iw_request_info *info,
11980 union iwreq_data *wrqu, char *extra)
11981{
11982 int ret;
11983
11984 cds_ssr_protect(__func__);
11985 ret = __iw_get_statistics(dev, info, wrqu, extra);
11986 cds_ssr_unprotect(__func__);
11987
11988 return ret;
11989}
11990
11991#ifdef FEATURE_WLAN_SCAN_PNO
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011992/*Max Len for PNO notification*/
11993#define MAX_PNO_NOTIFY_LEN 100
Abhishek Singh0481d662017-04-11 18:20:11 +053011994static void found_pref_network_cb(struct wlan_objmgr_vdev *vdev,
11995 struct scan_event *event, void *args)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011996{
Abhishek Singh0481d662017-04-11 18:20:11 +053011997 struct vdev_osif_priv *osif_priv;
11998 struct wireless_dev *wdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011999 union iwreq_data wrqu;
12000 char buf[MAX_PNO_NOTIFY_LEN + 1];
12001
Abhishek Singh0481d662017-04-11 18:20:11 +053012002 wlan_vdev_obj_lock(vdev);
12003 osif_priv = wlan_vdev_get_ospriv(vdev);
12004 wlan_vdev_obj_unlock(vdev);
12005 if (!osif_priv) {
12006 hdd_err("osif_priv is null");
12007 return;
12008 }
12009
12010 wdev = osif_priv->wdev;
12011 if (!wdev) {
12012 hdd_err("wdev is null");
12013 return;
12014 }
12015
12016 hdd_debug("A preferred network was found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012017
12018 /* create the event */
Abhishek Singh0481d662017-04-11 18:20:11 +053012019 qdf_mem_zero(&wrqu, sizeof(wrqu));
12020 qdf_mem_zero(buf, sizeof(buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012021
12022 snprintf(buf, MAX_PNO_NOTIFY_LEN,
Abhishek Singh0481d662017-04-11 18:20:11 +053012023 "QCOM: Found preferred network:");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012024
12025 wrqu.data.pointer = buf;
12026 wrqu.data.length = strlen(buf);
12027
12028 /* send the event */
12029
Abhishek Singh0481d662017-04-11 18:20:11 +053012030 wireless_send_event(wdev->netdev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012031}
12032
12033/**
12034 * __iw_set_pno() - Preferred Network Offload ioctl handler
12035 * @dev: device upon which the ioctl was received
12036 * @info: ioctl request information
12037 * @wrqu: ioctl request data
12038 * @extra: ioctl extra data
12039 *
12040 * This function parses a Preferred Network Offload command
12041 * Input is string based and expected to be of the form:
12042 *
12043 * <enable(1) | disable(0)>
12044 * when enabling:
12045 * <number of networks>
12046 * for each network:
12047 * <ssid_len> <ssid> <authentication> <encryption>
12048 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070012049 * <scan_time (seconds)>
12050 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012051 * <suspend mode>
12052 *
12053 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070012054 * 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 -080012055 *
12056 * this translates into:
12057 * -----------------------------
12058 * enable PNO
12059 * 2 networks
12060 * Network 1:
12061 * test - with authentication type 0 and encryption type 0,
12062 * search on 3 channels: 1 6 and 11,
12063 * SSID bcast type is unknown (directed probe will be sent if
12064 * AP not found) and must meet -40dBm RSSI
12065 * Network 2:
12066 * test2 - with authentication type 4 and encryption type 4,
12067 * search on 6 channels 1, 2, 3, 4, 5 and 6
12068 * bcast type is non-bcast (directed probe will be sent)
12069 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012070 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070012071 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012072 */
12073static int __iw_set_pno(struct net_device *dev,
12074 struct iw_request_info *info,
12075 union iwreq_data *wrqu, char *extra)
12076{
12077 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12078 hdd_context_t *hdd_ctx;
Abhishek Singh0481d662017-04-11 18:20:11 +053012079 uint8_t value;
12080 struct wlan_objmgr_vdev *vdev;
12081 struct wlan_objmgr_psoc *psoc;
12082 int ret = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012083 int offset;
12084 char *ptr;
Abhishek Singh0481d662017-04-11 18:20:11 +053012085 uint8_t i, j, params;
12086 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012087
12088 /* request is a large struct, so we make it static to avoid
12089 * stack overflow. This API is only invoked via ioctl, so it
12090 * is serialized by the kernel rtnl_lock and hence does not
12091 * need to be reentrant
12092 */
Abhishek Singh0481d662017-04-11 18:20:11 +053012093 static struct pno_scan_req_params req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012094
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012095 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012096
12097 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12098 ret = wlan_hdd_validate_context(hdd_ctx);
12099 if (ret)
12100 return ret;
12101
Jeff Johnson441e1f72017-02-07 08:50:49 -080012102 ret = hdd_check_private_wext_control(hdd_ctx, info);
12103 if (0 != ret)
12104 return ret;
12105
Abhishek Singh0481d662017-04-11 18:20:11 +053012106 vdev = wlan_objmgr_get_vdev_by_macaddr_from_pdev(hdd_ctx->hdd_pdev,
12107 dev->dev_addr, WLAN_LEGACY_MAC_ID);
12108 if (!vdev) {
12109 hdd_err("vdev object is NULL");
12110 return -EIO;
12111 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012112
Abhishek Singh0481d662017-04-11 18:20:11 +053012113 hdd_debug("PNO data len %d data %s", wrqu->data.length, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012114
12115 ptr = extra;
12116
Abhishek Singh0481d662017-04-11 18:20:11 +053012117 if (1 != sscanf(ptr, "%hhu%n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012118 hdd_err("PNO enable input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012119 ret = -EINVAL;
12120 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012121 }
12122
Abhishek Singh0481d662017-04-11 18:20:11 +053012123 if (!value) {
12124 status = ucfg_scan_pno_stop(vdev);
12125 if (QDF_IS_STATUS_ERROR(status)) {
12126 hdd_err("Failed to disabled PNO");
12127 ret = -EINVAL;
12128 } else {
12129 hdd_debug("PNO scan disabled");
12130 }
12131 goto exit;
12132 }
12133
12134 if (ucfg_scan_get_pno_in_progress(vdev)) {
12135 hdd_debug("pno is already in progress");
12136 ret = -EBUSY;
12137 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012138 }
12139
12140 ptr += offset;
12141
Abhishek Singh0481d662017-04-11 18:20:11 +053012142 if (1 != sscanf(ptr, "%hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012143 hdd_err("PNO count input not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012144 ret = -EINVAL;
12145 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012146 }
Abhishek Singh0481d662017-04-11 18:20:11 +053012147 req.networks_cnt = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012148
Abhishek Singh0481d662017-04-11 18:20:11 +053012149 hdd_debug("PNO enable networks count %d offset %d",
12150 req.networks_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012151
Abhishek Singh0481d662017-04-11 18:20:11 +053012152 if ((0 == req.networks_cnt) ||
12153 (req.networks_cnt > SCAN_PNO_MAX_SUPP_NETWORKS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012154 hdd_err("Network count %d invalid",
Abhishek Singh0481d662017-04-11 18:20:11 +053012155 req.networks_cnt);
12156 ret = -EINVAL;
12157 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012158 }
12159
12160 ptr += offset;
12161
Abhishek Singh0481d662017-04-11 18:20:11 +053012162 for (i = 0; i < req.networks_cnt; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012163
Abhishek Singh0481d662017-04-11 18:20:11 +053012164 req.networks_list[i].ssid.length = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012165
12166 params = sscanf(ptr, "%hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012167 &(req.networks_list[i].ssid.length),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012168 &offset);
12169
12170 if (1 != params) {
12171 hdd_err("PNO ssid length input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012172 ret = -EINVAL;
12173 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012174 }
12175
Abhishek Singh0481d662017-04-11 18:20:11 +053012176 if ((0 == req.networks_list[i].ssid.length) ||
12177 (req.networks_list[i].ssid.length > 32)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012178 hdd_err("SSID Len %d is not correct for network %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012179 req.networks_list[i].ssid.length, i);
12180 ret = -EINVAL;
12181 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012182 }
12183
12184 /* Advance to SSID */
12185 ptr += offset;
12186
Abhishek Singh0481d662017-04-11 18:20:11 +053012187 memcpy(req.networks_list[i].ssid.ssid, ptr,
12188 req.networks_list[i].ssid.length);
12189 ptr += req.networks_list[i].ssid.length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012190
12191 params = sscanf(ptr, "%u %u %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012192 &(req.networks_list[i].authentication),
12193 &(req.networks_list[i].encryption),
12194 &(req.networks_list[i].channel_cnt),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012195 &offset);
12196
12197 if (3 != params) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012198 hdd_err("Incorrect cmd %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012199 ret = -EINVAL;
12200 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012201 }
12202
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012203 hdd_debug("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012204 req.networks_list[i].ssid.length,
12205 req.networks_list[i].ssid.length,
12206 req.networks_list[i].ssid.ssid,
12207 req.networks_list[i].authentication,
12208 req.networks_list[i].encryption,
12209 req.networks_list[i].channel_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012210
12211 /* Advance to channel list */
12212 ptr += offset;
12213
Abhishek Singh0481d662017-04-11 18:20:11 +053012214 if (SCAN_PNO_MAX_NETW_CHANNELS_EX <
12215 req.networks_list[i].channel_cnt) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012216 hdd_err("Incorrect number of channels");
Abhishek Singh0481d662017-04-11 18:20:11 +053012217 ret = -EINVAL;
12218 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012219 }
12220
Abhishek Singh0481d662017-04-11 18:20:11 +053012221 if (0 != req.networks_list[i].channel_cnt) {
12222 for (j = 0; j < req.networks_list[i].channel_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012223 j++) {
Abhishek Singh0481d662017-04-11 18:20:11 +053012224 if (1 != sscanf(ptr, "%hhu %n", &value,
12225 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012226 hdd_err("PNO network channel is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012227 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012228 ret = -EINVAL;
12229 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012230 }
Abhishek Singh0481d662017-04-11 18:20:11 +053012231 req.networks_list[i].channels[j] =
12232 cds_chan_to_freq(value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012233 /* Advance to next channel number */
12234 ptr += offset;
12235 }
12236 }
12237
12238 if (1 != sscanf(ptr, "%u %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012239 &(req.networks_list[i].bc_new_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012240 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012241 hdd_err("PNO broadcast network type is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012242 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012243 ret = -EINVAL;
12244 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012245 }
12246
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012247 hdd_debug("PNO bcastNetwType %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012248 req.networks_list[i].bc_new_type, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012249
12250 /* Advance to rssi Threshold */
12251 ptr += offset;
12252 if (1 != sscanf(ptr, "%d %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012253 &(req.networks_list[i].rssi_thresh),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012254 &offset)) {
12255 hdd_err("PNO rssi threshold input is not valid %s",
12256 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012257 ret = -EINVAL;
12258 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012259 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012260 hdd_debug("PNO rssi %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012261 req.networks_list[i].rssi_thresh, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012262 /* Advance to next network */
12263 ptr += offset;
12264 } /* For ucNetworkCount */
12265
Abhishek Singh0481d662017-04-11 18:20:11 +053012266 req.fast_scan_period = 0;
12267 if (sscanf(ptr, "%u %n", &(req.fast_scan_period), &offset) > 0) {
12268 req.fast_scan_period *= MSEC_PER_SEC;
Dustin Brown43e87292016-10-10 10:38:25 -070012269 ptr += offset;
12270 }
12271
Abhishek Singh0481d662017-04-11 18:20:11 +053012272 req.fast_scan_max_cycles = 0;
12273 if (sscanf(ptr, "%hhu %n", &value,
Dustin Brown43e87292016-10-10 10:38:25 -070012274 &offset) > 0)
12275 ptr += offset;
Abhishek Singh0481d662017-04-11 18:20:11 +053012276 req.fast_scan_max_cycles = value;
Dustin Brown43e87292016-10-10 10:38:25 -070012277
Abhishek Singh0481d662017-04-11 18:20:11 +053012278 wlan_pdev_obj_lock(hdd_ctx->hdd_pdev);
12279 psoc = wlan_pdev_get_psoc(hdd_ctx->hdd_pdev);
12280 wlan_pdev_obj_unlock(hdd_ctx->hdd_pdev);
12281 ucfg_scan_register_pno_cb(psoc,
12282 found_pref_network_cb, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012283
Abhishek Singh0481d662017-04-11 18:20:11 +053012284 ucfg_scan_get_pno_def_params(vdev, &req);
12285 status = ucfg_scan_pno_start(vdev, &req);
12286 if (QDF_IS_STATUS_ERROR(status)) {
12287 hdd_err("Failed to enable PNO");
12288 ret = -EINVAL;
12289 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012290
Abhishek Singh0481d662017-04-11 18:20:11 +053012291exit:
12292 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012293
Abhishek Singh0481d662017-04-11 18:20:11 +053012294 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012295}
12296
12297static int iw_set_pno(struct net_device *dev,
12298 struct iw_request_info *info,
12299 union iwreq_data *wrqu, char *extra)
12300{
12301 int ret;
12302
12303 cds_ssr_protect(__func__);
12304 ret = __iw_set_pno(dev, info, wrqu, extra);
12305 cds_ssr_unprotect(__func__);
12306
12307 return ret;
12308}
12309#endif /* FEATURE_WLAN_SCAN_PNO */
12310
12311/* Common function to SetBand */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012312int hdd_reg_set_band(struct net_device *dev, u8 ui_band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012313{
12314 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12315 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012316 enum band_info band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012317
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012318 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012319 hdd_context_t *pHddCtx;
12320 hdd_adapter_list_node_t *pAdapterNode, *pNext;
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012321 enum band_info currBand;
12322 enum band_info connectedBand;
12323 long lrc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012324
12325 pAdapterNode = NULL;
12326 pNext = NULL;
12327 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12328
12329 switch (ui_band) {
12330 case WLAN_HDD_UI_BAND_AUTO:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012331 band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012332 break;
12333 case WLAN_HDD_UI_BAND_5_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012334 band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012335 break;
12336 case WLAN_HDD_UI_BAND_2_4_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012337 band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012338 break;
12339 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070012340 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012341 return -EINVAL;
12342 }
12343
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012344 hdd_debug("change band to %u", band);
12345
12346 if ((band == BAND_2G && pHddCtx->config->nBandCapability == 2) ||
12347 (band == BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012348 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012349 band, pHddCtx->config->nBandCapability);
12350 return -EIO;
12351 }
12352
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012353 if (band == BAND_ALL) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012354 hdd_debug("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012355 pHddCtx->config->nBandCapability);
12356 band = pHddCtx->config->nBandCapability;
12357 }
12358
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012359 if (QDF_STATUS_SUCCESS != ucfg_reg_get_curr_band(pHddCtx->hdd_pdev,
12360 &currBand)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012361 hdd_debug("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012362 return -EIO;
12363 }
12364
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012365 if (currBand == band)
12366 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012367
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012368 /* Change band request received.
12369 * Abort pending scan requests, flush the existing scan results,
12370 * and change the band capability
12371 */
12372 hdd_debug("Current band value = %u, new setting %u ",
12373 currBand, band);
12374
12375 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
12376 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
12377 pAdapter = pAdapterNode->pAdapter;
12378 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12379 wlan_abort_scan(pHddCtx->hdd_pdev, INVAL_PDEV_ID,
Abhishek Singh69ccb512017-04-25 11:58:16 +053012380 pAdapter->sessionId, INVALID_SCAN_ID, false);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012381 connectedBand = hdd_conn_get_connected_band(
12382 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012383
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012384 /* Handling is done only for STA and P2P */
12385 if (band != BAND_ALL &&
12386 ((pAdapter->device_mode == QDF_STA_MODE) ||
12387 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) &&
12388 (hdd_conn_is_connected(
12389 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
12390 && (connectedBand != band)) {
12391 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012392
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012393 /* STA already connected on current
12394 * band, So issue disconnect first,
12395 * then change the band
12396 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012397
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012398 hdd_debug("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012399 hdd_device_mode_to_string(pAdapter->device_mode),
12400 pAdapter->device_mode, currBand, band);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012401 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012402
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012403 status = sme_roam_disconnect(
12404 WLAN_HDD_GET_HAL_CTX(pAdapter),
12405 pAdapter->sessionId,
12406 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012407
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012408 if (QDF_STATUS_SUCCESS != status) {
12409 hdd_err("sme_roam_disconnect failure, status: %d",
Jeff Johnson99bac312016-06-28 10:38:18 -070012410 (int)status);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012411 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012412 }
12413
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012414 lrc = wait_for_completion_timeout(
12415 &pAdapter->disconnect_comp_var,
12416 msecs_to_jiffies(
12417 WLAN_WAIT_TIME_DISCONNECT));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012418
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012419 if (lrc == 0) {
12420 hdd_err("Timeout while waiting for csr_roam_disconnect");
12421 return -ETIMEDOUT;
12422 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012423 }
12424
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012425 sme_scan_flush_result(hHal);
12426
12427 status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
12428 pAdapterNode = pNext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012429 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012430
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012431 if (QDF_STATUS_SUCCESS !=
12432 ucfg_reg_set_band(pHddCtx->hdd_pdev, band)) {
12433 hdd_err("Failed to set the band value to %u",
12434 band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012435 return -EINVAL;
12436 }
12437
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012438 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012439}
12440
12441static int __iw_set_band_config(struct net_device *dev,
12442 struct iw_request_info *info,
12443 union iwreq_data *wrqu, char *extra)
12444{
Jeff Johnson441e1f72017-02-07 08:50:49 -080012445 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12446 hdd_context_t *hdd_ctx;
12447 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012448 int *value = (int *)extra;
12449
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012450 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012451
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012452 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012453 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012454 return -EPERM;
12455 }
12456
Jeff Johnson441e1f72017-02-07 08:50:49 -080012457 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12458 ret = hdd_check_private_wext_control(hdd_ctx, info);
12459 if (0 != ret)
12460 return ret;
12461
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012462 return hdd_reg_set_band(dev, value[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012463}
12464
12465static int iw_set_band_config(struct net_device *dev,
12466 struct iw_request_info *info,
12467 union iwreq_data *wrqu, char *extra)
12468{
12469 int ret;
12470
12471 cds_ssr_protect(__func__);
12472 ret = __iw_set_band_config(dev, info, wrqu, extra);
12473 cds_ssr_unprotect(__func__);
12474
12475 return ret;
12476}
12477
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012478/**
12479 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
12480 * @adapter: Handle to adapter
12481 * @chan: Monitor mode channel
12482 * @bandwidth: Capture channel bandwidth
12483 *
12484 * Return: 0 on success else error code.
12485 */
12486static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
12487 uint32_t bandwidth)
12488{
12489 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12490 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
12491 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
12492 QDF_STATUS status;
12493 tHalHandle hal_hdl = hdd_ctx->hHal;
12494 struct qdf_mac_addr bssid;
12495 tCsrRoamProfile roam_profile;
Amar Singhal5cccafe2017-02-15 12:42:58 -080012496 struct ch_params ch_params;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012497
12498 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
12499 hdd_err("Not supported, device is not in monitor mode");
12500 return -EINVAL;
12501 }
12502
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012503 hdd_debug("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080012504 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012505 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
12506 roam_profile.ChannelInfo.numOfChannels = 1;
12507 roam_profile.phyMode = ch_info->phy_mode;
12508 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070012509 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012510
12511 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
12512 QDF_MAC_ADDR_SIZE);
12513
12514 ch_params.ch_width = bandwidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012515 wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params);
Manjunathappa Prakashc4dc9382017-03-07 18:50:33 -080012516 if (ch_params.ch_width == CH_WIDTH_INVALID) {
12517 hdd_err("Invalid capture channel or bandwidth for a country");
12518 return -EINVAL;
12519 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012520
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012521 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
12522 &roam_profile);
12523 if (status) {
12524 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
12525 status);
12526 }
12527
12528 return qdf_status_to_os_return(status);
12529}
12530
Dustin Brown8d2d0f52017-04-03 17:02:08 -070012531static int printk_adapter(void *priv, const char *fmt, ...)
12532{
12533 int ret;
12534 va_list args;
12535
12536 va_start(args, fmt);
12537 ret = vprintk(fmt, args);
12538 ret += printk("\n");
12539 va_end(args);
12540
12541 return ret;
12542}
12543
12544#ifdef WMI_INTERFACE_EVENT_LOGGING
12545static void hdd_ioctl_log_buffer(int log_id, uint32_t count)
12546{
12547 qdf_abstract_print *print = &printk_adapter;
12548
12549 switch (log_id) {
12550 case HTC_CREDIT_HISTORY_LOG:
12551 print(NULL, "HTC Credit History (count %u)", count);
12552 cds_print_htc_credit_history(count, print, NULL);
12553 break;
12554 case COMMAND_LOG:
12555 print(NULL, "Command Log (count %u)", count);
12556 wma_print_wmi_cmd_log(count, print, NULL);
12557 break;
12558 case COMMAND_TX_CMP_LOG:
12559 print(NULL, "Command Tx Complete Log (count %u)", count);
12560 wma_print_wmi_cmd_tx_cmp_log(count, print, NULL);
12561 break;
12562 case MGMT_COMMAND_LOG:
12563 print(NULL, "Management Command Log (count %u)", count);
12564 wma_print_wmi_mgmt_cmd_log(count, print, NULL);
12565 break;
12566 case MGMT_COMMAND_TX_CMP_LOG:
12567 print(NULL, "Management Command Tx Complete Log (count %u)",
12568 count);
12569 wma_print_wmi_mgmt_cmd_tx_cmp_log(count, print, NULL);
12570 break;
12571 case EVENT_LOG:
12572 print(NULL, "Event Log (count %u)", count);
12573 wma_print_wmi_event_log(count, print, NULL);
12574 break;
12575 case RX_EVENT_LOG:
12576 print(NULL, "Rx Event Log (count %u)", count);
12577 wma_print_wmi_rx_event_log(count, print, NULL);
12578 break;
12579 case MGMT_EVENT_LOG:
12580 print(NULL, "Management Event Log (count %u)", count);
12581 wma_print_wmi_mgmt_event_log(count, print, NULL);
12582 break;
12583 default:
12584 print(NULL, "Invalid Log Id %d", log_id);
12585 break;
12586 }
12587}
12588#else
12589static inline void hdd_ioctl_log_buffer(int log_id, uint32_t count)
12590{
12591}
12592#endif /* WMI_INTERFACE_EVENT_LOGGING */
12593
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012594static int __iw_set_two_ints_getnone(struct net_device *dev,
12595 struct iw_request_info *info,
12596 union iwreq_data *wrqu, char *extra)
12597{
12598 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12599 int *value = (int *)extra;
12600 int sub_cmd = value[0];
12601 int ret;
12602 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
12603
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012604 ENTER_DEV(dev);
12605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012606 ret = wlan_hdd_validate_context(hdd_ctx);
12607 if (0 != ret)
12608 return ret;
12609
Jeff Johnson441e1f72017-02-07 08:50:49 -080012610 ret = hdd_check_private_wext_control(hdd_ctx, info);
12611 if (0 != ret)
12612 return ret;
12613
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012614 switch (sub_cmd) {
12615 case WE_SET_SMPS_PARAM:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012616 hdd_debug("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012617 ret = wma_cli_set_command(pAdapter->sessionId,
12618 WMI_STA_SMPS_PARAM_CMDID,
12619 value[1] << WMA_SMPS_PARAM_VALUE_S
12620 | value[2],
12621 VDEV_CMD);
12622 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070012623#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012624 case WE_SET_FW_CRASH_INJECT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012625 hdd_debug("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012626 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053012627 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
12628 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012629 ret = wma_cli_set2_command(pAdapter->sessionId,
12630 GEN_PARAM_CRASH_INJECT,
12631 value[1], value[2], GEN_CMD);
12632 break;
12633#endif
Govind Singha471e5e2015-10-12 17:11:14 +053012634 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070012635 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012636 value[1], value[2]);
12637 ret = wma_cli_set2_command(pAdapter->sessionId,
12638 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
12639 value[1], value[2], DBG_CMD);
12640 break;
12641 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070012642 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012643 value[1], value[2]);
12644 ret = wma_cli_set2_command(pAdapter->sessionId,
12645 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
12646 value[1], value[2], DBG_CMD);
12647 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012648 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
12649 hdd_debug("Ioctl to set dual fw mode config");
12650 if (hdd_ctx->config->dual_mac_feature_disable) {
12651 hdd_err("Dual mac feature is disabled from INI");
12652 return -EPERM;
12653 }
12654 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080012655 policy_mgr_set_dual_mac_fw_mode_config(hdd_ctx->hdd_psoc,
12656 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012657 break;
12658 case WE_DUMP_DP_TRACE_LEVEL:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012659 hdd_debug("WE_DUMP_DP_TRACE_LEVEL: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012660 value[1], value[2]);
12661 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012662 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053012663 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
12664 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053012665 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
12666 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012667 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012668 case WE_SET_MON_MODE_CHAN:
12669 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
12670 break;
Dustin Brown54096432017-02-23 13:00:44 -080012671 case WE_SET_WLAN_SUSPEND: {
Dustin Brown3ed3e9b2017-03-23 12:57:58 -070012672 hdd_info("STA unit-test suspend(%d, %d)", value[1], value[2]);
Dustin Brown54096432017-02-23 13:00:44 -080012673 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
12674 value[1], value[2]);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012675 break;
Dustin Brown54096432017-02-23 13:00:44 -080012676 }
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012677 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070012678 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012679 break;
Dustin Brown8d2d0f52017-04-03 17:02:08 -070012680 case WE_LOG_BUFFER: {
12681 int log_id = value[1];
12682 uint32_t count = value[2] < 0 ? 0 : value[2];
12683
12684 hdd_ioctl_log_buffer(log_id, count);
12685
12686 break;
12687 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012688 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070012689 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012690 break;
12691 }
12692
12693 return ret;
12694}
12695
12696static int iw_set_two_ints_getnone(struct net_device *dev,
12697 struct iw_request_info *info,
12698 union iwreq_data *wrqu, char *extra)
12699{
12700 int ret;
12701
12702 cds_ssr_protect(__func__);
12703 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
12704 cds_ssr_unprotect(__func__);
12705
12706 return ret;
12707}
12708
12709/* Define the Wireless Extensions to the Linux Network Device structure */
12710/* A number of these routines are NULL (meaning they are not implemented.) */
12711
12712static const iw_handler we_handler[] = {
12713 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
12714 (iw_handler) iw_get_name, /* SIOCGIWNAME */
12715 (iw_handler) NULL, /* SIOCSIWNWID */
12716 (iw_handler) NULL, /* SIOCGIWNWID */
12717 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
12718 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
12719 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
12720 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
12721 (iw_handler) NULL, /* SIOCSIWSENS */
12722 (iw_handler) NULL, /* SIOCGIWSENS */
12723 (iw_handler) NULL, /* SIOCSIWRANGE */
12724 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
12725 (iw_handler) NULL, /* SIOCSIWPRIV */
12726 (iw_handler) NULL, /* SIOCGIWPRIV */
12727 (iw_handler) NULL, /* SIOCSIWSTATS */
12728 (iw_handler) NULL, /* SIOCGIWSTATS */
12729 (iw_handler) NULL, /* SIOCSIWSPY */
12730 (iw_handler) NULL, /* SIOCGIWSPY */
12731 (iw_handler) NULL, /* SIOCSIWTHRSPY */
12732 (iw_handler) NULL, /* SIOCGIWTHRSPY */
12733 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
12734 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
12735 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
12736 (iw_handler) NULL, /* SIOCGIWAPLIST */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012737#ifndef NAPIER_SCAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012738 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
12739 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012740#else
12741 (iw_handler) NULL, /* SIOCSIWSCAN */
12742 (iw_handler) NULL, /* SIOCGIWSCAN */
12743#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012744 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
12745 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
12746 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
12747 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
12748 (iw_handler) NULL, /* -- hole -- */
12749 (iw_handler) NULL, /* -- hole -- */
12750 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
12751 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
12752 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
12753 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
12754 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
12755 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
12756 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
12757 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
12758 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
12759 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
12760 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
12761 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
12762 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
12763 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
12764 (iw_handler) NULL, /* -- hole -- */
12765 (iw_handler) NULL, /* -- hole -- */
12766 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
12767 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
12768 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
12769 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
12770 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
12771 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
12772 (iw_handler) NULL, /* SIOCSIWPMKSA */
12773};
12774
12775static const iw_handler we_private[] = {
12776
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012777 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone,
12778 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint,
12779 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012780 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12781 iw_set_three_ints_getnone,
12782 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012783 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012784 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12785 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070012786 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
12787 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012788 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
12789 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
12790 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012791 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012792 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
12793 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
12794 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
12795 iw_set_keepalive_params,
12796#ifdef WLAN_FEATURE_PACKET_FILTERING
12797 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
12798 iw_set_packet_filter_params,
12799#endif
12800#ifdef FEATURE_WLAN_SCAN_PNO
12801 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
12802#endif
12803 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080012804 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
12805 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012806 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
12807 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12808 iw_set_two_ints_getnone,
12809 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
12810 iw_set_dot11p_channel_sched,
12811};
12812
12813/*Maximum command length can be only 15 */
12814static const struct iw_priv_args we_private_args[] = {
12815
12816 /* handlers for main ioctl */
12817 {WLAN_PRIV_SET_INT_GET_NONE,
12818 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12819 0,
12820 ""},
12821
12822 /* handlers for sub-ioctl */
12823 {WE_SET_11D_STATE,
12824 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12825 0,
12826 "set11Dstate"},
12827
12828 {WE_WOWL,
12829 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12830 0,
12831 "wowl"},
12832
12833 {WE_SET_POWER,
12834 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12835 0,
12836 "setPower"},
12837
12838 {WE_SET_MAX_ASSOC,
12839 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12840 0,
12841 "setMaxAssoc"},
12842
12843 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
12844 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
12845 "setAutoChannel" },
12846
12847 {WE_SET_SCAN_DISABLE,
12848 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12849 0,
12850 "scan_disable"},
12851
12852 {WE_SET_DATA_INACTIVITY_TO,
12853 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12854 0,
12855 "inactivityTO"},
12856
Mukul Sharmaed92f2f2017-04-20 00:06:28 +053012857 {WE_SET_WOW_DATA_INACTIVITY_TO,
12858 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12859 0,
12860 "wow_ito"},
12861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012862 {WE_SET_MAX_TX_POWER,
12863 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12864 0,
12865 "setMaxTxPower"},
12866
12867 {WE_SET_TX_POWER,
12868 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12869 0,
12870 "setTxPower"},
12871
12872 {WE_SET_MC_RATE,
12873 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12874 0,
12875 "setMcRate"},
12876
12877 {WE_SET_MAX_TX_POWER_2_4,
12878 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12879 0,
12880 "setTxMaxPower2G"},
12881
12882 {WE_SET_MAX_TX_POWER_5_0,
12883 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12884 0,
12885 "setTxMaxPower5G"},
12886
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012887 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012888 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012889 0,
12890 "pktlog"},
12891
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012892 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
12893 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012894 * will support both
12895 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012896 {WE_SET_MAX_TX_POWER,
12897 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12898 0,
12899 "setTxMaxPower"},
12900
12901 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012902 * 1 = enable and 0 = disable
12903 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012904 {
12905 WE_SET_HIGHER_DTIM_TRANSITION,
12906 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12907 0,
12908 "setHDtimTransn"
12909 },
12910
12911 {WE_SET_TM_LEVEL,
12912 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12913 0,
12914 "setTmLevel"},
12915
12916 {WE_SET_PHYMODE,
12917 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12918 0,
12919 "setphymode"},
12920
12921 {WE_SET_NSS,
12922 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12923 0,
12924 "nss"},
12925
12926 {WE_SET_LDPC,
12927 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12928 0,
12929 "ldpc"},
12930
12931 {WE_SET_TX_STBC,
12932 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12933 0,
12934 "tx_stbc"},
12935
12936 {WE_SET_RX_STBC,
12937 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12938 0,
12939 "rx_stbc"},
12940
12941 {WE_SET_SHORT_GI,
12942 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12943 0,
12944 "shortgi"},
12945
12946 {WE_SET_RTSCTS,
12947 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12948 0,
12949 "enablertscts"},
12950
12951 {WE_SET_CHWIDTH,
12952 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12953 0,
12954 "chwidth"},
12955
12956 {WE_SET_ANI_EN_DIS,
12957 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12958 0,
12959 "anienable"},
12960
12961 {WE_SET_ANI_POLL_PERIOD,
12962 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12963 0,
12964 "aniplen"},
12965
12966 {WE_SET_ANI_LISTEN_PERIOD,
12967 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12968 0,
12969 "anilislen"},
12970
12971 {WE_SET_ANI_OFDM_LEVEL,
12972 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12973 0,
12974 "aniofdmlvl"},
12975
12976 {WE_SET_ANI_CCK_LEVEL,
12977 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12978 0,
12979 "aniccklvl"},
12980
12981 {WE_SET_DYNAMIC_BW,
12982 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12983 0,
12984 "cwmenable"},
12985
12986 {WE_SET_CTS_CBW,
12987 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12988 0,
12989 "cts_cbw" },
12990
12991 {WE_SET_GTX_HT_MCS,
12992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12993 0,
12994 "gtxHTMcs"},
12995
12996 {WE_SET_GTX_VHT_MCS,
12997 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12998 0,
12999 "gtxVHTMcs"},
13000
13001 {WE_SET_GTX_USRCFG,
13002 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13003 0,
13004 "gtxUsrCfg"},
13005
13006 {WE_SET_GTX_THRE,
13007 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13008 0,
13009 "gtxThre"},
13010
13011 {WE_SET_GTX_MARGIN,
13012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13013 0,
13014 "gtxMargin"},
13015
13016 {WE_SET_GTX_STEP,
13017 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13018 0,
13019 "gtxStep"},
13020
13021 {WE_SET_GTX_MINTPC,
13022 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13023 0,
13024 "gtxMinTpc"},
13025
13026 {WE_SET_GTX_BWMASK,
13027 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13028 0,
13029 "gtxBWMask"},
13030
13031 {WE_SET_TX_CHAINMASK,
13032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13033 0,
13034 "txchainmask"},
13035
13036 {WE_SET_RX_CHAINMASK,
13037 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13038 0,
13039 "rxchainmask"},
13040
13041 {WE_SET_11N_RATE,
13042 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13043 0,
13044 "set11NRates"},
13045
13046 {WE_SET_VHT_RATE,
13047 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13048 0,
13049 "set11ACRates"},
13050
13051 {WE_SET_AMPDU,
13052 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13053 0,
13054 "ampdu"},
13055
13056 {WE_SET_AMSDU,
13057 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13058 0,
13059 "amsdu"},
13060
13061 {WE_SET_BURST_ENABLE,
13062 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13063 0,
13064 "burst_enable"},
13065
13066 {WE_SET_BURST_DUR,
13067 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13068 0,
13069 "burst_dur"},
13070
13071 {WE_SET_TXPOW_2G,
13072 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13073 0,
13074 "txpow2g"},
13075
13076 {WE_SET_TXPOW_5G,
13077 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13078 0,
13079 "txpow5g"},
13080
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013081 /* Sub-cmds DBGLOG specific commands */
13082 {WE_DBGLOG_LOG_LEVEL,
13083 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13084 0,
13085 "dl_loglevel"},
13086
13087 {WE_DBGLOG_VAP_ENABLE,
13088 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13089 0,
13090 "dl_vapon"},
13091
13092 {WE_DBGLOG_VAP_DISABLE,
13093 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13094 0,
13095 "dl_vapoff"},
13096
13097 {WE_DBGLOG_MODULE_ENABLE,
13098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13099 0,
13100 "dl_modon"},
13101
13102 {WE_DBGLOG_MODULE_DISABLE,
13103 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13104 0,
13105 "dl_modoff"},
13106
13107 {WE_DBGLOG_MOD_LOG_LEVEL,
13108 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13109 0,
13110 "dl_mod_loglevel"},
13111
13112 {WE_DBGLOG_TYPE,
13113 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13114 0,
13115 "dl_type"},
13116 {WE_DBGLOG_REPORT_ENABLE,
13117 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13118 0,
13119 "dl_report"},
13120
13121 {WE_SET_TXRX_FWSTATS,
13122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13123 0,
13124 "txrx_fw_stats"},
13125
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080013126 {WE_SET_TXRX_STATS,
13127 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13128 0,
13129 "txrx_stats"},
13130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013131 {WE_TXRX_FWSTATS_RESET,
13132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13133 0,
13134 "txrx_fw_st_rst"},
13135
13136 {WE_PPS_PAID_MATCH,
13137 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13138 0, "paid_match"},
13139
13140 {WE_PPS_GID_MATCH,
13141 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13142 0, "gid_match"},
13143
13144 {WE_PPS_EARLY_TIM_CLEAR,
13145 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13146 0, "tim_clear"},
13147
13148 {WE_PPS_EARLY_DTIM_CLEAR,
13149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13150 0, "dtim_clear"},
13151
13152 {WE_PPS_EOF_PAD_DELIM,
13153 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13154 0, "eof_delim"},
13155
13156 {WE_PPS_MACADDR_MISMATCH,
13157 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13158 0, "mac_match"},
13159
13160 {WE_PPS_DELIM_CRC_FAIL,
13161 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13162 0, "delim_fail"},
13163
13164 {WE_PPS_GID_NSTS_ZERO,
13165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13166 0, "nsts_zero"},
13167
13168 {WE_PPS_RSSI_CHECK,
13169 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13170 0, "rssi_chk"},
13171
13172 {WE_PPS_5G_EBT,
13173 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13174 0, "5g_ebt"},
13175
13176 {WE_SET_HTSMPS,
13177 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13178 0, "htsmps"},
13179
13180 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
13181 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13182 0, "set_qpspollcnt"},
13183
13184 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
13185 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13186 0, "set_qtxwake"},
13187
13188 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13190 0, "set_qwakeintv"},
13191
13192 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13194 0, "set_qnodatapoll"},
13195
13196 /* handlers for MCC time quota and latency sub ioctls */
13197 {WE_MCC_CONFIG_LATENCY,
13198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13199 0, "setMccLatency"},
13200
13201 {WE_MCC_CONFIG_QUOTA,
13202 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13203 0, "setMccQuota"},
13204
13205 {WE_SET_DEBUG_LOG,
13206 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13207 0, "setDbgLvl"},
13208
13209 /* handlers for early_rx power save */
13210 {WE_SET_EARLY_RX_ADJUST_ENABLE,
13211 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13212 0, "erx_enable"},
13213
13214 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
13215 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13216 0, "erx_bmiss_val"},
13217
13218 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
13219 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13220 0, "erx_bmiss_smpl"},
13221
13222 {WE_SET_EARLY_RX_SLOP_STEP,
13223 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13224 0, "erx_slop_step"},
13225
13226 {WE_SET_EARLY_RX_INIT_SLOP,
13227 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13228 0, "erx_init_slop"},
13229
13230 {WE_SET_EARLY_RX_ADJUST_PAUSE,
13231 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13232 0, "erx_adj_pause"},
13233
13234 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
13235 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13236 0, "erx_dri_sample"},
13237
13238 {WE_DUMP_STATS,
13239 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13240 0, "dumpStats"},
13241
13242 {WE_CLEAR_STATS,
13243 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13244 0, "clearStats"},
13245
Govind Singha471e5e2015-10-12 17:11:14 +053013246 {WE_START_FW_PROFILE,
13247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13248 0, "startProfile"},
13249
Abhishek Singh1bdb1572015-10-16 16:24:19 +053013250 {WE_SET_CHANNEL,
13251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13252 0, "setChanChange" },
13253
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053013254 {WE_SET_CONC_SYSTEM_PREF,
13255 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13256 0, "setConcSysPref" },
13257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013258 {WLAN_PRIV_SET_NONE_GET_INT,
13259 0,
13260 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13261 ""},
13262
13263 /* handlers for sub-ioctl */
13264 {WE_GET_11D_STATE,
13265 0,
13266 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13267 "get11Dstate"},
13268
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013269 {WE_GET_WLAN_DBG,
13270 0,
13271 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13272 "getwlandbg"},
13273
13274 {WE_GET_MAX_ASSOC,
13275 0,
13276 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13277 "getMaxAssoc"},
13278
13279 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
13280 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13281 "getAutoChannel" },
13282
13283 {WE_GET_CONCURRENCY_MODE,
13284 0,
13285 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13286 "getconcurrency"},
13287
13288 {WE_GET_NSS,
13289 0,
13290 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13291 "get_nss"},
13292
13293 {WE_GET_LDPC,
13294 0,
13295 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13296 "get_ldpc"},
13297
13298 {WE_GET_TX_STBC,
13299 0,
13300 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13301 "get_tx_stbc"},
13302
13303 {WE_GET_RX_STBC,
13304 0,
13305 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13306 "get_rx_stbc"},
13307
13308 {WE_GET_SHORT_GI,
13309 0,
13310 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13311 "get_shortgi"},
13312
13313 {WE_GET_RTSCTS,
13314 0,
13315 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13316 "get_rtscts"},
13317
13318 {WE_GET_CHWIDTH,
13319 0,
13320 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13321 "get_chwidth"},
13322
13323 {WE_GET_ANI_EN_DIS,
13324 0,
13325 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13326 "get_anienable"},
13327
13328 {WE_GET_ANI_POLL_PERIOD,
13329 0,
13330 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13331 "get_aniplen"},
13332
13333 {WE_GET_ANI_LISTEN_PERIOD,
13334 0,
13335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13336 "get_anilislen"},
13337
13338 {WE_GET_ANI_OFDM_LEVEL,
13339 0,
13340 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13341 "get_aniofdmlvl"},
13342
13343 {WE_GET_ANI_CCK_LEVEL,
13344 0,
13345 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13346 "get_aniccklvl"},
13347
13348 {WE_GET_DYNAMIC_BW,
13349 0,
13350 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13351 "get_cwmenable"},
13352
13353 {WE_GET_GTX_HT_MCS,
13354 0,
13355 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13356 "get_gtxHTMcs"},
13357
13358 {WE_GET_GTX_VHT_MCS,
13359 0,
13360 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13361 "get_gtxVHTMcs"},
13362
13363 {WE_GET_GTX_USRCFG,
13364 0,
13365 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13366 "get_gtxUsrCfg"},
13367
13368 {WE_GET_GTX_THRE,
13369 0,
13370 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13371 "get_gtxThre"},
13372
13373 {WE_GET_GTX_MARGIN,
13374 0,
13375 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13376 "get_gtxMargin"},
13377
13378 {WE_GET_GTX_STEP,
13379 0,
13380 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13381 "get_gtxStep"},
13382
13383 {WE_GET_GTX_MINTPC,
13384 0,
13385 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13386 "get_gtxMinTpc"},
13387
13388 {WE_GET_GTX_BWMASK,
13389 0,
13390 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13391 "get_gtxBWMask"},
13392
13393 {WE_GET_TX_CHAINMASK,
13394 0,
13395 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13396 "get_txchainmask"},
13397
13398 {WE_GET_RX_CHAINMASK,
13399 0,
13400 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13401 "get_rxchainmask"},
13402
13403 {WE_GET_11N_RATE,
13404 0,
13405 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13406 "get_11nrate"},
13407
13408 {WE_GET_AMPDU,
13409 0,
13410 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13411 "get_ampdu"},
13412
13413 {WE_GET_AMSDU,
13414 0,
13415 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13416 "get_amsdu"},
13417
13418 {WE_GET_BURST_ENABLE,
13419 0,
13420 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13421 "get_burst_en"},
13422
13423 {WE_GET_BURST_DUR,
13424 0,
13425 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13426 "get_burst_dur"},
13427
13428 {WE_GET_TXPOW_2G,
13429 0,
13430 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13431 "get_txpow2g"},
13432
13433 {WE_GET_TXPOW_5G,
13434 0,
13435 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13436 "get_txpow5g"},
13437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013438 {WE_GET_PPS_PAID_MATCH,
13439 0,
13440 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13441 "get_paid_match"},
13442
13443 {WE_GET_PPS_GID_MATCH,
13444 0,
13445 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13446 "get_gid_match"},
13447
13448 {WE_GET_PPS_EARLY_TIM_CLEAR,
13449 0,
13450 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13451 "get_tim_clear"},
13452
13453 {WE_GET_PPS_EARLY_DTIM_CLEAR,
13454 0,
13455 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13456 "get_dtim_clear"},
13457
13458 {WE_GET_PPS_EOF_PAD_DELIM,
13459 0,
13460 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13461 "get_eof_delim"},
13462
13463 {WE_GET_PPS_MACADDR_MISMATCH,
13464 0,
13465 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13466 "get_mac_match"},
13467
13468 {WE_GET_PPS_DELIM_CRC_FAIL,
13469 0,
13470 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13471 "get_delim_fail"},
13472
13473 {WE_GET_PPS_GID_NSTS_ZERO,
13474 0,
13475 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13476 "get_nsts_zero"},
13477
13478 {WE_GET_PPS_RSSI_CHECK,
13479 0,
13480 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13481 "get_rssi_chk"},
13482
13483 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
13484 0,
13485 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13486 "get_qpspollcnt"},
13487
13488 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
13489 0,
13490 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13491 "get_qtxwake"},
13492
13493 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13494 0,
13495 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13496 "get_qwakeintv"},
13497
13498 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13499 0,
13500 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13501 "get_qnodatapoll"},
13502
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013503 {WE_CAP_TSF,
13504 0,
13505 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13506 "cap_tsf"},
13507
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013508 {WE_GET_TEMPERATURE,
13509 0,
13510 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13511 "get_temp"},
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070013512 {WE_GET_DCM,
13513 0,
13514 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13515 "get_dcm"},
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070013516 {WE_GET_RANGE_EXT,
13517 0,
13518 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13519 "get_range_ext"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013520 /* handlers for main ioctl */
13521 {WLAN_PRIV_SET_CHAR_GET_NONE,
13522 IW_PRIV_TYPE_CHAR | 512,
13523 0,
13524 ""},
13525
13526 /* handlers for sub-ioctl */
13527 {WE_WOWL_ADD_PTRN,
13528 IW_PRIV_TYPE_CHAR | 512,
13529 0,
13530 "wowlAddPtrn"},
13531
13532 {WE_WOWL_DEL_PTRN,
13533 IW_PRIV_TYPE_CHAR | 512,
13534 0,
13535 "wowlDelPtrn"},
13536
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013537 /* handlers for sub-ioctl */
13538 {WE_NEIGHBOR_REPORT_REQUEST,
13539 IW_PRIV_TYPE_CHAR | 512,
13540 0,
13541 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080013542
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013543 {WE_SET_AP_WPS_IE,
13544 IW_PRIV_TYPE_CHAR | 512,
13545 0,
13546 "set_ap_wps_ie"},
13547
13548 {WE_SET_CONFIG,
13549 IW_PRIV_TYPE_CHAR | 512,
13550 0,
13551 "setConfig"},
13552
13553 /* handlers for main ioctl */
13554 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
13555 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13556 0,
13557 ""},
13558
13559 /* handlers for sub-ioctl */
13560 {WE_SET_WLAN_DBG,
13561 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13562 0,
13563 "setwlandbg"},
13564
13565 /* handlers for sub-ioctl */
13566 {WE_SET_DP_TRACE,
13567 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13568 0,
13569 "set_dp_trace"},
13570
13571 {WE_SET_SAP_CHANNELS,
13572 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13573 0,
13574 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013575
13576 {WE_SET_FW_TEST,
13577 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13578 0, "fw_test"},
13579
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013580 /* handlers for main ioctl */
13581 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
13582 0,
13583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13584 "" },
13585 {WE_GET_TSF,
13586 0,
13587 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13588 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013589
13590 {WE_SET_DUAL_MAC_SCAN_CONFIG,
13591 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13592 0,
13593 "set_scan_cfg"},
13594
13595 /* handlers for main ioctl */
13596 {WLAN_PRIV_GET_CHAR_SET_NONE,
13597 0,
13598 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13599 ""},
13600
13601 /* handlers for sub-ioctl */
13602 {WE_WLAN_VERSION,
13603 0,
13604 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13605 "version"},
13606 {WE_GET_STATS,
13607 0,
13608 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13609 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080013610 {WE_GET_SUSPEND_RESUME_STATS,
13611 0,
13612 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13613 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053013614 {WE_LIST_FW_PROFILE,
13615 0,
13616 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13617 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013618 {WE_GET_STATES,
13619 0,
13620 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13621 "getHostStates"},
13622 {WE_GET_CFG,
13623 0,
13624 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13625 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013626 {WE_GET_RSSI,
13627 0,
13628 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13629 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013630 {WE_GET_WMM_STATUS,
13631 0,
13632 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13633 "getWmmStatus"},
13634 {
13635 WE_GET_CHANNEL_LIST,
13636 0,
13637 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13638 "getChannelList"
13639 },
13640#ifdef FEATURE_WLAN_TDLS
13641 {
13642 WE_GET_TDLS_PEERS,
13643 0,
13644 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13645 "getTdlsPeers"
13646 },
13647#endif
13648#ifdef WLAN_FEATURE_11W
13649 {
13650 WE_GET_11W_INFO,
13651 0,
13652 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13653 "getPMFInfo"
13654 },
13655#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013656 {
13657 WE_GET_IBSS_STA_INFO,
13658 0,
13659 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13660 "getIbssSTAs"
13661 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013662 {WE_GET_PHYMODE,
13663 0,
13664 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13665 "getphymode"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013666#if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013667 {WE_GET_OEM_DATA_CAP,
13668 0,
13669 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13670 "getOemDataCap"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013671#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013672 {WE_GET_SNR,
13673 0,
13674 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13675 "getSNR"},
13676
13677 /* handlers for main ioctl */
13678 {WLAN_PRIV_SET_NONE_GET_NONE,
13679 0,
13680 0,
13681 ""},
13682
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013683 /* handlers for sub-ioctl */
13684 {
13685 WE_IBSS_GET_PEER_INFO_ALL,
13686 0,
13687 0,
13688 "ibssPeerInfoAll"
13689 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013690 {WE_GET_RECOVERY_STAT,
13691 0,
13692 0,
13693 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053013694
13695 {WE_GET_FW_PROFILE_DATA,
13696 0,
13697 0,
13698 "getProfileData"},
13699
13700 {WE_SET_REASSOC_TRIGGER,
13701 0,
13702 0,
13703 "reassoc"},
13704
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080013705 {WE_STOP_OBSS_SCAN,
13706 0,
13707 0,
13708 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013709 /* handlers for main ioctl */
13710 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
13711 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13712 0,
13713 ""},
13714
13715 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013716 {WE_IBSS_GET_PEER_INFO,
13717 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13718 0,
13719 "ibssPeerInfo"},
13720
13721 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013722 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
13723 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13724 0,
13725 "setdumplog"},
13726
13727 {WE_MTRACE_DUMP_CMD,
13728 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13729 0,
13730 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080013731
13732 {WE_POLICY_MANAGER_CINFO_CMD,
13733 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13734 0,
13735 "pm_cinfo"},
13736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013737#ifdef MPC_UT_FRAMEWORK
13738 {WE_POLICY_MANAGER_CLIST_CMD,
13739 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13740 0,
13741 "pm_clist"},
13742
13743 {WE_POLICY_MANAGER_DLIST_CMD,
13744 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13745 0,
13746 "pm_dlist"},
13747
13748 {WE_POLICY_MANAGER_DBS_CMD,
13749 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13750 0,
13751 "pm_dbs"},
13752
13753 {WE_POLICY_MANAGER_PCL_CMD,
13754 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13755 0,
13756 "pm_pcl"},
13757
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013758 {WE_POLICY_MANAGER_ULIST_CMD,
13759 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13760 0,
13761 "pm_ulist"},
13762
13763 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
13764 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13765 0,
13766 "pm_query_action"},
13767
13768 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
13769 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13770 0,
13771 "pm_query_allow"},
13772
13773 {WE_POLICY_MANAGER_SCENARIO_CMD,
13774 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13775 0,
13776 "pm_run_scenario"},
13777
13778 {WE_POLICY_SET_HW_MODE_CMD,
13779 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13780 0,
13781 "pm_set_hw_mode"},
13782#endif
13783#ifdef FEATURE_WLAN_TDLS
13784 /* handlers for sub ioctl */
13785 {
13786 WE_TDLS_CONFIG_PARAMS,
13787 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13788 0,
13789 "setTdlsConfig"
13790 },
13791#endif
13792 {
13793 WE_UNIT_TEST_CMD,
13794 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13795 0,
13796 "setUnitTestCmd"
13797 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053013798 {
13799 WE_MAC_PWR_DEBUG_CMD,
13800 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13801 0,
13802 "halPwrDebug"
13803 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013804
13805#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
13806 {WE_LED_FLASHING_PARAM,
13807 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13808 0,
13809 "gpio_control"},
13810#endif
13811 /* handlers for main ioctl */
13812 {WLAN_PRIV_ADD_TSPEC,
13813 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
13814 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13815 "addTspec"},
13816
13817 /* handlers for main ioctl */
13818 {WLAN_PRIV_DEL_TSPEC,
13819 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13820 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13821 "delTspec"},
13822
13823 /* handlers for main ioctl */
13824 {WLAN_PRIV_GET_TSPEC,
13825 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13826 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13827 "getTspec"},
13828
13829 /* handlers for main ioctl - host offload */
13830 {
13831 WLAN_PRIV_SET_HOST_OFFLOAD,
Srinivas Girigowda077143e2017-03-25 10:47:27 -070013832 IW_PRIV_TYPE_BYTE | sizeof(struct host_offload_req),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013833 0,
13834 "setHostOffload"
13835 }
13836 ,
13837
13838 {
13839 WLAN_GET_WLAN_STATISTICS,
13840 0,
13841 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
13842 "getWlanStats"
13843 }
13844 ,
13845
13846 {
13847 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053013848 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
13849 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013850 0,
13851 "setKeepAlive"
13852 }
13853 ,
13854#ifdef WLAN_FEATURE_PACKET_FILTERING
13855 {
13856 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053013857 IW_PRIV_TYPE_BYTE |
13858 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013859 0,
13860 "setPktFilter"
13861 }
13862 ,
13863#endif
13864#ifdef FEATURE_WLAN_SCAN_PNO
13865 {
13866 WLAN_SET_PNO,
13867 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13868 0,
13869 "setpno"
13870 }
13871 ,
13872#endif
13873 {
13874 WLAN_SET_BAND_CONFIG,
13875 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13876 0,
13877 "SETBAND"
13878 }
13879 ,
13880 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080013881 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080013882 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013883 0,
13884 "setMCBCFilter"
13885 }
13886 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013887
13888 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013889 WLAN_GET_LINK_SPEED,
13890 IW_PRIV_TYPE_CHAR | 18,
13891 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
13892 }
13893 ,
13894
13895 /* handlers for main ioctl */
13896 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
13897 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13898 0,
13899 ""}
13900 ,
13901 {WE_SET_SMPS_PARAM,
13902 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13903 0, "set_smps_param"}
13904 ,
13905 {WLAN_SET_DOT11P_CHANNEL_SCHED,
13906 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
13907 0, "set_dot11p" }
13908 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070013909#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013910 {WE_SET_FW_CRASH_INJECT,
13911 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13912 0, "crash_inject"}
13913 ,
Dustin Brown8d2d0f52017-04-03 17:02:08 -070013914 {WE_LOG_BUFFER,
13915 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13916 0, "log_buffer"}
13917 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013918#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070013919#ifdef WLAN_SUSPEND_RESUME_TEST
13920 {WE_SET_WLAN_SUSPEND,
13921 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13922 0, "wlan_suspend"}
13923 ,
13924 {WE_SET_WLAN_RESUME,
13925 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13926 0, "wlan_resume"}
13927 ,
13928#endif
Govind Singha471e5e2015-10-12 17:11:14 +053013929 {WE_ENABLE_FW_PROFILE,
13930 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13931 0, "enableProfile"}
13932 ,
13933 {WE_SET_FW_PROFILE_HIST_INTVL,
13934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13935 0, "set_hist_intvl"}
13936 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013937 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
13938 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13939 0, "set_fw_mode_cfg"}
13940 ,
13941 {WE_DUMP_DP_TRACE_LEVEL,
13942 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13943 0, "dump_dp_trace"}
13944 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070013945 {WE_SET_MON_MODE_CHAN,
13946 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13947 0, "setMonChan"}
13948 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070013949
13950 {WE_GET_ROAM_SYNCH_DELAY,
13951 0,
13952 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13953 "hostroamdelay"}
13954 ,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -080013955 {WE_SET_11AX_RATE,
13956 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13957 0,
13958 "set_11ax_rate"}
13959 ,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070013960 {WE_SET_DCM,
13961 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13962 0,
13963 "enable_dcm"}
13964 ,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070013965 {WE_SET_RANGE_EXT,
13966 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13967 0,
13968 "enable_range_ext"}
13969 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013970};
13971
13972const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053013973 .num_standard = QDF_ARRAY_SIZE(we_handler),
13974 .num_private = QDF_ARRAY_SIZE(we_private),
13975 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013976
13977 .standard = (iw_handler *) we_handler,
13978 .private = (iw_handler *) we_private,
13979 .private_args = we_private_args,
13980 .get_wireless_stats = NULL,
13981};
13982
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013983/* hdd_set_wext() - configures bss parameters
13984 * @pAdapter: handle to adapter context
13985 *
13986 * Returns: none
13987 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070013988static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013989{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013990 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13991 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013992
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013993 ENTER();
13994
13995 if (!pwextBuf) {
13996 hdd_err("ERROR: pwextBuf is NULL");
13997 return QDF_STATUS_E_FAILURE;
13998 }
13999
14000 if (!pHddStaCtx) {
14001 hdd_err("ERROR: pHddStaCtx is NULL");
14002 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070014003 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014004
14005 /* Now configure the roaming profile links. To SSID and bssid. */
14006 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014007 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014008
14009 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014010 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014011
14012 /*Set the numOfChannels to zero to scan all the channels */
14013 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
14014 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
14015
14016 /* Default is no encryption */
14017 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
14018 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
14019 eCSR_ENCRYPT_TYPE_NONE;
14020
14021 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
14022 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
14023 eCSR_ENCRYPT_TYPE_NONE;
14024
14025 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
14026
14027 /* Default is no authentication */
14028 pwextBuf->roamProfile.AuthType.numEntries = 1;
14029 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
14030
14031 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
14032 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
14033
14034 /*Set the default scan mode */
14035 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
14036
14037 hdd_clear_roam_profile_ie(pAdapter);
14038
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014039 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014040 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014041
14042}
14043
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070014044/**
14045 * hdd_register_wext() - register wext context
14046 * @dev: net device handle
14047 *
14048 * Registers wext interface context for a given net device
14049 *
14050 * Returns: 0 on success, errno on failure
14051 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014052int hdd_register_wext(struct net_device *dev)
14053{
14054 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014055 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053014056 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014057
14058 ENTER();
14059
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014060 if (!pwextBuf) {
14061 hdd_err(FL("ERROR: pwextBuf is NULL"));
14062 return QDF_STATUS_E_FAILURE;
14063 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070014064
14065 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014066 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
14067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014068 status = hdd_set_wext(pAdapter);
14069
Anurag Chouhance0dc992016-02-16 18:18:03 +053014070 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070014071 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014072 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014073 }
14074
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070014075 status = qdf_event_create(&pwextBuf->hdd_qdf_event);
14076 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070014077 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014078 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014079 }
14080
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014081 /* Register as a wireless device */
14082 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
14083
14084 EXIT();
14085 return 0;
14086}
14087
14088int hdd_unregister_wext(struct net_device *dev)
14089{
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080014090 hdd_debug("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014091
14092 if (dev != NULL) {
14093 rtnl_lock();
14094 dev->wireless_handlers = NULL;
14095 rtnl_unlock();
14096 }
14097
14098 return 0;
14099}