blob: fedb8430203cbb468f1fcde24bd71630a1ad012a [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>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102#define HDD_FINISH_ULA_TIME_OUT 800
103#define HDD_SET_MCBC_FILTERS_TO_FW 1
104#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106/* To Validate Channel against the Frequency and Vice-Versa */
107static const hdd_freq_chan_map_t freq_chan_map[] = {
108 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
109 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
110 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
111 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
112 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
113 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
114 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
115 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
116 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
117 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
118 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
119 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
120
121#define FREQ_CHAN_MAP_TABLE_SIZE \
122 (sizeof(freq_chan_map) / sizeof(freq_chan_map[0]))
123
124/* Private ioctls and their sub-ioctls */
125#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
126#define WE_SET_11D_STATE 1
127#define WE_WOWL 2
128#define WE_SET_POWER 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530129/*
130 * <ioctl>
131 * setMaxAssoc - Sets the maximum number of associated stations
132 *
133 * @INPUT: 1 to 32
134 *
135 * @OUTPUT: None
136 *
137 * This IOTCL sets the maximum number of associated stations
138 *
139 * @E.g: iwpriv wlan0 setMaxAssoc <value>
140 *
141 * Supported Feature: STA
142 *
143 * Usage: Internal/External
144 *
145 * </ioctl>
146 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147#define WE_SET_MAX_ASSOC 4
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +0530148/*
149 * <ioctl>
150 * scan_diable - Disable scan
151 *
152 * @INPUT: set_value
153 *
154 * @OUTPUT: None
155 *
156 * This IOCTL is used to set disable scan
157 *
158 * @E.g: iwpriv wlan0 scan_disable 1
159 *
160 * Supported Feature: Scan
161 *
162 * Usage: Internal/External
163 *
164 * </ioctl>
165 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166#define WE_SET_SCAN_DISABLE 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530167/*
168 * <ioctl>
169 * inactivityTO - sets the timeout value for inactivity data while
170 * in power save mode
171 *
172 * @INPUT: int1…..int255
173 *
174 * @OUTPUT: None
175 *
176 * This IOCTL set the timeout value for inactivity data in power save mode
177 *
178 * @E.g: iwpriv wlan0 inactivityTO 20
179 *
180 * Supported Feature: STA
181 *
182 * Usage: Internal/External
183 *
184 * </ioctl>
185 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186#define WE_SET_DATA_INACTIVITY_TO 6
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530187/*
188 * <ioctl>
189 * setMaxTxPower - Dynamically sets the maximum transmission power
190 *
191 * @INPUT: Transmission power in dBm
192 *
193 * @OUTPUT: None
194 *
195 * This IOCTL dynamically sets the maximum transmission power
196 * This setting does not persist over reboots
197 *
198 * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
199 *
200 * Supported Feature: STA
201 *
202 * Usage: Internal/External
203 *
204 * </ioctl>
205 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206#define WE_SET_MAX_TX_POWER 7
207#define WE_SET_HIGHER_DTIM_TRANSITION 8
208#define WE_SET_TM_LEVEL 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530209/*
210 * <ioctl>
211 * setphymode - Set the phymode dynamically
212 *
213 * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
214 *
215 * @OUTPUT: None
216 *
217 * This IOCTL sets the phymode dynamically
218 *
219 * @E.g: iwpriv wlan0 setphymode 10
220 *
221 * Supported Feature: STA
222 *
223 * Usage: Internal/External
224 *
225 * </ioctl>
226 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227#define WE_SET_PHYMODE 10
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530228/*
229 * <ioctl>
230 * nss - Set the number of spatial streams
231 *
232 * @INPUT: int1…..int3
233 *
234 * @OUTPUT: None
235 *
236 * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
237 *
238 * @E.g: iwpriv wlan0 nss 2
239 *
240 * Supported Feature: STA
241 *
242 * Usage: Internal/External
243 *
244 * </ioctl>
245 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246#define WE_SET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530247/*
248 * <ioctl>
249 * ldpc - Enables or disables LDPC
250 *
251 * @INPUT: 0 – Disable, 1 - Enable
252 *
253 * @OUTPUT: None
254 *
255 * This IOCTL enables or disables LDPC
256 *
257 * @E.g: iwpriv wlan0 ldpc 1
258 *
259 * Supported Feature: STA
260 *
261 * Usage: Internal/External
262 *
263 * </ioctl>
264 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265#define WE_SET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530266/*
267 * <ioctl>
268 * tx_stbc - Enables or disables tx_stbc
269 *
270 * @INPUT: Int 0 – Disable, 1 - Enable
271 *
272 * @OUTPUT: None
273 *
274 * This IOTCL used to enables or disables tx_stbc
275 *
276 * @E.g: iwpriv wlan0 tx_stbc <value>
277 *
278 * Supported Feature: STA
279 *
280 * Usage: Internal/External
281 *
282 * </ioctl>
283 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284#define WE_SET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530285/*
286 * <ioctl>
287 * rx_stbc - Set the rx_stbc parameter
288 *
289 * @INPUT: Int 0 – Disable, 1 - Enable
290 *
291 * @OUTPUT: None
292 *
293 * This IOTCL used to set rx_stbc parameter
294 *
295 * @E.g: iwpriv wlan0 rx_stbc <value>
296 *
297 * Supported Feature: STA
298 *
299 * Usage: Internal/External
300 *
301 * </ioctl>
302 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303#define WE_SET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530304/*
305 * <ioctl>
306 * shortgi - Enables or disables a short-guard interval
307 *
308 * @INPUT: Int 0 – Disable, 1 - Enable
309 *
310 * @OUTPUT: None
311 *
312 * This IOCTL enables or disables a short-guard interval.
313 *
314 * @E.g: iwpriv wlan0 shortgi <value>
315 *
316 * Supported Feature: STA
317 *
318 * Usage: Internal/External
319 *
320 * </ioctl>
321 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322#define WE_SET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530323/*
324 * <ioctl>
325 * enablertscts - enables or disables rts/cts.
326 *
327 * @INPUT: 1-Enable , 0-Disable
328 *
329 * @OUTPUT: None
330 *
331 * This IOCTL enables or disables rts/cts.
332 *
333 * @E.g: iwpriv wlan0 enablertscts <value>
334 *
335 * Supported Feature: STA
336 *
337 * Usage: Internal/External
338 *
339 * </ioctl>
340 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341#define WE_SET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530342/*
343 * <ioctl>
344 * chwidth - Set the channel bandwidth
345 *
346 * @INPUT: 0-20mhz to 3-160mhz
347 *
348 * @OUTPUT: None
349 *
350 * This IOTCL used to set the channel bandwidth
351 *
352 * @E.g: iwpriv wlan0 chwidth 1
353 *
354 * Supported Feature: STA
355 *
356 * Usage: Internal/External
357 *
358 * </ioctl>
359 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360#define WE_SET_CHWIDTH 17
361#define WE_SET_ANI_EN_DIS 18
362#define WE_SET_ANI_POLL_PERIOD 19
363#define WE_SET_ANI_LISTEN_PERIOD 20
364#define WE_SET_ANI_OFDM_LEVEL 21
365#define WE_SET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530366/*
367 * <ioctl>
368 * cwmenable - Enables or disables the dynamic channel bandwidth
369 *
370 * @INPUT: 0-Disable, 1-Enable
371 *
372 * @OUTPUT: None
373 *
374 * This IOTCL used to enables or disables the dynamic channel bandwidth
375 *
376 * @E.g: iwpriv wlan0 cwmenable <value>
377 *
378 * Supported Feature: STA
379 *
380 * Usage: Internal/External
381 *
382 * </ioctl>
383 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384#define WE_SET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530385/*
386 * <ioctl>
387 * txchainmask - This IOCTL sets the current Tx chain mask
388 *
389 * @INPUT: Mask Value
390 *
391 * @OUTPUT: None
392 *
393 * This IOCTL sets the current Tx chain mask
394 *
395 * @E.g: iwpriv wlan0 txchainmask 1
396 *
397 * Supported Feature: STA
398 *
399 * Usage: Internal/External
400 *
401 * </ioctl>
402 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403#define WE_SET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530404/*
405 * <ioctl>
406 * rxchainmask - Sets the current Rx chain mask
407 *
408 * @INPUT: Mask Value
409 *
410 * @OUTPUT: None
411 *
412 * This IOCTL sets the current Rx chain mask. This command is the
413 * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
414 *
415 * @E.g: iwpriv wlan0 rxchainmask <value>
416 *
417 * Supported Feature: STA
418 *
419 * Usage: Internal/External
420 *
421 * </ioctl>
422 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423#define WE_SET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530424/*
425 * <ioctl>
426 * set11NRates - Fixes the Tx data rate of the 11N mode.
427 *
428 * @INPUT: 0x1b to 0x8f
429 *
430 * @OUTPUT: None
431 *
432 * This IOCTL fixes the Tx data rate of the 11N mode.
433 *
434 * @E.g: iwpriv wlan0 set11NRates 0x85
435 *
436 * Supported Feature: STA
437 *
438 * Usage: Internal/External
439 *
440 * </ioctl>
441 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442#define WE_SET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530443/*
444 * <ioctl>
445 * ampdu - Set the the maximum subframe of ampdu
446 *
447 * @INPUT: int 1 to int 63
448 *
449 * @OUTPUT: None
450 *
451 * This IOCTL sets the maximum subframe of ampdu.
452 *
453 * @E.g: iwpriv wlan0 ampdu 9
454 *
455 * Supported Feature: STA
456 *
457 * Usage: Internal/External
458 *
459 * </ioctl>
460 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461#define WE_SET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530462/*
463 * <ioctl>
464 * amsdu - Sets the maximum subframe of amsdu.
465 *
466 * @INPUT: int 1 to int 31
467 *
468 * @OUTPUT: None
469 *
470 * This IOCTL sets the maximum subframe of amsdu.
471 *
472 * @E.g: iwpriv wlan0 amsdu 9
473 *
474 * Supported Feature: STA
475 *
476 * Usage: Internal/External
477 *
478 * </ioctl>
479 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480#define WE_SET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530481/*
482 * <ioctl>
483 * txpow2g - current 2 GHz Tx power setting
484 *
485 * @INPUT: Tx power in dBm
486 *
487 * @OUTPUT: None
488 *
489 * This IOTCL used to set 2 ghz tx power
490 *
491 * @E.g: iwpriv wlan0 txpow2g
492 *
493 * Supported Feature: STA
494 *
495 * Usage: Internal/External
496 *
497 * </ioctl>
498 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800499#define WE_SET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530500/*
501 * <ioctl>
502 * txpow5g - Current 5 GHz tx power setting
503 *
504 * @INPUT: Tx power in dBm
505 *
506 * @OUTPUT: None
507 *
508 * This IOTCL used to set the 5 ghz txpower
509 *
510 * @E.g: iwpriv wlan0 txpow5g
511 *
512 * Supported Feature: STA
513 *
514 * Usage: Internal/External
515 *
516 * </ioctl>
517 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800518#define WE_SET_TXPOW_5G 30
519/* Private ioctl for firmware debug log */
520#define WE_DBGLOG_LOG_LEVEL 31
521#define WE_DBGLOG_VAP_ENABLE 32
522#define WE_DBGLOG_VAP_DISABLE 33
523#define WE_DBGLOG_MODULE_ENABLE 34
524#define WE_DBGLOG_MODULE_DISABLE 35
525#define WE_DBGLOG_MOD_LOG_LEVEL 36
526#define WE_DBGLOG_TYPE 37
527#define WE_SET_TXRX_FWSTATS 38
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530528/*
529 * <ioctl>
530 * set11ACRates - Fixes the Tx data rate of 11AC
531 *
532 * @INPUT: 0x1 to 0x9
533 *
534 * @OUTPUT: None
535 *
536 * This IOCTL fixes the Tx data rate of 11AC.
537 *
538 * @E.g: iwpriv wlan0 set11ACRates 0x9
539 *
540 * Supported Feature: STA
541 *
542 * Usage: Internal/External
543 *
544 * </ioctl>
545 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546#define WE_SET_VHT_RATE 39
547#define WE_DBGLOG_REPORT_ENABLE 40
548#define WE_TXRX_FWSTATS_RESET 41
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530549/*
550 * <ioctl>
551 * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
552 *
553 * @INPUT: Transmission power in dBm
554 *
555 * @OUTPUT: None
556 *
557 * This IOCTL sets the maximum transmit power for the 2.4-GHz band
558 * This setting does not persist over reboots
559 *
560 * @E.g: iwpriv wlan0 setTxMaxPower2G 10
561 *
562 * Supported Feature: STA
563 *
564 * Usage: Internal/External
565 *
566 * </ioctl>
567 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568#define WE_SET_MAX_TX_POWER_2_4 42
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530569/*
570 * <ioctl>
571 * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
572 *
573 * @INPUT: Transmission power in dBm
574 *
575 * @OUTPUT: None
576 *
577 * This IOCTL sets the maximum transmit power for the 5-GHz band
578 * This setting does not persist over reboots
579 *
580 * @E.g: iwpriv wlan0 setTxMaxPower5G 10
581 *
582 * Supported Feature: STA
583 *
584 * Usage: Internal/External
585 *
586 * </ioctl>
587 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800589#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590/* Private ioctl for packet powe save */
591#define WE_PPS_PAID_MATCH 45
592#define WE_PPS_GID_MATCH 46
593#define WE_PPS_EARLY_TIM_CLEAR 47
594#define WE_PPS_EARLY_DTIM_CLEAR 48
595#define WE_PPS_EOF_PAD_DELIM 49
596#define WE_PPS_MACADDR_MISMATCH 50
597#define WE_PPS_DELIM_CRC_FAIL 51
598#define WE_PPS_GID_NSTS_ZERO 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530599/*
600 * <ioctl>
601 * rssi_chk - Chek the rssi
602 *
603 * @INPUT: One argument as input
604 *
605 * @OUTPUT: rssi
606 * wlan0 rssi_chk:56
607 *
608 * This IOTCL used to chek rssi
609 *
610 * @E.g: iwpriv wlan0 rssi_chk <value>
611 *
612 * Supported Feature: STA
613 *
614 * Usage: Internal/External
615 *
616 * </ioctl>
617 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618#define WE_PPS_RSSI_CHECK 53
619#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530620/*
621 * <ioctl>
622 * htsmps - Sets the htsmps
623 *
624 * @INPUT: Atleast one int argument
625 *
626 * @OUTPUT: None
627 *
628 * This IOTCL used to set htsmps
629 *
630 * @E.g: iwpriv wlan0 htsmps <value>
631 *
632 * Supported Feature: STA
633 *
634 * Usage: Internal/External
635 *
636 * </ioctl>
637 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638#define WE_SET_HTSMPS 55
639/* Private ioctl for QPower */
640#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
641#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
642#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
643#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530644/*
645 * <ioctl>
646 * burst_enable - Enables or disables the burst feature
647 *
648 * @INPUT: 0-Disable, 1-Enable
649 *
650 * @OUTPUT: None
651 *
652 * This IOCTL enables or disables the burst feature.
653 *
654 * @E.g: iwpriv wlan0 burst_enable 0
655 *
656 * Supported Feature: STA
657 *
658 * Usage: Internal/External
659 *
660 * </ioctl>
661 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662#define WE_SET_BURST_ENABLE 60
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530663/*
664 * <ioctl>
665 * burst_dur - Enables or disables the burst feature
666 *
667 * @INPUT: int 1…..int 8191 in microseconds
668 *
669 * @OUTPUT: None
670 *
671 * This IOCTL sets the burst duration.
672 *
673 * @E.g: iwpriv wlan0 burst_dur <value>
674 *
675 * Supported Feature: STA
676 *
677 * Usage: Internal/External
678 *
679 * </ioctl>
680 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681#define WE_SET_BURST_DUR 61
682/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530683/*
684 * <ioctl>
685 * gtxHTMcs - Set the tx HTM value
686 *
687 * @INPUT: Atleast one int orgument
688 *
689 * @OUTPUT: None
690 *
691 * This IOTCL sets htm tx value
692 *
693 * @E.g: iwpriv wlan0 gtxHTMcs <value>
694 *
695 * Supported Feature: STA
696 *
697 * Usage: Internal/External
698 *
699 * </ioctl>
700 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701#define WE_SET_GTX_HT_MCS 62
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530702/*
703 * <ioctl>
704 * gtxVHTMcs - Set gtxVHTMcs value
705 *
706 * @INPUT: Atleast one int argument
707 *
708 * @OUTPUT: None
709 *
710 * This IOTCL used to set gtxVHTMcs value
711 *
712 * @E.g: iwpriv wlan0 gtxVHTMcs <value>
713 *
714 * Supported Feature: STA
715 *
716 * Usage: Internal/External
717 *
718 * </ioctl>
719 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720#define WE_SET_GTX_VHT_MCS 63
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530721/*
722 * <ioctl>
723 * gtxUsrCfg - Host request for GTX mask
724 *
725 * @INPUT: Atleast one int orgument
726 *
727 * @OUTPUT: None
728 *
729 * This IOTCL used send the host request for GTX mask
730 *
731 * @E.g: iwpriv wlan0 gtxUsrCfg <value>
732 *
733 * Supported Feature: STA
734 *
735 * Usage: Internal/External
736 *
737 * </ioctl>
738 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739#define WE_SET_GTX_USRCFG 64
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530740/*
741 * <ioctl>
742 * gtxThre - Set the tx threshold
743 *
744 * @INPUT: Atleast one int argument
745 *
746 * @OUTPUT: None
747 *
748 * This IOTCL used to set tx threshold
749 *
750 * @E.g: iwpriv wlan0 gtxThre <value>
751 *
752 * Supported Feature: STA
753 *
754 * Usage: Internal/External
755 *
756 * </ioctl>
757 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758#define WE_SET_GTX_THRE 65
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530759/*
760 * <ioctl>
761 * gtxMargin - Set the gtxMargin
762 *
763 * @INPUT: 1 to 32
764 *
765 * @OUTPUT: None
766 *
767 * This IOTCL use dto set gtxMargin
768 *
769 * @E.g: iwpriv wlan0 gtxMargini <value>
770 *
771 * Supported Feature: STA
772 *
773 * Usage: Internal/External
774 *
775 * </ioctl>
776 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777#define WE_SET_GTX_MARGIN 66
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530778/*
779 * <ioctl>
780 * gtxStep - Set the gtxStep
781 *
782 * @INPUT: None
783 *
784 * @OUTPUT: None
785 *
786 * This IOTCL used to sets gtxStep
787 *
788 * @E.g: iwpriv wlan0 gtxStep <value>
789 *
790 * Supported Feature: STA
791 *
792 * Usage: Internal/External
793 *
794 * </ioctl>
795 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796#define WE_SET_GTX_STEP 67
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530797/*
798 * <ioctl>
799 * gtxMinTpc - Sets the gtxMinTpc
800 *
801 * @INPUT: Atleast one int argument
802 *
803 * @OUTPUT: None
804 *
805 * This IOTCL sets the tx MinTpc
806 *
807 * @E.g: iwpriv wlan0 gtxMinTpc <value>
808 *
809 * Supported Feature: STA
810 *
811 * Usage: Internal/External
812 *
813 * </ioctl>
814 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815#define WE_SET_GTX_MINTPC 68
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530816/*
817 * <ioctl>
818 * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
819 *
820 * @INPUT: Mask value
821 *
822 * @OUTPUT: None
823 *
824 * This IOTCL used to set gtxBWMask
825 *
826 * @E.g: iwpriv wlan0 gtxBWMask <value>
827 *
828 * Supported Feature: STA
829 *
830 * Usage: Internal/External
831 *
832 * </ioctl>
833 */
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530834
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530835#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530836/*
837 * <ioctl>
838 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
839 *
840 * @INPUT: set_value
841 *
842 * @OUTPUT: None
843 *
844 * This IOCTL is used to set the MCC latency value in milliseconds
845 * during STA-P2P concurrency.
846 *
847 * If 0ms latency is provided, then FW will set to a default.
848 * Otherwise, latency must be at least 30ms.
849 *
850 * @E.g: iwpriv wlan0 setMccLatency 40
851 *
852 *
853 * Supported Feature: Concurrency
854 *
855 * Usage: Internal/External
856 *
857 * </ioctl>
858 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530860
861/*
862 * <ioctl>
863 * setMccQuota- Set the quota for P2P cases
864 *
865 * @INPUT: set_value [0,100]
866 *
867 * @OUTPUT: None
868 *
869 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
870 *
871 * Currently used to set time quota for 2 MCC vdevs/adapters using
872 * (operating channel, quota) for each mode.
873 * The info is provided run time using iwpriv command:
874 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
875 * Note: the quota provided in command is for the same mode in cmd.
876 * HDD checks if MCC mode is active, gets the second mode and its
877 * operating chan.
878 * Quota for the 2nd role is calculated as 100 - quota of first mode.
879 *
880 * @E.g: iwpriv wlan0 setMccQuota 50
881 * iwpriv p2p0 setMccQuota 50
882 *
883 * Supported Feature: Concurrency
884 *
885 * Usage: Internal/External
886 *
887 * </ioctl>
888 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889#define WE_MCC_CONFIG_QUOTA 71
890/* Private IOCTL for debug connection issues */
891#define WE_SET_DEBUG_LOG 72
892#ifdef WE_SET_TX_POWER
893#undef WE_SET_TX_POWER
894#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530895/*
896 * <ioctl>
897 * setTxPower - Set the current transmit power
898 *
899 * @INPUT: Transmission power in dBm
900 *
901 * @OUTPUT: None
902 *
903 * This IOCTL sets the current transmit power.
904 * This setting does not persist over reboots.
905 *
906 * @E.g: iwpriv wlan0 setTxPower 10
907 *
908 * Supported Feature: STA
909 *
910 * Usage: Internal/External
911 *
912 * </ioctl>
913 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914#define WE_SET_TX_POWER 74
915/* Private ioctl for earlyrx power save feature */
916#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
917#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
918#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
919#define WE_SET_EARLY_RX_SLOP_STEP 78
920#define WE_SET_EARLY_RX_INIT_SLOP 79
921#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530922/*
923 * <ioctl>
924 * setMcRate - Set the data rate for multicast data
925 *
926 * @INPUT: 1 to 32
927 *
928 * @OUTPUT: None
929 *
930 * This IOCTL sets the data rate for multicast data. Note that this command
931 * is allowed only in STA, IBSS, or QCMobileAP mode
932 *
933 * @E.g: iwpriv wlan0 setMcRate <value>
934 *
935 * Supported Feature: STA
936 *
937 * Usage: Internal/External
938 *
939 * </ioctl>
940 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941#define WE_SET_MC_RATE 81
942#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
943/* Private ioctl for packet power save */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530944/*
945 * <ioctl>
946 * 5g_ebt - Sets the 5g_ebt
947 *
948 * @INPUT: <value>
949 *
950 * @OUTPUT: None
951 *
952 * This IOTCL used to set 5g_ebt
953 *
954 * @E.g: iwpriv wlan0 5g_ebt <value>
955 *
956 * Supported Feature: STA
957 *
958 * Usage: Internal/External
959 *
960 * </ioctl>
961 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962#define WE_PPS_5G_EBT 83
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530963/*
964 * <ioctl>
965 * cts_cbw - Set CTS channel BW for dynamic BW adjustment
966 *
967 * @INPUT: 20 t0 160
968 *
969 * @OUTPUT: None
970 *
971 * This IOTCL used to set CTS channel BW for dynamic BW adjustment
972 *
973 * @E.g: iwpriv wlan0 cts_cbw <value>
974 *
975 * Supported Feature: STA
976 *
977 * Usage: Internal/External
978 *
979 * </ioctl>
980 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981#define WE_SET_CTS_CBW 84
982#define WE_DUMP_STATS 85
983#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530984/* Private sub ioctl for starting/stopping the profiling */
985#define WE_START_FW_PROFILE 87
Abhishek Singh3c507012016-12-01 11:15:42 +0530986/*
987 * <ioctl>
988 * setChanChange - Initiate channel change
989 *
990 * @INPUT: channel number to switch to.
991 *
992 * @OUTPUT: None
993 *
994 * This IOCTL is used to initiate a channel change.
995 * If called on STA/CLI interface it will send the
996 * ECSA action frame to the connected SAP/GO asking to
997 * initiate the ECSA, if supported.
998 * If called on SAP/GO interface it will initiate
999 * ECSA and ask connected peers to move to new channel.
1000 *
1001 * @E.g: iwpriv wlan0 setChanChange <channel>
1002 * iwpriv wlan0 setChanChange 1
1003 *
1004 * Supported Feature: ECSA
1005 *
1006 * Usage: Internal/External
1007 *
1008 * </ioctl>
1009 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +05301010#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05301011#define WE_SET_CONC_SYSTEM_PREF 89
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08001012#define WE_SET_TXRX_STATS 90
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08001014/*
1015 * <ioctl>
1016 * set_11ax_rate - set 11ax rates to FW
1017 *
1018 * @INPUT: rate code
1019 *
1020 * @OUTPUT: None
1021 *
1022 * This IOCTL fixes the Tx data rate of 11AX.
1023 *
1024 * @E.g: iwpriv wlan0 set_11ax_rate <rate code>
1025 *
1026 * Supported Feature: STA/SAP
1027 *
1028 * Usage: Internal
1029 *
1030 * </ioctl>
1031 */
1032#define WE_SET_11AX_RATE 91
1033
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001034/*
1035 * <ioctl>
1036 * enable_dcm - enable Dual Carrier Modulation(DCM)
1037 *
1038 * @INPUT: 0/1
1039 *
1040 * @OUTPUT: None
1041 *
1042 * This IOCTL enables/disables DCM.
1043 *
1044 * @E.g: iwpriv wlan0 enable_dcm <0/1>
1045 *
1046 * Supported Feature: STA/SAP
1047 *
1048 * Usage: Internal
1049 *
1050 * </ioctl>
1051 */
1052#define WE_SET_DCM 92
1053
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001054/*
1055 * <ioctl>
1056 * enable_range_ext - enable Range extension
1057 *
1058 * @INPUT: 0/1
1059 *
1060 * @OUTPUT: None
1061 *
1062 * This IOCTL enables/disables Range extension.
1063 *
1064 * @E.g: iwpriv wlan0 enable_range_ext <0/1>
1065 *
1066 * Supported Feature: STA/SAP
1067 *
1068 * Usage: Internal
1069 *
1070 * </ioctl>
1071 */
1072#define WE_SET_RANGE_EXT 93
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001073
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074/* Private ioctls and their sub-ioctls */
1075#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
1076#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077#define WE_SET_SAP_CHANNELS 3
1078#define WE_GET_WLAN_DBG 4
1079#define WE_GET_MAX_ASSOC 6
1080/* 7 is unused */
1081#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +05301082
1083/*
1084 * <ioctl>
1085 * getconcurrency - Get concurrency mode
1086 *
1087 * @INPUT: None
1088 *
1089 * @OUTPUT: It shows concurrency value
1090 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
1091 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
1092 * 8:OCB 9:EPPING 10:QVIT 11:NDI
1093 *
1094 * This IOCTL is used to retrieve concurrency mode.
1095 *
1096 * @E.g: iwpriv wlan0 getconcurrency
1097 * wlan0 getconcurrency:5
1098 * Above value shows STA+P2P_Client
1099 *
1100 * Supported Feature: Concurrency
1101 *
1102 * Usage: Internal/External
1103 *
1104 * </ioctl>
1105 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106#define WE_GET_CONCURRENCY_MODE 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301107/*
1108 * <ioctl>
1109 * get_nss - Get the number of spatial STBC streams (NSS)
1110 *
1111 * @INPUT: None
1112 *
1113 * @OUTPUT: NSS
1114 * wlan0 get_nss:2
1115 *
1116 * This IOTCL used to get the number of spatial STBC streams
1117 *
1118 * @E.g: iwpriv wlan0 get_nss
1119 *
1120 * Supported Feature: STA
1121 *
1122 * Usage: Internal/External
1123 *
1124 * </ioctl>
1125 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126#define WE_GET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301127/*
1128 * <ioctl>
1129 * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1130 *
1131 * @INPUT: None
1132 *
1133 * @OUTPUT: ldpc
1134 * wlan0 get_ldpc:1
1135 *
1136 * This IOTCL used to gets the low density parity check (LDPC)
1137 *
1138 * @E.g: iwpriv wlan0 get_ldpc
1139 *
1140 * Supported Feature: STA
1141 *
1142 * Usage: Internal/External
1143 *
1144 * </ioctl>
1145 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146#define WE_GET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301147/*
1148 * <ioctl>
1149 * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1150 *
1151 * @INPUT: None
1152 *
1153 * @OUTPUT: TXSTBC
1154 * wlan0 get_tx_stbc:1
1155 *
1156 * This IOTCL get the value of the current Tx space time block code (STBC)
1157 *
1158 * @E.g: iwpriv wlan0 get_tx_stbc
1159 *
1160 * Supported Feature: STA
1161 *
1162 * Usage: Internal/External
1163 *
1164 * </ioctl>
1165 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166#define WE_GET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301167/*
1168 * <ioctl>
1169 * get_rx_stbc - Gets the value of the current Rx STBC
1170 *
1171 * @INPUT: None
1172 *
1173 * @OUTPUT: Rx STBC
1174 * wlan0 get_rx_stbc:1
1175 *
1176 * This IOTCL used to get the value of the current Rx STBC
1177 *
1178 * @E.g: iwpriv wlan0 get_rx_stbc
1179 *
1180 * Supported Feature: STA
1181 *
1182 * Usage: Internal/External
1183 *
1184 * </ioctl>
1185 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186#define WE_GET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301187/*
1188 * <ioctl>
1189 * get_shortgi - Get the value of the current short GI setting
1190 *
1191 * @INPUT: None
1192 *
1193 * @OUTPUT: Enable/disable of shortgi
1194 * wlan0 get_shortgi:1
1195 *
1196 * This IOCTL gets the value of the current short GI setting
1197 *
1198 * @E.g: iwpriv wlan0 get_shortgi
1199 *
1200 * Supported Feature: STA
1201 *
1202 * Usage: Internal/External
1203 *
1204 * </ioctl>
1205 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206#define WE_GET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301207/*
1208 * <ioctl>
1209 * get_rtscts - Get the value of the current RTS/CTS setting.
1210 *
1211 * @INPUT: None
1212 *
1213 * @OUTPUT: Enable/disable of RTS/CTS
1214 * wlan0 get_rtscts:33
1215 *
1216 * This IOTCL get the value of the current RTS/CTS setting.
1217 *
1218 * @E.g: iwpriv wlan0 get_rtscts
1219 *
1220 * Supported Feature: STA
1221 *
1222 * Usage: Internal/External
1223 *
1224 * </ioctl>
1225 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226#define WE_GET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301227/*
1228 * <ioctl>
1229 * get_chwidth - Get the current channel width setting
1230 *
1231 * @INPUT: None
1232 *
1233 * @OUTPUT: channel width
1234 * wlan0 get_chwidth:0
1235 *
1236 * This IOTCL get the current channel width setting.
1237 *
1238 * @E.g: iwpriv wlan0 get_chwidth
1239 *
1240 * Supported Feature: STA
1241 *
1242 * Usage: Internal/External
1243 *
1244 * </ioctl>
1245 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246#define WE_GET_CHWIDTH 17
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301247/*
1248 * <ioctl>
1249 * get_anienable - Get the anienable
1250 *
1251 * @INPUT: None
1252 *
1253 * @OUTPUT:
1254 * wlan0 get_anienable:0
1255 *
1256 * This IOTCL get the anienable
1257 *
1258 * @E.g: iwpriv wlan0 get_anienable
1259 *
1260 * Supported Feature: STA
1261 *
1262 * Usage: Internal/External
1263 *
1264 * </ioctl>
1265 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266#define WE_GET_ANI_EN_DIS 18
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301267/*
1268 * <ioctl>
1269 * get_aniplen - Get the aniplen
1270 *
1271 * @INPUT: None
1272 *
1273 * @OUTPUT:
1274 * wlan0 get_aniplen:0
1275 *
1276 * This IOTCL get the aniplen
1277 *
1278 * @E.g: iwpriv wlan0 get_aniplen
1279 *
1280 * Supported Feature: STA
1281 *
1282 * Usage: Internal/External
1283 *
1284 * </ioctl>
1285 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286#define WE_GET_ANI_POLL_PERIOD 19
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301287/*
1288 * <ioctl>
1289 * get_anilislen- Get the anilislen
1290 *
1291 * @INPUT: None
1292 *
1293 * @OUTPUT:
1294 * wlan0 get_anilislen:0
1295 *
1296 * This IOTCL used to get anilislen
1297 *
1298 * @E.g: iwpriv wlan0 get_anilislen
1299 *
1300 * Supported Feature: STA
1301 *
1302 * Usage: Internal/External
1303 *
1304 * </ioctl>
1305 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306#define WE_GET_ANI_LISTEN_PERIOD 20
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301307/*
1308 * <ioctl>
1309 * get_aniofdmlvl - Get the OFDM level
1310 *
1311 * @INPUT: None
1312 *
1313 * @OUTPUT: OFDM
1314 * wlan0 get_aniofdmlvl:0
1315 *
1316 * This IOTCL used to get ofdm level
1317 *
1318 * @E.g: iwpriv wlan0 get_aniofdmlvl
1319 *
1320 * Supported Feature: STA
1321 *
1322 * Usage: Internal/External
1323 *
1324 * </ioctl>
1325 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326#define WE_GET_ANI_OFDM_LEVEL 21
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301327/*
1328 * <ioctl>
1329 * get_aniccklvl - Get the cck level
1330 *
1331 * @INPUT: None
1332 *
1333 * @OUTPUT:
1334 * wlan0 get_aniccklvl:0
1335 *
1336 * This IOTCL used to get cck level
1337 *
1338 * @E.g: iwpriv wlan0 get_aniccklvl
1339 *
1340 * Supported Feature: STA
1341 *
1342 * Usage: Internal/External
1343 *
1344 * </ioctl>
1345 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346#define WE_GET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301347/*
1348 * <ioctl>
1349 * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1350 *
1351 * @INPUT: None
1352 *
1353 * @OUTPUT: Enable/disable dynamic channel bandwidth
1354 * wlan0 get_cwmenable:0
1355 *
1356 * This IOTCL get the value of the dynamic channel bandwidth setting
1357 *
1358 * @E.g: iwpriv wlan0 get_cwmenable
1359 *
1360 * Supported Feature: STA
1361 *
1362 * Usage: Internal/External
1363 *
1364 * </ioctl>
1365 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366#define WE_GET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301367/*
1368 * <ioctl>
1369 * get_txchainmask - Get the txchainmask that was set
1370 *
1371 * @INPUT: None
1372 *
1373 * @OUTPUT: txchainmask
1374 * wlan0 get_txchainmask:1
1375 *
1376 * This IOCTL gets the txchainmask that was set
1377 * This command is useful if it was previously set
1378 *
1379 * @E.g: iwpriv wlan0 get_txchainmask
1380 *
1381 * Supported Feature: STA
1382 *
1383 * Usage: Internal/External
1384 *
1385 * </ioctl>
1386 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387#define WE_GET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301388/*
1389 * <ioctl>
1390 * get_rxchainmask - Get the rxchainmask that was set
1391 *
1392 * @INPUT: None
1393 *
1394 * @OUTPUT: rxchainmask
1395 * wlan0 get_rxchainmask:1
1396 *
1397 * This IOCTL gets the rxchainmask that was set
1398 * This command is useful only if it was previously set.
1399 *
1400 * @E.g: iwpriv wlan0 get_rxchainmask
1401 *
1402 * Supported Feature: STA
1403 *
1404 * Usage: Internal/External
1405 *
1406 * </ioctl>
1407 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408#define WE_GET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301409/*
1410 * <ioctl>
1411 * get_11nrate - Get the fixed Tx data rate
1412 *
1413 * @INPUT: None
1414 *
1415 * @OUTPUT: Using this command does not return the same value as set
1416 * wlan0 get_11nrate:0
1417 *
1418 * This IOCTL gets the fixed Tx data rate
1419 * This command is useful only if setting the fixed Tx rate.
1420 *
1421 * @E.g: iwpriv wlan0 get_11nrate
1422 *
1423 * Supported Feature: STA
1424 *
1425 * Usage: Internal/External
1426 *
1427 * </ioctl>
1428 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429#define WE_GET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301430/*
1431 * <ioctl>
1432 * get_ampdu - Get the maximum subframe of ampdu
1433 *
1434 * @INPUT: None
1435 *
1436 * @OUTPUT: Maximum subframe of ampdu
1437 * wlan0 get_ampdu:1
1438 *
1439 * This IOCTL gets the maximum subframe of ampdu
1440 * This command is useful only if setting ampdu.
1441 *
1442 * @E.g: iwpriv wlan0 get_ampdu
1443 *
1444 * Supported Feature: STA
1445 *
1446 * Usage: Internal/External
1447 *
1448 * </ioctl>
1449 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450#define WE_GET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301451/*
1452 * <ioctl>
1453 * get_amsdu - Get the maximum subframe of amsdu
1454 *
1455 * @INPUT: None
1456 *
1457 * @OUTPUT: Maximum subframe of amsdu
1458 * wlan0 get_amsdu:1
1459 *
1460 * This IOCTL gets the maximum subframe of amsdu.
1461 * This command is useful only if setting amsdu
1462 *
1463 * @E.g: iwpriv wlan0 get_amsdu
1464 *
1465 * Supported Feature: STA
1466 *
1467 * Usage: Internal/External
1468 *
1469 * </ioctl>
1470 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471#define WE_GET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301472/*
1473 * <ioctl>
1474 * get_txpow2g - Get the current 2 GHz Tx power setting
1475 *
1476 * @INPUT: None
1477 *
1478 * @OUTPUT: Tx Power in dbm
1479 * wlan0 get_txpow2g:0
1480 *
1481 * This IOCTL gets the current 2 GHz Tx power setting
1482 * This command is useful if setting Tx power
1483 *
1484 * @E.g: iwpriv wlan0 get_txpow2g
1485 *
1486 * Supported Feature: STA
1487 *
1488 * Usage: Internal/External
1489 *
1490 * </ioctl>
1491 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492#define WE_GET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301493/*
1494 * <ioctl>
1495 * get_txpow5g - Get the current 5 GHz Tx power setting
1496 *
1497 * @INPUT: None
1498 *
1499 * @OUTPUT: Tx Power in dbm
1500 * wlan0 get_txpow5g:0
1501 *
1502 * This IOCTL gets the current 5 GHz Tx power setting
1503 * This command is useful if setting Tx power
1504 *
1505 * @E.g: iwpriv wlan0 get_txpow5g
1506 *
1507 * Supported Feature: STA
1508 *
1509 * Usage: Internal/External
1510 *
1511 * </ioctl>
1512 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -08001514/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515#define WE_GET_PPS_PAID_MATCH 32
1516#define WE_GET_PPS_GID_MATCH 33
1517#define WE_GET_PPS_EARLY_TIM_CLEAR 34
1518#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
1519#define WE_GET_PPS_EOF_PAD_DELIM 36
1520#define WE_GET_PPS_MACADDR_MISMATCH 37
1521#define WE_GET_PPS_DELIM_CRC_FAIL 38
1522#define WE_GET_PPS_GID_NSTS_ZERO 39
1523#define WE_GET_PPS_RSSI_CHECK 40
1524/* Private ioctl for QPower */
1525#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
1526#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
1527#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
1528#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301529/*
1530 * <ioctl>
1531 * get_burst_en - Enables or disables the burst feature
1532 *
1533 * @INPUT: None
1534 *
1535 * @OUTPUT: Enable/disable of burst feature
1536 * wlan0 get_burst_en:1
1537 *
1538 * This IOCTL enables or disables the burst feature
1539 *
1540 * @E.g: iwpriv wlan0 get_burst_en
1541 *
1542 * Supported Feature:STA
1543 *
1544 * Usage: Internal/External
1545 *
1546 * </ioctl>
1547 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548#define WE_GET_BURST_ENABLE 45
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301549/*
1550 * <ioctl>
1551 * get_burst_dur - Get the burst duration
1552 *
1553 * @INPUT: None
1554 *
1555 * @OUTPUT: Duration in microseconds
1556 * wlan0 get_burst_dur:8160
1557 *
1558 * This IOCTL gets the burst duration
1559 * This command is useful if setting burst enable
1560 *
1561 * @E.g: iwpriv wlan0 get_burst_dur
1562 *
1563 * Supported Feature: STA
1564 *
1565 * Usage: Internal/External
1566 *
1567 * </ioctl>
1568 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569#define WE_GET_BURST_DUR 46
1570/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301571/*
1572 * <ioctl>
1573 * get_gtxHTMcs - Get the tx HTM
1574 *
1575 * @INPUT: None
1576 *
1577 * @OUTPUT: HTM
1578 * wlan0 get_gtxHTMcs:32896
1579 *
1580 * This IOTCL used to get HTM
1581 *
1582 * @E.g: iwpriv wlan0 get_gtxHTMcs
1583 *
1584 * Supported Feature: STA
1585 *
1586 * Usage: Internal/External
1587 *
1588 * </ioctl>
1589 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590#define WE_GET_GTX_HT_MCS 47
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301591/*
1592 * <ioctl>
1593 * get_gtxVHTMcs - Get the VHTM
1594 *
1595 * @INPUT: None
1596 *
1597 * @OUTPUT: VHTM
1598 * wlan0 get_gtxVHTMcs:524800
1599 *
1600 * This IOTCL used to get the VHTM
1601 *
1602 * @E.g: iwpriv wlan0 get_gtxVHTMcs
1603 *
1604 * Supported Feature: STA
1605 *
1606 * Usage: Internal/External
1607 *
1608 * </ioctl>
1609 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610#define WE_GET_GTX_VHT_MCS 48
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301611/*
1612 * <ioctl>
1613 * get_gtxUsrCfg - Get the tx cfg
1614 *
1615 * @INPUT: None
1616 *
1617 * @OUTPUT: TXCFG
1618 * wlan0 get_gtxUsrCfg:32
1619 *
1620 * This IOTCL used to get the tx cfg
1621 *
1622 * @E.g: iwpriv wlan0 get_gtxUsrCfg
1623 *
1624 * Supported Feature: STA
1625 *
1626 * Usage: Internal/External
1627 *
1628 * </ioctl>
1629 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630#define WE_GET_GTX_USRCFG 49
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301631/*
1632 * <ioctl>
1633 * get_gtxThre - Get the tx threshold
1634 *
1635 * @INPUT: None
1636 *
1637 * @OUTPUT: Threshold
1638 * wlan0 get_gtxThre:3
1639 *
1640 * This IOCTL is used to get tx threshold
1641 *
1642 * @E.g: iwpriv wlan0 get_gtxThre
1643 *
1644 * Supported Feature: STA
1645 *
1646 * Usage: Internal/External
1647 *
1648 * </ioctl>
1649 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650#define WE_GET_GTX_THRE 50
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301651/*
1652 * <ioctl>
1653 * get_gtxMargin - Get the tx margin
1654 *
1655 * @INPUT: None
1656 *
1657 * @OUTPUT: GTXMARGIN
1658 * wlan0 get_gtxMargin:2
1659 *
1660 * This IOCTL is used to set tx margin
1661 *
1662 * @E.g: iwpriv wlan0 get_gtxMargin
1663 *
1664 * Supported Feature: STA
1665 *
1666 * Usage: Internal/External
1667 *
1668 * </ioctl>
1669 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670#define WE_GET_GTX_MARGIN 51
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301671/*
1672 * <ioctl>
1673 * get_gtxStep - Get the tx step
1674 *
1675 * @INPUT: None
1676 *
1677 * @OUTPUT: GTXSTEP
1678 * wlan0 get_gtxStep:0
1679 *
1680 * This IOCTL is used to get the gtx step
1681 *
1682 * @E.g: iwpriv wlan0 get_gtxStep
1683 *
1684 * Supported Feature: STA
1685 *
1686 * Usage: Internal/External
1687 *
1688 * </ioctl>
1689 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690#define WE_GET_GTX_STEP 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301691/*
1692 * <ioctl>
1693 * get_gtxMinTpc - Get the tx miminum tpc
1694 *
1695 * @INPUT: None
1696 *
1697 * @OUTPUT: TPC
1698 * wlan0 get_gtxMinTpc:0
1699 *
1700 * This IOCTL is used to get tx miminum tpc
1701 *
1702 * @E.g: iwpriv wlan0 get_gtxMinTpc
1703 *
1704 * Supported Feature: STA
1705 *
1706 * Usage: Internal/External
1707 *
1708 * </ioctl>
1709 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710#define WE_GET_GTX_MINTPC 53
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301711/*
1712 * <ioctl>
1713 * get_gtxBWMask - Get the tx BW MASK
1714 *
1715 * @INPUT: None
1716 *
1717 * @OUTPUT: MASK
1718 * wlan0 get_gtxBWMask:15
1719 *
1720 * This IOCTL is used get gtx bw mask
1721 *
1722 * @E.g: iwpriv wlan0 get_gtxBWMask
1723 *
1724 * Supported Feature: STA
1725 *
1726 * Usage: Internal/External
1727 *
1728 * </ioctl>
1729 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730#define WE_GET_GTX_BWMASK 54
1731#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001732#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07001733#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001735/*
1736 * <ioctl>
1737 * get_dcm - Get dcm enablement value
1738 *
1739 * @INPUT: None
1740 *
1741 * @OUTPUT: 0/1
1742 * wlan0 get_dcm
1743 *
1744 * This IOCTL is used get dcm value
1745 *
1746 * Supported Feature: STA/SAP
1747 *
1748 * Usage: Internal
1749 *
1750 * </ioctl>
1751 */
1752#define WE_GET_DCM 60
1753
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001754/*
1755 * <ioctl>
1756 * get_dcm - Get range extension enablement value
1757 *
1758 * @INPUT: None
1759 *
1760 * @OUTPUT: 0/1
1761 * wlan0 get_range_ext
1762 *
1763 * This IOCTL is used get range_extension value
1764 *
1765 * Supported Feature: STA/SAP
1766 *
1767 * Usage: Internal
1768 *
1769 * </ioctl>
1770 */
1771#define WE_GET_RANGE_EXT 61
1772
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773/* Private ioctls and their sub-ioctls */
1774#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
1775
1776/* Private ioctls and their sub-ioctls */
1777#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
1778#define WE_WOWL_ADD_PTRN 1
1779#define WE_WOWL_DEL_PTRN 2
Sreelakshmi Konamkided64d72017-02-23 10:39:26 +05301780/*
1781 * <ioctl>
1782 * neighbor - Send neighbor report request
1783 *
1784 * @INPUT: string
1785 *
1786 * @OUTPUT: None
1787 *
1788 * This IOCTL create a Neighbor report request and send it to peer
1789 *
1790 * @E.g: iwpriv wlan0 neighbor "SSID"
1791 *
1792 * Supported Feature: 11k
1793 *
1794 * Usage: Internal/External
1795 *
1796 * </ioctl>
1797 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798#define WE_NEIGHBOR_REPORT_REQUEST 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301799/*
1800 * <ioctl>
1801 * set_ap_wps_ie - Set the P2P IE of the probe response
1802 *
1803 * @INPUT: string
1804 *
1805 * @OUTPUT: None
1806 *
1807 * This IOCTL sets the P2P IE of the probe response
1808 *
1809 * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1810 *
1811 * Supported Feature: STA
1812 *
1813 * Usage: Internal/External
1814 *
1815 * </ioctl>
1816 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817#define WE_SET_AP_WPS_IE 4 /* This is called in station mode to set probe rsp ie. */
1818#define WE_SET_CONFIG 5
1819
1820/* Private ioctls and their sub-ioctls */
1821#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
1822#define WE_SET_WLAN_DBG 1
1823#define WE_SET_DP_TRACE 2
1824#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05301825#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826
1827/* Private ioctls and their sub-ioctls */
1828#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
1829#define WE_WLAN_VERSION 1
1830#define WE_GET_STATS 2
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301831/*
1832 * <ioctl>
1833 * getConfig - gets the values of all configurations listed in WCNSS
1834 *
1835 * @INPUT: None
1836 *
1837 * @OUTPUT: Current configuration to the sys log
1838 * wlan0 getConfig: WLAN configuration written to system log
1839 *
1840 * This IOCTL gets the values of all configurations listed in WCNSS
1841 *
1842 * @E.g: iwpriv wlan0 getConfig
1843 *
1844 * Supported Feature: STA
1845 *
1846 * Usage: Internal/External
1847 *
1848 * </ioctl>
1849 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850#define WE_GET_CFG 3
1851#define WE_GET_WMM_STATUS 4
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301852/*
1853 * <ioctl>
1854 * getChannelList - Get the available channel list while in QCMobileAP
1855 *
1856 * @INPUT: None
1857 *
1858 * @OUTPUT: Channel list
1859 * wlan0 getChannelList:36 US 1..165
1860 *
1861 * This IOCTL gets the available channel list while in QCMobileAP
1862 *
1863 * @E.g: iwpriv wlan0 getChannelList
1864 *
1865 * Supported Feature: STA
1866 *
1867 * Usage: Internal/External
1868 *
1869 * </ioctl>
1870 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871#define WE_GET_CHANNEL_LIST 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301872/*
1873 * <ioctl>
1874 * getRSSI - Get the Received Signal Strength Indicator
1875 *
1876 * @INPUT: None
1877 *
1878 * @OUTPUT: RSSI
1879 * wlan0 getRSSI:rsssi=-32
1880 *
1881 * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1882 *
1883 * @E.g: iwpriv wlan0 getRSSI
1884 *
1885 * Supported Feature: STA
1886 *
1887 * Usage: Internal/External
1888 *
1889 * </ioctl>
1890 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -08001892
1893/*
1894 * <ioctl>
1895 * getSuspendStats - Get suspend/resume stats
1896 *
1897 * @INPUT: None
1898 *
1899 * @OUTPUT: character string containing formatted suspend/resume stats
1900 *
1901 * This ioctl is used to get suspend/resume stats formatted for display.
1902 * Currently it includes suspend/resume counts, wow wake up reasons, and
1903 * suspend fail reasons.
1904 *
1905 * @E.g: iwpriv wlan0 getSuspendStats
1906 * iwpriv wlan0 getSuspendStats
1907 *
1908 * Supported Feature: suspend/resume
1909 *
1910 * Usage: Internal
1911 *
1912 * </ioctl>
1913 */
1914#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05301916/*
1917 * <ioctl>
1918 * getTdlsPeers - Get all TDLS peers.
1919 *
1920 * @INPUT: None
1921 *
1922 * @OUTPUT: Returns the MAC address of all the TDLS peers
1923 * wlan0 getTdlsPeers:
1924 * MAC Id cap up RSSI
1925 * ---------------------------------
1926 * 00:0a:f5:0e:bd:18 2 Y Y -44
1927 * 00:0a:f5:bf:0e:12 0 N N 0
1928 *
1929 * This IOCTL is used to get all TDLS peers.
1930 *
1931 * @E.g: iwpriv wlan0 getTdlsPeers
1932 *
1933 * Supported Feature: TDLS
1934 *
1935 * Usage: Internal/External
1936 *
1937 * </ioctl>
1938 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939#define WE_GET_TDLS_PEERS 8
1940#endif
1941#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +05301942/*
1943 * <ioctl>
1944 * getPMFInfo - get the PMF info of the connected session
1945 *
1946 * @INPUT: None
1947 *
1948 * @OUTPUT:
1949 * wlan0 getPMFInfo:
1950 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
1951 * Number of Unprotected Disassocs 0
1952 * Number of Unprotected Deauths 0
1953 *
1954 * This IOCTL is used to get the PMF stats/status of the current
1955 * connection.
1956 *
1957 * @e.g:iwpriv wlan0 getPMFInfo
1958 *
1959 * Supported Feature: PMF
1960 *
1961 * Usage: Internal/External
1962 *
1963 * </ioctl>
1964 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965#define WE_GET_11W_INFO 9
1966#endif
1967#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +05301968/*
1969 * <ioctl>
1970 * getIbssSTAs - get ibss sta info
1971 *
1972 * @INPUT: None
1973 *
1974 * @OUTPUT: Give the MAC of the IBSS STA
1975 * wlan0 getIbssSTAs:
1976 * 1 .8c:fd:f0:01:9c:bf
1977 *
1978 * This IOCTL is used to get ibss sta info
1979 *
1980 * @E.g: iwpriv wlan0 getIbssSTAs
1981 *
1982 * Supported Feature: IBSS
1983 *
1984 * Usage: Internal/External
1985 *
1986 * </ioctl>
1987 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001988#define WE_GET_IBSS_STA_INFO 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301989/*
1990 * <ioctl>
1991 * getphymode - Get the current phymode.
1992 *
1993 * @INPUT: None
1994 *
1995 * @OUTPUT: In phymode
1996 * wlan0 getphymode:AUTO MODE
1997 *
1998 * This IOCTL used to gets the current phymode.
1999 *
2000 * @E.g: iwpriv wlan0 getphymode
2001 *
2002 * Supported Feature: STA
2003 *
2004 * Usage: Internal/External
2005 *
2006 * </ioctl>
2007 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008#define WE_GET_PHYMODE 12
Naveen Rawat910726a2017-03-06 11:42:51 -08002009
2010/*
2011 * <ioctl>
2012 * getOemDataCap - Get the oem data caps.
2013 *
2014 * @INPUT: None
2015 *
2016 * @OUTPUT: oem data capability
2017 *
2018 * This IOCTL used to gets the current oem data cap.
2019 *
2020 * @E.g: iwpriv wlan0 getOemDataCap
2021 *
2022 * Usage: Internal/External
2023 *
2024 * </ioctl>
2025 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026#define WE_GET_OEM_DATA_CAP 13
Naveen Rawat910726a2017-03-06 11:42:51 -08002027
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302028/*
2029 * <ioctl>
2030 * getSNR - Enable SNR Monitoring
2031 *
2032 * @INPUT: None
2033 *
2034 * @OUTPUT: Signal strength/ratio
2035 * wlan0 getSNR:1
2036 *
2037 * This IOCTL is used to get ibss sta info
2038 *
2039 * @E.g: iwpriv wlan0 getSNR
2040 *
2041 * Supported Feature: STA
2042 *
2043 * Usage: Internal/External
2044 *
2045 * </ioctl>
2046 */
Naveen Rawat910726a2017-03-06 11:42:51 -08002047
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +05302049#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050
2051/* Private ioctls and their sub-ioctls */
2052#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
2053#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +05302054/*
2055 * <ioctl>
2056 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
2057 *
2058 * @INPUT: None
2059 *
2060 * @OUTPUT: print ibss peer in info logs
2061 * pPeerInfo->numIBSSPeers = 1
2062 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2063 *
2064 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
2065 * in info logs
2066 *
2067 * @E.g: iwpriv wlan0 ibssPeerInfoAll
2068 *
2069 * Supported Feature: IBSS
2070 *
2071 * Usage: Internal/External
2072 *
2073 * </ioctl>
2074 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002075#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -08002076/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002077#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002078#define WE_GET_FW_PROFILE_DATA 18
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +05302079/*
2080 * <ioctl>
2081 * stop_obss_scan - Stop obss scan
2082 *
2083 * @INPUT: None
2084 *
2085 * @OUTPUT: None
2086 *
2087 * This IOCTL is used to stop obss scan
2088 *
2089 * @E.g: iwpriv wlan0 stop_obss_scan
2090 *
2091 * Supported Feature: Scan
2092 *
2093 * Usage: Internal/External
2094 *
2095 * </ioctl>
2096 */
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002097#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098
2099/* Private ioctls and their sub-ioctls */
2100#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
2101
2102#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +05302103/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104
Manjeet Singhf82ed072016-07-08 11:40:00 +05302105#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106
2107#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302108/*
2109 * <ioctl>
2110 * setTdlsConfig - Set TDLS configuration parameters.
2111 *
2112 * @INPUT: 11 TDLS configuration parameters
2113 * @args[0]: tdls: [0..2]
2114 * @args[1]: tx_period_t: [1000..4294967295UL]
2115 * @args[2]: tx_packet_n: [0..4294967295UL]
2116 * @args[3]: [discovery_period is not used anymore]
2117 * @args[4]: discovery_tries_n: [1..100]
2118 * @args[5]: [idle_timeout is not used anymore]
2119 * @args[6]: idle_packet_n: [0..40000]
2120 * @args[7]: [rssi_hysteresis is not used anymore]
2121 * @args[8]: rssi_trigger_threshold: [-120..0]
2122 * @args[9]: rssi_teardown_threshold: [-120..0]
2123 * @args[10]: rssi_delta: [-30..0]
2124 *
2125 * @OUTPUT: None
2126 *
2127 * This IOCTL is used to set the TDLS configuration parameters.
2128 *
2129 * @E.g: iwpriv wlan0 setTdlsConfig tdls tx_period_t tx_packet_n
2130 * discovery_period discovery_tries_n idle_timeout
2131 * idle_packet_n rssi_hysteresis rssi_trigger_threshold
2132 * rssi_teardown_threshold rssi_delta
2133 * iwpriv wlan0 setTdlsConfig 1 1500 40 1 5 1 5 0 -70 -70 -10
2134 *
2135 * Supported Feature: TDLS
2136 *
2137 * Usage: Internal/External
2138 *
2139 * </ioctl>
2140 */
2141
2142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143#define WE_TDLS_CONFIG_PARAMS 5
2144#endif
Abhishek Singh49b654e2016-12-01 16:11:17 +05302145/*
2146 * <ioctl>
2147 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
2148 *
2149 * @INPUT: staid
2150 *
2151 * @OUTPUT: print ibss peer corresponding to staid in info logs
2152 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2153 *
2154 * This IOCTL is used to print the specific ibss peers's MAC,
2155 * rate and RSSI in info logs
2156 *
2157 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
2158 * iwpriv wlan0 ibssPeerInfo 0
2159 *
2160 * Supported Feature: IBSS
2161 *
2162 * Usage: Internal/External
2163 *
2164 * </ioctl>
2165 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002166#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167#define WE_UNIT_TEST_CMD 7
2168
2169#define WE_MTRACE_DUMP_CMD 8
2170#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
2171
2172
2173#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2174#define WE_LED_FLASHING_PARAM 10
2175#endif
2176
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302177/*
2178 * <ioctl>
2179 * pm_clist - Increments the index value of the concurrent connection list
2180 * and update with the input parameters provided.
2181 *
2182 * @INPUT: Following 8 arguments:
2183 * @vdev_id: vdev id
2184 * @tx_streams: TX streams
2185 * @rx_streams: RX streams
2186 * @chain_mask: Chain mask
2187 * @type: vdev_type
2188 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2189 * @sub_type: vdev_subtype
2190 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2191 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2192 * @channel: Channel
2193 * @mac: Mac id
2194 *
2195 * @OUTPUT: None
2196 *
2197 * This IOCTL is used to increments the index value of the concurrent connection
2198 * list and update with the input parameters provided.
2199 *
2200 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
2201 * sub_type channel mac
2202 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
2203 *
2204 * Supported Feature: DBS
2205 *
2206 * Usage: Internal/External
2207 *
2208 * </ioctl>
2209 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302211
2212/*
2213 * <ioctl>
2214 * pm_dlist - Delete the index from the concurrent connection list that is
2215 * present in the given vdev_id.
2216 *
2217 * @INPUT: delete_all, vdev_id
2218 * @delete_all: delete all indices
2219 * @vdev_id: vdev id
2220 *
2221 * @OUTPUT: None
2222 *
2223 * This IOCTL is used to delete the index from the concurrent connection list
2224 * that is present in the given vdev_id.
2225 *
2226 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
2227 * iwpriv wlan0 pm_dlist 0 1
2228 *
2229 * Supported Feature: DBS
2230 *
2231 * Usage: Internal/External
2232 *
2233 * </ioctl>
2234 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302236
2237/*
2238 * <ioctl>
2239 * pm_dbs - Set dbs capability and system preference
2240 *
2241 * @INPUT: dbs, system_pref
2242 * @dbs: Value of DBS capability to be set
2243 * @system_pref: System preference
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002244 * 0:PM_THROUGHPUT 1: PM_POWERSAVE 2: PM_LATENCY
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302245 *
2246 * @OUTPUT: None
2247 *
2248 * This IOCTL is used to set dbs capability and system preference.
2249 *
2250 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
2251 * iwpriv wlan0 pm_dbs 1 0
2252 *
2253 * Supported Feature: DBS
2254 *
2255 * Usage: Internal/External
2256 *
2257 * </ioctl>
2258 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302260
2261/*
2262 * <ioctl>
2263 * pm_pcl - Set pcl for concurrency mode.
2264 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002265 * @INPUT: policy_mgr_con_mode
2266 * @policy_mgr_con_mode: concurrency mode for PCL table
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302267 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2268 *
2269 * @OUTPUT: None
2270 *
2271 * This IOCTL is used to set pcl for concurrency mode.
2272 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002273 * @E.g: iwpriv wlan0 pm_pcl policy_mgr_con_mode
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302274 * iwpriv wlan0 pm_pcl 0
2275 *
2276 * Supported Feature: DBS
2277 *
2278 * Usage: Internal/External
2279 *
2280 * </ioctl>
2281 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302283
2284/*
2285 * <ioctl>
2286 * pm_cinfo - Shows the concurrent connection list.
2287 *
2288 * @INPUT: None
2289 *
2290 * @OUTPUT: None
2291 *
2292 * This IOCTL is used to show the concurrent connection list.
2293 *
2294 * @E.g: iwpriv wlan0 pm_cinfo
2295 *
2296 * Supported Feature: DBS
2297 *
2298 * Usage: Internal/External
2299 *
2300 * </ioctl>
2301 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302303
2304/*
2305 * <ioctl>
2306 * pm_ulist - Updates the index value of the concurrent connection list
2307 * with the input parameters provided.
2308 *
2309 * @INPUT: Following 8 arguments:
2310 * @vdev_id: vdev id
2311 * @tx_streams: TX streams
2312 * @rx_streams: RX streams
2313 * @chain_mask: Chain mask
2314 * @type: vdev_type
2315 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2316 * @sub_type: vdev_subtype
2317 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2318 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2319 * @channel: Channel
2320 * @mac: Mac id
2321 *
2322 * @OUTPUT: None
2323 *
2324 * This IOCTL is used to updates the index value of the concurrent
2325 * connection list with the input parameters provided.
2326 *
2327 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
2328 * sub_type channel mac
2329 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
2330 *
2331 * Supported Feature: DBS
2332 *
2333 * Usage: Internal/External
2334 *
2335 * </ioctl>
2336 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302338
2339/*
2340 * <ioctl>
2341 * pm_query_action - Initiate actions needed on current connections as
2342 * per the channel provided.
2343 *
2344 * @INPUT: channel
2345 * @channel: Channel on which new connection will be.
2346 *
2347 * @OUTPUT: None
2348 *
2349 * This IOCTL is used to initiate actions needed on current connections
2350 * as per the channel provided.
2351 *
2352 * @E.g: iwpriv wlan0 pm_query_action channel
2353 * iwpriv wlan0 pm_query_action 6
2354 *
2355 * Supported Feature: DBS
2356 *
2357 * Usage: Internal/External
2358 *
2359 * </ioctl>
2360 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302362
2363/*
2364 * <ioctl>
2365 * pm_query_allow - Checks for allowed concurrency combination
2366 *
2367 * @INPUT: mode, channel, bandwidth
2368 * @mode: new connection mode
2369 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2370 * @channel: channel on which new connection is coming up
2371 * @bandwidth: Bandwidth requested by the connection
2372 * 0:None 1:5MHz 2:10MHz 3:20MHz
2373 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
2374 *
2375 * @OUTPUT: None
2376 *
2377 * This IOCTL is used to checks for allowed concurrency combination.
2378 *
2379 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
2380 * iwpriv wlan0 pm_query_allow 0 6 4
2381 *
2382 * Supported Feature: DBS
2383 *
2384 * Usage: Internal/External
2385 *
2386 * </ioctl>
2387 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302389
2390/*
2391 * <ioctl>
2392 * pm_run_scenario - Create scenario with number of connections provided.
2393 *
2394 * @INPUT: num_of_conn
2395 * @num_of_conn: the number of connections (values: 1~3)
2396 *
2397 * @OUTPUT: None
2398 *
2399 * This IOCTL is used to create scenario with the number of connections
2400 * provided.
2401 *
2402 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
2403 * iwpriv wlan0 pm_run_scenario 1
2404 *
2405 * Supported Feature: DBS
2406 *
2407 * Usage: Internal/External
2408 *
2409 * </ioctl>
2410 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302412
2413/*
2414 * <ioctl>
2415 * pm_set_hw_mode - Set hardware for single/dual mac.
2416 *
2417 * @INPUT: hw_mode
2418 * 0:single mac 1:dual mac
2419 *
2420 * @OUTPUT: None
2421 *
2422 * This IOCTL is used to set hardware for single/dual mac.
2423 *
2424 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
2425 * iwpriv wlan0 pm_set_hw_mode 1
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_SET_HW_MODE_CMD 20
2434
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302435/*
2436 * <ioctl>
2437 * set_scan_cfg - Set dual MAC scan config parameters.
2438 *
2439 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2440 * @dbs: Value of DBS bit
2441 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2442 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2443 *
2444 * @OUTPUT: None
2445 *
2446 * This IOCTL is used to set the dual MAC scan config.
2447 *
2448 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2449 * single_mac_scan_with_dbs
2450 * iwpriv wlan0 set_scan_cfg 1 0 1
2451 *
2452 * Supported Feature: DBS
2453 *
2454 * Usage: Internal/External
2455 *
2456 * </ioctl>
2457 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302459
2460/*
2461 * <ioctl>
2462 * set_fw_mode_cfg - Sets the dual mac FW mode config
2463 *
2464 * @INPUT: dbs, dfs
2465 * @dbs: DBS bit
2466 * @dfs: Agile DFS bit
2467 *
2468 * @OUTPUT: None
2469 *
2470 * This IOCTL is used to set the dual mac FW mode config.
2471 *
2472 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2473 * iwpriv wlan0 set_fw_mode_cfg 1 1
2474 *
2475 * Supported Feature: DBS
2476 *
2477 * Usage: Internal/External
2478 *
2479 * </ioctl>
2480 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07002482#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483
2484#ifdef FEATURE_WLAN_TDLS
2485#undef MAX_VAR_ARGS
2486#define MAX_VAR_ARGS 11
2487#else
2488#undef MAX_VAR_ARGS
2489#define MAX_VAR_ARGS 9
2490#endif
2491
2492/* Private ioctls (with no sub-ioctls) */
2493/* note that they must be odd so that they have "get" semantics */
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302494/*
2495 * <ioctl>
2496 * addTspec - Add TSPEC for each AC
2497 *
2498 * @INPUT: 19 TSPEC params
2499 * @[arg0]: handle
2500 * @[arg1]: tid
2501 * @[arg2]: dir
2502 * @[arg3]: psb
2503 * @[arg4]: up
2504 * @[arg5]: nomMsduSize
2505 * @[arg6]: maxMsduSize
2506 * @[arg7]: minDataRate
2507 * @[arg8]: meanDataRate
2508 * @[arg9]: peakDataRate
2509 * @[arg10]: maxBurstSize
2510 * @[arg11]: minPhyRate
2511 * @[arg12]: sba
2512 * @[arg13]: minServiceIntv
2513 * @[arg14]: suspendIntv
2514 * @[arg15]: burstSizeDefn
2515 * @[arg16]: ackPolicy
2516 * @[arg17]: inactivityPeriod
2517 * @[arg18]: maxServiceIntv
2518 *
2519 * @OUTPUT: Success/Failure
2520 *
2521 * This IOCTL is used to add TSPEC for each AC.
2522 *
2523 * @E.g: iwpriv wlan0 addTspec <handle> <tid> <dir> <psb> <up> <nomMsduSize>
2524 * <maxMsduSize> <minDataRate> <meanDataRate>
2525 * <peakDataRate> <maxBurstSize> <minPhyRate>
2526 * <sba> <minServiceIntv> <suspendIntv>
2527 * <burstSizeDefn> <ackPolicy> <inactivityPeriod>
2528 * <maxServiceIntv>
2529 * iwpriv wlan0 addTspec 7001 6 2 1 6 0x80D0 0x80D0 0x14500 0x14500 0x14500
2530 * 0 0x5B8D80 0x2001 20 2000 0 0 0 2000
2531 * wlan0 addTspec:3
2532 *
2533 * Supported Feature: WMM
2534 *
2535 * Usage: Internal/External
2536 *
2537 * </ioctl>
2538 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302540/*
2541 * <ioctl>
2542 * delTspec - Delete TSPEC entry for each AC
2543 *
2544 * @INPUT: 1 TSPEC param
2545 * @[arg0]: handle
2546 *
2547 * @OUTPUT: Success/Failure
2548 *
2549 * This IOCTL is used to delete TSPEC entry for each AC.
2550 *
2551 * @E.g: iwpriv wlan0 delTspec <handle>
2552 * iwpriv wlan0 delTspec 7001
2553 * wlan0 delTspec:16
2554 *
2555 * Supported Feature: WMM
2556 *
2557 * Usage: Internal/External
2558 *
2559 * </ioctl>
2560 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302562/*
2563 * <ioctl>
2564 * getTspec - Get TSPEC entry for each AC
2565 *
2566 * @INPUT: 1 TSPEC param
2567 * @[arg0]: handle
2568 *
2569 * @OUTPUT: Success/Failure
2570 *
2571 * This IOCTL is used to get TSPEC entry for each AC.
2572 *
2573 * @E.g: iwpriv wlan0 getTspec <handle>
2574 * iwpriv wlan0 getTspec 7001
2575 * wlan0 delTspec:18
2576 *
2577 * Supported Feature: WMM
2578 *
2579 * Usage: Internal/External
2580 *
2581 * </ioctl>
2582 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2584
2585/* (SIOCIWFIRSTPRIV + 8) is currently unused */
2586/* (SIOCIWFIRSTPRIV + 10) is currently unused */
2587/* (SIOCIWFIRSTPRIV + 12) is currently unused */
2588/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002589#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
2590#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591/* (SIOCIWFIRSTPRIV + 16) is currently unused */
2592/* (SIOCIWFIRSTPRIV + 17) is currently unused */
2593/* (SIOCIWFIRSTPRIV + 19) is currently unused */
2594
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596
2597/* Private ioctl for setting the host offload feature */
2598#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2599
2600/* Private ioctl to get the statistics */
2601#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2602
2603/* Private ioctl to set the Keep Alive Params */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302604/*
2605 * <ioctl>
2606 * setKeepAlive - Set the keep alive feature
2607 *
2608 * @INPUT: 28 bytes of information in the order of packet type, time period
2609 * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2610 *
2611 * @OUTPUT: None
2612 *
2613 * This IOCTL sets the keep alive feature to send either NULL
2614 * or unsolicited ARP response packets
2615 *
2616 * @E.g: iwpriv wlan0 setKeepAlive
2617 *
2618 * Supported Feature: STA
2619 *
2620 * Usage: Internal/External
2621 *
2622 * </ioctl>
2623 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2625
2626#ifdef WLAN_FEATURE_PACKET_FILTERING
2627/* Private ioctl to set the packet filtering params */
2628#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2629#endif
2630
2631
2632#ifdef FEATURE_WLAN_SCAN_PNO
2633/* Private ioctl to get the statistics */
2634#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2635#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302636/*
2637 * <ioctl>
2638 * SETBAND - Set the operational band
2639 *
2640 * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2641 *
2642 * @OUTPUT: None
2643 *
2644 * This IOCTL Set the operational band If the new band is different from the
2645 * current operational band, it aborts the pending scan requests, flushes
2646 * the existing scan results, and then change * the band capability
2647 *
2648 * @E.g: iwpriv wlan0 SETBAND <value>
2649 *
2650 * Supported Feature: STA
2651 *
2652 * Usage: Internal/External
2653 *
2654 * </ioctl>
2655 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
2657
Dustin Brown0cbc7572016-12-16 13:54:40 -08002658#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -08002659/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660
2661/* Private ioctls and their sub-ioctls */
2662#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
2663#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -07002664#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665#define WE_SET_FW_CRASH_INJECT 2
2666#endif
2667#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +05302668/* Private sub ioctl for enabling and setting histogram interval of profiling */
2669#define WE_ENABLE_FW_PROFILE 4
2670#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07002672/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002673#define WE_SET_WLAN_SUSPEND 6
2674#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002675
Dustin Brown8d2d0f52017-04-03 17:02:08 -07002676/*
2677 * <ioctl>
2678 * log_buffer - prints host/target related communication logs via dmesg
2679 *
2680 * @INPUT: Log Id, Count
2681 *
2682 * Log Id:
2683 * 0) HTC_CREDIT_HISTORY_LOG
2684 * 1) COMMAND_LOG,
2685 * 2) COMMAND_TX_CMP_LOG,
2686 * 3) MGMT_COMMAND_LOG,
2687 * 4) MGMT_COMMAND_TX_CMP_LOG,
2688 * 5) EVENT_LOG,
2689 * 6) RX_EVENT_LOG,
2690 * 7) MGMT_EVENT_LOG
2691 *
2692 * @OUTPUT: None
2693 *
2694 * @E.g:
2695 * # print up to 10 of the most recent records from HTC Credit History
2696 * iwpriv wlan0 log_buffer 0 10
2697 * # print up to 3 of the most recent records from Event Log
2698 * iwpriv wlan0 log_buffer 5 3
2699 *
2700 * Supported Feature: WLAN Trace
2701 *
2702 * Usage: Internal/External
2703 *
2704 * </ioctl>
2705 */
2706#define WE_LOG_BUFFER 8
2707
2708enum host_target_comm_log {
2709 HTC_CREDIT_HISTORY_LOG = 0,
2710 COMMAND_LOG,
2711 COMMAND_TX_CMP_LOG,
2712 MGMT_COMMAND_LOG,
2713 MGMT_COMMAND_TX_CMP_LOG,
2714 EVENT_LOG,
2715 RX_EVENT_LOG,
2716 MGMT_EVENT_LOG
2717};
2718
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719/* (SIOCIWFIRSTPRIV + 29) is currently unused */
2720
2721/* 802.11p IOCTL */
2722#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
2723
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302724/*
2725 * <ioctl>
2726 * getLinkSpeed - Gets the current link speed in Mbps
2727 *
2728 * @INPUT: None
2729 *
2730 * @OUTPUT: linkspeed in mbps
2731 * wlan0 getLinkSpeed:7
2732 *
2733 * This IOCTL is used get the current link speed in Mbps
2734 *
2735 * @E.g: iwpriv wlan0 getLinkSpeed
2736 *
2737 * Supported Feature: STA
2738 *
2739 * Usage: Internal/External
2740 *
2741 * </ioctl>
2742 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
2744
2745#define WLAN_STATS_INVALID 0
2746#define WLAN_STATS_RETRY_CNT 1
2747#define WLAN_STATS_MUL_RETRY_CNT 2
2748#define WLAN_STATS_TX_FRM_CNT 3
2749#define WLAN_STATS_RX_FRM_CNT 4
2750#define WLAN_STATS_FRM_DUP_CNT 5
2751#define WLAN_STATS_FAIL_CNT 6
2752#define WLAN_STATS_RTS_FAIL_CNT 7
2753#define WLAN_STATS_ACK_FAIL_CNT 8
2754#define WLAN_STATS_RTS_SUC_CNT 9
2755#define WLAN_STATS_RX_DISCARD_CNT 10
2756#define WLAN_STATS_RX_ERROR_CNT 11
2757#define WLAN_STATS_TX_BYTE_CNT 12
2758
2759#define WLAN_STATS_RX_BYTE_CNT 13
2760#define WLAN_STATS_RX_RATE 14
2761#define WLAN_STATS_TX_RATE 15
2762
2763#define WLAN_STATS_RX_UC_BYTE_CNT 16
2764#define WLAN_STATS_RX_MC_BYTE_CNT 17
2765#define WLAN_STATS_RX_BC_BYTE_CNT 18
2766#define WLAN_STATS_TX_UC_BYTE_CNT 19
2767#define WLAN_STATS_TX_MC_BYTE_CNT 20
2768#define WLAN_STATS_TX_BC_BYTE_CNT 21
2769
2770#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
2771 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
2772 *__p++ = __type; \
2773 *__p++ = __size; \
2774 memcpy(__p, __val, __size); \
2775 __p += __size; \
2776 __tlen += __size + 2; \
2777 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07002778 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 } \
2780 } while (0)
2781
2782#define VERSION_VALUE_MAX_LEN 32
2783
2784#define TX_PER_TRACKING_DEFAULT_RATIO 5
2785#define TX_PER_TRACKING_MAX_RATIO 10
2786#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
2787
2788#define WLAN_ADAPTER 0
2789#define P2P_ADAPTER 1
2790
2791/**
2792 * mem_alloc_copy_from_user_helper - copy from user helper
2793 * @wrqu_data: wireless extensions request data
2794 * @len: length of @wrqu_data
2795 *
2796 * Helper function to allocate buffer and copy user data.
2797 *
2798 * Return: On success return a pointer to a kernel buffer containing a
2799 * copy of the userspace data (with an additional NUL character
2800 * appended for safety). On failure return %NULL.
2801 */
2802void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2803{
2804 u8 *ptr = NULL;
2805
2806 /* in order to protect the code, an extra byte is post
2807 * appended to the buffer and the null termination is added.
2808 * However, when allocating (len+1) byte of memory, we need to
2809 * make sure that there is no uint overflow when doing
2810 * addition. In theory check len < UINT_MAX protects the uint
2811 * overflow. For wlan private ioctl, the buffer size is much
2812 * less than UINT_MAX, as a good guess, now, it is assumed
2813 * that the private command buffer size is no greater than 4K
2814 * (4096 bytes). So we use 4096 as the upper boundary for now.
2815 */
2816 if (len > MAX_USER_COMMAND_SIZE) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08002817 hdd_err("Invalid length: %zu max: %u",
2818 len, MAX_USER_COMMAND_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002819 return NULL;
2820 }
2821
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002822 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002824 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825 return NULL;
2826 }
2827
2828 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002829 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002830 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 return NULL;
2832 }
2833 ptr[len] = '\0';
2834 return ptr;
2835}
2836
2837/**
2838 * hdd_priv_get_data() - Get pointer to ioctl private data
2839 * @p_priv_data: pointer to iw_point struct to be filled
2840 * @wrqu: Pointer to IOCTL Data received from userspace
2841 *
2842 * Helper function to get compatible struct iw_point passed to ioctl
2843 *
2844 * Return - 0 if p_priv_data successfully filled, error otherwise
2845 */
2846int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2847{
2848 if ((NULL == p_priv_data) || (NULL == wrqu)) {
2849 return -EINVAL;
2850 }
2851#ifdef CONFIG_COMPAT
2852 if (is_compat_task()) {
2853 struct compat_iw_point *p_compat_priv_data;
2854
2855 /* Compat task:
2856 * typecast to compat structure and copy the members.
2857 */
2858 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2859
2860 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2861 p_priv_data->length = p_compat_priv_data->length;
2862 p_priv_data->flags = p_compat_priv_data->flags;
2863 } else {
2864#endif /* #ifdef CONFIG_COMPAT */
2865
2866 /* Non compat task: directly copy the structure. */
2867 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
2868
2869#ifdef CONFIG_COMPAT
2870 }
2871#endif /* #ifdef CONFIG_COMPAT */
2872
2873 return 0;
2874}
2875
Jeff Johnson441e1f72017-02-07 08:50:49 -08002876static int hdd_check_wext_control(enum hdd_wext_control wext_control,
2877 struct iw_request_info *info)
2878{
2879 switch (wext_control) {
2880 default:
2881 case hdd_wext_disabled:
2882 hdd_err("Rejecting disabled ioctl %x", info->cmd);
2883 return -ENOTSUPP;
2884 case hdd_wext_deprecated:
2885 hdd_warn("Using deprecated ioctl %x", info->cmd);
2886 return 0;
2887 case hdd_wext_enabled:
2888 return 0;
2889 }
2890}
2891
2892int hdd_check_standard_wext_control(struct hdd_context_s *hdd_ctx,
2893 struct iw_request_info *info)
2894{
2895 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
2896 info);
2897}
2898
2899int hdd_check_private_wext_control(struct hdd_context_s *hdd_ctx,
2900 struct iw_request_info *info)
2901{
2902 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
2903 info);
2904}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905
2906/**
2907 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
2908 * @pAdapter: Pointer to the hdd adapter.
2909 * @length: Size of the data copied
2910 * @buffer: Pointer to char buffer.
2911 * @buf_len: Length of the char buffer.
2912 *
2913 * This function called when the "iwpriv wlan0 get_stats" command is given.
2914 * It used to collect the txrx stats when the device is configured in SAP mode.
2915 *
2916 * Return - none
2917 */
2918void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
2919 char *buffer, uint16_t buf_len)
2920{
2921 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
2922 uint32_t len = 0;
2923 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
2924 uint32_t total_rx_delv = 0, total_rx_refused = 0;
2925 int i = 0;
2926
2927 for (; i < NUM_CPUS; i++) {
2928 total_rx_pkt += pStats->rxPackets[i];
2929 total_rx_dropped += pStats->rxDropped[i];
2930 total_rx_delv += pStats->rxDelivered[i];
2931 total_rx_refused += pStats->rxRefused[i];
2932 }
2933
2934 len = scnprintf(buffer, buf_len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002935 "\nTransmit[%lu] - "
Mohit Khannad0b63f52017-02-18 18:05:52 -08002936 "called %u, dropped %u orphan %u,"
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002937 "\n[dropped] BK %u, BE %u, VI %u, VO %u"
2938 "\n[classified] BK %u, BE %u, VI %u, VO %u"
2939 "\n\nReceive[%lu] - "
2940 "packets %u, dropped %u, delivered %u, refused %u"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941 "\n",
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002942 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943 pStats->txXmitCalled,
2944 pStats->txXmitDropped,
Mohit Khannad0b63f52017-02-18 18:05:52 -08002945 pStats->txXmitOrphaned,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946
2947 pStats->txXmitDroppedAC[SME_AC_BK],
2948 pStats->txXmitDroppedAC[SME_AC_BE],
2949 pStats->txXmitDroppedAC[SME_AC_VI],
2950 pStats->txXmitDroppedAC[SME_AC_VO],
2951
2952 pStats->txXmitClassifiedAC[SME_AC_BK],
2953 pStats->txXmitClassifiedAC[SME_AC_BE],
2954 pStats->txXmitClassifiedAC[SME_AC_VI],
2955 pStats->txXmitClassifiedAC[SME_AC_VO],
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002956 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
2958 );
2959
2960 for (i = 0; i < NUM_CPUS; i++) {
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002961 if (pStats->rxPackets[i] == 0)
2962 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002964 "Rx CPU[%d]:"
2965 "packets %u, dropped %u, delivered %u, refused %u\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 i, pStats->rxPackets[i], pStats->rxDropped[i],
2967 pStats->rxDelivered[i], pStats->rxRefused[i]);
2968 }
2969
2970 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002971 "\nTX_FLOW"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 "\nCurrent status: %s"
2973 "\ntx-flow timer start count %u"
2974 "\npause count %u, unpause count %u",
2975 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
2976 pStats->txflow_timer_cnt,
2977 pStats->txflow_pause_cnt,
2978 pStats->txflow_unpause_cnt);
2979
Leo Changfdb45c32016-10-28 11:09:23 -07002980 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
2981 pAdapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 *length = len + 1;
2983}
2984
2985/**
Dustin Brownd9322482017-01-09 12:46:03 -08002986 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
2987 * @hdd_ctx: The Hdd context owning the stats to be written
2988 * @buffer: The char buffer to write to
2989 * @max_len: The maximum number of chars to write
2990 *
2991 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
2992 *
2993 * Return - length of written content, negative number on error
2994 */
2995static int wlan_hdd_write_suspend_resume_stats(hdd_context_t *hdd_ctx,
2996 char *buffer, uint16_t max_len)
2997{
2998 QDF_STATUS status;
2999 struct suspend_resume_stats *sr_stats;
3000 struct sir_wake_lock_stats wow_stats;
3001
3002 sr_stats = &hdd_ctx->suspend_resume_stats;
3003
3004 status = wma_get_wakelock_stats(&wow_stats);
3005 if (QDF_IS_STATUS_ERROR(status)) {
3006 hdd_err("Failed to get WoW stats");
3007 return qdf_status_to_os_return(status);
3008 }
3009
3010 return scnprintf(buffer, max_len,
3011 "\n"
3012 "Suspends: %u\n"
3013 "Resumes: %u\n"
3014 "\n"
3015 "Suspend Fail Reasons\n"
3016 "\tIPA: %u\n"
3017 "\tRadar: %u\n"
3018 "\tRoam: %u\n"
3019 "\tScan: %u\n"
3020 "\tInitial Wakeup: %u\n"
3021 "\n"
3022 "WoW Wake Reasons\n"
3023 "\tunicast: %u\n"
3024 "\tbroadcast: %u\n"
3025 "\tIPv4 multicast: %u\n"
3026 "\tIPv6 multicast: %u\n"
3027 "\tIPv6 multicast RA: %u\n"
3028 "\tIPv6 multicast NS: %u\n"
3029 "\tIPv6 multicast NA: %u\n"
3030 "\tICMPv4: %u\n"
3031 "\tICMPv6: %u\n"
3032 "\tRSSI Breach: %u\n"
3033 "\tLow RSSI: %u\n"
3034 "\tG-Scan: %u\n"
3035 "\tPNO Complete: %u\n"
3036 "\tPNO Match: %u\n",
3037 sr_stats->suspends,
3038 sr_stats->resumes,
3039 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
3040 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
3041 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
3042 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
3043 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
3044 wow_stats.wow_ucast_wake_up_count,
3045 wow_stats.wow_bcast_wake_up_count,
3046 wow_stats.wow_ipv4_mcast_wake_up_count,
3047 wow_stats.wow_ipv6_mcast_wake_up_count,
3048 wow_stats.wow_ipv6_mcast_ra_stats,
3049 wow_stats.wow_ipv6_mcast_ns_stats,
3050 wow_stats.wow_ipv6_mcast_na_stats,
3051 wow_stats.wow_icmpv4_count,
3052 wow_stats.wow_icmpv6_count,
3053 wow_stats.wow_rssi_breach_wake_up_count,
3054 wow_stats.wow_low_rssi_wake_up_count,
3055 wow_stats.wow_gscan_wake_up_count,
3056 wow_stats.wow_pno_complete_wake_up_count,
3057 wow_stats.wow_pno_match_wake_up_count);
3058}
3059
3060/**
Govind Singha471e5e2015-10-12 17:11:14 +05303061 * hdd_wlan_list_fw_profile() - Get fw profiling points
3062 * @length: Size of the data copied
3063 * @buffer: Pointer to char buffer.
3064 * @buf_len: Length of the char buffer.
3065 *
3066 * This function called when the "iwpriv wlan0 listProfile" command is given.
3067 * It is used to get the supported profiling points in FW.
3068 *
3069 * Return - none
3070 */
3071void hdd_wlan_list_fw_profile(uint16_t *length,
3072 char *buffer, uint16_t buf_len)
3073{
3074 uint32_t len = 0;
3075
3076 len = scnprintf(buffer, buf_len,
3077 "PROF_CPU_IDLE: %u\n"
3078 "PROF_PPDU_PROC: %u\n"
3079 "PROF_PPDU_POST: %u\n"
3080 "PROF_HTT_TX_INPUT: %u\n"
3081 "PROF_MSDU_ENQ: %u\n"
3082 "PROF_PPDU_POST_HAL: %u\n"
3083 "PROF_COMPUTE_TX_TIME: %u\n",
3084 PROF_CPU_IDLE,
3085 PROF_PPDU_PROC,
3086 PROF_PPDU_POST,
3087 PROF_HTT_TX_INPUT,
3088 PROF_MSDU_ENQ,
3089 PROF_PPDU_POST_HAL,
3090 PROF_COMPUTE_TX_TIME);
3091
3092 *length = len + 1;
3093}
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003094/**
3095 * hdd_display_stats_help() - print statistics help
3096 *
3097 * Return: none
3098 */
3099void hdd_display_stats_help(void)
3100{
3101 hdd_err("iwpriv wlan0 dumpStats [option] - dump statistics");
3102 hdd_err("iwpriv wlan0 clearStats [option] - clear statistics");
3103 hdd_err("options:");
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003104 hdd_err(" 1 -- TXRX PATH statistics");
3105 hdd_err(" 2 -- TXRX HIST statistics");
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003106 hdd_err(" 3 -- TSO statistics");
3107 hdd_err(" 4 -- Network queue statistics");
3108 hdd_err(" 5 -- Flow control statistics");
3109 hdd_err(" 6 -- Per Layer statistics");
3110 hdd_err(" 7 -- Copy engine interrupt statistics");
3111 hdd_err(" 8 -- LRO statistics");
3112 hdd_err(" 9 -- NAPI statistics");
3113}
Govind Singha471e5e2015-10-12 17:11:14 +05303114
3115/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 * hdd_wlan_dump_stats() - display dump Stats
3117 * @adapter: adapter handle
3118 * @value: value from user
3119 *
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003120 * Return: 0 => success, error code on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 */
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003122int hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123{
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003124 int ret = 0;
3125 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3127
3128 switch (value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003129 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
3131 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003132 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 wlan_hdd_display_netif_queue_history(hdd_ctx);
3134 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003135 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05303136 hdd_display_hif_stats();
3137 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003138 case CDP_LRO_STATS:
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003139 hdd_lro_display_stats(hdd_ctx);
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003140 case CDP_NAPI_STATS:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003141 if (hdd_display_napi_stats()) {
3142 hdd_err("error displaying napi stats");
3143 ret = EFAULT;
3144 }
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003145 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146 default:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003147 status = cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC),
3148 value);
3149 if (status == QDF_STATUS_E_INVAL) {
3150 hdd_display_stats_help();
3151 ret = EINVAL;
3152 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 break;
3154 }
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003155 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156}
3157
3158/**
3159 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303160 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161 * @wrqu: Pointer to IOCTL REQUEST Data.
3162 * @extra: Pointer to destination buffer
3163 *
3164 * This function is used to get Wlan Driver, Firmware, & Hardware
3165 * Version information. If @wrqu and @extra are specified, then the
3166 * version string is returned. Otherwise it is simply printed to the
3167 * kernel log.
3168 *
3169 * Return: none
3170 */
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303171void hdd_wlan_get_version(hdd_context_t *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 char *extra)
3173{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303174 tSirVersionString wcnss_sw_version;
3175 const char *swversion;
3176 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003177 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303179 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003180 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 goto error;
3182 }
3183
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303184 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
3185 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303187 swversion = wcnss_sw_version;
3188 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
3189 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
3190 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
3191 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003192 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303194 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195
3196 if (wrqu && extra) {
3197 wrqu->data.length =
3198 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003199 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003201 msp_id, mspid, siid, crmid,
3202 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003204 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003206 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207 }
3208error:
3209 return;
3210}
3211
3212/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003213 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
3214 * @pAdapter: Adapter upon which the IBSS client is active
3215 * @staIdx: Station index of the IBSS peer
3216 *
3217 * Return: a pointer to the MAC address of the IBSS peer if the peer is
3218 * found, otherwise %NULL.
3219 */
3220struct qdf_mac_addr *
3221hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
3222 uint8_t staIdx)
3223{
3224 uint8_t idx;
3225 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3226
Naveen Rawatc45d1622016-07-05 12:20:09 -07003227 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003228 if (0 != pHddStaCtx->conn_info.staId[idx] &&
3229 staIdx == pHddStaCtx->conn_info.staId[idx]) {
3230 return &pHddStaCtx->conn_info.peerMacAddress[idx];
3231 }
3232 }
3233 return NULL;
3234}
3235
3236/**
3237 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
3238 * @pAdapter: Adapter upon which the IBSS client is active
3239 * @staIdx: Station index of the IBSS peer
3240 *
3241 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
3242 * otherwise an appropriate QDF_STATUS_E_* failure code.
3243 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003244static QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter,
3245 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003246{
3247 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3248 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3249 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003250 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003251
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003252 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003253 status = sme_request_ibss_peer_info(hHal, pAdapter,
3254 hdd_get_ibss_peer_info_cb,
3255 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003256
3257 if (QDF_STATUS_SUCCESS == status) {
3258 unsigned long rc;
3259 rc = wait_for_completion_timeout
3260 (&pAdapter->ibss_peer_info_comp,
3261 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3262 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003263 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003264 return QDF_STATUS_E_FAILURE;
3265 }
3266
3267 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003268 hdd_debug("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003269 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003270 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3271 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003272
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003273 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
3274 mac_addr, sizeof(mac_addr));
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003275 hdd_debug("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003276 mac_addr, (int)tx_rate,
3277 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003278 }
3279 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003280 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003281 }
3282
3283 return status;
3284}
3285
3286/**
3287 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
3288 * @pAdapter: Adapter upon which the IBSS clients are active
3289 *
3290 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
3291 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
3292 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003293static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003294{
3295 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3296 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3297 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003298 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003299 int i;
3300
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003301 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003302 status = sme_request_ibss_peer_info(hHal, pAdapter,
3303 hdd_get_ibss_peer_info_cb,
3304 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003305
3306 if (QDF_STATUS_SUCCESS == status) {
3307 unsigned long rc;
3308 rc = wait_for_completion_timeout
3309 (&pAdapter->ibss_peer_info_comp,
3310 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3311 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003312 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003313 return QDF_STATUS_E_FAILURE;
3314 }
3315
3316 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003317 hdd_debug("pPeerInfo->numIBSSPeers = %d ",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003318 (int)pPeerInfo->numPeers);
3319 for (i = 0; i < pPeerInfo->numPeers; i++) {
3320 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3321 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003322
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003323 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
3324 qdf_mem_copy(mac_addr,
3325 pPeerInfo->peerInfoParams[i].mac_addr,
3326 sizeof(mac_addr));
3327
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003328 hdd_debug(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003329 mac_addr, (int)tx_rate,
3330 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003331 }
3332 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003333 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003334 }
3335
3336 return status;
3337}
3338
3339/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 * hdd_wlan_get_freq() - Convert channel to frequency
3341 * @channel: channel to be converted
3342 * @pfreq: where to store the frequency
3343 *
3344 * Return: 1 on success, otherwise a negative errno
3345 */
3346int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
3347{
3348 int i;
3349 if (channel > 0) {
3350 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
3351 if (channel == freq_chan_map[i].chan) {
3352 *pfreq = freq_chan_map[i].freq;
3353 return 1;
3354 }
3355 }
3356 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003357 hdd_err("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 return -EINVAL;
3359}
3360
3361/**
3362 * hdd_is_auth_type_rsn() - RSN authentication type check
3363 * @authType: authentication type to be checked
3364 *
3365 * Return: true if @authType is an RSN authentication type,
3366 * false if it is not
3367 */
3368static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
3369{
3370 bool rsnType = false;
3371 /* is the authType supported? */
3372 switch (authType) {
3373 case eCSR_AUTH_TYPE_NONE: /* never used */
3374 rsnType = false;
3375 break;
3376 /* MAC layer authentication types */
3377 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3378 rsnType = false;
3379 break;
3380 case eCSR_AUTH_TYPE_SHARED_KEY:
3381 rsnType = false;
3382 break;
3383 case eCSR_AUTH_TYPE_AUTOSWITCH:
3384 rsnType = false;
3385 break;
3386
3387 /* Upper layer authentication types */
3388 case eCSR_AUTH_TYPE_WPA:
3389 rsnType = true;
3390 break;
3391 case eCSR_AUTH_TYPE_WPA_PSK:
3392 rsnType = true;
3393 break;
3394 case eCSR_AUTH_TYPE_WPA_NONE:
3395 rsnType = true;
3396 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003397 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 case eCSR_AUTH_TYPE_RSN:
3399 rsnType = true;
3400 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003401 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 case eCSR_AUTH_TYPE_RSN_PSK:
3403#ifdef WLAN_FEATURE_11W
3404 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3405 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
3406#endif
3407 rsnType = true;
3408 break;
3409 /* case eCSR_AUTH_TYPE_FAILED: */
3410 case eCSR_AUTH_TYPE_UNKNOWN:
3411 rsnType = false;
3412 break;
3413 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003414 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 authType);
3416 rsnType = false;
3417 break;
3418 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003419 hdd_debug("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 authType, rsnType);
3421 return rsnType;
3422}
3423
Jeff Johnsona5444942017-01-23 13:11:08 -08003424struct rssi_priv {
3425 int8_t rssi;
3426};
3427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428/**
3429 * hdd_get_rssi_cb() - "Get RSSI" callback function
3430 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08003431 * @sta_id: ID of the station
3432 * @context: opaque context originally passed to SME. HDD always passes
3433 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 *
3435 * Return: None
3436 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003437static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438{
Jeff Johnsona5444942017-01-23 13:11:08 -08003439 struct hdd_request *request;
3440 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441
Jeff Johnsona5444942017-01-23 13:11:08 -08003442 request = hdd_request_get(context);
3443 if (!request) {
3444 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 return;
3446 }
3447
Jeff Johnsona5444942017-01-23 13:11:08 -08003448 priv = hdd_request_priv(request);
3449 priv->rssi = rssi;
3450 hdd_request_complete(request);
3451 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452}
3453
3454/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 * wlan_hdd_get_rssi() - Get the current RSSI
3456 * @pAdapter: adapter upon which the measurement is requested
3457 * @rssi_value: pointer to where the RSSI should be returned
3458 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303459 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303461QDF_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463 hdd_context_t *pHddCtx;
3464 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303465 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08003466 int ret;
3467 void *cookie;
3468 struct hdd_request *request;
3469 struct rssi_priv *priv;
3470 static const struct hdd_request_params params = {
3471 .priv_size = sizeof(*priv),
3472 .timeout_ms = WLAN_WAIT_TIME_STATS,
3473 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474
3475 if (NULL == pAdapter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003476 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303477 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003479 if (cds_is_driver_recovering()) {
3480 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3481 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 /* return a cached value */
3483 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303484 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 }
3486
3487 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3488 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3489
3490 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003491 hdd_debug("Not associated!, rssi on disconnect %d",
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05303492 pAdapter->rssi_on_disconnect);
3493 *rssi_value = pAdapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303494 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 }
3496
3497 if (pHddStaCtx->hdd_ReassocScenario) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003498 hdd_debug("Roaming in progress, return cached RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303500 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 }
3502
Jeff Johnsona5444942017-01-23 13:11:08 -08003503 request = hdd_request_alloc(&params);
3504 if (!request) {
3505 hdd_err("Request allocation failure, return cached RSSI");
3506 *rssi_value = pAdapter->rssi;
3507 return QDF_STATUS_SUCCESS;
3508 }
3509 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510
3511 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
3512 pHddStaCtx->conn_info.staId[0],
3513 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
Jeff Johnsona5444942017-01-23 13:11:08 -08003514 cookie, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303515 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003516 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517 /* we'll returned a cached value below */
3518 } else {
3519 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08003520 ret = hdd_request_wait_for_response(request);
3521 if (ret) {
3522 hdd_warn("SME timed out while retrieving RSSI");
3523 /* we'll returned a cached value below */
3524 } else {
3525 /* update the adapter with the fresh results */
3526 priv = hdd_request_priv(request);
3527 pAdapter->rssi = priv->rssi;
3528 if (pAdapter->rssi > 0)
3529 pAdapter->rssi = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 }
3531 }
3532
Jeff Johnsona5444942017-01-23 13:11:08 -08003533 /*
3534 * either we never sent a request, we sent a request and
3535 * received a response or we sent a request and timed out.
3536 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003538 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003539
3540 *rssi_value = pAdapter->rssi;
3541
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303542 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543}
3544
Jeff Johnson002cb972017-01-23 14:59:07 -08003545struct snr_priv {
3546 int8_t snr;
3547};
3548
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08003550 * hdd_get_snr_cb() - "Get SNR" callback function
3551 * @snr: Current SNR of the station
Jeff Johnson002cb972017-01-23 14:59:07 -08003552 * @sta_id: ID of the station
3553 * @context: opaque context originally passed to SME. HDD always passes
3554 * a cookie for the request context
Jeff Johnson8eaff302017-01-23 11:03:31 -08003555 *
3556 * Return: None
3557 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003558static void hdd_get_snr_cb(int8_t snr, uint32_t sta_id, void *context)
Jeff Johnson8eaff302017-01-23 11:03:31 -08003559{
Jeff Johnson002cb972017-01-23 14:59:07 -08003560 struct hdd_request *request;
3561 struct snr_priv *priv;
Jeff Johnson8eaff302017-01-23 11:03:31 -08003562
Jeff Johnson002cb972017-01-23 14:59:07 -08003563 request = hdd_request_get(context);
3564 if (!request) {
3565 hdd_err("Obsolete request");
Jeff Johnson8eaff302017-01-23 11:03:31 -08003566 return;
3567 }
3568
Jeff Johnson002cb972017-01-23 14:59:07 -08003569 /* propagate response back to requesting thread */
3570 priv = hdd_request_priv(request);
3571 priv->snr = snr;
3572 hdd_request_complete(request);
3573 hdd_request_put(request);
Jeff Johnson8eaff302017-01-23 11:03:31 -08003574}
3575
3576/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577 * wlan_hdd_get_snr() - Get the current SNR
3578 * @pAdapter: adapter upon which the measurement is requested
3579 * @snr: pointer to where the SNR should be returned
3580 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303581 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303583QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 hdd_context_t *pHddCtx;
3586 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303587 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 int valid;
Jeff Johnson002cb972017-01-23 14:59:07 -08003589 int ret;
3590 void *cookie;
3591 struct hdd_request *request;
3592 struct snr_priv *priv;
3593 static const struct hdd_request_params params = {
3594 .priv_size = sizeof(*priv),
3595 .timeout_ms = WLAN_WAIT_TIME_STATS,
3596 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303598 ENTER();
3599
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003601 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303602 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603 }
3604
3605 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3606
3607 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303608 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303609 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610
3611 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3612
Jeff Johnson002cb972017-01-23 14:59:07 -08003613 request = hdd_request_alloc(&params);
3614 if (!request) {
3615 hdd_err("Request allocation failure");
3616 return QDF_STATUS_E_FAULT;
3617 }
3618 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619
3620 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
3621 pHddStaCtx->conn_info.staId[0],
Jeff Johnson002cb972017-01-23 14:59:07 -08003622 pHddStaCtx->conn_info.bssId, cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303623 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003624 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 /* we'll returned a cached value below */
3626 } else {
3627 /* request was sent -- wait for the response */
Jeff Johnson002cb972017-01-23 14:59:07 -08003628 ret = hdd_request_wait_for_response(request);
3629 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003630 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631 /* we'll now returned a cached value below */
Jeff Johnson002cb972017-01-23 14:59:07 -08003632 } else {
3633 /* update the adapter with the fresh results */
3634 priv = hdd_request_priv(request);
3635 pAdapter->snr = priv->snr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 }
3637 }
3638
Jeff Johnson002cb972017-01-23 14:59:07 -08003639 /*
3640 * either we never sent a request, we sent a request and
3641 * received a response or we sent a request and timed out.
3642 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003644 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645
3646 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303647 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303648 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649}
3650
Jeff Johnsone50427c2017-01-26 10:54:49 -08003651struct linkspeed_priv {
3652 tSirLinkSpeedInfo linkspeed_info;
3653};
3654
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655static void
Jeff Johnsone50427c2017-01-26 10:54:49 -08003656hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657{
Jeff Johnsone50427c2017-01-26 10:54:49 -08003658 struct hdd_request *request;
3659 struct linkspeed_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660
Jeff Johnsone50427c2017-01-26 10:54:49 -08003661 if (!linkspeed_info) {
3662 hdd_err("NULL linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 return;
3664 }
3665
Jeff Johnsone50427c2017-01-26 10:54:49 -08003666 request = hdd_request_get(context);
3667 if (!request) {
3668 hdd_err("Obsolete request");
3669 return;
3670 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671
Jeff Johnsone50427c2017-01-26 10:54:49 -08003672 priv = hdd_request_priv(request);
3673 priv->linkspeed_info = *linkspeed_info;
3674 hdd_request_complete(request);
3675 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676}
3677
Jeff Johnsone50427c2017-01-26 10:54:49 -08003678int wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *adapter,
3679 struct qdf_mac_addr *mac_address,
3680 uint32_t *linkspeed)
3681{
3682 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303683 QDF_STATUS status;
Jeff Johnsone50427c2017-01-26 10:54:49 -08003684 void *cookie;
3685 tSirLinkSpeedInfo *linkspeed_info;
3686 struct hdd_request *request;
3687 struct linkspeed_priv *priv;
3688 static const struct hdd_request_params params = {
3689 .priv_size = sizeof(*priv),
3690 .timeout_ms = WLAN_WAIT_TIME_STATS,
3691 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692
Jeff Johnsone50427c2017-01-26 10:54:49 -08003693 if ((!adapter) || (!linkspeed)) {
3694 hdd_err("NULL argument");
3695 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697
Jeff Johnsone50427c2017-01-26 10:54:49 -08003698 request = hdd_request_alloc(&params);
3699 if (!request) {
3700 hdd_err("Request allocation failure");
3701 ret = -ENOMEM;
3702 goto return_cached_value;
3703 }
3704
3705 cookie = hdd_request_cookie(request);
3706 priv = hdd_request_priv(request);
3707
3708 linkspeed_info = &priv->linkspeed_info;
3709 qdf_copy_macaddr(&linkspeed_info->peer_macaddr, mac_address);
3710 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(adapter),
3711 linkspeed_info,
3712 cookie, hdd_get_link_speed_cb);
3713 if (QDF_IS_STATUS_ERROR(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003714 hdd_err("Unable to retrieve statistics for link speed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003715 ret = qdf_status_to_os_return(status);
3716 goto cleanup;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717 }
Jeff Johnsone50427c2017-01-26 10:54:49 -08003718 ret = hdd_request_wait_for_response(request);
3719 if (ret) {
3720 hdd_err("SME timed out while retrieving link speed");
3721 goto cleanup;
3722 }
3723 adapter->estimated_linkspeed = linkspeed_info->estLinkSpeed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724
Jeff Johnsone50427c2017-01-26 10:54:49 -08003725cleanup:
3726 /*
3727 * either we never sent a request, we sent a request and
3728 * received a response or we sent a request and timed out.
3729 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003730 */
Jeff Johnsone50427c2017-01-26 10:54:49 -08003731 hdd_request_put(request);
3732
3733return_cached_value:
3734 *linkspeed = adapter->estimated_linkspeed;
3735
3736 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737}
3738
3739/**
3740 * wlan_hdd_get_link_speed() - get link speed
3741 * @pAdapter: pointer to the adapter
3742 * @link_speed: pointer to link speed
3743 *
3744 * This function fetches per bssid link speed.
3745 *
3746 * Return: if associated, link speed shall be returned.
3747 * if not associated, link speed of 0 is returned.
3748 * On error, error number will be returned.
3749 */
3750int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
3751{
3752 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
3753 hdd_station_ctx_t *hdd_stactx =
3754 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
3755 int ret;
3756
3757 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05303758 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003760
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303761 /* Linkspeed is allowed only for P2P mode */
3762 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
3763 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
3764 hdd_device_mode_to_string(sta_adapter->device_mode),
3765 sta_adapter->device_mode);
3766 return -ENOTSUPP;
3767 }
3768
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003769 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
3770 /* we are not connected so we don't have a classAstats */
3771 *link_speed = 0;
3772 } else {
Anurag Chouhan6d760662016-02-20 16:05:43 +05303773 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774
Anurag Chouhanc5548422016-02-24 18:33:27 +05303775 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003776
Jeff Johnsone50427c2017-01-26 10:54:49 -08003777 ret = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, &bssid,
3778 link_speed);
3779 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003780 hdd_err("Unable to retrieve SME linkspeed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003781 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783 /* linkspeed in units of 500 kbps */
3784 *link_speed = (*link_speed) / 500;
3785 }
3786 return 0;
3787}
3788
3789/**
3790 * hdd_statistics_cb() - "Get statistics" callback function
3791 * @pStats: statistics payload
3792 * @pContext: opaque context originally passed to SME. HDD always passes
3793 * a pointer to an adapter
3794 *
3795 * Return: None
3796 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003797static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798{
3799 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
3800 hdd_stats_t *pStatsCache = NULL;
3801 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05303802 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803
3804 tCsrSummaryStatsInfo *pSummaryStats = NULL;
3805 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807
3808 if (pAdapter != NULL)
3809 pStatsCache = &pAdapter->hdd_stats;
3810
3811 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3812 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Jeff Johnsonf2dac4f2017-03-16 11:41:31 -07003813 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814
3815 if (pStatsCache != NULL) {
3816 /* copy the stats into the cache we keep in the
3817 * adapter instance structure
3818 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303819 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303821 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303823 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 sizeof(pStatsCache->ClassD_stat));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825 }
3826
3827 if (pAdapter) {
3828 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303829 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05303830 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003831 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832 return;
3833 }
3834 }
3835}
3836
3837/**
3838 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
3839 * @pAdapter: adapter who's IEs are to be cleared
3840 *
3841 * Return: None
3842 */
3843void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
3844{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003845 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07003846
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003847 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848
3849 /* clear WPA/RSN/WSC IE information in the profile */
3850 pWextState->roamProfile.nWPAReqIELength = 0;
3851 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
3852 pWextState->roamProfile.nRSNReqIELength = 0;
3853 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
3854
3855#ifdef FEATURE_WLAN_WAPI
3856 pWextState->roamProfile.nWAPIReqIELength = 0;
3857 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
3858#endif
3859
3860 pWextState->roamProfile.bWPSAssociation = false;
3861 pWextState->roamProfile.bOSENAssociation = false;
3862 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
3863 pWextState->roamProfile.nAddIEScanLength = 0;
3864 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
3865 pWextState->roamProfile.nAddIEAssocLength = 0;
3866
3867 pWextState->roamProfile.EncryptionType.numEntries = 1;
3868 pWextState->roamProfile.EncryptionType.encryptionType[0]
3869 = eCSR_ENCRYPT_TYPE_NONE;
3870
3871 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3872 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
3873 = eCSR_ENCRYPT_TYPE_NONE;
3874
3875 pWextState->roamProfile.AuthType.numEntries = 1;
3876 pWextState->roamProfile.AuthType.authType[0] =
3877 eCSR_AUTH_TYPE_OPEN_SYSTEM;
3878
Abhishek Singh3c9910e2017-01-06 17:56:47 +05303879 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
3880 QDF_MAC_ADDR_SIZE);
3881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882#ifdef WLAN_FEATURE_11W
3883 pWextState->roamProfile.MFPEnabled = false;
3884 pWextState->roamProfile.MFPRequired = 0;
3885 pWextState->roamProfile.MFPCapable = 0;
3886#endif
3887
3888 pWextState->authKeyMgmt = 0;
3889
Yingying Tang3cc6b792016-10-20 17:00:37 +08003890 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
3891
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892#ifdef FEATURE_WLAN_WAPI
3893 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
3894 pAdapter->wapi_info.nWapiMode = 0;
3895#endif
3896
Anurag Chouhanc5548422016-02-24 18:33:27 +05303897 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003898 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899}
3900
3901/**
3902 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
3903 * @oui: The OUI that is being searched for
3904 * @oui_size: The length of @oui
3905 * @ie: The set of IEs within which we're trying to find @oui
3906 * @ie_len: The length of @ie
3907 *
3908 * This function will scan the IEs contained within @ie looking for @oui.
3909 *
3910 * Return: Pointer to @oui embedded within @ie if it is present, NULL
3911 * if @oui is not present within @ie.
3912 */
3913uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
3914 uint8_t *ie, int ie_len)
3915{
3916 int left = ie_len;
3917 uint8_t *ptr = ie;
3918 uint8_t elem_id, elem_len;
3919 uint8_t eid = 0xDD;
3920
3921 if (NULL == ie || 0 == ie_len)
3922 return NULL;
3923
3924 while (left >= 2) {
3925 elem_id = ptr[0];
3926 elem_len = ptr[1];
3927 left -= 2;
3928 if (elem_len > left) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003929 hdd_err("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003930 eid, elem_len, left);
3931 return NULL;
3932 }
3933 if (elem_id == eid) {
3934 if (memcmp(&ptr[2], oui, oui_size) == 0)
3935 return ptr;
3936 }
3937
3938 left -= elem_len;
3939 ptr += (elem_len + 2);
3940 }
3941 return NULL;
3942}
3943
3944/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303945 * hdd_get_ldpc() - Get adapter LDPC
3946 * @adapter: adapter being queried
3947 * @value: where to store the value
3948 *
3949 * Return: 0 on success, negative errno on failure
3950 */
3951int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
3952{
3953 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3954 int ret;
3955
3956 ENTER();
3957 ret = sme_get_ht_config(hal, adapter->sessionId,
3958 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
3959 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003960 hdd_err("Failed to get LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303961 } else {
3962 *value = ret;
3963 ret = 0;
3964 }
3965 return ret;
3966}
3967
3968/**
3969 * hdd_set_ldpc() - Set adapter LDPC
3970 * @adapter: adapter being modified
3971 * @value: new LDPC value
3972 *
3973 * Return: 0 on success, negative errno on failure
3974 */
3975int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
3976{
3977 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3978 int ret;
3979
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003980 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303981 if (value) {
3982 /* make sure HT capabilities allow this */
3983 QDF_STATUS status;
3984 uint32_t cfg_value;
3985 union {
3986 uint16_t cfg_value16;
3987 tSirMacHTCapabilityInfo ht_cap_info;
3988 } u;
3989
3990 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
3991 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003992 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303993 return -EIO;
3994 }
3995 u.cfg_value16 = cfg_value & 0xFFFF;
3996 if (!u.ht_cap_info.advCodingCap) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003997 hdd_err("LDCP not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303998 return -EINVAL;
3999 }
4000 }
4001
4002 ret = sme_update_ht_config(hal, adapter->sessionId,
4003 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
4004 value);
4005 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004006 hdd_err("Failed to set LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304007
4008 return ret;
4009}
4010
4011/**
4012 * hdd_get_tx_stbc() - Get adapter TX STBC
4013 * @adapter: adapter being queried
4014 * @value: where to store the value
4015 *
4016 * Return: 0 on success, negative errno on failure
4017 */
4018int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
4019{
4020 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4021 int ret;
4022
4023 ENTER();
4024 ret = sme_get_ht_config(hal, adapter->sessionId,
4025 WNI_CFG_HT_CAP_INFO_TX_STBC);
4026 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004027 hdd_err("Failed to get TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304028 } else {
4029 *value = ret;
4030 ret = 0;
4031 }
4032
4033 return ret;
4034}
4035
4036/**
4037 * hdd_set_tx_stbc() - Set adapter TX STBC
4038 * @adapter: adapter being modified
4039 * @value: new TX STBC value
4040 *
4041 * Return: 0 on success, negative errno on failure
4042 */
4043int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
4044{
4045 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4046 int ret;
4047
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004048 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304049 if (value) {
4050 /* make sure HT capabilities allow this */
4051 QDF_STATUS status;
4052 uint32_t cfg_value;
4053 union {
4054 uint16_t cfg_value16;
4055 tSirMacHTCapabilityInfo ht_cap_info;
4056 } u;
4057
4058 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4059 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004060 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304061 return -EIO;
4062 }
4063 u.cfg_value16 = cfg_value & 0xFFFF;
4064 if (!u.ht_cap_info.txSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004065 hdd_err("TX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304066 return -EINVAL;
4067 }
4068 }
4069 ret = sme_update_ht_config(hal, adapter->sessionId,
4070 WNI_CFG_HT_CAP_INFO_TX_STBC,
4071 value);
4072 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004073 hdd_err("Failed to set TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304074
4075 return ret;
4076}
4077
4078/**
4079 * hdd_get_rx_stbc() - Get adapter RX STBC
4080 * @adapter: adapter being queried
4081 * @value: where to store the value
4082 *
4083 * Return: 0 on success, negative errno on failure
4084 */
4085int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
4086{
4087 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4088 int ret;
4089
4090 ENTER();
4091 ret = sme_get_ht_config(hal, adapter->sessionId,
4092 WNI_CFG_HT_CAP_INFO_RX_STBC);
4093 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004094 hdd_err("Failed to get RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304095 } else {
4096 *value = ret;
4097 ret = 0;
4098 }
4099
4100 return ret;
4101}
4102
4103/**
4104 * hdd_set_rx_stbc() - Set adapter RX STBC
4105 * @adapter: adapter being modified
4106 * @value: new RX STBC value
4107 *
4108 * Return: 0 on success, negative errno on failure
4109 */
4110int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
4111{
4112 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4113 int ret;
4114
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004115 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304116 if (value) {
4117 /* make sure HT capabilities allow this */
4118 QDF_STATUS status;
4119 uint32_t cfg_value;
4120 union {
4121 uint16_t cfg_value16;
4122 tSirMacHTCapabilityInfo ht_cap_info;
4123 } u;
4124
4125 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4126 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004127 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304128 return -EIO;
4129 }
4130 u.cfg_value16 = cfg_value & 0xFFFF;
4131 if (!u.ht_cap_info.rxSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004132 hdd_warn("RX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304133 return -EINVAL;
4134 }
4135 }
4136 ret = sme_update_ht_config(hal, adapter->sessionId,
4137 WNI_CFG_HT_CAP_INFO_RX_STBC,
4138 value);
4139 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004140 hdd_err("Failed to set RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304141
4142 return ret;
4143}
4144
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004145int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate)
4146{
4147 int set_value;
4148
4149 if (sme_is_feature_supported_by_fw(DOT11AX))
4150 set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble);
4151 else
4152 set_value = (preamble << 6) | (nss << 4) | rate;
4153
4154 return set_value;
4155}
4156
4157int hdd_set_11ax_rate(hdd_adapter_t *adapter, int set_value,
4158 struct sap_Config *sap_config)
4159{
4160 uint8_t preamble = 0, nss = 0, rix = 0;
4161 int ret;
4162
4163 if (!sap_config) {
4164 if (!sme_is_feature_supported_by_fw(DOT11AX)) {
4165 hdd_err("Target does not support 11ax");
4166 return -EIO;
4167 }
4168 } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax &&
4169 sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) {
4170 hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d",
4171 sap_config->SapHw_mode, sap_config->channel);
4172 return -EIO;
4173 }
4174
4175 if (set_value != 0xff) {
4176 rix = RC_2_RATE_IDX_11AX(set_value);
4177 preamble = WMI_RATE_PREAMBLE_HE;
4178 nss = HT_RC_2_STREAMS_11AX(set_value);
4179
4180 set_value = hdd_assemble_rate_code(preamble, nss, rix);
4181 }
4182
4183 hdd_notice("SET_11AX_RATE val %d rix %d preamble %x nss %d",
4184 set_value, rix, preamble, nss);
4185
4186 ret = wma_cli_set_command(adapter->sessionId,
4187 WMI_VDEV_PARAM_FIXED_RATE,
4188 set_value, VDEV_CMD);
4189
4190 return ret;
4191}
4192
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304193/**
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004194 * hdd_get_aid_rc() - Get AID and rate code passed from user
4195 * @aid: pointer to AID
4196 * @rc: pointer to rate code
4197 * @set_value: value passed from user
4198 *
4199 * If target is 11ax capable, set_value will have AID left shifted 16 bits
4200 * and 16 bits for rate code. If the target is not 11ax capable, rate code
4201 * will only be 8 bits.
4202 *
4203 * Return: None
4204 */
4205static void hdd_get_aid_rc(uint8_t *aid, uint16_t *rc, int set_value)
4206{
4207 uint8_t rc_bits;
4208
4209 if (sme_is_feature_supported_by_fw(DOT11AX))
4210 rc_bits = 16;
4211 else
4212 rc_bits = 8;
4213
4214 *aid = set_value >> rc_bits;
4215 *rc = set_value & ((1 << (rc_bits + 1)) - 1);
4216}
4217
4218int hdd_set_peer_rate(hdd_adapter_t *adapter, int set_value)
4219{
4220 uint8_t aid, *peer_mac;
4221 uint16_t rc;
4222 QDF_STATUS status;
4223
4224 if (adapter->device_mode != QDF_SAP_MODE) {
4225 hdd_err("Invalid devicde mode - %d", adapter->device_mode);
4226 return -EINVAL;
4227 }
4228
4229 hdd_get_aid_rc(&aid, &rc, set_value);
4230
4231 if ((adapter->aStaInfo[aid].isUsed) &&
4232 (OL_TXRX_PEER_STATE_CONN == adapter->aStaInfo[aid].tlSTAState)) {
4233 peer_mac =
4234 (uint8_t *)&(adapter->aStaInfo[aid].macAddrSTA.bytes[0]);
4235 hdd_info("Peer AID: %d MAC_ADDR: "MAC_ADDRESS_STR,
4236 aid, MAC_ADDR_ARRAY(peer_mac));
4237 } else {
4238 hdd_err("No matching peer found for AID: %d", aid);
4239 return -EINVAL;
4240 }
4241
4242 status = sme_set_peer_param(peer_mac, WMI_PEER_PARAM_FIXED_RATE,
4243 rc, adapter->sessionId);
4244 if (status != QDF_STATUS_SUCCESS) {
4245 hdd_err("Failed to set peer fixed rate - status: %d", status);
4246 return -EIO;
4247 }
4248
4249 return 0;
4250}
4251
4252/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
4254 * @dev: device upon which the ioctl was received
4255 * @info: ioctl request information
4256 * @wrqu: ioctl request data
4257 * @extra: ioctl extra data
4258 *
4259 * Return: 0 on success, non-zero on error
4260 */
4261static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
4262 union iwreq_data *wrqu, char *extra)
4263{
4264 hdd_adapter_t *adapter;
4265 hdd_context_t *hdd_ctx;
4266 int ret;
4267
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004268 ENTER_DEV(dev);
4269
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4271 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4272 ret = wlan_hdd_validate_context(hdd_ctx);
4273 if (0 != ret)
4274 return ret;
4275
Jeff Johnson441e1f72017-02-07 08:50:49 -08004276 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4277 if (0 != ret)
4278 return ret;
4279
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 /* Do nothing for now */
4281 return 0;
4282}
4283
4284/**
4285 * iw_set_commit() - SSR wrapper function for __iw_set_commit
4286 * @dev: pointer to net_device
4287 * @info: pointer to iw_request_info
4288 * @wrqu: pointer to iwreq_data
4289 * @extra: extra
4290 *
4291 * Return: 0 on success, error number otherwise
4292 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004293static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 union iwreq_data *wrqu, char *extra)
4295{
4296 int ret;
4297
4298 cds_ssr_protect(__func__);
4299 ret = __iw_set_commit(dev, info, wrqu, extra);
4300 cds_ssr_unprotect(__func__);
4301
4302 return ret;
4303}
4304
4305/**
4306 * __iw_get_name() - SIOCGIWNAME ioctl handler
4307 * @dev: device upon which the ioctl was received
4308 * @info: ioctl request information
4309 * @wrqu: ioctl request data
4310 * @extra: ioctl extra data
4311 *
4312 * Return: 0 on success, non-zero on error
4313 */
4314static int __iw_get_name(struct net_device *dev,
4315 struct iw_request_info *info, char *wrqu, char *extra)
4316{
4317 hdd_adapter_t *adapter;
4318 hdd_context_t *hdd_ctx;
4319 int ret;
4320
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004321 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322
4323 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4324 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4325 ret = wlan_hdd_validate_context(hdd_ctx);
4326 if (0 != ret)
4327 return ret;
4328
Jeff Johnson441e1f72017-02-07 08:50:49 -08004329 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4330 if (0 != ret)
4331 return ret;
4332
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
4334 EXIT();
4335 return 0;
4336}
4337
4338/**
4339 * __iw_get_name() - SSR wrapper for __iw_get_name
4340 * @dev: pointer to net_device
4341 * @info: pointer to iw_request_info
4342 * @wrqu: pointer to iwreq_data
4343 * @extra: extra
4344 *
4345 * Return: 0 on success, error number otherwise
4346 */
4347static int iw_get_name(struct net_device *dev,
4348 struct iw_request_info *info,
4349 char *wrqu, char *extra)
4350{
4351 int ret;
4352
4353 cds_ssr_protect(__func__);
4354 ret = __iw_get_name(dev, info, wrqu, extra);
4355 cds_ssr_unprotect(__func__);
4356
4357 return ret;
4358}
4359
4360/**
4361 * __iw_set_mode() - ioctl handler
4362 * @dev: device upon which the ioctl was received
4363 * @info: ioctl request information
4364 * @wrqu: ioctl request data
4365 * @extra: ioctl extra data
4366 *
4367 * Return: 0 on success, non-zero on error
4368 */
4369static int __iw_set_mode(struct net_device *dev,
4370 struct iw_request_info *info,
4371 union iwreq_data *wrqu, char *extra)
4372{
4373 hdd_wext_state_t *pWextState;
4374 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4375 hdd_context_t *hdd_ctx;
4376 tCsrRoamProfile *pRoamProfile;
4377 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378 struct hdd_config *pConfig;
4379 struct wireless_dev *wdev;
4380 int ret;
4381
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004382 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383
4384 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4385 ret = wlan_hdd_validate_context(hdd_ctx);
4386 if (0 != ret)
4387 return ret;
4388
Jeff Johnson441e1f72017-02-07 08:50:49 -08004389 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4390 if (0 != ret)
4391 return ret;
4392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4394 wdev = dev->ieee80211_ptr;
4395 pRoamProfile = &pWextState->roamProfile;
4396 LastBSSType = pRoamProfile->BSSType;
4397
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004398 hdd_debug("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399
4400 switch (wrqu->mode) {
4401 case IW_MODE_ADHOC:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004402 hdd_debug("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
4404 /* Set the phymode correctly for IBSS. */
4405 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
4406 pWextState->roamProfile.phyMode =
4407 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08004408 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 wdev->iftype = NL80211_IFTYPE_ADHOC;
4410 break;
4411 case IW_MODE_INFRA:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004412 hdd_debug("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
4414 wdev->iftype = NL80211_IFTYPE_STATION;
4415 break;
4416 case IW_MODE_AUTO:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004417 hdd_debug("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
4419 break;
4420 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004421 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 return -EOPNOTSUPP;
4423 }
4424
4425 if (LastBSSType != pRoamProfile->BSSType) {
4426 /* the BSS mode changed. We need to issue disconnect
4427 * if connected or in IBSS disconnect state
4428 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07004429 if (hdd_conn_is_connected
4430 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304432 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433 /* need to issue a disconnect to CSR. */
4434 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304435 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4437 pAdapter->sessionId,
4438 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304439 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440 unsigned long rc;
4441 rc = wait_for_completion_timeout(&pAdapter->
4442 disconnect_comp_var,
4443 msecs_to_jiffies
4444 (WLAN_WAIT_TIME_DISCONNECT));
4445 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004446 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 }
4448 }
4449 }
4450
4451 EXIT();
4452 return 0;
4453}
4454
4455/**
4456 * iw_set_mode() - SSR wrapper for __iw_set_mode()
4457 * @dev: pointer to net_device
4458 * @info: pointer to iw_request_info
4459 * @wrqu: pointer to iwreq_data
4460 * @extra: pointer to extra ioctl payload
4461 *
4462 * Return: 0 on success, error number otherwise
4463 */
4464static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
4465 union iwreq_data *wrqu, char *extra)
4466{
4467 int ret;
4468
4469 cds_ssr_protect(__func__);
4470 ret = __iw_set_mode(dev, info, wrqu, extra);
4471 cds_ssr_unprotect(__func__);
4472
4473 return ret;
4474}
4475
4476/**
4477 * __iw_get_mode() - SIOCGIWMODE ioctl handler
4478 * @dev: device upon which the ioctl was received
4479 * @info: ioctl request information
4480 * @wrqu: ioctl request data
4481 * @extra: ioctl extra data
4482 *
4483 * Return: 0 on success, non-zero on error
4484 */
4485static int
4486__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4487 union iwreq_data *wrqu, char *extra)
4488{
4489 hdd_wext_state_t *pWextState;
4490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4491 hdd_context_t *hdd_ctx;
4492 int ret;
4493
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004494 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495
4496 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4497 ret = wlan_hdd_validate_context(hdd_ctx);
4498 if (0 != ret)
4499 return ret;
4500
Jeff Johnson441e1f72017-02-07 08:50:49 -08004501 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4502 if (0 != ret)
4503 return ret;
4504
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4506
4507 switch (pWextState->roamProfile.BSSType) {
4508 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004509 hdd_debug("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510 wrqu->mode = IW_MODE_INFRA;
4511 break;
4512 case eCSR_BSS_TYPE_IBSS:
4513 case eCSR_BSS_TYPE_START_IBSS:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004514 hdd_debug("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 wrqu->mode = IW_MODE_ADHOC;
4516 break;
4517 case eCSR_BSS_TYPE_ANY:
4518 default:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004519 hdd_debug("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520 wrqu->mode = IW_MODE_AUTO;
4521 break;
4522 }
4523
4524 EXIT();
4525 return 0;
4526}
4527
4528/**
4529 * iw_get_mode() - SSR wrapper for __iw_get_mode()
4530 * @dev: pointer to net_device
4531 * @info: pointer to iw_request_info
4532 * @wrqu: pointer to iwreq_data
4533 * @extra: pointer to extra ioctl payload
4534 *
4535 * Return: 0 on success, error number otherwise
4536 */
4537static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4538 union iwreq_data *wrqu, char *extra)
4539{
4540 int ret;
4541
4542 cds_ssr_protect(__func__);
4543 ret = __iw_get_mode(dev, info, wrqu, extra);
4544 cds_ssr_unprotect(__func__);
4545
4546 return ret;
4547}
4548
4549/**
4550 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
4551 * @dev: device upon which the ioctl was received
4552 * @info: ioctl request information
4553 * @wrqu: ioctl request data
4554 * @extra: ioctl extra data
4555 *
4556 * Return: 0 on success, non-zero on error
4557 */
4558static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4559 union iwreq_data *wrqu, char *extra)
4560{
4561 uint32_t numChans = 0;
4562 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4563 uint32_t indx = 0;
4564 int ret;
4565 hdd_wext_state_t *pWextState;
4566 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4567 hdd_context_t *hdd_ctx;
4568 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4569 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4570 tCsrRoamProfile *pRoamProfile;
4571
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004572 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573
4574 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4575 ret = wlan_hdd_validate_context(hdd_ctx);
4576 if (0 != ret)
4577 return ret;
4578
Jeff Johnson441e1f72017-02-07 08:50:49 -08004579 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4580 if (0 != ret)
4581 return ret;
4582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4584
4585 pRoamProfile = &pWextState->roamProfile;
4586
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587 /* Link is up then return cant set channel */
4588 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
4589 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004590 hdd_debug("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 return -EOPNOTSUPP;
4592 }
4593
4594 /* Settings by Frequency as input */
4595 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
4596 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
4597 uint32_t freq = wrqu->freq.m / 100000;
4598
4599 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
4600 && (freq != freq_chan_map[indx].freq))
4601 indx++;
4602 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
4603 return -EINVAL;
4604 }
4605 wrqu->freq.e = 0;
4606 wrqu->freq.m = freq_chan_map[indx].chan;
4607
4608 }
4609
4610 if (wrqu->freq.e == 0) {
4611 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
4612 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004613 hdd_debug("Channel %d is outside valid range from %d to %d",
Jeff Johnson99bac312016-06-28 10:38:18 -07004614 wrqu->freq.m,
4615 WNI_CFG_CURRENT_CHANNEL_STAMIN,
4616 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 return -EINVAL;
4618 }
4619
4620 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4621
4622 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
4623 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304624 QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004625 hdd_err("Failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626 return -EIO;
4627 }
4628
4629 for (indx = 0; indx < numChans; indx++) {
4630 if (wrqu->freq.m == validChan[indx]) {
4631 break;
4632 }
4633 }
4634 } else {
4635
4636 return -EINVAL;
4637 }
4638
4639 if (indx >= numChans) {
4640 return -EINVAL;
4641 }
4642
4643 /* Set the Operational Channel */
4644 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
4645 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
4646 pRoamProfile->ChannelInfo.ChannelList =
4647 &pHddStaCtx->conn_info.operationChannel;
4648
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004649 hdd_debug("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650
4651 EXIT();
4652
4653 return ret;
4654}
4655
4656/**
4657 * iw_set_freq() - SSR wrapper for __iw_set_freq()
4658 * @dev: pointer to net_device
4659 * @info: pointer to iw_request_info
4660 * @wrqu: pointer to iwreq_data
4661 * @extra: pointer to extra ioctl payload
4662 *
4663 * Return: 0 on success, error number otherwise
4664 */
4665static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4666 union iwreq_data *wrqu, char *extra)
4667{
4668 int ret;
4669
4670 cds_ssr_protect(__func__);
4671 ret = __iw_set_freq(dev, info, wrqu, extra);
4672 cds_ssr_unprotect(__func__);
4673
4674 return ret;
4675}
4676
4677/**
4678 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
4679 * @dev: device upon which the ioctl was received
4680 * @info: ioctl request information
4681 * @wrqu: ioctl request data
4682 * @extra: ioctl extra data
4683 *
4684 * Return: 0 on success, non-zero on error
4685 */
4686static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4687 struct iw_freq *fwrq, char *extra)
4688{
4689 uint32_t status = false, channel = 0, freq = 0;
4690 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4691 tHalHandle hHal;
4692 hdd_wext_state_t *pWextState;
4693 tCsrRoamProfile *pRoamProfile;
4694 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4695 hdd_context_t *hdd_ctx;
4696 int ret;
4697
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004698 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699
4700 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4701 ret = wlan_hdd_validate_context(hdd_ctx);
4702 if (0 != ret)
4703 return ret;
4704
Jeff Johnson441e1f72017-02-07 08:50:49 -08004705 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4706 if (0 != ret)
4707 return ret;
4708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4710 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4711
4712 pRoamProfile = &pWextState->roamProfile;
4713
4714 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
4715 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304716 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004717 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 pAdapter->sessionId);
4719 return -EIO;
Jeff Johnson68755312017-02-10 11:46:55 -08004720 }
4721
4722 status = hdd_wlan_get_freq(channel, &freq);
4723 if (true == status) {
4724 /* Set Exponent parameter as 6 (MHZ)
4725 * in struct iw_freq iwlist & iwconfig
4726 * command shows frequency into proper
4727 * format (2.412 GHz instead of 246.2
4728 * MHz)
4729 */
4730 fwrq->m = freq;
4731 fwrq->e = MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732 }
4733 } else {
4734 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4735 * iwlist & iwconfig command shows frequency into proper
4736 * format (2.412 GHz instead of 246.2 MHz)
4737 */
4738 fwrq->m = 0;
4739 fwrq->e = MHZ;
4740 }
4741 return 0;
4742}
4743
4744/**
4745 * iw_get_freq() - SSR wrapper for __iw_get_freq()
4746 * @dev: pointer to net_device
4747 * @info: pointer to iw_request_info
4748 * @fwrq: pointer to frequency data
4749 * @extra: pointer to extra ioctl payload
4750 *
4751 * Return: 0 on success, error number otherwise
4752 */
4753static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4754 struct iw_freq *fwrq, char *extra)
4755{
4756 int ret;
4757
4758 cds_ssr_protect(__func__);
4759 ret = __iw_get_freq(dev, info, fwrq, extra);
4760 cds_ssr_unprotect(__func__);
4761
4762 return ret;
4763}
4764
4765/**
4766 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
4767 * @dev: device upon which the ioctl was received
4768 * @info: ioctl request information
4769 * @wrqu: ioctl request data
4770 * @extra: ioctl extra data
4771 *
4772 * Return: 0 on success, non-zero on error
4773 */
4774static int __iw_get_tx_power(struct net_device *dev,
4775 struct iw_request_info *info,
4776 union iwreq_data *wrqu, char *extra)
4777{
4778
4779 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4780 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4781 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4782 int ret;
4783
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004784 ENTER_DEV(dev);
4785
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786 ret = wlan_hdd_validate_context(hdd_ctx);
4787 if (0 != ret)
4788 return ret;
4789
Jeff Johnson441e1f72017-02-07 08:50:49 -08004790 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4791 if (0 != ret)
4792 return ret;
4793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4795 wrqu->txpower.value = 0;
4796 return 0;
4797 }
4798 wlan_hdd_get_class_astats(pAdapter);
4799 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
4800
4801 return 0;
4802}
4803
4804/**
4805 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
4806 * @dev: pointer to net_device
4807 * @info: pointer to iw_request_info
4808 * @wrqu: pointer to iwreq_data
4809 * @extra: pointer to extra ioctl payload
4810 *
4811 * Return: 0 on success, error number otherwise
4812 */
4813static int iw_get_tx_power(struct net_device *dev,
4814 struct iw_request_info *info,
4815 union iwreq_data *wrqu, char *extra)
4816{
4817 int ret;
4818
4819 cds_ssr_protect(__func__);
4820 ret = __iw_get_tx_power(dev, info, wrqu, extra);
4821 cds_ssr_unprotect(__func__);
4822
4823 return ret;
4824}
4825
4826/**
4827 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
4828 * @dev: device upon which the ioctl was received
4829 * @info: ioctl request information
4830 * @wrqu: ioctl request data
4831 * @extra: ioctl extra data
4832 *
4833 * Return: 0 on success, non-zero on error
4834 */
4835static int __iw_set_tx_power(struct net_device *dev,
4836 struct iw_request_info *info,
4837 union iwreq_data *wrqu, char *extra)
4838{
4839 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4840 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4841 hdd_context_t *hdd_ctx;
4842 int ret;
4843
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004844 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004845
4846 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4847 ret = wlan_hdd_validate_context(hdd_ctx);
4848 if (0 != ret)
4849 return ret;
4850
Jeff Johnson441e1f72017-02-07 08:50:49 -08004851 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4852 if (0 != ret)
4853 return ret;
4854
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304856 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004857 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858 return -EIO;
4859 }
4860
4861 EXIT();
4862
4863 return 0;
4864}
4865
4866/**
4867 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
4868 * @dev: pointer to net_device
4869 * @info: pointer to iw_request_info
4870 * @wrqu: pointer to iwreq_data
4871 * @extra: pointer to extra ioctl payload
4872 *
4873 * Return: 0 on success, error number otherwise
4874 */
4875static int iw_set_tx_power(struct net_device *dev,
4876 struct iw_request_info *info,
4877 union iwreq_data *wrqu, char *extra)
4878{
4879 int ret;
4880
4881 cds_ssr_protect(__func__);
4882 ret = __iw_set_tx_power(dev, info, wrqu, extra);
4883 cds_ssr_unprotect(__func__);
4884
4885 return ret;
4886}
4887
4888/**
4889 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
4890 * @dev: device upon which the ioctl was received
4891 * @info: ioctl request information
4892 * @wrqu: ioctl request data
4893 * @extra: ioctl extra data
4894 *
4895 * Return: 0 on success, non-zero on error
4896 */
4897static int __iw_get_bitrate(struct net_device *dev,
4898 struct iw_request_info *info,
4899 union iwreq_data *wrqu, char *extra)
4900{
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004901 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004902 hdd_wext_state_t *pWextState;
4903 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4904 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4905 hdd_context_t *hdd_ctx;
4906 int ret;
4907
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004908 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909
4910 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4911 ret = wlan_hdd_validate_context(hdd_ctx);
4912 if (0 != ret)
4913 return ret;
4914
Jeff Johnson441e1f72017-02-07 08:50:49 -08004915 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4916 if (0 != ret)
4917 return ret;
4918
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4920 wrqu->bitrate.value = 0;
4921 } else {
4922 status =
4923 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4924 eCSR_HDD,
4925 SME_SUMMARY_STATS |
4926 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -08004927 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004928 hdd_statistics_cb, 0,
4929 false,
4930 pHddStaCtx->conn_info.staId[0],
4931 pAdapter, pAdapter->sessionId);
4932
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304933 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004934 hdd_err("Unable to retrieve statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004935 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936 }
4937
4938 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4939
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004940 status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304941 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 WLAN_WAIT_TIME_STATS);
4943
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004944 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004945 hdd_err("SME timeout while retrieving statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004946 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947 }
4948
4949 wrqu->bitrate.value =
4950 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
4951 }
4952
4953 EXIT();
4954
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004955 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004956}
4957
4958/**
4959 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
4960 * @dev: pointer to net_device
4961 * @info: pointer to iw_request_info
4962 * @wrqu: pointer to iwreq_data
4963 * @extra: pointer to extra ioctl payload
4964 *
4965 * Return: 0 on success, error number otherwise
4966 */
4967static int iw_get_bitrate(struct net_device *dev,
4968 struct iw_request_info *info,
4969 union iwreq_data *wrqu, char *extra)
4970{
4971 int ret;
4972
4973 cds_ssr_protect(__func__);
4974 ret = __iw_get_bitrate(dev, info, wrqu, extra);
4975 cds_ssr_unprotect(__func__);
4976
4977 return ret;
4978}
4979
4980/**
4981 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
4982 * @dev: device upon which the ioctl was received
4983 * @info: ioctl request information
4984 * @wrqu: ioctl request data
4985 * @extra: ioctl extra data
4986 *
4987 * Return: 0 on success, non-zero on error
4988 */
4989static int __iw_set_bitrate(struct net_device *dev,
4990 struct iw_request_info *info,
4991 union iwreq_data *wrqu, char *extra)
4992{
4993 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4994 hdd_wext_state_t *pWextState;
4995 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4996 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4997 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4998 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4999 uint32_t i, rate;
5000 uint32_t valid_rate = false, active_phy_mode = 0;
5001 hdd_context_t *hdd_ctx;
5002 int ret;
5003
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005004 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005005
5006 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5007 ret = wlan_hdd_validate_context(hdd_ctx);
5008 if (0 != ret)
5009 return ret;
5010
Jeff Johnson441e1f72017-02-07 08:50:49 -08005011 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5012 if (0 != ret)
5013 return ret;
5014
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5016
5017 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
5018 return -ENXIO;
5019 }
5020
5021 rate = wrqu->bitrate.value;
5022
5023 if (rate == -1) {
5024 rate = WNI_CFG_FIXED_RATE_AUTO;
5025 valid_rate = true;
5026 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
5027 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305028 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005029 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5030 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
5031 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
5032 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
5033 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305034 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035 &&
5036 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
5037 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305038 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005039 for (i = 0; i < (b_len + a_len); ++i) {
5040 /* supported rates returned is double
5041 * the actual rate so we divide it by 2
5042 */
5043 if ((supp_rates[i] & 0x7F) / 2 ==
5044 rate) {
5045 valid_rate = true;
5046 rate = i +
5047 WNI_CFG_FIXED_RATE_1MBPS;
5048 break;
5049 }
5050 }
5051 }
5052 }
5053 }
5054 if (valid_rate != true) {
5055 return -EINVAL;
5056 }
5057 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305058 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005059 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 return -EIO;
5061 }
5062 return 0;
5063}
5064
5065/**
5066 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
5067 * @dev: pointer to net_device
5068 * @info: pointer to iw_request_info
5069 * @wrqu: pointer to iwreq_data
5070 * @extra: pointer to extra ioctl payload
5071 *
5072 * Return: 0 on success, error number otherwise
5073 */
5074static int iw_set_bitrate(struct net_device *dev,
5075 struct iw_request_info *info,
5076 union iwreq_data *wrqu, char *extra)
5077{
5078 int ret;
5079
5080 cds_ssr_protect(__func__);
5081 ret = __iw_set_bitrate(dev, info, wrqu, extra);
5082 cds_ssr_unprotect(__func__);
5083
5084 return ret;
5085}
5086
5087/**
5088 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
5089 * @dev: device upon which the ioctl was received
5090 * @info: ioctl request information
5091 * @wrqu: ioctl request data
5092 * @extra: ioctl extra data
5093 *
5094 * Return: 0 on success, non-zero on error
5095 */
5096static int __iw_set_genie(struct net_device *dev,
5097 struct iw_request_info *info,
5098 union iwreq_data *wrqu, char *extra)
5099{
5100 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5101 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5102 uint8_t *genie = NULL;
5103 uint8_t *base_genie = NULL;
5104 uint16_t remLen;
5105 hdd_context_t *hdd_ctx;
5106 int ret;
5107
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005108 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109
5110 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5111 ret = wlan_hdd_validate_context(hdd_ctx);
5112 if (0 != ret)
5113 return ret;
5114
Jeff Johnson441e1f72017-02-07 08:50:49 -08005115 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5116 if (0 != ret)
5117 return ret;
5118
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119 if (!wrqu->data.length) {
5120 hdd_clear_roam_profile_ie(pAdapter);
5121 EXIT();
5122 return 0;
5123 }
5124
5125 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
5126 wrqu->data.length);
5127 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005128 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129 return -ENOMEM;
5130 }
5131
5132 genie = base_genie;
5133
5134 remLen = wrqu->data.length;
5135
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005136 hdd_debug("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005137 genie[1]);
5138
5139 /* clear any previous genIE before this call */
5140 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5141
5142 while (remLen >= 2) {
5143 uint16_t eLen = 0;
5144 uint8_t elementId;
5145 elementId = *genie++;
5146 eLen = *genie++;
5147 remLen -= 2;
5148
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005149 hdd_debug("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150
5151 switch (elementId) {
5152 case IE_EID_VENDOR:
5153 if ((IE_LEN_SIZE + IE_EID_SIZE + IE_VENDOR_OUI_SIZE) > eLen) { /* should have at least OUI */
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305154 ret = -EINVAL;
5155 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 }
5157
5158 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
5159 uint16_t curGenIELen = pWextState->genIE.length;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005160 hdd_debug("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
Jeff Johnson99bac312016-06-28 10:38:18 -07005161 genie[0], genie[1], genie[2],
5162 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005163
5164 if (SIR_MAC_MAX_IE_LENGTH <
5165 (pWextState->genIE.length + eLen)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005166 hdd_err("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305167 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305168 ret = -ENOMEM;
5169 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005170 }
5171 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
5172 memcpy(pWextState->genIE.addIEdata +
5173 curGenIELen, genie - 2, eLen + 2);
5174 pWextState->genIE.length += eLen + 2;
5175 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005176 hdd_debug("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305177 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005178 hdd_err("Cannot accommodate genIE, Need bigger buffer space");
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305179 ret = -EINVAL;
5180 QDF_ASSERT(0);
5181 goto exit;
5182 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005183 memset(pWextState->WPARSNIE, 0,
5184 MAX_WPA_RSN_IE_LEN);
5185 memcpy(pWextState->WPARSNIE, genie - 2,
5186 (eLen + 2));
5187 pWextState->roamProfile.pWPAReqIE =
5188 pWextState->WPARSNIE;
5189 pWextState->roamProfile.nWPAReqIELength =
5190 eLen + 2;
5191 } else { /* any vendorId except WPA IE should be accumulated to genIE */
5192
5193 uint16_t curGenIELen = pWextState->genIE.length;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005194 hdd_debug("Set OUI(%02x %02x %02x %02x) IE(len %d)",
Jeff Johnson99bac312016-06-28 10:38:18 -07005195 genie[0], genie[1], genie[2],
5196 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197
5198 if (SIR_MAC_MAX_IE_LENGTH <
5199 (pWextState->genIE.length + eLen)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005200 hdd_err("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305201 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305202 ret = -ENOMEM;
5203 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005204 }
5205 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
5206 memcpy(pWextState->genIE.addIEdata +
5207 curGenIELen, genie - 2, eLen + 2);
5208 pWextState->genIE.length += eLen + 2;
5209 }
5210 break;
5211 case DOT11F_EID_RSN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005212 hdd_debug("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305213 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005214 hdd_err("Cannot accommodate genIE, Need bigger buffer space");
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305215 ret = -EINVAL;
5216 QDF_ASSERT(0);
5217 goto exit;
5218 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005219 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
5220 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
5221 pWextState->roamProfile.pRSNReqIE =
5222 pWextState->WPARSNIE;
5223 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
5224 break;
5225
5226 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005227 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305228 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229 }
5230 genie += eLen;
5231 remLen -= eLen;
5232 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305233exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07005235 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305236 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005237}
5238
5239/**
5240 * iw_set_genie() - SSR wrapper for __iw_set_genie()
5241 * @dev: pointer to net_device
5242 * @info: pointer to iw_request_info
5243 * @wrqu: pointer to iwreq_data
5244 * @extra: pointer to extra ioctl payload
5245 *
5246 * Return: 0 on success, error number otherwise
5247 */
5248static int iw_set_genie(struct net_device *dev,
5249 struct iw_request_info *info,
5250 union iwreq_data *wrqu, char *extra)
5251{
5252 int ret;
5253
5254 cds_ssr_protect(__func__);
5255 ret = __iw_set_genie(dev, info, wrqu, extra);
5256 cds_ssr_unprotect(__func__);
5257
5258 return ret;
5259}
5260
5261/**
5262 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
5263 * @dev: device upon which the ioctl was received
5264 * @info: ioctl request information
5265 * @wrqu: ioctl request data
5266 * @extra: ioctl extra data
5267 *
5268 * Return: 0 on success, non-zero on error
5269 */
5270static int __iw_get_genie(struct net_device *dev,
5271 struct iw_request_info *info,
5272 union iwreq_data *wrqu, char *extra)
5273{
5274 hdd_wext_state_t *pWextState;
5275 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5276 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305277 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
5279 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
5280 hdd_context_t *hdd_ctx;
5281 int ret;
5282
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005283 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284
5285 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5286 ret = wlan_hdd_validate_context(hdd_ctx);
5287 if (0 != ret)
5288 return ret;
5289
Jeff Johnson441e1f72017-02-07 08:50:49 -08005290 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5291 if (0 != ret)
5292 return ret;
5293
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005294 hdd_debug("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295
5296 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5297
5298 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
5299 return -ENXIO;
5300 }
5301
5302 /* Return something ONLY if we are associated with an RSN or
5303 * WPA network
5304 */
5305 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
5306 return -ENXIO;
5307 }
5308
5309 /* Actually retrieve the RSN IE from CSR. (We previously sent
5310 * it down in the CSR Roam Profile.)
5311 */
5312 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
5313 pAdapter->sessionId,
5314 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305315 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005316 hdd_err("Failed to get WPA-RSN IE data status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 return -EFAULT;
5318 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005319 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05305320 if (length > DOT11F_IE_RSN_MAX_LEN) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005321 hdd_err("Invalid buffer length: %d", length);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305322 return -E2BIG;
5323 }
5324 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005325
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005326 hdd_debug("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327 wrqu->data.length);
5328
5329 EXIT();
5330
5331 return 0;
5332}
5333
5334/**
5335 * iw_get_genie() - SSR wrapper for __iw_get_genie()
5336 * @dev: pointer to net_device
5337 * @info: pointer to iw_request_info
5338 * @wrqu: pointer to iwreq_data
5339 * @extra: pointer to extra ioctl payload
5340 *
5341 * Return: 0 on success, error number otherwise
5342 */
5343static int iw_get_genie(struct net_device *dev,
5344 struct iw_request_info *info,
5345 union iwreq_data *wrqu, char *extra)
5346{
5347 int ret;
5348
5349 cds_ssr_protect(__func__);
5350 ret = __iw_get_genie(dev, info, wrqu, extra);
5351 cds_ssr_unprotect(__func__);
5352
5353 return ret;
5354}
5355
5356/**
5357 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
5358 * @dev: device upon which the ioctl was received
5359 * @info: ioctl request information
5360 * @wrqu: ioctl request data
5361 * @extra: ioctl extra data
5362 *
5363 * Return: 0 on success, non-zero on error
5364 */
5365static int __iw_get_encode(struct net_device *dev,
5366 struct iw_request_info *info,
5367 struct iw_point *dwrq, char *extra)
5368{
5369 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5370 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5371 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5372 int keyId;
5373 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
5374 int i;
5375 hdd_context_t *hdd_ctx;
5376 int ret;
5377
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005378 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379
5380 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5381 ret = wlan_hdd_validate_context(hdd_ctx);
5382 if (0 != ret)
5383 return ret;
5384
Jeff Johnson441e1f72017-02-07 08:50:49 -08005385 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5386 if (0 != ret)
5387 return ret;
5388
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005389 keyId = pRoamProfile->Keys.defaultIndex;
5390
5391 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005392 hdd_err("Invalid keyId: %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005393 return -EINVAL;
5394 }
5395
5396 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
5397 dwrq->flags |= IW_ENCODE_ENABLED;
5398 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305399 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400 pRoamProfile->Keys.KeyLength[keyId]);
5401
5402 dwrq->flags |= (keyId + 1);
5403
5404 } else {
5405 dwrq->flags |= IW_ENCODE_DISABLED;
5406 }
5407
5408 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08005409 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005410 continue;
5411 } else {
5412 break;
5413 }
5414 }
5415
5416 if (MAX_WEP_KEYS == i) {
5417 dwrq->flags |= IW_ENCODE_NOKEY;
5418 }
5419
5420 authType =
5421 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
5422 conn_info.authType;
5423
5424 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
5425 dwrq->flags |= IW_ENCODE_OPEN;
5426 } else {
5427 dwrq->flags |= IW_ENCODE_RESTRICTED;
5428 }
5429 EXIT();
5430 return 0;
5431}
5432
5433/**
5434 * iw_get_encode() - SSR wrapper for __iw_get_encode()
5435 * @dev: pointer to net_device
5436 * @info: pointer to iw_request_info
5437 * @dwrq: pointer to encoding information
5438 * @extra: pointer to extra ioctl payload
5439 *
5440 * Return: 0 on success, error number otherwise
5441 */
5442static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
5443 struct iw_point *dwrq, char *extra)
5444{
5445 int ret;
5446
5447 cds_ssr_protect(__func__);
5448 ret = __iw_get_encode(dev, info, dwrq, extra);
5449 cds_ssr_unprotect(__func__);
5450
5451 return ret;
5452}
5453
5454/**
5455 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
5456 * @dev: device upon which the ioctl was received
5457 * @info: ioctl request information
5458 * @wrqu: ioctl request data
5459 * @extra: ioctl extra data
5460 *
5461 * Return: 0 on success, non-zero on error
5462 */
5463static int __iw_get_rts_threshold(struct net_device *dev,
5464 struct iw_request_info *info,
5465 union iwreq_data *wrqu, char *extra)
5466{
Jeff Johnson5b907622017-02-07 10:00:37 -08005467 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5468 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5469 uint32_t threshold = 0;
5470 hdd_context_t *hdd_ctx;
5471 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005473 ENTER_DEV(dev);
5474
Jeff Johnson5b907622017-02-07 10:00:37 -08005475 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5476 ret = wlan_hdd_validate_context(hdd_ctx);
5477 if (0 != ret)
5478 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479
Jeff Johnson441e1f72017-02-07 08:50:49 -08005480 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5481 if (0 != ret)
5482 return ret;
5483
Jeff Johnson5b907622017-02-07 10:00:37 -08005484 if (QDF_STATUS_SUCCESS !=
5485 sme_cfg_get_int(hal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
5486 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
5487 return -EIO;
5488 }
5489 wrqu->rts.value = threshold;
5490
5491 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
5492
5493 EXIT();
5494
5495 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496}
5497
5498/**
5499 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
5500 * @dev: device upon which the ioctl was received
5501 * @info: ioctl request information
5502 * @wrqu: ioctl request data
5503 * @extra: ioctl extra data
5504 *
5505 * Return: 0 on success, non-zero on error
5506 */
5507static int __iw_set_rts_threshold(struct net_device *dev,
5508 struct iw_request_info *info,
5509 union iwreq_data *wrqu, char *extra)
5510{
5511 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5512 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5513 hdd_context_t *hdd_ctx;
5514 int ret;
5515
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005516 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517
5518 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5519 ret = wlan_hdd_validate_context(hdd_ctx);
5520 if (0 != ret)
5521 return ret;
5522
Jeff Johnson441e1f72017-02-07 08:50:49 -08005523 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5524 if (0 != ret)
5525 return ret;
5526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
5528 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
5529 return -EINVAL;
5530 }
5531
5532 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305533 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005534 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005535 return -EIO;
5536 }
5537
5538 EXIT();
5539
5540 return 0;
5541}
5542
5543/**
5544 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
5545 * @dev: pointer to net_device
5546 * @info: pointer to iw_request_info
5547 * @wrqu: pointer to iwreq_data
5548 * @extra: pointer to extra ioctl payload
5549 *
5550 * Return: 0 on success, error number otherwise
5551 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005552int iw_get_rts_threshold(struct net_device *dev,
5553 struct iw_request_info *info,
5554 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555{
5556 int ret;
5557
5558 cds_ssr_protect(__func__);
5559 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
5560 cds_ssr_unprotect(__func__);
5561
5562 return ret;
5563}
5564
5565/**
5566 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
5567 * @dev: pointer to net_device
5568 * @info: pointer to iw_request_info
5569 * @wrqu: pointer to iwreq_data
5570 * @extra: pointer to extra ioctl payload
5571 *
5572 * Return: 0 on success, error number otherwise
5573 */
5574static int iw_set_rts_threshold(struct net_device *dev,
5575 struct iw_request_info *info,
5576 union iwreq_data *wrqu, char *extra)
5577{
5578 int ret;
5579
5580 cds_ssr_protect(__func__);
5581 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
5582 cds_ssr_unprotect(__func__);
5583
5584 return ret;
5585}
5586
5587/**
5588 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
5589 * @dev: device upon which the ioctl was received
5590 * @info: ioctl request information
5591 * @wrqu: ioctl request data
5592 * @extra: ioctl extra data
5593 *
5594 * Return: 0 on success, non-zero on error
5595 */
5596static int __iw_get_frag_threshold(struct net_device *dev,
5597 struct iw_request_info *info,
5598 union iwreq_data *wrqu, char *extra)
5599{
Jeff Johnson5b907622017-02-07 10:00:37 -08005600 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5601 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5602 uint32_t threshold = 0;
5603 hdd_context_t *hdd_ctx;
5604 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005606 ENTER_DEV(dev);
5607
Jeff Johnson5b907622017-02-07 10:00:37 -08005608 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5609 ret = wlan_hdd_validate_context(hdd_ctx);
5610 if (0 != ret)
5611 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005612
Jeff Johnson441e1f72017-02-07 08:50:49 -08005613 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5614 if (0 != ret)
5615 return ret;
5616
Jeff Johnson5b907622017-02-07 10:00:37 -08005617 if (sme_cfg_get_int(hal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
5618 != QDF_STATUS_SUCCESS) {
5619 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
5620 return -EIO;
5621 }
5622 wrqu->frag.value = threshold;
5623
5624 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
5625
5626 EXIT();
5627
5628 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005629}
5630
5631/**
5632 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
5633 * @dev: pointer to net_device
5634 * @info: pointer to iw_request_info
5635 * @wrqu: pointer to iwreq_data
5636 * @extra: pointer to extra ioctl payload
5637 *
5638 * Return: 0 on success, error number otherwise
5639 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005640int iw_get_frag_threshold(struct net_device *dev,
5641 struct iw_request_info *info,
5642 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643{
5644 int ret;
5645
5646 cds_ssr_protect(__func__);
5647 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
5648 cds_ssr_unprotect(__func__);
5649
5650 return ret;
5651}
5652
5653/**
5654 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
5655 * @dev: device upon which the ioctl was received
5656 * @info: ioctl request information
5657 * @wrqu: ioctl request data
5658 * @extra: ioctl extra data
5659 *
5660 * Return: 0 on success, non-zero on error
5661 */
5662static int __iw_set_frag_threshold(struct net_device *dev,
5663 struct iw_request_info *info,
5664 union iwreq_data *wrqu, char *extra)
5665{
5666 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5667 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5668 hdd_context_t *hdd_ctx;
5669 int ret;
5670
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005671 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005672
5673 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5674 ret = wlan_hdd_validate_context(hdd_ctx);
5675 if (0 != ret)
5676 return ret;
5677
Jeff Johnson441e1f72017-02-07 08:50:49 -08005678 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5679 if (0 != ret)
5680 return ret;
5681
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005682 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
5683 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
5684 return -EINVAL;
5685 }
5686
5687 if (sme_cfg_set_int
5688 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305689 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005690 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005691 return -EIO;
5692 }
5693
5694 EXIT();
5695
5696 return 0;
5697}
5698
5699/**
5700 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
5701 * @dev: pointer to net_device
5702 * @info: pointer to iw_request_info
5703 * @wrqu: pointer to iwreq_data
5704 * @extra: pointer to extra ioctl payload
5705 *
5706 * Return: 0 on success, error number otherwise
5707 */
5708static int iw_set_frag_threshold(struct net_device *dev,
5709 struct iw_request_info *info,
5710 union iwreq_data *wrqu, char *extra)
5711{
5712 int ret;
5713
5714 cds_ssr_protect(__func__);
5715 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
5716 cds_ssr_unprotect(__func__);
5717
5718 return ret;
5719}
5720
5721/**
5722 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
5723 * @dev: device upon which the ioctl was received
5724 * @info: ioctl request information
5725 * @wrqu: ioctl request data
5726 * @extra: ioctl extra data
5727 *
5728 * Return: 0 on success, non-zero on error
5729 */
5730static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005731 struct iw_request_info *info,
5732 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005733{
5734 hdd_adapter_t *adapter;
5735 hdd_context_t *hdd_ctx;
5736 int ret;
5737
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005738 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005739
5740 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5741 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5742 ret = wlan_hdd_validate_context(hdd_ctx);
5743 if (0 != ret)
5744 return ret;
5745
Jeff Johnson441e1f72017-02-07 08:50:49 -08005746 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5747 if (0 != ret)
5748 return ret;
5749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750 return -EOPNOTSUPP;
5751}
5752
5753/**
5754 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
5755 * @dev: pointer to net_device
5756 * @info: pointer to iw_request_info
5757 * @wrqu: pointer to iwreq_data
5758 * @extra: extra
5759 *
5760 * Return: 0 on success, error number otherwise
5761 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005762static int iw_get_power_mode(struct net_device *dev,
5763 struct iw_request_info *info,
5764 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005765{
5766 int ret;
5767
5768 cds_ssr_protect(__func__);
5769 ret = __iw_get_power_mode(dev, info, wrqu, extra);
5770 cds_ssr_unprotect(__func__);
5771
5772 return ret;
5773}
5774
5775/**
5776 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
5777 * @dev: device upon which the ioctl was received
5778 * @info: ioctl request information
5779 * @wrqu: ioctl request data
5780 * @extra: ioctl extra data
5781 *
5782 * Return: 0 on success, non-zero on error
5783 */
5784static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005785 struct iw_request_info *info,
5786 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787{
5788 hdd_adapter_t *adapter;
5789 hdd_context_t *hdd_ctx;
5790 int ret;
5791
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005792 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005793
5794 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5795 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5796 ret = wlan_hdd_validate_context(hdd_ctx);
5797 if (0 != ret)
5798 return ret;
5799
Jeff Johnson441e1f72017-02-07 08:50:49 -08005800 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5801 if (0 != ret)
5802 return ret;
5803
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 return -EOPNOTSUPP;
5805}
5806
5807/**
5808 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
5809 * @dev: pointer to net_device
5810 * @info: pointer to iw_request_info
5811 * @wrqu: pointer to iwreq_data
5812 * @extra: extra
5813 *
5814 * Return: 0 on success, error number otherwise
5815 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005816static int iw_set_power_mode(struct net_device *dev,
5817 struct iw_request_info *info,
5818 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005819{
5820 int ret;
5821
5822 cds_ssr_protect(__func__);
5823 ret = __iw_set_power_mode(dev, info, wrqu, extra);
5824 cds_ssr_unprotect(__func__);
5825
5826 return ret;
5827}
5828
5829/**
5830 * __iw_get_range() - SIOCGIWRANGE ioctl handler
5831 * @dev: device upon which the ioctl was received
5832 * @info: ioctl request information
5833 * @wrqu: ioctl request data
5834 * @extra: ioctl extra data
5835 *
5836 * Return: 0 on success, non-zero on error
5837 */
5838static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
5839 union iwreq_data *wrqu, char *extra)
5840{
5841 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5842 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5843 struct iw_range *range = (struct iw_range *)extra;
5844
5845 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5846
5847 uint32_t num_channels = sizeof(channels);
5848 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
5849 uint32_t a_len;
5850 uint32_t b_len;
5851 uint32_t active_phy_mode = 0;
5852 uint8_t index = 0, i;
5853 hdd_context_t *hdd_ctx;
5854 int ret;
5855
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005856 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857
5858 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5859 ret = wlan_hdd_validate_context(hdd_ctx);
5860 if (0 != ret)
5861 return ret;
5862
Jeff Johnson441e1f72017-02-07 08:50:49 -08005863 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5864 if (0 != ret)
5865 return ret;
5866
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 wrqu->data.length = sizeof(struct iw_range);
5868 memset(range, 0, sizeof(struct iw_range));
5869
5870
5871 /*Get the phy mode */
5872 if (sme_cfg_get_int(hHal,
5873 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305874 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005875 hdd_debug("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005876
5877 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5878 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
5879 /*Get the supported rates for 11G band */
5880 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5881 if (sme_cfg_get_str(hHal,
5882 WNI_CFG_SUPPORTED_RATES_11A,
5883 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305884 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005885 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
5886 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5887 }
5888 for (i = 0; i < a_len; i++) {
5889 range->bitrate[i] =
5890 ((supp_rates[i] & 0x7F) / 2) *
5891 1000000;
5892 }
5893 range->num_bitrates = a_len;
5894 } else {
5895 return -EIO;
5896 }
5897 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
5898 /*Get the supported rates for 11B band */
5899 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5900 if (sme_cfg_get_str(hHal,
5901 WNI_CFG_SUPPORTED_RATES_11B,
5902 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305903 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005904 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
5905 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5906 }
5907 for (i = 0; i < b_len; i++) {
5908 range->bitrate[i] =
5909 ((supp_rates[i] & 0x7F) / 2) *
5910 1000000;
5911 }
5912 range->num_bitrates = b_len;
5913 } else {
5914 return -EIO;
5915 }
5916 }
5917 }
5918
5919 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
5920 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
5921 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
5922
5923 range->encoding_size[0] = 5;
5924 range->encoding_size[1] = 13;
5925 range->num_encoding_sizes = 2;
5926 range->max_encoding_tokens = MAX_WEP_KEYS;
5927
5928 /* we support through Wireless Extensions 22 */
5929 range->we_version_compiled = WIRELESS_EXT;
5930 range->we_version_source = 22;
5931
5932 /*Supported Channels and Frequencies */
5933 if (sme_cfg_get_str
5934 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305935 &num_channels) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005936 hdd_err("Failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005937 return -EIO;
5938 }
5939 if (num_channels > IW_MAX_FREQUENCIES) {
5940 num_channels = IW_MAX_FREQUENCIES;
5941 }
5942
5943 range->num_channels = num_channels;
5944 range->num_frequency = num_channels;
5945
5946 for (index = 0; index < num_channels; index++) {
5947 uint32_t frq_indx = 0;
5948
5949 range->freq[index].i = channels[index];
5950 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
5951 if (channels[index] == freq_chan_map[frq_indx].chan) {
5952 range->freq[index].m =
5953 freq_chan_map[frq_indx].freq * 100000;
5954 range->freq[index].e = 1;
5955 break;
5956 }
5957 frq_indx++;
5958 }
5959 }
5960
5961 /* Event capability (kernel + driver) */
5962 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
5963 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
5964 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
5965 range->event_capa[1] = IW_EVENT_CAPA_K_1;
5966
5967 /*Encryption capability */
5968 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
5969 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
5970
5971 /* Txpower capability */
5972 range->txpower_capa = IW_TXPOW_MWATT;
5973
5974 /*Scanning capability */
5975#if WIRELESS_EXT >= 22
5976 range->scan_capa =
5977 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
5978#endif
5979
5980 EXIT();
5981 return 0;
5982}
5983
5984/**
5985 * iw_get_range() - SSR wrapper for __iw_get_range()
5986 * @dev: pointer to net_device
5987 * @info: pointer to iw_request_info
5988 * @wrqu: pointer to iwreq_data
5989 * @extra: pointer to extra ioctl payload
5990 *
5991 * Return: 0 on success, error number otherwise
5992 */
5993static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
5994 union iwreq_data *wrqu, char *extra)
5995{
5996 int ret;
5997
5998 cds_ssr_protect(__func__);
5999 ret = __iw_get_range(dev, info, wrqu, extra);
6000 cds_ssr_unprotect(__func__);
6001
6002 return ret;
6003}
6004
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006005struct class_a_stats {
6006 tCsrGlobalClassAStatsInfo class_a_stats;
6007};
6008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009/**
6010 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006011 * @stats: pointer to Class A stats
6012 * @context: user context originally registered with SME (always the
6013 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006014 *
6015 * Return: None
6016 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006017static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006018{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006019 struct hdd_request *request;
6020 struct class_a_stats *priv;
6021 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006023 ENTER();
6024 if ((NULL == stats) || (NULL == context)) {
6025 hdd_err("Bad param, stats [%p] context [%p]",
6026 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027 return;
6028 }
6029
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006030 request = hdd_request_get(context);
6031 if (!request) {
6032 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033 return;
6034 }
6035
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006036 returned_stats = stats;
6037 priv = hdd_request_priv(request);
6038 priv->class_a_stats = *returned_stats;
6039 hdd_request_complete(request);
6040 hdd_request_put(request);
6041 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006042}
6043
6044/**
6045 * wlan_hdd_get_class_astats() - Get Class A statistics
6046 * @pAdapter: adapter for which statistics are desired
6047 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306048 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006049 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306050QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051{
6052 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306053 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006054 int ret;
6055 void *cookie;
6056 struct hdd_request *request;
6057 struct class_a_stats *priv;
6058 static const struct hdd_request_params params = {
6059 .priv_size = sizeof(*priv),
6060 .timeout_ms = WLAN_WAIT_TIME_STATS,
6061 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062
6063 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006064 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306065 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006066 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08006067 if (cds_is_driver_recovering()) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006068 hdd_debug("Recovery in Progress. State: 0x%x Ignore!!!",
Prashanth Bhatta9e143052015-12-04 11:56:47 -08006069 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306070 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 }
6072
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006073 request = hdd_request_alloc(&params);
6074 if (!request) {
6075 hdd_err("Request allocation failure");
6076 return QDF_STATUS_E_NOMEM;
6077 }
6078 cookie = hdd_request_cookie(request);
6079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006080 /* query only for Class A statistics (which include link speed) */
6081 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
6082 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
6083 hdd_get_class_a_statistics_cb,
6084 0, /* not periodic */
6085 false, /* non-cached results */
6086 pHddStaCtx->conn_info.staId[0],
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006087 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306088 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07006089 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006090 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 }
6092
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006093 /* request was sent -- wait for the response */
6094 ret = hdd_request_wait_for_response(request);
6095 if (ret) {
6096 hdd_warn("SME timed out while retrieving Class A statistics");
6097 goto return_cached_results;
6098 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006100 /* update the adapter with the fresh results */
6101 priv = hdd_request_priv(request);
6102 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6103
6104return_cached_results:
6105 /*
6106 * either we never sent a request, we sent a request and
6107 * received a response or we sent a request and timed out.
6108 * regardless we are done with the request.
6109 */
6110 hdd_request_put(request);
6111
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306112 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006113}
6114
Jeff Johnsondda167c2017-01-23 10:37:57 -08006115struct station_stats {
6116 tCsrSummaryStatsInfo summary_stats;
6117 tCsrGlobalClassAStatsInfo class_a_stats;
6118 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
6119};
6120
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006121/**
6122 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08006123 * @stats: pointer to combined station stats
6124 * @context: user context originally registered with SME (always the
6125 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126 *
6127 * Return: None
6128 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006129static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006130{
Jeff Johnsondda167c2017-01-23 10:37:57 -08006131 struct hdd_request *request;
6132 struct station_stats *priv;
6133 tCsrSummaryStatsInfo *summary_stats;
6134 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306135 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006136
Jeff Johnsondda167c2017-01-23 10:37:57 -08006137 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006138 hdd_err("Bad param, pStats [%p] pContext [%p]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08006139 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006140 return;
6141 }
6142
Jeff Johnsondda167c2017-01-23 10:37:57 -08006143 request = hdd_request_get(context);
6144 if (!request) {
6145 hdd_err("Obsolete request");
6146 return;
6147 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006148
Jeff Johnsondda167c2017-01-23 10:37:57 -08006149 summary_stats = (tCsrSummaryStatsInfo *) stats;
6150 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306151 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08006152 (class_a_stats + 1);
6153 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006154
6155 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006156 priv->summary_stats = *summary_stats;
6157 priv->class_a_stats = *class_a_stats;
6158 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006159
Jeff Johnsondda167c2017-01-23 10:37:57 -08006160 hdd_request_complete(request);
6161 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006162}
6163
6164/**
6165 * wlan_hdd_get_station_stats() - Get station statistics
6166 * @pAdapter: adapter for which statistics are desired
6167 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306168 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306170QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006171{
6172 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306173 QDF_STATUS hstatus;
Jeff Johnsondda167c2017-01-23 10:37:57 -08006174 int ret;
6175 void *cookie;
6176 struct hdd_request *request;
6177 struct station_stats *priv;
6178 static const struct hdd_request_params params = {
6179 .priv_size = sizeof(*priv),
6180 .timeout_ms = WLAN_WAIT_TIME_STATS,
6181 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006182
6183 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006184 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306185 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 }
6187
Jeff Johnsondda167c2017-01-23 10:37:57 -08006188 request = hdd_request_alloc(&params);
6189 if (!request) {
6190 hdd_err("Request allocation failure");
6191 return QDF_STATUS_E_NOMEM;
6192 }
6193 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006194
6195 /* query only for Summary & Class A statistics */
6196 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
6197 eCSR_HDD,
6198 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306199 SME_GLOBAL_CLASSA_STATS |
6200 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006201 hdd_get_station_statistics_cb,
6202 0, /* not periodic */
6203 false, /* non-cached results */
6204 pHddStaCtx->conn_info.staId[0],
Jeff Johnsondda167c2017-01-23 10:37:57 -08006205 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306206 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006207 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006208 /* we'll return with cached values */
6209 } else {
6210 /* request was sent -- wait for the response */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006211 ret = hdd_request_wait_for_response(request);
6212 if (ret) {
6213 hdd_warn("SME timed out while retrieving statistics");
6214 /* we'll returned a cached value below */
6215 } else {
6216 /* update the adapter with the fresh results */
6217 priv = hdd_request_priv(request);
6218 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
6219 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6220 pAdapter->hdd_stats.per_chain_rssi_stats =
6221 priv->per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006222 }
6223 }
6224
Jeff Johnsondda167c2017-01-23 10:37:57 -08006225 /*
6226 * either we never sent a request, we sent a request and
6227 * received a response or we sent a request and timed out.
6228 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006229 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006230 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006231
6232 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306233 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006234}
6235
6236/**
6237 * iw_get_linkspeed() - Get current link speed ioctl
6238 * @dev: device upon which the ioctl was received
6239 * @info: ioctl request information
6240 * @wrqu: ioctl request data
6241 * @extra: extra ioctl buffer
6242 *
6243 * Return: 0 on success, non-zero on error
6244 */
6245static int __iw_get_linkspeed(struct net_device *dev,
6246 struct iw_request_info *info,
6247 union iwreq_data *wrqu, char *extra)
6248{
6249 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6250 char *pLinkSpeed = (char *)extra;
6251 int len = sizeof(uint32_t) + 1;
6252 uint32_t link_speed = 0;
6253 hdd_context_t *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08006254 int ret;
6255 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006256
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006257 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306258
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006259 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08006260 ret = wlan_hdd_validate_context(hdd_ctx);
6261 if (0 != ret)
6262 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006263
Jeff Johnson441e1f72017-02-07 08:50:49 -08006264 ret = hdd_check_private_wext_control(hdd_ctx, info);
6265 if (0 != ret)
6266 return ret;
6267
6268 ret = wlan_hdd_get_link_speed(pAdapter, &link_speed);
6269 if (0 != ret) {
6270 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006271 }
6272
6273 wrqu->data.length = len;
6274 /* return the linkspeed as a string */
6275 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
6276 if ((rc < 0) || (rc >= len)) {
6277 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07006278 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006279 return -EIO;
6280 }
6281
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306282 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006283 /* a value is being successfully returned */
6284 return 0;
6285}
6286
6287static int iw_get_linkspeed(struct net_device *dev,
6288 struct iw_request_info *info,
6289 union iwreq_data *wrqu, char *extra)
6290{
6291 int ret;
6292
6293 cds_ssr_protect(__func__);
6294 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
6295 cds_ssr_unprotect(__func__);
6296
6297 return ret;
6298}
6299
6300/**
6301 * wlan_hdd_change_country_code_callback() - Change country code callback
6302 * @context: opaque context originally passed to SME. All functions
6303 * which use this callback pass the adapter upon which the country
6304 * code change is active
6305 *
6306 * This function is registered as the callback function when
6307 * sme_change_country_code() is invoked. Callers of
6308 * sme_change_country_code() subsequently wait for the adapter's
6309 * @change_country_code completion variable, so all this function
6310 * needs to do is set that completion variable so that execution can
6311 * continue.
6312 *
6313 * Return: none
6314 */
6315void wlan_hdd_change_country_code_callback(void *context)
6316{
6317
6318 hdd_adapter_t *adapter = context;
6319
6320 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
6321 complete(&adapter->change_country_code);
6322
6323 return;
6324}
6325
6326/**
6327 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
6328 * @dev: device upon which the ioctl was received
6329 * @info: ioctl request information
6330 * @wrqu: ioctl request data
6331 * @extra: ioctl extra data
6332 *
6333 * Return: 0 on success, non-zero on error
6334 */
6335static int __iw_set_nick(struct net_device *dev,
6336 struct iw_request_info *info,
6337 union iwreq_data *wrqu, char *extra)
6338{
6339 hdd_adapter_t *adapter;
6340 hdd_context_t *hdd_ctx;
6341 int ret;
6342
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006343 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006344
6345 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6346 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6347 ret = wlan_hdd_validate_context(hdd_ctx);
6348 if (0 != ret)
6349 return ret;
6350
Jeff Johnson441e1f72017-02-07 08:50:49 -08006351 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6352 if (0 != ret)
6353 return ret;
6354
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006355 return 0;
6356}
6357
6358/**
6359 * iw_set_nick() - SSR wrapper for __iw_set_nick
6360 * @dev: pointer to net_device
6361 * @info: pointer to iw_request_info
6362 * @wrqu: pointer to iwreq_data
6363 * @extra: extra
6364 *
6365 * Return: 0 on success, error number otherwise
6366 */
6367static int iw_set_nick(struct net_device *dev,
6368 struct iw_request_info *info,
6369 union iwreq_data *wrqu, char *extra)
6370{
6371 int ret;
6372
6373 cds_ssr_protect(__func__);
6374 ret = __iw_set_nick(dev, info, wrqu, extra);
6375 cds_ssr_unprotect(__func__);
6376
6377 return ret;
6378}
6379
6380/**
6381 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
6382 * @dev: device upon which the ioctl was received
6383 * @info: ioctl request information
6384 * @wrqu: ioctl request data
6385 * @extra: ioctl extra data
6386 *
6387 * Return: 0 on success, non-zero on error
6388 */
6389static int __iw_get_nick(struct net_device *dev,
6390 struct iw_request_info *info,
6391 union iwreq_data *wrqu, char *extra)
6392{
6393 hdd_adapter_t *adapter;
6394 hdd_context_t *hdd_ctx;
6395 int ret;
6396
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006397 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006398
6399 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6400 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6401 ret = wlan_hdd_validate_context(hdd_ctx);
6402 if (0 != ret)
6403 return ret;
6404
Jeff Johnson441e1f72017-02-07 08:50:49 -08006405 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6406 if (0 != ret)
6407 return ret;
6408
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006409 return 0;
6410}
6411
6412/**
6413 * iw_get_nick() - SSR wrapper for __iw_get_nick
6414 * @dev: pointer to net_device
6415 * @info: pointer to iw_request_info
6416 * @wrqu: pointer to iwreq_data
6417 * @extra: extra
6418 *
6419 * Return: 0 on success, error number otherwise
6420 */
6421static int iw_get_nick(struct net_device *dev,
6422 struct iw_request_info *info,
6423 union iwreq_data *wrqu, char *extra)
6424{
6425 int ret;
6426
6427 cds_ssr_protect(__func__);
6428 ret = __iw_get_nick(dev, info, wrqu, extra);
6429 cds_ssr_unprotect(__func__);
6430
6431 return ret;
6432}
6433
6434/**
6435 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
6436 * @dev: device upon which the ioctl was received
6437 * @info: ioctl request information
6438 * @wrqu: ioctl request data
6439 * @extra: ioctl extra data
6440 *
6441 * Return: 0 on success, non-zero on error
6442 */
6443static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6444 union iwreq_data *wrqu, char *extra)
6445{
6446 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6447 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6448 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6449 hdd_context_t *hdd_ctx;
6450 struct iw_point *encoderq = &(wrqu->encoding);
6451 uint32_t keyId;
6452 uint8_t key_length;
6453 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6454 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306455 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006456 int ret;
6457
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006458 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006459
6460 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6461 ret = wlan_hdd_validate_context(hdd_ctx);
6462 if (0 != ret)
6463 return ret;
6464
Jeff Johnson441e1f72017-02-07 08:50:49 -08006465 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6466 if (0 != ret)
6467 return ret;
6468
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006469 keyId = encoderq->flags & IW_ENCODE_INDEX;
6470
6471 if (keyId) {
6472 if (keyId > MAX_WEP_KEYS) {
6473 return -EINVAL;
6474 }
6475
6476 fKeyPresent = 1;
6477 keyId--;
6478 } else {
6479 fKeyPresent = 0;
6480 }
6481
6482 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006483 hdd_debug("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006484 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006485 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
6486 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006487 }
6488 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6489 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6490 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6491 eCSR_ENCRYPT_TYPE_NONE;
6492 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6493 eCSR_ENCRYPT_TYPE_NONE;
6494
6495 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6496 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6497
6498 if (eConnectionState_Associated ==
6499 pHddStaCtx->conn_info.connState) {
6500 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6501 status =
6502 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
6503 pAdapter->sessionId,
6504 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306505 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006506 unsigned long rc;
6507 rc = wait_for_completion_timeout(&pAdapter->
6508 disconnect_comp_var,
6509 msecs_to_jiffies
6510 (WLAN_WAIT_TIME_DISCONNECT));
6511 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07006512 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006513 }
6514 }
6515
6516 return status;
6517
6518 }
6519
6520 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006521 hdd_debug("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006522
6523 pHddStaCtx->conn_info.authType =
6524 (encoderq->
6525 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
6526 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6527
6528 }
6529
6530 if (wrqu->data.length > 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006531 hdd_debug("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006532
6533 key_length = wrqu->data.length;
6534
6535 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
6536
6537 if (5 == key_length) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006538 hdd_debug("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006539 key_length);
6540
6541 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6542 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6543 pHddStaCtx->conn_info.authType)) {
6544 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
6545 } else {
6546 encryptionType =
6547 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6548 }
6549 } else if (13 == key_length) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006550 hdd_debug("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006551 key_length);
6552
6553 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6554 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6555 pHddStaCtx->conn_info.authType)) {
6556 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
6557 } else {
6558 encryptionType =
6559 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6560 }
6561 } else {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006562 hdd_err("Invalid WEP key length :%d", key_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006563 return -EINVAL;
6564 }
6565
6566 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6567 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
6568 pWextState->roamProfile.EncryptionType.numEntries = 1;
6569 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6570 encryptionType;
6571 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
6572 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6573 encryptionType;
6574
6575 if ((eConnectionState_NotConnected ==
6576 pHddStaCtx->conn_info.connState)
6577 &&
6578 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6579 pHddStaCtx->conn_info.authType)
6580 || (eCSR_AUTH_TYPE_SHARED_KEY ==
6581 pHddStaCtx->conn_info.authType))) {
6582
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306583 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006584 KeyMaterial[keyId][0], extra, key_length);
6585
6586 pWextState->roamProfile.Keys.KeyLength[keyId] =
6587 (uint8_t) key_length;
6588 pWextState->roamProfile.Keys.defaultIndex =
6589 (uint8_t) keyId;
6590
6591 return status;
6592 }
6593 }
6594
6595 return 0;
6596}
6597
6598/**
6599 * iw_set_encode() - SSR wrapper for __iw_set_encode()
6600 * @dev: pointer to net_device
6601 * @info: pointer to iw_request_info
6602 * @wrqu: pointer to iwreq_data
6603 * @extra: pointer to extra ioctl payload
6604 *
6605 * Return: 0 on success, error number otherwise
6606 */
6607static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6608 union iwreq_data *wrqu, char *extra)
6609{
6610 int ret;
6611
6612 cds_ssr_protect(__func__);
6613 ret = __iw_set_encode(dev, info, wrqu, extra);
6614 cds_ssr_unprotect(__func__);
6615
6616 return ret;
6617}
6618
6619/**
6620 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
6621 * @dev: device upon which the ioctl was received
6622 * @info: ioctl request information
6623 * @wrqu: ioctl request data
6624 * @extra: ioctl extra data
6625 *
6626 * Return: 0 on success, non-zero on error
6627 */
6628static int __iw_get_encodeext(struct net_device *dev,
6629 struct iw_request_info *info,
6630 struct iw_point *dwrq, char *extra)
6631{
6632 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6633 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6634 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
6635 int keyId;
6636 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6637 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
6638 int i, ret;
6639 hdd_context_t *hdd_ctx;
6640
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006641 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006642
6643 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6644 ret = wlan_hdd_validate_context(hdd_ctx);
6645 if (0 != ret)
6646 return ret;
6647
Jeff Johnson441e1f72017-02-07 08:50:49 -08006648 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6649 if (0 != ret)
6650 return ret;
6651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006652 keyId = pRoamProfile->Keys.defaultIndex;
6653
6654 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006655 hdd_err("Invalid keyId: %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006656 return -EINVAL;
6657 }
6658
6659 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
6660 dwrq->flags |= IW_ENCODE_ENABLED;
6661 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306662 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006663 pRoamProfile->Keys.KeyLength[keyId]);
6664 } else {
6665 dwrq->flags |= IW_ENCODE_DISABLED;
6666 }
6667
6668 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006669 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006670 continue;
6671 } else {
6672 break;
6673 }
6674 }
6675
6676 if (MAX_WEP_KEYS == i) {
6677 dwrq->flags |= IW_ENCODE_NOKEY;
6678 } else {
6679 dwrq->flags |= IW_ENCODE_ENABLED;
6680 }
6681
6682 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
6683
6684 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
6685 dwrq->flags |= IW_ENCODE_DISABLED;
6686 }
6687
6688 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
6689
6690 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
6691 dwrq->flags |= IW_ENCODE_OPEN;
6692 } else {
6693 dwrq->flags |= IW_ENCODE_RESTRICTED;
6694 }
6695 EXIT();
6696 return 0;
6697
6698}
6699
6700/**
6701 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
6702 * @dev: pointer to net_device
6703 * @info: pointer to iw_request_info
6704 * @dwrq: pointer to encoding information
6705 * @extra: pointer to extra ioctl payload
6706 *
6707 * Return: 0 on success, error number otherwise
6708 */
6709static int iw_get_encodeext(struct net_device *dev,
6710 struct iw_request_info *info,
6711 struct iw_point *dwrq, char *extra)
6712{
6713 int ret;
6714
6715 cds_ssr_protect(__func__);
6716 ret = __iw_get_encodeext(dev, info, dwrq, extra);
6717 cds_ssr_unprotect(__func__);
6718
6719 return ret;
6720}
6721
6722/**
6723 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
6724 * @dev: device upon which the ioctl was received
6725 * @info: ioctl request information
6726 * @wrqu: ioctl request data
6727 * @extra: ioctl extra data
6728 *
6729 * Return: 0 on success, non-zero on error
6730 */
6731static int __iw_set_encodeext(struct net_device *dev,
6732 struct iw_request_info *info,
6733 union iwreq_data *wrqu, char *extra)
6734{
6735 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6736 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6737 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6738 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306739 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006740 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6741 int ret;
6742 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6743 int key_index;
6744 struct iw_point *encoding = &wrqu->encoding;
6745 tCsrRoamSetKey setKey;
6746 uint32_t roamId = 0xFF;
6747
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006748 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006749
6750 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6751 ret = wlan_hdd_validate_context(hdd_ctx);
6752 if (0 != ret)
6753 return ret;
6754
Jeff Johnson441e1f72017-02-07 08:50:49 -08006755 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6756 if (0 != ret)
6757 return ret;
6758
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006759 key_index = encoding->flags & IW_ENCODE_INDEX;
6760
6761 if (key_index > 0) {
6762
6763 /*Convert from 1-based to 0-based keying */
6764 key_index--;
6765 }
6766 if (!ext->key_len) {
6767
6768 /*Set the encrytion type to NONE */
6769 pRoamProfile->EncryptionType.encryptionType[0] =
6770 eCSR_ENCRYPT_TYPE_NONE;
6771 return ret;
6772 }
6773
6774 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
6775 (IW_ENCODE_ALG_WEP == ext->alg)) {
6776 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
6777
Jeff Johnson99bac312016-06-28 10:38:18 -07006778 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006779 return -EINVAL;
Jeff Johnson68755312017-02-10 11:46:55 -08006780 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006781
Jeff Johnson68755312017-02-10 11:46:55 -08006782 /*Static wep, update the roam profile with the keys */
6783 if (ext->key_len &&
6784 (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
6785 key_index < CSR_MAX_NUM_KEY) {
6786 qdf_mem_copy(&pRoamProfile->Keys.
6787 KeyMaterial[key_index][0],
6788 ext->key, ext->key_len);
6789 pRoamProfile->Keys.KeyLength[key_index] =
6790 (uint8_t) ext->key_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006791
Jeff Johnson68755312017-02-10 11:46:55 -08006792 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
6793 pRoamProfile->Keys.defaultIndex =
6794 (uint8_t) key_index;
6795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006796 }
6797 return ret;
6798 }
6799
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306800 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006801
6802 setKey.keyId = key_index;
6803 setKey.keyLength = ext->key_len;
6804
6805 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306806 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006807 }
6808
6809 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
6810 /*Key direction for group is RX only */
6811 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05306812 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006813 } else {
6814
6815 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306816 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306817 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006818 }
6819
6820 /*For supplicant pae role is zero */
6821 setKey.paeRole = 0;
6822
6823 switch (ext->alg) {
6824 case IW_ENCODE_ALG_NONE:
6825 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6826 break;
6827
6828 case IW_ENCODE_ALG_WEP:
6829 setKey.encType =
6830 (ext->key_len ==
6831 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
6832 break;
6833
6834 case IW_ENCODE_ALG_TKIP:
6835 {
6836 uint8_t *pKey = &setKey.Key[0];
6837
6838 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
6839
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306840 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006841
6842 /* Supplicant sends the 32bytes key in this order
6843 * |--------------|----------|----------|
6844 * | Tk1 | TX MIC | RX MIC |
6845 * |--------------|----------|----------|
6846 * <---16bytes---><--8bytes--><--8bytes-->
6847 *
6848 *
6849 * Sme expects the 32 bytes key to be in the below order
6850 * |--------------|----------|----------|
6851 * | Tk1 | RX MIC | TX MIC |
6852 * |--------------|----------|----------|
6853 * <---16bytes---><--8bytes--><--8bytes-->
6854 */
6855
6856 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306857 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006858
6859 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306860 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006861
6862 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306863 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006864
6865 }
6866 break;
6867
6868 case IW_ENCODE_ALG_CCMP:
6869 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
6870 break;
6871
6872#ifdef FEATURE_WLAN_ESE
6873#define IW_ENCODE_ALG_KRK 6
6874 case IW_ENCODE_ALG_KRK:
6875 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
6876 break;
6877#endif /* FEATURE_WLAN_ESE */
6878
6879 default:
6880 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6881 break;
6882 }
6883
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006884 hdd_debug("cipher_alg:%d key_len:%d EncryptionType:%d",
Jeff Johnson99bac312016-06-28 10:38:18 -07006885 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006886
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006887 /* The supplicant may attempt to set the PTK once
6888 * pre-authentication is done. Save the key in the UMAC and
6889 * include it in the ADD BSS request
6890 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306891 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006892 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306893 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006894 hdd_debug("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006895 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306896 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006897 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006898 return -EINVAL;
6899 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006900
6901 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6902
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306903 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006904 pAdapter->sessionId,
6905 &setKey, &roamId);
6906
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306907 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006908 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306909 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006910
6911 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6912 }
6913
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306914 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006915}
6916
6917/**
6918 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
6919 * @dev: pointer to net_device
6920 * @info: pointer to iw_request_info
6921 * @wrqu: pointer to iwreq_data
6922 * @extra: pointer to extra ioctl payload
6923 *
6924 * Return: 0 on success, error number otherwise
6925 */
6926static int iw_set_encodeext(struct net_device *dev,
6927 struct iw_request_info *info,
6928 union iwreq_data *wrqu, char *extra)
6929{
6930 int ret;
6931
6932 cds_ssr_protect(__func__);
6933 ret = __iw_set_encodeext(dev, info, wrqu, extra);
6934 cds_ssr_unprotect(__func__);
6935
6936 return ret;
6937}
6938
6939/**
6940 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
6941 * @dev: device upon which the ioctl was received
6942 * @info: ioctl request information
6943 * @wrqu: ioctl request data
6944 * @extra: ioctl extra data
6945 *
6946 * Return: 0 on success, non-zero on error
6947 */
6948static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
6949 union iwreq_data *wrqu, char *extra)
6950{
6951 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6952 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6953 hdd_context_t *hdd_ctx;
6954 int ret;
6955
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006956 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006957
6958 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6959 ret = wlan_hdd_validate_context(hdd_ctx);
6960 if (0 != ret)
6961 return ret;
6962
Jeff Johnson441e1f72017-02-07 08:50:49 -08006963 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6964 if (0 != ret)
6965 return ret;
6966
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006967 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
6968 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
6969
Jeff Johnson99bac312016-06-28 10:38:18 -07006970 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006971
6972 return -EINVAL;
6973 }
6974
6975 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
6976
6977 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
6978 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
6979 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306980 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006981 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006982 return -EIO;
6983 }
6984 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
6985 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6986 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306987 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05306988 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006989 return -EIO;
6990 }
6991 }
6992 } else {
6993 return -EOPNOTSUPP;
6994 }
6995
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006996 hdd_debug("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006997
6998 EXIT();
6999
7000 return 0;
7001
7002}
7003
7004/**
7005 * iw_set_retry() - SSR wrapper for __iw_set_retry()
7006 * @dev: pointer to net_device
7007 * @info: pointer to iw_request_info
7008 * @wrqu: pointer to iwreq_data
7009 * @extra: pointer to extra ioctl payload
7010 *
7011 * Return: 0 on success, error number otherwise
7012 */
7013static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
7014 union iwreq_data *wrqu, char *extra)
7015{
7016 int ret;
7017
7018 cds_ssr_protect(__func__);
7019 ret = __iw_set_retry(dev, info, wrqu, extra);
7020 cds_ssr_unprotect(__func__);
7021
7022 return ret;
7023}
7024
7025/**
7026 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
7027 * @dev: device upon which the ioctl was received
7028 * @info: ioctl request information
7029 * @wrqu: ioctl request data
7030 * @extra: ioctl extra data
7031 *
7032 * Return: 0 on success, non-zero on error
7033 */
7034static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7035 union iwreq_data *wrqu, char *extra)
7036{
7037 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7038 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7039 uint32_t retry = 0;
7040 hdd_context_t *hdd_ctx;
7041 int ret;
7042
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007043 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007044
7045 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7046 ret = wlan_hdd_validate_context(hdd_ctx);
7047 if (0 != ret)
7048 return ret;
7049
Jeff Johnson441e1f72017-02-07 08:50:49 -08007050 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7051 if (0 != ret)
7052 return ret;
7053
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007054 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
7055 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
7056
7057 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307058 QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007059 hdd_err("Failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007060 return -EIO;
7061 }
7062
7063 wrqu->retry.value = retry;
7064 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
7065 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
7066
7067 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307068 QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007069 hdd_err("Failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007070 return -EIO;
7071 }
7072
7073 wrqu->retry.value = retry;
7074 } else {
7075 return -EOPNOTSUPP;
7076 }
7077
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007078 hdd_debug("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007079
7080 EXIT();
7081
7082 return 0;
7083}
7084
7085/**
7086 * iw_get_retry() - SSR wrapper for __iw_get_retry()
7087 * @dev: pointer to net_device
7088 * @info: pointer to iw_request_info
7089 * @wrqu: pointer to iwreq_data
7090 * @extra: pointer to extra ioctl payload
7091 *
7092 * Return: 0 on success, error number otherwise
7093 */
7094static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7095 union iwreq_data *wrqu, char *extra)
7096{
7097 int ret;
7098
7099 cds_ssr_protect(__func__);
7100 ret = __iw_get_retry(dev, info, wrqu, extra);
7101 cds_ssr_unprotect(__func__);
7102
7103 return ret;
7104}
7105
7106/**
7107 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
7108 * @dev: device upon which the ioctl was received
7109 * @info: ioctl request information
7110 * @wrqu: ioctl request data
7111 * @extra: ioctl extra data
7112 *
7113 * Return: 0 on success, non-zero on error
7114 */
7115static int __iw_set_mlme(struct net_device *dev,
7116 struct iw_request_info *info,
7117 union iwreq_data *wrqu, char *extra)
7118{
7119 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7120 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7121 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307122 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007123 hdd_context_t *hdd_ctx;
7124 int ret;
7125
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007126 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007127
7128 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7129 ret = wlan_hdd_validate_context(hdd_ctx);
7130 if (0 != ret)
7131 return ret;
7132
Jeff Johnson441e1f72017-02-07 08:50:49 -08007133 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7134 if (0 != ret)
7135 return ret;
7136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007137 /* reason_code is unused. By default it is set to
7138 * eCSR_DISCONNECT_REASON_UNSPECIFIED
7139 */
7140 switch (mlme->cmd) {
7141 case IW_MLME_DISASSOC:
7142 case IW_MLME_DEAUTH:
7143
7144 if (pHddStaCtx->conn_info.connState ==
7145 eConnectionState_Associated) {
7146 eCsrRoamDisconnectReason reason =
7147 eCSR_DISCONNECT_REASON_UNSPECIFIED;
7148
7149 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
7150 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
7151
7152 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7153 status =
7154 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
7155 pAdapter->sessionId, reason);
7156
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307157 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007158 unsigned long rc;
7159 rc = wait_for_completion_timeout(&pAdapter->
7160 disconnect_comp_var,
7161 msecs_to_jiffies
7162 (WLAN_WAIT_TIME_DISCONNECT));
7163 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07007164 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007165 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07007166 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
7167 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007168
7169 /* Resetting authKeyMgmt */
7170 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
7171 0;
7172
Jeff Johnson99bac312016-06-28 10:38:18 -07007173 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007174 wlan_hdd_netif_queue_control(pAdapter,
7175 WLAN_NETIF_TX_DISABLE_N_CARRIER,
7176 WLAN_CONTROL_PATH);
7177
7178 } else {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007179 hdd_warn("%d Command Disassociate/Deauthenticate called but station is not in associated state",
Jeff Johnson99bac312016-06-28 10:38:18 -07007180 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007181 }
7182 break;
7183 default:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007184 hdd_err("Unexpected cmd: %d", (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007185 return -EINVAL;
7186 } /* end of switch */
7187
7188 EXIT();
7189
7190 return status;
7191
7192}
7193
7194/**
7195 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
7196 * @dev: pointer to net_device
7197 * @info: pointer to iw_request_info
7198 * @wrqu: pointer to iwreq_data
7199 * @extra: pointer to extra ioctl payload
7200 *
7201 * Return: 0 on success, error number otherwise
7202 */
7203static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
7204 union iwreq_data *wrqu, char *extra)
7205{
7206 int ret;
7207
7208 cds_ssr_protect(__func__);
7209 ret = __iw_set_mlme(dev, info, wrqu, extra);
7210 cds_ssr_unprotect(__func__);
7211
7212 return ret;
7213}
7214
7215/**
7216 * wlan_hdd_update_phymode() - handle change in PHY mode
7217 * @net: device upon which PHY mode change was received
7218 * @hal: umac handle for the driver
7219 * @new_phymode: new PHY mode for the device
7220 * @phddctx: pointer to the HDD context
7221 *
7222 * This function is called when the device is set to a new PHY mode.
7223 * It takes a holistic look at the desired PHY mode along with the
7224 * configured capabilities of the driver and the reported capabilities
7225 * of the hardware in order to correctly configure all PHY-related
7226 * parameters.
7227 *
7228 * Return: 0 on success, negative errno value on error
7229 */
7230int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
7231 int new_phymode, hdd_context_t *phddctx)
7232{
7233#ifdef QCA_HT_2040_COEX
7234 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307235 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007236#endif
7237 bool band_24 = false, band_5g = false;
7238 bool ch_bond24 = false, ch_bond5g = false;
7239 tSmeConfigParams smeconfig;
7240 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007241 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007242 eCsrPhyMode phymode = -EIO, old_phymode;
7243 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
7244 eCsrBand curr_band = eCSR_BAND_ALL;
7245
7246 old_phymode = sme_get_phy_mode(hal);
7247
7248 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7249 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7250 nChannelBondingMode24GHz))
7251 ch_bond24 = true;
7252
7253 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7254 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7255 nChannelBondingMode5GHz))
7256 ch_bond5g = true;
7257
7258 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
7259 band_24 = band_5g = true;
7260 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
7261 band_24 = true;
7262 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
7263 band_5g = true;
7264 }
7265
7266 vhtchanwidth = phddctx->config->vhtChannelWidth;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007267 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 -08007268 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
7269
7270 switch (new_phymode) {
7271 case IEEE80211_MODE_AUTO:
7272 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7273 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
7274 phymode = eCSR_DOT11_MODE_AUTO;
7275 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7276 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7277 curr_band = eCSR_BAND_ALL;
7278 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7279 } else {
7280 sme_set_phy_mode(hal, old_phymode);
7281 return -EIO;
7282 }
7283 break;
7284 case IEEE80211_MODE_11A:
7285 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
7286 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7287 phymode = eCSR_DOT11_MODE_11a;
7288 hdd_dot11mode = eHDD_DOT11_MODE_11a;
7289 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7290 curr_band = eCSR_BAND_5G;
7291 } else {
7292 sme_set_phy_mode(hal, old_phymode);
7293 return -EIO;
7294 }
7295 break;
7296 case IEEE80211_MODE_11B:
7297 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
7298 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7299 phymode = eCSR_DOT11_MODE_11b;
7300 hdd_dot11mode = eHDD_DOT11_MODE_11b;
7301 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7302 curr_band = eCSR_BAND_24;
7303 } else {
7304 sme_set_phy_mode(hal, old_phymode);
7305 return -EIO;
7306 }
7307 break;
7308 case IEEE80211_MODE_11G:
7309 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
7310 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7311 phymode = eCSR_DOT11_MODE_11g;
7312 hdd_dot11mode = eHDD_DOT11_MODE_11g;
7313 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7314 curr_band = eCSR_BAND_24;
7315 } else {
7316 sme_set_phy_mode(hal, old_phymode);
7317 return -EIO;
7318 }
7319 break;
7320 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
7321 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
7322 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
7323 */
7324 case IEEE80211_MODE_11NA_HT20:
7325 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7326 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7327 phymode = eCSR_DOT11_MODE_11n;
7328 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7329 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7330 curr_band = eCSR_BAND_5G;
7331 } else {
7332 sme_set_phy_mode(hal, old_phymode);
7333 return -EIO;
7334 }
7335 break;
7336 case IEEE80211_MODE_11NA_HT40:
7337 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7338 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7339 phymode = eCSR_DOT11_MODE_11n;
7340 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7341 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7342 curr_band = eCSR_BAND_5G;
7343 } else {
7344 sme_set_phy_mode(hal, old_phymode);
7345 return -EIO;
7346 }
7347 break;
7348 case IEEE80211_MODE_11NG_HT20:
7349 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7350 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7351 phymode = eCSR_DOT11_MODE_11n;
7352 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7353 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7354 curr_band = eCSR_BAND_24;
7355 } else {
7356 sme_set_phy_mode(hal, old_phymode);
7357 return -EIO;
7358 }
7359 break;
7360 case IEEE80211_MODE_11NG_HT40:
7361 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7362 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7363 phymode = eCSR_DOT11_MODE_11n;
7364 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7365 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7366 curr_band = eCSR_BAND_24;
7367 } else {
7368 sme_set_phy_mode(hal, old_phymode);
7369 return -EIO;
7370 }
7371 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007372 case IEEE80211_MODE_11AC_VHT20:
7373 case IEEE80211_MODE_11AC_VHT40:
7374 case IEEE80211_MODE_11AC_VHT80:
7375 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
7376 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7377 phymode = eCSR_DOT11_MODE_11ac;
7378 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
7379 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7380 curr_band = eCSR_BAND_5G;
7381 } else {
7382 sme_set_phy_mode(hal, old_phymode);
7383 return -EIO;
7384 }
7385 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007386 case IEEE80211_MODE_2G_AUTO:
7387 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7388 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7389 phymode = eCSR_DOT11_MODE_AUTO;
7390 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7391 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7392 curr_band = eCSR_BAND_24;
7393 } else {
7394 sme_set_phy_mode(hal, old_phymode);
7395 return -EIO;
7396 }
7397 break;
7398 case IEEE80211_MODE_5G_AUTO:
7399 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7400 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7401 phymode = eCSR_DOT11_MODE_AUTO;
7402 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7403 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7404 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7405 curr_band = eCSR_BAND_5G;
7406 } else {
7407 sme_set_phy_mode(hal, old_phymode);
7408 return -EIO;
7409 }
7410 break;
7411 case IEEE80211_MODE_11AGN:
7412 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7413 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
7414 phymode = eCSR_DOT11_MODE_11n;
7415 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7416 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7417 curr_band = eCSR_BAND_ALL;
7418 } else {
7419 sme_set_phy_mode(hal, old_phymode);
7420 return -EIO;
7421 }
7422 break;
7423 default:
7424 return -EIO;
7425 }
7426
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007427 switch (new_phymode) {
7428 case IEEE80211_MODE_11AC_VHT20:
7429 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7430 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
7431 break;
7432 case IEEE80211_MODE_11AC_VHT40:
7433 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
7434 break;
7435 case IEEE80211_MODE_11AC_VHT80:
7436 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7437 break;
7438 default:
7439 vhtchanwidth = phddctx->config->vhtChannelWidth;
7440 break;
7441 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007442
7443 if (phymode != -EIO) {
7444 sme_get_config_param(hal, &smeconfig);
7445 smeconfig.csrConfig.phyMode = phymode;
7446#ifdef QCA_HT_2040_COEX
7447 if (phymode == eCSR_DOT11_MODE_11n &&
7448 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
7449 smeconfig.csrConfig.obssEnabled = false;
7450 halStatus = sme_set_ht2040_mode(hal,
7451 pAdapter->sessionId,
7452 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307453 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007454 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007455 return -EIO;
7456 }
7457 } else if (phymode == eCSR_DOT11_MODE_11n &&
7458 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
7459 smeconfig.csrConfig.obssEnabled = true;
7460 halStatus = sme_set_ht2040_mode(hal,
7461 pAdapter->sessionId,
7462 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307463 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007464 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007465 return -EIO;
7466 }
7467 }
7468#endif
7469 smeconfig.csrConfig.eBand = curr_band;
7470 smeconfig.csrConfig.bandCapability = curr_band;
7471 if (curr_band == eCSR_BAND_24)
7472 smeconfig.csrConfig.Is11hSupportEnabled = 0;
7473 else
7474 smeconfig.csrConfig.Is11hSupportEnabled =
7475 phddctx->config->Is11hSupportEnabled;
7476 if (curr_band == eCSR_BAND_24)
7477 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7478 else if (curr_band == eCSR_BAND_24)
7479 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7480 else {
7481 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7482 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7483 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007484 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007485 sme_update_config(hal, &smeconfig);
7486
7487 phddctx->config->dot11Mode = hdd_dot11mode;
7488 phddctx->config->nBandCapability = curr_band;
7489 phddctx->config->nChannelBondingMode24GHz =
7490 smeconfig.csrConfig.channelBondingMode24GHz;
7491 phddctx->config->nChannelBondingMode5GHz =
7492 smeconfig.csrConfig.channelBondingMode5GHz;
7493 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07007494 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007495 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007496 return -EIO;
7497 }
7498 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07007499 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007500 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7501 else
Dustin Browna30892e2016-10-12 17:28:36 -07007502 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007503 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7504
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007505 hdd_debug("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007506 phymode, chwidth, curr_band, vhtchanwidth);
7507 }
7508
7509 return 0;
7510}
7511
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007512struct temperature_priv {
7513 int temperature;
7514};
7515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007516/**
7517 * hdd_get_temperature_cb() - "Get Temperature" callback function
7518 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007519 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007520 *
7521 * This function is passed to sme_get_temperature() as the callback
7522 * function to be invoked when the temperature measurement is
7523 * available.
7524 *
7525 * Return: None
7526 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007527static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007528{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007529 struct hdd_request *request;
7530 struct temperature_priv *priv;
7531
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007532 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007533
7534 request = hdd_request_get(context);
7535 if (!request) {
7536 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007537 return;
7538 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007539
7540 priv = hdd_request_priv(request);
7541 priv->temperature = temperature;
7542 hdd_request_complete(request);
7543 hdd_request_put(request);
7544
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007545 EXIT();
7546}
7547
7548/**
7549 * wlan_hdd_get_temperature() - get current device temperature
7550 * @pAdapter: device upon which the request was made
7551 * @temperature: pointer to where the temperature is to be returned
7552 *
7553 * Return: 0 if a temperature value (either current or cached) was
7554 * returned, otherwise a negative errno is returned.
7555 *
7556 */
7557int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
7558{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307559 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007560 int ret;
7561 void *cookie;
7562 struct hdd_request *request;
7563 struct temperature_priv *priv;
7564 static const struct hdd_request_params params = {
7565 .priv_size = sizeof(*priv),
7566 .timeout_ms = WLAN_WAIT_TIME_STATS,
7567 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007568
7569 ENTER();
7570 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007571 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007572 return -EPERM;
7573 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007574
7575 request = hdd_request_alloc(&params);
7576 if (!request) {
7577 hdd_err("Request allocation failure");
7578 return -ENOMEM;
7579 }
7580 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007581 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007582 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307583 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007584 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007585 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007586 ret = hdd_request_wait_for_response(request);
7587 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007588 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007589 } else {
7590 /* update the adapter with the fresh results */
7591 priv = hdd_request_priv(request);
7592 if (priv->temperature)
7593 pAdapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007594 }
7595 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007596
7597 /*
7598 * either we never sent a request, we sent a request and
7599 * received a response or we sent a request and timed out.
7600 * regardless we are done with the request.
7601 */
7602 hdd_request_put(request);
7603
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007604 *temperature = pAdapter->temperature;
7605 EXIT();
7606 return 0;
7607}
7608
7609/**
7610 * iw_setint_getnone() - Generic "set integer" private ioctl handler
7611 * @dev: device upon which the ioctl was received
7612 * @info: ioctl request information
7613 * @wrqu: ioctl request data
7614 * @extra: ioctl extra data
7615 *
7616 * Return: 0 on success, non-zero on error
7617 */
7618static int __iw_setint_getnone(struct net_device *dev,
7619 struct iw_request_info *info,
7620 union iwreq_data *wrqu, char *extra)
7621{
7622 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7623 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7624 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007625 hdd_context_t *hdd_ctx;
7626 tSmeConfigParams smeConfig;
7627 int *value = (int *)extra;
7628 int sub_cmd = value[0];
7629 int set_value = value[1];
7630 int ret;
7631 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307632 QDF_STATUS status;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08007633 void *soc = NULL;
7634 struct ol_txrx_stats_req req;
7635 struct cdp_pdev *pdev = NULL;
7636 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007637
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007638 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007640 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7641 ret = wlan_hdd_validate_context(hdd_ctx);
7642 if (0 != ret)
7643 return ret;
7644
Jeff Johnson441e1f72017-02-07 08:50:49 -08007645 ret = hdd_check_private_wext_control(hdd_ctx, info);
7646 if (0 != ret)
7647 return ret;
7648
Jeff Johnson441e1f72017-02-07 08:50:49 -08007649 memset(&smeConfig, 0x00, sizeof(smeConfig));
7650
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007651 switch (sub_cmd) {
7652 case WE_SET_11D_STATE:
7653 {
7654 if ((ENABLE_11D == set_value)
7655 || (DISABLE_11D == set_value)) {
7656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007657 sme_get_config_param(hHal, &smeConfig);
7658 smeConfig.csrConfig.Is11dSupportEnabled =
7659 (bool) set_value;
7660
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007661 hdd_debug("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007662 smeConfig.csrConfig.
7663 Is11dSupportEnabled);
7664
7665 sme_update_config(hHal, &smeConfig);
7666 } else {
7667 return -EINVAL;
7668 }
7669 break;
7670 }
7671
7672 case WE_WOWL:
7673 {
7674 switch (set_value) {
7675 case 0x00:
7676 hdd_exit_wowl(pAdapter);
7677 break;
7678 case 0x01:
7679 case 0x02:
7680 case 0x03:
7681 enable_mp = (set_value & 0x01) ? 1 : 0;
7682 enable_pbm = (set_value & 0x02) ? 1 : 0;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007683 hdd_debug("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007684 (enable_mp ? "YES" : "NO"),
7685 (enable_pbm ? "YES" : "NO"));
7686 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
7687 break;
7688 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007689 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007690 set_value);
7691 ret = -EINVAL;
7692 break;
7693 }
7694
7695 break;
7696 }
7697 case WE_SET_POWER:
7698 {
7699 switch (set_value) {
7700 case 1:
7701 /* Enable PowerSave */
7702 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7703 SME_PS_ENABLE);
7704 break;
7705 case 2:
7706 /* Disable PowerSave */
7707 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7708 SME_PS_DISABLE);
7709 break;
7710 case 3: /* Enable UASPD */
7711 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
7712 break;
7713 case 4: /* Disable UASPD */
7714 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
7715 break;
7716 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007717 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007718 set_value);
7719 ret = -EINVAL;
7720 break;
7721 }
7722 break;
7723 }
7724
7725 case WE_SET_MAX_ASSOC:
7726 {
7727 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
7728 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
7729 ret = -EINVAL;
7730 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
7731 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307732 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007733 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007734 ret = -EIO;
7735 }
7736 break;
7737 }
7738
7739 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
7740 if (set_value == 0 || set_value == 1)
7741 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
7742 set_value;
7743 else
7744 ret = -EINVAL;
7745 break;
7746
7747 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007748 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
7749 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
7750 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7751 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307752 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007753 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007754 ret = -EINVAL;
7755 }
7756 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007757 case WE_SET_MC_RATE:
7758 {
7759 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
7760 break;
7761 }
7762 case WE_SET_TX_POWER:
7763 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307764 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007765
Anurag Chouhanc5548422016-02-24 18:33:27 +05307766 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007767 if (sme_set_tx_power
7768 (hHal, pAdapter->sessionId, bssid,
7769 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307770 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007771 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007772 return -EIO;
7773 }
7774 break;
7775 }
7776 case WE_SET_MAX_TX_POWER:
7777 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307778 struct qdf_mac_addr bssid;
7779 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007780
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007781
7782 hdd_debug("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007783 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05307784 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
7785 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007786
7787 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307788 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007789 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007790 return -EIO;
7791 }
7792
7793 break;
7794 }
7795 case WE_SET_MAX_TX_POWER_2_4:
7796 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007797 hdd_debug("Setting maximum tx power %d dBm for 2.4 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07007798 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007799 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307800 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007801 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007802 return -EIO;
7803 }
7804
7805 break;
7806 }
7807 case WE_SET_MAX_TX_POWER_5_0:
7808 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007809 hdd_debug("Setting maximum tx power %d dBm for 5.0 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07007810 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007811 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307812 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007813 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007814 return -EIO;
7815 }
7816
7817 break;
7818 }
7819 case WE_SET_HIGHER_DTIM_TRANSITION:
7820 {
7821 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007822 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007823 set_value);
7824 ret = -EINVAL;
7825 } else {
7826 if (pAdapter->higherDtimTransition != set_value) {
7827 pAdapter->higherDtimTransition =
7828 set_value;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007829 hdd_debug("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007830 pAdapter->higherDtimTransition);
7831 }
7832 }
7833
7834 break;
7835 }
7836
7837 case WE_SET_TM_LEVEL:
7838 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007839 hdd_debug("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007840 (void)sme_set_thermal_level(hHal, set_value);
7841 break;
7842 }
7843
7844 case WE_SET_PHYMODE:
7845 {
7846 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
7847
7848 ret =
7849 wlan_hdd_update_phymode(dev, hHal, set_value,
7850 phddctx);
7851 break;
7852 }
7853
7854 case WE_SET_NSS:
7855 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007856 hdd_debug("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007857 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007858 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007859 ret = -EINVAL;
7860 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307861 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007862 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
7863 set_value))
7864 ret = -EINVAL;
7865 }
7866 break;
7867 }
7868
7869 case WE_SET_GTX_HT_MCS:
7870 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007871 hdd_debug("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007872 ret = wma_cli_set_command(pAdapter->sessionId,
7873 WMI_VDEV_PARAM_GTX_HT_MCS,
7874 set_value, GTX_CMD);
7875 break;
7876 }
7877
7878 case WE_SET_GTX_VHT_MCS:
7879 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007880 hdd_debug("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007881 set_value);
7882 ret = wma_cli_set_command(pAdapter->sessionId,
7883 WMI_VDEV_PARAM_GTX_VHT_MCS,
7884 set_value, GTX_CMD);
7885 break;
7886 }
7887
7888 case WE_SET_GTX_USRCFG:
7889 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007890 hdd_debug("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007891 set_value);
7892 ret = wma_cli_set_command(pAdapter->sessionId,
7893 WMI_VDEV_PARAM_GTX_USR_CFG,
7894 set_value, GTX_CMD);
7895 break;
7896 }
7897
7898 case WE_SET_GTX_THRE:
7899 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007900 hdd_debug("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007901 ret = wma_cli_set_command(pAdapter->sessionId,
7902 WMI_VDEV_PARAM_GTX_THRE,
7903 set_value, GTX_CMD);
7904 break;
7905 }
7906
7907 case WE_SET_GTX_MARGIN:
7908 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007909 hdd_debug("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007910 ret = wma_cli_set_command(pAdapter->sessionId,
7911 WMI_VDEV_PARAM_GTX_MARGIN,
7912 set_value, GTX_CMD);
7913 break;
7914 }
7915
7916 case WE_SET_GTX_STEP:
7917 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007918 hdd_debug("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007919 ret = wma_cli_set_command(pAdapter->sessionId,
7920 WMI_VDEV_PARAM_GTX_STEP,
7921 set_value, GTX_CMD);
7922 break;
7923 }
7924
7925 case WE_SET_GTX_MINTPC:
7926 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007927 hdd_debug("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007928 ret = wma_cli_set_command(pAdapter->sessionId,
7929 WMI_VDEV_PARAM_GTX_MINTPC,
7930 set_value, GTX_CMD);
7931 break;
7932 }
7933
7934 case WE_SET_GTX_BWMASK:
7935 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007936 hdd_debug("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007937 ret = wma_cli_set_command(pAdapter->sessionId,
7938 WMI_VDEV_PARAM_GTX_BW_MASK,
7939 set_value, GTX_CMD);
7940 break;
7941 }
7942
7943 case WE_SET_LDPC:
7944 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307945 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007946 break;
7947 }
7948
7949 case WE_SET_TX_STBC:
7950 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307951 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007952 break;
7953 }
7954
7955 case WE_SET_RX_STBC:
7956 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307957 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007958 break;
7959 }
7960
7961 case WE_SET_SHORT_GI:
7962 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007963 hdd_debug("WMI_VDEV_PARAM_SGI val %d", set_value);
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08007964 /*
7965 * wma_cli_set_command should be called instead of
7966 * sme_update_ht_config since SGI is used for HT/HE.
7967 * This should be refactored.
7968 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007969 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
7970 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
7971 set_value);
7972 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07007973 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007974 break;
7975 }
7976
7977 case WE_SET_RTSCTS:
7978 {
7979 uint32_t value;
7980
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007981 hdd_debug("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007982 set_value);
7983
7984 if ((set_value & HDD_RTSCTS_EN_MASK) ==
7985 HDD_RTSCTS_ENABLE)
7986 value =
7987 (WLAN_HDD_GET_CTX(pAdapter))->config->
7988 RTSThreshold;
7989 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
7990 || ((set_value & HDD_RTSCTS_EN_MASK) ==
7991 HDD_CTS_ENABLE))
7992 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
7993 else
7994 return -EIO;
7995
7996 ret = wma_cli_set_command(pAdapter->sessionId,
7997 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7998 set_value, VDEV_CMD);
7999 if (!ret) {
8000 if (sme_cfg_set_int
8001 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308002 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008003 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008004 return -EIO;
8005 }
8006 }
8007
8008 break;
8009 }
8010
8011 case WE_SET_CHWIDTH:
8012 {
8013 bool chwidth = false;
8014 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
8015 /*updating channel bonding only on 5Ghz */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008016 hdd_debug("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008017 set_value);
8018 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008019 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008020 return -EINVAL;
8021 }
8022
8023 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
8024 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
8025 nChannelBondingMode5GHz)))
8026 chwidth = true;
8027
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008028 sme_get_config_param(hHal, &smeConfig);
8029 switch (set_value) {
8030 case eHT_CHANNEL_WIDTH_20MHZ:
8031 smeConfig.csrConfig.channelBondingMode5GHz =
8032 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
8033 break;
8034 case eHT_CHANNEL_WIDTH_40MHZ:
8035 if (chwidth)
8036 smeConfig.csrConfig.
8037 channelBondingMode5GHz =
8038 phddctx->config->
8039 nChannelBondingMode5GHz;
8040 else
8041 return -EINVAL;
8042
8043 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008044 case eHT_CHANNEL_WIDTH_80MHZ:
8045 if (chwidth)
8046 smeConfig.csrConfig.
8047 channelBondingMode5GHz =
8048 phddctx->config->
8049 nChannelBondingMode5GHz;
8050 else
8051 return -EINVAL;
8052
8053 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008054
8055 default:
8056 return -EINVAL;
8057 }
8058
8059 ret = wma_cli_set_command(pAdapter->sessionId,
8060 WMI_VDEV_PARAM_CHWIDTH,
8061 set_value, VDEV_CMD);
8062 if (!ret)
8063 sme_update_config(hHal, &smeConfig);
8064
8065 break;
8066 }
8067
8068 case WE_SET_ANI_EN_DIS:
8069 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008070 hdd_debug("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008071 set_value);
8072 ret = wma_cli_set_command(pAdapter->sessionId,
8073 WMI_PDEV_PARAM_ANI_ENABLE,
8074 set_value, PDEV_CMD);
8075 break;
8076 }
8077
8078 case WE_SET_ANI_POLL_PERIOD:
8079 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008080 hdd_debug("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008081 set_value);
8082 ret = wma_cli_set_command(pAdapter->sessionId,
8083 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
8084 set_value, PDEV_CMD);
8085 break;
8086 }
8087
8088 case WE_SET_ANI_LISTEN_PERIOD:
8089 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008090 hdd_debug("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008091 set_value);
8092 ret = wma_cli_set_command(pAdapter->sessionId,
8093 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
8094 set_value, PDEV_CMD);
8095 break;
8096 }
8097
8098 case WE_SET_ANI_OFDM_LEVEL:
8099 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008100 hdd_debug("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008101 set_value);
8102 ret = wma_cli_set_command(pAdapter->sessionId,
8103 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
8104 set_value, PDEV_CMD);
8105 break;
8106 }
8107
8108 case WE_SET_ANI_CCK_LEVEL:
8109 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008110 hdd_debug("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008111 set_value);
8112 ret = wma_cli_set_command(pAdapter->sessionId,
8113 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
8114 set_value, PDEV_CMD);
8115 break;
8116 }
8117
8118 case WE_SET_DYNAMIC_BW:
8119 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008120 hdd_debug("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008121 set_value);
8122 ret = wma_cli_set_command(pAdapter->sessionId,
8123 WMI_PDEV_PARAM_DYNAMIC_BW,
8124 set_value, PDEV_CMD);
8125 break;
8126 }
8127
8128 case WE_SET_CTS_CBW:
8129 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008130 hdd_debug("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008131 ret = wma_cli_set_command(pAdapter->sessionId,
8132 WMI_PDEV_PARAM_CTS_CBW,
8133 set_value, PDEV_CMD);
8134 break;
8135 }
8136
8137 case WE_SET_11N_RATE:
8138 {
8139 uint8_t preamble = 0, nss = 0, rix = 0;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008140 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008141 set_value);
8142
8143 if (set_value != 0xff) {
8144 rix = RC_2_RATE_IDX(set_value);
8145 if (set_value & 0x80) {
8146 preamble = WMI_RATE_PREAMBLE_HT;
8147 nss = HT_RC_2_STREAMS(set_value) - 1;
8148 } else {
8149 nss = 0;
8150 rix = RC_2_RATE_IDX(set_value);
8151 if (set_value & 0x10) {
8152 preamble =
8153 WMI_RATE_PREAMBLE_CCK;
8154 if (rix != 0x3)
8155 /* Enable Short
8156 * preamble always for
8157 * CCK except 1mbps
8158 */
8159 rix |= 0x4;
8160 } else {
8161 preamble =
8162 WMI_RATE_PREAMBLE_OFDM;
8163 }
8164 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008165 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008166 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008167 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008168 set_value, rix, preamble, nss);
8169
8170 ret = wma_cli_set_command(pAdapter->sessionId,
8171 WMI_VDEV_PARAM_FIXED_RATE,
8172 set_value, VDEV_CMD);
8173 break;
8174 }
8175
8176 case WE_SET_VHT_RATE:
8177 {
8178 uint8_t preamble = 0, nss = 0, rix = 0;
8179
8180 if (set_value != 0xff) {
8181 rix = RC_2_RATE_IDX_11AC(set_value);
8182 preamble = WMI_RATE_PREAMBLE_VHT;
8183 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
8184
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008185 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008186 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008187 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008188 set_value, rix, preamble, nss);
8189 ret = wma_cli_set_command(pAdapter->sessionId,
8190 WMI_VDEV_PARAM_FIXED_RATE,
8191 set_value, VDEV_CMD);
8192 break;
8193 }
8194
8195 case WE_SET_AMPDU:
8196 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008197 hdd_debug("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008198 ret = wma_cli_set_command(pAdapter->sessionId,
8199 GEN_VDEV_PARAM_AMPDU,
8200 set_value, GEN_CMD);
8201 break;
8202 }
8203
8204 case WE_SET_AMSDU:
8205 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008206 hdd_debug("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008207 ret = wma_cli_set_command(pAdapter->sessionId,
8208 GEN_VDEV_PARAM_AMSDU,
8209 set_value, GEN_CMD);
8210 break;
8211 }
8212
8213 case WE_SET_BURST_ENABLE:
8214 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008215 hdd_debug("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008216 if ((set_value == 0) || (set_value == 1)) {
8217 ret = wma_cli_set_command(pAdapter->sessionId,
8218 WMI_PDEV_PARAM_BURST_ENABLE,
8219 set_value, PDEV_CMD);
8220 } else
8221 ret = -EINVAL;
8222 break;
8223 }
8224 case WE_SET_BURST_DUR:
8225 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008226 hdd_debug("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07008227 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008228 ret = wma_cli_set_command(pAdapter->sessionId,
8229 WMI_PDEV_PARAM_BURST_DUR,
8230 set_value, PDEV_CMD);
8231 else
8232 ret = -EINVAL;
8233 break;
8234 }
8235
8236 case WE_SET_TX_CHAINMASK:
8237 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008238 hdd_debug("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008239 set_value);
8240 ret = wma_cli_set_command(pAdapter->sessionId,
8241 WMI_PDEV_PARAM_TX_CHAIN_MASK,
8242 set_value, PDEV_CMD);
8243 break;
8244 }
8245
8246 case WE_SET_RX_CHAINMASK:
8247 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008248 hdd_debug("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008249 set_value);
8250 ret = wma_cli_set_command(pAdapter->sessionId,
8251 WMI_PDEV_PARAM_RX_CHAIN_MASK,
8252 set_value, PDEV_CMD);
8253 break;
8254 }
8255
8256 case WE_SET_TXPOW_2G:
8257 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008258 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008259 set_value);
8260 ret = wma_cli_set_command(pAdapter->sessionId,
8261 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
8262 set_value, PDEV_CMD);
8263 break;
8264 }
8265
8266 case WE_SET_TXPOW_5G:
8267 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008268 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008269 set_value);
8270 ret = wma_cli_set_command(pAdapter->sessionId,
8271 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
8272 set_value, PDEV_CMD);
8273 break;
8274 }
8275
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008276 /* Firmware debug log */
8277 case WE_DBGLOG_LOG_LEVEL:
8278 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008279 hdd_debug("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008280 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
8281 ret = wma_cli_set_command(pAdapter->sessionId,
8282 WMI_DBGLOG_LOG_LEVEL,
8283 set_value, DBG_CMD);
8284 break;
8285 }
8286
8287 case WE_DBGLOG_VAP_ENABLE:
8288 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008289 hdd_debug("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008290 ret = wma_cli_set_command(pAdapter->sessionId,
8291 WMI_DBGLOG_VAP_ENABLE,
8292 set_value, DBG_CMD);
8293 break;
8294 }
8295
8296 case WE_DBGLOG_VAP_DISABLE:
8297 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008298 hdd_debug("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008299 ret = wma_cli_set_command(pAdapter->sessionId,
8300 WMI_DBGLOG_VAP_DISABLE,
8301 set_value, DBG_CMD);
8302 break;
8303 }
8304
8305 case WE_DBGLOG_MODULE_ENABLE:
8306 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008307 hdd_debug("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008308 set_value);
8309 hdd_ctx->fw_log_settings.enable = set_value;
8310 ret = wma_cli_set_command(pAdapter->sessionId,
8311 WMI_DBGLOG_MODULE_ENABLE,
8312 set_value, DBG_CMD);
8313 break;
8314 }
8315
8316 case WE_DBGLOG_MODULE_DISABLE:
8317 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008318 hdd_debug("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008319 set_value);
8320 hdd_ctx->fw_log_settings.enable = set_value;
8321 ret = wma_cli_set_command(pAdapter->sessionId,
8322 WMI_DBGLOG_MODULE_DISABLE,
8323 set_value, DBG_CMD);
8324 break;
8325 }
8326 case WE_DBGLOG_MOD_LOG_LEVEL:
8327 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008328 hdd_debug("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008329 set_value);
8330
8331 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
8332 hdd_ctx->fw_log_settings.index = 0;
8333
8334 hdd_ctx->fw_log_settings.
8335 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
8336 set_value;
8337 hdd_ctx->fw_log_settings.index++;
8338
8339 ret = wma_cli_set_command(pAdapter->sessionId,
8340 WMI_DBGLOG_MOD_LOG_LEVEL,
8341 set_value, DBG_CMD);
8342 break;
8343 }
8344
8345 case WE_DBGLOG_TYPE:
8346 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008347 hdd_debug("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008348 hdd_ctx->fw_log_settings.dl_type = set_value;
8349 ret = wma_cli_set_command(pAdapter->sessionId,
8350 WMI_DBGLOG_TYPE,
8351 set_value, DBG_CMD);
8352 break;
8353 }
8354 case WE_DBGLOG_REPORT_ENABLE:
8355 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008356 hdd_debug("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008357 set_value);
8358 hdd_ctx->fw_log_settings.dl_report = set_value;
8359 ret = wma_cli_set_command(pAdapter->sessionId,
8360 WMI_DBGLOG_REPORT_ENABLE,
8361 set_value, DBG_CMD);
8362 break;
8363 }
8364
8365 case WE_SET_TXRX_FWSTATS:
8366 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008367 hdd_debug("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008368 ret = wma_cli_set_command(pAdapter->sessionId,
8369 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
8370 set_value, VDEV_CMD);
8371 break;
8372 }
8373
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008374 case WE_SET_TXRX_STATS:
8375 {
8376 hdd_notice("WE_SET_TXRX_STATS val %d", set_value);
8377 ret = cds_get_datapath_handles(&soc, &pdev, &vdev,
8378 pAdapter->sessionId);
8379
8380 if (ret != 0)
8381 break;
8382
8383 qdf_mem_zero(&req, sizeof(req));
8384 ret = cdp_txrx_stats(soc, vdev, &req, set_value);
8385 break;
8386 }
8387
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008388 case WE_TXRX_FWSTATS_RESET:
8389 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008390 hdd_debug("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008391 ret = wma_cli_set_command(pAdapter->sessionId,
8392 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
8393 set_value, VDEV_CMD);
8394 break;
8395 }
8396
8397 case WE_DUMP_STATS:
8398 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008399 hdd_debug("WE_DUMP_STATS val %d", set_value);
Mohit Khanna3e2115b2016-10-11 13:18:29 -07008400 ret = hdd_wlan_dump_stats(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008401 break;
8402 }
8403
8404 case WE_CLEAR_STATS:
8405 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008406 hdd_debug("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008407 switch (set_value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008408 case CDP_HDD_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008409 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
8410 memset(&pAdapter->hdd_stats, 0,
8411 sizeof(pAdapter->hdd_stats));
8412 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008413 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008414 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
8415 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008416 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008417 wlan_hdd_clear_netif_queue_history(hdd_ctx);
8418 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008419 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05308420 hdd_clear_hif_stats();
8421 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008422 default:
Leo Changfdb45c32016-10-28 11:09:23 -07008423 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
8424 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008425 }
8426 break;
8427 }
8428
8429 case WE_PPS_PAID_MATCH:
8430 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008431 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008432 return EINVAL;
8433
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008434 hdd_debug("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008435 set_value);
8436 ret = wma_cli_set_command(pAdapter->sessionId,
8437 WMI_VDEV_PPS_PAID_MATCH,
8438 set_value, PPS_CMD);
8439 break;
8440 }
8441
8442 case WE_PPS_GID_MATCH:
8443 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008444 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008445 return EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008446 hdd_debug("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008447 set_value);
8448 ret = wma_cli_set_command(pAdapter->sessionId,
8449 WMI_VDEV_PPS_GID_MATCH,
8450 set_value, PPS_CMD);
8451 break;
8452 }
8453
8454 case WE_PPS_EARLY_TIM_CLEAR:
8455 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008456 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008457 return EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008458 hdd_debug(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008459 set_value);
8460 ret = wma_cli_set_command(pAdapter->sessionId,
8461 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
8462 set_value, PPS_CMD);
8463 break;
8464 }
8465
8466 case WE_PPS_EARLY_DTIM_CLEAR:
8467 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008468 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008469 return EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008470 hdd_debug("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008471 set_value);
8472 ret = wma_cli_set_command(pAdapter->sessionId,
8473 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
8474 set_value, PPS_CMD);
8475 break;
8476 }
8477
8478 case WE_PPS_EOF_PAD_DELIM:
8479 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008480 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008481 return EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008482 hdd_debug("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008483 set_value);
8484 ret = wma_cli_set_command(pAdapter->sessionId,
8485 WMI_VDEV_PPS_EOF_PAD_DELIM,
8486 set_value, PPS_CMD);
8487 break;
8488 }
8489
8490 case WE_PPS_MACADDR_MISMATCH:
8491 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008492 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008493 return EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008494 hdd_debug("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008495 set_value);
8496 ret = wma_cli_set_command(pAdapter->sessionId,
8497 WMI_VDEV_PPS_MACADDR_MISMATCH,
8498 set_value, PPS_CMD);
8499 break;
8500 }
8501
8502 case WE_PPS_DELIM_CRC_FAIL:
8503 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008504 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008505 return EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008506 hdd_debug("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008507 set_value);
8508 ret = wma_cli_set_command(pAdapter->sessionId,
8509 WMI_VDEV_PPS_DELIM_CRC_FAIL,
8510 set_value, PPS_CMD);
8511 break;
8512 }
8513
8514 case WE_PPS_GID_NSTS_ZERO:
8515 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008516 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008517 return EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008518 hdd_debug("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008519 set_value);
8520 ret = wma_cli_set_command(pAdapter->sessionId,
8521 WMI_VDEV_PPS_GID_NSTS_ZERO,
8522 set_value, PPS_CMD);
8523 break;
8524 }
8525
8526 case WE_PPS_RSSI_CHECK:
8527 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008528 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008529 return EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008530 hdd_debug("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008531 set_value);
8532 ret = wma_cli_set_command(pAdapter->sessionId,
8533 WMI_VDEV_PPS_RSSI_CHECK,
8534 set_value, PPS_CMD);
8535 break;
8536 }
8537
8538 case WE_PPS_5G_EBT:
8539 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008540 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008541 return -EINVAL;
8542
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008543 hdd_debug("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008544 ret = wma_cli_set_command(pAdapter->sessionId,
8545 WMI_VDEV_PPS_5G_EBT,
8546 set_value, PPS_CMD);
8547 break;
8548 }
8549
8550 case WE_SET_HTSMPS:
8551 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008552 hdd_debug("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008553 ret = wma_cli_set_command(pAdapter->sessionId,
8554 WMI_STA_SMPS_FORCE_MODE_CMDID,
8555 set_value, VDEV_CMD);
8556 break;
8557 }
8558
8559 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
8560 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008561 hdd_debug("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008562 set_value);
8563 ret = wma_cli_set_command(pAdapter->sessionId,
8564 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
8565 set_value, QPOWER_CMD);
8566 break;
8567 }
8568
8569 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
8570 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008571 hdd_debug("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008572 set_value);
8573 ret = wma_cli_set_command(
8574 pAdapter->sessionId,
8575 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
8576 set_value, QPOWER_CMD);
8577 break;
8578 }
8579
8580 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
8581 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008582 hdd_debug("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008583 set_value);
8584 ret = wma_cli_set_command(
8585 pAdapter->sessionId,
8586 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
8587 set_value, QPOWER_CMD);
8588 break;
8589 }
8590
8591 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
8592 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008593 hdd_debug("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008594 set_value);
8595 ret = wma_cli_set_command(
8596 pAdapter->sessionId,
8597 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
8598 set_value, QPOWER_CMD);
8599 break;
8600 }
8601
8602 case WE_MCC_CONFIG_LATENCY:
8603 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008604 wlan_hdd_set_mcc_latency(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008605 break;
8606 }
8607
8608 case WE_MCC_CONFIG_QUOTA:
8609 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008610 hdd_debug("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008611 set_value);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008612 ret = wlan_hdd_set_mcc_p2p_quota(pAdapter,
8613 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008614 break;
8615 }
8616 case WE_SET_DEBUG_LOG:
8617 {
8618 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05308619
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008620 hdd_ctx->config->gEnableDebugLog = set_value;
8621 sme_update_connect_debug(hdd_ctx->hHal, set_value);
8622 break;
8623 }
8624 case WE_SET_EARLY_RX_ADJUST_ENABLE:
8625 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008626 hdd_debug("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008627 if ((set_value == 0) || (set_value == 1))
8628 ret = wma_cli_set_command(
8629 pAdapter->sessionId,
8630 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
8631 set_value, VDEV_CMD);
8632 else
8633 ret = -EINVAL;
8634 break;
8635 }
8636 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
8637 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008638 hdd_debug("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008639 ret = wma_cli_set_command(pAdapter->sessionId,
8640 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
8641 set_value, VDEV_CMD);
8642 break;
8643 }
8644 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
8645 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008646 hdd_debug("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008647 set_value);
8648 ret = wma_cli_set_command(
8649 pAdapter->sessionId,
8650 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
8651 set_value, VDEV_CMD);
8652 break;
8653 }
8654 case WE_SET_EARLY_RX_SLOP_STEP:
8655 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008656 hdd_debug("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008657 set_value);
8658 ret = wma_cli_set_command(pAdapter->sessionId,
8659 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
8660 set_value, VDEV_CMD);
8661 break;
8662 }
8663 case WE_SET_EARLY_RX_INIT_SLOP:
8664 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008665 hdd_debug("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008666 set_value);
8667 ret = wma_cli_set_command(pAdapter->sessionId,
8668 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
8669 set_value, VDEV_CMD);
8670 break;
8671 }
8672 case WE_SET_EARLY_RX_ADJUST_PAUSE:
8673 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008674 hdd_debug("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008675 if ((set_value == 0) || (set_value == 1))
8676 ret = wma_cli_set_command(
8677 pAdapter->sessionId,
8678 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
8679 set_value, VDEV_CMD);
8680 else
8681 ret = -EINVAL;
8682 break;
8683 }
8684 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
8685 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008686 hdd_debug("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008687 ret = wma_cli_set_command(pAdapter->sessionId,
8688 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
8689 set_value, VDEV_CMD);
8690 break;
8691 }
8692 case WE_SET_SCAN_DISABLE:
8693 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008694 hdd_debug("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008695 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
8696 break;
8697 }
Govind Singha471e5e2015-10-12 17:11:14 +05308698 case WE_START_FW_PROFILE:
8699 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008700 hdd_debug("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05308701 ret = wma_cli_set_command(pAdapter->sessionId,
8702 WMI_WLAN_PROFILE_TRIGGER_CMDID,
8703 set_value, DBG_CMD);
8704 break;
8705 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308706 case WE_SET_CHANNEL:
8707 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008708 hdd_debug("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308709 pAdapter->sessionId, pAdapter->device_mode);
8710
Krunal Sonif07bb382016-03-10 13:02:11 -08008711 if ((QDF_STA_MODE == pAdapter->device_mode) ||
8712 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308713
8714 status = sme_ext_change_channel(hHal,
8715 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308716 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008717 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308718 status);
8719 ret = -EINVAL;
8720 }
8721 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008722 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308723 pAdapter->device_mode);
8724 ret = -EINVAL;
8725 }
8726 break;
8727 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308728 case WE_SET_CONC_SYSTEM_PREF:
8729 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008730 hdd_debug("New preference: %d", set_value);
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308731 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
8732 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
8733 hdd_err("Invalid system preference %d", set_value);
8734 return -EINVAL;
8735 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308736
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308737 /* hdd_ctx, hdd_ctx->config are already checked for null */
8738 hdd_ctx->config->conc_system_pref = set_value;
8739 break;
8740 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008741 case WE_SET_11AX_RATE:
8742 ret = hdd_set_11ax_rate(pAdapter, set_value, NULL);
8743 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07008744 case WE_SET_DCM:
8745 hdd_notice("Set WMI_VDEV_PARAM_HE_DCM: %d", set_value);
8746 ret = wma_cli_set_command(pAdapter->sessionId,
8747 WMI_VDEV_PARAM_HE_DCM, set_value,
8748 VDEV_CMD);
8749 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07008750 case WE_SET_RANGE_EXT:
8751 hdd_notice("Set WMI_VDEV_PARAM_HE_RANGE_EXT: %d", set_value);
8752 ret = wma_cli_set_command(pAdapter->sessionId,
8753 WMI_VDEV_PARAM_HE_RANGE_EXT,
8754 set_value, VDEV_CMD);
8755 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008756 default:
8757 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008758 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008759 sub_cmd);
8760 ret = -EINVAL;
8761 break;
8762 }
8763 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308764 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008765 return ret;
8766}
8767
8768static int iw_setint_getnone(struct net_device *dev,
8769 struct iw_request_info *info,
8770 union iwreq_data *wrqu,
8771 char *extra)
8772{
8773 int ret;
8774
8775 cds_ssr_protect(__func__);
8776 ret = __iw_setint_getnone(dev, info, wrqu, extra);
8777 cds_ssr_unprotect(__func__);
8778
8779 return ret;
8780}
8781
8782/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008783 * __iw_setnone_get_threeint() - return three value to up layer.
8784 *
8785 * @dev: pointer of net_device of this wireless card
8786 * @info: meta data about Request sent
8787 * @wrqu: include request info
8788 * @extra: buf used for in/Output
8789 *
8790 * Return: execute result
8791 */
8792static int __iw_setnone_get_threeint(struct net_device *dev,
8793 struct iw_request_info *info,
8794 union iwreq_data *wrqu, char *extra)
8795{
8796 int ret = 0; /* success */
8797 uint32_t *value = (int *)extra;
8798 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8799 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8800
8801 ENTER_DEV(dev);
8802 ret = wlan_hdd_validate_context(hdd_ctx);
8803 if (0 != ret)
8804 return ret;
8805
Jeff Johnson441e1f72017-02-07 08:50:49 -08008806 ret = hdd_check_private_wext_control(hdd_ctx, info);
8807 if (0 != ret)
8808 return ret;
8809
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008810 hdd_debug("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008811 switch (value[0]) {
8812 case WE_GET_TSF:
8813 ret = hdd_indicate_tsf(adapter, value, 3);
8814 break;
8815 default:
8816 hdd_err("Invalid IOCTL get_value command %d", value[0]);
8817 break;
8818 }
8819 return ret;
8820}
8821
8822/**
8823 * iw_setnone_get_threeint() - return three value to up layer.
8824 *
8825 * @dev: pointer of net_device of this wireless card
8826 * @info: meta data about Request sent
8827 * @wrqu: include request info
8828 * @extra: buf used for in/Output
8829 *
8830 * Return: execute result
8831 */
8832static int iw_setnone_get_threeint(struct net_device *dev,
8833 struct iw_request_info *info,
8834 union iwreq_data *wrqu, char *extra)
8835{
8836 int ret;
8837
8838 cds_ssr_protect(__func__);
8839 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8840 cds_ssr_unprotect(__func__);
8841
8842 return ret;
8843}
8844
8845/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008846 * iw_setchar_getnone() - Generic "set string" private ioctl handler
8847 * @dev: device upon which the ioctl was received
8848 * @info: ioctl request information
8849 * @wrqu: ioctl request data
8850 * @extra: ioctl extra data
8851 *
8852 * Return: 0 on success, non-zero on error
8853 */
8854static int __iw_setchar_getnone(struct net_device *dev,
8855 struct iw_request_info *info,
8856 union iwreq_data *wrqu, char *extra)
8857{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308858 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008859 int sub_cmd;
8860 int ret;
8861 char *pBuffer = NULL;
8862 hdd_adapter_t *pAdapter = (netdev_priv(dev));
8863 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008864 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008865 struct iw_point s_priv_data;
8866
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008867 ENTER_DEV(dev);
8868
Mukul Sharma34777c62015-11-02 20:22:30 +05308869 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008870 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05308871 return -EPERM;
8872 }
8873
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008874 ret = wlan_hdd_validate_context(hdd_ctx);
8875 if (0 != ret)
8876 return ret;
8877
Jeff Johnson441e1f72017-02-07 08:50:49 -08008878 ret = hdd_check_private_wext_control(hdd_ctx, info);
8879 if (0 != ret)
8880 return ret;
8881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008882 /* helper function to get iwreq_data with compat handling. */
8883 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8884 return -EINVAL;
8885 }
8886
8887 /* make sure all params are correctly passed to function */
8888 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
8889 return -EINVAL;
8890 }
8891
8892 sub_cmd = s_priv_data.flags;
8893
8894 /* ODD number is used for set, copy data using copy_from_user */
8895 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8896 s_priv_data.length);
8897 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008898 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008899 return -ENOMEM;
8900 }
8901
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008902 hdd_debug("Received length %d", s_priv_data.length);
8903 hdd_debug("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008904
8905 switch (sub_cmd) {
8906 case WE_WOWL_ADD_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008907 hdd_debug("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008908 hdd_add_wowl_ptrn(pAdapter, pBuffer);
8909 break;
8910 case WE_WOWL_DEL_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008911 hdd_debug("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008912 hdd_del_wowl_ptrn(pAdapter, pBuffer);
8913 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008914 case WE_NEIGHBOR_REPORT_REQUEST:
8915 {
8916 tRrmNeighborReq neighborReq;
8917 tRrmNeighborRspCallbackInfo callbackInfo;
8918
8919 if (pConfig->fRrmEnable) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008920 hdd_debug("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008921 neighborReq.no_ssid =
8922 (s_priv_data.length - 1) ? false : true;
8923 if (!neighborReq.no_ssid) {
8924 neighborReq.ssid.length =
8925 (s_priv_data.length - 1) >
8926 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308927 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008928 pBuffer,
8929 neighborReq.ssid.length);
8930 }
8931
8932 callbackInfo.neighborRspCallback = NULL;
8933 callbackInfo.neighborRspCallbackContext = NULL;
8934 callbackInfo.timeout = 5000; /* 5 seconds */
8935 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
8936 (pAdapter),
8937 pAdapter->sessionId,
8938 &neighborReq,
8939 &callbackInfo);
8940 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008941 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008942 ret = -EINVAL;
8943 }
8944 }
8945 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008946 case WE_SET_AP_WPS_IE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008947 hdd_debug("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008948 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
8949 s_priv_data.length);
8950 break;
8951 case WE_SET_CONFIG:
8952 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308953 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008954 ret = -EINVAL;
8955 }
8956 break;
8957 default:
8958 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008959 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008960 sub_cmd);
8961 ret = -EINVAL;
8962 break;
8963 }
8964 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07008965 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308966 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008967 return ret;
8968}
8969
8970static int iw_setchar_getnone(struct net_device *dev,
8971 struct iw_request_info *info,
8972 union iwreq_data *wrqu, char *extra)
8973{
8974 int ret;
8975
8976 cds_ssr_protect(__func__);
8977 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
8978 cds_ssr_unprotect(__func__);
8979
8980 return ret;
8981}
8982
8983/**
8984 * iw_setnone_getint() - Generic "get integer" private ioctl handler
8985 * @dev: device upon which the ioctl was received
8986 * @info: ioctl request information
8987 * @wrqu: ioctl request data
8988 * @extra: ioctl extra data
8989 *
8990 * Return: 0 on success, non-zero on error
8991 */
8992static int __iw_setnone_getint(struct net_device *dev,
8993 struct iw_request_info *info,
8994 union iwreq_data *wrqu, char *extra)
8995{
8996 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8997 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8998 int *value = (int *)extra;
8999 int ret;
9000 tSmeConfigParams smeConfig;
9001 hdd_context_t *hdd_ctx;
9002
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009003 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309004
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009005 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9006 ret = wlan_hdd_validate_context(hdd_ctx);
9007 if (0 != ret)
9008 return ret;
9009
Jeff Johnson441e1f72017-02-07 08:50:49 -08009010 ret = hdd_check_private_wext_control(hdd_ctx, info);
9011 if (0 != ret)
9012 return ret;
9013
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009014 switch (value[0]) {
9015 case WE_GET_11D_STATE:
9016 {
9017 sme_get_config_param(hHal, &smeConfig);
9018
9019 *value = smeConfig.csrConfig.Is11dSupportEnabled;
9020
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009021 hdd_debug("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009022
9023 break;
9024 }
9025
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009026 case WE_GET_WLAN_DBG:
9027 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309028 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009029 *value = 0;
9030 break;
9031 }
9032 case WE_GET_MAX_ASSOC:
9033 {
9034 if (sme_cfg_get_int
9035 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309036 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009037 hdd_err("Failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009038 ret = -EIO;
9039 }
9040 break;
9041 }
9042 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
9043 *value = (WLAN_HDD_GET_CTX(
9044 pAdapter))->config->force_sap_acs;
9045 break;
9046
9047 case WE_GET_CONCURRENCY_MODE:
9048 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08009049 *value = policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009050
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009051 hdd_debug("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009052 break;
9053 }
9054
9055 case WE_GET_NSS:
9056 {
9057 sme_get_config_param(hHal, &smeConfig);
9058 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009059 hdd_debug("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009060 break;
9061 }
9062
9063 case WE_GET_GTX_HT_MCS:
9064 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009065 hdd_debug("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009066 *value = wma_cli_get_command(pAdapter->sessionId,
9067 WMI_VDEV_PARAM_GTX_HT_MCS,
9068 GTX_CMD);
9069 break;
9070 }
9071
9072 case WE_GET_GTX_VHT_MCS:
9073 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009074 hdd_debug("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009075 *value = wma_cli_get_command(pAdapter->sessionId,
9076 WMI_VDEV_PARAM_GTX_VHT_MCS,
9077 GTX_CMD);
9078 break;
9079 }
9080
9081 case WE_GET_GTX_USRCFG:
9082 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009083 hdd_debug("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009084 *value = wma_cli_get_command(pAdapter->sessionId,
9085 WMI_VDEV_PARAM_GTX_USR_CFG,
9086 GTX_CMD);
9087 break;
9088 }
9089
9090 case WE_GET_GTX_THRE:
9091 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009092 hdd_debug("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009093 *value = wma_cli_get_command(pAdapter->sessionId,
9094 WMI_VDEV_PARAM_GTX_THRE,
9095 GTX_CMD);
9096 break;
9097 }
9098
9099 case WE_GET_GTX_MARGIN:
9100 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009101 hdd_debug("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009102 *value = wma_cli_get_command(pAdapter->sessionId,
9103 WMI_VDEV_PARAM_GTX_MARGIN,
9104 GTX_CMD);
9105 break;
9106 }
9107
9108 case WE_GET_GTX_STEP:
9109 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009110 hdd_debug("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009111 *value = wma_cli_get_command(pAdapter->sessionId,
9112 WMI_VDEV_PARAM_GTX_STEP,
9113 GTX_CMD);
9114 break;
9115 }
9116
9117 case WE_GET_GTX_MINTPC:
9118 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009119 hdd_debug("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009120 *value = wma_cli_get_command(pAdapter->sessionId,
9121 WMI_VDEV_PARAM_GTX_MINTPC,
9122 GTX_CMD);
9123 break;
9124 }
9125
9126 case WE_GET_GTX_BWMASK:
9127 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009128 hdd_debug("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009129 *value = wma_cli_get_command(pAdapter->sessionId,
9130 WMI_VDEV_PARAM_GTX_BW_MASK,
9131 GTX_CMD);
9132 break;
9133 }
9134
9135 case WE_GET_LDPC:
9136 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309137 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009138 break;
9139 }
9140
9141 case WE_GET_TX_STBC:
9142 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309143 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009144 break;
9145 }
9146
9147 case WE_GET_RX_STBC:
9148 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309149 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009150 break;
9151 }
9152
9153 case WE_GET_SHORT_GI:
9154 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009155 hdd_debug("GET WMI_VDEV_PARAM_SGI");
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009156 *value = wma_cli_get_command(pAdapter->sessionId,
9157 WMI_VDEV_PARAM_SGI,
9158 VDEV_CMD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009159 break;
9160 }
9161
9162 case WE_GET_RTSCTS:
9163 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009164 hdd_debug("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009165 *value = wma_cli_get_command(pAdapter->sessionId,
9166 WMI_VDEV_PARAM_ENABLE_RTSCTS,
9167 VDEV_CMD);
9168 break;
9169 }
9170
9171 case WE_GET_CHWIDTH:
9172 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009173 hdd_debug("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009174 *value = wma_cli_get_command(pAdapter->sessionId,
9175 WMI_VDEV_PARAM_CHWIDTH,
9176 VDEV_CMD);
9177 break;
9178 }
9179
9180 case WE_GET_ANI_EN_DIS:
9181 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009182 hdd_debug("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009183 *value = wma_cli_get_command(pAdapter->sessionId,
9184 WMI_PDEV_PARAM_ANI_ENABLE,
9185 PDEV_CMD);
9186 break;
9187 }
9188
9189 case WE_GET_ANI_POLL_PERIOD:
9190 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009191 hdd_debug("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009192 *value = wma_cli_get_command(pAdapter->sessionId,
9193 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
9194 PDEV_CMD);
9195 break;
9196 }
9197
9198 case WE_GET_ANI_LISTEN_PERIOD:
9199 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009200 hdd_debug("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009201 *value = wma_cli_get_command(pAdapter->sessionId,
9202 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
9203 PDEV_CMD);
9204 break;
9205 }
9206
9207 case WE_GET_ANI_OFDM_LEVEL:
9208 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009209 hdd_debug("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009210 *value = wma_cli_get_command(pAdapter->sessionId,
9211 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
9212 PDEV_CMD);
9213 break;
9214 }
9215
9216 case WE_GET_ANI_CCK_LEVEL:
9217 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009218 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009219 *value = wma_cli_get_command(pAdapter->sessionId,
9220 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
9221 PDEV_CMD);
9222 break;
9223 }
9224
9225 case WE_GET_DYNAMIC_BW:
9226 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009227 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009228 *value = wma_cli_get_command(pAdapter->sessionId,
9229 WMI_PDEV_PARAM_DYNAMIC_BW,
9230 PDEV_CMD);
9231 break;
9232 }
9233
9234 case WE_GET_11N_RATE:
9235 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009236 hdd_debug("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009237 *value = wma_cli_get_command(pAdapter->sessionId,
9238 WMI_VDEV_PARAM_FIXED_RATE,
9239 VDEV_CMD);
9240 break;
9241 }
9242
9243 case WE_GET_AMPDU:
9244 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009245 hdd_debug("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009246 *value = wma_cli_get_command(pAdapter->sessionId,
9247 GEN_VDEV_PARAM_AMPDU,
9248 GEN_CMD);
9249 break;
9250 }
9251
9252 case WE_GET_AMSDU:
9253 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009254 hdd_debug("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009255 *value = wma_cli_get_command(pAdapter->sessionId,
9256 GEN_VDEV_PARAM_AMSDU,
9257 GEN_CMD);
9258 break;
9259 }
9260
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009261 case WE_GET_ROAM_SYNCH_DELAY:
9262 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009263 hdd_debug("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009264 *value = wma_cli_get_command(pAdapter->sessionId,
9265 GEN_VDEV_ROAM_SYNCH_DELAY,
9266 GEN_CMD);
9267 break;
9268 }
9269
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009270 case WE_GET_BURST_ENABLE:
9271 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009272 hdd_debug("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009273 *value = wma_cli_get_command(pAdapter->sessionId,
9274 WMI_PDEV_PARAM_BURST_ENABLE,
9275 PDEV_CMD);
9276 break;
9277 }
9278 case WE_GET_BURST_DUR:
9279 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009280 hdd_debug("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009281 *value = wma_cli_get_command(pAdapter->sessionId,
9282 WMI_PDEV_PARAM_BURST_DUR,
9283 PDEV_CMD);
9284 break;
9285 }
9286
9287 case WE_GET_TX_CHAINMASK:
9288 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009289 hdd_debug("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009290 *value = wma_cli_get_command(pAdapter->sessionId,
9291 WMI_PDEV_PARAM_TX_CHAIN_MASK,
9292 PDEV_CMD);
9293 break;
9294 }
9295
9296 case WE_GET_RX_CHAINMASK:
9297 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009298 hdd_debug("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009299 *value = wma_cli_get_command(pAdapter->sessionId,
9300 WMI_PDEV_PARAM_RX_CHAIN_MASK,
9301 PDEV_CMD);
9302 break;
9303 }
9304
9305 case WE_GET_TXPOW_2G:
9306 {
9307 uint32_t txpow2g = 0;
9308 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009309 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009310 *value = wma_cli_get_command(pAdapter->sessionId,
9311 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
9312 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309313 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009314 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9315 &txpow2g)) {
9316 return -EIO;
9317 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009318 hdd_debug("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009319 break;
9320 }
9321
9322 case WE_GET_TXPOW_5G:
9323 {
9324 uint32_t txpow5g = 0;
9325 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009326 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009327 *value = wma_cli_get_command(pAdapter->sessionId,
9328 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
9329 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309330 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009331 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9332 &txpow5g)) {
9333 return -EIO;
9334 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009335 hdd_debug("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009336 break;
9337 }
9338
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009339 case WE_GET_PPS_PAID_MATCH:
9340 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009341 hdd_debug("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009342 *value = wma_cli_get_command(pAdapter->sessionId,
9343 WMI_VDEV_PPS_PAID_MATCH,
9344 PPS_CMD);
9345 break;
9346 }
9347
9348 case WE_GET_PPS_GID_MATCH:
9349 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009350 hdd_debug("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009351 *value = wma_cli_get_command(pAdapter->sessionId,
9352 WMI_VDEV_PPS_GID_MATCH,
9353 PPS_CMD);
9354 break;
9355 }
9356
9357 case WE_GET_PPS_EARLY_TIM_CLEAR:
9358 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009359 hdd_debug("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009360 *value = wma_cli_get_command(pAdapter->sessionId,
9361 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
9362 PPS_CMD);
9363 break;
9364 }
9365
9366 case WE_GET_PPS_EARLY_DTIM_CLEAR:
9367 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009368 hdd_debug("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009369 *value = wma_cli_get_command(pAdapter->sessionId,
9370 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
9371 PPS_CMD);
9372 break;
9373 }
9374
9375 case WE_GET_PPS_EOF_PAD_DELIM:
9376 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009377 hdd_debug("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009378 *value = wma_cli_get_command(pAdapter->sessionId,
9379 WMI_VDEV_PPS_EOF_PAD_DELIM,
9380 PPS_CMD);
9381 break;
9382 }
9383
9384 case WE_GET_PPS_MACADDR_MISMATCH:
9385 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009386 hdd_debug("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009387 *value = wma_cli_get_command(pAdapter->sessionId,
9388 WMI_VDEV_PPS_MACADDR_MISMATCH,
9389 PPS_CMD);
9390 break;
9391 }
9392
9393 case WE_GET_PPS_DELIM_CRC_FAIL:
9394 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009395 hdd_debug("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009396 *value = wma_cli_get_command(pAdapter->sessionId,
9397 WMI_VDEV_PPS_DELIM_CRC_FAIL,
9398 PPS_CMD);
9399 break;
9400 }
9401
9402 case WE_GET_PPS_GID_NSTS_ZERO:
9403 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009404 hdd_debug("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009405 *value = wma_cli_get_command(pAdapter->sessionId,
9406 WMI_VDEV_PPS_GID_NSTS_ZERO,
9407 PPS_CMD);
9408 break;
9409 }
9410
9411 case WE_GET_PPS_RSSI_CHECK:
9412 {
9413
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009414 hdd_debug("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009415 *value = wma_cli_get_command(pAdapter->sessionId,
9416 WMI_VDEV_PPS_RSSI_CHECK,
9417 PPS_CMD);
9418 break;
9419 }
9420
9421 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
9422 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009423 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009424 *value = wma_cli_get_command(pAdapter->sessionId,
9425 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
9426 QPOWER_CMD);
9427 break;
9428 }
9429
9430 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
9431 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009432 hdd_debug("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009433 *value = wma_cli_get_command(pAdapter->sessionId,
9434 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
9435 QPOWER_CMD);
9436 break;
9437 }
9438
9439 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
9440 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009441 hdd_debug("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009442 *value = wma_cli_get_command(pAdapter->sessionId,
9443 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
9444 QPOWER_CMD);
9445 break;
9446 }
9447
9448 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
9449 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009450 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009451 *value = wma_cli_get_command(pAdapter->sessionId,
9452 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
9453 QPOWER_CMD);
9454 break;
9455 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009456 case WE_CAP_TSF:
9457 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
9458 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009459 case WE_GET_TEMPERATURE:
9460 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009461 hdd_debug("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009462 ret = wlan_hdd_get_temperature(pAdapter, value);
9463 break;
9464 }
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07009465 case WE_GET_DCM:
9466 hdd_notice("GET WMI_VDEV_PARAM_HE_DCM");
9467 *value = wma_cli_get_command(pAdapter->sessionId,
9468 WMI_VDEV_PARAM_HE_DCM,
9469 VDEV_CMD);
9470 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07009471 case WE_GET_RANGE_EXT:
9472 hdd_notice("GET WMI_VDEV_PARAM_HE_RANGE_EXT");
9473 *value = wma_cli_get_command(pAdapter->sessionId,
9474 WMI_VDEV_PARAM_HE_RANGE_EXT,
9475 VDEV_CMD);
9476 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009477 default:
9478 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009479 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009480 value[0]);
9481 break;
9482 }
9483 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309484 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009485 return ret;
9486}
9487
9488static int iw_setnone_getint(struct net_device *dev,
9489 struct iw_request_info *info,
9490 union iwreq_data *wrqu, char *extra)
9491{
9492 int ret;
9493
9494 cds_ssr_protect(__func__);
9495 ret = __iw_setnone_getint(dev, info, wrqu, extra);
9496 cds_ssr_unprotect(__func__);
9497
9498 return ret;
9499}
9500
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309501static int hdd_set_fwtest(int argc, int cmd, int value)
9502{
9503 struct set_fwtest_params *fw_test;
9504
9505 /* check for max number of arguments */
9506 if (argc > (WMA_MAX_NUM_ARGS) ||
9507 argc != HDD_FWTEST_PARAMS) {
9508 hdd_err("Too Many args %d", argc);
9509 return -EINVAL;
9510 }
9511 /*
9512 * check if number of arguments are 3 then, check
9513 * then set the default value for sounding interval.
9514 */
9515 if (HDD_FWTEST_PARAMS == argc) {
9516 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
9517 value = HDD_FWTEST_SU_DEFAULT_VALUE;
9518 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
9519 value = HDD_FWTEST_MU_DEFAULT_VALUE;
9520 }
9521 /* check sounding interval value should not exceed to max */
9522 if (value > HDD_FWTEST_MAX_VALUE) {
9523 hdd_err("Invalid arguments value should not exceed max: %d",
9524 value);
9525 return -EINVAL;
9526 }
9527 fw_test = qdf_mem_malloc(sizeof(*fw_test));
9528 if (NULL == fw_test) {
9529 hdd_err("qdf_mem_malloc failed for fw_test");
9530 return -ENOMEM;
9531 }
9532 fw_test->arg = cmd;
9533 fw_test->value = value;
9534 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
9535 qdf_mem_free(fw_test);
9536 hdd_err("Not able to post FW_TEST_CMD message to WMA");
9537 return -EINVAL;
9538 }
9539 return 0;
9540}
9541
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009542/**
9543 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
9544 * @dev: device upon which the ioctl was received
9545 * @info: ioctl request information
9546 * @wrqu: ioctl request data
9547 * @extra: ioctl extra data
9548 *
9549 * Return: 0 on success, non-zero on error
9550 */
9551static int __iw_set_three_ints_getnone(struct net_device *dev,
9552 struct iw_request_info *info,
9553 union iwreq_data *wrqu, char *extra)
9554{
9555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9556 int *value = (int *)extra;
9557 int sub_cmd = value[0];
9558 int ret;
9559 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9560
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009561 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309562
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009563 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009564 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009565 return -EPERM;
9566 }
9567
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009568 ret = wlan_hdd_validate_context(hdd_ctx);
9569 if (0 != ret)
9570 return ret;
9571
Jeff Johnson441e1f72017-02-07 08:50:49 -08009572 ret = hdd_check_private_wext_control(hdd_ctx, info);
9573 if (0 != ret)
9574 return ret;
9575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009576 switch (sub_cmd) {
9577
9578 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309579 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009580 break;
9581 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309582 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009583 break;
9584
9585 /* value[3] the acs band is not required as start and end channels are
9586 * enough but this cmd is maintained under set three ints for historic
9587 * reasons.
9588 */
9589 case WE_SET_SAP_CHANNELS:
9590 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309591 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009592 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309593 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009594 ret = -EINVAL;
9595 } else {
9596 hdd_ctx->config->force_sap_acs_st_ch = value[1];
9597 hdd_ctx->config->force_sap_acs_end_ch = value[2];
9598 }
9599 break;
9600 case WE_SET_DUAL_MAC_SCAN_CONFIG:
9601 hdd_debug("Ioctl to set dual mac scan config");
9602 if (hdd_ctx->config->dual_mac_feature_disable) {
9603 hdd_err("Dual mac feature is disabled from INI");
9604 return -EPERM;
9605 }
9606 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08009607 policy_mgr_set_dual_mac_scan_config(hdd_ctx->hdd_psoc,
9608 value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009609 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309610 case WE_SET_FW_TEST:
9611 {
9612 ret = hdd_set_fwtest(value[1], value[2], value[3]);
9613 if (ret) {
9614 hdd_err("Not able to set fwtest %d", ret);
9615 return ret;
9616 }
9617 }
9618 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009619 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009620 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009621 break;
9622
9623 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309624 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009625 return ret;
9626}
9627
9628int iw_set_three_ints_getnone(struct net_device *dev,
9629 struct iw_request_info *info,
9630 union iwreq_data *wrqu, char *extra)
9631{
9632 int ret;
9633
9634 cds_ssr_protect(__func__);
9635 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
9636 cds_ssr_unprotect(__func__);
9637
9638 return ret;
9639}
9640
9641/**
9642 * hdd_connection_state_string() - Get connection state string
9643 * @connection_state: enum to be converted to a string
9644 *
9645 * Return: the string equivalent of @connection_state
9646 */
9647static const char *
9648hdd_connection_state_string(eConnectionState connection_state)
9649{
9650 switch (connection_state) {
9651 CASE_RETURN_STRING(eConnectionState_NotConnected);
9652 CASE_RETURN_STRING(eConnectionState_Connecting);
9653 CASE_RETURN_STRING(eConnectionState_Associated);
9654 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
9655 CASE_RETURN_STRING(eConnectionState_IbssConnected);
9656 CASE_RETURN_STRING(eConnectionState_Disconnecting);
9657 default:
9658 return "UNKNOWN";
9659 }
9660}
9661
Naveen Rawat910726a2017-03-06 11:42:51 -08009662#if defined(FEATURE_OEM_DATA_SUPPORT)
9663/**
9664 * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
9665 * wifi_pos api to get oem data caps
9666 * @dev: net device upon which the request was received
9667 * @info: ioctl request information
9668 * @wrqu: ioctl request data
9669 * @extra: ioctl data payload
9670 *
9671 * Return: 0 for success, negative errno value on failure
9672 */
9673static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9674 struct iw_request_info *info,
9675 union iwreq_data *wrqu, char *extra)
9676{
9677 return iw_get_oem_data_cap(dev, info, wrqu, extra);
9678}
9679#elif defined(WIFI_POS_CONVERGED)
9680static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9681 struct iw_request_info *info,
9682 union iwreq_data *wrqu, char *extra)
9683{
9684 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9685 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9686
9687 return os_if_wifi_pos_populate_caps(hdd_ctx->hdd_psoc,
9688 (struct wifi_pos_driver_caps *)extra);
9689}
9690#else
9691static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9692 struct iw_request_info *info,
9693 union iwreq_data *wrqu, char *extra)
9694{
9695 return -ENOTSUPP;
9696}
9697#endif
9698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009699/**
9700 * iw_get_char_setnone() - Generic "get string" private ioctl handler
9701 * @dev: device upon which the ioctl was received
9702 * @info: ioctl request information
9703 * @wrqu: ioctl request data
9704 * @extra: ioctl extra data
9705 *
9706 * Return: 0 on success, non-zero on error
9707 */
9708static int __iw_get_char_setnone(struct net_device *dev,
9709 struct iw_request_info *info,
9710 union iwreq_data *wrqu, char *extra)
9711{
9712 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9713 int sub_cmd = wrqu->data.flags;
9714 hdd_context_t *hdd_ctx;
9715 int ret;
9716#ifdef WLAN_FEATURE_11W
9717 hdd_wext_state_t *pWextState;
9718#endif
9719
9720#ifdef WLAN_FEATURE_11W
9721 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9722#endif
9723
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009724 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309725
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009726 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9727 ret = wlan_hdd_validate_context(hdd_ctx);
9728 if (0 != ret)
9729 return ret;
9730
Jeff Johnson441e1f72017-02-07 08:50:49 -08009731 ret = hdd_check_private_wext_control(hdd_ctx, info);
9732 if (0 != ret)
9733 return ret;
9734
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009735 switch (sub_cmd) {
9736 case WE_WLAN_VERSION:
9737 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05309738 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009739 break;
9740 }
9741
9742 case WE_GET_STATS:
9743 {
9744 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
9745 extra, WE_MAX_STR_LEN);
9746 break;
9747 }
9748
Dustin Brownd9322482017-01-09 12:46:03 -08009749 case WE_GET_SUSPEND_RESUME_STATS:
9750 {
9751 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
9752 WE_MAX_STR_LEN);
9753 if (ret >= 0) {
9754 wrqu->data.length = ret;
9755 ret = 0;
9756 }
9757
9758 break;
9759 }
9760
Govind Singha471e5e2015-10-12 17:11:14 +05309761 case WE_LIST_FW_PROFILE:
9762 hdd_wlan_list_fw_profile(&(wrqu->data.length),
9763 extra, WE_MAX_STR_LEN);
9764 break;
9765
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009766 /* The case prints the current state of the HDD, SME, CSR, PE,
9767 * TL it can be extended for WDI Global State as well. And
9768 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
9769 * and P2P_GO have not been added as of now.
9770 */
9771 case WE_GET_STATES:
9772 {
9773 int buf = 0, len = 0;
9774 int adapter_num = 0;
9775 int count = 0, check = 1;
9776
9777 tHalHandle hHal = NULL;
9778 tpAniSirGlobal pMac = NULL;
9779 hdd_station_ctx_t *pHddStaCtx = NULL;
9780
9781 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9782 hdd_adapter_t *useAdapter = NULL;
9783
9784 /* Print wlan0 or p2p0 states based on the adapter_num
9785 * by using the correct adapter
9786 */
9787 while (adapter_num < 2) {
9788 if (WLAN_ADAPTER == adapter_num) {
9789 useAdapter = pAdapter;
9790 buf =
9791 scnprintf(extra + len,
9792 WE_MAX_STR_LEN - len,
9793 "\n\n wlan0 States:-");
9794 len += buf;
9795 } else if (P2P_ADAPTER == adapter_num) {
9796 buf =
9797 scnprintf(extra + len,
9798 WE_MAX_STR_LEN - len,
9799 "\n\n p2p0 States:-");
9800 len += buf;
9801
9802 if (!pHddCtx) {
9803 buf =
9804 scnprintf(extra + len,
9805 WE_MAX_STR_LEN -
9806 len,
9807 "\n pHddCtx is NULL");
9808 len += buf;
9809 break;
9810 }
9811
9812 /* Printing p2p0 states only in the
9813 * case when the device is configured
9814 * as a p2p_client
9815 */
9816 useAdapter =
9817 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08009818 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009819 if (!useAdapter) {
9820 buf =
9821 scnprintf(extra + len,
9822 WE_MAX_STR_LEN -
9823 len,
9824 "\n Device not configured as P2P_CLIENT.");
9825 len += buf;
9826 break;
9827 }
9828 }
9829
9830 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
9831 if (!hHal) {
9832 buf =
9833 scnprintf(extra + len,
9834 WE_MAX_STR_LEN - len,
9835 "\n pMac is NULL");
9836 len += buf;
9837 break;
9838 }
9839 pMac = PMAC_STRUCT(hHal);
9840 if (!pMac) {
9841 buf =
9842 scnprintf(extra + len,
9843 WE_MAX_STR_LEN - len,
9844 "\n pMac is NULL");
9845 len += buf;
9846 break;
9847 }
9848 pHddStaCtx =
9849 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
9850
9851
9852 buf =
9853 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9854 "\n HDD Conn State - %s "
9855 "\n \n SME State:"
9856 "\n Neighbour Roam State - %s"
9857 "\n CSR State - %s"
9858 "\n CSR Substate - %s",
9859 hdd_connection_state_string
9860 (pHddStaCtx->conn_info.connState),
9861 mac_trace_get_neighbour_roam_state
9862 (sme_get_neighbor_roam_state
9863 (hHal, useAdapter->sessionId)),
9864 mac_trace_getcsr_roam_state
9865 (sme_get_current_roam_state
9866 (hHal, useAdapter->sessionId)),
9867 mac_trace_getcsr_roam_sub_state
9868 (sme_get_current_roam_sub_state
9869 (hHal, useAdapter->sessionId))
9870 );
9871 len += buf;
9872 adapter_num++;
9873 }
9874
Mukul Sharma81661ae2015-10-30 20:26:02 +05309875 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009876 /* Printing Lim State starting with global lim states */
9877 buf =
9878 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9879 "\n \n LIM STATES:-"
9880 "\n Global Sme State - %s "
9881 "\n Global mlm State - %s " "\n",
9882 mac_trace_get_lim_sme_state
9883 (sme_get_lim_sme_state(hHal)),
9884 mac_trace_get_lim_mlm_state
9885 (sme_get_lim_sme_state(hHal))
9886 );
9887 len += buf;
9888
9889 /* Printing the PE Sme and Mlm states for valid lim sessions */
9890 while (check < 3 && count < 255) {
9891 if (sme_is_lim_session_valid(hHal, count)) {
9892 buf =
9893 scnprintf(extra + len,
9894 WE_MAX_STR_LEN -
9895 len,
9896 "\n Lim Valid Session %d:-"
9897 "\n PE Sme State - %s "
9898 "\n PE Mlm State - %s "
9899 "\n", check,
9900 mac_trace_get_lim_sme_state
9901 (sme_get_lim_sme_session_state
9902 (hHal, count)),
9903 mac_trace_get_lim_mlm_state
9904 (sme_get_lim_mlm_session_state
9905 (hHal, count))
9906 );
9907
9908 len += buf;
9909 check++;
9910 }
9911 count++;
9912 }
9913 }
9914
9915 wrqu->data.length = strlen(extra) + 1;
9916 break;
9917 }
9918
9919 case WE_GET_CFG:
9920 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009921 hdd_debug("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009922 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
9923 extra,
9924 QCSAP_IOCTL_MAX_STR_LEN);
9925 wrqu->data.length = strlen(extra) + 1;
9926 break;
9927 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009928 case WE_GET_RSSI:
9929 {
9930 int8_t s7Rssi = 0;
9931 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
9932 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
9933 wrqu->data.length = strlen(extra) + 1;
9934 break;
9935 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009936
9937 case WE_GET_WMM_STATUS:
9938 {
9939 snprintf(extra, WE_MAX_STR_LEN,
9940 "\nDir: 0=up, 1=down, 3=both\n"
9941 "|------------------------|\n"
9942 "|AC | ACM |Admitted| Dir |\n"
9943 "|------------------------|\n"
9944 "|VO | %d | %3s | %d |\n"
9945 "|VI | %d | %3s | %d |\n"
9946 "|BE | %d | %3s | %d |\n"
9947 "|BK | %d | %3s | %d |\n"
9948 "|------------------------|\n",
9949 pAdapter->hddWmmStatus.
9950 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
9951 pAdapter->hddWmmStatus.
9952 wmmAcStatus[SME_AC_VO].
9953 wmmAcAccessAllowed ? "YES" : "NO",
9954 pAdapter->hddWmmStatus.
9955 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
9956 ts_info.direction,
9957 pAdapter->hddWmmStatus.
9958 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
9959 pAdapter->hddWmmStatus.
9960 wmmAcStatus[SME_AC_VI].
9961 wmmAcAccessAllowed ? "YES" : "NO",
9962 pAdapter->hddWmmStatus.
9963 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
9964 ts_info.direction,
9965 pAdapter->hddWmmStatus.
9966 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
9967 pAdapter->hddWmmStatus.
9968 wmmAcStatus[SME_AC_BE].
9969 wmmAcAccessAllowed ? "YES" : "NO",
9970 pAdapter->hddWmmStatus.
9971 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
9972 ts_info.direction,
9973 pAdapter->hddWmmStatus.
9974 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
9975 pAdapter->hddWmmStatus.
9976 wmmAcStatus[SME_AC_BK].
9977 wmmAcAccessAllowed ? "YES" : "NO",
9978 pAdapter->hddWmmStatus.
9979 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
9980 ts_info.direction);
9981
9982 wrqu->data.length = strlen(extra) + 1;
9983 break;
9984 }
9985 case WE_GET_CHANNEL_LIST:
9986 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309987 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009988 uint8_t i, len;
9989 char *buf;
9990 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
9991 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
9992 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9993
Srinivas Girigowdac231df62017-03-24 18:27:57 -07009994 struct channel_list_info channel_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009995
9996 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05309997 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009998 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309999 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010000 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010001 return -EINVAL;
10002 }
10003 buf = extra;
10004 /*
10005 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
10006 * Maximum buffer needed = 5 * number of channels.
10007 * Check ifsufficient buffer is available and then
10008 * proceed to fill the buffer.
10009 */
10010 if (WE_MAX_STR_LEN <
10011 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010012 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010013 return -EINVAL;
10014 }
10015 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
10016 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010017 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010018 ubuf, &ubuf_len)) {
10019 /* Printing Country code in getChannelList */
10020 for (i = 0; i < (ubuf_len - 1); i++)
10021 len += scnprintf(buf + len,
10022 WE_MAX_STR_LEN - len,
10023 "%c", ubuf[i]);
10024 }
10025 for (i = 0; i < channel_list.num_channels; i++) {
10026 len +=
10027 scnprintf(buf + len, WE_MAX_STR_LEN - len,
10028 " %u", channel_list.channels[i]);
10029 }
10030 wrqu->data.length = strlen(extra) + 1;
10031
10032 break;
10033 }
10034#ifdef FEATURE_WLAN_TDLS
10035 case WE_GET_TDLS_PEERS:
10036 {
10037 wrqu->data.length =
10038 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
10039 WE_MAX_STR_LEN) + 1;
10040 break;
10041 }
10042#endif
10043#ifdef WLAN_FEATURE_11W
10044 case WE_GET_11W_INFO:
10045 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010046 hdd_debug("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010047 pWextState->roamProfile.MFPEnabled);
10048
10049 snprintf(extra, WE_MAX_STR_LEN,
10050 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
10051 "\n Number of Unprotected Disassocs %d"
10052 "\n Number of Unprotected Deauths %d",
10053 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
10054 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
10055 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
10056 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
10057 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
10058 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
10059 pWextState->roamProfile.MFPEnabled,
10060 pAdapter->hdd_stats.hddPmfStats.
10061 numUnprotDisassocRx,
10062 pAdapter->hdd_stats.hddPmfStats.
10063 numUnprotDeauthRx);
10064
10065 wrqu->data.length = strlen(extra) + 1;
10066 break;
10067 }
10068#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010069 case WE_GET_IBSS_STA_INFO:
10070 {
10071 hdd_station_ctx_t *pHddStaCtx =
10072 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10073 int idx = 0;
10074 int length = 0, buf = 0;
10075
Naveen Rawatc45d1622016-07-05 12:20:09 -070010076 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010077 if (0 != pHddStaCtx->conn_info.staId[idx]) {
10078 buf = snprintf
10079 ((extra + length),
10080 WE_MAX_STR_LEN - length,
10081 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
10082 pHddStaCtx->conn_info.staId[idx],
10083 pHddStaCtx->conn_info.
10084 peerMacAddress[idx].bytes[0],
10085 pHddStaCtx->conn_info.
10086 peerMacAddress[idx].bytes[1],
10087 pHddStaCtx->conn_info.
10088 peerMacAddress[idx].bytes[2],
10089 pHddStaCtx->conn_info.
10090 peerMacAddress[idx].bytes[3],
10091 pHddStaCtx->conn_info.
10092 peerMacAddress[idx].bytes[4],
10093 pHddStaCtx->conn_info.
10094 peerMacAddress[idx].bytes[5]
10095 );
10096 length += buf;
10097 }
10098 }
10099 wrqu->data.length = strlen(extra) + 1;
10100 break;
10101 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010102 case WE_GET_PHYMODE:
10103 {
10104 bool ch_bond24 = false, ch_bond5g = false;
10105 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
10106 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10107 eCsrPhyMode phymode;
10108 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010109 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010110
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010111 sme_config = qdf_mem_malloc(sizeof(*sme_config));
10112 if (!sme_config) {
10113 hdd_err("Out of memory");
10114 ret = -ENOMEM;
10115 break;
10116 }
10117
10118 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010119 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010120 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010121 ch_bond24 = true;
10122
10123 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010124 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010125 ch_bond5g = true;
10126
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010127 qdf_mem_free(sme_config);
10128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010129 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010130 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010131 sme_get_freq_band(hal, &currBand))) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010132 hdd_err("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010133 return -EIO;
10134 }
10135
10136 switch (phymode) {
10137 case eCSR_DOT11_MODE_AUTO:
10138 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
10139 break;
10140 case eCSR_DOT11_MODE_11n:
10141 case eCSR_DOT11_MODE_11n_ONLY:
10142 if (currBand == eCSR_BAND_24) {
10143 if (ch_bond24)
10144 snprintf(extra, WE_MAX_STR_LEN,
10145 "11NGHT40");
10146 else
10147 snprintf(extra, WE_MAX_STR_LEN,
10148 "11NGHT20");
10149 } else if (currBand == eCSR_BAND_5G) {
10150 if (ch_bond5g)
10151 snprintf(extra, WE_MAX_STR_LEN,
10152 "11NAHT40");
10153 else
10154 snprintf(extra, WE_MAX_STR_LEN,
10155 "11NAHT20");
10156 } else {
10157 snprintf(extra, WE_MAX_STR_LEN, "11N");
10158 }
10159 break;
10160 case eCSR_DOT11_MODE_abg:
10161 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
10162 break;
10163 case eCSR_DOT11_MODE_11a:
10164 snprintf(extra, WE_MAX_STR_LEN, "11A");
10165 break;
10166 case eCSR_DOT11_MODE_11b:
10167 case eCSR_DOT11_MODE_11b_ONLY:
10168 snprintf(extra, WE_MAX_STR_LEN, "11B");
10169 break;
10170 case eCSR_DOT11_MODE_11g:
10171 case eCSR_DOT11_MODE_11g_ONLY:
10172 snprintf(extra, WE_MAX_STR_LEN, "11G");
10173 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010174 case eCSR_DOT11_MODE_11ac:
10175 case eCSR_DOT11_MODE_11ac_ONLY:
10176 if (hddctx->config->vhtChannelWidth ==
10177 eHT_CHANNEL_WIDTH_20MHZ)
10178 snprintf(extra, WE_MAX_STR_LEN,
10179 "11ACVHT20");
10180 else if (hddctx->config->vhtChannelWidth ==
10181 eHT_CHANNEL_WIDTH_40MHZ)
10182 snprintf(extra, WE_MAX_STR_LEN,
10183 "11ACVHT40");
10184 else if (hddctx->config->vhtChannelWidth ==
10185 eHT_CHANNEL_WIDTH_80MHZ)
10186 snprintf(extra, WE_MAX_STR_LEN,
10187 "11ACVHT80");
10188 else if (hddctx->config->vhtChannelWidth ==
10189 eHT_CHANNEL_WIDTH_160MHZ)
10190 snprintf(extra, WE_MAX_STR_LEN,
10191 "11ACVHT160");
10192 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080010193 case eCSR_DOT11_MODE_11ax:
10194 case eCSR_DOT11_MODE_11ax_ONLY:
10195 /* currently using vhtChannelWidth */
10196 if (hddctx->config->vhtChannelWidth ==
10197 eHT_CHANNEL_WIDTH_20MHZ)
10198 snprintf(extra, WE_MAX_STR_LEN,
10199 "11AX_HE_20");
10200 else if (hddctx->config->vhtChannelWidth ==
10201 eHT_CHANNEL_WIDTH_40MHZ)
10202 snprintf(extra, WE_MAX_STR_LEN,
10203 "11AX_HE_40");
10204 else if (hddctx->config->vhtChannelWidth ==
10205 eHT_CHANNEL_WIDTH_80MHZ)
10206 snprintf(extra, WE_MAX_STR_LEN,
10207 "11AX_HE_80");
10208 else if (hddctx->config->vhtChannelWidth ==
10209 eHT_CHANNEL_WIDTH_160MHZ)
10210 snprintf(extra, WE_MAX_STR_LEN,
10211 "11AX_HE_160");
10212 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010213 }
10214
10215 wrqu->data.length = strlen(extra) + 1;
10216 break;
10217 }
10218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010219 case WE_GET_OEM_DATA_CAP:
Naveen Rawat910726a2017-03-06 11:42:51 -080010220 return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010221 case WE_GET_SNR:
10222 {
10223 int8_t s7snr = 0;
10224 int status = 0;
10225 hdd_context_t *pHddCtx;
10226 hdd_station_ctx_t *pHddStaCtx;
10227 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10228 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010229 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010230 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010231
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010232 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10233 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
10234 eConnectionState_Associated !=
10235 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010236 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010237 pHddCtx->config->fEnableSNRMonitoring,
10238 pHddStaCtx->conn_info.connState);
10239 return -ENONET;
10240 }
10241 wlan_hdd_get_snr(pAdapter, &s7snr);
10242 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
10243 wrqu->data.length = strlen(extra) + 1;
10244 break;
10245 }
10246 default:
10247 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010248 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010249 sub_cmd);
10250 break;
10251 }
10252 }
Dustin Brownd9322482017-01-09 12:46:03 -080010253
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010254 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -080010255 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010256}
10257
10258static int iw_get_char_setnone(struct net_device *dev,
10259 struct iw_request_info *info,
10260 union iwreq_data *wrqu, char *extra)
10261{
10262 int ret;
10263
10264 cds_ssr_protect(__func__);
10265 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
10266 cds_ssr_unprotect(__func__);
10267
10268 return ret;
10269}
10270
10271/**
10272 * iw_setnone_getnone() - Generic "action" private ioctl handler
10273 * @dev: device upon which the ioctl was received
10274 * @info: ioctl request information
10275 * @wrqu: ioctl request data
10276 * @extra: ioctl extra data
10277 *
10278 * Return: 0 on success, non-zero on error
10279 */
10280static int __iw_setnone_getnone(struct net_device *dev,
10281 struct iw_request_info *info,
10282 union iwreq_data *wrqu, char *extra)
10283{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010284 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010285 hdd_context_t *hdd_ctx;
10286 int ret;
10287 int sub_cmd;
10288
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010289 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010290
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010291 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010292 ret = wlan_hdd_validate_context(hdd_ctx);
10293 if (0 != ret)
10294 return ret;
10295
Jeff Johnson441e1f72017-02-07 08:50:49 -080010296 ret = hdd_check_private_wext_control(hdd_ctx, info);
10297 if (0 != ret)
10298 return ret;
10299
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010300#ifdef CONFIG_COMPAT
10301 /* this ioctl is a special case where a sub-ioctl is used and both
10302 * the number of get and set args is 0. in this specific case the
10303 * logic in iwpriv places the sub_cmd in the data.flags portion of
10304 * the iwreq. unfortunately the location of this field will be
10305 * different between 32-bit and 64-bit userspace, and the standard
10306 * compat support in the kernel does not handle this case. so we
10307 * need to explicitly handle it here.
10308 */
10309 if (is_compat_task()) {
10310 struct compat_iw_point *compat_iw_point =
10311 (struct compat_iw_point *)&wrqu->data;
10312 sub_cmd = compat_iw_point->flags;
10313 } else {
10314 sub_cmd = wrqu->data.flags;
10315 }
10316#else
10317 sub_cmd = wrqu->data.flags;
10318#endif
10319
10320 switch (sub_cmd) {
10321 case WE_GET_RECOVERY_STAT:
10322 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010323 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010324 sme_get_recovery_stats(hal);
10325 break;
10326 }
10327
Govind Singha471e5e2015-10-12 17:11:14 +053010328 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010329 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +053010330 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
10331 0, DBG_CMD);
10332 break;
10333
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010334 case WE_IBSS_GET_PEER_INFO_ALL:
10335 {
10336 hdd_wlan_get_ibss_peer_info_all(adapter);
10337 break;
10338 }
10339
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010340 case WE_SET_REASSOC_TRIGGER:
10341 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010342 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
10343 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010344 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010345 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010346 uint8_t operating_ch =
10347 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010348 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010349
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010350 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010351 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010352 if (roaming_offload_enabled(hdd_ctx)) {
10353 qdf_mem_copy(bssid,
10354 &adapter->sessionCtx.station.conn_info.bssId,
10355 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -080010356 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010357 bssid, operating_ch);
10358 } else {
10359 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
10360 NULL, modProfileFields, &roamId, 1);
10361 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010362 return 0;
10363 }
10364
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010365 case WE_STOP_OBSS_SCAN:
10366 {
10367 /*
10368 * 1.OBSS Scan is mandatory while operating in 2.4GHz
10369 * 2.OBSS scan is stopped by Firmware during the disassociation
10370 * 3.OBSS stop comamnd is added for debugging purpose
10371 */
10372 tHalHandle hal;
10373
10374 hal = WLAN_HDD_GET_HAL_CTX(adapter);
10375 if (hal == NULL) {
10376 hdd_err("hal context is NULL");
10377 return -EINVAL;
10378 }
10379 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
10380 }
10381 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010382 default:
10383 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010384 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010385 break;
10386 }
10387 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010388 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010389 return ret;
10390}
10391
10392static int iw_setnone_getnone(struct net_device *dev,
10393 struct iw_request_info *info,
10394 union iwreq_data *wrqu, char *extra)
10395{
10396 int ret;
10397
10398 cds_ssr_protect(__func__);
10399 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
10400 cds_ssr_unprotect(__func__);
10401
10402 return ret;
10403}
10404
Krunal Sonia6e505b2017-01-12 12:25:18 -080010405#ifdef MPC_UT_FRAMEWORK
10406static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10407 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10408{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -080010409 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010410 case WE_POLICY_MANAGER_CLIST_CMD:
10411 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010412 hdd_debug("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010413 policy_mgr_incr_connection_count_utfw(hdd_ctx->hdd_psoc,
10414 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
10415 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010416 }
10417 break;
10418
10419 case WE_POLICY_MANAGER_DLIST_CMD:
10420 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010421 hdd_debug("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010422 policy_mgr_decr_connection_count_utfw(hdd_ctx->hdd_psoc,
10423 apps_args[0], apps_args[1]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010424 }
10425 break;
10426
10427 case WE_POLICY_MANAGER_ULIST_CMD:
10428 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010429 hdd_debug("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010430 policy_mgr_update_connection_info_utfw(hdd_ctx->hdd_psoc,
10431 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
10432 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010433 }
10434 break;
10435
10436 case WE_POLICY_MANAGER_DBS_CMD:
10437 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010438 hdd_debug("<iwpriv wlan0 pm_dbs> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -080010439 if (apps_args[0] == 0)
10440 wma_set_dbs_capability_ut(0);
10441 else
10442 wma_set_dbs_capability_ut(1);
10443
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010444 if (apps_args[1] >= PM_THROUGHPUT &&
10445 apps_args[1] <= PM_LATENCY) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010446 pr_info("setting system pref to [%d]\n", apps_args[1]);
10447 hdd_ctx->config->conc_system_pref = apps_args[1];
10448 }
10449 }
10450 break;
10451
10452 case WE_POLICY_MANAGER_PCL_CMD:
10453 {
10454 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
10455 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
10456 uint32_t pcl_len = 0, i = 0;
10457
10458 hdd_err("<iwpriv wlan0 pm_pcl> is called");
10459
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010460 policy_mgr_get_pcl(hdd_ctx->hdd_psoc, apps_args[0],
Krunal Sonia6e505b2017-01-12 12:25:18 -080010461 pcl, &pcl_len,
10462 weight_list, QDF_ARRAY_SIZE(weight_list));
10463 pr_info("PCL list for role[%d] is {", apps_args[0]);
10464 for (i = 0 ; i < pcl_len; i++)
10465 pr_info(" %d, ", pcl[i]);
10466 pr_info("}--------->\n");
10467 }
10468 break;
10469
10470 case WE_POLICY_SET_HW_MODE_CMD:
10471 {
10472 if (apps_args[0] == 0) {
10473 hdd_err("set hw mode for single mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010474 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010475 adapter->sessionId,
10476 HW_MODE_SS_2x2,
10477 HW_MODE_80_MHZ,
10478 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
10479 HW_MODE_DBS_NONE,
10480 HW_MODE_AGILE_DFS_NONE,
10481 HW_MODE_SBS_NONE,
10482 SIR_UPDATE_REASON_UT);
10483 } else if (apps_args[0] == 1) {
10484 hdd_err("set hw mode for dual mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010485 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010486 adapter->sessionId,
10487 HW_MODE_SS_1x1,
10488 HW_MODE_80_MHZ,
10489 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
10490 HW_MODE_DBS,
10491 HW_MODE_AGILE_DFS_NONE,
10492 HW_MODE_SBS_NONE,
10493 SIR_UPDATE_REASON_UT);
10494 }
10495 }
10496 break;
10497
10498 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10499 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010500 enum policy_mgr_conc_next_action action;
Krunal Sonia6e505b2017-01-12 12:25:18 -080010501 hdd_notice("<iwpriv wlan0 pm_query_action> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010502 action = policy_mgr_current_connections_update(
10503 hdd_ctx->hdd_psoc,
10504 adapter->sessionId, apps_args[0],
10505 SIR_UPDATE_REASON_UT);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010506 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
10507 }
10508 break;
10509
10510 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10511 {
10512 bool allow;
10513 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010514 allow = policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010515 apps_args[0], apps_args[1], apps_args[2]);
10516 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
10517 }
10518 break;
10519
10520 case WE_POLICY_MANAGER_SCENARIO_CMD:
10521 {
10522 clean_report(hdd_ctx);
10523 if (apps_args[0] == 1) {
10524 wlan_hdd_one_connection_scenario(hdd_ctx);
10525 } else if (apps_args[0] == 2) {
10526 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010527 6, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010528 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010529 36, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010530 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010531 6, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010532 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010533 36, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010534 } else if (apps_args[0] == 3) {
10535 /* MCC on same band with 2x2 same mac*/
10536 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010537 6, 11, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010538 /* MCC on diff band with 2x2 same mac*/
10539 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010540 6, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010541 /* MCC on diff band with 1x1 diff mac */
10542 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010543 36, 6, POLICY_MGR_ONE_ONE, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010544 /* MCC on diff band with 1x1 same mac */
10545 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010546 36, 6, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010547 /* SCC on same band with 2x2 same mac */
10548 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010549 36, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010550 /* SCC on same band with 1x1 same mac */
10551 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010552 36, 36, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010553 /* MCC on same band with 2x2 same mac */
10554 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010555 36, 149, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010556 /* MCC on same band with 1x1 same mac */
10557 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010558 36, 149, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010559 }
10560 print_report(hdd_ctx);
10561 }
10562 break;
10563 }
10564 return 0;
10565}
10566#else
10567static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10568 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10569{
10570 return 0;
10571}
10572#endif
10573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010574/**
10575 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10576 * @dev: device upon which the ioctl was received
10577 * @info: ioctl request information
10578 * @wrqu: ioctl request data
10579 * @extra: ioctl extra data
10580 *
10581 * This is an SSR-protected generic handler for private ioctls which
10582 * take multiple arguments. Note that this implementation is also
10583 * somewhat unique in that it is shared by both STA-mode and SAP-mode
10584 * interfaces.
10585 *
10586 * Return: 0 on success, non-zero on error
10587 */
10588static int __iw_set_var_ints_getnone(struct net_device *dev,
10589 struct iw_request_info *info,
10590 union iwreq_data *wrqu, char *extra)
10591{
10592 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10593 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10594 int sub_cmd;
10595 int *apps_args = (int *) extra;
10596 hdd_context_t *hdd_ctx;
10597 int ret, num_args;
10598
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010599 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010600
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010601 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10602 ret = wlan_hdd_validate_context(hdd_ctx);
10603 if (0 != ret)
10604 return ret;
10605
Jeff Johnson441e1f72017-02-07 08:50:49 -080010606 ret = hdd_check_private_wext_control(hdd_ctx, info);
10607 if (0 != ret)
10608 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010609
10610 sub_cmd = wrqu->data.flags;
10611 num_args = wrqu->data.length;
10612
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010613 hdd_debug("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010614
10615 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010616 case WE_IBSS_GET_PEER_INFO:
10617 {
10618 pr_info("Station ID = %d\n", apps_args[0]);
10619 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
10620 }
10621 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010622
10623 case WE_P2P_NOA_CMD:
10624 {
10625 p2p_app_setP2pPs_t p2pNoA;
10626
Krunal Sonif07bb382016-03-10 13:02:11 -080010627 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -080010628 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
10629 hdd_device_mode_to_string(
10630 pAdapter->device_mode),
10631 pAdapter->device_mode);
10632 return -EINVAL;
10633 }
10634
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010635 p2pNoA.opp_ps = apps_args[0];
10636 p2pNoA.ctWindow = apps_args[1];
10637 p2pNoA.duration = apps_args[2];
10638 p2pNoA.interval = apps_args[3];
10639 p2pNoA.count = apps_args[4];
10640 p2pNoA.single_noa_duration = apps_args[5];
10641 p2pNoA.psSelection = apps_args[6];
10642
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010643 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 -070010644 apps_args[0], apps_args[1], apps_args[2],
10645 apps_args[3], apps_args[4],
10646 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010647
10648 hdd_set_p2p_ps(dev, &p2pNoA);
10649
10650 }
10651 break;
10652
10653 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
10654 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010655 hdd_debug("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
Jeff Johnson99bac312016-06-28 10:38:18 -070010656 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010657 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010658 }
10659 break;
10660
10661 case WE_MTRACE_DUMP_CMD:
10662 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010663 hdd_debug("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
Jeff Johnson99bac312016-06-28 10:38:18 -070010664 apps_args[0], apps_args[1],
10665 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010666 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010667 apps_args[1], apps_args[2],
10668 apps_args[3]);
10669
10670 }
10671 break;
10672
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010673 case WE_POLICY_MANAGER_CINFO_CMD:
10674 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010675 struct policy_mgr_conc_connection_info *conn_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010676 uint32_t i = 0, len = 0;
10677
Krunal Sonia6e505b2017-01-12 12:25:18 -080010678 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010679 conn_info = policy_mgr_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010680 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010681 for (i = 0; i < len; i++) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010682 pr_info("|table_index[%d]\t\t\n", i);
10683 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
10684 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
10685 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
10686 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
10687 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
10688 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
10689 pr_info("+--------------------------+\n");
10690 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010691 }
10692 }
10693 break;
10694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010695
10696#ifdef FEATURE_WLAN_TDLS
10697 case WE_TDLS_CONFIG_PARAMS:
10698 {
10699 tdls_config_params_t tdlsParams;
10700
10701 tdlsParams.tdls = apps_args[0];
10702 tdlsParams.tx_period_t = apps_args[1];
10703 tdlsParams.tx_packet_n = apps_args[2];
10704 /* ignore args[3] as discovery_period is not used anymore */
10705 tdlsParams.discovery_tries_n = apps_args[4];
10706 /* ignore args[5] as idle_timeout is not used anymore */
10707 tdlsParams.idle_packet_n = apps_args[6];
10708 /* ignore args[7] as rssi_hysteresis is not used anymore */
10709 tdlsParams.rssi_trigger_threshold = apps_args[8];
10710 tdlsParams.rssi_teardown_threshold = apps_args[9];
10711 tdlsParams.rssi_delta = apps_args[10];
10712
10713 wlan_hdd_tdls_set_params(dev, &tdlsParams);
10714 }
10715 break;
10716#endif
10717 case WE_UNIT_TEST_CMD:
10718 {
10719 t_wma_unit_test_cmd *unitTestArgs;
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010720 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010721 int i, j;
10722 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
10723 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010724 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010725 apps_args[0]);
10726 return -EINVAL;
10727 }
Anurag Chouhan77564182016-09-03 16:38:01 +053010728 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
10729 (apps_args[1] < 0)) {
10730 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010731 apps_args[1]);
10732 return -EINVAL;
10733 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010734 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010735 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010736 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010737 return -ENOMEM;
10738 }
10739 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
10740 unitTestArgs->module_id = apps_args[0];
10741 unitTestArgs->num_args = apps_args[1];
10742 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
10743 unitTestArgs->args[i] = apps_args[j];
10744 }
10745 msg.type = SIR_HAL_UNIT_TEST_CMD;
10746 msg.reserved = 0;
10747 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010748 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010749 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010750 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -070010751 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010752 return -EINVAL;
10753 }
10754 }
10755 break;
10756#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
10757 case WE_LED_FLASHING_PARAM:
10758 {
10759 int i;
10760 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010761 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010762 return -EINVAL;
10763 }
10764 for (i = 0; i < num_args; i++) {
10765 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010766 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010767 return -EINVAL;
10768 }
10769 }
10770 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10771 0, apps_args[0], apps_args[1]);
10772 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10773 1, apps_args[2], apps_args[3]);
10774 }
10775 break;
10776#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010777 case WE_SET_PKTLOG:
10778 {
10779 int ret;
10780
10781 if (num_args < 1 || num_args > 2) {
10782 hdd_err("pktlog: either 1 or 2 parameters are required");
10783 return -EINVAL;
10784 }
10785
10786 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
10787 apps_args[1]);
10788 if (ret)
10789 return ret;
10790 break;
10791 }
10792
Manjeet Singhf82ed072016-07-08 11:40:00 +053010793 case WE_MAC_PWR_DEBUG_CMD:
10794 {
10795 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
10796 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10797 int i, j;
10798
10799 if (num_args < 3) {
10800 hdd_err("number of arguments can't be null %d",
10801 num_args);
10802 return -EINVAL;
10803 }
10804 if (num_args - 3 != apps_args[2]) {
10805 hdd_err("arg list of size %d doesn't match num_args %d",
10806 num_args-3, apps_args[2]);
10807 return -EINVAL;
10808 }
10809 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
10810 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
10811 hdd_err("Invalid MODULE ID %d", apps_args[1]);
10812 return -EINVAL;
10813 }
10814 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
10815 hdd_err("Too Many args %d", apps_args[2]);
10816 return -EINVAL;
10817 }
10818 mac_pwr_dbg_args.pdev_id = apps_args[0];
10819 mac_pwr_dbg_args.module_id = apps_args[1];
10820 mac_pwr_dbg_args.num_args = apps_args[2];
10821
10822 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
10823 mac_pwr_dbg_args.args[i] = apps_args[j];
10824
10825 if (QDF_STATUS_SUCCESS !=
10826 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
10827 &mac_pwr_dbg_args)) {
10828 return -EINVAL;
10829 }
10830 }
10831 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -080010832 case WE_POLICY_MANAGER_CLIST_CMD:
10833 case WE_POLICY_MANAGER_DLIST_CMD:
10834 case WE_POLICY_MANAGER_ULIST_CMD:
10835 case WE_POLICY_MANAGER_DBS_CMD:
10836 case WE_POLICY_MANAGER_PCL_CMD:
10837 case WE_POLICY_SET_HW_MODE_CMD:
10838 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10839 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10840 case WE_POLICY_MANAGER_SCENARIO_CMD:
10841 {
10842 iw_get_policy_manager_ut_ops(hdd_ctx, pAdapter,
10843 sub_cmd, apps_args);
10844 }
10845 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010846 default:
10847 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010848 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010849 }
10850 break;
10851 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010852 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010853 return 0;
10854}
10855
10856/**
10857 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
10858 * @dev: pointer to net_device structure
10859 * @info: pointer to iw_request_info structure
10860 * @wrqu: pointer to iwreq_data
10861 * @extra; extra
10862 *
10863 * Return: 0 on success, error number otherwise
10864 *
10865 */
10866static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
10867 struct iw_request_info *info,
10868 union iwreq_data *wrqu, char *extra)
10869{
10870 union iwreq_data u_priv_wrqu;
10871 int apps_args[MAX_VAR_ARGS] = {0};
10872 int ret, num_args;
10873
Mukul Sharma64a70e82015-11-02 20:05:09 +053010874 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010875 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +053010876 return -EPERM;
10877 }
10878
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010879 /* Helper function to get iwreq_data with compat handling. */
10880 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
10881 return -EINVAL;
10882
10883 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010884 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010885 return -EINVAL;
10886 }
10887
10888 num_args = u_priv_wrqu.data.length;
10889 if (num_args > MAX_VAR_ARGS)
10890 num_args = MAX_VAR_ARGS;
10891
10892 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
10893 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010894 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010895 return -EFAULT;
10896 }
10897
10898 cds_ssr_protect(__func__);
10899 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
10900 (char *)&apps_args);
10901 cds_ssr_unprotect(__func__);
10902 return ret;
10903}
10904
10905/**
10906 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10907 * @dev: device upon which the ioctl was received
10908 * @info: ioctl request information
10909 * @wrqu: ioctl request data
10910 * @extra: ioctl extra data
10911 *
10912 * This is a generic handler for private ioctls which take multiple
10913 * arguments. Note that this implementation is also somewhat unique
10914 * in that it is shared by both STA-mode and SAP-mode interfaces.
10915 *
10916 * Return: 0 on success, non-zero on error
10917 */
10918int iw_set_var_ints_getnone(struct net_device *dev,
10919 struct iw_request_info *info,
10920 union iwreq_data *wrqu, char *extra)
10921{
10922 int ret;
10923
10924 cds_ssr_protect(__func__);
10925 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
10926 cds_ssr_unprotect(__func__);
10927 return ret;
10928}
10929
10930/**
10931 * iw_add_tspec - Add TSpec private ioctl handler
10932 * @dev: device upon which the ioctl was received
10933 * @info: ioctl request information
10934 * @wrqu: ioctl request data
10935 * @extra: ioctl extra data
10936 *
10937 * Return: 0 on success, non-zero on error
10938 */
10939static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
10940 union iwreq_data *wrqu, char *extra)
10941{
10942 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10943 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10944 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
10945 int params[HDD_WLAN_WMM_PARAM_COUNT];
10946 sme_QosWmmTspecInfo tSpec;
10947 uint32_t handle;
10948 struct iw_point s_priv_data;
10949 hdd_context_t *hdd_ctx;
10950 int ret;
10951
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010952 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010953
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010954 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10955 ret = wlan_hdd_validate_context(hdd_ctx);
10956 if (0 != ret)
10957 return ret;
10958
Jeff Johnson441e1f72017-02-07 08:50:49 -080010959 ret = hdd_check_private_wext_control(hdd_ctx, info);
10960 if (0 != ret)
10961 return ret;
10962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010963 /* make sure the application is sufficiently priviledged */
10964 /* note that the kernel will do this for "set" ioctls, but since */
10965 /* this ioctl wants to return status to user space it must be */
10966 /* defined as a "get" ioctl */
10967 if (!capable(CAP_NET_ADMIN)) {
10968 return -EPERM;
10969 }
10970
10971 /* we must be associated in order to add a tspec */
10972 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
10973 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10974 return 0;
10975 }
10976 /* since we are defined to be a "get" ioctl, and since the number */
10977 /* of params exceeds the number of params that wireless extensions */
10978 /* will pass down in the iwreq_data, we must copy the "set" params. */
10979 /* We must handle the compat for iwreq_data in 32U/64K environment. */
10980
10981 /* helper function to get iwreq_data with compat handling. */
10982 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
10983 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10984 return 0;
10985 }
10986 /* make sure all params are correctly passed to function */
10987 if ((NULL == s_priv_data.pointer) ||
10988 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
10989 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10990 return 0;
10991 }
10992 /* from user space ourselves */
10993 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
10994 /* hmmm, can't get them */
10995 return -EIO;
10996 }
10997 /* clear the tspec */
10998 memset(&tSpec, 0, sizeof(tSpec));
10999
11000 /* validate the handle */
11001 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11002 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11003 /* that one is reserved */
11004 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11005 return 0;
11006 }
11007 /* validate the TID */
11008 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
11009 /* out of range */
11010 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11011 return 0;
11012 }
11013 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
11014
11015 /* validate the direction */
11016 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
11017 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
11018 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
11019 break;
11020
11021 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
11022 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
11023 break;
11024
11025 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
11026 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
11027 break;
11028
11029 default:
11030 /* unknown */
11031 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11032 return 0;
11033 }
11034
11035 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
11036
11037 /* validate the user priority */
11038 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
11039 /* out of range */
11040 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11041 return 0;
11042 }
11043 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
11044 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011045 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011046 return 0;
11047 }
11048
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011049 hdd_debug("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011050 tSpec.ts_info.psb, tSpec.ts_info.up);
11051
11052 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
11053 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
11054 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
11055 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
11056 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
11057 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
11058 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
11059 tSpec.surplus_bw_allowance =
11060 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
11061 tSpec.min_service_interval =
11062 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
11063 tSpec.max_service_interval =
11064 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
11065 tSpec.suspension_interval =
11066 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
11067 tSpec.inactivity_interval =
11068 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
11069
11070 tSpec.ts_info.burst_size_defn =
11071 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
11072
11073 /* validate the ts info ack policy */
11074 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
11075 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
11076 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
11077 break;
11078
11079 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
11080 tSpec.ts_info.ack_policy =
11081 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
11082 break;
11083
11084 default:
11085 /* unknown */
11086 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11087 return 0;
11088 }
11089
11090 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011091 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011092 return 0;
11093}
11094
11095static int iw_add_tspec(struct net_device *dev,
11096 struct iw_request_info *info,
11097 union iwreq_data *wrqu, char *extra)
11098{
11099 int ret;
11100
11101 cds_ssr_protect(__func__);
11102 ret = __iw_add_tspec(dev, info, wrqu, extra);
11103 cds_ssr_unprotect(__func__);
11104
11105 return ret;
11106}
11107
11108/**
11109 * iw_del_tspec - Delete TSpec private ioctl handler
11110 * @dev: device upon which the ioctl was received
11111 * @info: ioctl request information
11112 * @wrqu: ioctl request data
11113 * @extra: ioctl extra data
11114 *
11115 * Return: 0 on success, non-zero on error
11116 */
11117static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
11118 union iwreq_data *wrqu, char *extra)
11119{
11120 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11121 hdd_context_t *hdd_ctx;
11122 int *params = (int *)extra;
11123 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11124 uint32_t handle;
11125 int ret;
11126
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011127 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011129 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11130 ret = wlan_hdd_validate_context(hdd_ctx);
11131 if (0 != ret)
11132 return ret;
11133
Jeff Johnson441e1f72017-02-07 08:50:49 -080011134 ret = hdd_check_private_wext_control(hdd_ctx, info);
11135 if (0 != ret)
11136 return ret;
11137
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011138 /* make sure the application is sufficiently priviledged */
11139 /* note that the kernel will do this for "set" ioctls, but since */
11140 /* this ioctl wants to return status to user space it must be */
11141 /* defined as a "get" ioctl */
11142 if (!capable(CAP_NET_ADMIN)) {
11143 return -EPERM;
11144 }
11145
11146 /* although we are defined to be a "get" ioctl, the params we require */
11147 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11148 /* is no need to copy the params from user space */
11149
11150 /* validate the handle */
11151 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11152 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11153 /* that one is reserved */
11154 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11155 return 0;
11156 }
11157
11158 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011159 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011160 return 0;
11161}
11162
11163static int iw_del_tspec(struct net_device *dev,
11164 struct iw_request_info *info,
11165 union iwreq_data *wrqu, char *extra)
11166{
11167 int ret;
11168
11169 cds_ssr_protect(__func__);
11170 ret = __iw_del_tspec(dev, info, wrqu, extra);
11171 cds_ssr_unprotect(__func__);
11172
11173 return ret;
11174}
11175
11176/**
11177 * iw_get_tspec - Get TSpec private ioctl handler
11178 * @dev: device upon which the ioctl was received
11179 * @info: ioctl request information
11180 * @wrqu: ioctl request data
11181 * @extra: ioctl extra data
11182 *
11183 * Return: 0 on success, non-zero on error
11184 */
11185static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
11186 union iwreq_data *wrqu, char *extra)
11187{
11188 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11189 hdd_context_t *hdd_ctx;
11190 int *params = (int *)extra;
11191 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11192 uint32_t handle;
11193 int ret;
11194
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011195 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011196
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011197 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11198 ret = wlan_hdd_validate_context(hdd_ctx);
11199 if (0 != ret)
11200 return ret;
11201
Jeff Johnson441e1f72017-02-07 08:50:49 -080011202 ret = hdd_check_private_wext_control(hdd_ctx, info);
11203 if (0 != ret)
11204 return ret;
11205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011206 /* although we are defined to be a "get" ioctl, the params we require */
11207 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11208 /* is no need to copy the params from user space */
11209
11210 /* validate the handle */
11211 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11212 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11213 /* that one is reserved */
11214 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11215 return 0;
11216 }
11217
11218 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011219 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011220 return 0;
11221}
11222
11223static int iw_get_tspec(struct net_device *dev,
11224 struct iw_request_info *info,
11225 union iwreq_data *wrqu, char *extra)
11226{
11227 int ret;
11228
11229 cds_ssr_protect(__func__);
11230 ret = __iw_get_tspec(dev, info, wrqu, extra);
11231 cds_ssr_unprotect(__func__);
11232
11233 return ret;
11234}
11235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011236/**
11237 * iw_set_fties - Set FT IEs private ioctl handler
11238 * @dev: device upon which the ioctl was received
11239 * @info: ioctl request information
11240 * @wrqu: ioctl request data
11241 * @extra: ioctl extra data
11242 *
11243 * Each time the supplicant has the auth_request or reassoc request
11244 * IEs ready they are pushed to the driver. The driver will in turn
11245 * use it to send out the auth req and reassoc req for 11r FT Assoc.
11246 *
11247 * Return: 0 on success, non-zero on error
11248 */
11249static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
11250 union iwreq_data *wrqu, char *extra)
11251{
11252 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11253 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11254 hdd_context_t *hdd_ctx;
11255 int ret;
11256
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011257 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011258
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011259 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11260 ret = wlan_hdd_validate_context(hdd_ctx);
11261 if (0 != ret)
11262 return ret;
11263
Jeff Johnson441e1f72017-02-07 08:50:49 -080011264 ret = hdd_check_private_wext_control(hdd_ctx, info);
11265 if (0 != ret)
11266 return ret;
11267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011268 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011269 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011270 return -EINVAL;
11271 }
11272 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011273 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011274 return -EINVAL;
11275 }
11276 /* Added for debug on reception of Re-assoc Req. */
11277 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011278 hdd_debug("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011279 wrqu->data.length);
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011280 hdd_debug("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011281 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011282 hdd_debug("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011283
11284 /* Pass the received FT IEs to SME */
11285 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
11286 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011287 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011288 return 0;
11289}
11290
11291static int iw_set_fties(struct net_device *dev,
11292 struct iw_request_info *info,
11293 union iwreq_data *wrqu, char *extra)
11294{
11295 int ret;
11296
11297 cds_ssr_protect(__func__);
11298 ret = __iw_set_fties(dev, info, wrqu, extra);
11299 cds_ssr_unprotect(__func__);
11300
11301 return ret;
11302}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011303
Dustin Brown0cbc7572016-12-16 13:54:40 -080011304/**
11305 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
11306 * @dev: device upon which the ioctl was received
11307 * @info: ioctl request information
11308 * @wrqu: ioctl request data
11309 * @extra: ioctl extra data
11310 *
Dustin Brown860566f2017-01-31 15:24:43 -080011311 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
11312 * time being to provide guidance in migrating to standard APIs.
11313 *
Dustin Brown0cbc7572016-12-16 13:54:40 -080011314 * Return: 0 on success, non-zero on error
11315 */
11316static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
11317 struct iw_request_info *info,
11318 union iwreq_data *wrqu,
11319 char *extra)
11320{
Dustin Brown860566f2017-01-31 15:24:43 -080011321 hdd_err("\n"
11322 "setMCBCFilter is obsolete. Use the following instead:\n"
11323 "Configure multicast filtering via the ‘ip’ command.\n"
11324 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
11325 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
11326 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
11327 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
11328 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Mukul Sharma3ba26b82017-01-12 21:59:41 +053011329 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -080011330}
11331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011332/**
11333 * iw_set_host_offload - Set host offload ioctl handler
11334 * @dev: device upon which the ioctl was received
11335 * @info: ioctl request information
11336 * @wrqu: ioctl request data
11337 * @extra: ioctl extra data
11338 *
11339 * Return: 0 on success, non-zero on error
11340 */
11341static int __iw_set_host_offload(struct net_device *dev,
11342 struct iw_request_info *info,
11343 union iwreq_data *wrqu, char *extra)
11344{
11345 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11346 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
11347 tSirHostOffloadReq offloadRequest;
11348 hdd_context_t *hdd_ctx;
11349 int ret;
11350
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011351 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011352
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011353 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11354 ret = wlan_hdd_validate_context(hdd_ctx);
11355 if (0 != ret)
11356 return ret;
11357
Jeff Johnson441e1f72017-02-07 08:50:49 -080011358 ret = hdd_check_private_wext_control(hdd_ctx, info);
11359 if (0 != ret)
11360 return ret;
11361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011362 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011363 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011364 return -EINVAL;
11365 }
11366
11367 /* Debug display of request components. */
11368 switch (pRequest->offloadType) {
11369 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011370 hdd_debug("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011371 switch (pRequest->enableOrDisable) {
11372 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011373 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011374 break;
11375 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011376 hdd_debug(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011377 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011378 hdd_debug(" ARP offload enable");
11379 hdd_debug(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011380 pRequest->params.hostIpv4Addr[0],
11381 pRequest->params.hostIpv4Addr[1],
11382 pRequest->params.hostIpv4Addr[2],
11383 pRequest->params.hostIpv4Addr[3]);
11384 }
11385 break;
11386
11387 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011388 hdd_debug("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011389 switch (pRequest->enableOrDisable) {
11390 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011391 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011392 break;
11393 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011394 hdd_debug(" enable");
11395 hdd_debug(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011396 *(uint16_t *) (pRequest->params.hostIpv6Addr),
11397 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11398 2),
11399 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11400 4),
11401 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11402 6),
11403 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11404 8),
11405 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11406 10),
11407 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11408 12),
11409 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11410 14));
11411 }
11412 }
11413
11414 /* Execute offload request. The reason that we can copy the
11415 * request information from the ioctl structure to the SME
11416 * structure is that they are laid out exactly the same.
11417 * Otherwise, each piece of information would have to be
11418 * copied individually.
11419 */
11420 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011421 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011422 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
11423 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011424 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011425 return -EINVAL;
11426 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011427 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011428 return 0;
11429}
11430
11431static int iw_set_host_offload(struct net_device *dev,
11432 struct iw_request_info *info,
11433 union iwreq_data *wrqu, char *extra)
11434{
11435 int ret;
11436
11437 cds_ssr_protect(__func__);
11438 ret = __iw_set_host_offload(dev, info, wrqu, extra);
11439 cds_ssr_unprotect(__func__);
11440
11441 return ret;
11442}
11443
11444/**
11445 * iw_set_keepalive_params - Set keepalive params ioctl handler
11446 * @dev: device upon which the ioctl was received
11447 * @info: ioctl request information
11448 * @wrqu: ioctl request data
11449 * @extra: ioctl extra data
11450 *
11451 * Return: 0 on success, non-zero on error
11452 */
11453static int __iw_set_keepalive_params(struct net_device *dev,
11454 struct iw_request_info *info,
11455 union iwreq_data *wrqu, char *extra)
11456{
11457 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011458 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011459 hdd_context_t *hdd_ctx;
11460 int ret;
11461
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011462 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011464 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11465 ret = wlan_hdd_validate_context(hdd_ctx);
11466 if (0 != ret)
11467 return ret;
11468
Jeff Johnson441e1f72017-02-07 08:50:49 -080011469 ret = hdd_check_private_wext_control(hdd_ctx, info);
11470 if (0 != ret)
11471 return ret;
11472
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011473 if (wrqu->data.length != sizeof(*request)) {
11474 hdd_err("Invalid length %d", wrqu->data.length);
11475 return -EINVAL;
11476 }
11477
11478 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
11479 hdd_err("Value of timePeriod %d exceed Max limit %d",
11480 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011481 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
11482 return -EINVAL;
11483 }
11484
11485 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011486 hdd_debug("Set Keep Alive Request : TimePeriod %d size %zu",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011487 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011488
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011489 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011490 case WLAN_KEEP_ALIVE_NULL_PKT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011491 hdd_debug("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011492 break;
11493
11494 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011495 hdd_debug("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011496
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011497 hdd_debug("Host IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011498 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
11499 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011500
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011501 hdd_debug("Dest IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011502 request->destIpv4Addr[0], request->destIpv4Addr[1],
11503 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011504
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011505 hdd_debug("Dest MAC address: "MAC_ADDRESS_STR,
Srinivas Girigowda9c330a92015-11-24 12:28:25 -080011506 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011507 break;
11508 }
11509
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011510 hdd_debug("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011511
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011512 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011513 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011514 pAdapter->sessionId, request)) {
11515 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011516 return -EINVAL;
11517 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011518 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011519 return 0;
11520}
11521
11522static int iw_set_keepalive_params(struct net_device *dev,
11523 struct iw_request_info *info,
11524 union iwreq_data *wrqu,
11525 char *extra)
11526{
11527 int ret;
11528
11529 cds_ssr_protect(__func__);
11530 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
11531 cds_ssr_unprotect(__func__);
11532
11533 return ret;
11534}
11535
11536#ifdef WLAN_FEATURE_PACKET_FILTERING
11537/**
11538 * wlan_hdd_set_filter() - Set packet filter
11539 * @hdd_ctx: Global HDD context
11540 * @request: Packet filter request struct
11541 * @sessionId: Target session for the request
11542 *
11543 * Return: 0 on success, non-zero on error
11544 */
11545static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
11546 struct pkt_filter_cfg *request,
11547 uint8_t sessionId)
11548{
11549 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
11550 tSirRcvFltPktClearParam packetFilterClrReq = {0};
11551 int i = 0;
11552
11553 if (hdd_ctx->config->disablePacketFilter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011554 hdd_warn("Packet filtering disabled in ini");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011555 return 0;
11556 }
11557
11558 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011559 hdd_debug("Packet Filter Request : FA %d params %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011560 request->filter_action, request->num_params);
11561
11562 switch (request->filter_action) {
11563 case HDD_RCV_FILTER_SET:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011564 hdd_debug("Set Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011565 request->filter_id);
11566
11567 packetFilterSetReq.filterId = request->filter_id;
11568 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
11569 hdd_err("Number of Params exceed Max limit %d",
11570 request->num_params);
11571 return -EINVAL;
11572 }
11573 packetFilterSetReq.numFieldParams = request->num_params;
11574 packetFilterSetReq.coalesceTime = 0;
11575 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
11576 for (i = 0; i < request->num_params; i++) {
11577 packetFilterSetReq.paramsData[i].protocolLayer =
11578 request->params_data[i].protocol_layer;
11579 packetFilterSetReq.paramsData[i].cmpFlag =
11580 request->params_data[i].compare_flag;
11581 packetFilterSetReq.paramsData[i].dataOffset =
11582 request->params_data[i].data_offset;
11583 packetFilterSetReq.paramsData[i].dataLength =
11584 request->params_data[i].data_length;
11585 packetFilterSetReq.paramsData[i].reserved = 0;
11586
Dustin Brown4d1e8462016-12-14 12:12:24 -080011587 if (request->params_data[i].data_offset >
11588 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
11589 hdd_err("Invalid data offset %u for param %d (max = %d)",
11590 request->params_data[i].data_offset,
11591 i,
11592 SIR_MAX_FILTER_TEST_DATA_OFFSET);
11593 return -EINVAL;
11594 }
11595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011596 if (request->params_data[i].data_length >
11597 SIR_MAX_FILTER_TEST_DATA_LEN) {
11598 hdd_err("Error invalid data length %d",
11599 request->params_data[i].data_length);
11600 return -EINVAL;
11601 }
11602
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011603 hdd_debug("Proto %d Comp Flag %d Filter Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011604 request->params_data[i].protocol_layer,
11605 request->params_data[i].compare_flag,
11606 packetFilterSetReq.filterType);
11607
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011608 hdd_debug("Data Offset %d Data Len %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011609 request->params_data[i].data_offset,
11610 request->params_data[i].data_length);
11611
Rajeev Kumarf5b6da22016-04-15 13:24:03 -070011612 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
11613 < (request->params_data[i].data_length)) {
11614 hdd_err("Error invalid data length %d",
11615 request->params_data[i].data_length);
11616 return -EINVAL;
11617 }
11618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011619 memcpy(&packetFilterSetReq.paramsData[i].compareData,
11620 request->params_data[i].compare_data,
11621 request->params_data[i].data_length);
11622 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
11623 request->params_data[i].data_mask,
11624 request->params_data[i].data_length);
11625
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011626 hdd_debug("CData %d CData %d CData %d CData %d CData %d CData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011627 request->params_data[i].compare_data[0],
11628 request->params_data[i].compare_data[1],
11629 request->params_data[i].compare_data[2],
11630 request->params_data[i].compare_data[3],
11631 request->params_data[i].compare_data[4],
11632 request->params_data[i].compare_data[5]);
11633
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011634 hdd_debug("MData %d MData %d MData %d MData %d MData %d MData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011635 request->params_data[i].data_mask[0],
11636 request->params_data[i].data_mask[1],
11637 request->params_data[i].data_mask[2],
11638 request->params_data[i].data_mask[3],
11639 request->params_data[i].data_mask[4],
11640 request->params_data[i].data_mask[5]);
11641 }
11642
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011643 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011644 sme_receive_filter_set_filter(hdd_ctx->hHal,
11645 &packetFilterSetReq,
11646 sessionId)) {
11647 hdd_err("Failure to execute Set Filter");
11648 return -EINVAL;
11649 }
11650
11651 break;
11652
11653 case HDD_RCV_FILTER_CLEAR:
11654
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011655 hdd_debug("Clear Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011656 request->filter_id);
11657 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011658 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011659 sme_receive_filter_clear_filter(hdd_ctx->hHal,
11660 &packetFilterClrReq,
11661 sessionId)) {
11662 hdd_err("Failure to execute Clear Filter");
11663 return -EINVAL;
11664 }
11665 break;
11666
11667 default:
11668 hdd_err("Packet Filter Request: Invalid %d",
11669 request->filter_action);
11670 return -EINVAL;
11671 }
11672 return 0;
11673}
11674
11675/**
11676 * __iw_set_packet_filter_params() - set packet filter parameters in target
11677 * @dev: Pointer to netdev
11678 * @info: Pointer to iw request info
11679 * @wrqu: Pointer to data
11680 * @extra: Pointer to extra data
11681 *
11682 * Return: 0 on success, non-zero on error
11683 */
11684static int __iw_set_packet_filter_params(struct net_device *dev,
11685 struct iw_request_info *info,
11686 union iwreq_data *wrqu, char *extra)
11687{
11688 int ret;
11689 hdd_context_t *hdd_ctx;
11690 struct iw_point priv_data;
11691 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
11692 struct pkt_filter_cfg *request = NULL;
11693
Mukul Sharma472382f2015-11-02 20:16:31 +053011694 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011695 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +053011696 return -EPERM;
11697 }
11698
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011699 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011700
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011701 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11702 ret = wlan_hdd_validate_context(hdd_ctx);
11703 if (0 != ret)
11704 return ret;
11705
Jeff Johnson441e1f72017-02-07 08:50:49 -080011706 ret = hdd_check_private_wext_control(hdd_ctx, info);
11707 if (0 != ret)
11708 return ret;
11709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011710 if (hdd_priv_get_data(&priv_data, wrqu)) {
11711 hdd_err("failed to get priv data");
11712 return -EINVAL;
11713 }
11714
11715 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
11716 hdd_err("invalid priv data %p or invalid priv data length %d",
11717 priv_data.pointer, priv_data.length);
11718 return -EINVAL;
11719 }
11720
11721 /* copy data using copy_from_user */
11722 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
11723 priv_data.length);
11724 if (NULL == request) {
11725 hdd_err("mem_alloc_copy_from_user_helper fail");
11726 return -ENOMEM;
11727 }
11728
11729 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
11730
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -070011731 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011732 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011733 return ret;
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
11751 cds_ssr_protect(__func__);
11752 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
11753 cds_ssr_unprotect(__func__);
11754
11755 return ret;
11756}
11757#endif
11758
11759
11760static int __iw_get_statistics(struct net_device *dev,
11761 struct iw_request_info *info,
11762 union iwreq_data *wrqu, char *extra)
11763{
11764
Anurag Chouhance0dc992016-02-16 18:18:03 +053011765 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011766 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011767 hdd_wext_state_t *pWextState;
11768 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11769 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11770 char *p = extra;
11771 int tlen = 0;
11772 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
11773 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
11774 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
11775 int ret;
11776
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011777 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011778
11779 ret = wlan_hdd_validate_context(hdd_ctx);
11780 if (0 != ret)
11781 return ret;
11782
Jeff Johnson441e1f72017-02-07 08:50:49 -080011783 ret = hdd_check_private_wext_control(hdd_ctx, info);
11784 if (0 != ret)
11785 return ret;
11786
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011787 if (eConnectionState_Associated !=
11788 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
11789
11790 wrqu->txpower.value = 0;
11791 } else {
11792 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11793 SME_SUMMARY_STATS |
11794 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080011795 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011796 hdd_statistics_cb, 0, false,
11797 (WLAN_HDD_GET_STATION_CTX_PTR
11798 (pAdapter))->conn_info.staId[0],
11799 pAdapter, pAdapter->sessionId);
11800
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011801 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011802 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011803 return -EINVAL;
11804 }
11805
11806 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11807
Anurag Chouhance0dc992016-02-16 18:18:03 +053011808 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011809 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011810 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011811 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011812 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011813 /*Remove the SME statistics list by passing NULL in callback argument */
11814 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11815 SME_SUMMARY_STATS |
11816 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080011817 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011818 NULL, 0, false,
11819 (WLAN_HDD_GET_STATION_CTX_PTR
11820 (pAdapter))->conn_info.
11821 staId[0], pAdapter,
11822 pAdapter->sessionId);
11823
11824 return -EINVAL;
11825 }
11826 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
11827 (uint8_t) sizeof(pStats->retry_cnt),
11828 (char *)&(pStats->retry_cnt[0]), tlen);
11829
11830 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
11831 (uint8_t) sizeof(pStats->multiple_retry_cnt),
11832 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
11833
11834 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
11835 (uint8_t) sizeof(pStats->tx_frm_cnt),
11836 (char *)&(pStats->tx_frm_cnt[0]), tlen);
11837
11838 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
11839 (uint8_t) sizeof(pStats->rx_frm_cnt),
11840 (char *)&(pStats->rx_frm_cnt), tlen);
11841
11842 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
11843 (uint8_t) sizeof(pStats->frm_dup_cnt),
11844 (char *)&(pStats->frm_dup_cnt), tlen);
11845
11846 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
11847 (uint8_t) sizeof(pStats->fail_cnt),
11848 (char *)&(pStats->fail_cnt[0]), tlen);
11849
11850 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
11851 (uint8_t) sizeof(pStats->rts_fail_cnt),
11852 (char *)&(pStats->rts_fail_cnt), tlen);
11853
11854 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
11855 (uint8_t) sizeof(pStats->ack_fail_cnt),
11856 (char *)&(pStats->ack_fail_cnt), tlen);
11857
11858 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
11859 (uint8_t) sizeof(pStats->rts_succ_cnt),
11860 (char *)&(pStats->rts_succ_cnt), tlen);
11861
11862 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
11863 (uint8_t) sizeof(pStats->rx_discard_cnt),
11864 (char *)&(pStats->rx_discard_cnt), tlen);
11865
11866 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
11867 (uint8_t) sizeof(pStats->rx_error_cnt),
11868 (char *)&(pStats->rx_error_cnt), tlen);
11869
11870 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
11871 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11872 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11873
11874 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
11875 (uint8_t) sizeof(dStats->rx_byte_cnt),
11876 (char *)&(dStats->rx_byte_cnt), tlen);
11877
11878 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
11879 (uint8_t) sizeof(dStats->rx_rate),
11880 (char *)&(dStats->rx_rate), tlen);
11881
11882 /* Transmit rate, in units of 500 kbit/sec */
11883 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
11884 (uint8_t) sizeof(aStats->tx_rate),
11885 (char *)&(aStats->tx_rate), tlen);
11886
11887 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
11888 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
11889 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
11890 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
11891 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
11892 (char *)&(dStats->rx_mc_byte_cnt), tlen);
11893 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
11894 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
11895 (char *)&(dStats->rx_bc_byte_cnt), tlen);
11896 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
11897 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11898 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11899 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
11900 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
11901 (char *)&(dStats->tx_mc_byte_cnt), tlen);
11902 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
11903 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
11904 (char *)&(dStats->tx_bc_byte_cnt), tlen);
11905
11906 wrqu->data.length = tlen;
11907
11908 }
11909
11910 EXIT();
11911
11912 return 0;
11913}
11914
11915static int iw_get_statistics(struct net_device *dev,
11916 struct iw_request_info *info,
11917 union iwreq_data *wrqu, char *extra)
11918{
11919 int ret;
11920
11921 cds_ssr_protect(__func__);
11922 ret = __iw_get_statistics(dev, info, wrqu, extra);
11923 cds_ssr_unprotect(__func__);
11924
11925 return ret;
11926}
11927
11928#ifdef FEATURE_WLAN_SCAN_PNO
11929
11930/*Max Len for PNO notification*/
11931#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011932static void found_pref_network_cb(void *callbackContext,
11933 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011934{
11935 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
11936 union iwreq_data wrqu;
11937 char buf[MAX_PNO_NOTIFY_LEN + 1];
11938
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011939 hdd_debug("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011940 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
11941
11942 /* create the event */
11943 memset(&wrqu, 0, sizeof(wrqu));
11944 memset(buf, 0, sizeof(buf));
11945
11946 snprintf(buf, MAX_PNO_NOTIFY_LEN,
11947 "QCOM: Found preferred network: %s with RSSI of -%u",
11948 pPrefNetworkFoundInd->ssId.ssId,
11949 (unsigned int)pPrefNetworkFoundInd->rssi);
11950
11951 wrqu.data.pointer = buf;
11952 wrqu.data.length = strlen(buf);
11953
11954 /* send the event */
11955
11956 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
11957
11958}
11959
11960/**
11961 * __iw_set_pno() - Preferred Network Offload ioctl handler
11962 * @dev: device upon which the ioctl was received
11963 * @info: ioctl request information
11964 * @wrqu: ioctl request data
11965 * @extra: ioctl extra data
11966 *
11967 * This function parses a Preferred Network Offload command
11968 * Input is string based and expected to be of the form:
11969 *
11970 * <enable(1) | disable(0)>
11971 * when enabling:
11972 * <number of networks>
11973 * for each network:
11974 * <ssid_len> <ssid> <authentication> <encryption>
11975 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070011976 * <scan_time (seconds)>
11977 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011978 * <suspend mode>
11979 *
11980 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070011981 * 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 -080011982 *
11983 * this translates into:
11984 * -----------------------------
11985 * enable PNO
11986 * 2 networks
11987 * Network 1:
11988 * test - with authentication type 0 and encryption type 0,
11989 * search on 3 channels: 1 6 and 11,
11990 * SSID bcast type is unknown (directed probe will be sent if
11991 * AP not found) and must meet -40dBm RSSI
11992 * Network 2:
11993 * test2 - with authentication type 4 and encryption type 4,
11994 * search on 6 channels 1, 2, 3, 4, 5 and 6
11995 * bcast type is non-bcast (directed probe will be sent)
11996 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011997 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070011998 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011999 */
12000static int __iw_set_pno(struct net_device *dev,
12001 struct iw_request_info *info,
12002 union iwreq_data *wrqu, char *extra)
12003{
12004 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12005 hdd_context_t *hdd_ctx;
12006 int ret;
12007 int offset;
12008 char *ptr;
12009 uint8_t i, j, params, mode;
12010
12011 /* request is a large struct, so we make it static to avoid
12012 * stack overflow. This API is only invoked via ioctl, so it
12013 * is serialized by the kernel rtnl_lock and hence does not
12014 * need to be reentrant
12015 */
12016 static tSirPNOScanReq request;
12017
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012018 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012019
12020 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12021 ret = wlan_hdd_validate_context(hdd_ctx);
12022 if (ret)
12023 return ret;
12024
Jeff Johnson441e1f72017-02-07 08:50:49 -080012025 ret = hdd_check_private_wext_control(hdd_ctx, info);
12026 if (0 != ret)
12027 return ret;
12028
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012029 hdd_debug("PNO data len %d data %s", wrqu->data.length, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012030
12031 request.enable = 0;
12032 request.ucNetworksCount = 0;
12033
12034 ptr = extra;
12035
12036 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
12037 hdd_err("PNO enable input is not valid %s", ptr);
12038 return -EINVAL;
12039 }
12040
12041 if (0 == request.enable) {
12042 /* Disable PNO, ignore any other params */
12043 memset(&request, 0, sizeof(request));
12044 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
12045 &request, adapter->sessionId,
12046 found_pref_network_cb, adapter);
12047 return 0;
12048 }
12049
12050 ptr += offset;
12051
12052 if (1 !=
12053 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
12054 hdd_err("PNO count input not valid %s", ptr);
12055 return -EINVAL;
12056
12057 }
12058
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012059 hdd_debug("PNO enable %d networks count %d offset %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012060 request.enable, request.ucNetworksCount, offset);
12061
12062 if ((0 == request.ucNetworksCount) ||
12063 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
12064 hdd_err("Network count %d invalid",
12065 request.ucNetworksCount);
12066 return -EINVAL;
12067 }
12068
12069 ptr += offset;
12070
12071 for (i = 0; i < request.ucNetworksCount; i++) {
12072
12073 request.aNetworks[i].ssId.length = 0;
12074
12075 params = sscanf(ptr, "%hhu %n",
12076 &(request.aNetworks[i].ssId.length),
12077 &offset);
12078
12079 if (1 != params) {
12080 hdd_err("PNO ssid length input is not valid %s", ptr);
12081 return -EINVAL;
12082 }
12083
12084 if ((0 == request.aNetworks[i].ssId.length) ||
12085 (request.aNetworks[i].ssId.length > 32)) {
12086 hdd_err("SSID Len %d is not correct for network %d",
12087 request.aNetworks[i].ssId.length, i);
12088 return -EINVAL;
12089 }
12090
12091 /* Advance to SSID */
12092 ptr += offset;
12093
12094 memcpy(request.aNetworks[i].ssId.ssId, ptr,
12095 request.aNetworks[i].ssId.length);
12096 ptr += request.aNetworks[i].ssId.length;
12097
12098 params = sscanf(ptr, "%u %u %hhu %n",
12099 &(request.aNetworks[i].authentication),
12100 &(request.aNetworks[i].encryption),
12101 &(request.aNetworks[i].ucChannelCount),
12102 &offset);
12103
12104 if (3 != params) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012105 hdd_err("Incorrect cmd %s", ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012106 return -EINVAL;
12107 }
12108
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012109 hdd_debug("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012110 request.aNetworks[i].ssId.length,
12111 request.aNetworks[i].ssId.length,
12112 request.aNetworks[i].ssId.ssId,
12113 request.aNetworks[i].authentication,
12114 request.aNetworks[i].encryption,
12115 request.aNetworks[i].ucChannelCount, offset);
12116
12117 /* Advance to channel list */
12118 ptr += offset;
12119
12120 if (SIR_PNO_MAX_NETW_CHANNELS <
12121 request.aNetworks[i].ucChannelCount) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012122 hdd_err("Incorrect number of channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012123 return -EINVAL;
12124 }
12125
12126 if (0 != request.aNetworks[i].ucChannelCount) {
12127 for (j = 0; j < request.aNetworks[i].ucChannelCount;
12128 j++) {
12129 if (1 !=
12130 sscanf(ptr, "%hhu %n",
12131 &(request.aNetworks[i].
12132 aChannels[j]), &offset)) {
12133 hdd_err("PNO network channel input is not valid %s",
12134 ptr);
12135 return -EINVAL;
12136 }
12137 /* Advance to next channel number */
12138 ptr += offset;
12139 }
12140 }
12141
12142 if (1 != sscanf(ptr, "%u %n",
12143 &(request.aNetworks[i].bcastNetwType),
12144 &offset)) {
12145 hdd_err("PNO broadcast network type input is not valid %s",
12146 ptr);
12147 return -EINVAL;
12148 }
12149
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012150 hdd_debug("PNO bcastNetwType %d offset %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012151 request.aNetworks[i].bcastNetwType, offset);
12152
12153 /* Advance to rssi Threshold */
12154 ptr += offset;
12155 if (1 != sscanf(ptr, "%d %n",
12156 &(request.aNetworks[i].rssiThreshold),
12157 &offset)) {
12158 hdd_err("PNO rssi threshold input is not valid %s",
12159 ptr);
12160 return -EINVAL;
12161 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012162 hdd_debug("PNO rssi %d offset %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012163 request.aNetworks[i].rssiThreshold, offset);
12164 /* Advance to next network */
12165 ptr += offset;
12166 } /* For ucNetworkCount */
12167
Dustin Brown43e87292016-10-10 10:38:25 -070012168 request.fast_scan_period = 0;
12169 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
12170 request.fast_scan_period *= MSEC_PER_SEC;
12171 ptr += offset;
12172 }
12173
12174 request.fast_scan_max_cycles = 0;
12175 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
12176 &offset) > 0)
12177 ptr += offset;
12178
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012179 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
12180
12181 request.modePNO = mode;
12182 /* for LA we just expose suspend option */
12183 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
12184 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
12185 }
12186
12187 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
12188 &request,
12189 adapter->sessionId,
12190 found_pref_network_cb, adapter);
12191
12192 return 0;
12193}
12194
12195static int iw_set_pno(struct net_device *dev,
12196 struct iw_request_info *info,
12197 union iwreq_data *wrqu, char *extra)
12198{
12199 int ret;
12200
12201 cds_ssr_protect(__func__);
12202 ret = __iw_set_pno(dev, info, wrqu, extra);
12203 cds_ssr_unprotect(__func__);
12204
12205 return ret;
12206}
12207#endif /* FEATURE_WLAN_SCAN_PNO */
12208
12209/* Common function to SetBand */
12210int hdd_set_band(struct net_device *dev, u8 ui_band)
12211{
12212 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12213 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12214 eCsrBand band;
12215
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012216 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012217 hdd_context_t *pHddCtx;
12218 hdd_adapter_list_node_t *pAdapterNode, *pNext;
12219 eCsrBand currBand = eCSR_BAND_MAX;
12220 eCsrBand connectedBand;
12221
12222 pAdapterNode = NULL;
12223 pNext = NULL;
12224 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12225
12226 switch (ui_band) {
12227 case WLAN_HDD_UI_BAND_AUTO:
12228 band = eCSR_BAND_ALL;
12229 break;
12230 case WLAN_HDD_UI_BAND_5_GHZ:
12231 band = eCSR_BAND_5G;
12232 break;
12233 case WLAN_HDD_UI_BAND_2_4_GHZ:
12234 band = eCSR_BAND_24;
12235 break;
12236 default:
12237 band = eCSR_BAND_MAX;
12238 }
12239
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012240 hdd_debug("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012241
12242 if (band == eCSR_BAND_MAX) {
12243 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -070012244 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012245 return -EINVAL;
12246 }
12247
12248 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
12249 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012250 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012251 band, pHddCtx->config->nBandCapability);
12252 return -EIO;
12253 }
12254
12255 if (band == eCSR_BAND_ALL) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012256 hdd_debug("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012257 pHddCtx->config->nBandCapability);
12258 band = pHddCtx->config->nBandCapability;
12259 }
12260
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012261 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012262 hdd_debug("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012263 return -EIO;
12264 }
12265
12266 if (currBand != band) {
12267 /* Change band request received.
12268 * Abort pending scan requests, flush the existing scan results,
12269 * and change the band capability
12270 */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012271 hdd_debug("Current band value = %u, new setting %u ",
Jeff Johnson99bac312016-06-28 10:38:18 -070012272 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012273
12274 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012275 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012276 pAdapter = pAdapterNode->pAdapter;
12277 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12278 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053012279 INVALID_SCAN_ID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012280 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
12281 connectedBand =
12282 hdd_conn_get_connected_band
12283 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
12284
12285 /* Handling is done only for STA and P2P */
12286 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -080012287 ((pAdapter->device_mode == QDF_STA_MODE)
12288 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012289 &&
12290 (hdd_conn_is_connected
12291 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
12292 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012293 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012294 long lrc;
12295
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012296 /* STA already connected on current
12297 * band, So issue disconnect first,
12298 * then change the band
12299 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012300
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012301 hdd_debug("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012302 hdd_device_mode_to_string(pAdapter->device_mode),
12303 pAdapter->device_mode, currBand, band);
12304 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12305
12306 status =
12307 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
12308 (pAdapter),
12309 pAdapter->sessionId,
12310 eCSR_DISCONNECT_REASON_UNSPECIFIED);
12311
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012312 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012313 hdd_err("csr_roam_disconnect failure, returned %d",
12314 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012315 return -EINVAL;
12316 }
12317
12318 lrc =
12319 wait_for_completion_timeout(&pAdapter->
12320 disconnect_comp_var,
12321 msecs_to_jiffies
12322 (WLAN_WAIT_TIME_DISCONNECT));
12323
12324 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012325 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012326 return -ETIMEDOUT;
12327 }
12328 }
12329
12330 sme_scan_flush_result(hHal);
12331
12332 status =
12333 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
12334 pAdapterNode = pNext;
12335 }
12336
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012337 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012338 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012339 hdd_err("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012340 band);
12341 return -EINVAL;
12342 }
12343 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
12344 }
12345 return 0;
12346}
12347
12348int hdd_set_band_helper(struct net_device *dev, const char *command)
12349{
12350 uint8_t band;
12351 int ret;
12352
12353 /* Convert the band value from ascii to integer */
12354 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
12355 ret = kstrtou8(command, 10, &band);
12356 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012357 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012358 return -EINVAL;
12359 }
12360
12361 return hdd_set_band(dev, band);
12362}
12363
12364static int __iw_set_band_config(struct net_device *dev,
12365 struct iw_request_info *info,
12366 union iwreq_data *wrqu, char *extra)
12367{
Jeff Johnson441e1f72017-02-07 08:50:49 -080012368 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12369 hdd_context_t *hdd_ctx;
12370 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012371 int *value = (int *)extra;
12372
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012373 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012374
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012375 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012376 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012377 return -EPERM;
12378 }
12379
Jeff Johnson441e1f72017-02-07 08:50:49 -080012380 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12381 ret = hdd_check_private_wext_control(hdd_ctx, info);
12382 if (0 != ret)
12383 return ret;
12384
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012385 return hdd_set_band(dev, value[0]);
12386}
12387
12388static int iw_set_band_config(struct net_device *dev,
12389 struct iw_request_info *info,
12390 union iwreq_data *wrqu, char *extra)
12391{
12392 int ret;
12393
12394 cds_ssr_protect(__func__);
12395 ret = __iw_set_band_config(dev, info, wrqu, extra);
12396 cds_ssr_unprotect(__func__);
12397
12398 return ret;
12399}
12400
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012401/**
12402 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
12403 * @adapter: Handle to adapter
12404 * @chan: Monitor mode channel
12405 * @bandwidth: Capture channel bandwidth
12406 *
12407 * Return: 0 on success else error code.
12408 */
12409static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
12410 uint32_t bandwidth)
12411{
12412 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12413 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
12414 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
12415 QDF_STATUS status;
12416 tHalHandle hal_hdl = hdd_ctx->hHal;
12417 struct qdf_mac_addr bssid;
12418 tCsrRoamProfile roam_profile;
12419 struct ch_params_s ch_params;
12420
12421 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
12422 hdd_err("Not supported, device is not in monitor mode");
12423 return -EINVAL;
12424 }
12425
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012426 hdd_debug("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080012427 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012428 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
12429 roam_profile.ChannelInfo.numOfChannels = 1;
12430 roam_profile.phyMode = ch_info->phy_mode;
12431 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070012432 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012433
12434 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
12435 QDF_MAC_ADDR_SIZE);
12436
12437 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -070012438 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakashc4dc9382017-03-07 18:50:33 -080012439 if (ch_params.ch_width == CH_WIDTH_INVALID) {
12440 hdd_err("Invalid capture channel or bandwidth for a country");
12441 return -EINVAL;
12442 }
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012443 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
12444 &roam_profile);
12445 if (status) {
12446 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
12447 status);
12448 }
12449
12450 return qdf_status_to_os_return(status);
12451}
12452
Dustin Brown8d2d0f52017-04-03 17:02:08 -070012453static int printk_adapter(void *priv, const char *fmt, ...)
12454{
12455 int ret;
12456 va_list args;
12457
12458 va_start(args, fmt);
12459 ret = vprintk(fmt, args);
12460 ret += printk("\n");
12461 va_end(args);
12462
12463 return ret;
12464}
12465
12466#ifdef WMI_INTERFACE_EVENT_LOGGING
12467static void hdd_ioctl_log_buffer(int log_id, uint32_t count)
12468{
12469 qdf_abstract_print *print = &printk_adapter;
12470
12471 switch (log_id) {
12472 case HTC_CREDIT_HISTORY_LOG:
12473 print(NULL, "HTC Credit History (count %u)", count);
12474 cds_print_htc_credit_history(count, print, NULL);
12475 break;
12476 case COMMAND_LOG:
12477 print(NULL, "Command Log (count %u)", count);
12478 wma_print_wmi_cmd_log(count, print, NULL);
12479 break;
12480 case COMMAND_TX_CMP_LOG:
12481 print(NULL, "Command Tx Complete Log (count %u)", count);
12482 wma_print_wmi_cmd_tx_cmp_log(count, print, NULL);
12483 break;
12484 case MGMT_COMMAND_LOG:
12485 print(NULL, "Management Command Log (count %u)", count);
12486 wma_print_wmi_mgmt_cmd_log(count, print, NULL);
12487 break;
12488 case MGMT_COMMAND_TX_CMP_LOG:
12489 print(NULL, "Management Command Tx Complete Log (count %u)",
12490 count);
12491 wma_print_wmi_mgmt_cmd_tx_cmp_log(count, print, NULL);
12492 break;
12493 case EVENT_LOG:
12494 print(NULL, "Event Log (count %u)", count);
12495 wma_print_wmi_event_log(count, print, NULL);
12496 break;
12497 case RX_EVENT_LOG:
12498 print(NULL, "Rx Event Log (count %u)", count);
12499 wma_print_wmi_rx_event_log(count, print, NULL);
12500 break;
12501 case MGMT_EVENT_LOG:
12502 print(NULL, "Management Event Log (count %u)", count);
12503 wma_print_wmi_mgmt_event_log(count, print, NULL);
12504 break;
12505 default:
12506 print(NULL, "Invalid Log Id %d", log_id);
12507 break;
12508 }
12509}
12510#else
12511static inline void hdd_ioctl_log_buffer(int log_id, uint32_t count)
12512{
12513}
12514#endif /* WMI_INTERFACE_EVENT_LOGGING */
12515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012516static int __iw_set_two_ints_getnone(struct net_device *dev,
12517 struct iw_request_info *info,
12518 union iwreq_data *wrqu, char *extra)
12519{
12520 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12521 int *value = (int *)extra;
12522 int sub_cmd = value[0];
12523 int ret;
12524 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
12525
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012526 ENTER_DEV(dev);
12527
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012528 ret = wlan_hdd_validate_context(hdd_ctx);
12529 if (0 != ret)
12530 return ret;
12531
Jeff Johnson441e1f72017-02-07 08:50:49 -080012532 ret = hdd_check_private_wext_control(hdd_ctx, info);
12533 if (0 != ret)
12534 return ret;
12535
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012536 switch (sub_cmd) {
12537 case WE_SET_SMPS_PARAM:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012538 hdd_debug("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012539 ret = wma_cli_set_command(pAdapter->sessionId,
12540 WMI_STA_SMPS_PARAM_CMDID,
12541 value[1] << WMA_SMPS_PARAM_VALUE_S
12542 | value[2],
12543 VDEV_CMD);
12544 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070012545#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012546 case WE_SET_FW_CRASH_INJECT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012547 hdd_debug("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012548 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053012549 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
12550 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012551 ret = wma_cli_set2_command(pAdapter->sessionId,
12552 GEN_PARAM_CRASH_INJECT,
12553 value[1], value[2], GEN_CMD);
12554 break;
12555#endif
Govind Singha471e5e2015-10-12 17:11:14 +053012556 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070012557 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012558 value[1], value[2]);
12559 ret = wma_cli_set2_command(pAdapter->sessionId,
12560 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
12561 value[1], value[2], DBG_CMD);
12562 break;
12563 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070012564 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012565 value[1], value[2]);
12566 ret = wma_cli_set2_command(pAdapter->sessionId,
12567 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
12568 value[1], value[2], DBG_CMD);
12569 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012570 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
12571 hdd_debug("Ioctl to set dual fw mode config");
12572 if (hdd_ctx->config->dual_mac_feature_disable) {
12573 hdd_err("Dual mac feature is disabled from INI");
12574 return -EPERM;
12575 }
12576 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080012577 policy_mgr_set_dual_mac_fw_mode_config(hdd_ctx->hdd_psoc,
12578 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012579 break;
12580 case WE_DUMP_DP_TRACE_LEVEL:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012581 hdd_debug("WE_DUMP_DP_TRACE_LEVEL: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012582 value[1], value[2]);
12583 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012584 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053012585 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
12586 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053012587 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
12588 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012589 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012590 case WE_SET_MON_MODE_CHAN:
12591 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
12592 break;
Dustin Brown54096432017-02-23 13:00:44 -080012593 case WE_SET_WLAN_SUSPEND: {
Dustin Brown3ed3e9b2017-03-23 12:57:58 -070012594 hdd_info("STA unit-test suspend(%d, %d)", value[1], value[2]);
Dustin Brown54096432017-02-23 13:00:44 -080012595 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
12596 value[1], value[2]);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012597 break;
Dustin Brown54096432017-02-23 13:00:44 -080012598 }
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012599 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070012600 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012601 break;
Dustin Brown8d2d0f52017-04-03 17:02:08 -070012602 case WE_LOG_BUFFER: {
12603 int log_id = value[1];
12604 uint32_t count = value[2] < 0 ? 0 : value[2];
12605
12606 hdd_ioctl_log_buffer(log_id, count);
12607
12608 break;
12609 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012610 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070012611 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012612 break;
12613 }
12614
12615 return ret;
12616}
12617
12618static int iw_set_two_ints_getnone(struct net_device *dev,
12619 struct iw_request_info *info,
12620 union iwreq_data *wrqu, char *extra)
12621{
12622 int ret;
12623
12624 cds_ssr_protect(__func__);
12625 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
12626 cds_ssr_unprotect(__func__);
12627
12628 return ret;
12629}
12630
12631/* Define the Wireless Extensions to the Linux Network Device structure */
12632/* A number of these routines are NULL (meaning they are not implemented.) */
12633
12634static const iw_handler we_handler[] = {
12635 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
12636 (iw_handler) iw_get_name, /* SIOCGIWNAME */
12637 (iw_handler) NULL, /* SIOCSIWNWID */
12638 (iw_handler) NULL, /* SIOCGIWNWID */
12639 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
12640 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
12641 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
12642 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
12643 (iw_handler) NULL, /* SIOCSIWSENS */
12644 (iw_handler) NULL, /* SIOCGIWSENS */
12645 (iw_handler) NULL, /* SIOCSIWRANGE */
12646 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
12647 (iw_handler) NULL, /* SIOCSIWPRIV */
12648 (iw_handler) NULL, /* SIOCGIWPRIV */
12649 (iw_handler) NULL, /* SIOCSIWSTATS */
12650 (iw_handler) NULL, /* SIOCGIWSTATS */
12651 (iw_handler) NULL, /* SIOCSIWSPY */
12652 (iw_handler) NULL, /* SIOCGIWSPY */
12653 (iw_handler) NULL, /* SIOCSIWTHRSPY */
12654 (iw_handler) NULL, /* SIOCGIWTHRSPY */
12655 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
12656 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
12657 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
12658 (iw_handler) NULL, /* SIOCGIWAPLIST */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012659#ifndef NAPIER_SCAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012660 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
12661 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012662#else
12663 (iw_handler) NULL, /* SIOCSIWSCAN */
12664 (iw_handler) NULL, /* SIOCGIWSCAN */
12665#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012666 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
12667 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
12668 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
12669 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
12670 (iw_handler) NULL, /* -- hole -- */
12671 (iw_handler) NULL, /* -- hole -- */
12672 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
12673 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
12674 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
12675 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
12676 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
12677 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
12678 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
12679 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
12680 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
12681 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
12682 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
12683 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
12684 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
12685 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
12686 (iw_handler) NULL, /* -- hole -- */
12687 (iw_handler) NULL, /* -- hole -- */
12688 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
12689 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
12690 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
12691 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
12692 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
12693 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
12694 (iw_handler) NULL, /* SIOCSIWPMKSA */
12695};
12696
12697static const iw_handler we_private[] = {
12698
12699 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
12700 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
12701 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
12702 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12703 iw_set_three_ints_getnone,
12704 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
12705 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
12706 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12707 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070012708 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
12709 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012710 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
12711 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
12712 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012713 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012714 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
12715 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
12716 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
12717 iw_set_keepalive_params,
12718#ifdef WLAN_FEATURE_PACKET_FILTERING
12719 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
12720 iw_set_packet_filter_params,
12721#endif
12722#ifdef FEATURE_WLAN_SCAN_PNO
12723 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
12724#endif
12725 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080012726 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
12727 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012728 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
12729 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12730 iw_set_two_ints_getnone,
12731 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
12732 iw_set_dot11p_channel_sched,
12733};
12734
12735/*Maximum command length can be only 15 */
12736static const struct iw_priv_args we_private_args[] = {
12737
12738 /* handlers for main ioctl */
12739 {WLAN_PRIV_SET_INT_GET_NONE,
12740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12741 0,
12742 ""},
12743
12744 /* handlers for sub-ioctl */
12745 {WE_SET_11D_STATE,
12746 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12747 0,
12748 "set11Dstate"},
12749
12750 {WE_WOWL,
12751 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12752 0,
12753 "wowl"},
12754
12755 {WE_SET_POWER,
12756 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12757 0,
12758 "setPower"},
12759
12760 {WE_SET_MAX_ASSOC,
12761 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12762 0,
12763 "setMaxAssoc"},
12764
12765 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
12766 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
12767 "setAutoChannel" },
12768
12769 {WE_SET_SCAN_DISABLE,
12770 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12771 0,
12772 "scan_disable"},
12773
12774 {WE_SET_DATA_INACTIVITY_TO,
12775 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12776 0,
12777 "inactivityTO"},
12778
12779 {WE_SET_MAX_TX_POWER,
12780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12781 0,
12782 "setMaxTxPower"},
12783
12784 {WE_SET_TX_POWER,
12785 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12786 0,
12787 "setTxPower"},
12788
12789 {WE_SET_MC_RATE,
12790 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12791 0,
12792 "setMcRate"},
12793
12794 {WE_SET_MAX_TX_POWER_2_4,
12795 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12796 0,
12797 "setTxMaxPower2G"},
12798
12799 {WE_SET_MAX_TX_POWER_5_0,
12800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12801 0,
12802 "setTxMaxPower5G"},
12803
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012804 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012805 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012806 0,
12807 "pktlog"},
12808
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012809 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
12810 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012811 * will support both
12812 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012813 {WE_SET_MAX_TX_POWER,
12814 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12815 0,
12816 "setTxMaxPower"},
12817
12818 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012819 * 1 = enable and 0 = disable
12820 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012821 {
12822 WE_SET_HIGHER_DTIM_TRANSITION,
12823 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12824 0,
12825 "setHDtimTransn"
12826 },
12827
12828 {WE_SET_TM_LEVEL,
12829 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12830 0,
12831 "setTmLevel"},
12832
12833 {WE_SET_PHYMODE,
12834 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12835 0,
12836 "setphymode"},
12837
12838 {WE_SET_NSS,
12839 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12840 0,
12841 "nss"},
12842
12843 {WE_SET_LDPC,
12844 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12845 0,
12846 "ldpc"},
12847
12848 {WE_SET_TX_STBC,
12849 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12850 0,
12851 "tx_stbc"},
12852
12853 {WE_SET_RX_STBC,
12854 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12855 0,
12856 "rx_stbc"},
12857
12858 {WE_SET_SHORT_GI,
12859 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12860 0,
12861 "shortgi"},
12862
12863 {WE_SET_RTSCTS,
12864 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12865 0,
12866 "enablertscts"},
12867
12868 {WE_SET_CHWIDTH,
12869 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12870 0,
12871 "chwidth"},
12872
12873 {WE_SET_ANI_EN_DIS,
12874 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12875 0,
12876 "anienable"},
12877
12878 {WE_SET_ANI_POLL_PERIOD,
12879 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12880 0,
12881 "aniplen"},
12882
12883 {WE_SET_ANI_LISTEN_PERIOD,
12884 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12885 0,
12886 "anilislen"},
12887
12888 {WE_SET_ANI_OFDM_LEVEL,
12889 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12890 0,
12891 "aniofdmlvl"},
12892
12893 {WE_SET_ANI_CCK_LEVEL,
12894 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12895 0,
12896 "aniccklvl"},
12897
12898 {WE_SET_DYNAMIC_BW,
12899 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12900 0,
12901 "cwmenable"},
12902
12903 {WE_SET_CTS_CBW,
12904 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12905 0,
12906 "cts_cbw" },
12907
12908 {WE_SET_GTX_HT_MCS,
12909 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12910 0,
12911 "gtxHTMcs"},
12912
12913 {WE_SET_GTX_VHT_MCS,
12914 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12915 0,
12916 "gtxVHTMcs"},
12917
12918 {WE_SET_GTX_USRCFG,
12919 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12920 0,
12921 "gtxUsrCfg"},
12922
12923 {WE_SET_GTX_THRE,
12924 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12925 0,
12926 "gtxThre"},
12927
12928 {WE_SET_GTX_MARGIN,
12929 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12930 0,
12931 "gtxMargin"},
12932
12933 {WE_SET_GTX_STEP,
12934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12935 0,
12936 "gtxStep"},
12937
12938 {WE_SET_GTX_MINTPC,
12939 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12940 0,
12941 "gtxMinTpc"},
12942
12943 {WE_SET_GTX_BWMASK,
12944 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12945 0,
12946 "gtxBWMask"},
12947
12948 {WE_SET_TX_CHAINMASK,
12949 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12950 0,
12951 "txchainmask"},
12952
12953 {WE_SET_RX_CHAINMASK,
12954 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12955 0,
12956 "rxchainmask"},
12957
12958 {WE_SET_11N_RATE,
12959 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12960 0,
12961 "set11NRates"},
12962
12963 {WE_SET_VHT_RATE,
12964 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12965 0,
12966 "set11ACRates"},
12967
12968 {WE_SET_AMPDU,
12969 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12970 0,
12971 "ampdu"},
12972
12973 {WE_SET_AMSDU,
12974 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12975 0,
12976 "amsdu"},
12977
12978 {WE_SET_BURST_ENABLE,
12979 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12980 0,
12981 "burst_enable"},
12982
12983 {WE_SET_BURST_DUR,
12984 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12985 0,
12986 "burst_dur"},
12987
12988 {WE_SET_TXPOW_2G,
12989 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12990 0,
12991 "txpow2g"},
12992
12993 {WE_SET_TXPOW_5G,
12994 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12995 0,
12996 "txpow5g"},
12997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012998 /* Sub-cmds DBGLOG specific commands */
12999 {WE_DBGLOG_LOG_LEVEL,
13000 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13001 0,
13002 "dl_loglevel"},
13003
13004 {WE_DBGLOG_VAP_ENABLE,
13005 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13006 0,
13007 "dl_vapon"},
13008
13009 {WE_DBGLOG_VAP_DISABLE,
13010 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13011 0,
13012 "dl_vapoff"},
13013
13014 {WE_DBGLOG_MODULE_ENABLE,
13015 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13016 0,
13017 "dl_modon"},
13018
13019 {WE_DBGLOG_MODULE_DISABLE,
13020 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13021 0,
13022 "dl_modoff"},
13023
13024 {WE_DBGLOG_MOD_LOG_LEVEL,
13025 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13026 0,
13027 "dl_mod_loglevel"},
13028
13029 {WE_DBGLOG_TYPE,
13030 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13031 0,
13032 "dl_type"},
13033 {WE_DBGLOG_REPORT_ENABLE,
13034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13035 0,
13036 "dl_report"},
13037
13038 {WE_SET_TXRX_FWSTATS,
13039 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13040 0,
13041 "txrx_fw_stats"},
13042
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080013043 {WE_SET_TXRX_STATS,
13044 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13045 0,
13046 "txrx_stats"},
13047
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013048 {WE_TXRX_FWSTATS_RESET,
13049 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13050 0,
13051 "txrx_fw_st_rst"},
13052
13053 {WE_PPS_PAID_MATCH,
13054 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13055 0, "paid_match"},
13056
13057 {WE_PPS_GID_MATCH,
13058 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13059 0, "gid_match"},
13060
13061 {WE_PPS_EARLY_TIM_CLEAR,
13062 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13063 0, "tim_clear"},
13064
13065 {WE_PPS_EARLY_DTIM_CLEAR,
13066 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13067 0, "dtim_clear"},
13068
13069 {WE_PPS_EOF_PAD_DELIM,
13070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13071 0, "eof_delim"},
13072
13073 {WE_PPS_MACADDR_MISMATCH,
13074 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13075 0, "mac_match"},
13076
13077 {WE_PPS_DELIM_CRC_FAIL,
13078 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13079 0, "delim_fail"},
13080
13081 {WE_PPS_GID_NSTS_ZERO,
13082 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13083 0, "nsts_zero"},
13084
13085 {WE_PPS_RSSI_CHECK,
13086 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13087 0, "rssi_chk"},
13088
13089 {WE_PPS_5G_EBT,
13090 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13091 0, "5g_ebt"},
13092
13093 {WE_SET_HTSMPS,
13094 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13095 0, "htsmps"},
13096
13097 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
13098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13099 0, "set_qpspollcnt"},
13100
13101 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
13102 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13103 0, "set_qtxwake"},
13104
13105 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13106 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13107 0, "set_qwakeintv"},
13108
13109 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13110 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13111 0, "set_qnodatapoll"},
13112
13113 /* handlers for MCC time quota and latency sub ioctls */
13114 {WE_MCC_CONFIG_LATENCY,
13115 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13116 0, "setMccLatency"},
13117
13118 {WE_MCC_CONFIG_QUOTA,
13119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13120 0, "setMccQuota"},
13121
13122 {WE_SET_DEBUG_LOG,
13123 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13124 0, "setDbgLvl"},
13125
13126 /* handlers for early_rx power save */
13127 {WE_SET_EARLY_RX_ADJUST_ENABLE,
13128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13129 0, "erx_enable"},
13130
13131 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
13132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13133 0, "erx_bmiss_val"},
13134
13135 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
13136 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13137 0, "erx_bmiss_smpl"},
13138
13139 {WE_SET_EARLY_RX_SLOP_STEP,
13140 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13141 0, "erx_slop_step"},
13142
13143 {WE_SET_EARLY_RX_INIT_SLOP,
13144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13145 0, "erx_init_slop"},
13146
13147 {WE_SET_EARLY_RX_ADJUST_PAUSE,
13148 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13149 0, "erx_adj_pause"},
13150
13151 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
13152 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13153 0, "erx_dri_sample"},
13154
13155 {WE_DUMP_STATS,
13156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13157 0, "dumpStats"},
13158
13159 {WE_CLEAR_STATS,
13160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13161 0, "clearStats"},
13162
Govind Singha471e5e2015-10-12 17:11:14 +053013163 {WE_START_FW_PROFILE,
13164 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13165 0, "startProfile"},
13166
Abhishek Singh1bdb1572015-10-16 16:24:19 +053013167 {WE_SET_CHANNEL,
13168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13169 0, "setChanChange" },
13170
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053013171 {WE_SET_CONC_SYSTEM_PREF,
13172 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13173 0, "setConcSysPref" },
13174
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013175 {WLAN_PRIV_SET_NONE_GET_INT,
13176 0,
13177 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13178 ""},
13179
13180 /* handlers for sub-ioctl */
13181 {WE_GET_11D_STATE,
13182 0,
13183 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13184 "get11Dstate"},
13185
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013186 {WE_GET_WLAN_DBG,
13187 0,
13188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13189 "getwlandbg"},
13190
13191 {WE_GET_MAX_ASSOC,
13192 0,
13193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13194 "getMaxAssoc"},
13195
13196 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
13197 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13198 "getAutoChannel" },
13199
13200 {WE_GET_CONCURRENCY_MODE,
13201 0,
13202 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13203 "getconcurrency"},
13204
13205 {WE_GET_NSS,
13206 0,
13207 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13208 "get_nss"},
13209
13210 {WE_GET_LDPC,
13211 0,
13212 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13213 "get_ldpc"},
13214
13215 {WE_GET_TX_STBC,
13216 0,
13217 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13218 "get_tx_stbc"},
13219
13220 {WE_GET_RX_STBC,
13221 0,
13222 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13223 "get_rx_stbc"},
13224
13225 {WE_GET_SHORT_GI,
13226 0,
13227 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13228 "get_shortgi"},
13229
13230 {WE_GET_RTSCTS,
13231 0,
13232 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13233 "get_rtscts"},
13234
13235 {WE_GET_CHWIDTH,
13236 0,
13237 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13238 "get_chwidth"},
13239
13240 {WE_GET_ANI_EN_DIS,
13241 0,
13242 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13243 "get_anienable"},
13244
13245 {WE_GET_ANI_POLL_PERIOD,
13246 0,
13247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13248 "get_aniplen"},
13249
13250 {WE_GET_ANI_LISTEN_PERIOD,
13251 0,
13252 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13253 "get_anilislen"},
13254
13255 {WE_GET_ANI_OFDM_LEVEL,
13256 0,
13257 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13258 "get_aniofdmlvl"},
13259
13260 {WE_GET_ANI_CCK_LEVEL,
13261 0,
13262 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13263 "get_aniccklvl"},
13264
13265 {WE_GET_DYNAMIC_BW,
13266 0,
13267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13268 "get_cwmenable"},
13269
13270 {WE_GET_GTX_HT_MCS,
13271 0,
13272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13273 "get_gtxHTMcs"},
13274
13275 {WE_GET_GTX_VHT_MCS,
13276 0,
13277 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13278 "get_gtxVHTMcs"},
13279
13280 {WE_GET_GTX_USRCFG,
13281 0,
13282 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13283 "get_gtxUsrCfg"},
13284
13285 {WE_GET_GTX_THRE,
13286 0,
13287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13288 "get_gtxThre"},
13289
13290 {WE_GET_GTX_MARGIN,
13291 0,
13292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13293 "get_gtxMargin"},
13294
13295 {WE_GET_GTX_STEP,
13296 0,
13297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13298 "get_gtxStep"},
13299
13300 {WE_GET_GTX_MINTPC,
13301 0,
13302 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13303 "get_gtxMinTpc"},
13304
13305 {WE_GET_GTX_BWMASK,
13306 0,
13307 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13308 "get_gtxBWMask"},
13309
13310 {WE_GET_TX_CHAINMASK,
13311 0,
13312 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13313 "get_txchainmask"},
13314
13315 {WE_GET_RX_CHAINMASK,
13316 0,
13317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13318 "get_rxchainmask"},
13319
13320 {WE_GET_11N_RATE,
13321 0,
13322 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13323 "get_11nrate"},
13324
13325 {WE_GET_AMPDU,
13326 0,
13327 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13328 "get_ampdu"},
13329
13330 {WE_GET_AMSDU,
13331 0,
13332 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13333 "get_amsdu"},
13334
13335 {WE_GET_BURST_ENABLE,
13336 0,
13337 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13338 "get_burst_en"},
13339
13340 {WE_GET_BURST_DUR,
13341 0,
13342 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13343 "get_burst_dur"},
13344
13345 {WE_GET_TXPOW_2G,
13346 0,
13347 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13348 "get_txpow2g"},
13349
13350 {WE_GET_TXPOW_5G,
13351 0,
13352 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13353 "get_txpow5g"},
13354
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013355 {WE_GET_PPS_PAID_MATCH,
13356 0,
13357 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13358 "get_paid_match"},
13359
13360 {WE_GET_PPS_GID_MATCH,
13361 0,
13362 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13363 "get_gid_match"},
13364
13365 {WE_GET_PPS_EARLY_TIM_CLEAR,
13366 0,
13367 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13368 "get_tim_clear"},
13369
13370 {WE_GET_PPS_EARLY_DTIM_CLEAR,
13371 0,
13372 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13373 "get_dtim_clear"},
13374
13375 {WE_GET_PPS_EOF_PAD_DELIM,
13376 0,
13377 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13378 "get_eof_delim"},
13379
13380 {WE_GET_PPS_MACADDR_MISMATCH,
13381 0,
13382 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13383 "get_mac_match"},
13384
13385 {WE_GET_PPS_DELIM_CRC_FAIL,
13386 0,
13387 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13388 "get_delim_fail"},
13389
13390 {WE_GET_PPS_GID_NSTS_ZERO,
13391 0,
13392 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13393 "get_nsts_zero"},
13394
13395 {WE_GET_PPS_RSSI_CHECK,
13396 0,
13397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13398 "get_rssi_chk"},
13399
13400 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
13401 0,
13402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13403 "get_qpspollcnt"},
13404
13405 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
13406 0,
13407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13408 "get_qtxwake"},
13409
13410 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13411 0,
13412 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13413 "get_qwakeintv"},
13414
13415 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13416 0,
13417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13418 "get_qnodatapoll"},
13419
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013420 {WE_CAP_TSF,
13421 0,
13422 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13423 "cap_tsf"},
13424
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013425 {WE_GET_TEMPERATURE,
13426 0,
13427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13428 "get_temp"},
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070013429 {WE_GET_DCM,
13430 0,
13431 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13432 "get_dcm"},
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070013433 {WE_GET_RANGE_EXT,
13434 0,
13435 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13436 "get_range_ext"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013437 /* handlers for main ioctl */
13438 {WLAN_PRIV_SET_CHAR_GET_NONE,
13439 IW_PRIV_TYPE_CHAR | 512,
13440 0,
13441 ""},
13442
13443 /* handlers for sub-ioctl */
13444 {WE_WOWL_ADD_PTRN,
13445 IW_PRIV_TYPE_CHAR | 512,
13446 0,
13447 "wowlAddPtrn"},
13448
13449 {WE_WOWL_DEL_PTRN,
13450 IW_PRIV_TYPE_CHAR | 512,
13451 0,
13452 "wowlDelPtrn"},
13453
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013454 /* handlers for sub-ioctl */
13455 {WE_NEIGHBOR_REPORT_REQUEST,
13456 IW_PRIV_TYPE_CHAR | 512,
13457 0,
13458 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080013459
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013460 {WE_SET_AP_WPS_IE,
13461 IW_PRIV_TYPE_CHAR | 512,
13462 0,
13463 "set_ap_wps_ie"},
13464
13465 {WE_SET_CONFIG,
13466 IW_PRIV_TYPE_CHAR | 512,
13467 0,
13468 "setConfig"},
13469
13470 /* handlers for main ioctl */
13471 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
13472 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13473 0,
13474 ""},
13475
13476 /* handlers for sub-ioctl */
13477 {WE_SET_WLAN_DBG,
13478 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13479 0,
13480 "setwlandbg"},
13481
13482 /* handlers for sub-ioctl */
13483 {WE_SET_DP_TRACE,
13484 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13485 0,
13486 "set_dp_trace"},
13487
13488 {WE_SET_SAP_CHANNELS,
13489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13490 0,
13491 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013492
13493 {WE_SET_FW_TEST,
13494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13495 0, "fw_test"},
13496
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013497 /* handlers for main ioctl */
13498 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
13499 0,
13500 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13501 "" },
13502 {WE_GET_TSF,
13503 0,
13504 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13505 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013506
13507 {WE_SET_DUAL_MAC_SCAN_CONFIG,
13508 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13509 0,
13510 "set_scan_cfg"},
13511
13512 /* handlers for main ioctl */
13513 {WLAN_PRIV_GET_CHAR_SET_NONE,
13514 0,
13515 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13516 ""},
13517
13518 /* handlers for sub-ioctl */
13519 {WE_WLAN_VERSION,
13520 0,
13521 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13522 "version"},
13523 {WE_GET_STATS,
13524 0,
13525 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13526 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080013527 {WE_GET_SUSPEND_RESUME_STATS,
13528 0,
13529 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13530 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053013531 {WE_LIST_FW_PROFILE,
13532 0,
13533 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13534 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013535 {WE_GET_STATES,
13536 0,
13537 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13538 "getHostStates"},
13539 {WE_GET_CFG,
13540 0,
13541 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13542 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013543 {WE_GET_RSSI,
13544 0,
13545 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13546 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013547 {WE_GET_WMM_STATUS,
13548 0,
13549 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13550 "getWmmStatus"},
13551 {
13552 WE_GET_CHANNEL_LIST,
13553 0,
13554 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13555 "getChannelList"
13556 },
13557#ifdef FEATURE_WLAN_TDLS
13558 {
13559 WE_GET_TDLS_PEERS,
13560 0,
13561 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13562 "getTdlsPeers"
13563 },
13564#endif
13565#ifdef WLAN_FEATURE_11W
13566 {
13567 WE_GET_11W_INFO,
13568 0,
13569 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13570 "getPMFInfo"
13571 },
13572#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013573 {
13574 WE_GET_IBSS_STA_INFO,
13575 0,
13576 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13577 "getIbssSTAs"
13578 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013579 {WE_GET_PHYMODE,
13580 0,
13581 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13582 "getphymode"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013583#if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013584 {WE_GET_OEM_DATA_CAP,
13585 0,
13586 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13587 "getOemDataCap"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013588#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013589 {WE_GET_SNR,
13590 0,
13591 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13592 "getSNR"},
13593
13594 /* handlers for main ioctl */
13595 {WLAN_PRIV_SET_NONE_GET_NONE,
13596 0,
13597 0,
13598 ""},
13599
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013600 /* handlers for sub-ioctl */
13601 {
13602 WE_IBSS_GET_PEER_INFO_ALL,
13603 0,
13604 0,
13605 "ibssPeerInfoAll"
13606 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013607 {WE_GET_RECOVERY_STAT,
13608 0,
13609 0,
13610 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053013611
13612 {WE_GET_FW_PROFILE_DATA,
13613 0,
13614 0,
13615 "getProfileData"},
13616
13617 {WE_SET_REASSOC_TRIGGER,
13618 0,
13619 0,
13620 "reassoc"},
13621
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080013622 {WE_STOP_OBSS_SCAN,
13623 0,
13624 0,
13625 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013626 /* handlers for main ioctl */
13627 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
13628 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13629 0,
13630 ""},
13631
13632 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013633 {WE_IBSS_GET_PEER_INFO,
13634 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13635 0,
13636 "ibssPeerInfo"},
13637
13638 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013639 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
13640 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13641 0,
13642 "setdumplog"},
13643
13644 {WE_MTRACE_DUMP_CMD,
13645 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13646 0,
13647 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080013648
13649 {WE_POLICY_MANAGER_CINFO_CMD,
13650 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13651 0,
13652 "pm_cinfo"},
13653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013654#ifdef MPC_UT_FRAMEWORK
13655 {WE_POLICY_MANAGER_CLIST_CMD,
13656 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13657 0,
13658 "pm_clist"},
13659
13660 {WE_POLICY_MANAGER_DLIST_CMD,
13661 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13662 0,
13663 "pm_dlist"},
13664
13665 {WE_POLICY_MANAGER_DBS_CMD,
13666 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13667 0,
13668 "pm_dbs"},
13669
13670 {WE_POLICY_MANAGER_PCL_CMD,
13671 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13672 0,
13673 "pm_pcl"},
13674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013675 {WE_POLICY_MANAGER_ULIST_CMD,
13676 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13677 0,
13678 "pm_ulist"},
13679
13680 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
13681 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13682 0,
13683 "pm_query_action"},
13684
13685 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
13686 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13687 0,
13688 "pm_query_allow"},
13689
13690 {WE_POLICY_MANAGER_SCENARIO_CMD,
13691 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13692 0,
13693 "pm_run_scenario"},
13694
13695 {WE_POLICY_SET_HW_MODE_CMD,
13696 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13697 0,
13698 "pm_set_hw_mode"},
13699#endif
13700#ifdef FEATURE_WLAN_TDLS
13701 /* handlers for sub ioctl */
13702 {
13703 WE_TDLS_CONFIG_PARAMS,
13704 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13705 0,
13706 "setTdlsConfig"
13707 },
13708#endif
13709 {
13710 WE_UNIT_TEST_CMD,
13711 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13712 0,
13713 "setUnitTestCmd"
13714 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053013715 {
13716 WE_MAC_PWR_DEBUG_CMD,
13717 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13718 0,
13719 "halPwrDebug"
13720 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013721
13722#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
13723 {WE_LED_FLASHING_PARAM,
13724 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13725 0,
13726 "gpio_control"},
13727#endif
13728 /* handlers for main ioctl */
13729 {WLAN_PRIV_ADD_TSPEC,
13730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
13731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13732 "addTspec"},
13733
13734 /* handlers for main ioctl */
13735 {WLAN_PRIV_DEL_TSPEC,
13736 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13737 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13738 "delTspec"},
13739
13740 /* handlers for main ioctl */
13741 {WLAN_PRIV_GET_TSPEC,
13742 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13743 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13744 "getTspec"},
13745
13746 /* handlers for main ioctl - host offload */
13747 {
13748 WLAN_PRIV_SET_HOST_OFFLOAD,
13749 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
13750 0,
13751 "setHostOffload"
13752 }
13753 ,
13754
13755 {
13756 WLAN_GET_WLAN_STATISTICS,
13757 0,
13758 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
13759 "getWlanStats"
13760 }
13761 ,
13762
13763 {
13764 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053013765 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
13766 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013767 0,
13768 "setKeepAlive"
13769 }
13770 ,
13771#ifdef WLAN_FEATURE_PACKET_FILTERING
13772 {
13773 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053013774 IW_PRIV_TYPE_BYTE |
13775 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013776 0,
13777 "setPktFilter"
13778 }
13779 ,
13780#endif
13781#ifdef FEATURE_WLAN_SCAN_PNO
13782 {
13783 WLAN_SET_PNO,
13784 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13785 0,
13786 "setpno"
13787 }
13788 ,
13789#endif
13790 {
13791 WLAN_SET_BAND_CONFIG,
13792 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13793 0,
13794 "SETBAND"
13795 }
13796 ,
13797 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080013798 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080013799 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013800 0,
13801 "setMCBCFilter"
13802 }
13803 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013804
13805 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013806 WLAN_GET_LINK_SPEED,
13807 IW_PRIV_TYPE_CHAR | 18,
13808 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
13809 }
13810 ,
13811
13812 /* handlers for main ioctl */
13813 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
13814 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13815 0,
13816 ""}
13817 ,
13818 {WE_SET_SMPS_PARAM,
13819 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13820 0, "set_smps_param"}
13821 ,
13822 {WLAN_SET_DOT11P_CHANNEL_SCHED,
13823 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
13824 0, "set_dot11p" }
13825 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070013826#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013827 {WE_SET_FW_CRASH_INJECT,
13828 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13829 0, "crash_inject"}
13830 ,
Dustin Brown8d2d0f52017-04-03 17:02:08 -070013831 {WE_LOG_BUFFER,
13832 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13833 0, "log_buffer"}
13834 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013835#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070013836#ifdef WLAN_SUSPEND_RESUME_TEST
13837 {WE_SET_WLAN_SUSPEND,
13838 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13839 0, "wlan_suspend"}
13840 ,
13841 {WE_SET_WLAN_RESUME,
13842 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13843 0, "wlan_resume"}
13844 ,
13845#endif
Govind Singha471e5e2015-10-12 17:11:14 +053013846 {WE_ENABLE_FW_PROFILE,
13847 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13848 0, "enableProfile"}
13849 ,
13850 {WE_SET_FW_PROFILE_HIST_INTVL,
13851 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13852 0, "set_hist_intvl"}
13853 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013854 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
13855 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13856 0, "set_fw_mode_cfg"}
13857 ,
13858 {WE_DUMP_DP_TRACE_LEVEL,
13859 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13860 0, "dump_dp_trace"}
13861 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070013862 {WE_SET_MON_MODE_CHAN,
13863 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13864 0, "setMonChan"}
13865 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070013866
13867 {WE_GET_ROAM_SYNCH_DELAY,
13868 0,
13869 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13870 "hostroamdelay"}
13871 ,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -080013872 {WE_SET_11AX_RATE,
13873 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13874 0,
13875 "set_11ax_rate"}
13876 ,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070013877 {WE_SET_DCM,
13878 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13879 0,
13880 "enable_dcm"}
13881 ,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070013882 {WE_SET_RANGE_EXT,
13883 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13884 0,
13885 "enable_range_ext"}
13886 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013887};
13888
13889const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053013890 .num_standard = QDF_ARRAY_SIZE(we_handler),
13891 .num_private = QDF_ARRAY_SIZE(we_private),
13892 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013893
13894 .standard = (iw_handler *) we_handler,
13895 .private = (iw_handler *) we_private,
13896 .private_args = we_private_args,
13897 .get_wireless_stats = NULL,
13898};
13899
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013900/* hdd_set_wext() - configures bss parameters
13901 * @pAdapter: handle to adapter context
13902 *
13903 * Returns: none
13904 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070013905static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013906{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013907 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13908 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013909
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013910 ENTER();
13911
13912 if (!pwextBuf) {
13913 hdd_err("ERROR: pwextBuf is NULL");
13914 return QDF_STATUS_E_FAILURE;
13915 }
13916
13917 if (!pHddStaCtx) {
13918 hdd_err("ERROR: pHddStaCtx is NULL");
13919 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013920 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013921
13922 /* Now configure the roaming profile links. To SSID and bssid. */
13923 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013924 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013925
13926 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013927 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013928
13929 /*Set the numOfChannels to zero to scan all the channels */
13930 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
13931 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
13932
13933 /* Default is no encryption */
13934 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
13935 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
13936 eCSR_ENCRYPT_TYPE_NONE;
13937
13938 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
13939 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
13940 eCSR_ENCRYPT_TYPE_NONE;
13941
13942 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
13943
13944 /* Default is no authentication */
13945 pwextBuf->roamProfile.AuthType.numEntries = 1;
13946 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13947
13948 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
13949 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
13950
13951 /*Set the default scan mode */
13952 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
13953
13954 hdd_clear_roam_profile_ie(pAdapter);
13955
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013956 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013957 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013958
13959}
13960
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013961/**
13962 * hdd_register_wext() - register wext context
13963 * @dev: net device handle
13964 *
13965 * Registers wext interface context for a given net device
13966 *
13967 * Returns: 0 on success, errno on failure
13968 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013969int hdd_register_wext(struct net_device *dev)
13970{
13971 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013972 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053013973 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013974
13975 ENTER();
13976
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013977 if (!pwextBuf) {
13978 hdd_err(FL("ERROR: pwextBuf is NULL"));
13979 return QDF_STATUS_E_FAILURE;
13980 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013981
13982 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013983 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
13984
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013985 status = hdd_set_wext(pAdapter);
13986
Anurag Chouhance0dc992016-02-16 18:18:03 +053013987 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013988
Jeff Johnson99bac312016-06-28 10:38:18 -070013989 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013990 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013991 }
13992
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013993 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070013994 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013995 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013996 }
13997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013998 /* Register as a wireless device */
13999 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
14000
14001 EXIT();
14002 return 0;
14003}
14004
14005int hdd_unregister_wext(struct net_device *dev)
14006{
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080014007 hdd_debug("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014008
14009 if (dev != NULL) {
14010 rtnl_lock();
14011 dev->wireless_handlers = NULL;
14012 rtnl_unlock();
14013 }
14014
14015 return 0;
14016}