xref: /wlan-driver/qcacld-3.0/core/hdd/src/wlan_hdd_wext.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: wlan_hdd_wext.c
22  *
23  * Linux Wireless Extensions Implementation
24  */
25 
26 #include <linux/version.h>
27 #include <linux/module.h>
28 #include <linux/kernel.h>
29 #include <linux/init.h>
30 #include <linux/wireless.h>
31 #include <mac_trace.h>
32 #include "osif_sync.h"
33 #include <wlan_hdd_includes.h>
34 #include <cds_api.h>
35 #include "scheduler_api.h"
36 #include <net/arp.h>
37 #include <cdp_txrx_cmn.h>
38 #include <cdp_txrx_stats.h>
39 #include "sir_params.h"
40 #include "csr_api.h"
41 #include "csr_inside_api.h"
42 #include "sme_rrm_internal.h"
43 #include <ani_global.h>
44 #include "dot11f.h"
45 #include <wlan_hdd_wowl.h>
46 #include <wlan_hdd_cfg.h>
47 #include <wlan_hdd_wmm.h>
48 #include "utils_api.h"
49 #include "wlan_hdd_p2p.h"
50 #ifdef FEATURE_WLAN_TDLS
51 #include "wlan_hdd_tdls.h"
52 #endif
53 
54 #include "cds_ieee80211_common.h"
55 #include "ol_if_athvar.h"
56 #include "dbglog_host.h"
57 #include "wma.h"
58 
59 #include <ol_defines.h>
60 
61 #include "wlan_hdd_power.h"
62 #include "qwlan_version.h"
63 #include "wlan_hdd_host_offload.h"
64 
65 #include <linux/wireless.h>
66 #include <net/cfg80211.h>
67 
68 #include "wlan_hdd_misc.h"
69 
70 #include "qc_sap_ioctl.h"
71 #include "sme_api.h"
72 #include "wma_types.h"
73 #include "wlan_hdd_assoc.h"
74 #include "wlan_hdd_ioctl.h"
75 #include "wlan_hdd_scan.h"
76 #include "sme_power_save_api.h"
77 #include "wlan_policy_mgr_api.h"
78 #include "wlan_hdd_fips.h"
79 #include "wlan_hdd_tsf.h"
80 #include "wlan_hdd_ocb.h"
81 #include "wlan_hdd_napi.h"
82 #include "cdp_txrx_flow_ctrl_legacy.h"
83 #include "wlan_hdd_nan_datapath.h"
84 #include "wlan_hdd_stats.h"
85 #ifdef WLAN_SUSPEND_RESUME_TEST
86 #include "wlan_hdd_driver_ops.h"
87 #include "hif.h"
88 #endif
89 #include "pld_common.h"
90 #include "cds_utils.h"
91 #include "wlan_osif_request_manager.h"
92 #include "os_if_wifi_pos.h"
93 #include <cdp_txrx_stats.h>
94 #include <cds_api.h>
95 #include "wlan_dsc_test.h"
96 #include <wlan_osif_priv.h>
97 #include "wlan_hdd_regulatory.h"
98 #include "wlan_reg_ucfg_api.h"
99 #include "wlan_hdd_packet_filter_api.h"
100 #include "wlan_cp_stats_mc_ucfg_api.h"
101 #include "wlan_mlme_ucfg_api.h"
102 #include "cfg_mlme_sta.h"
103 #include "wlan_mlme_public_struct.h"
104 #include "cfg_ucfg_api.h"
105 #include "wlan_policy_mgr_ucfg.h"
106 #include "wlan_mlme_public_struct.h"
107 #include "cfg_ucfg_api.h"
108 #include "cfg_mlme_threshold.h"
109 #include "wlan_pmo_cfg.h"
110 #include "wlan_pmo_ucfg_api.h"
111 #include "wlan_dp_rx_thread.h"
112 #include "wlan_fwol_ucfg_api.h"
113 #include "wlan_hdd_unit_test.h"
114 #include "wlan_hdd_thermal.h"
115 #include "wlan_cm_roam_ucfg_api.h"
116 #include "wlan_hdd_object_manager.h"
117 #include "wlan_dp_ucfg_api.h"
118 
119 /* Private ioctls and their sub-ioctls */
120 #define WLAN_PRIV_SET_INT_GET_NONE    (SIOCIWFIRSTPRIV + 0)
121 #define WE_SET_11D_STATE     1
122 #define WE_WOWL              2
123 #define WE_SET_POWER         3
124 /*
125  * <ioctl>
126  * setMaxAssoc - Sets the maximum number of associated stations
127  *
128  * @INPUT: 1 to 32
129  *
130  * @OUTPUT: None
131  *
132  * This IOTCL sets the maximum number of associated stations
133  *
134  * @E.g: iwpriv wlan0 setMaxAssoc <value>
135  *
136  * Supported Feature: STA
137  *
138  * Usage: Internal/External
139  *
140  * </ioctl>
141  */
142 #define WE_SET_MAX_ASSOC     4
143 /*
144  * <ioctl>
145  * scan_disable - Disable scan
146  *
147  * @INPUT: set_value
148  *
149  * @OUTPUT: None
150  *
151  * This IOCTL is used to set disable scan
152  *
153  * @E.g: iwpriv wlan0 scan_disable 1
154  *
155  * Supported Feature: Scan
156  *
157  * Usage: Internal/External
158  *
159  * </ioctl>
160  */
161 #define WE_SET_SCAN_DISABLE  5
162 /*
163  * <ioctl>
164  * inactivityTO - sets the timeout value for inactivity data while
165  * in power save mode
166  *
167  * @INPUT: int1…..int255
168  *
169  * @OUTPUT: None
170  *
171  * This IOCTL set the timeout value for inactivity data in power save mode
172  *
173  * @E.g: iwpriv wlan0 inactivityTO 20
174  *
175  * Supported Feature: STA
176  *
177  * Usage: Internal/External
178  *
179  * </ioctl>
180  */
181 #define WE_SET_DATA_INACTIVITY_TO  6
182 /*
183  * <ioctl>
184  * setMaxTxPower - Dynamically sets the maximum transmission power
185  *
186  * @INPUT: Transmission power in dBm
187  *
188  * @OUTPUT: None
189  *
190  * This IOCTL dynamically sets the maximum transmission power
191  * This setting does not persist over reboots
192  *
193  * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
194  *
195  * Supported Feature: STA
196  *
197  * Usage: Internal/External
198  *
199  * </ioctl>
200  */
201 #define WE_SET_MAX_TX_POWER  7
202 
203 #ifdef HASTINGS_BT_WAR
204 /* Temporary WAR for Hastings 1.1 only */
205 #define WE_SET_HASTINGS_BT_WAR 8
206 #endif
207 
208 #define WE_SET_TM_LEVEL      9
209 
210 /*
211  * <ioctl>
212  * setphymode - Set the phymode dynamically
213  *
214  * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
215  *
216  * @OUTPUT: None
217  *
218  * This IOCTL sets the phymode dynamically
219  *
220  * @E.g: iwpriv wlan0 setphymode 10
221  *
222  * Supported Feature: STA
223  *
224  * Usage: Internal/External
225  *
226  * </ioctl>
227  */
228 #define WE_SET_PHYMODE       10
229 /*
230  * <ioctl>
231  * nss - Set the number of spatial streams
232  *
233  * @INPUT: int1…..int3
234  *
235  * @OUTPUT: None
236  *
237  * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
238  *
239  * @E.g: iwpriv wlan0 nss 2
240  *
241  * Supported Feature: STA
242  *
243  * Usage: Internal/External
244  *
245  * </ioctl>
246  */
247 #define WE_SET_NSS           11
248 /*
249  * <ioctl>
250  * ldpc - Enables or disables LDPC
251  *
252  * @INPUT: 0 – Disable, 1 - Enable
253  *
254  * @OUTPUT: None
255  *
256  * This IOCTL enables or disables LDPC
257  *
258  * @E.g: iwpriv wlan0 ldpc 1
259  *
260  * Supported Feature: STA
261  *
262  * Usage: Internal/External
263  *
264  * </ioctl>
265  */
266 #define WE_SET_LDPC          12
267 /*
268  * <ioctl>
269  * tx_stbc - Enables or disables tx_stbc
270  *
271  * @INPUT: Int 0 – Disable, 1 - Enable
272  *
273  * @OUTPUT: None
274  *
275  * This IOTCL used to enables or disables tx_stbc
276  *
277  * @E.g: iwpriv wlan0 tx_stbc <value>
278  *
279  * Supported Feature: STA
280  *
281  * Usage: Internal/External
282  *
283  * </ioctl>
284  */
285 #define WE_SET_TX_STBC       13
286 /*
287  * <ioctl>
288  * rx_stbc - Set the rx_stbc parameter
289  *
290  * @INPUT: Int 0 – Disable, 1 - Enable
291  *
292  * @OUTPUT: None
293  *
294  * This IOTCL used to set rx_stbc parameter
295  *
296  * @E.g: iwpriv wlan0 rx_stbc <value>
297  *
298  * Supported Feature: STA
299  *
300  * Usage: Internal/External
301  *
302  * </ioctl>
303  */
304 #define WE_SET_RX_STBC       14
305 /*
306  * <ioctl>
307  * shortgi  - Sets the short-guard interval
308  *
309  * @INPUT: Fixed Rate: 0 - 400ns, 1 - 800ns, 2 - 1600ns, 3 - 3200us
310  * Auto Rate: 8 - 400ns, 9 - 800ns, 10 - 1600ns, 11 - 3200us
311  *
312  * @OUTPUT: None
313  *
314  * This IOCTL sets the short-guard interval.
315  *
316  * @E.g: iwpriv wlan0 shortgi <value>
317  *
318  * Supported Feature: STA
319  *
320  * Usage: Internal/External
321  *
322  * </ioctl>
323  */
324 #define WE_SET_SHORT_GI      15
325 /*
326  * <ioctl>
327  * enablertscts - enables or disables rts/cts.
328  *
329  * @INPUT: 1-Enable , 0-Disable
330  *
331  * @OUTPUT: None
332  *
333  * This IOCTL enables or disables rts/cts.
334  *
335  * @E.g: iwpriv wlan0 enablertscts <value>
336  *
337  * Supported Feature: STA
338  *
339  * Usage: Internal/External
340  *
341  * </ioctl>
342  */
343 #define WE_SET_RTSCTS        16
344 /*
345  * <ioctl>
346  * chwidth - Set the channel bandwidth
347  *
348  * @INPUT: 0-20mhz to 3-160mhz
349  *
350  * @OUTPUT: None
351  *
352  * This IOTCL used to set the channel bandwidth
353  *
354  * @E.g: iwpriv wlan0 chwidth 1
355  *
356  * Supported Feature: STA
357  *
358  * Usage: Internal/External
359  *
360  * </ioctl>
361  */
362 #define WE_SET_CHWIDTH       17
363 #define WE_SET_ANI_EN_DIS    18
364 #define WE_SET_ANI_POLL_PERIOD    19
365 #define WE_SET_ANI_LISTEN_PERIOD  20
366 #define WE_SET_ANI_OFDM_LEVEL     21
367 #define WE_SET_ANI_CCK_LEVEL      22
368 /*
369  * <ioctl>
370  * cwmenable - Enables or disables the dynamic channel bandwidth
371  *
372  * @INPUT: 0-Disable, 1-Enable
373  *
374  * @OUTPUT: None
375  *
376  * This IOTCL used to enables or disables the dynamic channel bandwidth
377  *
378  * @E.g: iwpriv wlan0 cwmenable <value>
379  *
380  * Supported Feature: STA
381  *
382  * Usage: Internal/External
383  *
384  * </ioctl>
385  */
386 #define WE_SET_DYNAMIC_BW         23
387 /*
388  * <ioctl>
389  * txchainmask - This IOCTL sets the current Tx chain mask
390  *
391  * @INPUT: Mask Value
392  *
393  * @OUTPUT: None
394  *
395  * This IOCTL sets the current Tx chain mask
396  *
397  * @E.g: iwpriv wlan0 txchainmask 1
398  *
399  * Supported Feature: STA
400  *
401  * Usage: Internal/External
402  *
403  * </ioctl>
404  */
405 #define WE_SET_TX_CHAINMASK  24
406 /*
407  * <ioctl>
408  * rxchainmask - Sets the current Rx chain mask
409  *
410  * @INPUT: Mask Value
411  *
412  * @OUTPUT: None
413  *
414  * This IOCTL sets the current Rx chain mask. This command is the
415  * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
416  *
417  * @E.g: iwpriv wlan0 rxchainmask <value>
418  *
419  * Supported Feature: STA
420  *
421  * Usage: Internal/External
422  *
423  * </ioctl>
424  */
425 #define WE_SET_RX_CHAINMASK  25
426 /*
427  * <ioctl>
428  * set11NRates - Fixes the Tx data rate of the 11N mode.
429  *
430  * @INPUT: 0x1b to 0x8f
431  *
432  * @OUTPUT: None
433  *
434  * This IOCTL fixes the Tx data rate of the 11N mode.
435  *
436  * @E.g: iwpriv wlan0 set11NRates 0x85
437  *
438  * Supported Feature: STA
439  *
440  * Usage: Internal/External
441  *
442  * </ioctl>
443  */
444 #define WE_SET_11N_RATE      26
445 /*
446  * <ioctl>
447  * ampdu  - Set the the maximum subframe of ampdu
448  *
449  * @INPUT: int 1 to int 63
450  *
451  * @OUTPUT: None
452  *
453  * This IOCTL sets the maximum subframe of ampdu.
454  *
455  * @E.g: iwpriv wlan0 ampdu 9
456  *
457  * Supported Feature: STA
458  *
459  * Usage: Internal/External
460  *
461  * </ioctl>
462  */
463 #define WE_SET_AMPDU         27
464 /*
465  * <ioctl>
466  * amsdu - Sets the maximum subframe of amsdu.
467  *
468  * @INPUT: int 1 to int 31
469  *
470  * @OUTPUT: None
471  *
472  * This IOCTL sets the maximum subframe of amsdu.
473  *
474  * @E.g: iwpriv wlan0 amsdu 9
475  *
476  * Supported Feature: STA
477  *
478  * Usage: Internal/External
479  *
480  * </ioctl>
481  */
482 #define WE_SET_AMSDU         28
483 /*
484  * <ioctl>
485  * txpow2g - current 2 GHz Tx power setting
486  *
487  * @INPUT: Tx power in dBm
488  *
489  * @OUTPUT: None
490  *
491  * This IOTCL  used to set 2 ghz tx power
492  *
493  * @E.g: iwpriv wlan0 txpow2g
494  *
495  * Supported Feature: STA
496  *
497  * Usage: Internal/External
498  *
499  * </ioctl>
500  */
501 #define WE_SET_TXPOW_2G      29
502 /*
503  * <ioctl>
504  * txpow5g - Current 5 GHz tx power setting
505  *
506  * @INPUT: Tx power in dBm
507  *
508  * @OUTPUT: None
509  *
510  * This IOTCL used to set the 5 ghz txpower
511  *
512  * @E.g: iwpriv wlan0 txpow5g
513  *
514  * Supported Feature: STA
515  *
516  * Usage: Internal/External
517  *
518  * </ioctl>
519  */
520 #define WE_SET_TXPOW_5G      30
521 /* Private ioctl for firmware debug log */
522 #define WE_DBGLOG_LOG_LEVEL             31
523 #define WE_DBGLOG_VAP_ENABLE            32
524 #define WE_DBGLOG_VAP_DISABLE           33
525 #define WE_DBGLOG_MODULE_ENABLE         34
526 #define WE_DBGLOG_MODULE_DISABLE        35
527 #define WE_DBGLOG_MOD_LOG_LEVEL         36
528 #define WE_DBGLOG_TYPE                  37
529 #define WE_SET_TXRX_FWSTATS             38
530 /*
531  * <ioctl>
532  * set11ACRates  - Fixes the Tx data rate of 11AC
533  *
534  * @INPUT: 0x1 to 0x9
535  *
536  * @OUTPUT: None
537  *
538  * This IOCTL fixes the Tx data rate of 11AC.
539  *
540  * @E.g: iwpriv wlan0 set11ACRates 0x9
541  *
542  * Supported Feature: STA
543  *
544  * Usage: Internal/External
545  *
546  * </ioctl>
547  */
548 #define WE_SET_VHT_RATE                 39
549 #define WE_DBGLOG_REPORT_ENABLE         40
550 #define WE_TXRX_FWSTATS_RESET           41
551 /*
552  * <ioctl>
553  * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
554  *
555  * @INPUT: Transmission power in dBm
556  *
557  * @OUTPUT: None
558  *
559  * This IOCTL sets the maximum transmit power for the 2.4-GHz band
560  * This setting does not persist over reboots
561  *
562  * @E.g: iwpriv wlan0 setTxMaxPower2G 10
563  *
564  * Supported Feature: STA
565  *
566  * Usage: Internal/External
567  *
568  * </ioctl>
569  */
570 #define WE_SET_MAX_TX_POWER_2_4   42
571 /*
572  * <ioctl>
573  * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
574  *
575  * @INPUT: Transmission power in dBm
576  *
577  * @OUTPUT: None
578  *
579  * This IOCTL sets the maximum transmit power for the 5-GHz band
580  * This setting does not persist over reboots
581  *
582  * @E.g: iwpriv wlan0 setTxMaxPower5G 10
583  *
584  * Supported Feature: STA
585  *
586  * Usage: Internal/External
587  *
588  * </ioctl>
589  */
590 #define WE_SET_MAX_TX_POWER_5_0   43
591 #define WE_SET_PKTLOG                   44
592 /* Private ioctl for packet power save */
593 #define  WE_PPS_PAID_MATCH              45
594 #define  WE_PPS_GID_MATCH               46
595 #define  WE_PPS_EARLY_TIM_CLEAR         47
596 #define  WE_PPS_EARLY_DTIM_CLEAR        48
597 #define  WE_PPS_EOF_PAD_DELIM           49
598 #define  WE_PPS_MACADDR_MISMATCH        50
599 #define  WE_PPS_DELIM_CRC_FAIL          51
600 #define  WE_PPS_GID_NSTS_ZERO           52
601 /*
602  * <ioctl>
603  * rssi_chk - Check the rssi
604  *
605  * @INPUT: One argument as input
606  *
607  * @OUTPUT: rssi
608  *  wlan0	rssi_chk:56
609  *
610  * This IOTCL used to check rssi
611  *
612  * @E.g: iwpriv wlan0 rssi_chk <value>
613  *
614  * Supported Feature: STA
615  *
616  * Usage: Internal/External
617  *
618  * </ioctl>
619  */
620 #define  WE_PPS_RSSI_CHECK              53
621 /*
622  * <ioctl>
623  * htsmps - Sets the htsmps
624  *
625  * @INPUT: Atleast one int argument
626  *
627  * @OUTPUT: None
628  *
629  * This IOTCL used to set htsmps
630  *
631  * @E.g: iwpriv wlan0 htsmps <value>
632  *
633  * Supported Feature: STA
634  *
635  * Usage: Internal/External
636  *
637  * </ioctl>
638  */
639 #define WE_SET_HTSMPS                   55
640 /* Private ioctl for QPower */
641 #define WE_SET_QPOWER_MAX_PSPOLL_COUNT            56
642 #define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE          57
643 #define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL   58
644 #define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
645 /* GTX Commands */
646 /*
647  * <ioctl>
648  * gtxHTMcs - Set the tx HTM value
649  *
650  * @INPUT: Atleast one int orgument
651  *
652  * @OUTPUT: None
653  *
654  * This IOTCL sets htm tx value
655  *
656  * @E.g: iwpriv wlan0 gtxHTMcs <value>
657  *
658  * Supported Feature: STA
659  *
660  * Usage: Internal/External
661  *
662  * </ioctl>
663  */
664 #define WE_SET_GTX_HT_MCS               62
665 /*
666  * <ioctl>
667  * gtxVHTMcs - Set gtxVHTMcs value
668  *
669  * @INPUT: Atleast one int argument
670  *
671  * @OUTPUT: None
672  *
673  * This IOTCL used to set gtxVHTMcs value
674  *
675  * @E.g: iwpriv wlan0 gtxVHTMcs <value>
676  *
677  * Supported Feature: STA
678  *
679  * Usage: Internal/External
680  *
681  * </ioctl>
682  */
683 #define WE_SET_GTX_VHT_MCS              63
684 /*
685  * <ioctl>
686  * gtxUsrCfg - Host request for GTX mask
687  *
688  * @INPUT: Atleast one int orgument
689  *
690  * @OUTPUT: None
691  *
692  * This IOTCL used send the host request for GTX mask
693  *
694  * @E.g: iwpriv wlan0 gtxUsrCfg <value>
695  *
696  * Supported Feature: STA
697  *
698  * Usage: Internal/External
699  *
700  * </ioctl>
701  */
702 #define WE_SET_GTX_USRCFG               64
703 /*
704  * <ioctl>
705  * gtxThre - Set the tx threshold
706  *
707  * @INPUT: Atleast one int argument
708  *
709  * @OUTPUT: None
710  *
711  * This IOTCL used to set tx threshold
712  *
713  * @E.g: iwpriv wlan0 gtxThre <value>
714  *
715  * Supported Feature: STA
716  *
717  * Usage: Internal/External
718  *
719  * </ioctl>
720  */
721 #define WE_SET_GTX_THRE                 65
722 /*
723  * <ioctl>
724  * gtxMargin  - Set the gtxMargin
725  *
726  * @INPUT: 1 to 32
727  *
728  * @OUTPUT: None
729  *
730  * This IOTCL use dto set gtxMargin
731  *
732  * @E.g: iwpriv wlan0 gtxMargini <value>
733  *
734  * Supported Feature: STA
735  *
736  * Usage: Internal/External
737  *
738  * </ioctl>
739  */
740 #define WE_SET_GTX_MARGIN               66
741 /*
742  * <ioctl>
743  * gtxStep - Set the gtxStep
744  *
745  * @INPUT: None
746  *
747  * @OUTPUT: None
748  *
749  * This IOTCL used to sets gtxStep
750  *
751  * @E.g: iwpriv wlan0 gtxStep <value>
752  *
753  * Supported Feature: STA
754  *
755  * Usage: Internal/External
756  *
757  * </ioctl>
758  */
759 #define WE_SET_GTX_STEP                 67
760 /*
761  * <ioctl>
762  * gtxMinTpc - Sets the gtxMinTpc
763  *
764  * @INPUT: Atleast one int argument
765  *
766  * @OUTPUT: None
767  *
768  * This IOTCL sets the tx MinTpc
769  *
770  * @E.g: iwpriv wlan0 gtxMinTpc <value>
771  *
772  * Supported Feature: STA
773  *
774  * Usage: Internal/External
775  *
776  * </ioctl>
777  */
778 #define WE_SET_GTX_MINTPC               68
779 /*
780  * <ioctl>
781  * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
782  *
783  * @INPUT: Mask value
784  *
785  * @OUTPUT: None
786  *
787  * This IOTCL used to set gtxBWMask
788  *
789  * @E.g: iwpriv wlan0 gtxBWMask <value>
790  *
791  * Supported Feature: STA
792  *
793  * Usage: Internal/External
794  *
795  * </ioctl>
796  */
797 
798 #define WE_SET_GTX_BWMASK               69
799 /*
800  * <ioctl>
801  * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
802  *
803  * @INPUT: set_value
804  *
805  * @OUTPUT: None
806  *
807  * This IOCTL is used to set the MCC latency value in milliseconds
808  * during STA-P2P concurrency.
809  *
810  * If 0ms latency is provided, then FW will set to a default.
811  * Otherwise, latency must be at least 30ms.
812  *
813  * @E.g: iwpriv wlan0 setMccLatency 40
814  *
815  *
816  * Supported Feature: Concurrency
817  *
818  * Usage: Internal/External
819  *
820  * </ioctl>
821  */
822 #define WE_MCC_CONFIG_LATENCY           70
823 
824 /*
825  * <ioctl>
826  * setMccQuota- Set the quota for P2P cases
827  *
828  * @INPUT: set_value [0,100]
829  *
830  * @OUTPUT: None
831  *
832  * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
833  *
834  * Currently used to set time quota for 2 MCC vdevs/adapters using
835  * (operating channel, quota) for each mode.
836  * The info is provided run time using iwpriv command:
837  * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
838  * Note: the quota provided in command is for the same mode in cmd.
839  * HDD checks if MCC mode is active, gets the second mode and its
840  * operating chan.
841  * Quota for the 2nd role is calculated as 100 - quota of first mode.
842  *
843  * @E.g: iwpriv wlan0 setMccQuota 50
844  *       iwpriv p2p0 setMccQuota 50
845  *
846  * Supported Feature: Concurrency
847  *
848  * Usage: Internal/External
849  *
850  * </ioctl>
851  */
852 #define WE_MCC_CONFIG_QUOTA             71
853 /* Private IOCTL for debug connection issues */
854 #define WE_SET_DEBUG_LOG                72
855 #ifdef WE_SET_TX_POWER
856 #undef WE_SET_TX_POWER
857 #endif
858 
859 /*
860  * <ioctl>
861  * setTxPower - Set the current transmit power
862  *
863  * @INPUT: Transmission power in dBm
864  *
865  * @OUTPUT: None
866  *
867  * This IOCTL sets the current transmit power.
868  * This setting does not persist over reboots.
869  *
870  * @E.g: iwpriv wlan0 setTxPower 10
871  *
872  * Supported Feature: STA
873  *
874  * Usage: Internal/External
875  *
876  * </ioctl>
877  */
878 #define WE_SET_TX_POWER                 74
879 /* Private ioctl for earlyrx power save feature */
880 #define WE_SET_EARLY_RX_ADJUST_ENABLE         75
881 #define WE_SET_EARLY_RX_TGT_BMISS_NUM         76
882 #define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE    77
883 #define WE_SET_EARLY_RX_SLOP_STEP             78
884 #define WE_SET_EARLY_RX_INIT_SLOP             79
885 #define WE_SET_EARLY_RX_ADJUST_PAUSE          80
886 /*
887  * <ioctl>
888  * setMcRate  - Set the data rate for multicast data
889  *
890  * @INPUT: 1 to 32
891  *
892  * @OUTPUT: None
893  *
894  * This IOCTL sets the data rate for multicast data. Note that this command
895  * is allowed only in STA or QCMobileAP mode
896  *
897  * @E.g: iwpriv wlan0 setMcRate <value>
898  *
899  * Supported Feature: STA
900  *
901  * Usage: Internal/External
902  *
903  * </ioctl>
904  */
905 #define WE_SET_MC_RATE                        81
906 #define WE_SET_EARLY_RX_DRIFT_SAMPLE          82
907 /* Private ioctl for packet power save */
908 /*
909  * <ioctl>
910  * 5g_ebt - Sets the 5g_ebt
911  *
912  * @INPUT: <value>
913  *
914  * @OUTPUT: None
915  *
916  * This IOTCL used to set 5g_ebt
917  *
918  * @E.g: iwpriv wlan0 5g_ebt <value>
919  *
920  * Supported Feature: STA
921  *
922  * Usage: Internal/External
923  *
924  * </ioctl>
925  */
926 #define WE_PPS_5G_EBT                         83
927 /*
928  * <ioctl>
929  * cts_cbw  - Set CTS channel BW for dynamic BW adjustment
930  *
931  * @INPUT: 20 t0 160
932  *
933  * @OUTPUT: None
934  *
935  * This IOTCL used to set CTS channel BW for dynamic BW adjustment
936  *
937  * @E.g: iwpriv wlan0 cts_cbw <value>
938  *
939  * Supported Feature: STA
940  *
941  * Usage: Internal/External
942  *
943  * </ioctl>
944  */
945 #define WE_SET_CTS_CBW                        84
946 #define WE_DUMP_STATS                         85
947 #define WE_CLEAR_STATS                        86
948 /* Private sub ioctl for starting/stopping the profiling */
949 #define WE_START_FW_PROFILE                      87
950 
951 /*
952  * <ioctl>
953  * setChanChange - Initiate channel change
954  *
955  * @INPUT: channel number to switch to.
956  *
957  * @OUTPUT: None
958  *
959  * This IOCTL is used to initiate a channel change.
960  * If called on STA/CLI interface it will send the
961  * ECSA action frame to the connected SAP/GO asking to
962  * initiate the ECSA, if supported.
963  * If called on SAP/GO interface it will initiate
964  * ECSA and ask connected peers to move to new channel.
965  *
966  * @E.g: iwpriv wlan0 setChanChange <channel>
967  * iwpriv wlan0 setChanChange 1
968  *
969  * Supported Feature: ECSA
970  *
971  * Usage: Internal/External
972  *
973  * </ioctl>
974  */
975 #define WE_SET_CHANNEL                        88
976 #define WE_SET_CONC_SYSTEM_PREF               89
977 
978 /*
979  * <ioctl>
980  * set_11ax_rate - set 11ax rates to FW
981  *
982  * @INPUT: rate code
983  *
984  * @OUTPUT: None
985  *
986  * This IOCTL fixes the Tx data rate of 11AX.
987  *
988  * @E.g: iwpriv wlan0 set_11ax_rate <rate code>
989  *
990  * Supported Feature: STA/SAP
991  *
992  * Usage: Internal
993  *
994  * </ioctl>
995  */
996 #define WE_SET_11AX_RATE                      91
997 
998 /*
999  * <ioctl>
1000  * enable_dcm - enable Dual Carrier Modulation(DCM)
1001  *
1002  * @INPUT: 0/1
1003  *
1004  * @OUTPUT: None
1005  *
1006  * This IOCTL enables/disables DCM.
1007  *
1008  * @E.g: iwpriv wlan0 enable_dcm <0/1>
1009  *
1010  * Supported Feature: STA/SAP
1011  *
1012  * Usage: Internal
1013  *
1014  * </ioctl>
1015  */
1016 #define WE_SET_DCM                            92
1017 
1018 /*
1019  * <ioctl>
1020  * range_ext - enable Range extension
1021  *
1022  * @INPUT: 0/1
1023  *
1024  * @OUTPUT: None
1025  *
1026  * This IOCTL enables/disables Range extension.
1027  *
1028  * @E.g: iwpriv wlan0 range_ext <1/0>
1029  *
1030  * Supported Feature: STA/SAP
1031  *
1032  * Usage: Internal
1033  *
1034  * </ioctl>
1035  */
1036 #define WE_SET_RANGE_EXT                      93
1037 
1038 /*
1039  * <ioctl>
1040  * wow_ito - sets the timeout value for inactivity data while
1041  * in power save mode during wow
1042  *
1043  * @INPUT: int
1044  *
1045  * @OUTPUT: None
1046  *
1047  * This IOCTL set the timeout value for inactivity data in power save mode
1048  *
1049  * @E.g: iwpriv wlan0 wow_ito 20
1050  *
1051  * Supported Feature: STA
1052  *
1053  * Usage: External
1054  *
1055  * </ioctl>
1056  */
1057 #define WE_SET_WOW_DATA_INACTIVITY_TO    94
1058 
1059 /*
1060  * <ioctl>
1061  * pdev_reset - reset the pdev
1062  *
1063  * @INPUT: Reset command to initiate:
1064  *    TX_FLUSH = 1
1065  *    WARM_RESET = 2
1066  *    COLD_RESET = 3
1067  *    WARM_RESET_RESTORE_CAL = 4
1068  *    COLD_RESET_RESTORE_CAL = 5
1069  *
1070  * @OUTPUT: None
1071  *
1072  * This IOCTL is used to reset the pdev. The primary use is
1073  * for internal testing. It is not expected that this will
1074  * be used on a production device.
1075  *
1076  * @E.g: iwpriv wlan0 pdev_reset <command>
1077  * iwpriv wlan0 pdev_reset 1
1078  *
1079  * Supported Feature: None
1080  *
1081  * Usage: Internal
1082  *
1083  * </ioctl>
1084  */
1085 #define WE_SET_PDEV_RESET    95
1086 
1087 /*
1088  * setModDTIM - Change Modulated DTIM
1089  *
1090  * @INPUT: set_value.
1091  *
1092  * @OUTPUT: None
1093  *
1094  * This IOCTL is used to change modulated DTIM
1095  * value without WIFI OFF/ON.
1096  *
1097  * @E.g: iwpriv wlan0 setModDTIM <value>
1098  * iwpriv wlan0 setModDTIM 2
1099  *
1100  * Supported Feature: N/A
1101  *
1102  * Usage: Internal/External
1103  *
1104  * </ioctl>
1105  */
1106 #define WE_SET_MODULATED_DTIM                   96
1107 
1108 #ifdef WLAN_FEATURE_MOTION_DETECTION
1109 #define WE_MOTION_DET_START_STOP                97
1110 #define WE_MOTION_DET_BASE_LINE_START_STOP      98
1111 #endif /* WLAN_FEATURE_MOTION_DETECTION */
1112 
1113 /*
1114  * set_btc_mode Set BTCoexMode
1115  *
1116  * @INPUT: set_value.
1117  *
1118  * @OUTPUT: None
1119  *
1120  * This IOCTL is used to set the BT COex operating mode
1121  * Allowed values are 0(TDD), 1(FDD), 2(Hybrid)
1122  *
1123  * @E.g: iwpriv wlan0 set_btc_mode  <value>
1124  * iwpriv wlan0 set_btc_mode 2
1125  *
1126  * Supported Feature: N/A
1127  *
1128  * Usage: Internal/External
1129  *
1130  * </ioctl>
1131  */
1132 #define WE_SET_BTCOEX_MODE	99
1133 
1134 /*
1135  * set_btc_rssi- Set WLAN low RSSI threshold for BTCOex
1136  *
1137  * @INPUT: set_value.
1138  *
1139  * @OUTPUT: None
1140  *
1141  * This IOCTL is used to modify the threshold at which
1142  * the COex mode changes from TDD to Hybrid mode
1143  * Allowed values are from -100 to 0
1144  *
1145  * @E.g: iwpriv wlan0 set_btc_rssi <value>
1146  * iwpriv wlan0 set_btc_rssi -70
1147  *
1148  * Supported Feature: N/A
1149  *
1150  * Usage: Internal/External
1151  *
1152  * </ioctl>
1153  */
1154 #define WE_SET_BTCOEX_RSSI_THRESHOLD	100
1155 
1156 /* Private ioctls and their sub-ioctls */
1157 #define WLAN_PRIV_SET_NONE_GET_INT    (SIOCIWFIRSTPRIV + 1)
1158 #define WE_GET_11D_STATE     1
1159 #define WE_GET_WLAN_DBG      4
1160 #define WE_GET_MAX_ASSOC     6
1161 /* 7 is unused */
1162 #define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
1163 
1164 /*
1165  * <ioctl>
1166  * getconcurrency - Get concurrency mode
1167  *
1168  * @INPUT: None
1169  *
1170  * @OUTPUT: It shows concurrency value
1171  * Bit 0:STA   1:SAP     2:P2P_Client  3:P2P_GO
1172  *     4:FTM   5:IBSS    6:Monitor     7:P2P_Device
1173  *     8:OCB   9:EPPING  10:QVIT       11:NDI
1174  *
1175  * This IOCTL is used to retrieve concurrency mode.
1176  *
1177  * @E.g: iwpriv wlan0 getconcurrency
1178  * wlan0     getconcurrency:5
1179  * Above value shows STA+P2P_Client
1180  *
1181  * Supported Feature: Concurrency
1182  *
1183  * Usage: Internal/External
1184  *
1185  * </ioctl>
1186  */
1187 #define WE_GET_CONCURRENCY_MODE 9
1188 /*
1189  * <ioctl>
1190  * get_nss - Get the number of spatial STBC streams (NSS)
1191  *
1192  * @INPUT: None
1193  *
1194  * @OUTPUT: NSS
1195  *  wlan0     get_nss:2
1196  *
1197  * This IOTCL used to get the number of spatial STBC streams
1198  *
1199  * @E.g: iwpriv wlan0 get_nss
1200  *
1201  * Supported Feature: STA
1202  *
1203  * Usage: Internal/External
1204  *
1205  * </ioctl>
1206  */
1207 #define WE_GET_NSS           11
1208 /*
1209  * <ioctl>
1210  * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1211  *
1212  * @INPUT: None
1213  *
1214  * @OUTPUT: ldpc
1215  *  wlan0     get_ldpc:1
1216  *
1217  * This IOTCL used to gets the low density parity check (LDPC)
1218  *
1219  * @E.g: iwpriv wlan0 get_ldpc
1220  *
1221  * Supported Feature: STA
1222  *
1223  * Usage: Internal/External
1224  *
1225  * </ioctl>
1226  */
1227 #define WE_GET_LDPC          12
1228 /*
1229  * <ioctl>
1230  * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1231  *
1232  * @INPUT: None
1233  *
1234  * @OUTPUT: TXSTBC
1235  *  wlan0     get_tx_stbc:1
1236  *
1237  * This IOTCL get the value of the current Tx space time block code (STBC)
1238  *
1239  * @E.g: iwpriv wlan0 get_tx_stbc
1240  *
1241  * Supported Feature: STA
1242  *
1243  * Usage: Internal/External
1244  *
1245  * </ioctl>
1246  */
1247 #define WE_GET_TX_STBC       13
1248 /*
1249  * <ioctl>
1250  * get_rx_stbc - Gets the value of the current Rx STBC
1251  *
1252  * @INPUT: None
1253  *
1254  * @OUTPUT: Rx STBC
1255  *  wlan0     get_rx_stbc:1
1256  *
1257  * This IOTCL used to get the value of the current Rx STBC
1258  *
1259  * @E.g: iwpriv wlan0 get_rx_stbc
1260  *
1261  * Supported Feature: STA
1262  *
1263  * Usage: Internal/External
1264  *
1265  * </ioctl>
1266  */
1267 #define WE_GET_RX_STBC       14
1268 /*
1269  * <ioctl>
1270  * get_shortgi - Get the value of the current short GI setting
1271  *
1272  * @INPUT: None
1273  *
1274  * @OUTPUT: Enable/disable of shortgi
1275  *  wlan0     get_shortgi:1
1276  *
1277  * This IOCTL gets the value of the current short GI setting
1278  *
1279  * @E.g: iwpriv wlan0 get_shortgi
1280  *
1281  * Supported Feature: STA
1282  *
1283  * Usage: Internal/External
1284  *
1285  * </ioctl>
1286  */
1287 #define WE_GET_SHORT_GI      15
1288 /*
1289  * <ioctl>
1290  * get_rtscts - Get the value of the current RTS/CTS setting.
1291  *
1292  * @INPUT: None
1293  *
1294  * @OUTPUT: Enable/disable of RTS/CTS
1295  *  wlan0     get_rtscts:33
1296  *
1297  * This IOTCL get the value of the current RTS/CTS setting.
1298  *
1299  * @E.g: iwpriv wlan0 get_rtscts
1300  *
1301  * Supported Feature: STA
1302  *
1303  * Usage: Internal/External
1304  *
1305  * </ioctl>
1306  */
1307 #define WE_GET_RTSCTS        16
1308 /*
1309  * <ioctl>
1310  * get_chwidth - Get the current channel width setting
1311  *
1312  * @INPUT: None
1313  *
1314  * @OUTPUT: channel width
1315  *  wlan0     get_chwidth:0
1316  *
1317  * This IOTCL get the current channel width setting.
1318  *
1319  * @E.g: iwpriv wlan0 get_chwidth
1320  *
1321  * Supported Feature: STA
1322  *
1323  * Usage: Internal/External
1324  *
1325  * </ioctl>
1326  */
1327 #define WE_GET_CHWIDTH       17
1328 /*
1329  * <ioctl>
1330  * get_anienable - Get the anienable
1331  *
1332  * @INPUT: None
1333  *
1334  * @OUTPUT:
1335  *  wlan0     get_anienable:0
1336  *
1337  * This IOTCL get the anienable
1338  *
1339  * @E.g: iwpriv wlan0 get_anienable
1340  *
1341  * Supported Feature: STA
1342  *
1343  * Usage: Internal/External
1344  *
1345  * </ioctl>
1346  */
1347 #define WE_GET_ANI_EN_DIS    18
1348 /*
1349  * <ioctl>
1350  * get_aniplen  - Get the aniplen
1351  *
1352  * @INPUT: None
1353  *
1354  * @OUTPUT:
1355  *  wlan0     get_aniplen:0
1356  *
1357  * This IOTCL get the aniplen
1358  *
1359  * @E.g: iwpriv wlan0 get_aniplen
1360  *
1361  * Supported Feature: STA
1362  *
1363  * Usage: Internal/External
1364  *
1365  * </ioctl>
1366  */
1367 #define WE_GET_ANI_POLL_PERIOD    19
1368 /*
1369  * <ioctl>
1370  * get_anilislen- Get the anilislen
1371  *
1372  * @INPUT: None
1373  *
1374  * @OUTPUT:
1375  *  wlan0     get_anilislen:0
1376  *
1377  * This IOTCL used to get anilislen
1378  *
1379  * @E.g: iwpriv wlan0 get_anilislen
1380  *
1381  * Supported Feature: STA
1382  *
1383  * Usage: Internal/External
1384  *
1385  * </ioctl>
1386  */
1387 #define WE_GET_ANI_LISTEN_PERIOD  20
1388 /*
1389  * <ioctl>
1390  * get_aniofdmlvl - Get the OFDM level
1391  *
1392  * @INPUT: None
1393  *
1394  * @OUTPUT: OFDM
1395  *  wlan0     get_aniofdmlvl:0
1396  *
1397  * This IOTCL used to get ofdm level
1398  *
1399  * @E.g: iwpriv wlan0 get_aniofdmlvl
1400  *
1401  * Supported Feature: STA
1402  *
1403  * Usage: Internal/External
1404  *
1405  * </ioctl>
1406  */
1407 #define WE_GET_ANI_OFDM_LEVEL     21
1408 /*
1409  * <ioctl>
1410  * get_aniccklvl - Get the cck level
1411  *
1412  * @INPUT: None
1413  *
1414  * @OUTPUT:
1415  *  wlan0     get_aniccklvl:0
1416  *
1417  * This IOTCL used to get cck level
1418  *
1419  * @E.g: iwpriv wlan0 get_aniccklvl
1420  *
1421  * Supported Feature: STA
1422  *
1423  * Usage: Internal/External
1424  *
1425  * </ioctl>
1426  */
1427 #define WE_GET_ANI_CCK_LEVEL      22
1428 /*
1429  * <ioctl>
1430  * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1431  *
1432  * @INPUT: None
1433  *
1434  * @OUTPUT: Enable/disable dynamic channel bandwidth
1435  *  wlan0     get_cwmenable:0
1436  *
1437  * This IOTCL get the value of the dynamic channel bandwidth setting
1438  *
1439  * @E.g: iwpriv wlan0 get_cwmenable
1440  *
1441  * Supported Feature: STA
1442  *
1443  * Usage: Internal/External
1444  *
1445  * </ioctl>
1446  */
1447 #define WE_GET_DYNAMIC_BW         23
1448 /*
1449  * <ioctl>
1450  * get_txchainmask - Get the txchainmask that was set
1451  *
1452  * @INPUT: None
1453  *
1454  * @OUTPUT: txchainmask
1455  *  wlan0     get_txchainmask:1
1456  *
1457  * This IOCTL gets the txchainmask that was set
1458  * This command is useful if it was previously set
1459  *
1460  * @E.g: iwpriv wlan0 get_txchainmask
1461  *
1462  * Supported Feature: STA
1463  *
1464  * Usage: Internal/External
1465  *
1466  * </ioctl>
1467  */
1468 #define WE_GET_TX_CHAINMASK  24
1469 /*
1470  * <ioctl>
1471  * get_rxchainmask - Get the rxchainmask that was set
1472  *
1473  * @INPUT: None
1474  *
1475  * @OUTPUT: rxchainmask
1476  *  wlan0     get_rxchainmask:1
1477  *
1478  * This IOCTL gets the rxchainmask that was set
1479  * This command is useful only if it was previously set.
1480  *
1481  * @E.g: iwpriv wlan0 get_rxchainmask
1482  *
1483  * Supported Feature: STA
1484  *
1485  * Usage: Internal/External
1486  *
1487  * </ioctl>
1488  */
1489 #define WE_GET_RX_CHAINMASK  25
1490 /*
1491  * <ioctl>
1492  * get_11nrate - Get the fixed Tx data rate
1493  *
1494  * @INPUT: None
1495  *
1496  * @OUTPUT: Using this command does not return the same value as set
1497  *  wlan0     get_11nrate:0
1498  *
1499  * This IOCTL gets the fixed Tx data rate
1500  * This command is useful only if setting the fixed Tx rate.
1501  *
1502  * @E.g: iwpriv wlan0 get_11nrate
1503  *
1504  * Supported Feature: STA
1505  *
1506  * Usage: Internal/External
1507  *
1508  * </ioctl>
1509  */
1510 #define WE_GET_11N_RATE      26
1511 /*
1512  * <ioctl>
1513  * get_ampdu - Get the maximum subframe of ampdu
1514  *
1515  * @INPUT: None
1516  *
1517  * @OUTPUT: Maximum subframe of ampdu
1518  *  wlan0     get_ampdu:1
1519  *
1520  * This IOCTL gets the maximum subframe of ampdu
1521  * This command is useful only if setting ampdu.
1522  *
1523  * @E.g: iwpriv wlan0 get_ampdu
1524  *
1525  * Supported Feature: STA
1526  *
1527  * Usage: Internal/External
1528  *
1529  * </ioctl>
1530  */
1531 #define WE_GET_AMPDU         27
1532 /*
1533  * <ioctl>
1534  * get_amsdu - Get the maximum subframe of amsdu
1535  *
1536  * @INPUT: None
1537  *
1538  * @OUTPUT: Maximum subframe of amsdu
1539  *  wlan0     get_amsdu:1
1540  *
1541  * This IOCTL gets the maximum subframe of amsdu.
1542  * This command is useful only if setting amsdu
1543  *
1544  * @E.g: iwpriv wlan0 get_amsdu
1545  *
1546  * Supported Feature: STA
1547  *
1548  * Usage: Internal/External
1549  *
1550  * </ioctl>
1551  */
1552 #define WE_GET_AMSDU         28
1553 /*
1554  * <ioctl>
1555  * get_txpow2g - Get the current 2 GHz Tx power setting
1556  *
1557  * @INPUT: None
1558  *
1559  * @OUTPUT: Tx Power in dbm
1560  * wlan0     get_txpow2g:0
1561  *
1562  * This IOCTL gets the current 2 GHz Tx power setting
1563  * This command is useful if setting Tx power
1564  *
1565  * @E.g: iwpriv wlan0 get_txpow2g
1566  *
1567  * Supported Feature: STA
1568  *
1569  * Usage: Internal/External
1570  *
1571  * </ioctl>
1572  */
1573 #define WE_GET_TXPOW_2G      29
1574 /*
1575  * <ioctl>
1576  * get_txpow5g - Get the current 5 GHz Tx power setting
1577  *
1578  * @INPUT: None
1579  *
1580  * @OUTPUT: Tx Power in dbm
1581  * wlan0     get_txpow5g:0
1582  *
1583  * This IOCTL gets the current 5 GHz Tx power setting
1584  * This command is useful if setting Tx power
1585  *
1586  * @E.g: iwpriv wlan0 get_txpow5g
1587  *
1588  * Supported Feature: STA
1589  *
1590  * Usage: Internal/External
1591  *
1592  * </ioctl>
1593  */
1594 #define WE_GET_TXPOW_5G      30
1595 /* 31 is unused */
1596 #define WE_GET_PPS_PAID_MATCH           32
1597 #define WE_GET_PPS_GID_MATCH            33
1598 #define WE_GET_PPS_EARLY_TIM_CLEAR      34
1599 #define WE_GET_PPS_EARLY_DTIM_CLEAR     35
1600 #define WE_GET_PPS_EOF_PAD_DELIM        36
1601 #define WE_GET_PPS_MACADDR_MISMATCH     37
1602 #define WE_GET_PPS_DELIM_CRC_FAIL       38
1603 #define WE_GET_PPS_GID_NSTS_ZERO        39
1604 #define WE_GET_PPS_RSSI_CHECK           40
1605 /* Private ioctl for QPower */
1606 #define WE_GET_QPOWER_MAX_PSPOLL_COUNT            41
1607 #define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE          42
1608 #define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL   43
1609 #define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
1610 /* GTX Commands */
1611 /*
1612  * <ioctl>
1613  * get_gtxHTMcs - Get the tx HTM
1614  *
1615  * @INPUT: None
1616  *
1617  * @OUTPUT: HTM
1618  *  wlan0     get_gtxHTMcs:32896
1619  *
1620  * This IOTCL used to get HTM
1621  *
1622  * @E.g: iwpriv wlan0 get_gtxHTMcs
1623  *
1624  * Supported Feature: STA
1625  *
1626  * Usage: Internal/External
1627  *
1628  * </ioctl>
1629  */
1630 #define WE_GET_GTX_HT_MCS               47
1631 /*
1632  * <ioctl>
1633  * get_gtxVHTMcs - Get the VHTM
1634  *
1635  * @INPUT: None
1636  *
1637  * @OUTPUT: VHTM
1638  *  wlan0     get_gtxVHTMcs:524800
1639  *
1640  * This IOTCL used to get the VHTM
1641  *
1642  * @E.g: iwpriv wlan0 get_gtxVHTMcs
1643  *
1644  * Supported Feature: STA
1645  *
1646  * Usage: Internal/External
1647  *
1648  * </ioctl>
1649  */
1650 #define WE_GET_GTX_VHT_MCS              48
1651 /*
1652  * <ioctl>
1653  * get_gtxUsrCfg - Get the tx cfg
1654  *
1655  * @INPUT: None
1656  *
1657  * @OUTPUT: TXCFG
1658  *  wlan0     get_gtxUsrCfg:32
1659  *
1660  * This IOTCL used to get the tx cfg
1661  *
1662  * @E.g: iwpriv wlan0 get_gtxUsrCfg
1663  *
1664  * Supported Feature: STA
1665  *
1666  * Usage: Internal/External
1667  *
1668  * </ioctl>
1669  */
1670 #define WE_GET_GTX_USRCFG               49
1671 /*
1672  * <ioctl>
1673  * get_gtxThre - Get the tx threshold
1674  *
1675  * @INPUT: None
1676  *
1677  * @OUTPUT: Threshold
1678  *  wlan0     get_gtxThre:3
1679  *
1680  * This IOCTL is used to get tx threshold
1681  *
1682  * @E.g: iwpriv wlan0 get_gtxThre
1683  *
1684  * Supported Feature: STA
1685  *
1686  * Usage: Internal/External
1687  *
1688  * </ioctl>
1689  */
1690 #define WE_GET_GTX_THRE                 50
1691 /*
1692  * <ioctl>
1693  * get_gtxMargin - Get the tx margin
1694  *
1695  * @INPUT: None
1696  *
1697  * @OUTPUT: GTXMARGIN
1698  *  wlan0     get_gtxMargin:2
1699  *
1700  * This IOCTL is used to set tx margin
1701  *
1702  * @E.g: iwpriv wlan0 get_gtxMargin
1703  *
1704  * Supported Feature: STA
1705  *
1706  * Usage: Internal/External
1707  *
1708  * </ioctl>
1709  */
1710 #define WE_GET_GTX_MARGIN               51
1711 /*
1712  * <ioctl>
1713  * get_gtxStep - Get the tx step
1714  *
1715  * @INPUT: None
1716  *
1717  * @OUTPUT: GTXSTEP
1718  * wlan0     get_gtxStep:0
1719  *
1720  * This IOCTL is used to get the gtx step
1721  *
1722  * @E.g: iwpriv wlan0 get_gtxStep
1723  *
1724  * Supported Feature: STA
1725  *
1726  * Usage: Internal/External
1727  *
1728  * </ioctl>
1729  */
1730 #define WE_GET_GTX_STEP                 52
1731 /*
1732  * <ioctl>
1733  * get_gtxMinTpc - Get the tx miminum tpc
1734  *
1735  * @INPUT: None
1736  *
1737  * @OUTPUT: TPC
1738  * wlan0     get_gtxMinTpc:0
1739  *
1740  * This IOCTL is used to get tx miminum tpc
1741  *
1742  * @E.g: iwpriv wlan0 get_gtxMinTpc
1743  *
1744  * Supported Feature: STA
1745  *
1746  * Usage: Internal/External
1747  *
1748  * </ioctl>
1749  */
1750 #define WE_GET_GTX_MINTPC               53
1751 /*
1752  * <ioctl>
1753  * get_gtxBWMask - Get the tx BW MASK
1754  *
1755  * @INPUT: None
1756  *
1757  * @OUTPUT: MASK
1758  * wlan0     get_gtxBWMask:15
1759  *
1760  * This IOCTL is used get gtx bw mask
1761  *
1762  * @E.g: iwpriv wlan0 get_gtxBWMask
1763  *
1764  * Supported Feature: STA
1765  *
1766  * Usage: Internal/External
1767  *
1768  * </ioctl>
1769  */
1770 #define WE_GET_GTX_BWMASK               54
1771 #define WE_GET_TEMPERATURE              56
1772 #define WE_CAP_TSF                      58
1773 #define WE_GET_ROAM_SYNCH_DELAY         59
1774 
1775 /*
1776  * <ioctl>
1777  * get_dcm - Get dcm enablement value
1778  *
1779  * @INPUT: None
1780  *
1781  * @OUTPUT: 0/1
1782  * wlan0     get_dcm
1783  *
1784  * This IOCTL is used get dcm value
1785  *
1786  * Supported Feature: STA/SAP
1787  *
1788  * Usage: Internal
1789  *
1790  * </ioctl>
1791  */
1792 #define WE_GET_DCM                      60
1793 
1794 /*
1795  * <ioctl>
1796  * get_dcm - Get range extension enablement value
1797  *
1798  * @INPUT: None
1799  *
1800  * @OUTPUT: 0/1
1801  * wlan0     get_range_ext
1802  *
1803  * This IOCTL is used get range_extension value
1804  *
1805  * Supported Feature: STA/SAP
1806  *
1807  * Usage: Internal
1808  *
1809  * </ioctl>
1810  */
1811 #define WE_GET_RANGE_EXT                61
1812 
1813 /* Private ioctls and their sub-ioctls */
1814 #define WLAN_PRIV_SET_INT_GET_INT     (SIOCIWFIRSTPRIV + 2)
1815 
1816 /* Private ioctls and their sub-ioctls */
1817 #define WLAN_PRIV_SET_CHAR_GET_NONE   (SIOCIWFIRSTPRIV + 3)
1818 #define WE_WOWL_ADD_PTRN     1
1819 #define WE_WOWL_DEL_PTRN     2
1820 /*
1821  * <ioctl>
1822  * neighbor - Send neighbor report request
1823  *
1824  * @INPUT: string
1825  *
1826  * @OUTPUT: None
1827  *
1828  * This IOCTL create a Neighbor report request and send it to peer
1829  *
1830  * @E.g: iwpriv wlan0 neighbor "SSID"
1831  *
1832  * Supported Feature: 11k
1833  *
1834  * Usage: Internal/External
1835  *
1836  * </ioctl>
1837  */
1838 #define WE_NEIGHBOR_REPORT_REQUEST 3
1839 /*
1840  * <ioctl>
1841  * set_ap_wps_ie - Set the P2P IE of the probe response
1842  *
1843  * @INPUT: string
1844  *
1845  * @OUTPUT: None
1846  *
1847  * This IOCTL sets the P2P IE of the probe response
1848  *
1849  * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1850  *
1851  * Supported Feature: STA
1852  *
1853  * Usage: Internal/External
1854  *
1855  * </ioctl>
1856  */
1857 #define WE_SET_AP_WPS_IE     4
1858 
1859 /* 5 is unused */
1860 
1861 /*
1862  * <ioctl>
1863  * unit_test - execute component-level unit tests
1864  *
1865  * @INPUT: string - the name of the component to test.
1866  *	All tests are executed if unspecified
1867  * @OUTPUT: None
1868  *
1869  * Usage: Internal only
1870  * </ioctl>
1871  */
1872 #define WE_UNIT_TEST         6
1873 
1874 /* Private ioctls and their sub-ioctls */
1875 #define WLAN_PRIV_SET_THREE_INT_GET_NONE   (SIOCIWFIRSTPRIV + 4)
1876 #define WE_SET_WLAN_DBG      1
1877 #define WE_SET_DP_TRACE      2
1878 #define WE_SET_FW_TEST       4
1879 
1880 /* Private ioctls and their sub-ioctls */
1881 #define WLAN_PRIV_GET_CHAR_SET_NONE   (SIOCIWFIRSTPRIV + 5)
1882 #define WE_WLAN_VERSION      1
1883 #define WE_GET_STATS         2
1884 /*
1885  * <ioctl>
1886  * getConfig - gets the values of all configurations listed in WCNSS
1887  *
1888  * @INPUT: None
1889  *
1890  * @OUTPUT: Current configuration to the sys log
1891  *  wlan0	getConfig: WLAN configuration written to system log
1892  *
1893  * This IOCTL gets the values of all configurations listed in WCNSS
1894  *
1895  * @E.g: iwpriv wlan0 getConfig
1896  *
1897  * Supported Feature: STA
1898  *
1899  * Usage: Internal/External
1900  *
1901  * </ioctl>
1902  */
1903 #define WE_GET_CFG           3
1904 #define WE_GET_WMM_STATUS    4
1905 /*
1906  * <ioctl>
1907  * getChannelList - Get the available channel list while in QCMobileAP
1908  *
1909  * @INPUT: None
1910  *
1911  * @OUTPUT: Channel list
1912  * wlan0     getChannelList:36 US 1..165
1913  *
1914  * This IOCTL gets the available channel list while in QCMobileAP
1915  *
1916  * @E.g: iwpriv wlan0 getChannelList
1917  *
1918  * Supported Feature: STA
1919  *
1920  * Usage: Internal/External
1921  *
1922  * </ioctl>
1923  */
1924 #define WE_GET_CHANNEL_LIST  5
1925 /*
1926  * <ioctl>
1927  * getRSSI - Get the Received Signal Strength Indicator
1928  *
1929  * @INPUT: None
1930  *
1931  * @OUTPUT: RSSI
1932  * wlan0     getRSSI:rsssi=-32
1933  *
1934  * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1935  *
1936  * @E.g: iwpriv wlan0 getRSSI
1937  *
1938  * Supported Feature: STA
1939  *
1940  * Usage: Internal/External
1941  *
1942  * </ioctl>
1943  */
1944 #define WE_GET_RSSI          6
1945 
1946 /*
1947  * <ioctl>
1948  * getSuspendStats - Get suspend/resume stats
1949  *
1950  * @INPUT: None
1951  *
1952  * @OUTPUT: character string containing formatted suspend/resume stats
1953  *
1954  * This ioctl is used to get suspend/resume stats formatted for display.
1955  * Currently it includes suspend/resume counts, wow wake up reasons, and
1956  * suspend fail reasons.
1957  *
1958  * @E.g: iwpriv wlan0 getSuspendStats
1959  * iwpriv wlan0 getSuspendStats
1960  *
1961  * Supported Feature: suspend/resume
1962  *
1963  * Usage: Internal
1964  *
1965  * </ioctl>
1966  */
1967 #define WE_GET_SUSPEND_RESUME_STATS 7
1968 #ifdef FEATURE_WLAN_TDLS
1969 /*
1970  * <ioctl>
1971  * getTdlsPeers - Get all TDLS peers.
1972  *
1973  * @INPUT: None
1974  *
1975  * @OUTPUT: Returns the MAC address of all the TDLS peers
1976  * wlan0     getTdlsPeers:
1977  * MAC               Id cap up RSSI
1978  * ---------------------------------
1979  * 00:0a:f5:0e:bd:18  2   Y  Y  -44
1980  * 00:0a:f5:bf:0e:12  0   N  N    0
1981  *
1982  * This IOCTL is used to get all TDLS peers.
1983  *
1984  * @E.g: iwpriv wlan0 getTdlsPeers
1985  *
1986  * Supported Feature: TDLS
1987  *
1988  * Usage: Internal/External
1989  *
1990  * </ioctl>
1991  */
1992 #define WE_GET_TDLS_PEERS    8
1993 #endif
1994 /*
1995  * <ioctl>
1996  * getPMFInfo - get the PMF info of the connected session
1997  *
1998  * @INPUT: None
1999  *
2000  * @OUTPUT:
2001  *  wlan0     getPMFInfo:
2002  *  BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
2003  *  Number of Unprotected Disassocs 0
2004  *  Number of Unprotected Deauths 0
2005  *
2006  * This IOCTL is used to get the PMF stats/status of the current
2007  * connection.
2008  *
2009  * @e.g:iwpriv wlan0 getPMFInfo
2010  *
2011  * Supported Feature: PMF
2012  *
2013  * Usage: Internal/External
2014  *
2015  * </ioctl>
2016  */
2017 #define WE_GET_11W_INFO      9
2018 #define WE_GET_STATES        10
2019 /*
2020  * <ioctl>
2021  * getphymode - Get the current phymode.
2022  *
2023  * @INPUT: None
2024  *
2025  * @OUTPUT: In phymode
2026  *  wlan0     getphymode:AUTO MODE
2027  *
2028  * This IOCTL used to gets the current phymode.
2029  *
2030  * @E.g: iwpriv wlan0 getphymode
2031  *
2032  * Supported Feature: STA
2033  *
2034  * Usage: Internal/External
2035  *
2036  * </ioctl>
2037  */
2038 #define WE_GET_PHYMODE       12
2039 
2040 /*
2041  * <ioctl>
2042  * getOemDataCap - Get the oem data caps.
2043  *
2044  * @INPUT: None
2045  *
2046  * @OUTPUT: oem data capability
2047  *
2048  * This IOCTL used to gets the current oem data cap.
2049  *
2050  * @E.g: iwpriv wlan0 getOemDataCap
2051  *
2052  * Usage: Internal/External
2053  *
2054  * </ioctl>
2055  */
2056 #define WE_GET_OEM_DATA_CAP  13
2057 
2058 /*
2059  * <ioctl>
2060  * getSNR - Enable SNR Monitoring
2061  *
2062  * @INPUT: None
2063  *
2064  * @OUTPUT: Signal strength/ratio
2065  *  wlan0     getSNR:1
2066  *
2067  * This IOCTL is used to get ibss sta info
2068  *
2069  * @E.g: iwpriv wlan0 getSNR
2070  *
2071  * Supported Feature: STA
2072  *
2073  * Usage: Internal/External
2074  *
2075  * </ioctl>
2076  */
2077 
2078 #define WE_GET_SNR           14
2079 #define WE_LIST_FW_PROFILE      15
2080 
2081 /*
2082  * <ioctl>
2083  *
2084  * get_ba_timeout - to get timeout for each AC
2085  *
2086  * @INPUT: None
2087  *
2088  * @OUTPUT: displays timeout value for each access class
2089  *
2090  * @E.g.: iwpriv wlan0 get_ba_timeout
2091  *
2092  * Usage: Internal
2093  *
2094  * </ioctl>
2095  */
2096 #define WE_GET_BA_AGEING_TIMEOUT 16
2097 
2098 /*
2099  * <ioctl>
2100  *
2101  * sta_cxn_info - STA connection information
2102  *
2103  * @INPUT: none
2104  *
2105  * @OUTPUT: STA's connection information
2106  *
2107  * This IOCTL is used to get connection's information.
2108  *
2109  * @E.g: iwpriv wlan0 get_cxn_info
2110  *
2111  * Usage: Internal
2112  *
2113  * </ioctl>
2114  */
2115 #define WE_GET_STA_CXN_INFO 17
2116 
2117 /* Private ioctls and their sub-ioctls */
2118 #define WLAN_PRIV_SET_NONE_GET_NONE   (SIOCIWFIRSTPRIV + 6)
2119 
2120 /*
2121  * <ioctl>
2122  * reassoc - Trigger STA re-association to the connected AP
2123  *
2124  * @INPUT: None
2125  *
2126  * @OUTPUT: None
2127  *
2128  * This IOCTL is used to trigger STA reassociation to the connected AP.
2129  *
2130  * @E.g: iwpriv wlan0 reassoc
2131  *
2132  * Supported Feature: Roaming
2133  *
2134  * Usage: Internal
2135  *
2136  * </ioctl>
2137  */
2138 #define WE_SET_REASSOC_TRIGGER     8
2139 
2140 /* Sub ioctls 11 to 16 are not used */
2141 #define WE_GET_FW_PROFILE_DATA     18
2142 /*
2143  * <ioctl>
2144  * stop_obss_scan - Stop obss scan
2145  *
2146  * @INPUT: None
2147  *
2148  * @OUTPUT: None
2149  *
2150  * This IOCTL is used to stop obss scan
2151  *
2152  * @E.g: iwpriv wlan0 stop_obss_scan
2153  *
2154  * Supported Feature: Scan
2155  *
2156  * Usage: Internal/External
2157  *
2158  * </ioctl>
2159  */
2160 #define WE_STOP_OBSS_SCAN          19
2161 
2162 /* Private ioctls and their sub-ioctls */
2163 #define WLAN_PRIV_SET_VAR_INT_GET_NONE   (SIOCIWFIRSTPRIV + 7)
2164 
2165 #define WE_P2P_NOA_CMD       2
2166 /* subcommands 3 is unused */
2167 
2168 #define WE_MAC_PWR_DEBUG_CMD 4
2169 
2170 /* subcommand 5 is unused */
2171 /* subcommand 6 is unused */
2172 
2173 #define WE_UNIT_TEST_CMD   7
2174 
2175 #define WE_MTRACE_DUMP_CMD    8
2176 #define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD    9
2177 
2178 
2179 #ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2180 #define WE_LED_FLASHING_PARAM    10
2181 #endif
2182 
2183 
2184 /*
2185  * Sequence Numbers 11-14, 16, 17-20 are not in use.
2186  */
2187 
2188 /*
2189  * <ioctl>
2190  * pm_cinfo - Shows the concurrent connection list.
2191  *
2192  * @INPUT: None
2193  *
2194  * @OUTPUT: None
2195  *
2196  * This IOCTL is used to show the concurrent connection list.
2197  *
2198  * @E.g: iwpriv wlan0 pm_cinfo
2199  *
2200  * Supported Feature: DBS
2201  *
2202  * Usage: Internal/External
2203  *
2204  * </ioctl>
2205  */
2206 #define WE_POLICY_MANAGER_CINFO_CMD    15
2207 
2208 /*
2209  * <ioctl>
2210  * ch_avoid - unit test SAP channel avoidance
2211  *
2212  * @INPUT: chan avoid ranges
2213  *
2214  * @OUTPUT: none
2215  *
2216  * This IOCTL is used to fake a channel avoidance event.
2217  * To test SAP/GO chan switch during chan avoid event process.
2218  *
2219  * @E.g: iwpriv wlan0 ch_avoid 2452 2462
2220  *
2221  * Supported Feature: SAP chan avoidance.
2222  *
2223  * Usage: Internal
2224  *
2225  * </ioctl>
2226  */
2227 #define WE_SET_CHAN_AVOID 21
2228 
2229 /*
2230  * <ioctl>
2231  * set_scan_cfg - Set dual MAC scan config parameters.
2232  *
2233  * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2234  * @dbs: Value of DBS bit
2235  * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2236  * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2237  *
2238  * @OUTPUT: None
2239  *
2240  * This IOCTL is used to set the dual MAC scan config.
2241  *
2242  * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2243  *                    single_mac_scan_with_dbs
2244  * iwpriv wlan0 set_scan_cfg 1 0 1
2245  *
2246  * Supported Feature: DBS
2247  *
2248  * Usage: Internal/External
2249  *
2250  * </ioctl>
2251  */
2252 #define WE_SET_DUAL_MAC_SCAN_CONFIG    21
2253 
2254 /*
2255  * <ioctl>
2256  * set_fw_mode_cfg - Sets the dual mac FW mode config
2257  *
2258  * @INPUT: dbs, dfs
2259  * @dbs: DBS bit
2260  * @dfs: Agile DFS bit
2261  *
2262  * @OUTPUT: None
2263  *
2264  * This IOCTL is used to set the dual mac FW mode config.
2265  *
2266  * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2267  * iwpriv wlan0 set_fw_mode_cfg 1 1
2268  *
2269  * Supported Feature: DBS
2270  *
2271  * Usage: Internal/External
2272  *
2273  * </ioctl>
2274  */
2275 #define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
2276 #define WE_SET_MON_MODE_CHAN 23
2277 /*
2278  * <ioctl>
2279  * txrx_stats - TXRX statistics query
2280  *
2281  * @INPUT: query category, mac id (default mac id is 0)
2282  *
2283  * @OUTPUT: TXRX statistics result
2284  *
2285  * This IOCTL is used to get TXRX statistics counters.
2286  *
2287  * @E.g: iwpriv wlan0 txrx_stats 21 0
2288  * iwpriv wlan0 txrx_stats 21 1
2289  *
2290  * Usage: Internal
2291  *
2292  * </ioctl>
2293  */
2294 #define WE_SET_TXRX_STATS    24
2295 
2296 
2297 #ifdef FEATURE_WLAN_TDLS
2298 #undef  MAX_VAR_ARGS
2299 #define MAX_VAR_ARGS         11
2300 #else
2301 #undef  MAX_VAR_ARGS
2302 #define MAX_VAR_ARGS         9
2303 #endif
2304 
2305 #ifdef WLAN_FEATURE_MOTION_DETECTION
2306 #undef  MAX_VAR_ARGS
2307 #define MAX_VAR_ARGS                              15
2308 #endif /* WLAN_FEATURE_MOTION_DETECTION */
2309 #define WE_MOTION_DET_CONFIG_PARAM                25
2310 #define WE_MOTION_DET_BASE_LINE_CONFIG_PARAM      26
2311 
2312 #define WE_SET_THERMAL_THROTTLE_CFG               27
2313 /*
2314  * <ioctl>
2315  * fips_test - Perform a FIPS test
2316  *
2317  * @INPUT: Binary representation of the following packed structure
2318  *
2319  * @OUTPUT: Binary representation of the following packed structure
2320  *
2321  * This IOCTL is used to perform FIPS certification testing
2322  *
2323  * @E.g: iwpriv wlan0 fips_test <test vector>
2324  *
2325  * iwpriv wlan0 fips_test <tbd>
2326  *
2327  * Supported Feature: FIPS
2328  *
2329  * Usage: Internal
2330  *
2331  * </ioctl>
2332  */
2333 #define WLAN_PRIV_FIPS_TEST (SIOCIWFIRSTPRIV +  8)
2334 
2335 /* Private ioctls (with no sub-ioctls) */
2336 /* note that they must be odd so that they have "get" semantics */
2337 /*
2338  * <ioctl>
2339  * addTspec - Add TSPEC for each AC
2340  *
2341  * @INPUT: 19 TSPEC params
2342  *     @[arg0]: handle
2343  *     @[arg1]: tid
2344  *     @[arg2]: dir
2345  *     @[arg3]: psb
2346  *     @[arg4]: up
2347  *     @[arg5]: nomMsduSize
2348  *     @[arg6]: maxMsduSize
2349  *     @[arg7]: minDataRate
2350  *     @[arg8]: meanDataRate
2351  *     @[arg9]: peakDataRate
2352  *     @[arg10]: maxBurstSize
2353  *     @[arg11]: minPhyRate
2354  *     @[arg12]: sba
2355  *     @[arg13]: minServiceIntv
2356  *     @[arg14]: suspendIntv
2357  *     @[arg15]: burstSizeDefn
2358  *     @[arg16]: ackPolicy
2359  *     @[arg17]: inactivityPeriod
2360  *     @[arg18]: maxServiceIntv
2361  *
2362  * @OUTPUT: Success/Failure
2363  *
2364  * This IOCTL is used to add TSPEC for each AC.
2365  *
2366  * @E.g: iwpriv wlan0 addTspec <handle> <tid> <dir> <psb> <up> <nomMsduSize>
2367  *                             <maxMsduSize> <minDataRate> <meanDataRate>
2368  *                             <peakDataRate> <maxBurstSize> <minPhyRate>
2369  *                             <sba> <minServiceIntv> <suspendIntv>
2370  *                             <burstSizeDefn> <ackPolicy> <inactivityPeriod>
2371  *                             <maxServiceIntv>
2372  * iwpriv wlan0 addTspec 7001 6 2 1 6 0x80D0 0x80D0 0x14500 0x14500 0x14500
2373  *                      0 0x5B8D80 0x2001 20 2000 0 0 0 2000
2374  * wlan0     addTspec:3
2375  *
2376  * Supported Feature: WMM
2377  *
2378  * Usage: Internal/External
2379  *
2380  * </ioctl>
2381  */
2382 #define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV +  9)
2383 /*
2384  * <ioctl>
2385  * delTspec - Delete TSPEC entry for each AC
2386  *
2387  * @INPUT: 1 TSPEC param
2388  *     @[arg0]: handle
2389  *
2390  * @OUTPUT: Success/Failure
2391  *
2392  * This IOCTL is used to delete TSPEC entry for each AC.
2393  *
2394  * @E.g: iwpriv wlan0 delTspec <handle>
2395  * iwpriv wlan0 delTspec 7001
2396  * wlan0     delTspec:16
2397  *
2398  * Supported Feature: WMM
2399  *
2400  * Usage: Internal/External
2401  *
2402  * </ioctl>
2403  */
2404 #define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
2405 /*
2406  * <ioctl>
2407  * getTspec - Get TSPEC entry for each AC
2408  *
2409  * @INPUT: 1 TSPEC param
2410  *     @[arg0]: handle
2411  *
2412  * @OUTPUT: Success/Failure
2413  *
2414  * This IOCTL is used to get TSPEC entry for each AC.
2415  *
2416  * @E.g: iwpriv wlan0 getTspec <handle>
2417  * iwpriv wlan0 getTspec 7001
2418  * wlan0     delTspec:18
2419  *
2420  * Supported Feature: WMM
2421  *
2422  * Usage: Internal/External
2423  *
2424  * </ioctl>
2425  */
2426 #define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2427 
2428 /* (SIOCIWFIRSTPRIV + 10) is currently unused */
2429 /* (SIOCIWFIRSTPRIV + 12) is currently unused */
2430 /* (SIOCIWFIRSTPRIV + 14) is currently unused */
2431 #define WLAN_PRIV_SET_NONE_GET_THREE_INT   (SIOCIWFIRSTPRIV + 15)
2432 #define WE_GET_TSF      1
2433 /* (SIOCIWFIRSTPRIV + 16) is currently unused */
2434 
2435 #ifdef FEATURE_WLM_STATS
2436 /*
2437  * <ioctl>
2438  *
2439  * get_wlm_stats - Get stats from FW for game latency
2440  *
2441  * @INPUT: BITMASK inform of decimal number
2442  *
2443  * @OUTPUT: HEX string given by FW
2444  *
2445  * This IOCTL is used to get game latency related STATS from FW
2446  *
2447  * @E.g.: iwpriv wlan0 get_wlm_stats 1
2448  *
2449  * Usage: internal
2450  *
2451  * </ioctl>
2452  */
2453 #define WLAN_GET_WLM_STATS       (SIOCIWFIRSTPRIV + 17)
2454 #endif
2455 
2456 /* (SIOCIWFIRSTPRIV + 19) is currently unused */
2457 
2458 #define WLAN_PRIV_SET_FTIES             (SIOCIWFIRSTPRIV + 20)
2459 
2460 /* Private ioctl for setting the host offload feature */
2461 #define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2462 
2463 /* Private ioctl to get the statistics */
2464 #define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2465 
2466 /* Private ioctl to set the Keep Alive Params */
2467 /*
2468  * <ioctl>
2469  * setKeepAlive - Set the keep alive feature
2470  *
2471  * @INPUT: 28 bytes of information in the order of packet type, time period
2472  * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2473  *
2474  * @OUTPUT: None
2475  *
2476  * This IOCTL sets the keep alive feature to send either NULL
2477  * or unsolicited ARP response packets
2478  *
2479  * @E.g: iwpriv wlan0 setKeepAlive
2480  *
2481  * Supported Feature: STA
2482  *
2483  * Usage: Internal/External
2484  *
2485  * </ioctl>
2486  */
2487 #define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2488 
2489 #ifdef WLAN_FEATURE_PACKET_FILTERING
2490 /* Private ioctl to set the packet filtering params */
2491 #define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2492 #endif
2493 
2494 
2495 #ifdef FEATURE_WLAN_SCAN_PNO
2496 /* Private ioctl to get the statistics */
2497 #define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2498 #endif
2499 /*
2500  * <ioctl>
2501  * SETBAND - Set the operational band
2502  *
2503  * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2504  *
2505  * @OUTPUT: None
2506  *
2507  * This IOCTL Set the operational band If the new band is different from the
2508  * current operational band, it aborts the pending scan requests, flushes
2509  * the existing scan results, and then change * the band capability
2510  *
2511  * @E.g: iwpriv wlan0 SETBAND <value>
2512  *
2513  * Supported Feature: STA
2514  *
2515  * Usage: Internal/External
2516  *
2517  * </ioctl>
2518  */
2519 #define WLAN_SET_BAND_CONFIG  (SIOCIWFIRSTPRIV + 25)
2520 
2521 #define WLAN_PRIV_SET_MCBC_FILTER   (SIOCIWFIRSTPRIV + 26)
2522 /* (SIOCIWFIRSTPRIV + 27) is currently unused */
2523 
2524 /* Private ioctls and their sub-ioctls */
2525 #define WLAN_PRIV_SET_TWO_INT_GET_NONE   (SIOCIWFIRSTPRIV + 28)
2526 #define WE_SET_SMPS_PARAM    1
2527 #define WE_SET_FW_CRASH_INJECT    2
2528 #define WE_DUMP_DP_TRACE_LEVEL    3
2529 /* Private sub ioctl for enabling and setting histogram interval of profiling */
2530 #define WE_ENABLE_FW_PROFILE    4
2531 #define WE_SET_FW_PROFILE_HIST_INTVL    5
2532 
2533 /* Private sub-ioctl for initiating WoW suspend without Apps suspend */
2534 #define WE_SET_WLAN_SUSPEND    6
2535 #define WE_SET_WLAN_RESUME    7
2536 
2537 /*
2538  * <ioctl>
2539  * log_buffer - prints host/target related communication logs via dmesg
2540  *
2541  * @INPUT: Log Id, Count
2542  *
2543  * Log Id:
2544  *	0) HTC_CREDIT_HISTORY_LOG
2545  *	1) COMMAND_LOG,
2546  *	2) COMMAND_TX_CMP_LOG,
2547  *	3) MGMT_COMMAND_LOG,
2548  *	4) MGMT_COMMAND_TX_CMP_LOG,
2549  *	5) EVENT_LOG,
2550  *	6) RX_EVENT_LOG,
2551  *	7) MGMT_EVENT_LOG
2552  *
2553  * @OUTPUT: None
2554  *
2555  * @E.g:
2556  * # print up to 10 of the most recent records from HTC Credit History
2557  *	iwpriv wlan0 log_buffer 0 10
2558  * # print up to 3 of the most recent records from Event Log
2559  *	iwpriv wlan0 log_buffer 5 3
2560  *
2561  * Supported Feature: WLAN Trace
2562  *
2563  * Usage: Internal/External
2564  *
2565  * </ioctl>
2566  */
2567 #define WE_LOG_BUFFER			8
2568 
2569 /*
2570  * <ioctl>
2571  * set_ba_timeout - sets Block ACK aging timeout value for each Access class
2572  *
2573  * @INPUT: Access Class [0:BK, 1:BE, 2:VI, 3:VO], Timeout value
2574  *
2575  * @OUTPUT: None
2576  *
2577  * @E.g.:
2578  * # to set duration of 2 seconds for BE
2579  *	iwpriv wlan0 set_ba_timeout 1 2
2580  * # to set duration of 3 seconds for VO
2581  *	iwpriv wlan0 set_ba_timeout 3 3
2582  *
2583  * Usage: Internal
2584  *
2585  * </ioctl>
2586  */
2587 #define WE_SET_BA_AGEING_TIMEOUT		9
2588 
2589 /* (SIOCIWFIRSTPRIV + 29) is currently unused */
2590 
2591 /* 802.11p IOCTL */
2592 #define WLAN_SET_DOT11P_CHANNEL_SCHED    (SIOCIWFIRSTPRIV + 30)
2593 
2594 /*
2595  * <ioctl>
2596  * getLinkSpeed - Gets the current link speed in Mbps
2597  *
2598  * @INPUT: None
2599  *
2600  * @OUTPUT: linkspeed in mbps
2601  *  wlan0     getLinkSpeed:7
2602  *
2603  * This IOCTL is used get the current link speed in Mbps
2604  *
2605  * @E.g: iwpriv wlan0 getLinkSpeed
2606  *
2607  * Supported Feature: STA
2608  *
2609  * Usage: Internal/External
2610  *
2611  * </ioctl>
2612  */
2613 #define WLAN_GET_LINK_SPEED          (SIOCIWFIRSTPRIV + 31)
2614 
2615 #define WLAN_STATS_INVALID            0
2616 #define WLAN_STATS_RETRY_CNT          1
2617 #define WLAN_STATS_MUL_RETRY_CNT      2
2618 #define WLAN_STATS_TX_FRM_CNT         3
2619 #define WLAN_STATS_RX_FRM_CNT         4
2620 #define WLAN_STATS_FRM_DUP_CNT        5
2621 #define WLAN_STATS_FAIL_CNT           6
2622 #define WLAN_STATS_RTS_FAIL_CNT       7
2623 #define WLAN_STATS_ACK_FAIL_CNT       8
2624 #define WLAN_STATS_RTS_SUC_CNT        9
2625 #define WLAN_STATS_RX_DISCARD_CNT     10
2626 #define WLAN_STATS_RX_ERROR_CNT       11
2627 #define WLAN_STATS_TX_BYTE_CNT        12
2628 
2629 #define WLAN_STATS_RX_BYTE_CNT        13
2630 #define WLAN_STATS_RX_RATE            14
2631 #define WLAN_STATS_TX_RATE            15
2632 
2633 #define WLAN_STATS_RX_UC_BYTE_CNT     16
2634 #define WLAN_STATS_RX_MC_BYTE_CNT     17
2635 #define WLAN_STATS_RX_BC_BYTE_CNT     18
2636 #define WLAN_STATS_TX_UC_BYTE_CNT     19
2637 #define WLAN_STATS_TX_MC_BYTE_CNT     20
2638 #define WLAN_STATS_TX_BC_BYTE_CNT     21
2639 
2640 #define FILL_TLV(__p, __type, __size, __val, __tlen) do {		\
2641 		if ((__tlen + __size + 2) < WE_MAX_STR_LEN) {		\
2642 			*__p++ = __type;				\
2643 			*__p++ = __size;				\
2644 			memcpy(__p, __val, __size);			\
2645 			__p += __size;					\
2646 			__tlen += __size + 2;				\
2647 		} else {						\
2648 			hdd_err("FILL_TLV Failed!!!");  \
2649 		}							\
2650 	} while (0)
2651 
2652 #define TX_PER_TRACKING_DEFAULT_RATIO             5
2653 #define TX_PER_TRACKING_MAX_RATIO                10
2654 #define TX_PER_TRACKING_DEFAULT_WATERMARK         5
2655 
2656 #define WLAN_ADAPTER 0
2657 #define P2P_ADAPTER  1
2658 
2659 /**
2660  * mem_alloc_copy_from_user_helper - copy from user helper
2661  * @wrqu_data: wireless extensions request data
2662  * @len: length of @wrqu_data
2663  *
2664  * Helper function to allocate buffer and copy user data.
2665  *
2666  * Return: On success return a pointer to a kernel buffer containing a
2667  * copy of the userspace data (with an additional NUL character
2668  * appended for safety). On failure return %NULL.
2669  */
mem_alloc_copy_from_user_helper(const __user void * wrqu_data,size_t len)2670 void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2671 {
2672 	u8 *ptr = NULL;
2673 
2674 	/* in order to protect the code, an extra byte is post
2675 	 * appended to the buffer and the null termination is added.
2676 	 * However, when allocating (len+1) byte of memory, we need to
2677 	 * make sure that there is no uint overflow when doing
2678 	 * addition. In theory check len < UINT_MAX protects the uint
2679 	 * overflow. For wlan private ioctl, the buffer size is much
2680 	 * less than UINT_MAX, as a good guess, now, it is assumed
2681 	 * that the private command buffer size is no greater than 4K
2682 	 * (4096 bytes). So we use 4096 as the upper boundary for now.
2683 	 */
2684 	if (len > MAX_USER_COMMAND_SIZE) {
2685 		hdd_err("Invalid length: %zu max: %u",
2686 			 len, MAX_USER_COMMAND_SIZE);
2687 		return NULL;
2688 	}
2689 
2690 	ptr = qdf_mem_malloc(len + 1);
2691 	if (!ptr)
2692 		return NULL;
2693 
2694 	if (copy_from_user(ptr, wrqu_data, len)) {
2695 		hdd_err("failed to copy data to user buffer");
2696 		qdf_mem_free(ptr);
2697 		return NULL;
2698 	}
2699 	ptr[len] = '\0';
2700 	return ptr;
2701 }
2702 
2703 /**
2704  * hdd_priv_get_data() - Get pointer to ioctl private data
2705  * @p_priv_data: pointer to iw_point struct to be filled
2706  * @wrqu: Pointer to IOCTL Data received from userspace
2707  *
2708  * Helper function to get compatible struct iw_point passed to ioctl
2709  *
2710  * Return - 0 if p_priv_data successfully filled, error otherwise
2711  */
hdd_priv_get_data(struct iw_point * p_priv_data,union iwreq_data * wrqu)2712 int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2713 {
2714 	if ((!p_priv_data) || (!wrqu))
2715 		return -EINVAL;
2716 
2717 #ifdef CONFIG_COMPAT
2718 	if (in_compat_syscall()) {
2719 		struct compat_iw_point *p_compat_priv_data;
2720 
2721 		/* Compat task:
2722 		 * typecast to compat structure and copy the members.
2723 		 */
2724 		p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2725 
2726 		p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2727 		p_priv_data->length = p_compat_priv_data->length;
2728 		p_priv_data->flags = p_compat_priv_data->flags;
2729 	} else {
2730 #endif /* #ifdef CONFIG_COMPAT */
2731 
2732 		/* Non compat task: directly copy the structure. */
2733 		memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
2734 
2735 #ifdef CONFIG_COMPAT
2736 	}
2737 #endif /* #ifdef CONFIG_COMPAT */
2738 
2739 	return 0;
2740 }
2741 
hdd_check_wext_control(enum hdd_wext_control wext_control,struct iw_request_info * info)2742 static int hdd_check_wext_control(enum hdd_wext_control wext_control,
2743 				  struct iw_request_info *info)
2744 {
2745 	switch (wext_control) {
2746 	default:
2747 	case hdd_wext_disabled:
2748 		hdd_err_rl("Rejecting disabled ioctl %x", info->cmd);
2749 		return -ENOTSUPP;
2750 	case hdd_wext_deprecated:
2751 		hdd_nofl_debug("Using deprecated ioctl %x", info->cmd);
2752 		return 0;
2753 	case hdd_wext_enabled:
2754 		return 0;
2755 	}
2756 }
2757 
hdd_check_private_wext_control(struct hdd_context * hdd_ctx,struct iw_request_info * info)2758 int hdd_check_private_wext_control(struct hdd_context *hdd_ctx,
2759 				   struct iw_request_info *info)
2760 {
2761 	return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
2762 				      info);
2763 }
2764 
hdd_wlan_get_stats(struct wlan_hdd_link_info * link_info,uint16_t * length,char * buffer,uint16_t buf_len)2765 void hdd_wlan_get_stats(struct wlan_hdd_link_info *link_info, uint16_t *length,
2766 			char *buffer, uint16_t buf_len)
2767 {
2768 	struct hdd_tx_rx_stats *stats = &link_info->hdd_stats.tx_rx_stats;
2769 	struct dp_tx_rx_stats *dp_stats;
2770 	uint32_t len = 0;
2771 	uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
2772 	uint32_t total_rx_delv = 0, total_rx_refused = 0;
2773 	uint32_t total_tx_pkt = 0;
2774 	uint32_t total_tx_dropped = 0;
2775 	uint32_t total_tx_orphaned = 0;
2776 	uint32_t total_tx_classified_ac[WLAN_MAX_AC] = {0};
2777 	uint32_t total_tx_dropped_ac[WLAN_MAX_AC] = {0};
2778 	int i = 0;
2779 	uint8_t ac, rx_ol_con = 0, rx_ol_low_tput = 0;
2780 	struct hdd_context *hdd_ctx = link_info->adapter->hdd_ctx;
2781 	struct wlan_objmgr_vdev *vdev;
2782 
2783 	vdev = hdd_objmgr_get_vdev_by_user(link_info, WLAN_DP_ID);
2784 	if (!vdev)
2785 		return;
2786 
2787 	dp_stats = qdf_mem_malloc(sizeof(*dp_stats));
2788 	if (!dp_stats) {
2789 		hdd_objmgr_put_vdev_by_user(vdev, WLAN_DP_ID);
2790 		return;
2791 	}
2792 
2793 	if (ucfg_dp_get_txrx_stats(vdev, dp_stats)) {
2794 		hdd_objmgr_put_vdev_by_user(vdev, WLAN_DP_ID);
2795 		hdd_err("Unable to get stats from DP component");
2796 		qdf_mem_free(dp_stats);
2797 		return;
2798 	}
2799 	hdd_objmgr_put_vdev_by_user(vdev, WLAN_DP_ID);
2800 
2801 	ucfg_dp_get_disable_rx_ol_val(hdd_ctx->psoc,
2802 				      &rx_ol_con, &rx_ol_low_tput);
2803 
2804 	for (; i < NUM_CPUS; i++) {
2805 		total_rx_pkt += dp_stats->per_cpu[i].rx_packets;
2806 		total_rx_dropped += dp_stats->per_cpu[i].rx_dropped;
2807 		total_rx_delv += dp_stats->per_cpu[i].rx_delivered;
2808 		total_rx_refused += dp_stats->per_cpu[i].rx_refused;
2809 		total_tx_pkt += dp_stats->per_cpu[i].tx_called;
2810 		total_tx_dropped += dp_stats->per_cpu[i].tx_dropped;
2811 		total_tx_orphaned += dp_stats->per_cpu[i].tx_orphaned;
2812 		for (ac = 0; ac < WLAN_MAX_AC; ac++) {
2813 			total_tx_classified_ac[ac] +=
2814 					 stats->per_cpu[i].tx_classified_ac[ac];
2815 			total_tx_dropped_ac[ac] +=
2816 					    stats->per_cpu[i].tx_dropped_ac[ac];
2817 		}
2818 	}
2819 
2820 	len = scnprintf(buffer, buf_len,
2821 			"\nTransmit[%lu] - "
2822 			"called %u, dropped %u orphan %u,"
2823 			"\n[dropped]    BK %u, BE %u, VI %u, VO %u"
2824 			"\n[classified] BK %u, BE %u, VI %u, VO %u"
2825 			"\n\nReceive[%lu] - "
2826 			"packets %u, dropped %u, unsolict_arp_n_mcast_drp %u, delivered %u, refused %u\n"
2827 			"GRO - agg %u non-agg %u flush_skip %u low_tput_flush %u disabled(conc %u low-tput %u)\n",
2828 			qdf_system_ticks(),
2829 			total_tx_pkt,
2830 			total_tx_dropped,
2831 			total_tx_orphaned,
2832 			total_tx_dropped_ac[SME_AC_BK],
2833 			total_tx_dropped_ac[SME_AC_BE],
2834 			total_tx_dropped_ac[SME_AC_VI],
2835 			total_tx_dropped_ac[SME_AC_VO],
2836 			total_tx_classified_ac[SME_AC_BK],
2837 			total_tx_classified_ac[SME_AC_BE],
2838 			total_tx_classified_ac[SME_AC_VI],
2839 			total_tx_classified_ac[SME_AC_VO],
2840 			qdf_system_ticks(),
2841 			total_rx_pkt, total_rx_dropped,
2842 			qdf_atomic_read(&dp_stats->rx_usolict_arp_n_mcast_drp),
2843 			total_rx_delv,
2844 			total_rx_refused,
2845 			dp_stats->rx_aggregated, dp_stats->rx_non_aggregated,
2846 			dp_stats->rx_gro_flush_skip,
2847 			dp_stats->rx_gro_low_tput_flush,
2848 			rx_ol_con,
2849 			rx_ol_low_tput);
2850 
2851 	for (i = 0; i < NUM_CPUS; i++) {
2852 		if (dp_stats->per_cpu[i].rx_packets == 0)
2853 			continue;
2854 		len += scnprintf(buffer + len, buf_len - len,
2855 				 "Rx CPU[%d]:"
2856 				 "packets %u, dropped %u, delivered %u, refused %u\n",
2857 				 i, dp_stats->per_cpu[i].rx_packets,
2858 				 dp_stats->per_cpu[i].rx_dropped,
2859 				 dp_stats->per_cpu[i].rx_delivered,
2860 				 dp_stats->per_cpu[i].rx_refused);
2861 	}
2862 
2863 	len += scnprintf(buffer + len, buf_len - len,
2864 		"\nTX_FLOW"
2865 		"\nCurrent status: %s"
2866 		"\ntx-flow timer start count %u"
2867 		"\npause count %u, unpause count %u",
2868 		(stats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
2869 		stats->txflow_timer_cnt,
2870 		stats->txflow_pause_cnt,
2871 		stats->txflow_unpause_cnt);
2872 
2873 	len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
2874 			 link_info->vdev_id, &buffer[len],
2875 			 (buf_len - len));
2876 	*length = len + 1;
2877 	qdf_mem_free(dp_stats);
2878 }
2879 
2880 /**
2881  * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
2882  * @hdd_ctx: The Hdd context owning the stats to be written
2883  * @buffer: The char buffer to write to
2884  * @max_len: The maximum number of chars to write
2885  *
2886  * This assumes hdd_ctx has already been validated, and buffer is not NULL.
2887  *
2888  * Return - length of written content, negative number on error
2889  */
wlan_hdd_write_suspend_resume_stats(struct hdd_context * hdd_ctx,char * buffer,uint16_t max_len)2890 static int wlan_hdd_write_suspend_resume_stats(struct hdd_context *hdd_ctx,
2891 					       char *buffer, uint16_t max_len)
2892 {
2893 	int ret;
2894 	QDF_STATUS status;
2895 	struct suspend_resume_stats *sr_stats;
2896 
2897 	sr_stats = &hdd_ctx->suspend_resume_stats;
2898 	ret = scnprintf(buffer, max_len,
2899 			"\n"
2900 			"Suspends: %u\n"
2901 			"Resumes: %u\n"
2902 			"\n"
2903 			"Suspend Fail Reasons\n"
2904 			"\tIPA: %u\n"
2905 			"\tRadar: %u\n"
2906 			"\tRoam: %u\n"
2907 			"\tScan: %u\n"
2908 			"\tInitial Wakeup: %u\n"
2909 			"\n",
2910 			sr_stats->suspends, sr_stats->resumes,
2911 			sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
2912 			sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
2913 			sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
2914 			sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
2915 			sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP]);
2916 
2917 	status = ucfg_mc_cp_stats_write_wow_stats(hdd_ctx->psoc,
2918 						  &buffer[ret], max_len - ret,
2919 						  &ret);
2920 	if (QDF_IS_STATUS_ERROR(status)) {
2921 		hdd_err("Failed to get WoW stats");
2922 		return qdf_status_to_os_return(status);
2923 	}
2924 
2925 	return ret;
2926 }
2927 
2928 /**
2929  * hdd_wlan_list_fw_profile() - Get fw profiling points
2930  * @length:   Size of the data copied
2931  * @buffer:   Pointer to char buffer.
2932  * @buf_len:  Length of the char buffer.
2933  *
2934  * This function called when the "iwpriv wlan0 listProfile" command is given.
2935  * It is used to get the supported profiling points in FW.
2936  *
2937  * Return - none
2938  */
hdd_wlan_list_fw_profile(uint16_t * length,char * buffer,uint16_t buf_len)2939 void hdd_wlan_list_fw_profile(uint16_t *length,
2940 			char *buffer, uint16_t buf_len)
2941 {
2942 	uint32_t len = 0;
2943 
2944 	len = scnprintf(buffer, buf_len,
2945 		    "PROF_CPU_IDLE: %u\n"
2946 		    "PROF_PPDU_PROC: %u\n"
2947 		    "PROF_PPDU_POST: %u\n"
2948 		    "PROF_HTT_TX_INPUT: %u\n"
2949 		    "PROF_MSDU_ENQ: %u\n"
2950 		    "PROF_PPDU_POST_HAL: %u\n"
2951 		    "PROF_COMPUTE_TX_TIME: %u\n",
2952 		    PROF_CPU_IDLE,
2953 		    PROF_PPDU_PROC,
2954 		    PROF_PPDU_POST,
2955 		    PROF_HTT_TX_INPUT,
2956 		    PROF_MSDU_ENQ,
2957 		    PROF_PPDU_POST_HAL,
2958 		    PROF_COMPUTE_TX_TIME);
2959 
2960 	*length = len + 1;
2961 }
2962 
hdd_we_dump_stats(struct wlan_hdd_link_info * link_info,int value)2963 static int hdd_we_dump_stats(struct wlan_hdd_link_info *link_info, int value)
2964 {
2965 	return hdd_wlan_dump_stats(link_info->adapter, value);
2966 }
2967 
2968 /**
2969  * __iw_get_linkspeed() - Get current link speed ioctl
2970  * @dev: device upon which the ioctl was received
2971  * @info: ioctl request information
2972  * @wrqu: ioctl request data
2973  * @extra: extra ioctl buffer
2974  *
2975  * Return: 0 on success, non-zero on error
2976  */
__iw_get_linkspeed(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)2977 static int __iw_get_linkspeed(struct net_device *dev,
2978 			      struct iw_request_info *info,
2979 			      union iwreq_data *wrqu, char *extra)
2980 {
2981 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
2982 	char *out_link_speed = (char *)extra;
2983 	int len = sizeof(uint32_t) + 1;
2984 	uint32_t link_speed = 0;
2985 	struct hdd_context *hdd_ctx;
2986 	int ret, rc;
2987 
2988 	hdd_enter_dev(dev);
2989 
2990 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
2991 	ret = wlan_hdd_validate_context(hdd_ctx);
2992 	if (0 != ret)
2993 		return ret;
2994 
2995 	ret = hdd_check_private_wext_control(hdd_ctx, info);
2996 	if (0 != ret)
2997 		return ret;
2998 
2999 	ret = wlan_hdd_get_link_speed(adapter->deflink, &link_speed);
3000 	if (0 != ret)
3001 		return ret;
3002 
3003 	wrqu->data.length = len;
3004 	/* return the linkspeed as a string */
3005 	rc = snprintf(out_link_speed, len, "%u", link_speed);
3006 	if ((rc < 0) || (rc >= len)) {
3007 		/* encoding or length error? */
3008 		hdd_err("Unable to encode link speed");
3009 		return -EIO;
3010 	}
3011 
3012 	hdd_exit();
3013 	/* a value is being successfully returned */
3014 	return 0;
3015 }
3016 
3017 /**
3018  * iw_get_linkspeed() - Get current link speed ioctl
3019  * @dev: device upon which the ioctl was received
3020  * @info: ioctl request information
3021  * @wrqu: ioctl request data
3022  * @extra: extra ioctl buffer
3023  *
3024  * Return: 0 on success, non-zero on error
3025  */
iw_get_linkspeed(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)3026 static int iw_get_linkspeed(struct net_device *dev,
3027 			    struct iw_request_info *info,
3028 			    union iwreq_data *wrqu, char *extra)
3029 {
3030 	int errno;
3031 	struct osif_vdev_sync *vdev_sync;
3032 
3033 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
3034 	if (errno)
3035 		return errno;
3036 
3037 	errno = __iw_get_linkspeed(dev, info, wrqu, extra);
3038 
3039 	osif_vdev_sync_op_stop(vdev_sync);
3040 
3041 	return errno;
3042 }
3043 
3044 #ifdef FEATURE_WLM_STATS
wlan_get_wlm_stats_cb(void * cookie,const char * data)3045 static void wlan_get_wlm_stats_cb(void *cookie, const char *data)
3046 {
3047 	struct osif_request *request;
3048 	char *priv;
3049 
3050 	request = osif_request_get(cookie);
3051 	if (!request) {
3052 		hdd_err("Obsolete request");
3053 		return;
3054 	}
3055 	priv = osif_request_priv(request);
3056 	strlcpy(priv, data, WE_MAX_STR_LEN);
3057 	osif_request_complete(request);
3058 	osif_request_put(request);
3059 }
3060 
wlan_get_wlm_stats(struct hdd_adapter * adapter,uint32_t bitmask,char * response)3061 static int wlan_get_wlm_stats(struct hdd_adapter *adapter, uint32_t bitmask,
3062 			      char *response)
3063 {
3064 	struct osif_request *request;
3065 	void *cookie;
3066 	int errno;
3067 	char *priv;
3068 	static const struct osif_request_params params = {
3069 			.priv_size = WE_MAX_STR_LEN,
3070 			.timeout_ms = 2000,
3071 	};
3072 
3073 	if (!adapter) {
3074 		hdd_err("NULL argument");
3075 		return -EINVAL;
3076 	}
3077 	request = osif_request_alloc(&params);
3078 	if (!request) {
3079 		hdd_err("Request allocation failure");
3080 		return -ENOMEM;
3081 	}
3082 	cookie = osif_request_cookie(request);
3083 	errno = wma_wlm_stats_req(adapter->deflink->vdev_id, bitmask,
3084 				  params.priv_size,
3085 				  wlan_get_wlm_stats_cb, cookie);
3086 	if (errno) {
3087 		hdd_err("Request failed be sent, %d", errno);
3088 		goto cleanup;
3089 	}
3090 	errno = osif_request_wait_for_response(request);
3091 	if (errno) {
3092 		hdd_err("Timeout happened, can't complete the req");
3093 		goto cleanup;
3094 	}
3095 	priv = osif_request_priv(request);
3096 	strlcpy(response, priv, params.priv_size);
3097 
3098 cleanup:
3099 	osif_request_put(request);
3100 
3101 	return errno;
3102 }
3103 
3104 /*
3105  * Due to a limitation in iwpriv the "get_wlm_stats" ioctl is defined
3106  * to take as input a variable-length string as opposed to taking a
3107  * single integer "bitmask" value. Hence we must have a buffer large
3108  * enough to hold a string representing the largest possible
3109  * value. MAX_INT = 2,147,483,647 which can be fit in 10 chars.
3110  * Round up to 12 to hold the trailing NUL and be a multiple of 4.
3111  */
3112 #define WLM_USER_DATA_SIZE 12
3113 
__iw_get_wlm_stats(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)3114 static int __iw_get_wlm_stats(struct net_device *dev,
3115 			      struct iw_request_info *info,
3116 			      union iwreq_data *wrqu, char *extra)
3117 {
3118 	struct iw_point priv_data;
3119 	char user_data[WLM_USER_DATA_SIZE] = {0};
3120 	uint32_t bitmask = 0;
3121 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3122 	struct hdd_context *hdd_ctx;
3123 	int errno;
3124 
3125 	hdd_enter_dev(dev);
3126 
3127 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3128 	errno = wlan_hdd_validate_context(hdd_ctx);
3129 	if (errno)
3130 		return errno;
3131 
3132 	if (!capable(CAP_NET_ADMIN)) {
3133 		hdd_err("permission check failed");
3134 		return -EPERM;
3135 	}
3136 
3137 	/*
3138 	 * Since this is GETTER iwpriv ioctl, driver needs to
3139 	 * copy SET data from user space to kernel space.
3140 	 * Helper function to get iwreq_data with compat handling.
3141 	 */
3142 	if (hdd_priv_get_data(&priv_data, wrqu))
3143 		return -EINVAL;
3144 
3145 	/*
3146 	 * priv_data.pointer  should be pointing to data given
3147 	 * to iwpriv command.
3148 	 *
3149 	 * For example "iwpriv wlan0 get_wlm_stats 1234"
3150 	 *
3151 	 * priv_data.pointer should be pointing to "1234"
3152 	 * priv_data.length should be zero as this GETTER iwpriv ioctl
3153 	 */
3154 	if (!priv_data.pointer) {
3155 		hdd_err("NULL data pointer");
3156 		return -EINVAL;
3157 	}
3158 
3159 	/*
3160 	 * ideally driver should have used priv_data.length to copy
3161 	 * data from priv_data.pointer but this iwpriv IOCTL has been
3162 	 * declared as GETTER in nature which makes length field zero
3163 	 * for input arguments but priv_data.pointer still points to
3164 	 * user's input argument (just doesn't pass the length of the
3165 	 * argument)
3166 	 */
3167 	if (copy_from_user(user_data, priv_data.pointer,
3168 			   sizeof(user_data) - 1)) {
3169 		hdd_err("failed to copy data from user buffer");
3170 		return -EFAULT;
3171 	}
3172 
3173 	/*
3174 	 * user data is given in ascii, convert ascii to integer
3175 	 */
3176 	if (kstrtou32(user_data, 0, &bitmask)) {
3177 		hdd_err("failed to parse input %s", user_data);
3178 		return -EFAULT;
3179 	}
3180 
3181 	if (wlan_get_wlm_stats(adapter, bitmask, extra)) {
3182 		hdd_err("returning failure");
3183 		return -EFAULT;
3184 	}
3185 	wrqu->data.length = strlen(extra) + 1;
3186 
3187 	return 0;
3188 }
3189 
iw_get_wlm_stats(struct net_device * net_dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)3190 static int iw_get_wlm_stats(struct net_device *net_dev,
3191 			    struct iw_request_info *info,
3192 			    union iwreq_data *wrqu, char *extra)
3193 {
3194 	struct osif_vdev_sync *vdev_sync;
3195 	int errno;
3196 
3197 	errno = osif_vdev_sync_op_start(net_dev, &vdev_sync);
3198 	if (errno)
3199 		return errno;
3200 
3201 	errno = __iw_get_wlm_stats(net_dev, info, wrqu, extra);
3202 
3203 	osif_vdev_sync_op_stop(vdev_sync);
3204 
3205 	return errno;
3206 }
3207 #endif /* FEATURE_WLM_STATS */
3208 
hdd_we_ieee_to_phymode(int ieee_mode,eCsrPhyMode * csr_phy_mode)3209 static int hdd_we_ieee_to_phymode(int ieee_mode, eCsrPhyMode *csr_phy_mode)
3210 {
3211 	switch (ieee_mode) {
3212 	case IEEE80211_MODE_AUTO:
3213 	case IEEE80211_MODE_2G_AUTO:
3214 	case IEEE80211_MODE_5G_AUTO:
3215 		*csr_phy_mode = eCSR_DOT11_MODE_AUTO;
3216 		break;
3217 	case IEEE80211_MODE_11A:
3218 		*csr_phy_mode = eCSR_DOT11_MODE_11a;
3219 		break;
3220 	case IEEE80211_MODE_11B:
3221 		*csr_phy_mode = eCSR_DOT11_MODE_11b;
3222 		break;
3223 	case IEEE80211_MODE_11G:
3224 		*csr_phy_mode = eCSR_DOT11_MODE_11g;
3225 		break;
3226 	case IEEE80211_MODE_11NA_HT20:
3227 	case IEEE80211_MODE_11NA_HT40:
3228 	case IEEE80211_MODE_11NG_HT20:
3229 	case IEEE80211_MODE_11NG_HT40:
3230 	case IEEE80211_MODE_11AGN:
3231 		*csr_phy_mode = eCSR_DOT11_MODE_11n;
3232 		break;
3233 	case IEEE80211_MODE_11AC_VHT20:
3234 	case IEEE80211_MODE_11AC_VHT40:
3235 	case IEEE80211_MODE_11AC_VHT80:
3236 		*csr_phy_mode = eCSR_DOT11_MODE_11ac;
3237 		break;
3238 	default:
3239 		hdd_err("Not supported mode %d", ieee_mode);
3240 		return -EINVAL;
3241 	}
3242 
3243 	return 0;
3244 }
3245 
hdd_we_ieee_to_band(int ieee_mode,uint8_t * supported_band)3246 static int hdd_we_ieee_to_band(int ieee_mode, uint8_t *supported_band)
3247 {
3248 	switch (ieee_mode) {
3249 	case IEEE80211_MODE_AUTO:
3250 	case IEEE80211_MODE_11AC_VHT20:
3251 	case IEEE80211_MODE_11AC_VHT40:
3252 	case IEEE80211_MODE_11AC_VHT80:
3253 	case IEEE80211_MODE_11AGN:
3254 		*supported_band = BIT(REG_BAND_2G) | BIT(REG_BAND_5G);
3255 		break;
3256 	case IEEE80211_MODE_11A:
3257 	case IEEE80211_MODE_11NA_HT20:
3258 	case IEEE80211_MODE_11NA_HT40:
3259 	case IEEE80211_MODE_5G_AUTO:
3260 		*supported_band = BIT(REG_BAND_5G);
3261 		break;
3262 	case IEEE80211_MODE_11B:
3263 	case IEEE80211_MODE_11G:
3264 	case IEEE80211_MODE_11NG_HT20:
3265 	case IEEE80211_MODE_11NG_HT40:
3266 	case IEEE80211_MODE_2G_AUTO:
3267 		*supported_band = BIT(REG_BAND_2G);
3268 		break;
3269 	default:
3270 		hdd_err("Not supported mode %d", ieee_mode);
3271 		return -EINVAL;
3272 	}
3273 
3274 	return 0;
3275 }
3276 
hdd_we_ieee_to_bonding_mode(int ieee_mode,uint32_t * bonding_mode)3277 static int hdd_we_ieee_to_bonding_mode(int ieee_mode, uint32_t *bonding_mode)
3278 {
3279 	switch (ieee_mode) {
3280 	case IEEE80211_MODE_AUTO:
3281 	case IEEE80211_MODE_11NA_HT40:
3282 	case IEEE80211_MODE_11NG_HT40:
3283 	case IEEE80211_MODE_11AC_VHT40:
3284 	case IEEE80211_MODE_11AC_VHT80:
3285 	case IEEE80211_MODE_2G_AUTO:
3286 	case IEEE80211_MODE_5G_AUTO:
3287 	case IEEE80211_MODE_11AGN:
3288 		*bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
3289 		break;
3290 	case IEEE80211_MODE_11A:
3291 	case IEEE80211_MODE_11B:
3292 	case IEEE80211_MODE_11G:
3293 	case IEEE80211_MODE_11NA_HT20:
3294 	case IEEE80211_MODE_11NG_HT20:
3295 	case IEEE80211_MODE_11AC_VHT20:
3296 		*bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3297 		break;
3298 	default:
3299 		hdd_err("Not supported mode %d", ieee_mode);
3300 		return -EINVAL;
3301 	}
3302 
3303 	return 0;
3304 }
3305 
hdd_we_update_phymode(struct wlan_hdd_link_info * link_info,int new_phymode)3306 int hdd_we_update_phymode(struct wlan_hdd_link_info *link_info,
3307 			  int new_phymode)
3308 {
3309 	eCsrPhyMode phymode;
3310 	uint8_t supported_band;
3311 	uint32_t bonding_mode;
3312 	int ret;
3313 
3314 	ret = hdd_we_ieee_to_phymode(new_phymode, &phymode);
3315 	if (ret < 0)
3316 		return -EINVAL;
3317 
3318 	ret = hdd_we_ieee_to_band(new_phymode, &supported_band);
3319 	if (ret < 0)
3320 		return ret;
3321 
3322 	ret = hdd_we_ieee_to_bonding_mode(new_phymode, &bonding_mode);
3323 	if (ret < 0)
3324 		return ret;
3325 
3326 	return hdd_update_phymode(link_info->adapter, phymode, supported_band,
3327 				  bonding_mode);
3328 }
3329 
hdd_validate_pdev_reset(int value)3330 static int hdd_validate_pdev_reset(int value)
3331 {
3332 	if ((value < 1) || (value > 5)) {
3333 		hdd_warn(" Invalid value %d: Use any one of the below values\n"
3334 			 "    TX_FLUSH = 1\n"
3335 			 "    WARM_RESET = 2\n"
3336 			 "    COLD_RESET = 3\n"
3337 			 "    WARM_RESET_RESTORE_CAL = 4\n"
3338 			 "    COLD_RESET_RESTORE_CAL = 5", value);
3339 
3340 		return -EINVAL;
3341 	}
3342 
3343 	return 0;
3344 }
3345 
hdd_handle_pdev_reset(struct wlan_hdd_link_info * link_info,int value)3346 static int hdd_handle_pdev_reset(struct wlan_hdd_link_info *link_info,
3347 				 int value)
3348 {
3349 	int ret;
3350 
3351 	hdd_debug("%d", value);
3352 
3353 	ret = hdd_validate_pdev_reset(value);
3354 	if (ret)
3355 		return ret;
3356 
3357 	ret = wma_cli_set_command(link_info->vdev_id,
3358 				  wmi_pdev_param_pdev_reset,
3359 				  value, PDEV_CMD);
3360 
3361 	return ret;
3362 }
3363 
hdd_we_set_11d_state(struct wlan_hdd_link_info * link_info,int state_11d)3364 static int hdd_we_set_11d_state(struct wlan_hdd_link_info *link_info,
3365 				int state_11d)
3366 {
3367 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
3368 	bool enable_11d;
3369 	mac_handle_t mac_handle = hdd_ctx->mac_handle;
3370 	QDF_STATUS status;
3371 
3372 	if (!mac_handle)
3373 		return -EINVAL;
3374 
3375 	switch (state_11d) {
3376 	case ENABLE_11D:
3377 		enable_11d = true;
3378 		break;
3379 	case DISABLE_11D:
3380 		enable_11d = false;
3381 		break;
3382 	default:
3383 		return -EINVAL;
3384 	}
3385 
3386 	status = ucfg_mlme_set_11d_enabled(hdd_ctx->psoc, enable_11d);
3387 	if (!QDF_IS_STATUS_SUCCESS(status))
3388 		hdd_err("Invalid 11d_enable flag");
3389 
3390 	hdd_debug("11D state=%d", enable_11d);
3391 
3392 	return 0;
3393 }
3394 
hdd_we_set_power(struct wlan_hdd_link_info * link_info,int value)3395 static int hdd_we_set_power(struct wlan_hdd_link_info *link_info, int value)
3396 {
3397 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
3398 	mac_handle_t mac_handle = hdd_ctx->mac_handle;
3399 
3400 	if (!mac_handle)
3401 		return -EINVAL;
3402 
3403 	switch (value) {
3404 	case 1:
3405 		/* Enable PowerSave */
3406 		sme_ps_set_powersave(hdd_ctx->mac_handle,
3407 				     link_info->vdev_id,
3408 				     true, 0, true);
3409 		return 0;
3410 	case 2:
3411 		/* Disable PowerSave */
3412 		sme_ps_set_powersave(hdd_ctx->mac_handle,
3413 				     link_info->vdev_id,
3414 				     false, 0, true);
3415 		return 0;
3416 	case 3:
3417 		/* Enable UASPD */
3418 		sme_ps_uapsd_enable(mac_handle, link_info->vdev_id);
3419 		return 0;
3420 	case 4:
3421 		/* Disable UASPD */
3422 		sme_ps_uapsd_disable(mac_handle, link_info->vdev_id);
3423 		return 0;
3424 	default:
3425 		hdd_err("Invalid value %d", value);
3426 		return -EINVAL;
3427 	}
3428 }
3429 
hdd_we_set_max_assoc(struct wlan_hdd_link_info * link_info,int value)3430 static int hdd_we_set_max_assoc(struct wlan_hdd_link_info *link_info, int value)
3431 {
3432 	struct hdd_context *hdd_ctx;
3433 	QDF_STATUS status;
3434 
3435 	hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
3436 	status = ucfg_mlme_set_assoc_sta_limit(hdd_ctx->psoc, value);
3437 	if (QDF_IS_STATUS_ERROR(status))
3438 		hdd_err("cfg set failed, value %d status %d", value, status);
3439 
3440 	return qdf_status_to_os_return(status);
3441 }
3442 
3443 static inline int
hdd_we_set_data_inactivity_timeout(struct wlan_hdd_link_info * link_info,int inactivity_timeout)3444 hdd_we_set_data_inactivity_timeout(struct wlan_hdd_link_info *link_info,
3445 				   int inactivity_timeout)
3446 {
3447 	/* data inactivity timeout is no longer supported and is not used */
3448 	return -ENOTSUPP;
3449 }
3450 
3451 static int
hdd_we_set_wow_data_inactivity_timeout(struct wlan_hdd_link_info * link_info,int value)3452 hdd_we_set_wow_data_inactivity_timeout(struct wlan_hdd_link_info *link_info,
3453 				       int value)
3454 {
3455 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
3456 	mac_handle_t mac_handle = hdd_ctx->mac_handle;
3457 
3458 	if (!mac_handle)
3459 		return -EINVAL;
3460 
3461 	if (!cfg_in_range(CFG_PMO_WOW_DATA_INACTIVITY_TIMEOUT, value)) {
3462 		hdd_err_rl("Invalid value %d", value);
3463 		return -EINVAL;
3464 	}
3465 
3466 	ucfg_pmo_set_wow_data_inactivity_timeout(hdd_ctx->psoc, (uint8_t)value);
3467 
3468 	return 0;
3469 }
3470 
hdd_we_set_tx_power(struct wlan_hdd_link_info * link_info,int value)3471 static int hdd_we_set_tx_power(struct wlan_hdd_link_info *link_info,
3472 			       int value)
3473 {
3474 	struct hdd_adapter *adapter = link_info->adapter;
3475 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3476 	struct hdd_station_ctx *sta_ctx;
3477 	mac_handle_t mac_handle = hdd_ctx->mac_handle;
3478 	QDF_STATUS status;
3479 
3480 	if (!mac_handle)
3481 		return -EINVAL;
3482 
3483 	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
3484 	status = sme_set_tx_power(mac_handle, link_info->vdev_id,
3485 				  sta_ctx->conn_info.bssid,
3486 				  adapter->device_mode, value);
3487 
3488 	if (QDF_IS_STATUS_ERROR(status))
3489 		hdd_err("cfg set failed, value %d status %d", value, status);
3490 
3491 	return qdf_status_to_os_return(status);
3492 }
3493 
hdd_we_set_max_tx_power(struct wlan_hdd_link_info * link_info,int value)3494 static int hdd_we_set_max_tx_power(struct wlan_hdd_link_info *link_info,
3495 				   int value)
3496 {
3497 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
3498 	struct hdd_station_ctx *sta_ctx;
3499 	mac_handle_t mac_handle = hdd_ctx->mac_handle;
3500 	QDF_STATUS status;
3501 
3502 	if (!mac_handle)
3503 		return -EINVAL;
3504 
3505 	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
3506 	status = sme_set_max_tx_power(mac_handle,
3507 				      sta_ctx->conn_info.bssid,
3508 				      sta_ctx->conn_info.bssid,
3509 				      value);
3510 
3511 	if (QDF_IS_STATUS_ERROR(status))
3512 		hdd_err("cfg set failed, value %d status %d", value, status);
3513 
3514 	return qdf_status_to_os_return(status);
3515 }
3516 
hdd_we_set_max_tx_power_2_4(struct wlan_hdd_link_info * link_info,int power)3517 static int hdd_we_set_max_tx_power_2_4(struct wlan_hdd_link_info *link_info,
3518 				       int power)
3519 {
3520 	QDF_STATUS status;
3521 
3522 	hdd_debug("power %d dBm", power);
3523 	status = sme_set_max_tx_power_per_band(BAND_2G, power);
3524 	if (QDF_IS_STATUS_ERROR(status))
3525 		hdd_err("cfg set failed, value %d status %d", power, status);
3526 
3527 	return qdf_status_to_os_return(status);
3528 }
3529 
hdd_we_set_max_tx_power_5_0(struct wlan_hdd_link_info * link_info,int power)3530 static int hdd_we_set_max_tx_power_5_0(struct wlan_hdd_link_info *link_info,
3531 				       int power)
3532 {
3533 	QDF_STATUS status;
3534 
3535 	hdd_debug("power %d dBm", power);
3536 	status = sme_set_max_tx_power_per_band(BAND_5G, power);
3537 	if (QDF_IS_STATUS_ERROR(status))
3538 		hdd_err("cfg set failed, value %d status %d", power, status);
3539 
3540 	return qdf_status_to_os_return(status);
3541 }
3542 
3543 #ifdef HASTINGS_BT_WAR
3544 
hdd_hastings_bt_war_applicable(struct hdd_context * hdd_ctx)3545 static bool hdd_hastings_bt_war_applicable(struct hdd_context *hdd_ctx)
3546 {
3547 	struct pld_soc_info info;
3548 	int errno;
3549 
3550 	errno = pld_get_soc_info(hdd_ctx->parent_dev, &info);
3551 	if (errno)
3552 		return false;
3553 
3554 	/* check for HST 1.1 values */
3555 
3556 	if (info.device_version.family_number != 0x04)
3557 		return false;
3558 
3559 	if (info.device_version.device_number != 0x0A)
3560 		return false;
3561 
3562 	if (info.device_version.major_version != 0x01)
3563 		return false;
3564 
3565 	return true;
3566 }
3567 
3568 /*
3569  * replicate logic:
3570  * iwpriv wlan0 setUnitTestCmd 19 2 23 1 => enable WAR
3571  * iwpriv wlan0 setUnitTestCmd 19 2 23 0 => disable WAR
3572  */
3573 
3574 #define HASTINGS_WAR_FW_PARAM_ID 23
3575 
hdd_hastings_bt_war_set_fw(struct hdd_context * hdd_ctx,uint32_t value)3576 static int hdd_hastings_bt_war_set_fw(struct hdd_context *hdd_ctx,
3577 				      uint32_t value)
3578 {
3579 	uint32_t vdev_id = 0; /* not used */
3580 	uint32_t module_id = WLAN_MODULE_WAL;
3581 	uint32_t arg_count = 2;
3582 	uint32_t arg[2] = {HASTINGS_WAR_FW_PARAM_ID, value};
3583 	QDF_STATUS status;
3584 
3585 	if (!hdd_hastings_bt_war_applicable(hdd_ctx))
3586 		return 0;
3587 
3588 	status = wma_form_unit_test_cmd_and_send(vdev_id, module_id,
3589 						 arg_count, arg);
3590 
3591 	return qdf_status_to_os_return(status);
3592 }
3593 
hdd_hastings_bt_war_enable_fw(struct hdd_context * hdd_ctx)3594 int hdd_hastings_bt_war_enable_fw(struct hdd_context *hdd_ctx)
3595 {
3596 	return hdd_hastings_bt_war_set_fw(hdd_ctx, 1);
3597 }
3598 
hdd_hastings_bt_war_disable_fw(struct hdd_context * hdd_ctx)3599 int hdd_hastings_bt_war_disable_fw(struct hdd_context *hdd_ctx)
3600 {
3601 	return hdd_hastings_bt_war_set_fw(hdd_ctx, 0);
3602 }
3603 
3604 /* value to restore the config when the WAR is disabled */
3605 static uint32_t iface_change_wait_time_checkpoint;
checkpoint_iface_change_wait_time(struct hdd_context * hdd_ctx)3606 static void checkpoint_iface_change_wait_time(struct hdd_context *hdd_ctx)
3607 {
3608 	struct hdd_config *config = hdd_ctx->config;
3609 
3610 	/* did we already checkpoint a value ? */
3611 	if (iface_change_wait_time_checkpoint)
3612 		return;
3613 
3614 	/* checkpoint current value */
3615 	iface_change_wait_time_checkpoint = config->iface_change_wait_time;
3616 
3617 	/* was the timer enabled when we checkpointed? */
3618 	if (iface_change_wait_time_checkpoint)
3619 		return;
3620 
3621 	/* WAR was enabled at boot, use default when disable */
3622 	iface_change_wait_time_checkpoint =
3623 		cfg_default(CFG_INTERFACE_CHANGE_WAIT);
3624 }
3625 
hdd_hastings_war_enable(struct hdd_context * hdd_ctx)3626 static int hdd_hastings_war_enable(struct hdd_context *hdd_ctx)
3627 {
3628 	struct hdd_config *config = hdd_ctx->config;
3629 
3630 	config->iface_change_wait_time = 0;
3631 
3632 	return hdd_hastings_bt_war_enable_fw(hdd_ctx);
3633 }
3634 
hdd_hastings_war_disable(struct hdd_context * hdd_ctx)3635 static int hdd_hastings_war_disable(struct hdd_context *hdd_ctx)
3636 {
3637 	struct hdd_config *config = hdd_ctx->config;
3638 
3639 	config->iface_change_wait_time = iface_change_wait_time_checkpoint;
3640 
3641 	return hdd_hastings_bt_war_disable_fw(hdd_ctx);
3642 }
3643 
hdd_we_set_hastings_bt_war(struct wlan_hdd_link_info * link_info,int enable)3644 static int hdd_we_set_hastings_bt_war(struct wlan_hdd_link_info *link_info,
3645 				      int enable)
3646 {
3647 	int errno;
3648 	struct hdd_context *hdd_ctx;
3649 	struct hdd_adapter *adapter = link_info->adapter;
3650 
3651 	errno = hdd_validate_adapter(adapter);
3652 	if (errno)
3653 		return errno;
3654 
3655 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3656 	if (!hdd_hastings_bt_war_applicable(hdd_ctx))
3657 		return 0;
3658 
3659 	checkpoint_iface_change_wait_time(hdd_ctx);
3660 
3661 	return enable ?
3662 		hdd_hastings_war_enable(hdd_ctx) :
3663 		hdd_hastings_war_disable(hdd_ctx);
3664 }
3665 #endif
3666 
hdd_we_set_tm_level(struct wlan_hdd_link_info * link_info,int level)3667 static int hdd_we_set_tm_level(struct wlan_hdd_link_info *link_info, int level)
3668 {
3669 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
3670 	mac_handle_t mac_handle = hdd_ctx->mac_handle;
3671 	QDF_STATUS status;
3672 
3673 	if (!mac_handle)
3674 		return -EINVAL;
3675 
3676 	hdd_debug("Thermal Mitigation Level %d", level);
3677 	status = sme_set_thermal_level(mac_handle, level);
3678 	if (QDF_IS_STATUS_ERROR(status))
3679 		hdd_err("cfg set failed, value %d status %d", level, status);
3680 
3681 	return qdf_status_to_os_return(status);
3682 }
3683 
hdd_we_set_nss(struct wlan_hdd_link_info * link_info,int nss)3684 static int hdd_we_set_nss(struct wlan_hdd_link_info *link_info, int nss)
3685 {
3686 	QDF_STATUS status;
3687 
3688 	hdd_debug("NSS %d", nss);
3689 
3690 	if ((nss > 2) || (nss <= 0)) {
3691 		hdd_err("Invalid NSS: %d", nss);
3692 		return -EINVAL;
3693 	}
3694 
3695 	status = hdd_update_nss(link_info, nss, nss);
3696 	if (QDF_IS_STATUS_ERROR(status))
3697 		hdd_err("cfg set failed, value %d status %d", nss, status);
3698 
3699 	return qdf_status_to_os_return(status);
3700 }
3701 
hdd_we_set_short_gi(struct wlan_hdd_link_info * link_info,int sgi)3702 int hdd_we_set_short_gi(struct wlan_hdd_link_info *link_info, int sgi)
3703 {
3704 	int errno;
3705 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
3706 	mac_handle_t mac_handle = hdd_ctx->mac_handle;
3707 
3708 	hdd_debug("Short GI %d", sgi);
3709 
3710 	if (!mac_handle) {
3711 		hdd_err("NULL Mac handle");
3712 		return -EINVAL;
3713 	}
3714 
3715 	if (sgi & HDD_AUTO_RATE_SGI)
3716 		errno = sme_set_auto_rate_he_sgi(mac_handle,
3717 						 link_info->vdev_id,
3718 						 sgi);
3719 	else
3720 		errno = sme_update_ht_config(mac_handle,
3721 					     link_info->vdev_id,
3722 					     WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
3723 					     sgi);
3724 	if (errno)
3725 		hdd_err("cfg set failed, value %d status %d", sgi, errno);
3726 
3727 	return errno;
3728 }
3729 
hdd_we_set_rtscts(struct wlan_hdd_link_info * link_info,int rtscts)3730 static int hdd_we_set_rtscts(struct wlan_hdd_link_info *link_info, int rtscts)
3731 {
3732 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
3733 	mac_handle_t mac_handle = hdd_ctx->mac_handle;
3734 	uint32_t value;
3735 	uint32_t rts_threshold_val;
3736 	QDF_STATUS status;
3737 	int errno;
3738 
3739 	hdd_debug("RTSCTS %d", rtscts);
3740 
3741 	if (!mac_handle) {
3742 		hdd_err("NULL Mac handle");
3743 		return -EINVAL;
3744 	}
3745 
3746 	status = ucfg_mlme_get_rts_threshold(hdd_ctx->psoc,
3747 					     &rts_threshold_val);
3748 	if (QDF_IS_STATUS_ERROR(status)) {
3749 		hdd_err("Get rts threshold failed, status %d", status);
3750 		return -EINVAL;
3751 	}
3752 
3753 	if ((rtscts & HDD_RTSCTS_EN_MASK) == HDD_RTSCTS_ENABLE) {
3754 		value = rts_threshold_val;
3755 	} else if (((rtscts & HDD_RTSCTS_EN_MASK) == 0) ||
3756 		   ((rtscts & HDD_RTSCTS_EN_MASK) == HDD_CTS_ENABLE)) {
3757 		value = cfg_max(CFG_RTS_THRESHOLD);
3758 	} else {
3759 		hdd_err_rl("Invalid value %d", rtscts);
3760 		return -EINVAL;
3761 	}
3762 
3763 	errno = wma_cli_set_command(link_info->vdev_id,
3764 				    wmi_vdev_param_enable_rtscts,
3765 				    rtscts, VDEV_CMD);
3766 	if (errno) {
3767 		hdd_err("Failed to set firmware, errno %d", errno);
3768 		return errno;
3769 	}
3770 
3771 	status = ucfg_mlme_set_rts_threshold(hdd_ctx->psoc, value);
3772 	if (QDF_IS_STATUS_ERROR(status)) {
3773 		hdd_err("Set rts threshold failed, status %d", status);
3774 		return -EINVAL;
3775 	}
3776 
3777 	return 0;
3778 }
3779 
hdd_we_set_11n_rate(struct wlan_hdd_link_info * link_info,int rate_code)3780 static int hdd_we_set_11n_rate(struct wlan_hdd_link_info *link_info,
3781 			       int rate_code)
3782 {
3783 	uint8_t preamble = 0, nss = 0, rix = 0;
3784 	int errno;
3785 	QDF_STATUS status;
3786 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
3787 	enum wlan_phymode peer_phymode;
3788 	uint8_t *peer_mac;
3789 
3790 	peer_mac = link_info->session.station.conn_info.bssid.bytes;
3791 
3792 	hdd_debug("Rate code %d", rate_code);
3793 
3794 	if (rate_code != 0xffff) {
3795 		rix = RC_2_RATE_IDX(rate_code);
3796 		if (rate_code & 0x80) {
3797 			preamble = WMI_RATE_PREAMBLE_HT;
3798 			nss = HT_RC_2_STREAMS(rate_code) - 1;
3799 		} else {
3800 			status = ucfg_mlme_get_peer_phymode(hdd_ctx->psoc,
3801 							    peer_mac,
3802 							    &peer_phymode);
3803 			if (QDF_IS_STATUS_ERROR(status)) {
3804 				hdd_err("Failed to set rate");
3805 				return 0;
3806 			}
3807 			if (IS_WLAN_PHYMODE_HE(peer_phymode)) {
3808 				hdd_err("Do not set legacy rate %d in HE mode",
3809 					rate_code);
3810 				return 0;
3811 			}
3812 			nss = 0;
3813 			rix = RC_2_RATE_IDX(rate_code);
3814 			if (rate_code & 0x10) {
3815 				preamble = WMI_RATE_PREAMBLE_CCK;
3816 				if (rix != 0x3)
3817 					/* Enable Short preamble
3818 					 * always for CCK except 1mbps
3819 					 */
3820 					rix |= 0x4;
3821 			} else {
3822 				preamble = WMI_RATE_PREAMBLE_OFDM;
3823 			}
3824 		}
3825 		rate_code = hdd_assemble_rate_code(preamble, nss, rix);
3826 	}
3827 
3828 	hdd_debug("wmi_vdev_param_fixed_rate val %d rix %d preamble %x nss %d",
3829 		  rate_code, rix, preamble, nss);
3830 
3831 	errno = wma_cli_set_command(link_info->vdev_id,
3832 				    wmi_vdev_param_fixed_rate,
3833 				    rate_code, VDEV_CMD);
3834 	if (errno)
3835 		hdd_err("Failed to set firmware, errno %d", errno);
3836 
3837 	return errno;
3838 }
3839 
hdd_we_set_vht_rate(struct wlan_hdd_link_info * link_info,int rate_code)3840 static int hdd_we_set_vht_rate(struct wlan_hdd_link_info *link_info,
3841 			       int rate_code)
3842 {
3843 	uint8_t preamble = 0, nss = 0, rix = 0;
3844 	int errno;
3845 
3846 	hdd_debug("Rate code %d", rate_code);
3847 
3848 	if (rate_code != 0xffff) {
3849 		rix = RC_2_RATE_IDX_11AC(rate_code);
3850 		preamble = WMI_RATE_PREAMBLE_VHT;
3851 		nss = HT_RC_2_STREAMS_11AC(rate_code) - 1;
3852 		rate_code = hdd_assemble_rate_code(preamble, nss, rix);
3853 	}
3854 
3855 	hdd_debug("wmi_vdev_param_fixed_rate val %d rix %d preamble %x nss %d",
3856 		  rate_code, rix, preamble, nss);
3857 
3858 	errno = wma_cli_set_command(link_info->vdev_id,
3859 				    wmi_vdev_param_fixed_rate,
3860 				    rate_code, VDEV_CMD);
3861 	if (errno)
3862 		hdd_err("Failed to set firmware, errno %d", errno);
3863 
3864 	return errno;
3865 }
3866 
hdd_we_set_ampdu(struct wlan_hdd_link_info * link_info,int ampdu)3867 static int hdd_we_set_ampdu(struct wlan_hdd_link_info *link_info, int ampdu)
3868 {
3869 	hdd_debug("AMPDU %d", ampdu);
3870 	return wma_cli_set_command(link_info->vdev_id,
3871 				   GEN_VDEV_PARAM_AMPDU,
3872 				   ampdu, GEN_CMD);
3873 }
3874 
hdd_we_set_amsdu(struct wlan_hdd_link_info * link_info,int amsdu)3875 static int hdd_we_set_amsdu(struct wlan_hdd_link_info *link_info, int amsdu)
3876 {
3877 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
3878 	mac_handle_t mac_handle = hdd_ctx->mac_handle;
3879 	int errno;
3880 	QDF_STATUS status;
3881 
3882 	hdd_debug("AMSDU %d", amsdu);
3883 
3884 	if (!mac_handle) {
3885 		hdd_err("NULL Mac handle");
3886 		return -EINVAL;
3887 	}
3888 
3889 	status = ucfg_mlme_set_max_amsdu_num(hdd_ctx->psoc, amsdu);
3890 	if (QDF_IS_STATUS_ERROR(status)) {
3891 		hdd_err("Failed to set Max AMSDU Num to cfg");
3892 		return -EINVAL;
3893 	}
3894 
3895 	if (amsdu > 1)
3896 		sme_set_amsdu(mac_handle, true);
3897 	else
3898 		sme_set_amsdu(mac_handle, false);
3899 
3900 	errno = wma_cli_set_command(link_info->vdev_id, GEN_VDEV_PARAM_AMSDU,
3901 				    amsdu, GEN_CMD);
3902 	if (errno) {
3903 		hdd_err("Failed to set firmware, errno %d", errno);
3904 		return errno;
3905 	}
3906 
3907 	return 0;
3908 }
3909 
hdd_we_clear_stats(struct wlan_hdd_link_info * link_info,int option)3910 static int hdd_we_clear_stats(struct wlan_hdd_link_info *link_info, int option)
3911 {
3912 	return hdd_wlan_clear_stats(link_info->adapter, option);
3913 }
3914 
hdd_we_set_green_tx_param(struct hdd_adapter * adapter,green_tx_param id,const char * id_string,int value)3915 static int hdd_we_set_green_tx_param(struct hdd_adapter *adapter,
3916 				     green_tx_param id,
3917 				     const char *id_string,
3918 				     int value)
3919 {
3920 	int errno;
3921 
3922 	hdd_debug("%s %d", id_string, value);
3923 	errno = wma_cli_set_command(adapter->deflink->vdev_id,
3924 				    id, value, GTX_CMD);
3925 	if (errno)
3926 		hdd_err("Failed to set firmware, errno %d", errno);
3927 
3928 	return errno;
3929 }
3930 
3931 #define hdd_we_set_green_tx_param(adapter, id, value) \
3932 			hdd_we_set_green_tx_param(adapter, id, #id, value)
3933 
hdd_we_set_gtx_ht_mcs(struct wlan_hdd_link_info * link_info,int value)3934 static int hdd_we_set_gtx_ht_mcs(struct wlan_hdd_link_info *link_info,
3935 				 int value)
3936 {
3937 	return hdd_we_set_green_tx_param(link_info->adapter,
3938 					 wmi_vdev_param_gtx_ht_mcs,
3939 					 value);
3940 }
3941 
hdd_we_set_gtx_vht_mcs(struct wlan_hdd_link_info * link_info,int value)3942 static int hdd_we_set_gtx_vht_mcs(struct wlan_hdd_link_info *link_info,
3943 				  int value)
3944 {
3945 	return hdd_we_set_green_tx_param(link_info->adapter,
3946 					 wmi_vdev_param_gtx_vht_mcs,
3947 					 value);
3948 }
3949 
hdd_we_set_gtx_usrcfg(struct wlan_hdd_link_info * link_info,int value)3950 static int hdd_we_set_gtx_usrcfg(struct wlan_hdd_link_info *link_info,
3951 				 int value)
3952 {
3953 	return hdd_we_set_green_tx_param(link_info->adapter,
3954 					 wmi_vdev_param_gtx_usr_cfg,
3955 					 value);
3956 }
3957 
hdd_we_set_gtx_thre(struct wlan_hdd_link_info * link_info,int value)3958 static int hdd_we_set_gtx_thre(struct wlan_hdd_link_info *link_info,
3959 			       int value)
3960 {
3961 	return hdd_we_set_green_tx_param(link_info->adapter,
3962 					 wmi_vdev_param_gtx_thre,
3963 					 value);
3964 }
3965 
hdd_we_set_gtx_margin(struct wlan_hdd_link_info * link_info,int value)3966 static int hdd_we_set_gtx_margin(struct wlan_hdd_link_info *link_info,
3967 				 int value)
3968 {
3969 	return hdd_we_set_green_tx_param(link_info->adapter,
3970 					 wmi_vdev_param_gtx_margin,
3971 					 value);
3972 }
3973 
hdd_we_set_gtx_step(struct wlan_hdd_link_info * link_info,int value)3974 static int hdd_we_set_gtx_step(struct wlan_hdd_link_info *link_info,
3975 			       int value)
3976 {
3977 	return hdd_we_set_green_tx_param(link_info->adapter,
3978 					 wmi_vdev_param_gtx_step,
3979 					 value);
3980 }
3981 
hdd_we_set_gtx_mintpc(struct wlan_hdd_link_info * link_info,int value)3982 static int hdd_we_set_gtx_mintpc(struct wlan_hdd_link_info *link_info,
3983 				 int value)
3984 {
3985 	return hdd_we_set_green_tx_param(link_info->adapter,
3986 					 wmi_vdev_param_gtx_mintpc,
3987 					 value);
3988 }
3989 
hdd_we_set_gtx_bwmask(struct wlan_hdd_link_info * link_info,int value)3990 static int hdd_we_set_gtx_bwmask(struct wlan_hdd_link_info *link_info,
3991 				 int value)
3992 {
3993 	return hdd_we_set_green_tx_param(link_info->adapter,
3994 					 wmi_vdev_param_gtx_bw_mask,
3995 					 value);
3996 }
3997 
hdd_we_packet_power_save(struct hdd_adapter * adapter,packet_power_save id,const char * id_string,int value)3998 static int hdd_we_packet_power_save(struct hdd_adapter *adapter,
3999 				    packet_power_save id,
4000 				    const char *id_string,
4001 				    int value)
4002 {
4003 	int errno;
4004 
4005 	if (adapter->device_mode != QDF_STA_MODE) {
4006 		hdd_err_rl("Not supported in mode %d", adapter->device_mode);
4007 		return -EINVAL;
4008 	}
4009 
4010 	hdd_debug("%s %d", id_string, value);
4011 	errno = wma_cli_set_command(adapter->deflink->vdev_id,
4012 				    id, value, PPS_CMD);
4013 	if (errno)
4014 		hdd_err("Failed to set firmware, errno %d", errno);
4015 
4016 	return errno;
4017 }
4018 
4019 #define hdd_we_packet_power_save(adapter, id, value) \
4020 			hdd_we_packet_power_save(adapter, id, #id, value)
4021 
hdd_we_pps_paid_match(struct wlan_hdd_link_info * link_info,int value)4022 static int hdd_we_pps_paid_match(struct wlan_hdd_link_info *link_info,
4023 				 int value)
4024 {
4025 	return hdd_we_packet_power_save(link_info->adapter,
4026 					WMI_VDEV_PPS_PAID_MATCH,
4027 					value);
4028 }
4029 
hdd_we_pps_gid_match(struct wlan_hdd_link_info * link_info,int value)4030 static int hdd_we_pps_gid_match(struct wlan_hdd_link_info *link_info,
4031 				int value)
4032 {
4033 	return hdd_we_packet_power_save(link_info->adapter,
4034 					WMI_VDEV_PPS_GID_MATCH,
4035 					value);
4036 }
4037 
hdd_we_pps_early_tim_clear(struct wlan_hdd_link_info * link_info,int value)4038 static int hdd_we_pps_early_tim_clear(struct wlan_hdd_link_info *link_info,
4039 				      int value)
4040 {
4041 	return hdd_we_packet_power_save(link_info->adapter,
4042 					WMI_VDEV_PPS_EARLY_TIM_CLEAR,
4043 					value);
4044 }
4045 
hdd_we_pps_early_dtim_clear(struct wlan_hdd_link_info * link_info,int value)4046 static int hdd_we_pps_early_dtim_clear(struct wlan_hdd_link_info *link_info,
4047 				       int value)
4048 {
4049 	return hdd_we_packet_power_save(link_info->adapter,
4050 					WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
4051 					value);
4052 }
4053 
hdd_we_pps_eof_pad_delim(struct wlan_hdd_link_info * link_info,int value)4054 static int hdd_we_pps_eof_pad_delim(struct wlan_hdd_link_info *link_info,
4055 				    int value)
4056 {
4057 	return hdd_we_packet_power_save(link_info->adapter,
4058 					WMI_VDEV_PPS_EOF_PAD_DELIM,
4059 					value);
4060 }
4061 
hdd_we_pps_macaddr_mismatch(struct wlan_hdd_link_info * link_info,int value)4062 static int hdd_we_pps_macaddr_mismatch(struct wlan_hdd_link_info *link_info,
4063 				       int value)
4064 {
4065 	return hdd_we_packet_power_save(link_info->adapter,
4066 					WMI_VDEV_PPS_MACADDR_MISMATCH,
4067 					value);
4068 }
4069 
hdd_we_pps_delim_crc_fail(struct wlan_hdd_link_info * link_info,int value)4070 static int hdd_we_pps_delim_crc_fail(struct wlan_hdd_link_info *link_info,
4071 				     int value)
4072 {
4073 	return hdd_we_packet_power_save(link_info->adapter,
4074 					WMI_VDEV_PPS_DELIM_CRC_FAIL,
4075 					value);
4076 }
4077 
hdd_we_pps_gid_nsts_zero(struct wlan_hdd_link_info * link_info,int value)4078 static int hdd_we_pps_gid_nsts_zero(struct wlan_hdd_link_info *link_info,
4079 				    int value)
4080 {
4081 	return hdd_we_packet_power_save(link_info->adapter,
4082 					WMI_VDEV_PPS_GID_NSTS_ZERO,
4083 					value);
4084 }
4085 
hdd_we_pps_rssi_check(struct wlan_hdd_link_info * link_info,int value)4086 static int hdd_we_pps_rssi_check(struct wlan_hdd_link_info *link_info,
4087 				 int value)
4088 {
4089 	return hdd_we_packet_power_save(link_info->adapter,
4090 					WMI_VDEV_PPS_RSSI_CHECK,
4091 					value);
4092 }
4093 
hdd_we_pps_5g_ebt(struct wlan_hdd_link_info * link_info,int value)4094 static int hdd_we_pps_5g_ebt(struct wlan_hdd_link_info *link_info,
4095 			     int value)
4096 {
4097 	return hdd_we_packet_power_save(link_info->adapter,
4098 					WMI_VDEV_PPS_5G_EBT,
4099 					value);
4100 }
4101 
hdd_we_set_qpower(struct hdd_adapter * adapter,enum wmi_sta_powersave_param id,const char * id_string,int value)4102 static int hdd_we_set_qpower(struct hdd_adapter *adapter,
4103 			     enum wmi_sta_powersave_param id,
4104 			     const char *id_string,
4105 			     int value)
4106 {
4107 	int errno;
4108 
4109 	hdd_debug("%s %d", id_string, value);
4110 	errno = wma_cli_set_command(adapter->deflink->vdev_id,
4111 				    id, value, QPOWER_CMD);
4112 	if (errno)
4113 		hdd_err("Failed to set firmware, errno %d", errno);
4114 
4115 	return errno;
4116 }
4117 
4118 #define hdd_we_set_qpower(adapter, id, value) \
4119 			hdd_we_set_qpower(adapter, id, #id, value)
4120 
4121 static int
hdd_we_set_qpower_max_pspoll_count(struct wlan_hdd_link_info * link_info,int value)4122 hdd_we_set_qpower_max_pspoll_count(struct wlan_hdd_link_info *link_info,
4123 				   int value)
4124 {
4125 	enum wmi_sta_powersave_param id =
4126 		WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT;
4127 
4128 	return hdd_we_set_qpower(link_info->adapter, id, value);
4129 }
4130 
4131 static int
hdd_we_set_qpower_max_tx_before_wake(struct wlan_hdd_link_info * link_info,int value)4132 hdd_we_set_qpower_max_tx_before_wake(struct wlan_hdd_link_info *link_info,
4133 				     int value)
4134 {
4135 	enum wmi_sta_powersave_param id =
4136 		WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE;
4137 
4138 	return hdd_we_set_qpower(link_info->adapter, id, value);
4139 }
4140 
4141 static int
hdd_we_set_qpower_spec_pspoll_wake_interval(struct wlan_hdd_link_info * link_info,int value)4142 hdd_we_set_qpower_spec_pspoll_wake_interval(struct wlan_hdd_link_info *link_info,
4143 					    int value)
4144 {
4145 	enum wmi_sta_powersave_param id =
4146 		WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL;
4147 
4148 	return hdd_we_set_qpower(link_info->adapter, id, value);
4149 }
4150 
4151 static int
hdd_we_set_qpower_spec_max_spec_nodata_pspoll(struct wlan_hdd_link_info * link_info,int value)4152 hdd_we_set_qpower_spec_max_spec_nodata_pspoll(struct wlan_hdd_link_info *link_info,
4153 					      int value)
4154 {
4155 	enum wmi_sta_powersave_param id =
4156 		WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL;
4157 
4158 	return hdd_we_set_qpower(link_info->adapter, id, value);
4159 }
4160 
hdd_we_set_pdev(struct hdd_adapter * adapter,wmi_conv_pdev_params_id id,const char * id_string,int value)4161 static int hdd_we_set_pdev(struct hdd_adapter *adapter,
4162 			   wmi_conv_pdev_params_id id,
4163 			   const char *id_string,
4164 			   int value)
4165 {
4166 	int errno;
4167 
4168 	hdd_debug("%s %d", id_string, value);
4169 	errno = wma_cli_set_command(adapter->deflink->vdev_id,
4170 				    id, value, PDEV_CMD);
4171 	if (errno)
4172 		hdd_err("Failed to set firmware, errno %d", errno);
4173 
4174 	return errno;
4175 }
4176 
4177 #define hdd_we_set_pdev(adapter, id, value) \
4178 			hdd_we_set_pdev(adapter, id, #id, value)
4179 
hdd_we_set_ani_en_dis(struct wlan_hdd_link_info * link_info,int value)4180 static int hdd_we_set_ani_en_dis(struct wlan_hdd_link_info *link_info,
4181 				 int value)
4182 {
4183 	return hdd_we_set_pdev(link_info->adapter,
4184 			       wmi_pdev_param_ani_enable,
4185 			       value);
4186 }
4187 
hdd_we_set_ani_poll_period(struct wlan_hdd_link_info * link_info,int value)4188 static int hdd_we_set_ani_poll_period(struct wlan_hdd_link_info *link_info,
4189 				      int value)
4190 {
4191 	return hdd_we_set_pdev(link_info->adapter,
4192 			       wmi_pdev_param_ani_poll_period,
4193 			       value);
4194 }
4195 
hdd_we_set_ani_listen_period(struct wlan_hdd_link_info * link_info,int value)4196 static int hdd_we_set_ani_listen_period(struct wlan_hdd_link_info *link_info,
4197 					int value)
4198 {
4199 	return hdd_we_set_pdev(link_info->adapter,
4200 			       wmi_pdev_param_ani_listen_period,
4201 			       value);
4202 }
4203 
hdd_we_set_ani_ofdm_level(struct wlan_hdd_link_info * link_info,int value)4204 static int hdd_we_set_ani_ofdm_level(struct wlan_hdd_link_info *link_info,
4205 				     int value)
4206 {
4207 	return hdd_we_set_pdev(link_info->adapter,
4208 			       wmi_pdev_param_ani_ofdm_level,
4209 			       value);
4210 }
4211 
hdd_we_set_ani_cck_level(struct wlan_hdd_link_info * link_info,int value)4212 static int hdd_we_set_ani_cck_level(struct wlan_hdd_link_info *link_info,
4213 				    int value)
4214 {
4215 	return hdd_we_set_pdev(link_info->adapter,
4216 			       wmi_pdev_param_ani_cck_level,
4217 			       value);
4218 }
4219 
hdd_we_set_dynamic_bw(struct wlan_hdd_link_info * link_info,int value)4220 static int hdd_we_set_dynamic_bw(struct wlan_hdd_link_info *link_info,
4221 				 int value)
4222 {
4223 	return hdd_we_set_pdev(link_info->adapter,
4224 			       wmi_pdev_param_dynamic_bw,
4225 			       value);
4226 }
4227 
hdd_we_set_cts_cbw(struct wlan_hdd_link_info * link_info,int value)4228 static int hdd_we_set_cts_cbw(struct wlan_hdd_link_info *link_info,
4229 			      int value)
4230 {
4231 	return hdd_we_set_pdev(link_info->adapter,
4232 			       wmi_pdev_param_cts_cbw,
4233 			       value);
4234 }
4235 
hdd_we_set_tx_chainmask(struct wlan_hdd_link_info * link_info,int value)4236 static int hdd_we_set_tx_chainmask(struct wlan_hdd_link_info *link_info,
4237 				   int value)
4238 {
4239 	int errno;
4240 
4241 	errno = hdd_we_set_pdev(link_info->adapter,
4242 				wmi_pdev_param_tx_chain_mask,
4243 				value);
4244 	if (errno)
4245 		return errno;
4246 
4247 	return hdd_set_antenna_mode(link_info, value);
4248 }
4249 
hdd_we_set_rx_chainmask(struct wlan_hdd_link_info * link_info,int value)4250 static int hdd_we_set_rx_chainmask(struct wlan_hdd_link_info *link_info,
4251 				   int value)
4252 {
4253 	int errno;
4254 
4255 	errno = hdd_we_set_pdev(link_info->adapter,
4256 				wmi_pdev_param_rx_chain_mask,
4257 				value);
4258 	if (errno)
4259 		return errno;
4260 
4261 	return hdd_set_antenna_mode(link_info, value);
4262 }
4263 
hdd_we_set_txpow_2g(struct wlan_hdd_link_info * link_info,int value)4264 static int hdd_we_set_txpow_2g(struct wlan_hdd_link_info *link_info,
4265 			       int value)
4266 {
4267 	return hdd_we_set_pdev(link_info->adapter,
4268 			       wmi_pdev_param_txpower_limit2g,
4269 			       value);
4270 }
4271 
hdd_we_set_txpow_5g(struct wlan_hdd_link_info * link_info,int value)4272 static int hdd_we_set_txpow_5g(struct wlan_hdd_link_info *link_info,
4273 			       int value)
4274 {
4275 	return hdd_we_set_pdev(link_info->adapter,
4276 			       wmi_pdev_param_txpower_limit5g,
4277 			       value);
4278 }
4279 
hdd_we_set_vdev(struct hdd_adapter * adapter,int id,const char * id_string,int value)4280 static int hdd_we_set_vdev(struct hdd_adapter *adapter,
4281 			   int id,
4282 			   const char *id_string,
4283 			   int value)
4284 {
4285 	int errno;
4286 
4287 	hdd_debug("%s %d", id_string, value);
4288 	errno = wma_cli_set_command(adapter->deflink->vdev_id,
4289 				    id, value, VDEV_CMD);
4290 	if (errno)
4291 		hdd_err("Failed to set firmware, errno %d", errno);
4292 
4293 	return errno;
4294 }
4295 
4296 #define hdd_we_set_vdev(adapter, id, value) \
4297 			hdd_we_set_vdev(adapter, id, #id, value)
4298 
hdd_we_set_txrx_fwstats(struct wlan_hdd_link_info * link_info,int value)4299 static int hdd_we_set_txrx_fwstats(struct wlan_hdd_link_info *link_info,
4300 				   int value)
4301 {
4302 	return hdd_we_set_vdev(link_info->adapter,
4303 			       WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
4304 			       value);
4305 }
4306 
hdd_we_txrx_fwstats_reset(struct wlan_hdd_link_info * link_info,int value)4307 static int hdd_we_txrx_fwstats_reset(struct wlan_hdd_link_info *link_info,
4308 				     int value)
4309 {
4310 	return hdd_we_set_vdev(link_info->adapter,
4311 			       WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
4312 			       value);
4313 }
4314 
hdd_we_set_htsmps(struct wlan_hdd_link_info * link_info,int value)4315 static int hdd_we_set_htsmps(struct wlan_hdd_link_info *link_info,
4316 			     int value)
4317 {
4318 	return hdd_we_set_vdev(link_info->adapter,
4319 			       WMI_STA_SMPS_FORCE_MODE_CMDID,
4320 			       value);
4321 }
4322 
4323 static int
hdd_we_set_early_rx_adjust_enable(struct wlan_hdd_link_info * link_info,int value)4324 hdd_we_set_early_rx_adjust_enable(struct wlan_hdd_link_info *link_info,
4325 				  int value)
4326 {
4327 	if ((value != 0) && (value != 1))
4328 		return -EINVAL;
4329 
4330 	return hdd_we_set_vdev(link_info->adapter,
4331 			       wmi_vdev_param_early_rx_adjust_enable,
4332 			       value);
4333 }
4334 
4335 static int
hdd_we_set_early_rx_tgt_bmiss_num(struct wlan_hdd_link_info * link_info,int value)4336 hdd_we_set_early_rx_tgt_bmiss_num(struct wlan_hdd_link_info *link_info,
4337 				  int value)
4338 {
4339 	return hdd_we_set_vdev(link_info->adapter,
4340 			       wmi_vdev_param_early_rx_tgt_bmiss_num,
4341 			       value);
4342 }
4343 
4344 static int
hdd_we_set_early_rx_bmiss_sample_cycle(struct wlan_hdd_link_info * link_info,int value)4345 hdd_we_set_early_rx_bmiss_sample_cycle(struct wlan_hdd_link_info *link_info,
4346 				       int value)
4347 {
4348 	return hdd_we_set_vdev(link_info->adapter,
4349 			       wmi_vdev_param_early_rx_bmiss_sample_cycle,
4350 			       value);
4351 }
4352 
hdd_we_set_early_rx_slop_step(struct wlan_hdd_link_info * link_info,int value)4353 static int hdd_we_set_early_rx_slop_step(struct wlan_hdd_link_info *link_info,
4354 					 int value)
4355 {
4356 	return hdd_we_set_vdev(link_info->adapter,
4357 			       wmi_vdev_param_early_rx_slop_step,
4358 			       value);
4359 }
4360 
hdd_we_set_early_rx_init_slop(struct wlan_hdd_link_info * link_info,int value)4361 static int hdd_we_set_early_rx_init_slop(struct wlan_hdd_link_info *link_info,
4362 					 int value)
4363 {
4364 	return hdd_we_set_vdev(link_info->adapter,
4365 			       wmi_vdev_param_early_rx_init_slop,
4366 			       value);
4367 }
4368 
4369 static int
hdd_we_set_early_rx_adjust_pause(struct wlan_hdd_link_info * link_info,int value)4370 hdd_we_set_early_rx_adjust_pause(struct wlan_hdd_link_info *link_info,
4371 				 int value)
4372 {
4373 	if ((value != 0) && (value != 1))
4374 		return -EINVAL;
4375 
4376 	return hdd_we_set_vdev(link_info->adapter,
4377 			       wmi_vdev_param_early_rx_adjust_pause,
4378 			       value);
4379 }
4380 
4381 static int
hdd_we_set_early_rx_drift_sample(struct wlan_hdd_link_info * link_info,int value)4382 hdd_we_set_early_rx_drift_sample(struct wlan_hdd_link_info *link_info,
4383 				 int value)
4384 {
4385 	return hdd_we_set_vdev(link_info->adapter,
4386 			       wmi_vdev_param_early_rx_drift_sample,
4387 			       value);
4388 }
4389 
hdd_we_set_dcm(struct wlan_hdd_link_info * link_info,int value)4390 static int hdd_we_set_dcm(struct wlan_hdd_link_info *link_info,
4391 			  int value)
4392 {
4393 	return hdd_we_set_vdev(link_info->adapter,
4394 			       wmi_vdev_param_he_dcm_enable,
4395 			       value);
4396 }
4397 
4398 #define MAX_VDEV_HE_RANGE_PARAMS 2
4399 /* params being sent:
4400  * wmi_vdev_param_he_range_ext
4401  * wmi_vdev_param_non_data_he_range_ext
4402  */
4403 
hdd_we_set_range_ext(struct wlan_hdd_link_info * link_info,int value)4404 static int hdd_we_set_range_ext(struct wlan_hdd_link_info *link_info,
4405 				int value)
4406 {
4407 	int status;
4408 	struct dev_set_param setparam[MAX_VDEV_HE_RANGE_PARAMS] = {};
4409 	uint8_t index = 0;
4410 
4411 	status = mlme_check_index_setparam(setparam,
4412 					   wmi_vdev_param_he_range_ext,
4413 					   value, index++,
4414 					   MAX_VDEV_HE_RANGE_PARAMS);
4415 	if (QDF_IS_STATUS_ERROR(status)) {
4416 		hdd_err("failed at wmi_vdev_param_he_range_ext");
4417 		goto error;
4418 	}
4419 
4420 	status = mlme_check_index_setparam(setparam,
4421 					   wmi_vdev_param_non_data_he_range_ext,
4422 					   value, index++,
4423 					   MAX_VDEV_HE_RANGE_PARAMS);
4424 	if (QDF_IS_STATUS_ERROR(status)) {
4425 		hdd_err("failed at wmi_vdev_param_non_data_he_range_ext");
4426 		goto error;
4427 	}
4428 
4429 	status = wma_send_multi_pdev_vdev_set_params(MLME_VDEV_SETPARAM,
4430 						     link_info->vdev_id,
4431 						     setparam, index);
4432 	if (QDF_IS_STATUS_ERROR(status))
4433 		hdd_err("Failed to send vdev set params");
4434 
4435 error:
4436 	return status;
4437 }
4438 
hdd_we_set_dbg(struct hdd_adapter * adapter,int id,const char * id_string,int value)4439 static int hdd_we_set_dbg(struct hdd_adapter *adapter,
4440 			  int id,
4441 			  const char *id_string,
4442 			  int value)
4443 {
4444 	int errno;
4445 
4446 	hdd_debug("%s %d", id_string, value);
4447 	errno = wma_cli_set_command(adapter->deflink->vdev_id,
4448 				    id, value, DBG_CMD);
4449 	if (errno)
4450 		hdd_err("Failed to set firmware, errno %d", errno);
4451 
4452 	return errno;
4453 }
4454 
4455 #define hdd_we_set_dbg(adapter, id, value) \
4456 			hdd_we_set_dbg(adapter, id, #id, value)
4457 
hdd_we_dbglog_log_level(struct wlan_hdd_link_info * link_info,int value)4458 static int hdd_we_dbglog_log_level(struct wlan_hdd_link_info *link_info,
4459 				   int value)
4460 {
4461 	return hdd_we_set_dbg(link_info->adapter,
4462 			      WMI_DBGLOG_LOG_LEVEL,
4463 			      value);
4464 }
4465 
hdd_we_dbglog_vap_enable(struct wlan_hdd_link_info * link_info,int value)4466 static int hdd_we_dbglog_vap_enable(struct wlan_hdd_link_info *link_info,
4467 				    int value)
4468 {
4469 	return hdd_we_set_dbg(link_info->adapter,
4470 			      WMI_DBGLOG_VAP_ENABLE,
4471 			      value);
4472 }
4473 
hdd_we_dbglog_vap_disable(struct wlan_hdd_link_info * link_info,int value)4474 static int hdd_we_dbglog_vap_disable(struct wlan_hdd_link_info *link_info,
4475 				     int value)
4476 {
4477 	return hdd_we_set_dbg(link_info->adapter,
4478 			      WMI_DBGLOG_VAP_DISABLE,
4479 			      value);
4480 }
4481 
hdd_we_dbglog_module_enable(struct wlan_hdd_link_info * link_info,int value)4482 static int hdd_we_dbglog_module_enable(struct wlan_hdd_link_info *link_info,
4483 				       int value)
4484 {
4485 	return hdd_we_set_dbg(link_info->adapter,
4486 			      WMI_DBGLOG_MODULE_ENABLE,
4487 			      value);
4488 }
4489 
hdd_we_dbglog_module_disable(struct wlan_hdd_link_info * link_info,int value)4490 static int hdd_we_dbglog_module_disable(struct wlan_hdd_link_info *link_info,
4491 					int value)
4492 {
4493 	return hdd_we_set_dbg(link_info->adapter,
4494 			      WMI_DBGLOG_MODULE_DISABLE,
4495 			      value);
4496 }
4497 
hdd_we_dbglog_mod_log_level(struct wlan_hdd_link_info * link_info,int value)4498 static int hdd_we_dbglog_mod_log_level(struct wlan_hdd_link_info *link_info,
4499 				       int value)
4500 {
4501 	return hdd_we_set_dbg(link_info->adapter,
4502 			      WMI_DBGLOG_MOD_LOG_LEVEL,
4503 			      value);
4504 }
4505 
hdd_we_dbglog_type(struct wlan_hdd_link_info * link_info,int value)4506 static int hdd_we_dbglog_type(struct wlan_hdd_link_info *link_info,
4507 			      int value)
4508 {
4509 	return hdd_we_set_dbg(link_info->adapter,
4510 			      WMI_DBGLOG_TYPE,
4511 			      value);
4512 }
4513 
hdd_we_dbglog_report_enable(struct wlan_hdd_link_info * link_info,int value)4514 static int hdd_we_dbglog_report_enable(struct wlan_hdd_link_info *link_info,
4515 				       int value)
4516 {
4517 	return hdd_we_set_dbg(link_info->adapter,
4518 			      WMI_DBGLOG_REPORT_ENABLE,
4519 			      value);
4520 }
4521 
hdd_we_start_fw_profile(struct wlan_hdd_link_info * link_info,int value)4522 static int hdd_we_start_fw_profile(struct wlan_hdd_link_info *link_info,
4523 				   int value)
4524 {
4525 	return hdd_we_set_dbg(link_info->adapter,
4526 			      WMI_WLAN_PROFILE_TRIGGER_CMDID,
4527 			      value);
4528 }
4529 
hdd_we_set_channel(struct wlan_hdd_link_info * link_info,int channel)4530 static int hdd_we_set_channel(struct wlan_hdd_link_info *link_info,
4531 			      int channel)
4532 {
4533 	struct hdd_adapter *adapter = link_info->adapter;
4534 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4535 	qdf_freq_t ch_freq;
4536 	QDF_STATUS status;
4537 
4538 	hdd_debug("Set Channel %d Session ID %d mode %d", channel,
4539 		  link_info->vdev_id, adapter->device_mode);
4540 
4541 	if (!hdd_ctx->mac_handle)
4542 		return -EINVAL;
4543 
4544 	switch (adapter->device_mode) {
4545 	case QDF_STA_MODE:
4546 	case QDF_P2P_CLIENT_MODE:
4547 		/* supported */
4548 		break;
4549 	default:
4550 		hdd_err("change channel not supported for device mode %d",
4551 			adapter->device_mode);
4552 		return -EINVAL;
4553 	}
4554 	ch_freq = wlan_reg_legacy_chan_to_freq(hdd_ctx->pdev,
4555 					       channel);
4556 	status = sme_ext_change_freq(hdd_ctx->mac_handle, ch_freq,
4557 				     link_info->vdev_id);
4558 	if (status != QDF_STATUS_SUCCESS)
4559 		hdd_err("Error in change channel status %d", status);
4560 
4561 	return qdf_status_to_os_return(status);
4562 }
4563 
hdd_we_mcc_config_latency(struct wlan_hdd_link_info * link_info,int latency)4564 static int hdd_we_mcc_config_latency(struct wlan_hdd_link_info *link_info,
4565 				     int latency)
4566 {
4567 	hdd_debug("MCC latency %d", latency);
4568 
4569 	wlan_hdd_set_mcc_latency(link_info->adapter, latency);
4570 
4571 	return 0;
4572 }
4573 
hdd_we_mcc_config_quota(struct wlan_hdd_link_info * link_info,int quota)4574 static int hdd_we_mcc_config_quota(struct wlan_hdd_link_info *link_info,
4575 				   int quota)
4576 {
4577 	hdd_debug("MCC quota %dms", quota);
4578 
4579 	return wlan_hdd_set_mcc_p2p_quota(link_info->adapter, quota);
4580 }
4581 
hdd_we_set_debug_log(struct wlan_hdd_link_info * link_info,int value)4582 static int hdd_we_set_debug_log(struct wlan_hdd_link_info *link_info,
4583 				int value)
4584 {
4585 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
4586 
4587 	if (!hdd_ctx->mac_handle)
4588 		return -EINVAL;
4589 
4590 	sme_update_connect_debug(hdd_ctx->mac_handle, value);
4591 
4592 	return 0;
4593 }
4594 
hdd_we_set_scan_disable(struct wlan_hdd_link_info * link_info,int value)4595 static int hdd_we_set_scan_disable(struct wlan_hdd_link_info *link_info,
4596 				   int value)
4597 {
4598 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
4599 
4600 	hdd_debug("%d", value);
4601 
4602 	if (!hdd_ctx->psoc)
4603 		return -EINVAL;
4604 
4605 	if (value)
4606 		ucfg_scan_psoc_set_disable(hdd_ctx->psoc, REASON_USER_SPACE);
4607 	else
4608 		ucfg_scan_psoc_set_enable(hdd_ctx->psoc, REASON_USER_SPACE);
4609 
4610 	return 0;
4611 }
4612 
hdd_we_set_conc_system_pref(struct wlan_hdd_link_info * link_info,int preference)4613 static int hdd_we_set_conc_system_pref(struct wlan_hdd_link_info *link_info,
4614 				       int preference)
4615 {
4616 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
4617 
4618 	hdd_debug("%d", preference);
4619 
4620 	if (!hdd_ctx->psoc)
4621 		return -EINVAL;
4622 
4623 	ucfg_policy_mgr_set_sys_pref(hdd_ctx->psoc, preference);
4624 
4625 	return 0;
4626 }
4627 
hdd_we_set_11ax_rate(struct wlan_hdd_link_info * link_info,int rate)4628 static int hdd_we_set_11ax_rate(struct wlan_hdd_link_info *link_info,
4629 				int rate)
4630 {
4631 	return hdd_set_11ax_rate(link_info->adapter, rate, NULL);
4632 }
4633 
hdd_we_set_modulated_dtim(struct wlan_hdd_link_info * link_info,int value)4634 static int hdd_we_set_modulated_dtim(struct wlan_hdd_link_info *link_info,
4635 				     int value)
4636 {
4637 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(link_info->adapter);
4638 
4639 	hdd_debug("%d", value);
4640 
4641 	if (!hdd_ctx->psoc)
4642 		return -EINVAL;
4643 
4644 	if ((value < cfg_min(CFG_PMO_ENABLE_MODULATED_DTIM)) ||
4645 	    (value > cfg_max(CFG_PMO_ENABLE_MODULATED_DTIM))) {
4646 		hdd_err("Invalid value %d", value);
4647 		return -EINVAL;
4648 	}
4649 
4650 	ucfg_policy_mgr_set_sys_pref(hdd_ctx->psoc, value);
4651 
4652 	return 0;
4653 }
4654 
4655 #ifdef WLAN_FEATURE_MOTION_DETECTION
4656 /**
4657  * hdd_we_motion_det_start_stop - start/stop motion detection
4658  * @link_info: Link info pointer in HDD adapter
4659  * @value: start/stop value to set
4660  *
4661  * Return: 0 on success, error on failure
4662  */
hdd_we_motion_det_start_stop(struct wlan_hdd_link_info * link_info,int value)4663 static int hdd_we_motion_det_start_stop(struct wlan_hdd_link_info *link_info,
4664 					int value)
4665 {
4666 	struct sme_motion_det_en motion_det;
4667 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4668 
4669 	if (value < 0 || value > 1) {
4670 		hdd_err("Invalid value %d in mt_start", value);
4671 		return -EINVAL;
4672 	}
4673 
4674 	if (!adapter->motion_det_cfg) {
4675 		hdd_err("Motion Detection config values not available");
4676 		return -EINVAL;
4677 	}
4678 
4679 	if (!adapter->motion_det_baseline_value) {
4680 		hdd_err("Motion Detection Baselining not started/completed");
4681 		return -EAGAIN;
4682 	}
4683 
4684 	motion_det.vdev_id = link_info->vdev_id;
4685 	motion_det.enable = value;
4686 
4687 	if (value) {
4688 		/* For motion detection start, set motion_det_in_progress */
4689 		adapter->motion_det_in_progress = true;
4690 	} else {
4691 		/* For motion detection stop, reset motion_det_in_progress */
4692 		adapter->motion_det_in_progress = false;
4693 		adapter->motion_detection_mode = 0;
4694 	}
4695 
4696 	sme_motion_det_enable(hdd_ctx->mac_handle, &motion_det);
4697 
4698 	return 0;
4699 }
4700 
4701 /**
4702  * hdd_we_motion_det_base_line_start_stop - start/stop md baselining
4703  * @link_info: Link info pointer in HDD adapter
4704  * @value: start/stop value to set
4705  *
4706  * Return: 0 on success, error on failure
4707  */
4708 static int
hdd_we_motion_det_base_line_start_stop(struct wlan_hdd_link_info * link_info,int value)4709 hdd_we_motion_det_base_line_start_stop(struct wlan_hdd_link_info *link_info,
4710 				       int value)
4711 {
4712 	struct hdd_adapter *adapter = link_info->adapter;
4713 	struct sme_motion_det_base_line_en motion_det_base_line;
4714 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4715 
4716 	if (value < 0 || value > 1) {
4717 		hdd_err("Invalid value %d in mt_bl_start", value);
4718 		return -EINVAL;
4719 	}
4720 
4721 	/* Do not send baselining start/stop during motion detection phase */
4722 	if (adapter->motion_det_in_progress) {
4723 		hdd_err("Motion detection still in progress, try later");
4724 		return -EAGAIN;
4725 	}
4726 
4727 	motion_det_base_line.vdev_id = link_info->vdev_id;
4728 	motion_det_base_line.enable = value;
4729 	sme_motion_det_base_line_enable(hdd_ctx->mac_handle,
4730 					&motion_det_base_line);
4731 
4732 	return 0;
4733 }
4734 #endif /* WLAN_FEATURE_MOTION_DETECTION */
4735 
wlan_hdd_set_btcoex_mode(struct wlan_hdd_link_info * link_info,int value)4736 int wlan_hdd_set_btcoex_mode(struct wlan_hdd_link_info *link_info, int value)
4737 {
4738 	struct coex_config_params coex_cfg_params = {0};
4739 
4740 	coex_cfg_params.config_type = WMI_COEX_CONFIG_BTC_MODE;
4741 	coex_cfg_params.config_arg1 = value;
4742 	coex_cfg_params.vdev_id     = link_info->vdev_id;
4743 
4744 	if (value < cfg_min(CFG_BTC_MODE) || value > cfg_max(CFG_BTC_MODE)) {
4745 		hdd_err_rl("Invalid value %d", value);
4746 		return -EINVAL;
4747 	}
4748 
4749 	if (QDF_IS_STATUS_ERROR(sme_send_coex_config_cmd(&coex_cfg_params))) {
4750 		hdd_err_rl("Failed to send coex BTC mode");
4751 		return -EINVAL;
4752 	}
4753 
4754 	return 0;
4755 }
4756 
wlan_hdd_set_btcoex_rssi_threshold(struct wlan_hdd_link_info * link_info,int value)4757 int wlan_hdd_set_btcoex_rssi_threshold(struct wlan_hdd_link_info *link_info,
4758 				       int value)
4759 {
4760 	struct coex_config_params coex_cfg_params = {0};
4761 
4762 	coex_cfg_params.config_type =  WMI_COEX_CONFIG_BT_LOW_RSSI_THRESHOLD;
4763 	coex_cfg_params.config_arg1 = value;
4764 	coex_cfg_params.vdev_id     = link_info->vdev_id;
4765 
4766 	if (value < cfg_min(CFG_WLAN_LOW_RSSI_THRESHOLD) ||
4767 	    value > cfg_max(CFG_WLAN_LOW_RSSI_THRESHOLD)) {
4768 		hdd_err_rl("Invalid value %d", value);
4769 		return -EINVAL;
4770 	}
4771 
4772 	if (QDF_IS_STATUS_ERROR(sme_send_coex_config_cmd(&coex_cfg_params))) {
4773 		hdd_err_rl("Failed to send coex BTC RSSI Threshold");
4774 		return -EINVAL;
4775 	}
4776 	return 0;
4777 }
4778 
4779 typedef int (*setint_getnone_fn)(struct wlan_hdd_link_info *link_info,
4780 				 int value);
4781 static const setint_getnone_fn setint_getnone_cb[] = {
4782 	[WE_SET_11D_STATE] = hdd_we_set_11d_state,
4783 	[WE_SET_POWER] = hdd_we_set_power,
4784 	[WE_SET_MAX_ASSOC] = hdd_we_set_max_assoc,
4785 	[WE_SET_DATA_INACTIVITY_TO] = hdd_we_set_data_inactivity_timeout,
4786 	[WE_SET_WOW_DATA_INACTIVITY_TO] =
4787 				hdd_we_set_wow_data_inactivity_timeout,
4788 	[WE_SET_MC_RATE] = wlan_hdd_set_mc_rate,
4789 	[WE_SET_TX_POWER] = hdd_we_set_tx_power,
4790 	[WE_SET_MAX_TX_POWER] = hdd_we_set_max_tx_power,
4791 	[WE_SET_MAX_TX_POWER_2_4] = hdd_we_set_max_tx_power_2_4,
4792 	[WE_SET_MAX_TX_POWER_5_0] = hdd_we_set_max_tx_power_5_0,
4793 #ifdef HASTINGS_BT_WAR
4794 	[WE_SET_HASTINGS_BT_WAR] = hdd_we_set_hastings_bt_war,
4795 #endif
4796 	[WE_SET_TM_LEVEL] = hdd_we_set_tm_level,
4797 	[WE_SET_PHYMODE] = hdd_we_update_phymode,
4798 	[WE_SET_NSS] = hdd_we_set_nss,
4799 	[WE_SET_GTX_HT_MCS] = hdd_we_set_gtx_ht_mcs,
4800 	[WE_SET_GTX_VHT_MCS] = hdd_we_set_gtx_vht_mcs,
4801 	[WE_SET_GTX_USRCFG] = hdd_we_set_gtx_usrcfg,
4802 	[WE_SET_GTX_THRE] = hdd_we_set_gtx_thre,
4803 	[WE_SET_GTX_MARGIN] = hdd_we_set_gtx_margin,
4804 	[WE_SET_GTX_STEP] = hdd_we_set_gtx_step,
4805 	[WE_SET_GTX_MINTPC] = hdd_we_set_gtx_mintpc,
4806 	[WE_SET_GTX_BWMASK] = hdd_we_set_gtx_bwmask,
4807 	[WE_SET_LDPC] = hdd_set_ldpc,
4808 	[WE_SET_TX_STBC] = hdd_set_tx_stbc,
4809 	[WE_SET_RX_STBC] = hdd_set_rx_stbc,
4810 	[WE_SET_SHORT_GI] = hdd_we_set_short_gi,
4811 	[WE_SET_RTSCTS] = hdd_we_set_rtscts,
4812 	[WE_SET_CHWIDTH] = hdd_we_set_ch_width,
4813 	[WE_SET_ANI_EN_DIS] = hdd_we_set_ani_en_dis,
4814 	[WE_SET_ANI_POLL_PERIOD] = hdd_we_set_ani_poll_period,
4815 	[WE_SET_ANI_LISTEN_PERIOD] = hdd_we_set_ani_listen_period,
4816 	[WE_SET_ANI_OFDM_LEVEL] = hdd_we_set_ani_ofdm_level,
4817 	[WE_SET_ANI_CCK_LEVEL] = hdd_we_set_ani_cck_level,
4818 	[WE_SET_DYNAMIC_BW] = hdd_we_set_dynamic_bw,
4819 	[WE_SET_CTS_CBW] = hdd_we_set_cts_cbw,
4820 	[WE_SET_11N_RATE] = hdd_we_set_11n_rate,
4821 	[WE_SET_VHT_RATE] = hdd_we_set_vht_rate,
4822 	[WE_SET_AMPDU] = hdd_we_set_ampdu,
4823 	[WE_SET_AMSDU] = hdd_we_set_amsdu,
4824 	[WE_SET_TX_CHAINMASK] = hdd_we_set_tx_chainmask,
4825 	[WE_SET_RX_CHAINMASK] = hdd_we_set_rx_chainmask,
4826 	[WE_SET_TXPOW_2G] = hdd_we_set_txpow_2g,
4827 	[WE_SET_TXPOW_5G] = hdd_we_set_txpow_5g,
4828 	[WE_DBGLOG_LOG_LEVEL] = hdd_we_dbglog_log_level,
4829 	[WE_DBGLOG_VAP_ENABLE] = hdd_we_dbglog_vap_enable,
4830 	[WE_DBGLOG_VAP_DISABLE] = hdd_we_dbglog_vap_disable,
4831 	[WE_DBGLOG_MODULE_ENABLE] = hdd_we_dbglog_module_enable,
4832 	[WE_DBGLOG_MODULE_DISABLE] = hdd_we_dbglog_module_disable,
4833 	[WE_DBGLOG_MOD_LOG_LEVEL] = hdd_we_dbglog_mod_log_level,
4834 	[WE_DBGLOG_TYPE] = hdd_we_dbglog_type,
4835 	[WE_DBGLOG_REPORT_ENABLE] = hdd_we_dbglog_report_enable,
4836 	[WE_SET_TXRX_FWSTATS] = hdd_we_set_txrx_fwstats,
4837 	[WE_TXRX_FWSTATS_RESET] = hdd_we_txrx_fwstats_reset,
4838 	[WE_DUMP_STATS] = hdd_we_dump_stats,
4839 	[WE_CLEAR_STATS] = hdd_we_clear_stats,
4840 	[WE_PPS_PAID_MATCH] = hdd_we_pps_paid_match,
4841 	[WE_PPS_GID_MATCH] = hdd_we_pps_gid_match,
4842 	[WE_PPS_EARLY_TIM_CLEAR] = hdd_we_pps_early_tim_clear,
4843 	[WE_PPS_EARLY_DTIM_CLEAR] = hdd_we_pps_early_dtim_clear,
4844 	[WE_PPS_EOF_PAD_DELIM] = hdd_we_pps_eof_pad_delim,
4845 	[WE_PPS_MACADDR_MISMATCH] = hdd_we_pps_macaddr_mismatch,
4846 	[WE_PPS_DELIM_CRC_FAIL] = hdd_we_pps_delim_crc_fail,
4847 	[WE_PPS_GID_NSTS_ZERO] = hdd_we_pps_gid_nsts_zero,
4848 	[WE_PPS_RSSI_CHECK] = hdd_we_pps_rssi_check,
4849 	[WE_PPS_5G_EBT] = hdd_we_pps_5g_ebt,
4850 	[WE_SET_HTSMPS] = hdd_we_set_htsmps,
4851 	[WE_SET_QPOWER_MAX_PSPOLL_COUNT] = hdd_we_set_qpower_max_pspoll_count,
4852 	[WE_SET_QPOWER_MAX_TX_BEFORE_WAKE] =
4853 				hdd_we_set_qpower_max_tx_before_wake,
4854 	[WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL] =
4855 				hdd_we_set_qpower_spec_pspoll_wake_interval,
4856 	[WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL] =
4857 				hdd_we_set_qpower_spec_max_spec_nodata_pspoll,
4858 	[WE_MCC_CONFIG_LATENCY] = hdd_we_mcc_config_latency,
4859 	[WE_MCC_CONFIG_QUOTA] = hdd_we_mcc_config_quota,
4860 	[WE_SET_DEBUG_LOG] = hdd_we_set_debug_log,
4861 	[WE_SET_EARLY_RX_ADJUST_ENABLE] = hdd_we_set_early_rx_adjust_enable,
4862 	[WE_SET_EARLY_RX_TGT_BMISS_NUM] = hdd_we_set_early_rx_tgt_bmiss_num,
4863 	[WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE] =
4864 				hdd_we_set_early_rx_bmiss_sample_cycle,
4865 	[WE_SET_EARLY_RX_SLOP_STEP] = hdd_we_set_early_rx_slop_step,
4866 	[WE_SET_EARLY_RX_INIT_SLOP] = hdd_we_set_early_rx_init_slop,
4867 	[WE_SET_EARLY_RX_ADJUST_PAUSE] = hdd_we_set_early_rx_adjust_pause,
4868 	[WE_SET_EARLY_RX_DRIFT_SAMPLE] = hdd_we_set_early_rx_drift_sample,
4869 	[WE_SET_SCAN_DISABLE] = hdd_we_set_scan_disable,
4870 	[WE_START_FW_PROFILE] = hdd_we_start_fw_profile,
4871 	[WE_SET_CHANNEL] = hdd_we_set_channel,
4872 	[WE_SET_CONC_SYSTEM_PREF] = hdd_we_set_conc_system_pref,
4873 	[WE_SET_11AX_RATE] = hdd_we_set_11ax_rate,
4874 	[WE_SET_DCM] = hdd_we_set_dcm,
4875 	[WE_SET_RANGE_EXT] = hdd_we_set_range_ext,
4876 	[WE_SET_PDEV_RESET] = hdd_handle_pdev_reset,
4877 	[WE_SET_MODULATED_DTIM] = hdd_we_set_modulated_dtim,
4878 #ifdef WLAN_FEATURE_MOTION_DETECTION
4879 	[WE_MOTION_DET_START_STOP] = hdd_we_motion_det_start_stop,
4880 	[WE_MOTION_DET_BASE_LINE_START_STOP] =
4881 				hdd_we_motion_det_base_line_start_stop,
4882 #endif /* WLAN_FEATURE_MOTION_DETECTION */
4883 	[WE_SET_BTCOEX_MODE] = wlan_hdd_set_btcoex_mode,
4884 	[WE_SET_BTCOEX_RSSI_THRESHOLD] = wlan_hdd_set_btcoex_rssi_threshold,
4885 };
4886 
hdd_get_setint_getnone_cb(int param)4887 static setint_getnone_fn hdd_get_setint_getnone_cb(int param)
4888 {
4889 	if (param < 0)
4890 		return NULL;
4891 
4892 	if (param >= QDF_ARRAY_SIZE(setint_getnone_cb))
4893 		return NULL;
4894 
4895 	return setint_getnone_cb[param];
4896 }
4897 
4898 /**
4899  * __iw_setint_getnone() - Generic "set integer" private ioctl handler
4900  * @dev: device upon which the ioctl was received
4901  * @info: ioctl request information
4902  * @wrqu: ioctl request data
4903  * @extra: ioctl extra data
4904  *
4905  * Return: 0 on success, non-zero on error
4906  */
__iw_setint_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)4907 static int __iw_setint_getnone(struct net_device *dev,
4908 			       struct iw_request_info *info,
4909 			       union iwreq_data *wrqu, char *extra)
4910 {
4911 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4912 	struct hdd_context *hdd_ctx;
4913 	setint_getnone_fn cb;
4914 	int *value = (int *)extra;
4915 	int sub_cmd = value[0];
4916 	int set_value = value[1];
4917 	int ret;
4918 
4919 	hdd_enter_dev(dev);
4920 
4921 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4922 	ret = wlan_hdd_validate_context(hdd_ctx);
4923 	if (ret)
4924 		return ret;
4925 
4926 	ret = hdd_check_private_wext_control(hdd_ctx, info);
4927 	if (ret)
4928 		return ret;
4929 
4930 	cb = hdd_get_setint_getnone_cb(sub_cmd);
4931 	if (!cb) {
4932 		hdd_debug("Invalid sub command %d", sub_cmd);
4933 		return -EINVAL;
4934 	}
4935 
4936 	ret = cb(adapter->deflink, set_value);
4937 
4938 	hdd_exit();
4939 
4940 	return ret;
4941 }
4942 
4943 /**
4944  * iw_setint_getnone() - Generic "set integer" private ioctl handler
4945  * @dev: device upon which the ioctl was received
4946  * @info: ioctl request information
4947  * @wrqu: ioctl request data
4948  * @extra: ioctl extra data
4949  *
4950  * Return: 0 on success, non-zero on error
4951  */
iw_setint_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)4952 static int iw_setint_getnone(struct net_device *dev,
4953 			     struct iw_request_info *info,
4954 			     union iwreq_data *wrqu,
4955 			     char *extra)
4956 {
4957 	int errno;
4958 	struct osif_vdev_sync *vdev_sync;
4959 
4960 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
4961 	if (errno)
4962 		return errno;
4963 
4964 	errno = __iw_setint_getnone(dev, info, wrqu, extra);
4965 
4966 	osif_vdev_sync_op_stop(vdev_sync);
4967 
4968 	return errno;
4969 }
4970 
4971 /**
4972  * __iw_setnone_get_threeint() - return three value to up layer.
4973  *
4974  * @dev: pointer of net_device of this wireless card
4975  * @info: meta data about Request sent
4976  * @wrqu: include request info
4977  * @extra: buf used for in/Output
4978  *
4979  * Return: execute result
4980  */
__iw_setnone_get_threeint(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)4981 static int __iw_setnone_get_threeint(struct net_device *dev,
4982 					struct iw_request_info *info,
4983 					union iwreq_data *wrqu, char *extra)
4984 {
4985 	int ret = 0; /* success */
4986 	uint32_t *value = (int *)extra;
4987 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4988 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4989 	struct hdd_tsf_op_response tsf_op_resp;
4990 
4991 	hdd_enter_dev(dev);
4992 	ret = wlan_hdd_validate_context(hdd_ctx);
4993 	if (0 != ret)
4994 		return ret;
4995 
4996 	ret = hdd_check_private_wext_control(hdd_ctx, info);
4997 	if (0 != ret)
4998 		return ret;
4999 
5000 	hdd_debug("param = %d", value[0]);
5001 	switch (value[0]) {
5002 	case WE_GET_TSF:
5003 		ret = hdd_indicate_tsf(adapter, &tsf_op_resp);
5004 		if (!ret) {
5005 			value[0] = tsf_op_resp.status;
5006 			value[1] = tsf_op_resp.time & 0xffffffff;
5007 			value[2] = (tsf_op_resp.time >> 32) & 0xffffffff;
5008 		}
5009 		break;
5010 	default:
5011 		hdd_err("Invalid IOCTL get_value command %d", value[0]);
5012 		break;
5013 	}
5014 	return ret;
5015 }
5016 
5017 /**
5018  * iw_setnone_get_threeint() - return three value to up layer.
5019  *
5020  * @dev: pointer of net_device of this wireless card
5021  * @info: meta data about Request sent
5022  * @wrqu: include request info
5023  * @extra: buf used for in/Output
5024  *
5025  * Return: execute result
5026  */
iw_setnone_get_threeint(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5027 static int iw_setnone_get_threeint(struct net_device *dev,
5028 					struct iw_request_info *info,
5029 					union iwreq_data *wrqu, char *extra)
5030 {
5031 	int errno;
5032 	struct osif_vdev_sync *vdev_sync;
5033 
5034 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
5035 	if (errno)
5036 		return errno;
5037 
5038 	errno = __iw_setnone_get_threeint(dev, info, wrqu, extra);
5039 
5040 	osif_vdev_sync_op_stop(vdev_sync);
5041 
5042 	return errno;
5043 }
5044 
5045 /**
5046  * __iw_setchar_getnone() - Generic "set string" private ioctl handler
5047  * @dev: device upon which the ioctl was received
5048  * @info: ioctl request information
5049  * @wrqu: ioctl request data
5050  * @extra: ioctl extra data
5051  *
5052  * Return: 0 on success, non-zero on error
5053  */
__iw_setchar_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5054 static int __iw_setchar_getnone(struct net_device *dev,
5055 				struct iw_request_info *info,
5056 				union iwreq_data *wrqu, char *extra)
5057 {
5058 	int sub_cmd;
5059 	int ret;
5060 	char *str_arg = NULL;
5061 	struct hdd_adapter *adapter = (netdev_priv(dev));
5062 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5063 	struct iw_point s_priv_data;
5064 	bool neighbor_report_req_support = false;
5065 
5066 	hdd_enter_dev(dev);
5067 
5068 	if (!capable(CAP_NET_ADMIN)) {
5069 		hdd_err("permission check failed");
5070 		return -EPERM;
5071 	}
5072 
5073 	ret = wlan_hdd_validate_context(hdd_ctx);
5074 	if (0 != ret)
5075 		return ret;
5076 
5077 	ret = hdd_check_private_wext_control(hdd_ctx, info);
5078 	if (0 != ret)
5079 		return ret;
5080 
5081 	/* helper function to get iwreq_data with compat handling. */
5082 	if (hdd_priv_get_data(&s_priv_data, wrqu))
5083 		return -EINVAL;
5084 
5085 	/* make sure all params are correctly passed to function */
5086 	if ((!s_priv_data.pointer) || (0 == s_priv_data.length))
5087 		return -EINVAL;
5088 
5089 	sub_cmd = s_priv_data.flags;
5090 
5091 	/* ODD number is used for set, copy data using copy_from_user */
5092 	str_arg = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
5093 						  s_priv_data.length);
5094 	if (!str_arg) {
5095 		hdd_err("mem_alloc_copy_from_user_helper fail");
5096 		return -ENOMEM;
5097 	}
5098 
5099 	hdd_debug("Received length: %d data: %s",
5100 			s_priv_data.length, str_arg);
5101 
5102 	switch (sub_cmd) {
5103 	case WE_WOWL_ADD_PTRN:
5104 		hdd_debug("ADD_PTRN");
5105 		if (!hdd_add_wowl_ptrn(adapter, str_arg))
5106 			ret = -EINVAL;
5107 		break;
5108 	case WE_WOWL_DEL_PTRN:
5109 		hdd_debug("DEL_PTRN");
5110 		if (!hdd_del_wowl_ptrn(adapter, str_arg))
5111 			ret = -EINVAL;
5112 		break;
5113 	case WE_NEIGHBOR_REPORT_REQUEST:
5114 	{
5115 		tRrmNeighborReq request;
5116 		tRrmNeighborRspCallbackInfo callback;
5117 		bool rrm_enabled = false;
5118 
5119 		ucfg_wlan_mlme_get_rrm_enabled(hdd_ctx->psoc,
5120 					       &rrm_enabled);
5121 
5122 		if (rrm_enabled) {
5123 			request.neighbor_report_offload = false;
5124 			request.no_ssid =
5125 				(s_priv_data.length - 1) ? false : true;
5126 			hdd_debug("Neighbor Request ssid present %d",
5127 				  request.no_ssid);
5128 			if (!request.no_ssid) {
5129 				request.ssid.length =
5130 					(s_priv_data.length - 1) >
5131 					32 ? 32 : (s_priv_data.length - 1);
5132 				qdf_mem_copy(request.ssid.ssId,
5133 					     str_arg,
5134 					     request.ssid.length);
5135 			}
5136 
5137 			/*
5138 			 * If 11k offload is supported by FW and enabled
5139 			 * in the ini, set the offload to true
5140 			 */
5141 			if (QDF_IS_STATUS_ERROR(
5142 			    ucfg_fwol_is_neighbor_report_req_supported(
5143 			    hdd_ctx->psoc, &neighbor_report_req_support)))
5144 				hdd_err("Neighbor report req bit get fail");
5145 
5146 			if (hdd_ctx->config->is_11k_offload_supported &&
5147 			    neighbor_report_req_support) {
5148 				hdd_debug("Neighbor report offloaded to FW");
5149 				request.neighbor_report_offload = true;
5150 			}
5151 
5152 			callback.neighborRspCallback = NULL;
5153 			callback.neighborRspCallbackContext = NULL;
5154 			callback.timeout = 5000; /* 5 seconds */
5155 			sme_neighbor_report_request(
5156 					hdd_ctx->mac_handle,
5157 					adapter->deflink->vdev_id,
5158 					&request,
5159 					&callback);
5160 		} else {
5161 			hdd_err("Ignoring neighbor request as RRM not enabled");
5162 			ret = -EINVAL;
5163 		}
5164 	}
5165 	break;
5166 	case WE_SET_AP_WPS_IE:
5167 		hdd_debug("Received WE_SET_AP_WPS_IE, won't process");
5168 		break;
5169 	case WE_UNIT_TEST:
5170 		ret = wlan_hdd_unit_test(hdd_ctx, str_arg);
5171 		break;
5172 	default:
5173 	{
5174 		hdd_err("Invalid sub command %d", sub_cmd);
5175 		ret = -EINVAL;
5176 		break;
5177 	}
5178 	}
5179 
5180 	qdf_mem_free(str_arg);
5181 	hdd_exit();
5182 
5183 	return ret;
5184 }
5185 
5186 /**
5187  * iw_setchar_getnone() - Generic "set string" private ioctl handler
5188  * @dev: device upon which the ioctl was received
5189  * @info: ioctl request information
5190  * @wrqu: ioctl request data
5191  * @extra: ioctl extra data
5192  *
5193  * Return: 0 on success, non-zero on error
5194  */
iw_setchar_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5195 static int iw_setchar_getnone(struct net_device *dev,
5196 			      struct iw_request_info *info,
5197 			      union iwreq_data *wrqu, char *extra)
5198 {
5199 	int errno;
5200 	struct osif_vdev_sync *vdev_sync;
5201 
5202 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
5203 	if (errno)
5204 		return errno;
5205 
5206 	errno = __iw_setchar_getnone(dev, info, wrqu, extra);
5207 
5208 	osif_vdev_sync_op_stop(vdev_sync);
5209 
5210 	return errno;
5211 }
5212 
5213 /**
5214  * __iw_setnone_getint() - Generic "get integer" private ioctl handler
5215  * @dev: device upon which the ioctl was received
5216  * @info: ioctl request information
5217  * @wrqu: ioctl request data
5218  * @extra: ioctl extra data
5219  *
5220  * Return: 0 on success, non-zero on error
5221  */
__iw_setnone_getint(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5222 static int __iw_setnone_getint(struct net_device *dev,
5223 			       struct iw_request_info *info,
5224 			       union iwreq_data *wrqu, char *extra)
5225 {
5226 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5227 	mac_handle_t mac_handle;
5228 	int *value = (int *)extra;
5229 	int ret;
5230 	struct sme_config_params *sme_config;
5231 	struct hdd_context *hdd_ctx;
5232 	QDF_STATUS status;
5233 	bool bval = false;
5234 
5235 	hdd_enter_dev(dev);
5236 
5237 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5238 	ret = wlan_hdd_validate_context(hdd_ctx);
5239 	if (0 != ret)
5240 		return ret;
5241 
5242 	ret = hdd_check_private_wext_control(hdd_ctx, info);
5243 	if (0 != ret)
5244 		return ret;
5245 
5246 	sme_config = qdf_mem_malloc(sizeof(*sme_config));
5247 	if (!sme_config)
5248 		return -ENOMEM;
5249 
5250 	mac_handle = hdd_ctx->mac_handle;
5251 	switch (value[0]) {
5252 	case WE_GET_11D_STATE:
5253 	{
5254 		status = ucfg_mlme_is_11d_enabled(hdd_ctx->psoc, &bval);
5255 		if (!QDF_IS_STATUS_SUCCESS(status))
5256 			hdd_err("Invalid 11d_enable flag");
5257 		*value = bval;
5258 		hdd_debug("11D state=%d!!", *value);
5259 
5260 		break;
5261 	}
5262 
5263 	case WE_GET_WLAN_DBG:
5264 	{
5265 		qdf_trace_display();
5266 		*value = 0;
5267 		break;
5268 	}
5269 	case WE_GET_MAX_ASSOC:
5270 	{
5271 		if (ucfg_mlme_get_assoc_sta_limit(hdd_ctx->psoc, value) !=
5272 		    QDF_STATUS_SUCCESS) {
5273 			hdd_err("CFG_ASSOC_STA_LIMIT failed");
5274 			ret = -EIO;
5275 		}
5276 
5277 		break;
5278 	}
5279 
5280 	case WE_GET_CONCURRENCY_MODE:
5281 	{
5282 		*value = policy_mgr_get_concurrency_mode(hdd_ctx->psoc);
5283 
5284 		hdd_debug("concurrency mode=%d", *value);
5285 		break;
5286 	}
5287 
5288 	case WE_GET_NSS:
5289 	{
5290 		uint8_t nss;
5291 
5292 		status = hdd_get_nss(adapter, &nss);
5293 		if (!QDF_IS_STATUS_SUCCESS(status)) {
5294 			hdd_err("unable to get vht_enable2x2");
5295 			ret = -EIO;
5296 			break;
5297 		}
5298 		*value = nss;
5299 
5300 		hdd_debug("GET_NSS: Current NSS:%d", *value);
5301 		break;
5302 	}
5303 
5304 	case WE_GET_GTX_HT_MCS:
5305 	{
5306 		hdd_debug("GET wmi_vdev_param_gtx_ht_mcs");
5307 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5308 					     wmi_vdev_param_gtx_ht_mcs,
5309 					     GTX_CMD);
5310 		break;
5311 	}
5312 
5313 	case WE_GET_GTX_VHT_MCS:
5314 	{
5315 		hdd_debug("GET wmi_vdev_param_gtx_vht_mcs");
5316 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5317 					     wmi_vdev_param_gtx_vht_mcs,
5318 					     GTX_CMD);
5319 		break;
5320 	}
5321 
5322 	case WE_GET_GTX_USRCFG:
5323 	{
5324 		hdd_debug("GET wmi_vdev_param_gtx_usr_cfg");
5325 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5326 					     wmi_vdev_param_gtx_usr_cfg,
5327 					     GTX_CMD);
5328 		break;
5329 	}
5330 
5331 	case WE_GET_GTX_THRE:
5332 	{
5333 		hdd_debug("GET wmi_vdev_param_gtx_thre");
5334 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5335 					     wmi_vdev_param_gtx_thre,
5336 					     GTX_CMD);
5337 		break;
5338 	}
5339 
5340 	case WE_GET_GTX_MARGIN:
5341 	{
5342 		hdd_debug("GET wmi_vdev_param_gtx_margin");
5343 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5344 					     wmi_vdev_param_gtx_margin,
5345 					     GTX_CMD);
5346 		break;
5347 	}
5348 
5349 	case WE_GET_GTX_STEP:
5350 	{
5351 		hdd_debug("GET wmi_vdev_param_gtx_step");
5352 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5353 					     wmi_vdev_param_gtx_step,
5354 					     GTX_CMD);
5355 		break;
5356 	}
5357 
5358 	case WE_GET_GTX_MINTPC:
5359 	{
5360 		hdd_debug("GET wmi_vdev_param_gtx_mintpc");
5361 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5362 					     wmi_vdev_param_gtx_mintpc,
5363 					     GTX_CMD);
5364 		break;
5365 	}
5366 
5367 	case WE_GET_GTX_BWMASK:
5368 	{
5369 		hdd_debug("GET wmi_vdev_param_gtx_bw_mask");
5370 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5371 					     wmi_vdev_param_gtx_bw_mask,
5372 					     GTX_CMD);
5373 		break;
5374 	}
5375 
5376 	case WE_GET_LDPC:
5377 	{
5378 		ret = hdd_get_ldpc(adapter, value);
5379 		break;
5380 	}
5381 
5382 	case WE_GET_TX_STBC:
5383 	{
5384 		ret = hdd_get_tx_stbc(adapter, value);
5385 		break;
5386 	}
5387 
5388 	case WE_GET_RX_STBC:
5389 	{
5390 		ret = hdd_get_rx_stbc(adapter, value);
5391 		break;
5392 	}
5393 
5394 	case WE_GET_SHORT_GI:
5395 	{
5396 		hdd_debug("GET wmi_vdev_param_sgi");
5397 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5398 					     wmi_vdev_param_sgi,
5399 					     VDEV_CMD);
5400 		break;
5401 	}
5402 
5403 	case WE_GET_RTSCTS:
5404 	{
5405 		hdd_debug("GET wmi_vdev_param_enable_rtscts");
5406 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5407 					     wmi_vdev_param_enable_rtscts,
5408 					     VDEV_CMD);
5409 		break;
5410 	}
5411 
5412 	case WE_GET_CHWIDTH:
5413 	{
5414 		hdd_debug("GET wmi_vdev_param_chwidth");
5415 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5416 					     wmi_vdev_param_chwidth,
5417 					     VDEV_CMD);
5418 		break;
5419 	}
5420 
5421 	case WE_GET_ANI_EN_DIS:
5422 	{
5423 		hdd_debug("GET wmi_pdev_param_ani_enable");
5424 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5425 					     wmi_pdev_param_ani_enable,
5426 					     PDEV_CMD);
5427 		break;
5428 	}
5429 
5430 	case WE_GET_ANI_POLL_PERIOD:
5431 	{
5432 		hdd_debug("GET wmi_pdev_param_ani_poll_period");
5433 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5434 					     wmi_pdev_param_ani_poll_period,
5435 					     PDEV_CMD);
5436 		break;
5437 	}
5438 
5439 	case WE_GET_ANI_LISTEN_PERIOD:
5440 	{
5441 		hdd_debug("GET wmi_pdev_param_ani_listen_period");
5442 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5443 					     wmi_pdev_param_ani_listen_period,
5444 					     PDEV_CMD);
5445 		break;
5446 	}
5447 
5448 	case WE_GET_ANI_OFDM_LEVEL:
5449 	{
5450 		hdd_debug("GET wmi_pdev_param_ani_ofdm_level");
5451 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5452 					     wmi_pdev_param_ani_ofdm_level,
5453 					     PDEV_CMD);
5454 		break;
5455 	}
5456 
5457 	case WE_GET_ANI_CCK_LEVEL:
5458 	{
5459 		hdd_debug("GET wmi_pdev_param_ani_cck_level");
5460 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5461 					     wmi_pdev_param_ani_cck_level,
5462 					     PDEV_CMD);
5463 		break;
5464 	}
5465 
5466 	case WE_GET_DYNAMIC_BW:
5467 	{
5468 		hdd_debug("GET wmi_pdev_param_ani_cck_level");
5469 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5470 					     wmi_pdev_param_dynamic_bw,
5471 					     PDEV_CMD);
5472 		break;
5473 	}
5474 
5475 	case WE_GET_11N_RATE:
5476 	{
5477 		hdd_debug("GET wmi_vdev_param_fixed_rate");
5478 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5479 					     wmi_vdev_param_fixed_rate,
5480 					     VDEV_CMD);
5481 		break;
5482 	}
5483 
5484 	case WE_GET_AMPDU:
5485 	{
5486 		hdd_debug("GET AMPDU");
5487 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5488 					     GEN_VDEV_PARAM_AMPDU,
5489 					     GEN_CMD);
5490 		break;
5491 	}
5492 
5493 	case WE_GET_AMSDU:
5494 	{
5495 		hdd_debug("GET AMSDU");
5496 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5497 					     GEN_VDEV_PARAM_AMSDU,
5498 					     GEN_CMD);
5499 		break;
5500 	}
5501 
5502 	case WE_GET_ROAM_SYNCH_DELAY:
5503 	{
5504 		hdd_debug("GET ROAM SYNCH DELAY");
5505 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5506 					     GEN_VDEV_ROAM_SYNCH_DELAY,
5507 					     GEN_CMD);
5508 		break;
5509 	}
5510 
5511 	case WE_GET_TX_CHAINMASK:
5512 	{
5513 		hdd_debug("GET wmi_pdev_param_tx_chain_mask");
5514 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5515 					     wmi_pdev_param_tx_chain_mask,
5516 					     PDEV_CMD);
5517 		break;
5518 	}
5519 
5520 	case WE_GET_RX_CHAINMASK:
5521 	{
5522 		hdd_debug("GET wmi_pdev_param_rx_chain_mask");
5523 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5524 					     wmi_pdev_param_rx_chain_mask,
5525 					     PDEV_CMD);
5526 		break;
5527 	}
5528 
5529 	case WE_GET_TXPOW_2G:
5530 	{
5531 		uint8_t txpow2g = 0;
5532 
5533 		hdd_debug("GET wmi_pdev_param_txpower_limit2g");
5534 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5535 					     wmi_pdev_param_txpower_limit2g,
5536 					     PDEV_CMD);
5537 		ucfg_mlme_get_current_tx_power_level(hdd_ctx->psoc, &txpow2g);
5538 		hdd_debug("2G tx_power %d", txpow2g);
5539 		break;
5540 	}
5541 
5542 	case WE_GET_TXPOW_5G:
5543 	{
5544 		uint8_t txpow5g = 0;
5545 
5546 		hdd_debug("GET wmi_pdev_param_txpower_limit5g");
5547 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5548 					     wmi_pdev_param_txpower_limit5g,
5549 					     PDEV_CMD);
5550 		ucfg_mlme_get_current_tx_power_level(hdd_ctx->psoc, &txpow5g);
5551 		hdd_debug("5G tx_power %d", txpow5g);
5552 		break;
5553 	}
5554 
5555 	case WE_GET_PPS_PAID_MATCH:
5556 	{
5557 		hdd_debug("GET WMI_VDEV_PPS_PAID_MATCH");
5558 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5559 					     WMI_VDEV_PPS_PAID_MATCH,
5560 					     PPS_CMD);
5561 		break;
5562 	}
5563 
5564 	case WE_GET_PPS_GID_MATCH:
5565 	{
5566 		hdd_debug("GET WMI_VDEV_PPS_GID_MATCH");
5567 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5568 					     WMI_VDEV_PPS_GID_MATCH,
5569 					     PPS_CMD);
5570 		break;
5571 	}
5572 
5573 	case WE_GET_PPS_EARLY_TIM_CLEAR:
5574 	{
5575 		hdd_debug("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
5576 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5577 					     WMI_VDEV_PPS_EARLY_TIM_CLEAR,
5578 					     PPS_CMD);
5579 		break;
5580 	}
5581 
5582 	case WE_GET_PPS_EARLY_DTIM_CLEAR:
5583 	{
5584 		hdd_debug("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
5585 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5586 					     WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
5587 					     PPS_CMD);
5588 		break;
5589 	}
5590 
5591 	case WE_GET_PPS_EOF_PAD_DELIM:
5592 	{
5593 		hdd_debug("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
5594 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5595 					     WMI_VDEV_PPS_EOF_PAD_DELIM,
5596 					     PPS_CMD);
5597 		break;
5598 	}
5599 
5600 	case WE_GET_PPS_MACADDR_MISMATCH:
5601 	{
5602 		hdd_debug("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
5603 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5604 					     WMI_VDEV_PPS_MACADDR_MISMATCH,
5605 					     PPS_CMD);
5606 		break;
5607 	}
5608 
5609 	case WE_GET_PPS_DELIM_CRC_FAIL:
5610 	{
5611 		hdd_debug("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
5612 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5613 					     WMI_VDEV_PPS_DELIM_CRC_FAIL,
5614 					     PPS_CMD);
5615 		break;
5616 	}
5617 
5618 	case WE_GET_PPS_GID_NSTS_ZERO:
5619 	{
5620 		hdd_debug("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
5621 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5622 					     WMI_VDEV_PPS_GID_NSTS_ZERO,
5623 					     PPS_CMD);
5624 		break;
5625 	}
5626 
5627 	case WE_GET_PPS_RSSI_CHECK:
5628 	{
5629 
5630 		hdd_debug("GET WMI_VDEV_PPS_RSSI_CHECK");
5631 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5632 					     WMI_VDEV_PPS_RSSI_CHECK,
5633 					     PPS_CMD);
5634 		break;
5635 	}
5636 
5637 	case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
5638 	{
5639 		hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
5640 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5641 					     WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
5642 					     QPOWER_CMD);
5643 		break;
5644 	}
5645 
5646 	case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
5647 	{
5648 		hdd_debug("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
5649 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5650 					     WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
5651 					     QPOWER_CMD);
5652 		break;
5653 	}
5654 
5655 	case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
5656 	{
5657 		hdd_debug("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
5658 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5659 					     WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
5660 					     QPOWER_CMD);
5661 		break;
5662 	}
5663 
5664 	case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
5665 	{
5666 		hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
5667 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5668 					     WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
5669 					     QPOWER_CMD);
5670 		break;
5671 	}
5672 	case WE_CAP_TSF:
5673 		ret = hdd_capture_tsf(adapter, (uint32_t *)value, 1);
5674 		break;
5675 	case WE_GET_TEMPERATURE:
5676 	{
5677 		hdd_debug("WE_GET_TEMPERATURE");
5678 		ret = wlan_hdd_get_temperature(adapter, value);
5679 		break;
5680 	}
5681 	case WE_GET_DCM:
5682 		hdd_debug("GET wmi_vdev_param_he_dcm");
5683 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5684 					     wmi_vdev_param_he_dcm_enable,
5685 					     VDEV_CMD);
5686 		break;
5687 	case WE_GET_RANGE_EXT:
5688 		hdd_debug("GET wmi_vdev_param_he_range_ext");
5689 		*value = wma_cli_get_command(adapter->deflink->vdev_id,
5690 					     wmi_vdev_param_he_range_ext,
5691 					     VDEV_CMD);
5692 		break;
5693 	default:
5694 	{
5695 		hdd_err("Invalid IOCTL get_value command %d",
5696 		       value[0]);
5697 		break;
5698 	}
5699 	}
5700 	hdd_exit();
5701 	qdf_mem_free(sme_config);
5702 	return ret;
5703 }
5704 
5705 /**
5706  * iw_setnone_getint() - Generic "get integer" private ioctl handler
5707  * @dev: device upon which the ioctl was received
5708  * @info: ioctl request information
5709  * @wrqu: ioctl request data
5710  * @extra: ioctl extra data
5711  *
5712  * Return: 0 on success, non-zero on error
5713  */
iw_setnone_getint(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5714 static int iw_setnone_getint(struct net_device *dev,
5715 			     struct iw_request_info *info,
5716 			     union iwreq_data *wrqu, char *extra)
5717 {
5718 	int errno;
5719 	struct osif_vdev_sync *vdev_sync;
5720 
5721 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
5722 	if (errno)
5723 		return errno;
5724 
5725 	errno = __iw_setnone_getint(dev, info, wrqu, extra);
5726 
5727 	osif_vdev_sync_op_stop(vdev_sync);
5728 
5729 	return errno;
5730 }
5731 
hdd_set_fwtest(int argc,int cmd,int value)5732 static int hdd_set_fwtest(int argc, int cmd, int value)
5733 {
5734 	struct set_fwtest_params *fw_test;
5735 
5736 	/* check for max number of arguments */
5737 	if (argc > WMI_UNIT_TEST_MAX_NUM_ARGS ||
5738 	    argc != HDD_FWTEST_PARAMS) {
5739 		hdd_err("Too Many args %d", argc);
5740 		return -EINVAL;
5741 	}
5742 	/*
5743 	 * check if number of arguments are 3 then, check
5744 	 * then set the default value for sounding interval.
5745 	 */
5746 	if (HDD_FWTEST_PARAMS == argc) {
5747 		if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
5748 			value = HDD_FWTEST_SU_DEFAULT_VALUE;
5749 		if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
5750 			value = HDD_FWTEST_MU_DEFAULT_VALUE;
5751 	}
5752 	/* check sounding interval value should not exceed to max */
5753 	if (value > HDD_FWTEST_MAX_VALUE) {
5754 		hdd_err("Invalid arguments value should not exceed max: %d",
5755 			value);
5756 		return -EINVAL;
5757 	}
5758 	fw_test = qdf_mem_malloc(sizeof(*fw_test));
5759 	if (!fw_test)
5760 		return -ENOMEM;
5761 
5762 	fw_test->arg = cmd;
5763 	fw_test->value = value;
5764 	if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
5765 		qdf_mem_free(fw_test);
5766 		hdd_err("Not able to post FW_TEST_CMD message to WMA");
5767 		return -EINVAL;
5768 	}
5769 	return 0;
5770 }
5771 
5772 /**
5773  * __iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
5774  * @dev: device upon which the ioctl was received
5775  * @info: ioctl request information
5776  * @wrqu: ioctl request data
5777  * @extra: ioctl extra data
5778  *
5779  * Return: 0 on success, non-zero on error
5780  */
__iw_set_three_ints_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5781 static int __iw_set_three_ints_getnone(struct net_device *dev,
5782 				       struct iw_request_info *info,
5783 				       union iwreq_data *wrqu, char *extra)
5784 {
5785 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5786 	int *value = (int *)extra;
5787 	int sub_cmd = value[0];
5788 	int ret;
5789 	uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN;
5790 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5791 	QDF_STATUS status;
5792 
5793 	hdd_enter_dev(dev);
5794 
5795 	if (!capable(CAP_NET_ADMIN)) {
5796 		hdd_err("permission check failed");
5797 		return -EPERM;
5798 	}
5799 
5800 	ret = wlan_hdd_validate_context(hdd_ctx);
5801 	if (0 != ret)
5802 		return ret;
5803 
5804 	ret = hdd_check_private_wext_control(hdd_ctx, info);
5805 	if (0 != ret)
5806 		return ret;
5807 
5808 	switch (sub_cmd) {
5809 
5810 	case WE_SET_WLAN_DBG:
5811 		qdf_print_set_category_verbose(qdf_get_pidx(), value[1],
5812 					       value[2], value[3]);
5813 		break;
5814 	case WE_SET_DP_TRACE:
5815 		qdf_dp_trace_set_value(value[1], value[2], value[3]);
5816 		break;
5817 
5818 	case WE_SET_DUAL_MAC_SCAN_CONFIG:
5819 		hdd_debug("Ioctl to set dual mac scan config");
5820 		status =
5821 		ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc,
5822 						     &dual_mac_feature);
5823 		if (status != QDF_STATUS_SUCCESS)
5824 			hdd_err("can't get dual mac feature val, use def");
5825 		if (dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) {
5826 			hdd_err("Dual mac feature is disabled from INI");
5827 			return -EPERM;
5828 		}
5829 		hdd_debug("%d %d %d", value[1], value[2], value[3]);
5830 		policy_mgr_set_dual_mac_scan_config(hdd_ctx->psoc,
5831 			value[1], value[2], value[3]);
5832 		break;
5833 	case WE_SET_FW_TEST:
5834 	{
5835 		ret = hdd_set_fwtest(value[1], value[2], value[3]);
5836 		if (ret) {
5837 			hdd_err("Not able to set fwtest %d", ret);
5838 			return ret;
5839 		}
5840 	}
5841 	break;
5842 	default:
5843 		hdd_err("Invalid IOCTL command %d", sub_cmd);
5844 		break;
5845 
5846 	}
5847 	hdd_exit();
5848 	return ret;
5849 }
5850 
5851 /**
5852  * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
5853  * @dev: device upon which the ioctl was received
5854  * @info: ioctl request information
5855  * @wrqu: ioctl request data
5856  * @extra: ioctl extra data
5857  *
5858  * Return: 0 on success, non-zero on error
5859  */
iw_set_three_ints_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5860 int iw_set_three_ints_getnone(struct net_device *dev,
5861 			      struct iw_request_info *info,
5862 			      union iwreq_data *wrqu, char *extra)
5863 {
5864 	int errno;
5865 	struct osif_vdev_sync *vdev_sync;
5866 
5867 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
5868 	if (errno)
5869 		return errno;
5870 
5871 	errno = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
5872 
5873 	osif_vdev_sync_op_stop(vdev_sync);
5874 
5875 	return errno;
5876 }
5877 
5878 /**
5879  * hdd_connection_state_string() - Get connection state string
5880  * @connection_state: enum to be converted to a string
5881  *
5882  * Return: the string equivalent of @connection_state
5883  */
5884 static const char *
hdd_connection_state_string(eConnectionState connection_state)5885 hdd_connection_state_string(eConnectionState connection_state)
5886 {
5887 	switch (connection_state) {
5888 		CASE_RETURN_STRING(eConnectionState_NotConnected);
5889 		CASE_RETURN_STRING(eConnectionState_NdiDisconnected);
5890 		CASE_RETURN_STRING(eConnectionState_NdiConnected);
5891 	default:
5892 		return "UNKNOWN";
5893 	}
5894 }
5895 
5896 #if defined(FEATURE_OEM_DATA_SUPPORT)
5897 /**
5898  * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
5899  * wifi_pos api to get oem data caps
5900  * @dev: net device upon which the request was received
5901  * @info: ioctl request information
5902  * @wrqu: ioctl request data
5903  * @extra: ioctl data payload
5904  *
5905  * Return: 0 for success, negative errno value on failure
5906  */
iw_get_oem_data_cap_wrapper(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5907 static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
5908 					struct iw_request_info *info,
5909 					union iwreq_data *wrqu, char *extra)
5910 {
5911 	return iw_get_oem_data_cap(dev, info, wrqu, extra);
5912 }
5913 #elif defined(WIFI_POS_CONVERGED)
iw_get_oem_data_cap_wrapper(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5914 static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
5915 					struct iw_request_info *info,
5916 					union iwreq_data *wrqu, char *extra)
5917 {
5918 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5919 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5920 
5921 	return os_if_wifi_pos_populate_caps(hdd_ctx->psoc,
5922 					(struct wifi_pos_driver_caps *)extra);
5923 }
5924 #else
iw_get_oem_data_cap_wrapper(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5925 static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
5926 					struct iw_request_info *info,
5927 					union iwreq_data *wrqu, char *extra)
5928 {
5929 	return -ENOTSUPP;
5930 }
5931 #endif
5932 
5933 #ifdef WLAN_UNIT_TEST
hdd_get_sta_cxn_info(struct hdd_context * hdd_ctx,struct hdd_adapter * adapter,char * extra)5934 static int hdd_get_sta_cxn_info(struct hdd_context *hdd_ctx,
5935 				struct hdd_adapter *adapter,
5936 				char *extra)
5937 {
5938 	QDF_STATUS status;
5939 
5940 	status = sme_get_sta_cxn_info(hdd_ctx->mac_handle,
5941 				      adapter->deflink->vdev_id,
5942 				      extra, WE_MAX_STR_LEN);
5943 	if (status != QDF_STATUS_SUCCESS)
5944 		qdf_scnprintf(extra, WE_MAX_STR_LEN,
5945 			      "\nNo active connection");
5946 
5947 	return 0;
5948 }
5949 #else
hdd_get_sta_cxn_info(struct hdd_context * hdd_ctx,struct hdd_adapter * adapter,char * extra)5950 static int hdd_get_sta_cxn_info(struct hdd_context *hdd_ctx,
5951 				struct hdd_adapter *adapter,
5952 				char *extra)
5953 {
5954 	qdf_scnprintf(extra, WE_MAX_STR_LEN,
5955 		      "\nNot supported");
5956 	return -ENOTSUPP;
5957 }
5958 #endif
5959 
5960 /**
5961  * __iw_get_char_setnone() - Generic "get string" private ioctl handler
5962  * @dev: device upon which the ioctl was received
5963  * @info: ioctl request information
5964  * @wrqu: ioctl request data
5965  * @extra: ioctl extra data
5966  *
5967  * Return: 0 on success, non-zero on error
5968  */
__iw_get_char_setnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)5969 static int __iw_get_char_setnone(struct net_device *dev,
5970 				 struct iw_request_info *info,
5971 				 union iwreq_data *wrqu, char *extra)
5972 {
5973 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5974 	int sub_cmd = wrqu->data.flags;
5975 	struct hdd_context *hdd_ctx;
5976 	mac_handle_t mac_handle;
5977 	int ret;
5978 	QDF_STATUS status;
5979 	uint8_t value;
5980 	struct wlan_hdd_link_info *link_info = adapter->deflink;
5981 
5982 	hdd_enter_dev(dev);
5983 
5984 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5985 	ret = wlan_hdd_validate_context(hdd_ctx);
5986 	if (0 != ret)
5987 		return ret;
5988 
5989 	ret = hdd_check_private_wext_control(hdd_ctx, info);
5990 	if (0 != ret)
5991 		return ret;
5992 
5993 	mac_handle = hdd_ctx->mac_handle;
5994 	switch (sub_cmd) {
5995 	case WE_WLAN_VERSION:
5996 	{
5997 		wrqu->data.length = hdd_wlan_get_version(hdd_ctx,
5998 							 WE_MAX_STR_LEN, extra);
5999 		break;
6000 	}
6001 
6002 	case WE_GET_STATS:
6003 	{
6004 		hdd_wlan_get_stats(link_info, &wrqu->data.length,
6005 				   extra, WE_MAX_STR_LEN);
6006 		break;
6007 	}
6008 
6009 	case WE_GET_SUSPEND_RESUME_STATS:
6010 	{
6011 		ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
6012 							  WE_MAX_STR_LEN);
6013 		if (ret >= 0) {
6014 			wrqu->data.length = ret;
6015 			ret = 0;
6016 		}
6017 
6018 		break;
6019 	}
6020 
6021 	case WE_LIST_FW_PROFILE:
6022 		hdd_wlan_list_fw_profile(&(wrqu->data.length),
6023 					extra, WE_MAX_STR_LEN);
6024 		break;
6025 
6026 	/* The case prints the current state of the HDD, SME, CSR, PE,
6027 	 * TL it can be extended for WDI Global State as well.  And
6028 	 * currently it only checks P2P_CLIENT adapter.  P2P_DEVICE
6029 	 * and P2P_GO have not been added as of now.
6030 	 */
6031 	case WE_GET_STATES:
6032 	{
6033 		int buf = 0, len = 0;
6034 		int adapter_num = 0;
6035 		int count = 0, check = 1;
6036 		uint8_t stat_vdev_id;
6037 		struct hdd_station_ctx *sta_ctx = NULL;
6038 		struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6039 		struct hdd_adapter *stat_adapter = NULL;
6040 		struct wlan_hdd_link_info *stat_link_info;
6041 
6042 		/* Print wlan0 or p2p0 states based on the adapter_num
6043 		 * by using the correct adapter
6044 		 */
6045 		while (adapter_num < 2) {
6046 			if (WLAN_ADAPTER == adapter_num) {
6047 				stat_adapter = adapter;
6048 				buf = scnprintf(extra + len,
6049 						WE_MAX_STR_LEN - len,
6050 						"\n\n wlan0 States:-");
6051 				len += buf;
6052 			} else if (P2P_ADAPTER == adapter_num) {
6053 				buf = scnprintf(extra + len,
6054 						WE_MAX_STR_LEN - len,
6055 						"\n\n p2p0 States:-");
6056 				len += buf;
6057 
6058 				if (!hdd_ctx) {
6059 					buf = scnprintf(extra + len,
6060 							WE_MAX_STR_LEN - len,
6061 							"\n hdd_ctx is NULL");
6062 					len += buf;
6063 					break;
6064 				}
6065 
6066 				/* Printing p2p0 states only in the
6067 				 * case when the device is configured
6068 				 * as a p2p_client
6069 				 */
6070 				stat_adapter =
6071 					hdd_get_adapter(hdd_ctx,
6072 							QDF_P2P_CLIENT_MODE);
6073 				if (!stat_adapter) {
6074 					buf =
6075 						scnprintf(extra + len,
6076 							  WE_MAX_STR_LEN -
6077 							  len,
6078 							  "\n Device not configured as P2P_CLIENT.");
6079 					len += buf;
6080 					break;
6081 				}
6082 			}
6083 
6084 			if (!mac_handle) {
6085 				buf = scnprintf(extra + len,
6086 						WE_MAX_STR_LEN - len,
6087 						"\n mac_handle is NULL");
6088 				len += buf;
6089 				break;
6090 			}
6091 			stat_link_info = stat_adapter->deflink;
6092 			sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(stat_link_info);
6093 
6094 			stat_vdev_id = stat_link_info->vdev_id;
6095 			buf = scnprintf(extra + len, WE_MAX_STR_LEN - len,
6096 					"\n HDD Conn State - %s \n\n SME State:\n CSR State - %s\n CSR Substate - %s",
6097 					hdd_connection_state_string
6098 						(sta_ctx->conn_info.conn_state),
6099 					mac_trace_getcsr_roam_state
6100 						(sme_get_current_roam_state
6101 						   (mac_handle, stat_vdev_id)),
6102 					mac_trace_getcsr_roam_sub_state
6103 						(sme_get_current_roam_sub_state
6104 						   (mac_handle, stat_vdev_id))
6105 					);
6106 			len += buf;
6107 			adapter_num++;
6108 		}
6109 
6110 		if (mac_handle) {
6111 			/* Printing Lim State starting with global lim states */
6112 			buf =
6113 				scnprintf(extra + len, WE_MAX_STR_LEN - len,
6114 					  "\n\n LIM STATES:-"
6115 					  "\n Global Sme State - %s "
6116 					  "\n Global mlm State - %s " "\n",
6117 					  mac_trace_get_lim_sme_state
6118 						  (sme_get_lim_sme_state(mac_handle)),
6119 					  mac_trace_get_lim_mlm_state
6120 						  (sme_get_lim_mlm_state(mac_handle))
6121 					  );
6122 			len += buf;
6123 
6124 			while (check < 3 && count < 255) {
6125 				if (sme_is_lim_session_valid(mac_handle, count)) {
6126 					buf =
6127 						scnprintf(extra + len,
6128 							  WE_MAX_STR_LEN -
6129 							  len,
6130 							  "\n Lim Valid Session %d:-"
6131 							  "\n PE Sme State - %s "
6132 							  "\n PE Mlm State - %s "
6133 							  "\n", check,
6134 							  mac_trace_get_lim_sme_state
6135 								  (sme_get_lim_sme_session_state
6136 									  (mac_handle, count)),
6137 							  mac_trace_get_lim_mlm_state
6138 								  (sme_get_lim_mlm_session_state
6139 									  (mac_handle, count))
6140 							  );
6141 
6142 					len += buf;
6143 					check++;
6144 				}
6145 				count++;
6146 			}
6147 		}
6148 
6149 		wrqu->data.length = strlen(extra) + 1;
6150 		break;
6151 	}
6152 
6153 	case WE_GET_CFG:
6154 	{
6155 		hdd_debug("Printing CLD global INI Config");
6156 		hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(adapter),
6157 					  extra,
6158 					  QCSAP_IOCTL_MAX_STR_LEN);
6159 		wrqu->data.length = strlen(extra) + 1;
6160 		break;
6161 	}
6162 	case WE_GET_RSSI:
6163 	{
6164 		int8_t s7Rssi = 0;
6165 
6166 		wlan_hdd_get_rssi(link_info, &s7Rssi);
6167 		snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
6168 		wrqu->data.length = strlen(extra) + 1;
6169 		break;
6170 	}
6171 
6172 	case WE_GET_WMM_STATUS:
6173 	{
6174 		snprintf(extra, WE_MAX_STR_LEN,
6175 			 "\nDir: 0=up, 1=down, 3=both\n"
6176 			 "|------------------------|\n"
6177 			 "|AC | ACM |Admitted| Dir |\n"
6178 			 "|------------------------|\n"
6179 			 "|VO |  %d  |  %3s   |  %d  |\n"
6180 			 "|VI |  %d  |  %3s   |  %d  |\n"
6181 			 "|BE |  %d  |  %3s   |  %d  |\n"
6182 			 "|BK |  %d  |  %3s   |  %d  |\n"
6183 			 "|------------------------|\n",
6184 			 adapter->hdd_wmm_status.
6185 			 ac_status[SME_AC_VO].is_access_required,
6186 			 adapter->hdd_wmm_status.
6187 			 ac_status[SME_AC_VO].
6188 			 is_access_allowed ? "YES" : "NO",
6189 			 adapter->hdd_wmm_status.
6190 			 ac_status[SME_AC_VO].tspec.
6191 			 ts_info.direction,
6192 			 adapter->hdd_wmm_status.
6193 			 ac_status[SME_AC_VI].is_access_required,
6194 			 adapter->hdd_wmm_status.
6195 			 ac_status[SME_AC_VI].
6196 			 is_access_allowed ? "YES" : "NO",
6197 			 adapter->hdd_wmm_status.
6198 			 ac_status[SME_AC_VI].tspec.
6199 			 ts_info.direction,
6200 			 adapter->hdd_wmm_status.
6201 			 ac_status[SME_AC_BE].is_access_required,
6202 			 adapter->hdd_wmm_status.
6203 			 ac_status[SME_AC_BE].
6204 			 is_access_allowed ? "YES" : "NO",
6205 			 adapter->hdd_wmm_status.
6206 			 ac_status[SME_AC_BE].tspec.
6207 			 ts_info.direction,
6208 			 adapter->hdd_wmm_status.
6209 			 ac_status[SME_AC_BK].is_access_required,
6210 			 adapter->hdd_wmm_status.
6211 			 ac_status[SME_AC_BK].
6212 			 is_access_allowed ? "YES" : "NO",
6213 			 adapter->hdd_wmm_status.
6214 			 ac_status[SME_AC_BK].tspec.
6215 			 ts_info.direction);
6216 
6217 		wrqu->data.length = strlen(extra) + 1;
6218 		break;
6219 	}
6220 
6221 	case WE_GET_BA_AGEING_TIMEOUT:
6222 	{
6223 		uint32_t i;
6224 		enum qca_wlan_ac_type duration[QCA_WLAN_AC_ALL];
6225 		void *soc = cds_get_context(QDF_MODULE_ID_SOC);
6226 
6227 		if (!soc)
6228 			break;
6229 
6230 		for (i = 0; i < QCA_WLAN_AC_ALL; i++)
6231 			cdp_get_ba_timeout(soc, i, &duration[i]);
6232 
6233 		snprintf(extra, WE_MAX_STR_LEN,
6234 			 "\n|------------------------------|\n"
6235 			 "|AC | BA aging timeout duration |\n"
6236 			 "|--------------------------------|\n"
6237 			 "|VO |  %d        |\n"
6238 			 "|VI |  %d        |\n"
6239 			 "|BK |  %d        |\n"
6240 			 "|BE |  %d        |\n"
6241 			 "|--------------------------------|\n",
6242 			duration[QCA_WLAN_AC_VO], duration[QCA_WLAN_AC_VI],
6243 			duration[QCA_WLAN_AC_BK], duration[QCA_WLAN_AC_BE]);
6244 
6245 		wrqu->data.length = strlen(extra) + 1;
6246 		break;
6247 	}
6248 
6249 	case WE_GET_CHANNEL_LIST:
6250 	{
6251 		if (0 !=
6252 		    iw_get_channel_list_with_cc(dev, mac_handle,
6253 						info, wrqu, extra))
6254 			return -EINVAL;
6255 		break;
6256 	}
6257 #ifdef FEATURE_WLAN_TDLS
6258 	case WE_GET_TDLS_PEERS:
6259 	{
6260 		wrqu->data.length =
6261 			wlan_hdd_tdls_get_all_peers(adapter, extra,
6262 						    WE_MAX_STR_LEN) + 1;
6263 		break;
6264 	}
6265 #endif
6266 	case WE_GET_11W_INFO:
6267 	{
6268 		struct qdf_mac_addr connected_bssid;
6269 
6270 		wlan_mlme_get_bssid_vdev_id(hdd_ctx->pdev,
6271 					    link_info->vdev_id,
6272 					    &connected_bssid);
6273 		snprintf(extra, WE_MAX_STR_LEN,
6274 			 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X"
6275 			 "\n Number of Unprotected Disassocs %d"
6276 			 "\n Number of Unprotected Deauths %d",
6277 			 connected_bssid.bytes[0],
6278 			 connected_bssid.bytes[1],
6279 			 connected_bssid.bytes[2],
6280 			 connected_bssid.bytes[3],
6281 			 connected_bssid.bytes[4],
6282 			 connected_bssid.bytes[5],
6283 			 link_info->hdd_stats.hdd_pmf_stats.
6284 			 num_unprot_disassoc_rx,
6285 			 link_info->hdd_stats.hdd_pmf_stats.
6286 			 num_unprot_deauth_rx);
6287 
6288 		wrqu->data.length = strlen(extra) + 1;
6289 		break;
6290 	}
6291 	case WE_GET_PHYMODE:
6292 	{
6293 		bool ch_bond24 = false, ch_bond5g = false;
6294 		struct hdd_context *hddctx = WLAN_HDD_GET_CTX(adapter);
6295 		eCsrPhyMode phymode;
6296 		enum band_info current_band;
6297 		struct sme_config_params *sme_config;
6298 
6299 		sme_config = qdf_mem_malloc(sizeof(*sme_config));
6300 		if (!sme_config) {
6301 			ret = -ENOMEM;
6302 			break;
6303 		}
6304 
6305 		sme_get_config_param(mac_handle, sme_config);
6306 		if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
6307 		    sme_config->csr_config.channelBondingMode24GHz)
6308 			ch_bond24 = true;
6309 
6310 		if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
6311 		    sme_config->csr_config.channelBondingMode5GHz)
6312 			ch_bond5g = true;
6313 
6314 		qdf_mem_free(sme_config);
6315 
6316 		phymode = sme_get_phy_mode(mac_handle);
6317 		if ((QDF_STATUS_SUCCESS !=
6318 		     ucfg_reg_get_band(hddctx->pdev, &current_band))) {
6319 			hdd_err("Failed to get current band config");
6320 			return -EIO;
6321 		}
6322 
6323 		switch (phymode) {
6324 		case eCSR_DOT11_MODE_AUTO:
6325 			snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
6326 			break;
6327 		case eCSR_DOT11_MODE_11n:
6328 		case eCSR_DOT11_MODE_11n_ONLY:
6329 			if (current_band == BAND_2G) {
6330 				if (ch_bond24)
6331 					snprintf(extra, WE_MAX_STR_LEN,
6332 						 "11NGHT40");
6333 				else
6334 					snprintf(extra, WE_MAX_STR_LEN,
6335 						 "11NGHT20");
6336 			} else if (current_band == BAND_5G) {
6337 				if (ch_bond5g)
6338 					snprintf(extra, WE_MAX_STR_LEN,
6339 						 "11NAHT40");
6340 				else
6341 					snprintf(extra, WE_MAX_STR_LEN,
6342 						 "11NAHT20");
6343 			} else {
6344 				snprintf(extra, WE_MAX_STR_LEN, "11N");
6345 			}
6346 			break;
6347 		case eCSR_DOT11_MODE_abg:
6348 			snprintf(extra, WE_MAX_STR_LEN, "11ABG");
6349 			break;
6350 		case eCSR_DOT11_MODE_11a:
6351 			snprintf(extra, WE_MAX_STR_LEN, "11A");
6352 			break;
6353 		case eCSR_DOT11_MODE_11b:
6354 		case eCSR_DOT11_MODE_11b_ONLY:
6355 			snprintf(extra, WE_MAX_STR_LEN, "11B");
6356 			break;
6357 		case eCSR_DOT11_MODE_11g:
6358 		case eCSR_DOT11_MODE_11g_ONLY:
6359 			snprintf(extra, WE_MAX_STR_LEN, "11G");
6360 			break;
6361 		case eCSR_DOT11_MODE_11ac:
6362 		case eCSR_DOT11_MODE_11ac_ONLY:
6363 			status =
6364 			   ucfg_mlme_get_vht_channel_width(hddctx->psoc,
6365 							   &value);
6366 			if (!QDF_IS_STATUS_SUCCESS(status))
6367 				hdd_err("Failed to set channel_width");
6368 			if (value == eHT_CHANNEL_WIDTH_20MHZ)
6369 				snprintf(extra, WE_MAX_STR_LEN,
6370 					 "11ACVHT20");
6371 			else if (value == eHT_CHANNEL_WIDTH_40MHZ)
6372 				snprintf(extra, WE_MAX_STR_LEN,
6373 					 "11ACVHT40");
6374 			else if (value == eHT_CHANNEL_WIDTH_80MHZ)
6375 				snprintf(extra, WE_MAX_STR_LEN,
6376 					 "11ACVHT80");
6377 			else if (value == eHT_CHANNEL_WIDTH_160MHZ)
6378 				snprintf(extra, WE_MAX_STR_LEN,
6379 					 "11ACVHT160");
6380 			break;
6381 		case eCSR_DOT11_MODE_11ax:
6382 		case eCSR_DOT11_MODE_11ax_ONLY:
6383 			status =
6384 			ucfg_mlme_get_vht_channel_width(hddctx->psoc,
6385 							&value);
6386 			if (!QDF_IS_STATUS_SUCCESS(status))
6387 				hdd_err("Failed to set channel_width");
6388 
6389 			/* currently using vhtChannelWidth */
6390 			if (value == eHT_CHANNEL_WIDTH_20MHZ)
6391 				snprintf(extra, WE_MAX_STR_LEN,
6392 					 "11AX_HE_20");
6393 			else if (value == eHT_CHANNEL_WIDTH_40MHZ)
6394 				snprintf(extra, WE_MAX_STR_LEN,
6395 					 "11AX_HE_40");
6396 			else if (value == eHT_CHANNEL_WIDTH_80MHZ)
6397 				snprintf(extra, WE_MAX_STR_LEN,
6398 					 "11AX_HE_80");
6399 			else if (value == eHT_CHANNEL_WIDTH_160MHZ)
6400 				snprintf(extra, WE_MAX_STR_LEN,
6401 					 "11AX_HE_160");
6402 			break;
6403 		default:
6404 			break;
6405 		}
6406 
6407 		wrqu->data.length = strlen(extra) + 1;
6408 		break;
6409 	}
6410 
6411 	case WE_GET_OEM_DATA_CAP:
6412 		return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
6413 	case WE_GET_SNR:
6414 	{
6415 		int8_t s7snr = 0;
6416 		int status = 0;
6417 		bool enable_snr_monitoring;
6418 		struct hdd_context *hdd_ctx;
6419 
6420 		hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6421 		status = wlan_hdd_validate_context(hdd_ctx);
6422 		if (status)
6423 			return status;
6424 
6425 		enable_snr_monitoring =
6426 				ucfg_scan_is_snr_monitor_enabled(hdd_ctx->psoc);
6427 		if (!enable_snr_monitoring ||
6428 		    !hdd_cm_is_vdev_associated(link_info)) {
6429 			hdd_err("getSNR failed: Enable SNR Monitoring-%d",
6430 				enable_snr_monitoring);
6431 			return -ENONET;
6432 		}
6433 		wlan_hdd_get_snr(link_info, &s7snr);
6434 		snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
6435 		wrqu->data.length = strlen(extra) + 1;
6436 		break;
6437 	}
6438 
6439 	case WE_GET_STA_CXN_INFO:
6440 		ret = hdd_get_sta_cxn_info(hdd_ctx, adapter, extra);
6441 		wrqu->data.length = strlen(extra) + 1;
6442 		break;
6443 
6444 	default:
6445 		hdd_err("Invalid IOCTL command %d", sub_cmd);
6446 		break;
6447 	}
6448 
6449 	hdd_exit();
6450 	return ret;
6451 }
6452 
6453 /**
6454  * iw_get_char_setnone() - Generic "get string" private ioctl handler
6455  * @dev: device upon which the ioctl was received
6456  * @info: ioctl request information
6457  * @wrqu: ioctl request data
6458  * @extra: ioctl extra data
6459  *
6460  * Return: 0 on success, non-zero on error
6461  */
iw_get_char_setnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)6462 static int iw_get_char_setnone(struct net_device *dev,
6463 			       struct iw_request_info *info,
6464 			       union iwreq_data *wrqu, char *extra)
6465 {
6466 	int errno;
6467 	struct osif_vdev_sync *vdev_sync;
6468 
6469 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
6470 	if (errno)
6471 		return errno;
6472 
6473 	errno = __iw_get_char_setnone(dev, info, wrqu, extra);
6474 
6475 	osif_vdev_sync_op_stop(vdev_sync);
6476 
6477 	return errno;
6478 }
6479 
6480 /**
6481  * __iw_setnone_getnone() - Generic "action" private ioctl handler
6482  * @dev: device upon which the ioctl was received
6483  * @info: ioctl request information
6484  * @wrqu: ioctl request data
6485  * @extra: ioctl extra data
6486  *
6487  * Return: 0 on success, non-zero on error
6488  */
__iw_setnone_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)6489 static int __iw_setnone_getnone(struct net_device *dev,
6490 				struct iw_request_info *info,
6491 				union iwreq_data *wrqu, char *extra)
6492 {
6493 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6494 	struct hdd_context *hdd_ctx;
6495 	mac_handle_t mac_handle;
6496 	int ret;
6497 	int sub_cmd;
6498 
6499 	hdd_enter_dev(dev);
6500 
6501 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6502 	ret = wlan_hdd_validate_context(hdd_ctx);
6503 	if (0 != ret)
6504 		return ret;
6505 
6506 	ret = hdd_check_private_wext_control(hdd_ctx, info);
6507 	if (0 != ret)
6508 		return ret;
6509 
6510 #ifdef CONFIG_COMPAT
6511 	/* this ioctl is a special case where a sub-ioctl is used and both
6512 	 * the number of get and set args is 0.  in this specific case the
6513 	 * logic in iwpriv places the sub_cmd in the data.flags portion of
6514 	 * the iwreq.  unfortunately the location of this field will be
6515 	 * different between 32-bit and 64-bit userspace, and the standard
6516 	 * compat support in the kernel does not handle this case.  so we
6517 	 * need to explicitly handle it here.
6518 	 */
6519 	if (in_compat_syscall()) {
6520 		struct compat_iw_point *compat_iw_point =
6521 			(struct compat_iw_point *)&wrqu->data;
6522 		sub_cmd = compat_iw_point->flags;
6523 	} else {
6524 		sub_cmd = wrqu->data.flags;
6525 	}
6526 #else
6527 	sub_cmd = wrqu->data.flags;
6528 #endif
6529 
6530 	mac_handle = hdd_ctx->mac_handle;
6531 	switch (sub_cmd) {
6532 	case WE_GET_FW_PROFILE_DATA:
6533 		ret = wma_cli_set_command(
6534 				adapter->deflink->vdev_id,
6535 				WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
6536 				0, DBG_CMD);
6537 		break;
6538 
6539 	case WE_SET_REASSOC_TRIGGER:
6540 	{
6541 		struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6542 		qdf_freq_t chan_freq =
6543 			wlan_get_operation_chan_freq(adapter->deflink->vdev);
6544 		struct qdf_mac_addr target_bssid;
6545 
6546 		wlan_mlme_get_bssid_vdev_id(hdd_ctx->pdev,
6547 					    adapter->deflink->vdev_id,
6548 					    &target_bssid);
6549 		ucfg_wlan_cm_roam_invoke(hdd_ctx->pdev,
6550 					 adapter->deflink->vdev_id,
6551 					 &target_bssid, chan_freq,
6552 					 CM_ROAMING_USER);
6553 		return 0;
6554 	}
6555 
6556 	case WE_STOP_OBSS_SCAN:
6557 		/*
6558 		 * 1.OBSS Scan is mandatory while operating in 2.4GHz
6559 		 * 2.OBSS scan is stopped by Firmware during the disassociation
6560 		 * 3.OBSS stop command is added for debugging purpose
6561 		 */
6562 		if (!mac_handle) {
6563 			hdd_err("mac_handle context is NULL");
6564 			return -EINVAL;
6565 		}
6566 		sme_ht40_stop_obss_scan(mac_handle, adapter->deflink->vdev_id);
6567 		break;
6568 
6569 	default:
6570 		hdd_err("unknown ioctl %d", sub_cmd);
6571 		break;
6572 	}
6573 	hdd_exit();
6574 	return ret;
6575 }
6576 
6577 /**
6578  * iw_setnone_getnone() - Generic "action" private ioctl handler
6579  * @dev: device upon which the ioctl was received
6580  * @info: ioctl request information
6581  * @wrqu: ioctl request data
6582  * @extra: ioctl extra data
6583  *
6584  * Return: 0 on success, non-zero on error
6585  */
iw_setnone_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)6586 static int iw_setnone_getnone(struct net_device *dev,
6587 			      struct iw_request_info *info,
6588 			      union iwreq_data *wrqu, char *extra)
6589 {
6590 	int errno;
6591 	struct osif_vdev_sync *vdev_sync;
6592 
6593 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
6594 	if (errno)
6595 		return errno;
6596 
6597 	errno = __iw_setnone_getnone(dev, info, wrqu, extra);
6598 
6599 	osif_vdev_sync_op_stop(vdev_sync);
6600 
6601 	return errno;
6602 }
6603 
6604 /**
6605  * hdd_ch_avoid_unit_cmd - unit test ch avoidance
6606  * @hdd_ctx: hdd_context
6607  * @num_args: input args number
6608  * @apps_args: args data ptr
6609  *
6610  * This is to inject a ch avoid event to do unit test SAP chan avoidance.
6611  *
6612  * Return: void
6613  */
6614 #ifdef WLAN_DEBUG
hdd_ch_avoid_unit_cmd(struct hdd_context * hdd_ctx,int num_args,int * apps_args)6615 static void hdd_ch_avoid_unit_cmd(struct hdd_context *hdd_ctx,
6616 				  int num_args, int *apps_args)
6617 {
6618 	struct ch_avoid_ind_type ch_avoid;
6619 	int cnt = 0, i;
6620 
6621 	if (num_args < 2 || num_args > CH_AVOID_MAX_RANGE * 2 ||
6622 	    num_args % 2 != 0)
6623 		return;
6624 	hdd_info("simulate ch avoid num_args %d", num_args);
6625 	for (i = 0; i < num_args && i < CH_AVOID_MAX_RANGE * 2; i++) {
6626 		ch_avoid.avoid_freq_range[cnt].start_freq =
6627 			apps_args[i];
6628 		ch_avoid.avoid_freq_range[cnt].end_freq =
6629 			apps_args[++i];
6630 
6631 		hdd_info("simulate ch avoid [%d %d]",
6632 			 ch_avoid.avoid_freq_range[cnt].start_freq,
6633 			 ch_avoid.avoid_freq_range[cnt].end_freq);
6634 		cnt++;
6635 	}
6636 	ch_avoid.ch_avoid_range_cnt = cnt;
6637 	ucfg_reg_unit_simulate_ch_avoid(hdd_ctx->psoc, &ch_avoid);
6638 }
6639 #else
hdd_ch_avoid_unit_cmd(struct hdd_context * hdd_ctx,int num_args,int * apps_args)6640 static void hdd_ch_avoid_unit_cmd(struct hdd_context *hdd_ctx,
6641 				  int num_args, int *apps_args)
6642 {
6643 }
6644 #endif
6645 
6646 #ifdef FW_THERMAL_THROTTLE_SUPPORT
6647 /**
6648  * hdd_send_thermal_mgmt_cmd - Send thermal management params
6649  * @mac_handle: Opaque handle to the global MAC context
6650  * @lower_thresh_deg: Lower threshold value of Temperature
6651  * @higher_thresh_deg: Higher threshold value of Temperature
6652  *
6653  * Return: QDF_STATUS
6654  */
6655 #ifndef QCN7605_SUPPORT
hdd_send_thermal_mgmt_cmd(mac_handle_t mac_handle,uint16_t lower_thresh_deg,uint16_t higher_thresh_deg)6656 static QDF_STATUS hdd_send_thermal_mgmt_cmd(mac_handle_t mac_handle,
6657 					    uint16_t lower_thresh_deg,
6658 					    uint16_t higher_thresh_deg)
6659 {
6660 	return sme_set_thermal_mgmt(mac_handle, lower_thresh_deg,
6661 				    higher_thresh_deg);
6662 }
6663 #else
hdd_send_thermal_mgmt_cmd(mac_handle_t mac_handle,uint16_t lower_thresh_deg,uint16_t higher_thresh_deg)6664 static QDF_STATUS hdd_send_thermal_mgmt_cmd(mac_handle_t mac_handle,
6665 					    uint16_t lower_thresh_deg,
6666 					    uint16_t higher_thresh_deg)
6667 {
6668 	return QDF_STATUS_SUCCESS;
6669 }
6670 #endif
6671 #endif /* FW_THERMAL_THROTTLE_SUPPORT */
6672 
6673 /**
6674  * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
6675  * @dev: device upon which the ioctl was received
6676  * @info: ioctl request information
6677  * @wrqu: ioctl request data
6678  * @extra: ioctl extra data
6679  *
6680  * This is an SSR-protected generic handler for private ioctls which
6681  * take multiple arguments.  Note that this implementation is also
6682  * somewhat unique in that it is shared by both STA-mode and SAP-mode
6683  * interfaces.
6684  *
6685  * Return: 0 on success, non-zero on error
6686  */
__iw_set_var_ints_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)6687 static int __iw_set_var_ints_getnone(struct net_device *dev,
6688 				     struct iw_request_info *info,
6689 				     union iwreq_data *wrqu, char *extra)
6690 {
6691 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6692 	mac_handle_t mac_handle;
6693 	struct hdd_station_ctx *sta_ctx;
6694 	int sub_cmd;
6695 	int *apps_args = (int *) extra;
6696 	struct hdd_context *hdd_ctx;
6697 	int ret, num_args;
6698 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
6699 	struct cdp_txrx_stats_req req = {0};
6700 
6701 	hdd_enter_dev(dev);
6702 
6703 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6704 	ret = wlan_hdd_validate_context(hdd_ctx);
6705 	if (0 != ret)
6706 		return ret;
6707 
6708 	ret = hdd_check_private_wext_control(hdd_ctx, info);
6709 	if (0 != ret)
6710 		return ret;
6711 
6712 	mac_handle = hdd_ctx->mac_handle;
6713 	sub_cmd = wrqu->data.flags;
6714 	num_args = wrqu->data.length;
6715 	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
6716 
6717 	hdd_debug("Received length %d", wrqu->data.length);
6718 
6719 	switch (sub_cmd) {
6720 	case WE_P2P_NOA_CMD:
6721 	{
6722 		struct p2p_app_set_ps p2p_noa;
6723 
6724 		if (adapter->device_mode != QDF_P2P_GO_MODE) {
6725 			hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
6726 				qdf_opmode_str(adapter->device_mode),
6727 				adapter->device_mode);
6728 			return -EINVAL;
6729 		}
6730 
6731 		p2p_noa.opp_ps = apps_args[0];
6732 		p2p_noa.ct_window = apps_args[1];
6733 		p2p_noa.duration = apps_args[2];
6734 		p2p_noa.interval = apps_args[3];
6735 		p2p_noa.count = apps_args[4];
6736 		p2p_noa.single_noa_duration = apps_args[5];
6737 		p2p_noa.ps_selection = apps_args[6];
6738 
6739 		hdd_debug("P2P_NOA_ATTR:opp ps %d ct window %d duration %d interval %d count %d single noa duration %d ps selection %x",
6740 			   apps_args[0], apps_args[1], apps_args[2],
6741 			   apps_args[3], apps_args[4],
6742 			   apps_args[5], apps_args[6]);
6743 
6744 		hdd_set_p2p_ps(dev, &p2p_noa);
6745 
6746 	}
6747 	break;
6748 
6749 	case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
6750 	{
6751 		hdd_debug("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
6752 			   apps_args[0], apps_args[1]);
6753 		qdf_trace_enable(apps_args[0], apps_args[1]);
6754 	}
6755 	break;
6756 
6757 	case WE_MTRACE_DUMP_CMD:
6758 	{
6759 		hdd_debug("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
6760 			   apps_args[0], apps_args[1],
6761 			   apps_args[2], apps_args[3]);
6762 		qdf_trace_dump_all((void *)mac_handle, apps_args[0],
6763 				   apps_args[1], apps_args[2],
6764 				   apps_args[3]);
6765 
6766 	}
6767 	break;
6768 
6769 	case WE_POLICY_MANAGER_CINFO_CMD:
6770 	{
6771 		struct policy_mgr_conc_connection_info *conn_info;
6772 		uint32_t i = 0, len = 0;
6773 
6774 		hdd_info("<iwpriv wlan0 pm_cinfo> is called");
6775 		conn_info = policy_mgr_get_conn_info(&len);
6776 		pr_info("+--------------------------+\n");
6777 		for (i = 0; i < len; i++) {
6778 			if (!conn_info->in_use)
6779 				continue;
6780 
6781 			pr_info("|table_index[%d]\t\t\n", i);
6782 			pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
6783 			pr_info("|\t|freq    - %-10d|\n", conn_info->freq);
6784 			pr_info("|\t|bw      - %-10d|\n", conn_info->bw);
6785 			pr_info("|\t|mode    - %-10d|\n", conn_info->mode);
6786 			pr_info("|\t|mac_id  - %-10d|\n", conn_info->mac);
6787 			pr_info("|\t|in_use  - %-10d|\n", conn_info->in_use);
6788 			pr_info("+--------------------------+\n");
6789 			conn_info++;
6790 		}
6791 
6792 		pr_info("|\t|current state dbs - %-10d, sbs - %-10d|\n",
6793 			policy_mgr_is_current_hwmode_dbs(hdd_ctx->psoc),
6794 			policy_mgr_is_current_hwmode_sbs(hdd_ctx->psoc));
6795 	}
6796 	break;
6797 
6798 	case WE_UNIT_TEST_CMD:
6799 	{
6800 		QDF_STATUS status;
6801 		uint8_t vdev_id = 0;
6802 
6803 		if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
6804 		    (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
6805 			hdd_err_rl("Invalid MODULE ID %d", apps_args[0]);
6806 			return -EINVAL;
6807 		}
6808 		if (apps_args[1] > WMI_UNIT_TEST_MAX_NUM_ARGS ||
6809 		    apps_args[1] < 0) {
6810 			hdd_err_rl("Too Many/Few args %d", apps_args[1]);
6811 			return -EINVAL;
6812 		}
6813 
6814 		if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam())
6815 			vdev_id = 0;
6816 		else
6817 			vdev_id = adapter->deflink->vdev_id;
6818 
6819 		if (vdev_id >= WLAN_MAX_VDEVS) {
6820 			hdd_err_rl("Invalid vdev id %d", vdev_id);
6821 			return -EINVAL;
6822 		}
6823 
6824 		status = sme_send_unit_test_cmd(vdev_id,
6825 						apps_args[0],
6826 						apps_args[1],
6827 						&apps_args[2]);
6828 		if (QDF_STATUS_SUCCESS != status) {
6829 			hdd_err("sme_send_unit_test_cmd returned %d", status);
6830 			return -EINVAL;
6831 		}
6832 	}
6833 	break;
6834 #ifdef WLAN_FEATURE_GPIO_LED_FLASHING
6835 	case WE_LED_FLASHING_PARAM:
6836 	{
6837 		int i;
6838 
6839 		if (num_args != 4) {
6840 			hdd_err("gpio_control: 4 parameters are required");
6841 			return -EINVAL;
6842 		}
6843 		for (i = 0; i < num_args; i++) {
6844 			if (apps_args[i] >= 0x7fffffff) {
6845 				hdd_err("gpio_control: parameter should be less than 0x7fffffff");
6846 				return -EINVAL;
6847 			}
6848 		}
6849 		sme_set_led_flashing(mac_handle,
6850 				     0, apps_args[0], apps_args[1]);
6851 		sme_set_led_flashing(mac_handle,
6852 				     1, apps_args[2], apps_args[3]);
6853 	}
6854 	break;
6855 #endif
6856 	case WE_SET_PKTLOG:
6857 	{
6858 		int ret;
6859 
6860 		if (num_args < 1 || num_args > 2) {
6861 			hdd_err("pktlog: either 1 or 2 parameters are required");
6862 			return -EINVAL;
6863 		}
6864 
6865 		ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
6866 						   apps_args[1]);
6867 		if (ret)
6868 			return ret;
6869 		break;
6870 	}
6871 	case WE_MAC_PWR_DEBUG_CMD:
6872 	{
6873 		struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
6874 		int i, j;
6875 
6876 		if (num_args < 3) {
6877 			hdd_err("number of arguments can't be null %d",
6878 				num_args);
6879 			return -EINVAL;
6880 		}
6881 		if (num_args - 3 != apps_args[2]) {
6882 			hdd_err("arg list of size %d doesn't match num_args %d",
6883 				num_args-3, apps_args[2]);
6884 			return -EINVAL;
6885 		}
6886 		if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
6887 		    (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
6888 			hdd_err("Invalid MODULE ID %d", apps_args[1]);
6889 			return -EINVAL;
6890 		}
6891 		if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
6892 			hdd_err("Too Many args %d", apps_args[2]);
6893 			return -EINVAL;
6894 		}
6895 		mac_pwr_dbg_args.pdev_id = apps_args[0];
6896 		mac_pwr_dbg_args.module_id = apps_args[1];
6897 		mac_pwr_dbg_args.num_args = apps_args[2];
6898 
6899 		for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
6900 			mac_pwr_dbg_args.args[i] = apps_args[j];
6901 
6902 		if (QDF_STATUS_SUCCESS !=
6903 			sme_process_mac_pwr_dbg_cmd(mac_handle,
6904 						    adapter->deflink->vdev_id,
6905 						    &mac_pwr_dbg_args)) {
6906 			return -EINVAL;
6907 		}
6908 	}
6909 	break;
6910 	case WE_SET_CHAN_AVOID:
6911 	{
6912 		hdd_ch_avoid_unit_cmd(hdd_ctx, num_args, apps_args);
6913 	}
6914 	break;
6915 	case WE_SET_TXRX_STATS:
6916 	{
6917 		req.stats = apps_args[0];
6918 		/* default value of secondary parameter is 0(mac_id) */
6919 		req.mac_id = apps_args[1];
6920 
6921 		hdd_debug("WE_SET_TXRX_STATS stats cmd: %d mac_id: %d",
6922 				req.stats, req.mac_id);
6923 		if (qdf_unlikely(!soc)) {
6924 			hdd_err("soc is NULL");
6925 			return -EINVAL;
6926 		}
6927 
6928 		if (apps_args[0] == CDP_TXRX_STATS_28) {
6929 			if (sta_ctx->conn_info.is_authenticated) {
6930 				hdd_debug("ap mac addr: "QDF_MAC_ADDR_FMT,
6931 					  QDF_MAC_ADDR_REF(sta_ctx->conn_info.bssid.bytes));
6932 				req.peer_addr =
6933 					(char *)&sta_ctx->conn_info.bssid;
6934 			}
6935 		}
6936 		ret = cdp_txrx_stats_request(soc, adapter->deflink->vdev_id,
6937 					     &req);
6938 		break;
6939 	}
6940 #ifdef WLAN_FEATURE_MOTION_DETECTION
6941 	case WE_MOTION_DET_CONFIG_PARAM:
6942 	{
6943 		struct sme_motion_det_cfg motion_det_cfg;
6944 
6945 		if (num_args != 15) {
6946 			hdd_err_rl("mt_config: Invalid no of args");
6947 			return -EINVAL;
6948 		}
6949 
6950 		motion_det_cfg.vdev_id = adapter->deflink->vdev_id;
6951 		motion_det_cfg.time_t1 = apps_args[0];
6952 		motion_det_cfg.time_t2 = apps_args[1];
6953 		motion_det_cfg.n1 = apps_args[2];
6954 		motion_det_cfg.n2 = apps_args[3];
6955 		motion_det_cfg.time_t1_gap = apps_args[4];
6956 		motion_det_cfg.time_t2_gap = apps_args[5];
6957 		motion_det_cfg.coarse_K = apps_args[6];
6958 		motion_det_cfg.fine_K = apps_args[7];
6959 		motion_det_cfg.coarse_Q = apps_args[8];
6960 		motion_det_cfg.fine_Q = apps_args[9];
6961 		motion_det_cfg.md_coarse_thr_high = apps_args[10];
6962 		motion_det_cfg.md_fine_thr_high = apps_args[11];
6963 		motion_det_cfg.md_coarse_thr_low = apps_args[12];
6964 		motion_det_cfg.md_fine_thr_low = apps_args[13];
6965 		adapter->motion_detection_mode = apps_args[14];
6966 		sme_motion_det_config(hdd_ctx->mac_handle, &motion_det_cfg);
6967 		adapter->motion_det_cfg =  true;
6968 	}
6969 	break;
6970 	case WE_MOTION_DET_BASE_LINE_CONFIG_PARAM:
6971 	{
6972 		struct sme_motion_det_base_line_cfg motion_det_base_line_cfg;
6973 
6974 		if (num_args != 4) {
6975 			hdd_err_rl("mt_bl_config: Invalid no of args");
6976 			return -EINVAL;
6977 		}
6978 
6979 		motion_det_base_line_cfg.vdev_id = adapter->deflink->vdev_id;
6980 		motion_det_base_line_cfg.bl_time_t = apps_args[0];
6981 		motion_det_base_line_cfg.bl_packet_gap = apps_args[1];
6982 		motion_det_base_line_cfg.bl_n = apps_args[2];
6983 		motion_det_base_line_cfg.bl_num_meas = apps_args[3];
6984 		sme_motion_det_base_line_config(hdd_ctx->mac_handle,
6985 						&motion_det_base_line_cfg);
6986 	}
6987 	break;
6988 #endif /* WLAN_FEATURE_MOTION_DETECTION */
6989 #ifdef FW_THERMAL_THROTTLE_SUPPORT
6990 	case WE_SET_THERMAL_THROTTLE_CFG:
6991 	{
6992 		QDF_STATUS status;
6993 		struct thermal_mitigation_params therm_cfg_params;
6994 		struct wlan_fwol_thermal_temp thermal_temp = {0};
6995 		if (num_args != 7) {
6996 			hdd_err_rl("set_thermal_cfg: Invalid no of args");
6997 			return -EINVAL;
6998 		}
6999 		status = ucfg_fwol_get_thermal_temp(hdd_ctx->psoc,
7000 						    &thermal_temp);
7001 		if (QDF_IS_STATUS_ERROR(status)) {
7002 			hdd_err_rl("Failed to get fwol thermal obj");
7003 			return qdf_status_to_os_return(status);
7004 		}
7005 
7006 		/* Check for valid inputs */
7007 		if (apps_args[0] < 0 || apps_args[0] > 1 || apps_args[1] < 0 ||
7008 		    apps_args[2] < 0 || apps_args[2] > 100 ||
7009 		    apps_args[3] < 0 || apps_args[3] > 3 ||  apps_args[4] < 0 ||
7010 		    apps_args[5] < 0 || apps_args[6] < 0 ||
7011 		    apps_args[5] <= apps_args[4])
7012 			return -EINVAL;
7013 
7014 		therm_cfg_params.enable = apps_args[0];
7015 		therm_cfg_params.dc = apps_args[1];
7016 		therm_cfg_params.levelconf[0].dcoffpercent = apps_args[2];
7017 		therm_cfg_params.levelconf[0].priority = apps_args[3];
7018 		therm_cfg_params.levelconf[0].tmplwm = apps_args[6];
7019 		hdd_thermal_fill_clientid_priority(hdd_ctx,
7020 						   THERMAL_MONITOR_APPS,
7021 						   thermal_temp.priority_apps,
7022 						   thermal_temp.priority_wpps,
7023 						   &therm_cfg_params);
7024 		therm_cfg_params.num_thermal_conf = 1;
7025 		status = sme_set_thermal_throttle_cfg(hdd_ctx->mac_handle,
7026 						      &therm_cfg_params);
7027 		if (QDF_IS_STATUS_ERROR(status))
7028 			return qdf_status_to_os_return(status);
7029 
7030 		if (!apps_args[6]) {
7031 			status = hdd_send_thermal_mgmt_cmd(hdd_ctx->mac_handle,
7032 							   apps_args[4],
7033 							   apps_args[5]);
7034 			if (QDF_IS_STATUS_ERROR(status))
7035 				return qdf_status_to_os_return(status);
7036 		}
7037 		break;
7038 	}
7039 #endif /* FW_THERMAL_THROTTLE_SUPPORT */
7040 	default:
7041 	{
7042 		hdd_err("Invalid IOCTL command %d", sub_cmd);
7043 	}
7044 	break;
7045 	}
7046 	hdd_exit();
7047 	return 0;
7048 }
7049 
7050 /**
7051  * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
7052  * @dev: pointer to net_device structure
7053  * @info: pointer to iw_request_info structure
7054  * @wrqu: pointer to iwreq_data
7055  * @extra: extra
7056  *
7057  * Return: 0 on success, error number otherwise
7058  *
7059  */
iw_hdd_set_var_ints_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7060 static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
7061 				       struct iw_request_info *info,
7062 				       union iwreq_data *wrqu, char *extra)
7063 {
7064 	union iwreq_data u_priv_wrqu;
7065 	int apps_args[MAX_VAR_ARGS] = {0};
7066 	int errno, num_args;
7067 	struct osif_vdev_sync *vdev_sync;
7068 
7069 	if (!capable(CAP_NET_ADMIN)) {
7070 		hdd_err("permission check failed");
7071 		return -EPERM;
7072 	}
7073 
7074 	/* Helper function to get iwreq_data with compat handling. */
7075 	if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
7076 		return -EINVAL;
7077 
7078 	if (!u_priv_wrqu.data.pointer) {
7079 		hdd_err("NULL data pointer");
7080 		return -EINVAL;
7081 	}
7082 
7083 	num_args = u_priv_wrqu.data.length;
7084 	if (num_args > MAX_VAR_ARGS)
7085 		num_args = MAX_VAR_ARGS;
7086 
7087 	if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
7088 			   sizeof(int) * num_args)) {
7089 		hdd_err("failed to copy data from user buffer");
7090 		return -EFAULT;
7091 	}
7092 
7093 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
7094 	if (errno)
7095 		return errno;
7096 
7097 	errno = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
7098 					  (char *)&apps_args);
7099 
7100 	osif_vdev_sync_op_stop(vdev_sync);
7101 
7102 	return errno;
7103 }
7104 
7105 /**
7106  * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
7107  * @dev: device upon which the ioctl was received
7108  * @info: ioctl request information
7109  * @wrqu: ioctl request data
7110  * @extra: ioctl extra data
7111  *
7112  * This is a generic handler for private ioctls which take multiple
7113  * arguments.  Note that this implementation is also somewhat unique
7114  * in that it is shared by both STA-mode and SAP-mode interfaces.
7115  *
7116  * Return: 0 on success, non-zero on error
7117  */
iw_set_var_ints_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7118 int iw_set_var_ints_getnone(struct net_device *dev,
7119 			    struct iw_request_info *info,
7120 			    union iwreq_data *wrqu, char *extra)
7121 {
7122 	int errno;
7123 	struct osif_vdev_sync *vdev_sync;
7124 
7125 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
7126 	if (errno)
7127 		return errno;
7128 
7129 	errno = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
7130 
7131 	osif_vdev_sync_op_stop(vdev_sync);
7132 
7133 	return errno;
7134 }
7135 
7136 /**
7137  * __iw_add_tspec - Add TSpec private ioctl handler
7138  * @dev: device upon which the ioctl was received
7139  * @info: ioctl request information
7140  * @wrqu: ioctl request data
7141  * @extra: ioctl extra data
7142  *
7143  * Return: 0 on success, non-zero on error
7144  */
__iw_add_tspec(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7145 static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
7146 			  union iwreq_data *wrqu, char *extra)
7147 {
7148 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7149 	hdd_wlan_wmm_status_e *wmm_status = (hdd_wlan_wmm_status_e *) extra;
7150 	int params[HDD_WLAN_WMM_PARAM_COUNT];
7151 	struct sme_qos_wmmtspecinfo tspec;
7152 	uint32_t handle;
7153 	struct iw_point s_priv_data;
7154 	struct hdd_context *hdd_ctx;
7155 	int ret;
7156 
7157 	hdd_enter_dev(dev);
7158 
7159 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7160 	ret = wlan_hdd_validate_context(hdd_ctx);
7161 	if (0 != ret)
7162 		return ret;
7163 
7164 	ret = hdd_check_private_wext_control(hdd_ctx, info);
7165 	if (0 != ret)
7166 		return ret;
7167 
7168 	/* make sure the application is sufficiently privileged */
7169 	/* note that the kernel will do this for "set" ioctls, but since */
7170 	/* this ioctl wants to return status to user space it must be */
7171 	/* defined as a "get" ioctl */
7172 	if (!capable(CAP_NET_ADMIN))
7173 		return -EPERM;
7174 
7175 	/* we must be associated in order to add a tspec */
7176 	if (!hdd_cm_is_vdev_associated(adapter->deflink)) {
7177 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7178 		return 0;
7179 	}
7180 	/* since we are defined to be a "get" ioctl, and since the number */
7181 	/* of params exceeds the number of params that wireless extensions */
7182 	/* will pass down in the iwreq_data, we must copy the "set" params. */
7183 	/* We must handle the compat for iwreq_data in 32U/64K environment. */
7184 
7185 	/* helper function to get iwreq_data with compat handling. */
7186 	if (hdd_priv_get_data(&s_priv_data, wrqu)) {
7187 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7188 		return 0;
7189 	}
7190 	/* make sure all params are correctly passed to function */
7191 	if ((!s_priv_data.pointer) ||
7192 	    (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
7193 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7194 		return 0;
7195 	}
7196 	/* from user space ourselves */
7197 	if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
7198 		/* hmmm, can't get them */
7199 		return -EIO;
7200 	}
7201 	/* clear the tspec */
7202 	memset(&tspec, 0, sizeof(tspec));
7203 
7204 	/* validate the handle */
7205 	handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7206 	if (HDD_WMM_HANDLE_IMPLICIT == handle) {
7207 		/* that one is reserved */
7208 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7209 		return 0;
7210 	}
7211 	/* validate the TID */
7212 	if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
7213 		/* out of range */
7214 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7215 		return 0;
7216 	}
7217 	tspec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
7218 
7219 	/* validate the direction */
7220 	switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
7221 	case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
7222 		tspec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
7223 		break;
7224 
7225 	case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
7226 		tspec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
7227 		break;
7228 
7229 	case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
7230 		tspec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
7231 		break;
7232 
7233 	default:
7234 		/* unknown */
7235 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7236 		return 0;
7237 	}
7238 
7239 	tspec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
7240 
7241 	/* validate the user priority */
7242 	if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
7243 		/* out of range */
7244 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7245 		return 0;
7246 	}
7247 	tspec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
7248 	if (0 > tspec.ts_info.up || SME_QOS_WMM_UP_MAX < tspec.ts_info.up) {
7249 		hdd_err("***ts_info.up out of bounds***");
7250 		return 0;
7251 	}
7252 
7253 	hdd_debug("TS_INFO PSB %d UP %d !!!",
7254 		  tspec.ts_info.psb, tspec.ts_info.up);
7255 
7256 	tspec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
7257 	tspec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
7258 	tspec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
7259 	tspec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
7260 	tspec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
7261 	tspec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
7262 	tspec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
7263 	tspec.surplus_bw_allowance =
7264 		params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
7265 	tspec.min_service_interval =
7266 		params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
7267 	tspec.max_service_interval =
7268 		params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
7269 	tspec.suspension_interval =
7270 		params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
7271 	tspec.inactivity_interval =
7272 		params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
7273 
7274 	tspec.ts_info.burst_size_defn =
7275 		params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
7276 
7277 	/* validate the ts info ack policy */
7278 	switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
7279 	case TS_INFO_ACK_POLICY_NORMAL_ACK:
7280 		tspec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
7281 		break;
7282 
7283 	case TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
7284 		tspec.ts_info.ack_policy =
7285 			SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
7286 		break;
7287 
7288 	default:
7289 		/* unknown */
7290 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7291 		return 0;
7292 	}
7293 
7294 	*wmm_status = hdd_wmm_addts(adapter, handle, &tspec);
7295 	hdd_exit();
7296 	return 0;
7297 }
7298 
7299 /**
7300  * iw_add_tspec - Add TSpec private ioctl handler
7301  * @dev: device upon which the ioctl was received
7302  * @info: ioctl request information
7303  * @wrqu: ioctl request data
7304  * @extra: ioctl extra data
7305  *
7306  * Return: 0 on success, non-zero on error
7307  */
iw_add_tspec(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7308 static int iw_add_tspec(struct net_device *dev,
7309 			struct iw_request_info *info,
7310 			union iwreq_data *wrqu, char *extra)
7311 {
7312 	int errno;
7313 	struct osif_vdev_sync *vdev_sync;
7314 
7315 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
7316 	if (errno)
7317 		return errno;
7318 
7319 	errno = __iw_add_tspec(dev, info, wrqu, extra);
7320 
7321 	osif_vdev_sync_op_stop(vdev_sync);
7322 
7323 	return errno;
7324 }
7325 
7326 /**
7327  * __iw_del_tspec - Delete TSpec private ioctl handler
7328  * @dev: device upon which the ioctl was received
7329  * @info: ioctl request information
7330  * @wrqu: ioctl request data
7331  * @extra: ioctl extra data
7332  *
7333  * Return: 0 on success, non-zero on error
7334  */
__iw_del_tspec(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7335 static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
7336 			  union iwreq_data *wrqu, char *extra)
7337 {
7338 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7339 	struct hdd_context *hdd_ctx;
7340 	int *params = (int *)extra;
7341 	hdd_wlan_wmm_status_e *wmm_status = (hdd_wlan_wmm_status_e *) extra;
7342 	uint32_t handle;
7343 	int ret;
7344 
7345 	hdd_enter_dev(dev);
7346 
7347 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7348 	ret = wlan_hdd_validate_context(hdd_ctx);
7349 	if (0 != ret)
7350 		return ret;
7351 
7352 	ret = hdd_check_private_wext_control(hdd_ctx, info);
7353 	if (0 != ret)
7354 		return ret;
7355 
7356 	/* make sure the application is sufficiently privileged */
7357 	/* note that the kernel will do this for "set" ioctls, but since */
7358 	/* this ioctl wants to return status to user space it must be */
7359 	/* defined as a "get" ioctl */
7360 	if (!capable(CAP_NET_ADMIN))
7361 		return -EPERM;
7362 
7363 	/* although we are defined to be a "get" ioctl, the params we require */
7364 	/* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
7365 	/* is no need to copy the params from user space */
7366 
7367 	/* validate the handle */
7368 	handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7369 	if (HDD_WMM_HANDLE_IMPLICIT == handle) {
7370 		/* that one is reserved */
7371 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7372 		return 0;
7373 	}
7374 
7375 	*wmm_status = hdd_wmm_delts(adapter, handle);
7376 	hdd_exit();
7377 	return 0;
7378 }
7379 
7380 /**
7381  * iw_del_tspec - Delete TSpec private ioctl handler
7382  * @dev: device upon which the ioctl was received
7383  * @info: ioctl request information
7384  * @wrqu: ioctl request data
7385  * @extra: ioctl extra data
7386  *
7387  * Return: 0 on success, non-zero on error
7388  */
iw_del_tspec(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7389 static int iw_del_tspec(struct net_device *dev,
7390 			struct iw_request_info *info,
7391 			union iwreq_data *wrqu, char *extra)
7392 {
7393 	int errno;
7394 	struct osif_vdev_sync *vdev_sync;
7395 
7396 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
7397 	if (errno)
7398 		return errno;
7399 
7400 	errno = __iw_del_tspec(dev, info, wrqu, extra);
7401 
7402 	osif_vdev_sync_op_stop(vdev_sync);
7403 
7404 	return errno;
7405 }
7406 
7407 /**
7408  * __iw_get_tspec - Get TSpec private ioctl handler
7409  * @dev: device upon which the ioctl was received
7410  * @info: ioctl request information
7411  * @wrqu: ioctl request data
7412  * @extra: ioctl extra data
7413  *
7414  * Return: 0 on success, non-zero on error
7415  */
__iw_get_tspec(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7416 static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
7417 			  union iwreq_data *wrqu, char *extra)
7418 {
7419 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7420 	struct hdd_context *hdd_ctx;
7421 	int *params = (int *)extra;
7422 	hdd_wlan_wmm_status_e *wmm_status = (hdd_wlan_wmm_status_e *) extra;
7423 	uint32_t handle;
7424 	int ret;
7425 
7426 	hdd_enter_dev(dev);
7427 
7428 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7429 	ret = wlan_hdd_validate_context(hdd_ctx);
7430 	if (0 != ret)
7431 		return ret;
7432 
7433 	ret = hdd_check_private_wext_control(hdd_ctx, info);
7434 	if (0 != ret)
7435 		return ret;
7436 
7437 	/* although we are defined to be a "get" ioctl, the params we require */
7438 	/* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
7439 	/* is no need to copy the params from user space */
7440 
7441 	/* validate the handle */
7442 	handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
7443 	if (HDD_WMM_HANDLE_IMPLICIT == handle) {
7444 		/* that one is reserved */
7445 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
7446 		return 0;
7447 	}
7448 
7449 	*wmm_status = hdd_wmm_checkts(adapter, handle);
7450 	hdd_exit();
7451 	return 0;
7452 }
7453 
7454 /**
7455  * iw_get_tspec - Get TSpec private ioctl handler
7456  * @dev: device upon which the ioctl was received
7457  * @info: ioctl request information
7458  * @wrqu: ioctl request data
7459  * @extra: ioctl extra data
7460  *
7461  * Return: 0 on success, non-zero on error
7462  */
iw_get_tspec(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7463 static int iw_get_tspec(struct net_device *dev,
7464 			struct iw_request_info *info,
7465 			union iwreq_data *wrqu, char *extra)
7466 {
7467 	int errno;
7468 	struct osif_vdev_sync *vdev_sync;
7469 
7470 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
7471 	if (errno)
7472 		return errno;
7473 
7474 	errno = __iw_get_tspec(dev, info, wrqu, extra);
7475 
7476 	osif_vdev_sync_op_stop(vdev_sync);
7477 
7478 	return errno;
7479 }
7480 
7481 /**
7482  * __iw_set_fties - Set FT IEs private ioctl handler
7483  * @dev: device upon which the ioctl was received
7484  * @info: ioctl request information
7485  * @wrqu: ioctl request data
7486  * @extra: ioctl extra data
7487  *
7488  * Each time the supplicant has the auth_request or reassoc request
7489  * IEs ready they are pushed to the driver. The driver will in turn
7490  * use it to send out the auth req and reassoc req for 11r FT Assoc.
7491  *
7492  * Return: 0 on success, non-zero on error
7493  */
__iw_set_fties(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7494 static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
7495 			  union iwreq_data *wrqu, char *extra)
7496 {
7497 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7498 	struct hdd_context *hdd_ctx;
7499 	int ret;
7500 
7501 	hdd_enter_dev(dev);
7502 
7503 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7504 	ret = wlan_hdd_validate_context(hdd_ctx);
7505 	if (0 != ret)
7506 		return ret;
7507 
7508 	ret = hdd_check_private_wext_control(hdd_ctx, info);
7509 	if (0 != ret)
7510 		return ret;
7511 
7512 	if (!wrqu->data.length) {
7513 		hdd_err("called with 0 length IEs");
7514 		return -EINVAL;
7515 	}
7516 	if (!wrqu->data.pointer) {
7517 		hdd_err("called with NULL IE");
7518 		return -EINVAL;
7519 	}
7520 	/* Added for debug on reception of Re-assoc Req. */
7521 	if (!hdd_cm_is_vdev_associated(adapter->deflink)) {
7522 		hdd_debug("Called with Ie of length = %d when not associated",
7523 		       wrqu->data.length);
7524 		hdd_debug("Should be Re-assoc Req IEs");
7525 	}
7526 	hdd_debug("called with Ie of length = %d", wrqu->data.length);
7527 
7528 	/* Pass the received FT IEs to SME */
7529 	ucfg_cm_set_ft_ies(hdd_ctx->pdev, adapter->deflink->vdev_id,
7530 			   extra, wrqu->data.length);
7531 	hdd_exit();
7532 	return 0;
7533 }
7534 
7535 /**
7536  * iw_set_fties - Set FT IEs private ioctl handler
7537  * @dev: device upon which the ioctl was received
7538  * @info: ioctl request information
7539  * @wrqu: ioctl request data
7540  * @extra: ioctl extra data
7541  *
7542  * Each time the supplicant has the auth_request or reassoc request
7543  * IEs ready they are pushed to the driver. The driver will in turn
7544  * use it to send out the auth req and reassoc req for 11r FT Assoc.
7545  *
7546  * Return: 0 on success, non-zero on error
7547  */
iw_set_fties(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7548 static int iw_set_fties(struct net_device *dev,
7549 			struct iw_request_info *info,
7550 			union iwreq_data *wrqu, char *extra)
7551 {
7552 	int errno;
7553 	struct osif_vdev_sync *vdev_sync;
7554 
7555 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
7556 	if (errno)
7557 		return errno;
7558 
7559 	errno = __iw_set_fties(dev, info, wrqu, extra);
7560 
7561 	osif_vdev_sync_op_stop(vdev_sync);
7562 
7563 	return errno;
7564 }
7565 
7566 /**
7567  * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
7568  * @dev: device upon which the ioctl was received
7569  * @info: ioctl request information
7570  * @wrqu: ioctl request data
7571  * @extra: ioctl extra data
7572  *
7573  * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
7574  * time being to provide guidance in migrating to standard APIs.
7575  *
7576  * Return: 0 on success, non-zero on error
7577  */
iw_set_dynamic_mcbc_filter(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7578 static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
7579 				      struct iw_request_info *info,
7580 				      union iwreq_data *wrqu,
7581 				      char *extra)
7582 {
7583 	hdd_err("\n"
7584 		"setMCBCFilter is obsolete. Use the following instead:\n"
7585 		"Configure multicast filtering via the ‘ip’ command.\n"
7586 		"\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
7587 		"\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
7588 		"Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
7589 		"\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
7590 		"\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
7591 	return -EINVAL;
7592 }
7593 
7594 /**
7595  * __iw_set_host_offload - Set host offload ioctl handler
7596  * @dev: device upon which the ioctl was received
7597  * @info: ioctl request information
7598  * @wrqu: ioctl request data
7599  * @extra: ioctl extra data
7600  *
7601  * Return: 0 on success, non-zero on error
7602  */
__iw_set_host_offload(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7603 static int __iw_set_host_offload(struct net_device *dev,
7604 				 struct iw_request_info *info,
7605 				 union iwreq_data *wrqu, char *extra)
7606 {
7607 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7608 	struct host_offload_req *user_request =
7609 					(struct host_offload_req *) extra;
7610 	struct sir_host_offload_req offload_request;
7611 	struct hdd_context *hdd_ctx;
7612 	int ret;
7613 
7614 	hdd_enter_dev(dev);
7615 
7616 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7617 	ret = wlan_hdd_validate_context(hdd_ctx);
7618 	if (0 != ret)
7619 		return ret;
7620 
7621 	ret = hdd_check_private_wext_control(hdd_ctx, info);
7622 	if (0 != ret)
7623 		return ret;
7624 
7625 	if (!hdd_cm_is_vdev_associated(adapter->deflink)) {
7626 		hdd_err("dev is not in CONNECTED state, ignore!!!");
7627 		return -EINVAL;
7628 	}
7629 
7630 	/* Debug display of request components. */
7631 	switch (user_request->offloadType) {
7632 	case WLAN_IPV4_ARP_REPLY_OFFLOAD:
7633 		hdd_debug("Host offload request: ARP reply");
7634 		switch (user_request->enableOrDisable) {
7635 		case WLAN_OFFLOAD_DISABLE:
7636 			hdd_debug("   disable");
7637 			break;
7638 		case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
7639 			hdd_debug("   BC Filtering enable");
7640 			fallthrough;
7641 		case WLAN_OFFLOAD_ENABLE:
7642 			hdd_debug("   ARP offload enable");
7643 			hdd_debug("   IP address: %pI4",
7644 				  user_request->params.hostIpv4Addr);
7645 		}
7646 		break;
7647 
7648 	case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
7649 		hdd_debug("Host offload request: neighbor discovery");
7650 		switch (user_request->enableOrDisable) {
7651 		case WLAN_OFFLOAD_DISABLE:
7652 			hdd_debug("   disable");
7653 			break;
7654 		case WLAN_OFFLOAD_ENABLE:
7655 			hdd_debug("   enable");
7656 			hdd_debug("   IP address: %pI6c",
7657 				  user_request->params.hostIpv6Addr);
7658 		}
7659 	}
7660 
7661 	qdf_mem_zero(&offload_request, sizeof(offload_request));
7662 	offload_request.offloadType = user_request->offloadType;
7663 	offload_request.enableOrDisable = user_request->enableOrDisable;
7664 	qdf_mem_copy(&offload_request.params, &user_request->params,
7665 		     sizeof(user_request->params));
7666 	qdf_mem_copy(&offload_request.bssid, &user_request->bssId.bytes,
7667 		     QDF_MAC_ADDR_SIZE);
7668 
7669 	if (QDF_STATUS_SUCCESS !=
7670 	    sme_set_host_offload(hdd_ctx->mac_handle,
7671 				 adapter->deflink->vdev_id, &offload_request)) {
7672 		hdd_err("Failure to execute host offload request");
7673 		return -EINVAL;
7674 	}
7675 	hdd_exit();
7676 	return 0;
7677 }
7678 
7679 /**
7680  * iw_set_host_offload - Set host offload ioctl handler
7681  * @dev: device upon which the ioctl was received
7682  * @info: ioctl request information
7683  * @wrqu: ioctl request data
7684  * @extra: ioctl extra data
7685  *
7686  * Return: 0 on success, non-zero on error
7687  */
iw_set_host_offload(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7688 static int iw_set_host_offload(struct net_device *dev,
7689 			       struct iw_request_info *info,
7690 			       union iwreq_data *wrqu, char *extra)
7691 {
7692 	int errno;
7693 	struct osif_vdev_sync *vdev_sync;
7694 
7695 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
7696 	if (errno)
7697 		return errno;
7698 
7699 	errno = __iw_set_host_offload(dev, info, wrqu, extra);
7700 
7701 	osif_vdev_sync_op_stop(vdev_sync);
7702 
7703 	return errno;
7704 }
7705 
7706 /**
7707  * __iw_set_keepalive_params - Set keepalive params ioctl handler
7708  * @dev: device upon which the ioctl was received
7709  * @info: ioctl request information
7710  * @wrqu: ioctl request data
7711  * @extra: ioctl extra data
7712  *
7713  * Return: 0 on success, non-zero on error
7714  */
__iw_set_keepalive_params(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7715 static int __iw_set_keepalive_params(struct net_device *dev,
7716 				     struct iw_request_info *info,
7717 				     union iwreq_data *wrqu, char *extra)
7718 {
7719 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7720 	struct keep_alive_req *request = (struct keep_alive_req *)extra;
7721 	struct hdd_context *hdd_ctx;
7722 	int ret;
7723 
7724 	hdd_enter_dev(dev);
7725 
7726 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7727 	ret = wlan_hdd_validate_context(hdd_ctx);
7728 	if (0 != ret)
7729 		return ret;
7730 
7731 	ret = hdd_check_private_wext_control(hdd_ctx, info);
7732 	if (0 != ret)
7733 		return ret;
7734 
7735 	if (wrqu->data.length != sizeof(*request)) {
7736 		hdd_err("Invalid length %d", wrqu->data.length);
7737 		return -EINVAL;
7738 	}
7739 
7740 	if (request->timePeriod > cfg_max(CFG_INFRA_STA_KEEP_ALIVE_PERIOD)) {
7741 		hdd_err("Value of timePeriod %d exceed Max limit %d",
7742 			request->timePeriod,
7743 			cfg_max(CFG_INFRA_STA_KEEP_ALIVE_PERIOD));
7744 		return -EINVAL;
7745 	}
7746 
7747 	/* Debug display of request components. */
7748 	hdd_debug("Set Keep Alive Request : TimePeriod %d size %zu",
7749 		request->timePeriod, sizeof(struct keep_alive_req));
7750 
7751 	switch (request->packetType) {
7752 	case WLAN_KEEP_ALIVE_NULL_PKT:
7753 		hdd_debug("Keep Alive Request: Tx NULL");
7754 		break;
7755 
7756 	case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
7757 		hdd_debug("Keep Alive Request: Tx UnSolicited ARP RSP");
7758 
7759 		hdd_debug("Host IP address: %d.%d.%d.%d",
7760 		       request->hostIpv4Addr[0], request->hostIpv4Addr[1],
7761 		       request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
7762 
7763 		hdd_debug("Dest IP address: %d.%d.%d.%d",
7764 		       request->destIpv4Addr[0], request->destIpv4Addr[1],
7765 		       request->destIpv4Addr[2], request->destIpv4Addr[3]);
7766 
7767 		hdd_debug("Dest MAC address: "QDF_MAC_ADDR_FMT,
7768 		       QDF_MAC_ADDR_REF(request->dest_macaddr.bytes));
7769 		break;
7770 	}
7771 
7772 	hdd_debug("Keep alive period  %d", request->timePeriod);
7773 
7774 	if (QDF_STATUS_SUCCESS !=
7775 	    sme_set_keep_alive(hdd_ctx->mac_handle,
7776 			       adapter->deflink->vdev_id, request)) {
7777 		hdd_err("Failure to execute Keep Alive");
7778 		return -EINVAL;
7779 	}
7780 	hdd_exit();
7781 	return 0;
7782 }
7783 
7784 /**
7785  * iw_set_keepalive_params - Set keepalive params ioctl handler
7786  * @dev: device upon which the ioctl was received
7787  * @info: ioctl request information
7788  * @wrqu: ioctl request data
7789  * @extra: ioctl extra data
7790  *
7791  * Return: 0 on success, non-zero on error
7792  */
iw_set_keepalive_params(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7793 static int iw_set_keepalive_params(struct net_device *dev,
7794 				   struct iw_request_info *info,
7795 				   union iwreq_data *wrqu,
7796 				   char *extra)
7797 {
7798 	int errno;
7799 	struct osif_vdev_sync *vdev_sync;
7800 
7801 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
7802 	if (errno)
7803 		return errno;
7804 
7805 	errno = __iw_set_keepalive_params(dev, info, wrqu, extra);
7806 
7807 	osif_vdev_sync_op_stop(vdev_sync);
7808 
7809 	return errno;
7810 }
7811 
7812 #ifdef WLAN_FEATURE_PACKET_FILTERING
7813 /**
7814  * validate_packet_filter_params_size() - Validate the size of the params rcvd
7815  * @request: Pointer to the struct containing the copied data from user space
7816  * @length: length of the request
7817  *
7818  * Return: False on invalid length, true otherwise
7819  */
validate_packet_filter_params_size(struct pkt_filter_cfg * request,uint16_t length)7820 static bool validate_packet_filter_params_size(struct pkt_filter_cfg *request,
7821 					       uint16_t length)
7822 {
7823 	int max_params_size, rcvd_params_size;
7824 
7825 	max_params_size = HDD_MAX_CMP_PER_PACKET_FILTER *
7826 					sizeof(struct pkt_filter_param_cfg);
7827 
7828 	if (length < sizeof(struct pkt_filter_cfg) - max_params_size) {
7829 		hdd_err("Less than minimum number of arguments needed");
7830 		return false;
7831 	}
7832 
7833 	rcvd_params_size = request->num_params *
7834 					sizeof(struct pkt_filter_param_cfg);
7835 
7836 	if (length != sizeof(struct pkt_filter_cfg) -
7837 					max_params_size + rcvd_params_size) {
7838 		hdd_err("Arguments do not match the number of params provided");
7839 		return false;
7840 	}
7841 
7842 	return true;
7843 }
7844 
7845 /**
7846  * __iw_set_packet_filter_params() - set packet filter parameters in target
7847  * @dev: Pointer to netdev
7848  * @info: Pointer to iw request info
7849  * @wrqu: Pointer to data
7850  * @extra: Pointer to extra data
7851  *
7852  * Return: 0 on success, non-zero on error
7853  */
__iw_set_packet_filter_params(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7854 static int __iw_set_packet_filter_params(struct net_device *dev,
7855 				       struct iw_request_info *info,
7856 				       union iwreq_data *wrqu, char *extra)
7857 {
7858 	int ret;
7859 	struct hdd_context *hdd_ctx;
7860 	struct iw_point priv_data;
7861 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7862 	struct pkt_filter_cfg *request = NULL;
7863 
7864 	if (!capable(CAP_NET_ADMIN)) {
7865 		hdd_err("permission check failed");
7866 		return -EPERM;
7867 	}
7868 
7869 	hdd_enter_dev(dev);
7870 
7871 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7872 	ret = wlan_hdd_validate_context(hdd_ctx);
7873 	if (0 != ret)
7874 		return ret;
7875 
7876 	ret = hdd_check_private_wext_control(hdd_ctx, info);
7877 	if (0 != ret)
7878 		return ret;
7879 
7880 	if (hdd_priv_get_data(&priv_data, wrqu)) {
7881 		hdd_err("failed to get priv data");
7882 		return -EINVAL;
7883 	}
7884 
7885 	if ((!priv_data.pointer) || (0 == priv_data.length)) {
7886 		hdd_err("invalid priv data %pK or invalid priv data length %d",
7887 			priv_data.pointer, priv_data.length);
7888 		return -EINVAL;
7889 	}
7890 
7891 	if (adapter->device_mode != QDF_STA_MODE) {
7892 		hdd_err("Packet filter not supported for this mode :%d",
7893 			adapter->device_mode);
7894 		return -ENOTSUPP;
7895 	}
7896 
7897 	if (!hdd_cm_is_vdev_associated(adapter->deflink)) {
7898 		hdd_err("Packet filter not supported in disconnected state");
7899 		return -ENOTSUPP;
7900 	}
7901 
7902 	/* copy data using copy_from_user */
7903 	request = mem_alloc_copy_from_user_helper(priv_data.pointer,
7904 						   priv_data.length);
7905 
7906 	if (!request) {
7907 		hdd_err("mem_alloc_copy_from_user_helper fail");
7908 		return -ENOMEM;
7909 	}
7910 
7911 	if (!validate_packet_filter_params_size(request, priv_data.length)) {
7912 		hdd_err("Invalid priv data length %d", priv_data.length);
7913 		qdf_mem_free(request);
7914 		return -EINVAL;
7915 	}
7916 
7917 	if (request->filter_action == HDD_RCV_FILTER_SET)
7918 		hdd_ctx->user_configured_pkt_filter_rules |=
7919 					1 << request->filter_id;
7920 	else if (request->filter_action == HDD_RCV_FILTER_CLEAR)
7921 		hdd_ctx->user_configured_pkt_filter_rules &=
7922 					~(1 << request->filter_id);
7923 
7924 	ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->deflink->vdev_id);
7925 
7926 	qdf_mem_free(request);
7927 	hdd_exit();
7928 	return ret;
7929 }
7930 
7931 /**
7932  * iw_set_packet_filter_params() - set packet filter parameters in target
7933  * @dev: Pointer to netdev
7934  * @info: Pointer to iw request info
7935  * @wrqu: Pointer to data
7936  * @extra: Pointer to extra data
7937  *
7938  * Return: 0 on success, non-zero on error
7939  */
iw_set_packet_filter_params(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7940 static int iw_set_packet_filter_params(struct net_device *dev,
7941 				       struct iw_request_info *info,
7942 				       union iwreq_data *wrqu, char *extra)
7943 {
7944 	int errno;
7945 	struct osif_vdev_sync *vdev_sync;
7946 
7947 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
7948 	if (errno)
7949 		return errno;
7950 
7951 	errno = __iw_set_packet_filter_params(dev, info, wrqu, extra);
7952 
7953 	osif_vdev_sync_op_stop(vdev_sync);
7954 
7955 	return errno;
7956 }
7957 #endif
7958 
hdd_get_wlan_stats(struct hdd_adapter * adapter)7959 static int hdd_get_wlan_stats(struct hdd_adapter *adapter)
7960 {
7961 	int stats = wlan_hdd_get_station_stats(adapter->deflink);
7962 
7963 	wlan_hdd_get_peer_rx_rate_stats(adapter->deflink);
7964 
7965 	return stats;
7966 }
7967 
__iw_get_statistics(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)7968 static int __iw_get_statistics(struct net_device *dev,
7969 			       struct iw_request_info *info,
7970 			       union iwreq_data *wrqu, char *extra)
7971 {
7972 	int ret;
7973 	char *p;
7974 	int tlen;
7975 	struct hdd_station_ctx *sta_ctx;
7976 	tCsrSummaryStatsInfo *summary_stats;
7977 	tCsrGlobalClassAStatsInfo *class_a_stats;
7978 	tCsrGlobalClassDStatsInfo *class_d_stats;
7979 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7980 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
7981 
7982 	hdd_enter_dev(dev);
7983 
7984 	ret = wlan_hdd_validate_context(hdd_ctx);
7985 	if (0 != ret)
7986 		return ret;
7987 
7988 	ret = hdd_check_private_wext_control(hdd_ctx, info);
7989 	if (0 != ret)
7990 		return ret;
7991 
7992 	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
7993 	if (!hdd_cm_is_vdev_associated(adapter->deflink)) {
7994 		wrqu->data.length = 0;
7995 		return 0;
7996 	}
7997 
7998 	hdd_get_wlan_stats(adapter);
7999 
8000 	summary_stats = &adapter->deflink->hdd_stats.summary_stat;
8001 	class_a_stats = &adapter->deflink->hdd_stats.class_a_stat;
8002 	class_d_stats = &adapter->deflink->hdd_stats.class_d_stat;
8003 
8004 	p = extra;
8005 	tlen = 0;
8006 
8007 	FILL_TLV(p, WLAN_STATS_RETRY_CNT,
8008 		 sizeof(summary_stats->retry_cnt),
8009 		 &(summary_stats->retry_cnt[0]), tlen);
8010 
8011 	FILL_TLV(p, WLAN_STATS_MUL_RETRY_CNT,
8012 		 sizeof(summary_stats->multiple_retry_cnt),
8013 		 &(summary_stats->multiple_retry_cnt[0]), tlen);
8014 
8015 	FILL_TLV(p, WLAN_STATS_TX_FRM_CNT,
8016 		 sizeof(summary_stats->tx_frm_cnt),
8017 		 &(summary_stats->tx_frm_cnt[0]), tlen);
8018 
8019 	FILL_TLV(p, WLAN_STATS_RX_FRM_CNT,
8020 		 sizeof(summary_stats->rx_frm_cnt),
8021 		 &(summary_stats->rx_frm_cnt), tlen);
8022 
8023 	FILL_TLV(p, WLAN_STATS_FRM_DUP_CNT,
8024 		 sizeof(summary_stats->frm_dup_cnt),
8025 		 &(summary_stats->frm_dup_cnt), tlen);
8026 
8027 	FILL_TLV(p, WLAN_STATS_FAIL_CNT,
8028 		 sizeof(summary_stats->fail_cnt),
8029 		 &(summary_stats->fail_cnt[0]), tlen);
8030 
8031 	FILL_TLV(p, WLAN_STATS_RTS_FAIL_CNT,
8032 		 sizeof(summary_stats->rts_fail_cnt),
8033 		 &(summary_stats->rts_fail_cnt), tlen);
8034 
8035 	FILL_TLV(p, WLAN_STATS_ACK_FAIL_CNT,
8036 		 sizeof(summary_stats->ack_fail_cnt),
8037 		 &(summary_stats->ack_fail_cnt), tlen);
8038 
8039 	FILL_TLV(p, WLAN_STATS_RTS_SUC_CNT,
8040 		 sizeof(summary_stats->rts_succ_cnt),
8041 		 &(summary_stats->rts_succ_cnt), tlen);
8042 
8043 	FILL_TLV(p, WLAN_STATS_RX_DISCARD_CNT,
8044 		 sizeof(summary_stats->rx_discard_cnt),
8045 		 &(summary_stats->rx_discard_cnt), tlen);
8046 
8047 	FILL_TLV(p, WLAN_STATS_RX_ERROR_CNT,
8048 		 sizeof(summary_stats->rx_error_cnt),
8049 		 &(summary_stats->rx_error_cnt), tlen);
8050 
8051 	FILL_TLV(p, WLAN_STATS_TX_BYTE_CNT,
8052 		 sizeof(class_d_stats->tx_uc_byte_cnt[0]),
8053 		 &(class_d_stats->tx_uc_byte_cnt[0]), tlen);
8054 
8055 	FILL_TLV(p, WLAN_STATS_RX_BYTE_CNT,
8056 		 sizeof(class_d_stats->rx_byte_cnt),
8057 		 &(class_d_stats->rx_byte_cnt), tlen);
8058 
8059 	FILL_TLV(p, WLAN_STATS_RX_RATE,
8060 		 sizeof(class_d_stats->rx_rate),
8061 		 &(class_d_stats->rx_rate), tlen);
8062 
8063 	/* Transmit rate, in units of 500 kbit/sec */
8064 	FILL_TLV(p, WLAN_STATS_TX_RATE,
8065 		 sizeof(class_a_stats->tx_rate),
8066 		 &(class_a_stats->tx_rate), tlen);
8067 
8068 	FILL_TLV(p, WLAN_STATS_RX_UC_BYTE_CNT,
8069 		 sizeof(class_d_stats->rx_uc_byte_cnt[0]),
8070 		 &(class_d_stats->rx_uc_byte_cnt[0]), tlen);
8071 	FILL_TLV(p, WLAN_STATS_RX_MC_BYTE_CNT,
8072 		 sizeof(class_d_stats->rx_mc_byte_cnt),
8073 		 &(class_d_stats->rx_mc_byte_cnt), tlen);
8074 	FILL_TLV(p, WLAN_STATS_RX_BC_BYTE_CNT,
8075 		 sizeof(class_d_stats->rx_bc_byte_cnt),
8076 		 &(class_d_stats->rx_bc_byte_cnt), tlen);
8077 	FILL_TLV(p, WLAN_STATS_TX_UC_BYTE_CNT,
8078 		 sizeof(class_d_stats->tx_uc_byte_cnt[0]),
8079 		 &(class_d_stats->tx_uc_byte_cnt[0]), tlen);
8080 	FILL_TLV(p, WLAN_STATS_TX_MC_BYTE_CNT,
8081 		 sizeof(class_d_stats->tx_mc_byte_cnt),
8082 		 &(class_d_stats->tx_mc_byte_cnt), tlen);
8083 	FILL_TLV(p, WLAN_STATS_TX_BC_BYTE_CNT,
8084 		 sizeof(class_d_stats->tx_bc_byte_cnt),
8085 		 &(class_d_stats->tx_bc_byte_cnt), tlen);
8086 
8087 	wrqu->data.length = tlen;
8088 
8089 	hdd_exit();
8090 
8091 	return 0;
8092 }
8093 
iw_get_statistics(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)8094 static int iw_get_statistics(struct net_device *dev,
8095 			     struct iw_request_info *info,
8096 			     union iwreq_data *wrqu, char *extra)
8097 {
8098 	int errno;
8099 	struct osif_vdev_sync *vdev_sync;
8100 
8101 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
8102 	if (errno)
8103 		return errno;
8104 
8105 	errno = wlan_hdd_qmi_get_sync_resume();
8106 	if (errno) {
8107 		hdd_err("qmi sync resume failed: %d", errno);
8108 		goto end;
8109 	}
8110 
8111 	errno = __iw_get_statistics(dev, info, wrqu, extra);
8112 
8113 	wlan_hdd_qmi_put_suspend();
8114 
8115 end:
8116 	osif_vdev_sync_op_stop(vdev_sync);
8117 
8118 	return errno;
8119 }
8120 
8121 #ifdef FEATURE_WLAN_SCAN_PNO
8122 /*Max Len for PNO notification*/
8123 #define MAX_PNO_NOTIFY_LEN 100
found_pref_network_cb(struct wlan_objmgr_vdev * vdev,struct scan_event * event,void * args)8124 static void found_pref_network_cb(struct wlan_objmgr_vdev *vdev,
8125 	struct scan_event *event, void *args)
8126 {
8127 	struct vdev_osif_priv *osif_priv;
8128 	struct wireless_dev *wdev;
8129 	union iwreq_data wrqu;
8130 	char buf[MAX_PNO_NOTIFY_LEN + 1];
8131 
8132 	wlan_vdev_obj_lock(vdev);
8133 	osif_priv = wlan_vdev_get_ospriv(vdev);
8134 	wlan_vdev_obj_unlock(vdev);
8135 	if (!osif_priv) {
8136 		hdd_err("osif_priv is null");
8137 		return;
8138 	}
8139 
8140 	wdev = osif_priv->wdev;
8141 	if (!wdev) {
8142 		hdd_err("wdev is null");
8143 		return;
8144 	}
8145 
8146 	hdd_debug("A preferred network was found");
8147 
8148 	/* create the event */
8149 	qdf_mem_zero(&wrqu, sizeof(wrqu));
8150 	qdf_mem_zero(buf, sizeof(buf));
8151 
8152 	snprintf(buf, MAX_PNO_NOTIFY_LEN,
8153 		 "QCOM: Found preferred network:");
8154 
8155 	wrqu.data.pointer = buf;
8156 	wrqu.data.length = strlen(buf);
8157 
8158 	/* send the event */
8159 
8160 	hdd_wext_send_event(wdev->netdev, IWEVCUSTOM, &wrqu, buf);
8161 }
8162 
8163 /**
8164  * __iw_set_pno() - Preferred Network Offload ioctl handler
8165  * @dev: device upon which the ioctl was received
8166  * @info: ioctl request information
8167  * @wrqu: ioctl request data
8168  * @extra: ioctl extra data
8169  *
8170  * This function parses a Preferred Network Offload command
8171  * Input is string based and expected to be of the form:
8172  *
8173  * <enable(1) | disable(0)>
8174  * when enabling:
8175  * <number of networks>
8176  * for each network:
8177  *    <ssid_len> <ssid> <authentication> <encryption>
8178  *    <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
8179  * <scan_time (seconds)>
8180  * <scan_repeat_count (0 means indefinite)>
8181  * <suspend mode>
8182  *
8183  * e.g:
8184  * 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
8185  *
8186  * this translates into:
8187  * -----------------------------
8188  * enable PNO
8189  * 2 networks
8190  * Network 1:
8191  *   test - with authentication type 0 and encryption type 0,
8192  *   search on 3 channels: 1 6 and 11,
8193  *   SSID bcast type is unknown (directed probe will be sent if
8194  *   AP not found) and must meet -40dBm RSSI
8195  * Network 2:
8196  *   test2 - with authentication type 4 and encryption type 4,
8197  *   search on 6 channels 1, 2, 3, 4, 5 and 6
8198  *   bcast type is non-bcast (directed probe will be sent)
8199  *   and must not meet any RSSI threshold
8200  *   scan every 5 seconds 2 times
8201  *   enable on suspend
8202  */
__iw_set_pno(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)8203 static int __iw_set_pno(struct net_device *dev,
8204 			struct iw_request_info *info,
8205 			union iwreq_data *wrqu, char *extra)
8206 {
8207 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8208 	struct hdd_context *hdd_ctx;
8209 	uint8_t value;
8210 	struct wlan_objmgr_vdev *vdev;
8211 	struct wlan_objmgr_psoc *psoc;
8212 	int ret = 0;
8213 	int offset;
8214 	char *ptr, *data;
8215 	uint8_t i, j, params;
8216 	QDF_STATUS status;
8217 	size_t len;
8218 
8219 	/* request is a large struct, so we make it static to avoid
8220 	 * stack overflow.  This API is only invoked via ioctl, so it
8221 	 * is serialized by the kernel rtnl_lock and hence does not
8222 	 * need to be reentrant
8223 	 */
8224 	static struct pno_scan_req_params req;
8225 
8226 	hdd_enter_dev(dev);
8227 
8228 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8229 	ret = wlan_hdd_validate_context(hdd_ctx);
8230 	if (ret)
8231 		return ret;
8232 
8233 	ret = hdd_check_private_wext_control(hdd_ctx, info);
8234 	if (0 != ret)
8235 		return ret;
8236 
8237 	vdev = wlan_objmgr_get_vdev_by_macaddr_from_pdev(hdd_ctx->pdev,
8238 							 dev->dev_addr,
8239 							 WLAN_OSIF_SCAN_ID);
8240 	if (!vdev) {
8241 		hdd_err("vdev object is NULL");
8242 		return -EIO;
8243 	}
8244 
8245 	/* making sure argument string ends with '\0' */
8246 	len = (wrqu->data.length + 1);
8247 	data = qdf_mem_malloc(len);
8248 	if (!data) {
8249 		ret = -EINVAL;
8250 		goto exit;
8251 	}
8252 
8253 	qdf_mem_copy(data, extra, (len-1));
8254 	ptr = data;
8255 
8256 	hdd_debug("PNO data len %d data %s", wrqu->data.length, data);
8257 
8258 	if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
8259 		hdd_err("PNO enable input is not valid %s", ptr);
8260 		ret = -EINVAL;
8261 		goto exit;
8262 	}
8263 
8264 	if (!value) {
8265 		status = ucfg_scan_pno_stop(vdev);
8266 		if (QDF_IS_STATUS_ERROR(status)) {
8267 			hdd_err("Failed to disabled PNO");
8268 			ret = -EINVAL;
8269 		} else {
8270 			hdd_debug("PNO scan disabled");
8271 		}
8272 		goto exit;
8273 	}
8274 
8275 	if (ucfg_scan_get_pno_in_progress(vdev)) {
8276 		hdd_debug("pno is already in progress");
8277 		ret = -EBUSY;
8278 		goto exit;
8279 	}
8280 
8281 	ptr += offset;
8282 
8283 	if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
8284 		hdd_err("PNO count input not valid %s", ptr);
8285 		ret = -EINVAL;
8286 		goto exit;
8287 	}
8288 	req.networks_cnt = value;
8289 
8290 	hdd_debug("PNO enable networks count %d offset %d",
8291 		 req.networks_cnt, offset);
8292 
8293 	if ((0 == req.networks_cnt) ||
8294 	    (req.networks_cnt > SCAN_PNO_MAX_SUPP_NETWORKS)) {
8295 		hdd_err("Network count %d invalid",
8296 			req.networks_cnt);
8297 		ret = -EINVAL;
8298 		goto exit;
8299 	}
8300 
8301 	ptr += offset;
8302 
8303 	for (i = 0; i < req.networks_cnt; i++) {
8304 
8305 		req.networks_list[i].ssid.length = 0;
8306 
8307 		params = sscanf(ptr, " %hhu %n",
8308 				  &(req.networks_list[i].ssid.length),
8309 				  &offset);
8310 
8311 		if (1 != params) {
8312 			hdd_err("PNO ssid length input is not valid %s", ptr);
8313 			ret = -EINVAL;
8314 			goto exit;
8315 		}
8316 
8317 		if ((0 == req.networks_list[i].ssid.length) ||
8318 		    (req.networks_list[i].ssid.length > 32)) {
8319 			hdd_err("SSID Len %d is not correct for network %d",
8320 				  req.networks_list[i].ssid.length, i);
8321 			ret = -EINVAL;
8322 			goto exit;
8323 		}
8324 
8325 		/* Advance to SSID */
8326 		ptr += offset;
8327 
8328 		memcpy(req.networks_list[i].ssid.ssid, ptr,
8329 		       req.networks_list[i].ssid.length);
8330 		ptr += req.networks_list[i].ssid.length;
8331 
8332 		params = sscanf(ptr, " %u %u %hhu %n",
8333 				&(req.networks_list[i].authentication),
8334 				&(req.networks_list[i].encryption),
8335 				&(req.networks_list[i].pno_chan_list.num_chan),
8336 				&offset);
8337 
8338 		if (3 != params) {
8339 			hdd_err("Incorrect cmd %s", ptr);
8340 			ret = -EINVAL;
8341 			goto exit;
8342 		}
8343 
8344 		hdd_debug("PNO ssid " QDF_SSID_FMT " auth %d encry %d channel count %d offset %d",
8345 			  QDF_SSID_REF(req.networks_list[i].ssid.length,
8346 				       req.networks_list[i].ssid.ssid),
8347 			  req.networks_list[i].authentication,
8348 			  req.networks_list[i].encryption,
8349 			  req.networks_list[i].pno_chan_list.num_chan, offset);
8350 
8351 		/* Advance to channel list */
8352 		ptr += offset;
8353 
8354 		if (SCAN_PNO_MAX_NETW_CHANNELS_EX <
8355 		    req.networks_list[i].pno_chan_list.num_chan) {
8356 			hdd_err("Incorrect number of channels");
8357 			ret = -EINVAL;
8358 			goto exit;
8359 		}
8360 
8361 		if (0 != req.networks_list[i].pno_chan_list.num_chan) {
8362 			for (j = 0;
8363 			     j < req.networks_list[i].pno_chan_list.num_chan;
8364 			     j++) {
8365 				if (1 != sscanf(ptr, " %hhu %n", &value,
8366 				   &offset)) {
8367 					hdd_err("PNO network channel is not valid %s",
8368 						  ptr);
8369 					ret = -EINVAL;
8370 					goto exit;
8371 				}
8372 				if (!IS_CHANNEL_VALID(value)) {
8373 					hdd_err("invalid channel: %hhu", value);
8374 					ret = -EINVAL;
8375 					goto exit;
8376 				}
8377 				req.networks_list[i].pno_chan_list.chan[j].freq =
8378 					cds_chan_to_freq(value);
8379 				/* Advance to next channel number */
8380 				ptr += offset;
8381 			}
8382 		}
8383 
8384 		if (1 != sscanf(ptr, " %u %n",
8385 				&(req.networks_list[i].bc_new_type),
8386 				&offset)) {
8387 			hdd_err("PNO broadcast network type is not valid %s",
8388 				  ptr);
8389 			ret = -EINVAL;
8390 			goto exit;
8391 		}
8392 		if (req.networks_list[i].bc_new_type > 2) {
8393 			hdd_err("invalid bcast nw type: %u",
8394 				req.networks_list[i].bc_new_type);
8395 			ret = -EINVAL;
8396 			goto exit;
8397 		}
8398 
8399 		hdd_debug("PNO bcastNetwType %d offset %d",
8400 			  req.networks_list[i].bc_new_type, offset);
8401 
8402 		/* Advance to rssi Threshold */
8403 		ptr += offset;
8404 		if (1 != sscanf(ptr, " %d %n",
8405 				&(req.networks_list[i].rssi_thresh),
8406 				&offset)) {
8407 			hdd_err("PNO rssi threshold input is not valid %s",
8408 				  ptr);
8409 			ret = -EINVAL;
8410 			goto exit;
8411 		}
8412 		hdd_debug("PNO rssi %d offset %d",
8413 			  req.networks_list[i].rssi_thresh, offset);
8414 		/* Advance to next network */
8415 		ptr += offset;
8416 	} /* For ucNetworkCount */
8417 
8418 	req.fast_scan_period = 0;
8419 	if (sscanf(ptr, " %u %n", &(req.fast_scan_period), &offset) > 0) {
8420 		req.fast_scan_period *= MSEC_PER_SEC;
8421 		ptr += offset;
8422 	}
8423 	if (req.fast_scan_period == 0) {
8424 		hdd_err("invalid fast scan period %u",
8425 			req.fast_scan_period);
8426 			ret = -EINVAL;
8427 			goto exit;
8428 	}
8429 
8430 	req.fast_scan_max_cycles = 0;
8431 	if (sscanf(ptr, " %hhu %n", &value,
8432 		   &offset) > 0)
8433 		ptr += offset;
8434 	req.fast_scan_max_cycles = value;
8435 
8436 	wlan_pdev_obj_lock(hdd_ctx->pdev);
8437 	psoc = wlan_pdev_get_psoc(hdd_ctx->pdev);
8438 	wlan_pdev_obj_unlock(hdd_ctx->pdev);
8439 	ucfg_scan_register_pno_cb(psoc,
8440 		found_pref_network_cb, NULL);
8441 
8442 	ucfg_scan_get_pno_def_params(vdev, &req);
8443 	status = ucfg_scan_pno_start(vdev, &req);
8444 	if (QDF_IS_STATUS_ERROR(status)) {
8445 		hdd_err("Failed to enable PNO");
8446 		ret = -EINVAL;
8447 	}
8448 
8449 exit:
8450 	wlan_objmgr_vdev_release_ref(vdev, WLAN_OSIF_SCAN_ID);
8451 
8452 	qdf_mem_free(data);
8453 	return ret;
8454 }
8455 
iw_set_pno(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)8456 static int iw_set_pno(struct net_device *dev,
8457 		      struct iw_request_info *info,
8458 		      union iwreq_data *wrqu, char *extra)
8459 {
8460 	int errno;
8461 	struct osif_vdev_sync *vdev_sync;
8462 
8463 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
8464 	if (errno)
8465 		return errno;
8466 
8467 	errno = __iw_set_pno(dev, info, wrqu, extra);
8468 
8469 	osif_vdev_sync_op_stop(vdev_sync);
8470 
8471 	return errno;
8472 }
8473 #endif /* FEATURE_WLAN_SCAN_PNO */
8474 
__iw_set_band_config(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)8475 static int __iw_set_band_config(struct net_device *dev,
8476 				struct iw_request_info *info,
8477 				union iwreq_data *wrqu, char *extra)
8478 {
8479 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8480 	struct hdd_context *hdd_ctx;
8481 	int ret;
8482 	int *value = (int *)extra;
8483 
8484 	hdd_enter_dev(dev);
8485 
8486 	if (!capable(CAP_NET_ADMIN)) {
8487 		hdd_err("permission check failed");
8488 		return -EPERM;
8489 	}
8490 
8491 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8492 	ret = hdd_check_private_wext_control(hdd_ctx, info);
8493 	if (0 != ret)
8494 		return ret;
8495 
8496 	return hdd_reg_set_band(dev, value[0]);
8497 }
8498 
iw_set_band_config(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)8499 static int iw_set_band_config(struct net_device *dev,
8500 			      struct iw_request_info *info,
8501 			      union iwreq_data *wrqu, char *extra)
8502 {
8503 	int errno;
8504 	struct osif_vdev_sync *vdev_sync;
8505 
8506 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
8507 	if (errno)
8508 		return errno;
8509 
8510 	errno = __iw_set_band_config(dev, info, wrqu, extra);
8511 
8512 	osif_vdev_sync_op_stop(vdev_sync);
8513 
8514 	return errno;
8515 }
8516 
8517 
8518 
8519 #ifdef CONFIG_DP_TRACE
hdd_set_dump_dp_trace(uint16_t cmd_type,uint16_t count)8520 void hdd_set_dump_dp_trace(uint16_t cmd_type, uint16_t count)
8521 {
8522 	hdd_debug("WE_DUMP_DP_TRACE_LEVEL: %d %d",
8523 		  cmd_type, count);
8524 	if (cmd_type == DUMP_DP_TRACE)
8525 		qdf_dp_trace_dump_all(count, QDF_TRACE_DEFAULT_PDEV_ID);
8526 	else if (cmd_type == ENABLE_DP_TRACE_LIVE_MODE)
8527 		qdf_dp_trace_enable_live_mode();
8528 	else if (cmd_type == CLEAR_DP_TRACE_BUFFER)
8529 		qdf_dp_trace_clear_buffer();
8530 	else if (cmd_type == DISABLE_DP_TRACE_LIVE_MODE)
8531 		qdf_dp_trace_disable_live_mode();
8532 }
8533 #endif
8534 
__iw_set_two_ints_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)8535 static int __iw_set_two_ints_getnone(struct net_device *dev,
8536 				     struct iw_request_info *info,
8537 				     union iwreq_data *wrqu, char *extra)
8538 {
8539 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8540 	int *value = (int *)extra;
8541 	int sub_cmd = value[0];
8542 	int ret;
8543 	uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN;
8544 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8545 	QDF_STATUS status;
8546 
8547 	hdd_enter_dev(dev);
8548 
8549 	ret = wlan_hdd_validate_context(hdd_ctx);
8550 	if (0 != ret)
8551 		return ret;
8552 
8553 	ret = hdd_check_private_wext_control(hdd_ctx, info);
8554 	if (0 != ret)
8555 		return ret;
8556 
8557 	switch (sub_cmd) {
8558 	case WE_SET_SMPS_PARAM:
8559 		hdd_debug("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
8560 		ret = wma_cli_set_command(adapter->deflink->vdev_id,
8561 					  WMI_STA_SMPS_PARAM_CMDID,
8562 					  value[1] << WMA_SMPS_PARAM_VALUE_S
8563 					      | value[2],
8564 					  VDEV_CMD);
8565 		break;
8566 	case WE_SET_FW_CRASH_INJECT:
8567 		ret = hdd_crash_inject(adapter, value[1], value[2]);
8568 		break;
8569 	case WE_ENABLE_FW_PROFILE:
8570 		hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
8571 		       value[1], value[2]);
8572 		ret = wma_cli_set2_command(
8573 				adapter->deflink->vdev_id,
8574 				WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
8575 				value[1], value[2], DBG_CMD);
8576 		break;
8577 	case WE_SET_FW_PROFILE_HIST_INTVL:
8578 		hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
8579 		       value[1], value[2]);
8580 		ret = wma_cli_set2_command(
8581 					adapter->deflink->vdev_id,
8582 					WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
8583 					value[1], value[2], DBG_CMD);
8584 		break;
8585 	case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
8586 		hdd_debug("Ioctl to set dual fw mode config");
8587 		status =
8588 		ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc,
8589 						     &dual_mac_feature);
8590 		if (status != QDF_STATUS_SUCCESS)
8591 			hdd_err("can't get dual mac feature val, use def");
8592 		if (dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) {
8593 			hdd_err("Dual mac feature is disabled from INI");
8594 			return -EPERM;
8595 		}
8596 		hdd_debug("%d %d", value[1], value[2]);
8597 		policy_mgr_set_dual_mac_fw_mode_config(hdd_ctx->psoc,
8598 			value[1], value[2]);
8599 		break;
8600 	case WE_DUMP_DP_TRACE_LEVEL:
8601 		hdd_set_dump_dp_trace(value[1], value[2]);
8602 		break;
8603 	case WE_SET_MON_MODE_CHAN:
8604 		if (value[1] > 256)
8605 			ret = wlan_hdd_set_mon_chan(adapter, value[1],
8606 						    value[2]);
8607 		else
8608 			ret = wlan_hdd_set_mon_chan(
8609 						adapter,
8610 						wlan_reg_legacy_chan_to_freq(
8611 						hdd_ctx->pdev, value[1]),
8612 						value[2]);
8613 		break;
8614 	case WE_SET_WLAN_SUSPEND:
8615 		ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
8616 						 value[1], value[2]);
8617 		break;
8618 	case WE_SET_WLAN_RESUME:
8619 		ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
8620 		break;
8621 	case WE_LOG_BUFFER: {
8622 		int log_id = value[1];
8623 		uint32_t count = value[2] < 0 ? 0 : value[2];
8624 
8625 		hdd_ioctl_log_buffer(log_id, count, NULL, NULL);
8626 
8627 		break;
8628 	}
8629 	case WE_SET_BA_AGEING_TIMEOUT:
8630 	{
8631 		void *soc = cds_get_context(QDF_MODULE_ID_SOC);
8632 
8633 		if (!soc)
8634 			break;
8635 
8636 		cdp_set_ba_timeout(soc, value[1], value[2]);
8637 		break;
8638 	}
8639 	default:
8640 		hdd_err("Invalid IOCTL command %d", sub_cmd);
8641 		break;
8642 	}
8643 
8644 	return ret;
8645 }
8646 
iw_set_two_ints_getnone(struct net_device * dev,struct iw_request_info * info,union iwreq_data * wrqu,char * extra)8647 static int iw_set_two_ints_getnone(struct net_device *dev,
8648 				   struct iw_request_info *info,
8649 				   union iwreq_data *wrqu, char *extra)
8650 {
8651 	int errno;
8652 	struct osif_vdev_sync *vdev_sync;
8653 
8654 	errno = osif_vdev_sync_op_start(dev, &vdev_sync);
8655 	if (errno)
8656 		return errno;
8657 
8658 	errno = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
8659 
8660 	osif_vdev_sync_op_stop(vdev_sync);
8661 
8662 	return errno;
8663 }
8664 
8665 /* Define the Wireless Extensions to the Linux Network Device structure */
8666 
8667 static const iw_handler we_private[] = {
8668 
8669 	[WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone,
8670 	[WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint,
8671 	[WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone,
8672 	[WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
8673 		iw_set_three_ints_getnone,
8674 	[WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
8675 	[WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone,
8676 	[WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
8677 		iw_hdd_set_var_ints_getnone,
8678 	[WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
8679 							iw_setnone_get_threeint,
8680 #ifdef WLAN_FEATURE_FIPS
8681 	[WLAN_PRIV_FIPS_TEST - SIOCIWFIRSTPRIV] = hdd_fips_test,
8682 #endif
8683 	[WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
8684 	[WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
8685 	[WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
8686 	[WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
8687 	[WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
8688 	[WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
8689 	[WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
8690 		iw_set_keepalive_params,
8691 #ifdef WLAN_FEATURE_PACKET_FILTERING
8692 	[WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
8693 		iw_set_packet_filter_params,
8694 #endif
8695 #ifdef FEATURE_WLAN_SCAN_PNO
8696 	[WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
8697 #endif
8698 	[WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
8699 	[WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
8700 		iw_set_dynamic_mcbc_filter,
8701 	[WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
8702 #ifdef FEATURE_WLM_STATS
8703 	[WLAN_GET_WLM_STATS - SIOCIWFIRSTPRIV] = iw_get_wlm_stats,
8704 #endif
8705 	[WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
8706 		iw_set_two_ints_getnone,
8707 	[WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
8708 		iw_set_dot11p_channel_sched,
8709 };
8710 
8711 /*Maximum command length can be only 15 */
8712 static const struct iw_priv_args we_private_args[] = {
8713 
8714 	/* handlers for main ioctl */
8715 	{WLAN_PRIV_SET_INT_GET_NONE,
8716 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8717 	 0,
8718 	 ""},
8719 
8720 	/* handlers for sub-ioctl */
8721 	{WE_SET_11D_STATE,
8722 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8723 	 0,
8724 	 "set11Dstate"},
8725 
8726 	{WE_WOWL,
8727 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8728 	 0,
8729 	 "wowl"},
8730 
8731 	{WE_SET_POWER,
8732 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8733 	 0,
8734 	 "setPower"},
8735 
8736 	{WE_SET_MAX_ASSOC,
8737 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8738 	 0,
8739 	 "setMaxAssoc"},
8740 
8741 	{WE_SET_SCAN_DISABLE,
8742 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8743 	 0,
8744 	 "scan_disable"},
8745 
8746 	{WE_SET_DATA_INACTIVITY_TO,
8747 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8748 	 0,
8749 	 "inactivityTO"},
8750 
8751 	{WE_SET_WOW_DATA_INACTIVITY_TO,
8752 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8753 	 0,
8754 	 "wow_ito"},
8755 
8756 	{WE_SET_MAX_TX_POWER,
8757 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8758 	 0,
8759 	 "setMaxTxPower"},
8760 
8761 	{WE_SET_TX_POWER,
8762 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8763 	 0,
8764 	 "setTxPower"},
8765 
8766 	{WE_SET_MC_RATE,
8767 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8768 	 0,
8769 	 "setMcRate"},
8770 
8771 	{WE_SET_MAX_TX_POWER_2_4,
8772 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8773 	 0,
8774 	 "setTxMaxPower2G"},
8775 
8776 	{WE_SET_MAX_TX_POWER_5_0,
8777 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8778 	 0,
8779 	 "setTxMaxPower5G"},
8780 
8781 #ifndef REMOVE_PKT_LOG
8782 	{WE_SET_PKTLOG,
8783 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
8784 	 0,
8785 	 "pktlog"},
8786 #endif
8787 
8788 	/* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
8789 	 * as well to keep same syntax as in SAP. Now onwards, STA
8790 	 * will support both
8791 	 */
8792 	{WE_SET_MAX_TX_POWER,
8793 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8794 	 0,
8795 	 "setTxMaxPower"},
8796 
8797 #ifdef HASTINGS_BT_WAR
8798 	{WE_SET_HASTINGS_BT_WAR,
8799 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8800 	 0,
8801 	 "hastings_bt_war"},
8802 #endif
8803 
8804 	{WE_SET_TM_LEVEL,
8805 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8806 	 0,
8807 	 "setTmLevel"},
8808 
8809 	{WE_SET_PHYMODE,
8810 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8811 	 0,
8812 	 "setphymode"},
8813 
8814 	{WE_SET_NSS,
8815 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8816 	 0,
8817 	 "nss"},
8818 
8819 	{WE_SET_LDPC,
8820 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8821 	 0,
8822 	 "ldpc"},
8823 
8824 	{WE_SET_TX_STBC,
8825 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8826 	 0,
8827 	 "tx_stbc"},
8828 
8829 	{WE_SET_RX_STBC,
8830 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8831 	 0,
8832 	 "rx_stbc"},
8833 
8834 	{WE_SET_SHORT_GI,
8835 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8836 	 0,
8837 	 "shortgi"},
8838 
8839 	{WE_SET_RTSCTS,
8840 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8841 	 0,
8842 	 "enablertscts"},
8843 
8844 	{WE_SET_CHWIDTH,
8845 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8846 	 0,
8847 	 "chwidth"},
8848 
8849 	{WE_SET_ANI_EN_DIS,
8850 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8851 	 0,
8852 	 "anienable"},
8853 
8854 	{WE_SET_ANI_POLL_PERIOD,
8855 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8856 	 0,
8857 	 "aniplen"},
8858 
8859 	{WE_SET_ANI_LISTEN_PERIOD,
8860 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8861 	 0,
8862 	 "anilislen"},
8863 
8864 	{WE_SET_ANI_OFDM_LEVEL,
8865 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8866 	 0,
8867 	 "aniofdmlvl"},
8868 
8869 	{WE_SET_ANI_CCK_LEVEL,
8870 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8871 	 0,
8872 	 "aniccklvl"},
8873 
8874 	{WE_SET_DYNAMIC_BW,
8875 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8876 	 0,
8877 	 "cwmenable"},
8878 
8879 	{WE_SET_CTS_CBW,
8880 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8881 	 0,
8882 	 "cts_cbw" },
8883 
8884 	{WE_SET_GTX_HT_MCS,
8885 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8886 	 0,
8887 	 "gtxHTMcs"},
8888 
8889 	{WE_SET_GTX_VHT_MCS,
8890 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8891 	 0,
8892 	 "gtxVHTMcs"},
8893 
8894 	{WE_SET_GTX_USRCFG,
8895 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8896 	 0,
8897 	 "gtxUsrCfg"},
8898 
8899 	{WE_SET_GTX_THRE,
8900 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8901 	 0,
8902 	 "gtxThre"},
8903 
8904 	{WE_SET_GTX_MARGIN,
8905 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8906 	 0,
8907 	 "gtxMargin"},
8908 
8909 	{WE_SET_GTX_STEP,
8910 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8911 	 0,
8912 	 "gtxStep"},
8913 
8914 	{WE_SET_GTX_MINTPC,
8915 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8916 	 0,
8917 	 "gtxMinTpc"},
8918 
8919 	{WE_SET_GTX_BWMASK,
8920 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8921 	 0,
8922 	 "gtxBWMask"},
8923 
8924 	{WE_SET_TX_CHAINMASK,
8925 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8926 	 0,
8927 	 "txchainmask"},
8928 
8929 	{WE_SET_RX_CHAINMASK,
8930 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8931 	 0,
8932 	 "rxchainmask"},
8933 
8934 	{WE_SET_11N_RATE,
8935 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8936 	 0,
8937 	 "set11NRates"},
8938 
8939 	{WE_SET_VHT_RATE,
8940 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8941 	 0,
8942 	 "set11ACRates"},
8943 
8944 	{WE_SET_AMPDU,
8945 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8946 	 0,
8947 	 "ampdu"},
8948 
8949 	{WE_SET_AMSDU,
8950 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8951 	 0,
8952 	 "amsdu"},
8953 
8954 	{WE_SET_TXPOW_2G,
8955 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8956 	 0,
8957 	 "txpow2g"},
8958 
8959 	{WE_SET_TXPOW_5G,
8960 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8961 	 0,
8962 	 "txpow5g"},
8963 
8964 #ifdef FEATURE_FW_LOG_PARSING
8965 	/* Sub-cmds DBGLOG specific commands */
8966 	{WE_DBGLOG_LOG_LEVEL,
8967 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8968 	 0,
8969 	 "dl_loglevel"},
8970 
8971 	{WE_DBGLOG_VAP_ENABLE,
8972 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8973 	 0,
8974 	 "dl_vapon"},
8975 
8976 	{WE_DBGLOG_VAP_DISABLE,
8977 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8978 	 0,
8979 	 "dl_vapoff"},
8980 
8981 	{WE_DBGLOG_MODULE_ENABLE,
8982 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8983 	 0,
8984 	 "dl_modon"},
8985 
8986 	{WE_DBGLOG_MODULE_DISABLE,
8987 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8988 	 0,
8989 	 "dl_modoff"},
8990 
8991 	{WE_DBGLOG_MOD_LOG_LEVEL,
8992 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8993 	 0,
8994 	 "dl_mod_loglevel"},
8995 
8996 	{WE_DBGLOG_TYPE,
8997 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
8998 	 0,
8999 	 "dl_type"},
9000 
9001 	{WE_DBGLOG_REPORT_ENABLE,
9002 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9003 	 0,
9004 	 "dl_report"},
9005 #endif /* FEATURE_FW_LOG_PARSING */
9006 
9007 	{WE_SET_TXRX_FWSTATS,
9008 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9009 	 0,
9010 	 "txrx_fw_stats"},
9011 
9012 	{WE_SET_TXRX_STATS,
9013 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9014 	 0,
9015 	 "txrx_stats"},
9016 #ifdef FW_THERMAL_THROTTLE_SUPPORT
9017 	{WE_SET_THERMAL_THROTTLE_CFG,
9018 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9019 	 0,
9020 	 "set_thermal_cfg"},
9021 #endif /* FW_THERMAL_THROTTLE_SUPPORT */
9022 	{WE_SET_BTCOEX_MODE,
9023 	IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9024 	0, "set_btc_mode" },
9025 	{WE_SET_BTCOEX_RSSI_THRESHOLD,
9026 	IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9027 	0, "set_btc_rssi" },
9028 	{WE_TXRX_FWSTATS_RESET,
9029 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9030 	 0,
9031 	 "txrx_fw_st_rst"},
9032 
9033 	{WE_PPS_PAID_MATCH,
9034 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9035 	 0, "paid_match"},
9036 
9037 	{WE_PPS_GID_MATCH,
9038 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9039 	 0, "gid_match"},
9040 
9041 	{WE_PPS_EARLY_TIM_CLEAR,
9042 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9043 	 0, "tim_clear"},
9044 
9045 	{WE_PPS_EARLY_DTIM_CLEAR,
9046 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9047 	 0, "dtim_clear"},
9048 
9049 	{WE_PPS_EOF_PAD_DELIM,
9050 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9051 	 0, "eof_delim"},
9052 
9053 	{WE_PPS_MACADDR_MISMATCH,
9054 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9055 	 0, "mac_match"},
9056 
9057 	{WE_PPS_DELIM_CRC_FAIL,
9058 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9059 	 0, "delim_fail"},
9060 
9061 	{WE_PPS_GID_NSTS_ZERO,
9062 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9063 	 0, "nsts_zero"},
9064 
9065 	{WE_PPS_RSSI_CHECK,
9066 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9067 	 0, "rssi_chk"},
9068 
9069 	{WE_PPS_5G_EBT,
9070 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9071 	 0, "5g_ebt"},
9072 
9073 	{WE_SET_HTSMPS,
9074 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9075 	 0, "htsmps"},
9076 
9077 	{WE_SET_QPOWER_MAX_PSPOLL_COUNT,
9078 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9079 	 0, "set_qpspollcnt"},
9080 
9081 	{WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
9082 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9083 	 0, "set_qtxwake"},
9084 
9085 	{WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
9086 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9087 	 0, "set_qwakeintv"},
9088 
9089 	{WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
9090 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9091 	 0, "set_qnodatapoll"},
9092 
9093 	/* handlers for MCC time quota and latency sub ioctls */
9094 	{WE_MCC_CONFIG_LATENCY,
9095 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9096 	 0, "setMccLatency"},
9097 
9098 	{WE_MCC_CONFIG_QUOTA,
9099 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9100 	 0, "setMccQuota"},
9101 
9102 	{WE_SET_DEBUG_LOG,
9103 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9104 	 0, "setDbgLvl"},
9105 
9106 	/* handlers for early_rx power save */
9107 	{WE_SET_EARLY_RX_ADJUST_ENABLE,
9108 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9109 	 0, "erx_enable"},
9110 
9111 	{WE_SET_EARLY_RX_TGT_BMISS_NUM,
9112 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9113 	 0, "erx_bmiss_val"},
9114 
9115 	{WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
9116 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9117 	 0, "erx_bmiss_smpl"},
9118 
9119 	{WE_SET_EARLY_RX_SLOP_STEP,
9120 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9121 	 0, "erx_slop_step"},
9122 
9123 	{WE_SET_EARLY_RX_INIT_SLOP,
9124 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9125 	 0, "erx_init_slop"},
9126 
9127 	{WE_SET_EARLY_RX_ADJUST_PAUSE,
9128 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9129 	 0, "erx_adj_pause"},
9130 
9131 	{WE_SET_EARLY_RX_DRIFT_SAMPLE,
9132 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9133 	 0, "erx_dri_sample"},
9134 
9135 	{WE_DUMP_STATS,
9136 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9137 	 0, "dumpStats"},
9138 
9139 	{WE_CLEAR_STATS,
9140 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9141 	 0, "clearStats"},
9142 
9143 	{WE_START_FW_PROFILE,
9144 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9145 	 0, "startProfile"},
9146 
9147 	{WE_SET_CHANNEL,
9148 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9149 	 0, "setChanChange" },
9150 
9151 	{WE_SET_CONC_SYSTEM_PREF,
9152 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9153 	 0, "setConcSysPref" },
9154 
9155 	{WE_SET_PDEV_RESET,
9156 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9157 	 0, "pdev_reset" },
9158 
9159 	{WE_SET_MODULATED_DTIM,
9160 	IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9161 	0, "setModDTIM" },
9162 
9163 	{WLAN_PRIV_SET_NONE_GET_INT,
9164 	 0,
9165 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9166 	 ""},
9167 
9168 	/* handlers for sub-ioctl */
9169 	{WE_GET_11D_STATE,
9170 	 0,
9171 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9172 	 "get11Dstate"},
9173 
9174 	{WE_GET_WLAN_DBG,
9175 	 0,
9176 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9177 	 "getwlandbg"},
9178 
9179 	{WE_GET_MAX_ASSOC,
9180 	 0,
9181 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9182 	 "getMaxAssoc"},
9183 
9184 	{WE_GET_SAP_AUTO_CHANNEL_SELECTION,
9185 	 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9186 	 "getAutoChannel"},
9187 
9188 	{WE_GET_CONCURRENCY_MODE,
9189 	 0,
9190 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9191 	 "getconcurrency"},
9192 
9193 	{WE_GET_NSS,
9194 	 0,
9195 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9196 	 "get_nss"},
9197 
9198 	{WE_GET_LDPC,
9199 	 0,
9200 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9201 	 "get_ldpc"},
9202 
9203 	{WE_GET_TX_STBC,
9204 	 0,
9205 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9206 	 "get_tx_stbc"},
9207 
9208 	{WE_GET_RX_STBC,
9209 	 0,
9210 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9211 	 "get_rx_stbc"},
9212 
9213 	{WE_GET_SHORT_GI,
9214 	 0,
9215 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9216 	 "get_shortgi"},
9217 
9218 	{WE_GET_RTSCTS,
9219 	 0,
9220 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9221 	 "get_rtscts"},
9222 
9223 	{WE_GET_CHWIDTH,
9224 	 0,
9225 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9226 	 "get_chwidth"},
9227 
9228 	{WE_GET_ANI_EN_DIS,
9229 	 0,
9230 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9231 	 "get_anienable"},
9232 
9233 	{WE_GET_ANI_POLL_PERIOD,
9234 	 0,
9235 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9236 	 "get_aniplen"},
9237 
9238 	{WE_GET_ANI_LISTEN_PERIOD,
9239 	 0,
9240 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9241 	 "get_anilislen"},
9242 
9243 	{WE_GET_ANI_OFDM_LEVEL,
9244 	 0,
9245 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9246 	 "get_aniofdmlvl"},
9247 
9248 	{WE_GET_ANI_CCK_LEVEL,
9249 	 0,
9250 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9251 	 "get_aniccklvl"},
9252 
9253 	{WE_GET_DYNAMIC_BW,
9254 	 0,
9255 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9256 	 "get_cwmenable"},
9257 
9258 	{WE_GET_GTX_HT_MCS,
9259 	 0,
9260 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9261 	 "get_gtxHTMcs"},
9262 
9263 	{WE_GET_GTX_VHT_MCS,
9264 	 0,
9265 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9266 	 "get_gtxVHTMcs"},
9267 
9268 	{WE_GET_GTX_USRCFG,
9269 	 0,
9270 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9271 	 "get_gtxUsrCfg"},
9272 
9273 	{WE_GET_GTX_THRE,
9274 	 0,
9275 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9276 	 "get_gtxThre"},
9277 
9278 	{WE_GET_GTX_MARGIN,
9279 	 0,
9280 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9281 	 "get_gtxMargin"},
9282 
9283 	{WE_GET_GTX_STEP,
9284 	 0,
9285 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9286 	 "get_gtxStep"},
9287 
9288 	{WE_GET_GTX_MINTPC,
9289 	 0,
9290 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9291 	 "get_gtxMinTpc"},
9292 
9293 	{WE_GET_GTX_BWMASK,
9294 	 0,
9295 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9296 	 "get_gtxBWMask"},
9297 
9298 	{WE_GET_TX_CHAINMASK,
9299 	 0,
9300 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9301 	 "get_txchainmask"},
9302 
9303 	{WE_GET_RX_CHAINMASK,
9304 	 0,
9305 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9306 	 "get_rxchainmask"},
9307 
9308 	{WE_GET_11N_RATE,
9309 	 0,
9310 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9311 	 "get_11nrate"},
9312 
9313 	{WE_GET_AMPDU,
9314 	 0,
9315 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9316 	 "get_ampdu"},
9317 
9318 	{WE_GET_AMSDU,
9319 	 0,
9320 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9321 	 "get_amsdu"},
9322 
9323 	{WE_GET_TXPOW_2G,
9324 	 0,
9325 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9326 	 "get_txpow2g"},
9327 
9328 	{WE_GET_TXPOW_5G,
9329 	 0,
9330 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9331 	 "get_txpow5g"},
9332 
9333 	{WE_GET_PPS_PAID_MATCH,
9334 	 0,
9335 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9336 	 "get_paid_match"},
9337 
9338 	{WE_GET_PPS_GID_MATCH,
9339 	 0,
9340 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9341 	 "get_gid_match"},
9342 
9343 	{WE_GET_PPS_EARLY_TIM_CLEAR,
9344 	 0,
9345 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9346 	 "get_tim_clear"},
9347 
9348 	{WE_GET_PPS_EARLY_DTIM_CLEAR,
9349 	 0,
9350 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9351 	 "get_dtim_clear"},
9352 
9353 	{WE_GET_PPS_EOF_PAD_DELIM,
9354 	 0,
9355 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9356 	 "get_eof_delim"},
9357 
9358 	{WE_GET_PPS_MACADDR_MISMATCH,
9359 	 0,
9360 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9361 	 "get_mac_match"},
9362 
9363 	{WE_GET_PPS_DELIM_CRC_FAIL,
9364 	 0,
9365 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9366 	 "get_delim_fail"},
9367 
9368 	{WE_GET_PPS_GID_NSTS_ZERO,
9369 	 0,
9370 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9371 	 "get_nsts_zero"},
9372 
9373 	{WE_GET_PPS_RSSI_CHECK,
9374 	 0,
9375 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9376 	 "get_rssi_chk"},
9377 
9378 	{WE_GET_QPOWER_MAX_PSPOLL_COUNT,
9379 	 0,
9380 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9381 	 "get_qpspollcnt"},
9382 
9383 	{WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
9384 	 0,
9385 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9386 	 "get_qtxwake"},
9387 
9388 	{WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
9389 	 0,
9390 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9391 	 "get_qwakeintv"},
9392 
9393 	{WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
9394 	 0,
9395 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9396 	 "get_qnodatapoll"},
9397 
9398 	{WE_CAP_TSF,
9399 	 0,
9400 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9401 	 "cap_tsf"},
9402 
9403 	{WE_GET_TEMPERATURE,
9404 	 0,
9405 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9406 	 "get_temp"},
9407 
9408 	{WE_GET_DCM,
9409 	 0,
9410 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9411 	 "get_dcm"},
9412 
9413 	{WE_GET_RANGE_EXT,
9414 	 0,
9415 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9416 	 "get_range_ext"},
9417 
9418 	/* handlers for main ioctl */
9419 	{WLAN_PRIV_SET_CHAR_GET_NONE,
9420 	 IW_PRIV_TYPE_CHAR | 512,
9421 	 0,
9422 	 ""},
9423 
9424 	/* handlers for sub-ioctl */
9425 	{WE_WOWL_ADD_PTRN,
9426 	 IW_PRIV_TYPE_CHAR | 512,
9427 	 0,
9428 	 "wowlAddPtrn"},
9429 
9430 	{WE_WOWL_DEL_PTRN,
9431 	 IW_PRIV_TYPE_CHAR | 512,
9432 	 0,
9433 	 "wowlDelPtrn"},
9434 
9435 	/* handlers for sub-ioctl */
9436 	{WE_NEIGHBOR_REPORT_REQUEST,
9437 	 IW_PRIV_TYPE_CHAR | 512,
9438 	 0,
9439 	 "neighbor"},
9440 
9441 	{WE_SET_AP_WPS_IE,
9442 	 IW_PRIV_TYPE_CHAR | 512,
9443 	 0,
9444 	 "set_ap_wps_ie"},
9445 
9446 #ifdef WLAN_UNIT_TEST
9447 	{WE_UNIT_TEST,
9448 	 IW_PRIV_TYPE_CHAR | 512,
9449 	 0,
9450 	 "unit_test"},
9451 #endif
9452 
9453 	/* handlers for main ioctl */
9454 	{WLAN_PRIV_SET_THREE_INT_GET_NONE,
9455 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9456 	 0,
9457 	 ""},
9458 
9459 	/* handlers for sub-ioctl */
9460 	{WE_SET_WLAN_DBG,
9461 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9462 	 0,
9463 	 "setwlandbg"},
9464 
9465 #ifdef CONFIG_DP_TRACE
9466 	/* handlers for sub-ioctl */
9467 	{WE_SET_DP_TRACE,
9468 	IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9469 	0,
9470 	"set_dp_trace"},
9471 #endif
9472 
9473 	{WE_SET_FW_TEST,
9474 	IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9475 	0, "fw_test"},
9476 
9477 	/* handlers for main ioctl */
9478 	{WLAN_PRIV_SET_NONE_GET_THREE_INT,
9479 	 0,
9480 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9481 	 ""},
9482 
9483 	{WE_GET_TSF,
9484 	 0,
9485 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9486 	 "get_tsf"},
9487 
9488 	{WE_SET_DUAL_MAC_SCAN_CONFIG,
9489 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
9490 	 0,
9491 	 "set_scan_cfg"},
9492 
9493 	/* handlers for main ioctl */
9494 	{WLAN_PRIV_GET_CHAR_SET_NONE,
9495 	 0,
9496 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9497 	 ""},
9498 
9499 	/* handlers for sub-ioctl */
9500 	{WE_WLAN_VERSION,
9501 	 0,
9502 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9503 	 "version"},
9504 
9505 	{WE_GET_STATS,
9506 	 0,
9507 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9508 	 "getStats"},
9509 
9510 	{WE_GET_SUSPEND_RESUME_STATS,
9511 	 0,
9512 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9513 	 "getSuspendStats"},
9514 
9515 	{WE_LIST_FW_PROFILE,
9516 	 0,
9517 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9518 	 "listProfile"},
9519 
9520 	{WE_GET_STATES,
9521 	 0,
9522 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9523 	 "getHostStates"},
9524 
9525 	{WE_GET_CFG,
9526 	 0,
9527 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9528 	 "getConfig"},
9529 
9530 	{WE_GET_RSSI,
9531 	 0,
9532 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9533 	 "getRSSI"},
9534 
9535 	{WE_GET_WMM_STATUS,
9536 	 0,
9537 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9538 	 "getWmmStatus"},
9539 
9540 	{WE_GET_CHANNEL_LIST,
9541 	 0,
9542 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9543 	 "getChannelList"},
9544 #ifdef FEATURE_WLAN_TDLS
9545 	{WE_GET_TDLS_PEERS,
9546 	 0,
9547 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9548 	 "getTdlsPeers"},
9549 #endif
9550 	{WE_GET_11W_INFO,
9551 	 0,
9552 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9553 	 "getPMFInfo"},
9554 
9555 	{WE_GET_STA_CXN_INFO,
9556 	 0,
9557 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9558 	 "get_cxn_info"	},
9559 
9560 	{WE_GET_PHYMODE,
9561 	 0,
9562 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9563 	 "getphymode"},
9564 #if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
9565 	{WE_GET_OEM_DATA_CAP,
9566 	 0,
9567 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9568 	 "getOemDataCap"},
9569 #endif
9570 	{WE_GET_SNR,
9571 	 0,
9572 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9573 	 "getSNR"},
9574 
9575 	{WE_GET_BA_AGEING_TIMEOUT,
9576 	 0,
9577 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9578 	 "get_ba_timeout"},
9579 
9580 	/* handlers for main ioctl */
9581 	{WLAN_PRIV_SET_NONE_GET_NONE,
9582 	 0,
9583 	 0,
9584 	 ""},
9585 
9586 	{WE_GET_FW_PROFILE_DATA,
9587 	 0,
9588 	 0,
9589 	 "getProfileData"},
9590 
9591 	{WE_SET_REASSOC_TRIGGER,
9592 	0,
9593 	0,
9594 	"reassoc"},
9595 
9596 	{WE_STOP_OBSS_SCAN,
9597 	 0,
9598 	 0,
9599 	 "stop_obss_scan"},
9600 	/* handlers for main ioctl */
9601 	{WLAN_PRIV_SET_VAR_INT_GET_NONE,
9602 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9603 	 0,
9604 	 ""},
9605 
9606 #ifdef TRACE_RECORD
9607 	/* handlers for sub-ioctl */
9608 	{WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
9609 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9610 	 0,
9611 	 "setdumplog"},
9612 
9613 	{WE_MTRACE_DUMP_CMD,
9614 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9615 	 0,
9616 	 "dumplog"},
9617 #endif
9618 
9619 	{WE_POLICY_MANAGER_CINFO_CMD,
9620 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9621 	 0,
9622 	 "pm_cinfo"},
9623 
9624 	{WE_UNIT_TEST_CMD,
9625 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9626 	 0,
9627 	 "setUnitTestCmd"},
9628 
9629 	{WE_MAC_PWR_DEBUG_CMD,
9630 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9631 	 0,
9632 	 "halPwrDebug"},
9633 #ifdef WLAN_FEATURE_GPIO_LED_FLASHING
9634 	{WE_LED_FLASHING_PARAM,
9635 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9636 	 0,
9637 	 "gpio_control"},
9638 #endif
9639 #ifdef WLAN_DEBUG
9640 	{WE_SET_CHAN_AVOID,
9641 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9642 	 0,
9643 	 "ch_avoid"},
9644 #endif
9645 	/* handlers for main ioctl */
9646 	{WLAN_PRIV_FIPS_TEST,
9647 	 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
9648 	 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
9649 	 "fips_test"},
9650 
9651 	/* handlers for main ioctl */
9652 	{WLAN_PRIV_ADD_TSPEC,
9653 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
9654 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9655 	 "addTspec"},
9656 
9657 	/* handlers for main ioctl */
9658 	{WLAN_PRIV_DEL_TSPEC,
9659 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9660 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9661 	 "delTspec"},
9662 
9663 	/* handlers for main ioctl */
9664 	{WLAN_PRIV_GET_TSPEC,
9665 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9666 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9667 	 "getTspec"},
9668 
9669 	/* handlers for main ioctl - host offload */
9670 	{WLAN_PRIV_SET_HOST_OFFLOAD,
9671 	 IW_PRIV_TYPE_BYTE | sizeof(struct host_offload_req),
9672 	 0,
9673 	 "setHostOffload"},
9674 
9675 	{WLAN_GET_WLAN_STATISTICS,
9676 	 0,
9677 	 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
9678 	 "getWlanStats"},
9679 
9680 	{WLAN_SET_KEEPALIVE_PARAMS,
9681 	 IW_PRIV_TYPE_BYTE | sizeof(struct keep_alive_req) |
9682 	 IW_PRIV_SIZE_FIXED,
9683 	 0,
9684 	 "setKeepAlive"},
9685 #ifdef WLAN_FEATURE_PACKET_FILTERING
9686 	{WLAN_SET_PACKET_FILTER_PARAMS,
9687 	 IW_PRIV_TYPE_BYTE |
9688 	 sizeof(struct pkt_filter_cfg),
9689 	 0,
9690 	 "setPktFilter"},
9691 #endif
9692 #ifdef FEATURE_WLAN_SCAN_PNO
9693 	{WLAN_SET_PNO,
9694 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9695 	 0,
9696 	 "setpno"},
9697 #endif
9698 	{WLAN_SET_BAND_CONFIG,
9699 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9700 	 0,
9701 	 "SETBAND"},
9702 
9703 	{WLAN_PRIV_SET_MCBC_FILTER,
9704 	 0,
9705 	 0,
9706 	 "setMCBCFilter"},
9707 
9708 	{WLAN_GET_LINK_SPEED,
9709 	 IW_PRIV_TYPE_CHAR | 18,
9710 	 IW_PRIV_TYPE_CHAR | 5,
9711 	 "getLinkSpeed"},
9712 
9713 #ifdef FEATURE_WLM_STATS
9714 	{WLAN_GET_WLM_STATS,
9715 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9716 	 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
9717 	 "get_wlm_stats"},
9718 #endif
9719 
9720 	/* handlers for main ioctl */
9721 	{WLAN_PRIV_SET_TWO_INT_GET_NONE,
9722 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9723 	 0,
9724 	 ""},
9725 
9726 	{WE_SET_SMPS_PARAM,
9727 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9728 	 0, "set_smps_param"},
9729 
9730 	{WLAN_SET_DOT11P_CHANNEL_SCHED,
9731 	 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
9732 	 0, "set_dot11p" },
9733 
9734 #ifdef CONFIG_WLAN_DEBUG_CRASH_INJECT
9735 	{WE_SET_FW_CRASH_INJECT,
9736 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9737 	 0, "crash_inject"},
9738 
9739 #endif
9740 #if defined(WMI_INTERFACE_EVENT_LOGGING) || defined(FEATURE_HTC_CREDIT_HISTORY)
9741 	{WE_LOG_BUFFER,
9742 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9743 	 0, "log_buffer"},
9744 
9745 #endif
9746 	{WE_SET_BA_AGEING_TIMEOUT,
9747 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9748 	 0, "set_ba_timeout"},
9749 
9750 #ifdef WLAN_SUSPEND_RESUME_TEST
9751 	{WE_SET_WLAN_SUSPEND,
9752 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9753 	 0, "wlan_suspend"},
9754 
9755 	{WE_SET_WLAN_RESUME,
9756 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9757 	 0, "wlan_resume"},
9758 #endif
9759 	{WE_ENABLE_FW_PROFILE,
9760 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9761 	 0, "enableProfile"},
9762 
9763 	{WE_SET_FW_PROFILE_HIST_INTVL,
9764 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9765 	 0, "set_hist_intvl"},
9766 
9767 	{WE_SET_DUAL_MAC_FW_MODE_CONFIG,
9768 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9769 	 0, "set_fw_mode_cfg"},
9770 #ifdef CONFIG_DP_TRACE
9771 	{WE_DUMP_DP_TRACE_LEVEL,
9772 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9773 	 0, "dump_dp_trace"},
9774 #endif
9775 #ifdef FEATURE_MONITOR_MODE_SUPPORT
9776 	{WE_SET_MON_MODE_CHAN,
9777 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
9778 	 0, "setMonChan"},
9779 #endif
9780 	{WE_GET_ROAM_SYNCH_DELAY,
9781 	 0,
9782 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9783 	 "hostroamdelay"},
9784 
9785 	{WE_SET_11AX_RATE,
9786 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9787 	 0,
9788 	 "set_11ax_rate"},
9789 
9790 	{WE_SET_DCM,
9791 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9792 	 0,
9793 	 "enable_dcm"},
9794 
9795 	{WE_SET_RANGE_EXT,
9796 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9797 	 0,
9798 	 "range_ext"},
9799 
9800 	{WLAN_PRIV_SET_FTIES,
9801 	 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
9802 	 0,
9803 	 "set_ft_ies"},
9804 
9805 #ifdef WLAN_FEATURE_MOTION_DETECTION
9806 	{WE_MOTION_DET_START_STOP,
9807 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9808 	 0,
9809 	 "mt_start"},
9810 
9811 	{WE_MOTION_DET_BASE_LINE_START_STOP,
9812 	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
9813 	 0,
9814 	 "mt_bl_start"},
9815 
9816 	{WE_MOTION_DET_CONFIG_PARAM,
9817 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9818 	 0,
9819 	 "mt_config"},
9820 
9821 	{WE_MOTION_DET_BASE_LINE_CONFIG_PARAM,
9822 	 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
9823 	 0,
9824 	 "mt_bl_config"},
9825 #endif /* WLAN_FEATURE_MOTION_DETECTION */
9826 };
9827 
9828 const struct iw_handler_def we_handler_def = {
9829 	.num_standard = 0,
9830 	.num_private = QDF_ARRAY_SIZE(we_private),
9831 	.num_private_args = QDF_ARRAY_SIZE(we_private_args),
9832 
9833 	.standard = NULL,
9834 	.private = (iw_handler *) we_private,
9835 	.private_args = we_private_args,
9836 	.get_wireless_stats = NULL,
9837 };
9838 
hdd_register_wext(struct net_device * dev)9839 void hdd_register_wext(struct net_device *dev)
9840 {
9841 	hdd_enter_dev(dev);
9842 
9843 	dev->wireless_handlers = &we_handler_def;
9844 
9845 	hdd_exit();
9846 }
9847 
hdd_wext_unregister(struct net_device * dev,bool rtnl_held)9848 void hdd_wext_unregister(struct net_device *dev,
9849 			 bool rtnl_held)
9850 {
9851 	if (!dev)
9852 		return;
9853 
9854 	if (!rtnl_held)
9855 		rtnl_lock();
9856 	dev->wireless_handlers = NULL;
9857 	if (!rtnl_held)
9858 		rtnl_unlock();
9859 }
9860 
9861