blob: 12cdd454badd24d73fdf510f37c2fcde66091978 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_wext.c
30 *
31 * Linux Wireless Extensions Implementation
32 */
33
34#include <linux/version.h>
35#include <linux/module.h>
36#include <linux/kernel.h>
37#include <linux/init.h>
38#include <linux/wireless.h>
39#include <mac_trace.h>
40#include <wlan_hdd_includes.h>
41#include <cds_api.h>
Rajeev Kumarea95edd2017-01-11 20:49:36 -080042#include "scheduler_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043#include <net/arp.h>
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080044#include <cdp_txrx_cmn.h>
Manjunathappa Prakash3454fd62016-04-01 08:52:06 -070045#include <cdp_txrx_stats.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "sir_params.h"
47#include "csr_api.h"
48#include "csr_inside_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include "sme_rrm_internal.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include <ani_global.h>
51#include "dot11f.h"
52#include <wlan_hdd_wowl.h>
53#include <wlan_hdd_cfg.h>
54#include <wlan_hdd_wmm.h>
55#include "utils_api.h"
56#include "wlan_hdd_p2p.h"
57#ifdef FEATURE_WLAN_TDLS
58#include "wlan_hdd_tdls.h"
59#endif
60
61#include "cds_ieee80211_common.h"
62#include "ol_if_athvar.h"
63#include "dbglog_host.h"
64#include "wma.h"
65
66#include "wlan_hdd_power.h"
67#include "qwlan_version.h"
68#include "wlan_hdd_host_offload.h"
69
70#include <linux/wireless.h>
71#include <net/cfg80211.h>
72
73#include "wlan_hdd_misc.h"
74
75#include "qc_sap_ioctl.h"
76#include "sme_api.h"
77#include "wma_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053078#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079#include "wlan_hdd_assoc.h"
80#include "wlan_hdd_ioctl.h"
81#include "wlan_hdd_scan.h"
82#include "sme_power_save_api.h"
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080083#include "wlan_policy_mgr_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084#include "wlan_hdd_conc_ut.h"
Jeff Johnson6fa1e012017-04-05 06:40:53 -070085#include "wlan_hdd_fips.h"
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070086#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087#include "wlan_hdd_ocb.h"
88#include "wlan_hdd_napi.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080089#include "cdp_txrx_flow_ctrl_legacy.h"
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070090#include "wlan_hdd_nan_datapath.h"
Nirav Shahbf1b0332016-05-25 14:27:39 +053091#include "wlan_hdd_stats.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070092#ifdef WLAN_SUSPEND_RESUME_TEST
93#include "wlan_hdd_driver_ops.h"
94#include "hif.h"
Rajeev Kumar9bb2e852016-09-24 12:29:25 -070095#include "pld_common.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070096#endif
Dhanashri Atree7d442a2016-07-14 18:20:29 -070097#include "wlan_hdd_lro.h"
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053098#include "cds_utils.h"
Jeff Johnsona6ace5b2017-01-23 07:11:02 -080099#include "wlan_hdd_request_manager.h"
Naveen Rawat910726a2017-03-06 11:42:51 -0800100#include "os_if_wifi_pos.h"
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -0800101#include <cdp_txrx_stats.h>
102#include <cds_api.h>
Abhishek Singh0481d662017-04-11 18:20:11 +0530103#include <wlan_osif_priv.h>
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700104#include "wlan_hdd_regulatory.h"
105#include "wlan_reg_ucfg_api.h"
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +0530106#include "wlan_hdd_packet_filter_api.h"
Abhishek Singh0481d662017-04-11 18:20:11 +0530107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108#define HDD_FINISH_ULA_TIME_OUT 800
109#define HDD_SET_MCBC_FILTERS_TO_FW 1
110#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112/* To Validate Channel against the Frequency and Vice-Versa */
Srinivas Girigowda48592672017-03-25 14:58:44 -0700113static const struct ccp_freq_chan_map freq_chan_map[] = {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
115 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
116 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
117 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
118 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
119 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
120 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
121 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
122 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
123 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
124 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
125 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
126
Srinivas Girigowdafba82a02017-03-24 21:26:35 -0700127#define FREQ_CHAN_MAP_TABLE_SIZE QDF_ARRAY_SIZE(freq_chan_map)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128
129/* Private ioctls and their sub-ioctls */
130#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
131#define WE_SET_11D_STATE 1
132#define WE_WOWL 2
133#define WE_SET_POWER 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530134/*
135 * <ioctl>
136 * setMaxAssoc - Sets the maximum number of associated stations
137 *
138 * @INPUT: 1 to 32
139 *
140 * @OUTPUT: None
141 *
142 * This IOTCL sets the maximum number of associated stations
143 *
144 * @E.g: iwpriv wlan0 setMaxAssoc <value>
145 *
146 * Supported Feature: STA
147 *
148 * Usage: Internal/External
149 *
150 * </ioctl>
151 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152#define WE_SET_MAX_ASSOC 4
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +0530153/*
154 * <ioctl>
155 * scan_diable - Disable scan
156 *
157 * @INPUT: set_value
158 *
159 * @OUTPUT: None
160 *
161 * This IOCTL is used to set disable scan
162 *
163 * @E.g: iwpriv wlan0 scan_disable 1
164 *
165 * Supported Feature: Scan
166 *
167 * Usage: Internal/External
168 *
169 * </ioctl>
170 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171#define WE_SET_SCAN_DISABLE 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530172/*
173 * <ioctl>
174 * inactivityTO - sets the timeout value for inactivity data while
175 * in power save mode
176 *
177 * @INPUT: int1…..int255
178 *
179 * @OUTPUT: None
180 *
181 * This IOCTL set the timeout value for inactivity data in power save mode
182 *
183 * @E.g: iwpriv wlan0 inactivityTO 20
184 *
185 * Supported Feature: STA
186 *
187 * Usage: Internal/External
188 *
189 * </ioctl>
190 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191#define WE_SET_DATA_INACTIVITY_TO 6
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530192/*
193 * <ioctl>
194 * setMaxTxPower - Dynamically sets the maximum transmission power
195 *
196 * @INPUT: Transmission power in dBm
197 *
198 * @OUTPUT: None
199 *
200 * This IOCTL dynamically sets the maximum transmission power
201 * This setting does not persist over reboots
202 *
203 * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
204 *
205 * Supported Feature: STA
206 *
207 * Usage: Internal/External
208 *
209 * </ioctl>
210 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211#define WE_SET_MAX_TX_POWER 7
Jeff Johnsonfab9b252017-10-28 15:44:34 -0700212/* 8 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213#define WE_SET_TM_LEVEL 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530214/*
215 * <ioctl>
216 * setphymode - Set the phymode dynamically
217 *
218 * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
219 *
220 * @OUTPUT: None
221 *
222 * This IOCTL sets the phymode dynamically
223 *
224 * @E.g: iwpriv wlan0 setphymode 10
225 *
226 * Supported Feature: STA
227 *
228 * Usage: Internal/External
229 *
230 * </ioctl>
231 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232#define WE_SET_PHYMODE 10
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530233/*
234 * <ioctl>
235 * nss - Set the number of spatial streams
236 *
237 * @INPUT: int1…..int3
238 *
239 * @OUTPUT: None
240 *
241 * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
242 *
243 * @E.g: iwpriv wlan0 nss 2
244 *
245 * Supported Feature: STA
246 *
247 * Usage: Internal/External
248 *
249 * </ioctl>
250 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251#define WE_SET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530252/*
253 * <ioctl>
254 * ldpc - Enables or disables LDPC
255 *
256 * @INPUT: 0 – Disable, 1 - Enable
257 *
258 * @OUTPUT: None
259 *
260 * This IOCTL enables or disables LDPC
261 *
262 * @E.g: iwpriv wlan0 ldpc 1
263 *
264 * Supported Feature: STA
265 *
266 * Usage: Internal/External
267 *
268 * </ioctl>
269 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270#define WE_SET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530271/*
272 * <ioctl>
273 * tx_stbc - Enables or disables tx_stbc
274 *
275 * @INPUT: Int 0 – Disable, 1 - Enable
276 *
277 * @OUTPUT: None
278 *
279 * This IOTCL used to enables or disables tx_stbc
280 *
281 * @E.g: iwpriv wlan0 tx_stbc <value>
282 *
283 * Supported Feature: STA
284 *
285 * Usage: Internal/External
286 *
287 * </ioctl>
288 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289#define WE_SET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530290/*
291 * <ioctl>
292 * rx_stbc - Set the rx_stbc parameter
293 *
294 * @INPUT: Int 0 – Disable, 1 - Enable
295 *
296 * @OUTPUT: None
297 *
298 * This IOTCL used to set rx_stbc parameter
299 *
300 * @E.g: iwpriv wlan0 rx_stbc <value>
301 *
302 * Supported Feature: STA
303 *
304 * Usage: Internal/External
305 *
306 * </ioctl>
307 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308#define WE_SET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530309/*
310 * <ioctl>
311 * shortgi - Enables or disables a short-guard interval
312 *
313 * @INPUT: Int 0 – Disable, 1 - Enable
314 *
315 * @OUTPUT: None
316 *
317 * This IOCTL enables or disables a short-guard interval.
318 *
319 * @E.g: iwpriv wlan0 shortgi <value>
320 *
321 * Supported Feature: STA
322 *
323 * Usage: Internal/External
324 *
325 * </ioctl>
326 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327#define WE_SET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530328/*
329 * <ioctl>
330 * enablertscts - enables or disables rts/cts.
331 *
332 * @INPUT: 1-Enable , 0-Disable
333 *
334 * @OUTPUT: None
335 *
336 * This IOCTL enables or disables rts/cts.
337 *
338 * @E.g: iwpriv wlan0 enablertscts <value>
339 *
340 * Supported Feature: STA
341 *
342 * Usage: Internal/External
343 *
344 * </ioctl>
345 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346#define WE_SET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530347/*
348 * <ioctl>
349 * chwidth - Set the channel bandwidth
350 *
351 * @INPUT: 0-20mhz to 3-160mhz
352 *
353 * @OUTPUT: None
354 *
355 * This IOTCL used to set the channel bandwidth
356 *
357 * @E.g: iwpriv wlan0 chwidth 1
358 *
359 * Supported Feature: STA
360 *
361 * Usage: Internal/External
362 *
363 * </ioctl>
364 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365#define WE_SET_CHWIDTH 17
366#define WE_SET_ANI_EN_DIS 18
367#define WE_SET_ANI_POLL_PERIOD 19
368#define WE_SET_ANI_LISTEN_PERIOD 20
369#define WE_SET_ANI_OFDM_LEVEL 21
370#define WE_SET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530371/*
372 * <ioctl>
373 * cwmenable - Enables or disables the dynamic channel bandwidth
374 *
375 * @INPUT: 0-Disable, 1-Enable
376 *
377 * @OUTPUT: None
378 *
379 * This IOTCL used to enables or disables the dynamic channel bandwidth
380 *
381 * @E.g: iwpriv wlan0 cwmenable <value>
382 *
383 * Supported Feature: STA
384 *
385 * Usage: Internal/External
386 *
387 * </ioctl>
388 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389#define WE_SET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530390/*
391 * <ioctl>
392 * txchainmask - This IOCTL sets the current Tx chain mask
393 *
394 * @INPUT: Mask Value
395 *
396 * @OUTPUT: None
397 *
398 * This IOCTL sets the current Tx chain mask
399 *
400 * @E.g: iwpriv wlan0 txchainmask 1
401 *
402 * Supported Feature: STA
403 *
404 * Usage: Internal/External
405 *
406 * </ioctl>
407 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408#define WE_SET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530409/*
410 * <ioctl>
411 * rxchainmask - Sets the current Rx chain mask
412 *
413 * @INPUT: Mask Value
414 *
415 * @OUTPUT: None
416 *
417 * This IOCTL sets the current Rx chain mask. This command is the
418 * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
419 *
420 * @E.g: iwpriv wlan0 rxchainmask <value>
421 *
422 * Supported Feature: STA
423 *
424 * Usage: Internal/External
425 *
426 * </ioctl>
427 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428#define WE_SET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530429/*
430 * <ioctl>
431 * set11NRates - Fixes the Tx data rate of the 11N mode.
432 *
433 * @INPUT: 0x1b to 0x8f
434 *
435 * @OUTPUT: None
436 *
437 * This IOCTL fixes the Tx data rate of the 11N mode.
438 *
439 * @E.g: iwpriv wlan0 set11NRates 0x85
440 *
441 * Supported Feature: STA
442 *
443 * Usage: Internal/External
444 *
445 * </ioctl>
446 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447#define WE_SET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530448/*
449 * <ioctl>
450 * ampdu - Set the the maximum subframe of ampdu
451 *
452 * @INPUT: int 1 to int 63
453 *
454 * @OUTPUT: None
455 *
456 * This IOCTL sets the maximum subframe of ampdu.
457 *
458 * @E.g: iwpriv wlan0 ampdu 9
459 *
460 * Supported Feature: STA
461 *
462 * Usage: Internal/External
463 *
464 * </ioctl>
465 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466#define WE_SET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530467/*
468 * <ioctl>
469 * amsdu - Sets the maximum subframe of amsdu.
470 *
471 * @INPUT: int 1 to int 31
472 *
473 * @OUTPUT: None
474 *
475 * This IOCTL sets the maximum subframe of amsdu.
476 *
477 * @E.g: iwpriv wlan0 amsdu 9
478 *
479 * Supported Feature: STA
480 *
481 * Usage: Internal/External
482 *
483 * </ioctl>
484 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485#define WE_SET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530486/*
487 * <ioctl>
488 * txpow2g - current 2 GHz Tx power setting
489 *
490 * @INPUT: Tx power in dBm
491 *
492 * @OUTPUT: None
493 *
494 * This IOTCL used to set 2 ghz tx power
495 *
496 * @E.g: iwpriv wlan0 txpow2g
497 *
498 * Supported Feature: STA
499 *
500 * Usage: Internal/External
501 *
502 * </ioctl>
503 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800504#define WE_SET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530505/*
506 * <ioctl>
507 * txpow5g - Current 5 GHz tx power setting
508 *
509 * @INPUT: Tx power in dBm
510 *
511 * @OUTPUT: None
512 *
513 * This IOTCL used to set the 5 ghz txpower
514 *
515 * @E.g: iwpriv wlan0 txpow5g
516 *
517 * Supported Feature: STA
518 *
519 * Usage: Internal/External
520 *
521 * </ioctl>
522 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523#define WE_SET_TXPOW_5G 30
524/* Private ioctl for firmware debug log */
525#define WE_DBGLOG_LOG_LEVEL 31
526#define WE_DBGLOG_VAP_ENABLE 32
527#define WE_DBGLOG_VAP_DISABLE 33
528#define WE_DBGLOG_MODULE_ENABLE 34
529#define WE_DBGLOG_MODULE_DISABLE 35
530#define WE_DBGLOG_MOD_LOG_LEVEL 36
531#define WE_DBGLOG_TYPE 37
532#define WE_SET_TXRX_FWSTATS 38
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530533/*
534 * <ioctl>
535 * set11ACRates - Fixes the Tx data rate of 11AC
536 *
537 * @INPUT: 0x1 to 0x9
538 *
539 * @OUTPUT: None
540 *
541 * This IOCTL fixes the Tx data rate of 11AC.
542 *
543 * @E.g: iwpriv wlan0 set11ACRates 0x9
544 *
545 * Supported Feature: STA
546 *
547 * Usage: Internal/External
548 *
549 * </ioctl>
550 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551#define WE_SET_VHT_RATE 39
552#define WE_DBGLOG_REPORT_ENABLE 40
553#define WE_TXRX_FWSTATS_RESET 41
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530554/*
555 * <ioctl>
556 * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
557 *
558 * @INPUT: Transmission power in dBm
559 *
560 * @OUTPUT: None
561 *
562 * This IOCTL sets the maximum transmit power for the 2.4-GHz band
563 * This setting does not persist over reboots
564 *
565 * @E.g: iwpriv wlan0 setTxMaxPower2G 10
566 *
567 * Supported Feature: STA
568 *
569 * Usage: Internal/External
570 *
571 * </ioctl>
572 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573#define WE_SET_MAX_TX_POWER_2_4 42
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530574/*
575 * <ioctl>
576 * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
577 *
578 * @INPUT: Transmission power in dBm
579 *
580 * @OUTPUT: None
581 *
582 * This IOCTL sets the maximum transmit power for the 5-GHz band
583 * This setting does not persist over reboots
584 *
585 * @E.g: iwpriv wlan0 setTxMaxPower5G 10
586 *
587 * Supported Feature: STA
588 *
589 * Usage: Internal/External
590 *
591 * </ioctl>
592 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800594#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595/* Private ioctl for packet powe save */
596#define WE_PPS_PAID_MATCH 45
597#define WE_PPS_GID_MATCH 46
598#define WE_PPS_EARLY_TIM_CLEAR 47
599#define WE_PPS_EARLY_DTIM_CLEAR 48
600#define WE_PPS_EOF_PAD_DELIM 49
601#define WE_PPS_MACADDR_MISMATCH 50
602#define WE_PPS_DELIM_CRC_FAIL 51
603#define WE_PPS_GID_NSTS_ZERO 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530604/*
605 * <ioctl>
606 * rssi_chk - Chek the rssi
607 *
608 * @INPUT: One argument as input
609 *
610 * @OUTPUT: rssi
611 * wlan0 rssi_chk:56
612 *
613 * This IOTCL used to chek rssi
614 *
615 * @E.g: iwpriv wlan0 rssi_chk <value>
616 *
617 * Supported Feature: STA
618 *
619 * Usage: Internal/External
620 *
621 * </ioctl>
622 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623#define WE_PPS_RSSI_CHECK 53
Agrawal Ashishbafaff12016-12-27 17:43:08 +0530624/*
625 * <ioctl>
626 * setAutoChannel - set ACS enable/disable
627 *
628 * @INPUT: None
629 *
630 * @OUTPUT: None
631 *
632 * This IOCTL is used to set SAP ACS eanble/disable
633 *
634 * @E.g: iwpriv wlan0 setAutoChannel 0
635 *
636 * Supported Feature: SAP
637 *
638 * Usage: Internal/External
639 *
640 * </ioctl>
641 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530643/*
644 * <ioctl>
645 * htsmps - Sets the htsmps
646 *
647 * @INPUT: Atleast one int argument
648 *
649 * @OUTPUT: None
650 *
651 * This IOTCL used to set htsmps
652 *
653 * @E.g: iwpriv wlan0 htsmps <value>
654 *
655 * Supported Feature: STA
656 *
657 * Usage: Internal/External
658 *
659 * </ioctl>
660 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661#define WE_SET_HTSMPS 55
662/* Private ioctl for QPower */
663#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
664#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
665#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
666#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530667/*
668 * <ioctl>
669 * burst_enable - Enables or disables the burst feature
670 *
671 * @INPUT: 0-Disable, 1-Enable
672 *
673 * @OUTPUT: None
674 *
675 * This IOCTL enables or disables the burst feature.
676 *
677 * @E.g: iwpriv wlan0 burst_enable 0
678 *
679 * Supported Feature: STA
680 *
681 * Usage: Internal/External
682 *
683 * </ioctl>
684 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685#define WE_SET_BURST_ENABLE 60
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530686/*
687 * <ioctl>
688 * burst_dur - Enables or disables the burst feature
689 *
690 * @INPUT: int 1…..int 8191 in microseconds
691 *
692 * @OUTPUT: None
693 *
694 * This IOCTL sets the burst duration.
695 *
696 * @E.g: iwpriv wlan0 burst_dur <value>
697 *
698 * Supported Feature: STA
699 *
700 * Usage: Internal/External
701 *
702 * </ioctl>
703 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704#define WE_SET_BURST_DUR 61
705/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530706/*
707 * <ioctl>
708 * gtxHTMcs - Set the tx HTM value
709 *
710 * @INPUT: Atleast one int orgument
711 *
712 * @OUTPUT: None
713 *
714 * This IOTCL sets htm tx value
715 *
716 * @E.g: iwpriv wlan0 gtxHTMcs <value>
717 *
718 * Supported Feature: STA
719 *
720 * Usage: Internal/External
721 *
722 * </ioctl>
723 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724#define WE_SET_GTX_HT_MCS 62
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530725/*
726 * <ioctl>
727 * gtxVHTMcs - Set gtxVHTMcs value
728 *
729 * @INPUT: Atleast one int argument
730 *
731 * @OUTPUT: None
732 *
733 * This IOTCL used to set gtxVHTMcs value
734 *
735 * @E.g: iwpriv wlan0 gtxVHTMcs <value>
736 *
737 * Supported Feature: STA
738 *
739 * Usage: Internal/External
740 *
741 * </ioctl>
742 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743#define WE_SET_GTX_VHT_MCS 63
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530744/*
745 * <ioctl>
746 * gtxUsrCfg - Host request for GTX mask
747 *
748 * @INPUT: Atleast one int orgument
749 *
750 * @OUTPUT: None
751 *
752 * This IOTCL used send the host request for GTX mask
753 *
754 * @E.g: iwpriv wlan0 gtxUsrCfg <value>
755 *
756 * Supported Feature: STA
757 *
758 * Usage: Internal/External
759 *
760 * </ioctl>
761 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762#define WE_SET_GTX_USRCFG 64
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530763/*
764 * <ioctl>
765 * gtxThre - Set the tx threshold
766 *
767 * @INPUT: Atleast one int argument
768 *
769 * @OUTPUT: None
770 *
771 * This IOTCL used to set tx threshold
772 *
773 * @E.g: iwpriv wlan0 gtxThre <value>
774 *
775 * Supported Feature: STA
776 *
777 * Usage: Internal/External
778 *
779 * </ioctl>
780 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781#define WE_SET_GTX_THRE 65
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530782/*
783 * <ioctl>
784 * gtxMargin - Set the gtxMargin
785 *
786 * @INPUT: 1 to 32
787 *
788 * @OUTPUT: None
789 *
790 * This IOTCL use dto set gtxMargin
791 *
792 * @E.g: iwpriv wlan0 gtxMargini <value>
793 *
794 * Supported Feature: STA
795 *
796 * Usage: Internal/External
797 *
798 * </ioctl>
799 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800#define WE_SET_GTX_MARGIN 66
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530801/*
802 * <ioctl>
803 * gtxStep - Set the gtxStep
804 *
805 * @INPUT: None
806 *
807 * @OUTPUT: None
808 *
809 * This IOTCL used to sets gtxStep
810 *
811 * @E.g: iwpriv wlan0 gtxStep <value>
812 *
813 * Supported Feature: STA
814 *
815 * Usage: Internal/External
816 *
817 * </ioctl>
818 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819#define WE_SET_GTX_STEP 67
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530820/*
821 * <ioctl>
822 * gtxMinTpc - Sets the gtxMinTpc
823 *
824 * @INPUT: Atleast one int argument
825 *
826 * @OUTPUT: None
827 *
828 * This IOTCL sets the tx MinTpc
829 *
830 * @E.g: iwpriv wlan0 gtxMinTpc <value>
831 *
832 * Supported Feature: STA
833 *
834 * Usage: Internal/External
835 *
836 * </ioctl>
837 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838#define WE_SET_GTX_MINTPC 68
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530839/*
840 * <ioctl>
841 * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
842 *
843 * @INPUT: Mask value
844 *
845 * @OUTPUT: None
846 *
847 * This IOTCL used to set gtxBWMask
848 *
849 * @E.g: iwpriv wlan0 gtxBWMask <value>
850 *
851 * Supported Feature: STA
852 *
853 * Usage: Internal/External
854 *
855 * </ioctl>
856 */
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530857
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530858#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530859/*
860 * <ioctl>
861 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
862 *
863 * @INPUT: set_value
864 *
865 * @OUTPUT: None
866 *
867 * This IOCTL is used to set the MCC latency value in milliseconds
868 * during STA-P2P concurrency.
869 *
870 * If 0ms latency is provided, then FW will set to a default.
871 * Otherwise, latency must be at least 30ms.
872 *
873 * @E.g: iwpriv wlan0 setMccLatency 40
874 *
875 *
876 * Supported Feature: Concurrency
877 *
878 * Usage: Internal/External
879 *
880 * </ioctl>
881 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530883
884/*
885 * <ioctl>
886 * setMccQuota- Set the quota for P2P cases
887 *
888 * @INPUT: set_value [0,100]
889 *
890 * @OUTPUT: None
891 *
892 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
893 *
894 * Currently used to set time quota for 2 MCC vdevs/adapters using
895 * (operating channel, quota) for each mode.
896 * The info is provided run time using iwpriv command:
897 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
898 * Note: the quota provided in command is for the same mode in cmd.
899 * HDD checks if MCC mode is active, gets the second mode and its
900 * operating chan.
901 * Quota for the 2nd role is calculated as 100 - quota of first mode.
902 *
903 * @E.g: iwpriv wlan0 setMccQuota 50
904 * iwpriv p2p0 setMccQuota 50
905 *
906 * Supported Feature: Concurrency
907 *
908 * Usage: Internal/External
909 *
910 * </ioctl>
911 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912#define WE_MCC_CONFIG_QUOTA 71
913/* Private IOCTL for debug connection issues */
914#define WE_SET_DEBUG_LOG 72
915#ifdef WE_SET_TX_POWER
916#undef WE_SET_TX_POWER
917#endif
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -0800918
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530919/*
920 * <ioctl>
921 * setTxPower - Set the current transmit power
922 *
923 * @INPUT: Transmission power in dBm
924 *
925 * @OUTPUT: None
926 *
927 * This IOCTL sets the current transmit power.
928 * This setting does not persist over reboots.
929 *
930 * @E.g: iwpriv wlan0 setTxPower 10
931 *
932 * Supported Feature: STA
933 *
934 * Usage: Internal/External
935 *
936 * </ioctl>
937 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938#define WE_SET_TX_POWER 74
939/* Private ioctl for earlyrx power save feature */
940#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
941#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
942#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
943#define WE_SET_EARLY_RX_SLOP_STEP 78
944#define WE_SET_EARLY_RX_INIT_SLOP 79
945#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530946/*
947 * <ioctl>
948 * setMcRate - Set the data rate for multicast data
949 *
950 * @INPUT: 1 to 32
951 *
952 * @OUTPUT: None
953 *
954 * This IOCTL sets the data rate for multicast data. Note that this command
955 * is allowed only in STA, IBSS, or QCMobileAP mode
956 *
957 * @E.g: iwpriv wlan0 setMcRate <value>
958 *
959 * Supported Feature: STA
960 *
961 * Usage: Internal/External
962 *
963 * </ioctl>
964 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965#define WE_SET_MC_RATE 81
966#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
967/* Private ioctl for packet power save */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530968/*
969 * <ioctl>
970 * 5g_ebt - Sets the 5g_ebt
971 *
972 * @INPUT: <value>
973 *
974 * @OUTPUT: None
975 *
976 * This IOTCL used to set 5g_ebt
977 *
978 * @E.g: iwpriv wlan0 5g_ebt <value>
979 *
980 * Supported Feature: STA
981 *
982 * Usage: Internal/External
983 *
984 * </ioctl>
985 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986#define WE_PPS_5G_EBT 83
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530987/*
988 * <ioctl>
989 * cts_cbw - Set CTS channel BW for dynamic BW adjustment
990 *
991 * @INPUT: 20 t0 160
992 *
993 * @OUTPUT: None
994 *
995 * This IOTCL used to set CTS channel BW for dynamic BW adjustment
996 *
997 * @E.g: iwpriv wlan0 cts_cbw <value>
998 *
999 * Supported Feature: STA
1000 *
1001 * Usage: Internal/External
1002 *
1003 * </ioctl>
1004 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005#define WE_SET_CTS_CBW 84
1006#define WE_DUMP_STATS 85
1007#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +05301008/* Private sub ioctl for starting/stopping the profiling */
1009#define WE_START_FW_PROFILE 87
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301010
Abhishek Singh3c507012016-12-01 11:15:42 +05301011/*
1012 * <ioctl>
1013 * setChanChange - Initiate channel change
1014 *
1015 * @INPUT: channel number to switch to.
1016 *
1017 * @OUTPUT: None
1018 *
1019 * This IOCTL is used to initiate a channel change.
1020 * If called on STA/CLI interface it will send the
1021 * ECSA action frame to the connected SAP/GO asking to
1022 * initiate the ECSA, if supported.
1023 * If called on SAP/GO interface it will initiate
1024 * ECSA and ask connected peers to move to new channel.
1025 *
1026 * @E.g: iwpriv wlan0 setChanChange <channel>
1027 * iwpriv wlan0 setChanChange 1
1028 *
1029 * Supported Feature: ECSA
1030 *
1031 * Usage: Internal/External
1032 *
1033 * </ioctl>
1034 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +05301035#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05301036#define WE_SET_CONC_SYSTEM_PREF 89
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08001037#define WE_SET_TXRX_STATS 90
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08001039/*
1040 * <ioctl>
1041 * set_11ax_rate - set 11ax rates to FW
1042 *
1043 * @INPUT: rate code
1044 *
1045 * @OUTPUT: None
1046 *
1047 * This IOCTL fixes the Tx data rate of 11AX.
1048 *
1049 * @E.g: iwpriv wlan0 set_11ax_rate <rate code>
1050 *
1051 * Supported Feature: STA/SAP
1052 *
1053 * Usage: Internal
1054 *
1055 * </ioctl>
1056 */
1057#define WE_SET_11AX_RATE 91
1058
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001059/*
1060 * <ioctl>
1061 * enable_dcm - enable Dual Carrier Modulation(DCM)
1062 *
1063 * @INPUT: 0/1
1064 *
1065 * @OUTPUT: None
1066 *
1067 * This IOCTL enables/disables DCM.
1068 *
1069 * @E.g: iwpriv wlan0 enable_dcm <0/1>
1070 *
1071 * Supported Feature: STA/SAP
1072 *
1073 * Usage: Internal
1074 *
1075 * </ioctl>
1076 */
1077#define WE_SET_DCM 92
1078
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001079/*
1080 * <ioctl>
Naveen Rawat53448ea2017-11-27 11:43:18 -08001081 * range_ext - enable Range extension
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001082 *
1083 * @INPUT: 0/1
1084 *
1085 * @OUTPUT: None
1086 *
1087 * This IOCTL enables/disables Range extension.
1088 *
Naveen Rawat53448ea2017-11-27 11:43:18 -08001089 * @E.g: iwpriv wlan0 range_ext <1/0>
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001090 *
1091 * Supported Feature: STA/SAP
1092 *
1093 * Usage: Internal
1094 *
1095 * </ioctl>
1096 */
1097#define WE_SET_RANGE_EXT 93
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001098
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301099/*
1100 * <ioctl>
1101 * wow_ito - sets the timeout value for inactivity data while
1102 * in power save mode during wow
1103 *
1104 * @INPUT: int
1105 *
1106 * @OUTPUT: None
1107 *
1108 * This IOCTL set the timeout value for inactivity data in power save mode
1109 *
1110 * @E.g: iwpriv wlan0 wow_ito 20
1111 *
1112 * Supported Feature: STA
1113 *
1114 * Usage: External
1115 *
1116 * </ioctl>
Jeff Johnsondcf84ce2017-10-05 09:26:24 -07001117 */
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301118#define WE_SET_WOW_DATA_INACTIVITY_TO 94
1119
Jeff Johnson011c4502017-10-05 15:25:56 -07001120/*
1121 * <ioctl>
1122 * pdev_reset - reset the pdev
1123 *
1124 * @INPUT: Reset command to initiate:
1125 * TX_FLUSH = 1
1126 * WARM_RESET = 2
1127 * COLD_RESET = 3
1128 * WARM_RESET_RESTORE_CAL = 4
1129 * COLD_RESET_RESTORE_CAL = 5
1130 *
1131 * @OUTPUT: None
1132 *
1133 * This IOCTL is used to reset the pdev. The primary use is
1134 * for internal testing. It is not expected that this will
1135 * be used on a production device.
1136 *
1137 * @E.g: iwpriv wlan0 pdev_reset <command>
1138 * iwpriv wlan0 pdev_reset 1
1139 *
1140 * Supported Feature: None
1141 *
1142 * Usage: Internal
1143 *
1144 * </ioctl>
1145 */
1146#define WE_SET_PDEV_RESET 95
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301147
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05301148/*
1149 * setModDTIM - Change Modulated DTIM
1150 *
1151 * @INPUT: set_value.
1152 *
1153 * @OUTPUT: None
1154 *
1155 * This IOCTL is used to change modulated DTIM
1156 * value without WIFI OFF/ON.
1157 *
1158 * @E.g: iwpriv wlan0 setModDTIM <value>
1159 * iwpriv wlan0 setModDTIM 2
1160 *
1161 * Supported Feature: N/A
1162 *
1163 * Usage: Internal/External
1164 *
1165 * </ioctl>
1166 */
1167#define WE_SET_MODULATED_DTIM 96
1168
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169/* Private ioctls and their sub-ioctls */
1170#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
1171#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172#define WE_SET_SAP_CHANNELS 3
1173#define WE_GET_WLAN_DBG 4
1174#define WE_GET_MAX_ASSOC 6
1175/* 7 is unused */
1176#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +05301177
1178/*
1179 * <ioctl>
1180 * getconcurrency - Get concurrency mode
1181 *
1182 * @INPUT: None
1183 *
1184 * @OUTPUT: It shows concurrency value
1185 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
1186 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
1187 * 8:OCB 9:EPPING 10:QVIT 11:NDI
1188 *
1189 * This IOCTL is used to retrieve concurrency mode.
1190 *
1191 * @E.g: iwpriv wlan0 getconcurrency
1192 * wlan0 getconcurrency:5
1193 * Above value shows STA+P2P_Client
1194 *
1195 * Supported Feature: Concurrency
1196 *
1197 * Usage: Internal/External
1198 *
1199 * </ioctl>
1200 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201#define WE_GET_CONCURRENCY_MODE 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301202/*
1203 * <ioctl>
1204 * get_nss - Get the number of spatial STBC streams (NSS)
1205 *
1206 * @INPUT: None
1207 *
1208 * @OUTPUT: NSS
1209 * wlan0 get_nss:2
1210 *
1211 * This IOTCL used to get the number of spatial STBC streams
1212 *
1213 * @E.g: iwpriv wlan0 get_nss
1214 *
1215 * Supported Feature: STA
1216 *
1217 * Usage: Internal/External
1218 *
1219 * </ioctl>
1220 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221#define WE_GET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301222/*
1223 * <ioctl>
1224 * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1225 *
1226 * @INPUT: None
1227 *
1228 * @OUTPUT: ldpc
1229 * wlan0 get_ldpc:1
1230 *
1231 * This IOTCL used to gets the low density parity check (LDPC)
1232 *
1233 * @E.g: iwpriv wlan0 get_ldpc
1234 *
1235 * Supported Feature: STA
1236 *
1237 * Usage: Internal/External
1238 *
1239 * </ioctl>
1240 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241#define WE_GET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301242/*
1243 * <ioctl>
1244 * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1245 *
1246 * @INPUT: None
1247 *
1248 * @OUTPUT: TXSTBC
1249 * wlan0 get_tx_stbc:1
1250 *
1251 * This IOTCL get the value of the current Tx space time block code (STBC)
1252 *
1253 * @E.g: iwpriv wlan0 get_tx_stbc
1254 *
1255 * Supported Feature: STA
1256 *
1257 * Usage: Internal/External
1258 *
1259 * </ioctl>
1260 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261#define WE_GET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301262/*
1263 * <ioctl>
1264 * get_rx_stbc - Gets the value of the current Rx STBC
1265 *
1266 * @INPUT: None
1267 *
1268 * @OUTPUT: Rx STBC
1269 * wlan0 get_rx_stbc:1
1270 *
1271 * This IOTCL used to get the value of the current Rx STBC
1272 *
1273 * @E.g: iwpriv wlan0 get_rx_stbc
1274 *
1275 * Supported Feature: STA
1276 *
1277 * Usage: Internal/External
1278 *
1279 * </ioctl>
1280 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281#define WE_GET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301282/*
1283 * <ioctl>
1284 * get_shortgi - Get the value of the current short GI setting
1285 *
1286 * @INPUT: None
1287 *
1288 * @OUTPUT: Enable/disable of shortgi
1289 * wlan0 get_shortgi:1
1290 *
1291 * This IOCTL gets the value of the current short GI setting
1292 *
1293 * @E.g: iwpriv wlan0 get_shortgi
1294 *
1295 * Supported Feature: STA
1296 *
1297 * Usage: Internal/External
1298 *
1299 * </ioctl>
1300 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301#define WE_GET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301302/*
1303 * <ioctl>
1304 * get_rtscts - Get the value of the current RTS/CTS setting.
1305 *
1306 * @INPUT: None
1307 *
1308 * @OUTPUT: Enable/disable of RTS/CTS
1309 * wlan0 get_rtscts:33
1310 *
1311 * This IOTCL get the value of the current RTS/CTS setting.
1312 *
1313 * @E.g: iwpriv wlan0 get_rtscts
1314 *
1315 * Supported Feature: STA
1316 *
1317 * Usage: Internal/External
1318 *
1319 * </ioctl>
1320 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321#define WE_GET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301322/*
1323 * <ioctl>
1324 * get_chwidth - Get the current channel width setting
1325 *
1326 * @INPUT: None
1327 *
1328 * @OUTPUT: channel width
1329 * wlan0 get_chwidth:0
1330 *
1331 * This IOTCL get the current channel width setting.
1332 *
1333 * @E.g: iwpriv wlan0 get_chwidth
1334 *
1335 * Supported Feature: STA
1336 *
1337 * Usage: Internal/External
1338 *
1339 * </ioctl>
1340 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341#define WE_GET_CHWIDTH 17
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301342/*
1343 * <ioctl>
1344 * get_anienable - Get the anienable
1345 *
1346 * @INPUT: None
1347 *
1348 * @OUTPUT:
1349 * wlan0 get_anienable:0
1350 *
1351 * This IOTCL get the anienable
1352 *
1353 * @E.g: iwpriv wlan0 get_anienable
1354 *
1355 * Supported Feature: STA
1356 *
1357 * Usage: Internal/External
1358 *
1359 * </ioctl>
1360 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361#define WE_GET_ANI_EN_DIS 18
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301362/*
1363 * <ioctl>
1364 * get_aniplen - Get the aniplen
1365 *
1366 * @INPUT: None
1367 *
1368 * @OUTPUT:
1369 * wlan0 get_aniplen:0
1370 *
1371 * This IOTCL get the aniplen
1372 *
1373 * @E.g: iwpriv wlan0 get_aniplen
1374 *
1375 * Supported Feature: STA
1376 *
1377 * Usage: Internal/External
1378 *
1379 * </ioctl>
1380 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381#define WE_GET_ANI_POLL_PERIOD 19
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301382/*
1383 * <ioctl>
1384 * get_anilislen- Get the anilislen
1385 *
1386 * @INPUT: None
1387 *
1388 * @OUTPUT:
1389 * wlan0 get_anilislen:0
1390 *
1391 * This IOTCL used to get anilislen
1392 *
1393 * @E.g: iwpriv wlan0 get_anilislen
1394 *
1395 * Supported Feature: STA
1396 *
1397 * Usage: Internal/External
1398 *
1399 * </ioctl>
1400 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401#define WE_GET_ANI_LISTEN_PERIOD 20
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301402/*
1403 * <ioctl>
1404 * get_aniofdmlvl - Get the OFDM level
1405 *
1406 * @INPUT: None
1407 *
1408 * @OUTPUT: OFDM
1409 * wlan0 get_aniofdmlvl:0
1410 *
1411 * This IOTCL used to get ofdm level
1412 *
1413 * @E.g: iwpriv wlan0 get_aniofdmlvl
1414 *
1415 * Supported Feature: STA
1416 *
1417 * Usage: Internal/External
1418 *
1419 * </ioctl>
1420 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421#define WE_GET_ANI_OFDM_LEVEL 21
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301422/*
1423 * <ioctl>
1424 * get_aniccklvl - Get the cck level
1425 *
1426 * @INPUT: None
1427 *
1428 * @OUTPUT:
1429 * wlan0 get_aniccklvl:0
1430 *
1431 * This IOTCL used to get cck level
1432 *
1433 * @E.g: iwpriv wlan0 get_aniccklvl
1434 *
1435 * Supported Feature: STA
1436 *
1437 * Usage: Internal/External
1438 *
1439 * </ioctl>
1440 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441#define WE_GET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301442/*
1443 * <ioctl>
1444 * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1445 *
1446 * @INPUT: None
1447 *
1448 * @OUTPUT: Enable/disable dynamic channel bandwidth
1449 * wlan0 get_cwmenable:0
1450 *
1451 * This IOTCL get the value of the dynamic channel bandwidth setting
1452 *
1453 * @E.g: iwpriv wlan0 get_cwmenable
1454 *
1455 * Supported Feature: STA
1456 *
1457 * Usage: Internal/External
1458 *
1459 * </ioctl>
1460 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461#define WE_GET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301462/*
1463 * <ioctl>
1464 * get_txchainmask - Get the txchainmask that was set
1465 *
1466 * @INPUT: None
1467 *
1468 * @OUTPUT: txchainmask
1469 * wlan0 get_txchainmask:1
1470 *
1471 * This IOCTL gets the txchainmask that was set
1472 * This command is useful if it was previously set
1473 *
1474 * @E.g: iwpriv wlan0 get_txchainmask
1475 *
1476 * Supported Feature: STA
1477 *
1478 * Usage: Internal/External
1479 *
1480 * </ioctl>
1481 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482#define WE_GET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301483/*
1484 * <ioctl>
1485 * get_rxchainmask - Get the rxchainmask that was set
1486 *
1487 * @INPUT: None
1488 *
1489 * @OUTPUT: rxchainmask
1490 * wlan0 get_rxchainmask:1
1491 *
1492 * This IOCTL gets the rxchainmask that was set
1493 * This command is useful only if it was previously set.
1494 *
1495 * @E.g: iwpriv wlan0 get_rxchainmask
1496 *
1497 * Supported Feature: STA
1498 *
1499 * Usage: Internal/External
1500 *
1501 * </ioctl>
1502 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503#define WE_GET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301504/*
1505 * <ioctl>
1506 * get_11nrate - Get the fixed Tx data rate
1507 *
1508 * @INPUT: None
1509 *
1510 * @OUTPUT: Using this command does not return the same value as set
1511 * wlan0 get_11nrate:0
1512 *
1513 * This IOCTL gets the fixed Tx data rate
1514 * This command is useful only if setting the fixed Tx rate.
1515 *
1516 * @E.g: iwpriv wlan0 get_11nrate
1517 *
1518 * Supported Feature: STA
1519 *
1520 * Usage: Internal/External
1521 *
1522 * </ioctl>
1523 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524#define WE_GET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301525/*
1526 * <ioctl>
1527 * get_ampdu - Get the maximum subframe of ampdu
1528 *
1529 * @INPUT: None
1530 *
1531 * @OUTPUT: Maximum subframe of ampdu
1532 * wlan0 get_ampdu:1
1533 *
1534 * This IOCTL gets the maximum subframe of ampdu
1535 * This command is useful only if setting ampdu.
1536 *
1537 * @E.g: iwpriv wlan0 get_ampdu
1538 *
1539 * Supported Feature: STA
1540 *
1541 * Usage: Internal/External
1542 *
1543 * </ioctl>
1544 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545#define WE_GET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301546/*
1547 * <ioctl>
1548 * get_amsdu - Get the maximum subframe of amsdu
1549 *
1550 * @INPUT: None
1551 *
1552 * @OUTPUT: Maximum subframe of amsdu
1553 * wlan0 get_amsdu:1
1554 *
1555 * This IOCTL gets the maximum subframe of amsdu.
1556 * This command is useful only if setting amsdu
1557 *
1558 * @E.g: iwpriv wlan0 get_amsdu
1559 *
1560 * Supported Feature: STA
1561 *
1562 * Usage: Internal/External
1563 *
1564 * </ioctl>
1565 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566#define WE_GET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301567/*
1568 * <ioctl>
1569 * get_txpow2g - Get the current 2 GHz Tx power setting
1570 *
1571 * @INPUT: None
1572 *
1573 * @OUTPUT: Tx Power in dbm
1574 * wlan0 get_txpow2g:0
1575 *
1576 * This IOCTL gets the current 2 GHz Tx power setting
1577 * This command is useful if setting Tx power
1578 *
1579 * @E.g: iwpriv wlan0 get_txpow2g
1580 *
1581 * Supported Feature: STA
1582 *
1583 * Usage: Internal/External
1584 *
1585 * </ioctl>
1586 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587#define WE_GET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301588/*
1589 * <ioctl>
1590 * get_txpow5g - Get the current 5 GHz Tx power setting
1591 *
1592 * @INPUT: None
1593 *
1594 * @OUTPUT: Tx Power in dbm
1595 * wlan0 get_txpow5g:0
1596 *
1597 * This IOCTL gets the current 5 GHz Tx power setting
1598 * This command is useful if setting Tx power
1599 *
1600 * @E.g: iwpriv wlan0 get_txpow5g
1601 *
1602 * Supported Feature: STA
1603 *
1604 * Usage: Internal/External
1605 *
1606 * </ioctl>
1607 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -08001609/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610#define WE_GET_PPS_PAID_MATCH 32
1611#define WE_GET_PPS_GID_MATCH 33
1612#define WE_GET_PPS_EARLY_TIM_CLEAR 34
1613#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
1614#define WE_GET_PPS_EOF_PAD_DELIM 36
1615#define WE_GET_PPS_MACADDR_MISMATCH 37
1616#define WE_GET_PPS_DELIM_CRC_FAIL 38
1617#define WE_GET_PPS_GID_NSTS_ZERO 39
1618#define WE_GET_PPS_RSSI_CHECK 40
1619/* Private ioctl for QPower */
1620#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
1621#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
1622#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
1623#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301624/*
1625 * <ioctl>
1626 * get_burst_en - Enables or disables the burst feature
1627 *
1628 * @INPUT: None
1629 *
1630 * @OUTPUT: Enable/disable of burst feature
1631 * wlan0 get_burst_en:1
1632 *
1633 * This IOCTL enables or disables the burst feature
1634 *
1635 * @E.g: iwpriv wlan0 get_burst_en
1636 *
1637 * Supported Feature:STA
1638 *
1639 * Usage: Internal/External
1640 *
1641 * </ioctl>
1642 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643#define WE_GET_BURST_ENABLE 45
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301644/*
1645 * <ioctl>
1646 * get_burst_dur - Get the burst duration
1647 *
1648 * @INPUT: None
1649 *
1650 * @OUTPUT: Duration in microseconds
1651 * wlan0 get_burst_dur:8160
1652 *
1653 * This IOCTL gets the burst duration
1654 * This command is useful if setting burst enable
1655 *
1656 * @E.g: iwpriv wlan0 get_burst_dur
1657 *
1658 * Supported Feature: STA
1659 *
1660 * Usage: Internal/External
1661 *
1662 * </ioctl>
1663 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664#define WE_GET_BURST_DUR 46
1665/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301666/*
1667 * <ioctl>
1668 * get_gtxHTMcs - Get the tx HTM
1669 *
1670 * @INPUT: None
1671 *
1672 * @OUTPUT: HTM
1673 * wlan0 get_gtxHTMcs:32896
1674 *
1675 * This IOTCL used to get HTM
1676 *
1677 * @E.g: iwpriv wlan0 get_gtxHTMcs
1678 *
1679 * Supported Feature: STA
1680 *
1681 * Usage: Internal/External
1682 *
1683 * </ioctl>
1684 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685#define WE_GET_GTX_HT_MCS 47
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301686/*
1687 * <ioctl>
1688 * get_gtxVHTMcs - Get the VHTM
1689 *
1690 * @INPUT: None
1691 *
1692 * @OUTPUT: VHTM
1693 * wlan0 get_gtxVHTMcs:524800
1694 *
1695 * This IOTCL used to get the VHTM
1696 *
1697 * @E.g: iwpriv wlan0 get_gtxVHTMcs
1698 *
1699 * Supported Feature: STA
1700 *
1701 * Usage: Internal/External
1702 *
1703 * </ioctl>
1704 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705#define WE_GET_GTX_VHT_MCS 48
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301706/*
1707 * <ioctl>
1708 * get_gtxUsrCfg - Get the tx cfg
1709 *
1710 * @INPUT: None
1711 *
1712 * @OUTPUT: TXCFG
1713 * wlan0 get_gtxUsrCfg:32
1714 *
1715 * This IOTCL used to get the tx cfg
1716 *
1717 * @E.g: iwpriv wlan0 get_gtxUsrCfg
1718 *
1719 * Supported Feature: STA
1720 *
1721 * Usage: Internal/External
1722 *
1723 * </ioctl>
1724 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725#define WE_GET_GTX_USRCFG 49
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301726/*
1727 * <ioctl>
1728 * get_gtxThre - Get the tx threshold
1729 *
1730 * @INPUT: None
1731 *
1732 * @OUTPUT: Threshold
1733 * wlan0 get_gtxThre:3
1734 *
1735 * This IOCTL is used to get tx threshold
1736 *
1737 * @E.g: iwpriv wlan0 get_gtxThre
1738 *
1739 * Supported Feature: STA
1740 *
1741 * Usage: Internal/External
1742 *
1743 * </ioctl>
1744 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745#define WE_GET_GTX_THRE 50
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301746/*
1747 * <ioctl>
1748 * get_gtxMargin - Get the tx margin
1749 *
1750 * @INPUT: None
1751 *
1752 * @OUTPUT: GTXMARGIN
1753 * wlan0 get_gtxMargin:2
1754 *
1755 * This IOCTL is used to set tx margin
1756 *
1757 * @E.g: iwpriv wlan0 get_gtxMargin
1758 *
1759 * Supported Feature: STA
1760 *
1761 * Usage: Internal/External
1762 *
1763 * </ioctl>
1764 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765#define WE_GET_GTX_MARGIN 51
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301766/*
1767 * <ioctl>
1768 * get_gtxStep - Get the tx step
1769 *
1770 * @INPUT: None
1771 *
1772 * @OUTPUT: GTXSTEP
1773 * wlan0 get_gtxStep:0
1774 *
1775 * This IOCTL is used to get the gtx step
1776 *
1777 * @E.g: iwpriv wlan0 get_gtxStep
1778 *
1779 * Supported Feature: STA
1780 *
1781 * Usage: Internal/External
1782 *
1783 * </ioctl>
1784 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785#define WE_GET_GTX_STEP 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301786/*
1787 * <ioctl>
1788 * get_gtxMinTpc - Get the tx miminum tpc
1789 *
1790 * @INPUT: None
1791 *
1792 * @OUTPUT: TPC
1793 * wlan0 get_gtxMinTpc:0
1794 *
1795 * This IOCTL is used to get tx miminum tpc
1796 *
1797 * @E.g: iwpriv wlan0 get_gtxMinTpc
1798 *
1799 * Supported Feature: STA
1800 *
1801 * Usage: Internal/External
1802 *
1803 * </ioctl>
1804 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805#define WE_GET_GTX_MINTPC 53
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301806/*
1807 * <ioctl>
1808 * get_gtxBWMask - Get the tx BW MASK
1809 *
1810 * @INPUT: None
1811 *
1812 * @OUTPUT: MASK
1813 * wlan0 get_gtxBWMask:15
1814 *
1815 * This IOCTL is used get gtx bw mask
1816 *
1817 * @E.g: iwpriv wlan0 get_gtxBWMask
1818 *
1819 * Supported Feature: STA
1820 *
1821 * Usage: Internal/External
1822 *
1823 * </ioctl>
1824 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825#define WE_GET_GTX_BWMASK 54
1826#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001827#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07001828#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001830/*
1831 * <ioctl>
1832 * get_dcm - Get dcm enablement value
1833 *
1834 * @INPUT: None
1835 *
1836 * @OUTPUT: 0/1
1837 * wlan0 get_dcm
1838 *
1839 * This IOCTL is used get dcm value
1840 *
1841 * Supported Feature: STA/SAP
1842 *
1843 * Usage: Internal
1844 *
1845 * </ioctl>
1846 */
1847#define WE_GET_DCM 60
1848
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001849/*
1850 * <ioctl>
1851 * get_dcm - Get range extension enablement value
1852 *
1853 * @INPUT: None
1854 *
1855 * @OUTPUT: 0/1
1856 * wlan0 get_range_ext
1857 *
1858 * This IOCTL is used get range_extension value
1859 *
1860 * Supported Feature: STA/SAP
1861 *
1862 * Usage: Internal
1863 *
1864 * </ioctl>
1865 */
1866#define WE_GET_RANGE_EXT 61
1867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868/* Private ioctls and their sub-ioctls */
1869#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
1870
1871/* Private ioctls and their sub-ioctls */
1872#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
1873#define WE_WOWL_ADD_PTRN 1
1874#define WE_WOWL_DEL_PTRN 2
Sreelakshmi Konamkided64d72017-02-23 10:39:26 +05301875/*
1876 * <ioctl>
1877 * neighbor - Send neighbor report request
1878 *
1879 * @INPUT: string
1880 *
1881 * @OUTPUT: None
1882 *
1883 * This IOCTL create a Neighbor report request and send it to peer
1884 *
1885 * @E.g: iwpriv wlan0 neighbor "SSID"
1886 *
1887 * Supported Feature: 11k
1888 *
1889 * Usage: Internal/External
1890 *
1891 * </ioctl>
1892 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893#define WE_NEIGHBOR_REPORT_REQUEST 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301894/*
1895 * <ioctl>
1896 * set_ap_wps_ie - Set the P2P IE of the probe response
1897 *
1898 * @INPUT: string
1899 *
1900 * @OUTPUT: None
1901 *
1902 * This IOCTL sets the P2P IE of the probe response
1903 *
1904 * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1905 *
1906 * Supported Feature: STA
1907 *
1908 * Usage: Internal/External
1909 *
1910 * </ioctl>
1911 */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07001912#define WE_SET_AP_WPS_IE 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913#define WE_SET_CONFIG 5
1914
1915/* Private ioctls and their sub-ioctls */
1916#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
1917#define WE_SET_WLAN_DBG 1
1918#define WE_SET_DP_TRACE 2
1919#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05301920#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921
1922/* Private ioctls and their sub-ioctls */
1923#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
1924#define WE_WLAN_VERSION 1
1925#define WE_GET_STATS 2
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301926/*
1927 * <ioctl>
1928 * getConfig - gets the values of all configurations listed in WCNSS
1929 *
1930 * @INPUT: None
1931 *
1932 * @OUTPUT: Current configuration to the sys log
1933 * wlan0 getConfig: WLAN configuration written to system log
1934 *
1935 * This IOCTL gets the values of all configurations listed in WCNSS
1936 *
1937 * @E.g: iwpriv wlan0 getConfig
1938 *
1939 * Supported Feature: STA
1940 *
1941 * Usage: Internal/External
1942 *
1943 * </ioctl>
1944 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945#define WE_GET_CFG 3
1946#define WE_GET_WMM_STATUS 4
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301947/*
1948 * <ioctl>
1949 * getChannelList - Get the available channel list while in QCMobileAP
1950 *
1951 * @INPUT: None
1952 *
1953 * @OUTPUT: Channel list
1954 * wlan0 getChannelList:36 US 1..165
1955 *
1956 * This IOCTL gets the available channel list while in QCMobileAP
1957 *
1958 * @E.g: iwpriv wlan0 getChannelList
1959 *
1960 * Supported Feature: STA
1961 *
1962 * Usage: Internal/External
1963 *
1964 * </ioctl>
1965 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966#define WE_GET_CHANNEL_LIST 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301967/*
1968 * <ioctl>
1969 * getRSSI - Get the Received Signal Strength Indicator
1970 *
1971 * @INPUT: None
1972 *
1973 * @OUTPUT: RSSI
1974 * wlan0 getRSSI:rsssi=-32
1975 *
1976 * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1977 *
1978 * @E.g: iwpriv wlan0 getRSSI
1979 *
1980 * Supported Feature: STA
1981 *
1982 * Usage: Internal/External
1983 *
1984 * </ioctl>
1985 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -08001987
1988/*
1989 * <ioctl>
1990 * getSuspendStats - Get suspend/resume stats
1991 *
1992 * @INPUT: None
1993 *
1994 * @OUTPUT: character string containing formatted suspend/resume stats
1995 *
1996 * This ioctl is used to get suspend/resume stats formatted for display.
1997 * Currently it includes suspend/resume counts, wow wake up reasons, and
1998 * suspend fail reasons.
1999 *
2000 * @E.g: iwpriv wlan0 getSuspendStats
2001 * iwpriv wlan0 getSuspendStats
2002 *
2003 * Supported Feature: suspend/resume
2004 *
2005 * Usage: Internal
2006 *
2007 * </ioctl>
2008 */
2009#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302011/*
2012 * <ioctl>
2013 * getTdlsPeers - Get all TDLS peers.
2014 *
2015 * @INPUT: None
2016 *
2017 * @OUTPUT: Returns the MAC address of all the TDLS peers
2018 * wlan0 getTdlsPeers:
2019 * MAC Id cap up RSSI
2020 * ---------------------------------
2021 * 00:0a:f5:0e:bd:18 2 Y Y -44
2022 * 00:0a:f5:bf:0e:12 0 N N 0
2023 *
2024 * This IOCTL is used to get all TDLS peers.
2025 *
2026 * @E.g: iwpriv wlan0 getTdlsPeers
2027 *
2028 * Supported Feature: TDLS
2029 *
2030 * Usage: Internal/External
2031 *
2032 * </ioctl>
2033 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034#define WE_GET_TDLS_PEERS 8
2035#endif
2036#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +05302037/*
2038 * <ioctl>
2039 * getPMFInfo - get the PMF info of the connected session
2040 *
2041 * @INPUT: None
2042 *
2043 * @OUTPUT:
2044 * wlan0 getPMFInfo:
2045 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
2046 * Number of Unprotected Disassocs 0
2047 * Number of Unprotected Deauths 0
2048 *
2049 * This IOCTL is used to get the PMF stats/status of the current
2050 * connection.
2051 *
2052 * @e.g:iwpriv wlan0 getPMFInfo
2053 *
2054 * Supported Feature: PMF
2055 *
2056 * Usage: Internal/External
2057 *
2058 * </ioctl>
2059 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060#define WE_GET_11W_INFO 9
2061#endif
2062#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +05302063/*
2064 * <ioctl>
2065 * getIbssSTAs - get ibss sta info
2066 *
2067 * @INPUT: None
2068 *
2069 * @OUTPUT: Give the MAC of the IBSS STA
2070 * wlan0 getIbssSTAs:
2071 * 1 .8c:fd:f0:01:9c:bf
2072 *
2073 * This IOCTL is used to get ibss sta info
2074 *
2075 * @E.g: iwpriv wlan0 getIbssSTAs
2076 *
2077 * Supported Feature: IBSS
2078 *
2079 * Usage: Internal/External
2080 *
2081 * </ioctl>
2082 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002083#define WE_GET_IBSS_STA_INFO 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302084/*
2085 * <ioctl>
2086 * getphymode - Get the current phymode.
2087 *
2088 * @INPUT: None
2089 *
2090 * @OUTPUT: In phymode
2091 * wlan0 getphymode:AUTO MODE
2092 *
2093 * This IOCTL used to gets the current phymode.
2094 *
2095 * @E.g: iwpriv wlan0 getphymode
2096 *
2097 * Supported Feature: STA
2098 *
2099 * Usage: Internal/External
2100 *
2101 * </ioctl>
2102 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103#define WE_GET_PHYMODE 12
Naveen Rawat910726a2017-03-06 11:42:51 -08002104
2105/*
2106 * <ioctl>
2107 * getOemDataCap - Get the oem data caps.
2108 *
2109 * @INPUT: None
2110 *
2111 * @OUTPUT: oem data capability
2112 *
2113 * This IOCTL used to gets the current oem data cap.
2114 *
2115 * @E.g: iwpriv wlan0 getOemDataCap
2116 *
2117 * Usage: Internal/External
2118 *
2119 * </ioctl>
2120 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121#define WE_GET_OEM_DATA_CAP 13
Naveen Rawat910726a2017-03-06 11:42:51 -08002122
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302123/*
2124 * <ioctl>
2125 * getSNR - Enable SNR Monitoring
2126 *
2127 * @INPUT: None
2128 *
2129 * @OUTPUT: Signal strength/ratio
2130 * wlan0 getSNR:1
2131 *
2132 * This IOCTL is used to get ibss sta info
2133 *
2134 * @E.g: iwpriv wlan0 getSNR
2135 *
2136 * Supported Feature: STA
2137 *
2138 * Usage: Internal/External
2139 *
2140 * </ioctl>
2141 */
Naveen Rawat910726a2017-03-06 11:42:51 -08002142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +05302144#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145
2146/* Private ioctls and their sub-ioctls */
2147#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
Selvaraj, Sridharf7939832017-03-25 16:59:50 +05302148
2149/*
2150 * <ioctl>
2151 * reassoc - Trigger STA re-association to the connected AP
2152 *
2153 * @INPUT: None
2154 *
2155 * @OUTPUT: None
2156 *
2157 * This IOCTL is used to trigger STA reassociation to the connected AP.
2158 *
2159 * @E.g: iwpriv wlan0 reassoc
2160 *
2161 * Supported Feature: Roaming
2162 *
2163 * Usage: Internal
2164 *
2165 * </ioctl>
2166 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +05302168/*
2169 * <ioctl>
2170 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
2171 *
2172 * @INPUT: None
2173 *
2174 * @OUTPUT: print ibss peer in info logs
2175 * pPeerInfo->numIBSSPeers = 1
2176 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2177 *
2178 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
2179 * in info logs
2180 *
2181 * @E.g: iwpriv wlan0 ibssPeerInfoAll
2182 *
2183 * Supported Feature: IBSS
2184 *
2185 * Usage: Internal/External
2186 *
2187 * </ioctl>
2188 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002189#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -08002190/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002191#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002192#define WE_GET_FW_PROFILE_DATA 18
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +05302193/*
2194 * <ioctl>
2195 * stop_obss_scan - Stop obss scan
2196 *
2197 * @INPUT: None
2198 *
2199 * @OUTPUT: None
2200 *
2201 * This IOCTL is used to stop obss scan
2202 *
2203 * @E.g: iwpriv wlan0 stop_obss_scan
2204 *
2205 * Supported Feature: Scan
2206 *
2207 * Usage: Internal/External
2208 *
2209 * </ioctl>
2210 */
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002211#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212
2213/* Private ioctls and their sub-ioctls */
2214#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
2215
2216#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +05302217/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218
Manjeet Singhf82ed072016-07-08 11:40:00 +05302219#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220
Kabilan Kannan6894e6a2017-11-09 14:37:55 -08002221/* subcommand 5 is unused */
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302222
Abhishek Singh49b654e2016-12-01 16:11:17 +05302223/*
2224 * <ioctl>
2225 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
2226 *
2227 * @INPUT: staid
2228 *
2229 * @OUTPUT: print ibss peer corresponding to staid in info logs
2230 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2231 *
2232 * This IOCTL is used to print the specific ibss peers's MAC,
2233 * rate and RSSI in info logs
2234 *
2235 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
2236 * iwpriv wlan0 ibssPeerInfo 0
2237 *
2238 * Supported Feature: IBSS
2239 *
2240 * Usage: Internal/External
2241 *
2242 * </ioctl>
2243 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002244#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245#define WE_UNIT_TEST_CMD 7
2246
2247#define WE_MTRACE_DUMP_CMD 8
2248#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
2249
2250
2251#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2252#define WE_LED_FLASHING_PARAM 10
2253#endif
2254
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302255/*
2256 * <ioctl>
2257 * pm_clist - Increments the index value of the concurrent connection list
2258 * and update with the input parameters provided.
2259 *
2260 * @INPUT: Following 8 arguments:
2261 * @vdev_id: vdev id
2262 * @tx_streams: TX streams
2263 * @rx_streams: RX streams
2264 * @chain_mask: Chain mask
2265 * @type: vdev_type
2266 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2267 * @sub_type: vdev_subtype
2268 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2269 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2270 * @channel: Channel
2271 * @mac: Mac id
2272 *
2273 * @OUTPUT: None
2274 *
2275 * This IOCTL is used to increments the index value of the concurrent connection
2276 * list and update with the input parameters provided.
2277 *
2278 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
2279 * sub_type channel mac
2280 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
2281 *
2282 * Supported Feature: DBS
2283 *
2284 * Usage: Internal/External
2285 *
2286 * </ioctl>
2287 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302289
2290/*
2291 * <ioctl>
2292 * pm_dlist - Delete the index from the concurrent connection list that is
2293 * present in the given vdev_id.
2294 *
2295 * @INPUT: delete_all, vdev_id
2296 * @delete_all: delete all indices
2297 * @vdev_id: vdev id
2298 *
2299 * @OUTPUT: None
2300 *
2301 * This IOCTL is used to delete the index from the concurrent connection list
2302 * that is present in the given vdev_id.
2303 *
2304 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
2305 * iwpriv wlan0 pm_dlist 0 1
2306 *
2307 * Supported Feature: DBS
2308 *
2309 * Usage: Internal/External
2310 *
2311 * </ioctl>
2312 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302314
2315/*
2316 * <ioctl>
2317 * pm_dbs - Set dbs capability and system preference
2318 *
2319 * @INPUT: dbs, system_pref
2320 * @dbs: Value of DBS capability to be set
2321 * @system_pref: System preference
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002322 * 0:PM_THROUGHPUT 1: PM_POWERSAVE 2: PM_LATENCY
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302323 *
2324 * @OUTPUT: None
2325 *
2326 * This IOCTL is used to set dbs capability and system preference.
2327 *
2328 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
2329 * iwpriv wlan0 pm_dbs 1 0
2330 *
2331 * Supported Feature: DBS
2332 *
2333 * Usage: Internal/External
2334 *
2335 * </ioctl>
2336 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302338
2339/*
2340 * <ioctl>
2341 * pm_pcl - Set pcl for concurrency mode.
2342 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002343 * @INPUT: policy_mgr_con_mode
2344 * @policy_mgr_con_mode: concurrency mode for PCL table
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302345 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2346 *
2347 * @OUTPUT: None
2348 *
2349 * This IOCTL is used to set pcl for concurrency mode.
2350 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002351 * @E.g: iwpriv wlan0 pm_pcl policy_mgr_con_mode
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302352 * iwpriv wlan0 pm_pcl 0
2353 *
2354 * Supported Feature: DBS
2355 *
2356 * Usage: Internal/External
2357 *
2358 * </ioctl>
2359 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302361
2362/*
2363 * <ioctl>
2364 * pm_cinfo - Shows the concurrent connection list.
2365 *
2366 * @INPUT: None
2367 *
2368 * @OUTPUT: None
2369 *
2370 * This IOCTL is used to show the concurrent connection list.
2371 *
2372 * @E.g: iwpriv wlan0 pm_cinfo
2373 *
2374 * Supported Feature: DBS
2375 *
2376 * Usage: Internal/External
2377 *
2378 * </ioctl>
2379 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302381
2382/*
2383 * <ioctl>
2384 * pm_ulist - Updates the index value of the concurrent connection list
2385 * with the input parameters provided.
2386 *
2387 * @INPUT: Following 8 arguments:
2388 * @vdev_id: vdev id
2389 * @tx_streams: TX streams
2390 * @rx_streams: RX streams
2391 * @chain_mask: Chain mask
2392 * @type: vdev_type
2393 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2394 * @sub_type: vdev_subtype
2395 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2396 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2397 * @channel: Channel
2398 * @mac: Mac id
2399 *
2400 * @OUTPUT: None
2401 *
2402 * This IOCTL is used to updates the index value of the concurrent
2403 * connection list with the input parameters provided.
2404 *
2405 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
2406 * sub_type channel mac
2407 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
2408 *
2409 * Supported Feature: DBS
2410 *
2411 * Usage: Internal/External
2412 *
2413 * </ioctl>
2414 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302416
2417/*
2418 * <ioctl>
2419 * pm_query_action - Initiate actions needed on current connections as
2420 * per the channel provided.
2421 *
2422 * @INPUT: channel
2423 * @channel: Channel on which new connection will be.
2424 *
2425 * @OUTPUT: None
2426 *
2427 * This IOCTL is used to initiate actions needed on current connections
2428 * as per the channel provided.
2429 *
2430 * @E.g: iwpriv wlan0 pm_query_action channel
2431 * iwpriv wlan0 pm_query_action 6
2432 *
2433 * Supported Feature: DBS
2434 *
2435 * Usage: Internal/External
2436 *
2437 * </ioctl>
2438 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302440
2441/*
2442 * <ioctl>
2443 * pm_query_allow - Checks for allowed concurrency combination
2444 *
2445 * @INPUT: mode, channel, bandwidth
2446 * @mode: new connection mode
2447 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2448 * @channel: channel on which new connection is coming up
2449 * @bandwidth: Bandwidth requested by the connection
2450 * 0:None 1:5MHz 2:10MHz 3:20MHz
2451 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
2452 *
2453 * @OUTPUT: None
2454 *
2455 * This IOCTL is used to checks for allowed concurrency combination.
2456 *
2457 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
2458 * iwpriv wlan0 pm_query_allow 0 6 4
2459 *
2460 * Supported Feature: DBS
2461 *
2462 * Usage: Internal/External
2463 *
2464 * </ioctl>
2465 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302467
2468/*
2469 * <ioctl>
2470 * pm_run_scenario - Create scenario with number of connections provided.
2471 *
2472 * @INPUT: num_of_conn
2473 * @num_of_conn: the number of connections (values: 1~3)
2474 *
2475 * @OUTPUT: None
2476 *
2477 * This IOCTL is used to create scenario with the number of connections
2478 * provided.
2479 *
2480 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
2481 * iwpriv wlan0 pm_run_scenario 1
2482 *
2483 * Supported Feature: DBS
2484 *
2485 * Usage: Internal/External
2486 *
2487 * </ioctl>
2488 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302490
2491/*
2492 * <ioctl>
2493 * pm_set_hw_mode - Set hardware for single/dual mac.
2494 *
2495 * @INPUT: hw_mode
2496 * 0:single mac 1:dual mac
2497 *
2498 * @OUTPUT: None
2499 *
2500 * This IOCTL is used to set hardware for single/dual mac.
2501 *
2502 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
2503 * iwpriv wlan0 pm_set_hw_mode 1
2504 *
2505 * Supported Feature: DBS
2506 *
2507 * Usage: Internal/External
2508 *
2509 * </ioctl>
2510 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511#define WE_POLICY_SET_HW_MODE_CMD 20
2512
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302513/*
2514 * <ioctl>
Liangwei Dong2a7f2912018-02-07 17:08:17 +08002515 * ch_avoid - unit test SAP channel avoidance
2516 *
2517 * @INPUT: chan avoid ranges
2518 *
2519 * @OUTPUT: none
2520 *
2521 * This IOCTL is used to fake a channel avoidance event.
2522 * To test SAP/GO chan switch during chan avoid event process.
2523 *
2524 * @E.g: iwpriv wlan0 ch_avoid 2452 2462
2525 *
2526 * Supported Feature: SAP chan avoidance.
2527 *
2528 * Usage: Internal
2529 *
2530 * </ioctl>
2531 */
2532#define WE_SET_CHAN_AVOID 21
2533
2534/*
2535 * <ioctl>
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302536 * set_scan_cfg - Set dual MAC scan config parameters.
2537 *
2538 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2539 * @dbs: Value of DBS bit
2540 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2541 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2542 *
2543 * @OUTPUT: None
2544 *
2545 * This IOCTL is used to set the dual MAC scan config.
2546 *
2547 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2548 * single_mac_scan_with_dbs
2549 * iwpriv wlan0 set_scan_cfg 1 0 1
2550 *
2551 * Supported Feature: DBS
2552 *
2553 * Usage: Internal/External
2554 *
2555 * </ioctl>
2556 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302558
2559/*
2560 * <ioctl>
2561 * set_fw_mode_cfg - Sets the dual mac FW mode config
2562 *
2563 * @INPUT: dbs, dfs
2564 * @dbs: DBS bit
2565 * @dfs: Agile DFS bit
2566 *
2567 * @OUTPUT: None
2568 *
2569 * This IOCTL is used to set the dual mac FW mode config.
2570 *
2571 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2572 * iwpriv wlan0 set_fw_mode_cfg 1 1
2573 *
2574 * Supported Feature: DBS
2575 *
2576 * Usage: Internal/External
2577 *
2578 * </ioctl>
2579 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07002581#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582
2583#ifdef FEATURE_WLAN_TDLS
2584#undef MAX_VAR_ARGS
2585#define MAX_VAR_ARGS 11
2586#else
2587#undef MAX_VAR_ARGS
2588#define MAX_VAR_ARGS 9
2589#endif
2590
Jeff Johnson6fa1e012017-04-05 06:40:53 -07002591/*
2592 * <ioctl>
2593 * fips_test - Perform a FIPS test
2594 *
2595 * @INPUT: Binary representation of the following packed structure
2596 *
2597 * @OUTPUT: Binary representation of the following packed structure
2598 *
2599 * This IOCTL is used to perform FIPS certification testing
2600 *
2601 * @E.g: iwpriv wlan0 fips_test <test vector>
2602 *
2603 * iwpriv wlan0 fips_test <tbd>
2604 *
2605 * Supported Feature: FIPS
2606 *
2607 * Usage: Internal
2608 *
2609 * </ioctl>
2610 */
2611#define WLAN_PRIV_FIPS_TEST (SIOCIWFIRSTPRIV + 8)
2612
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613/* Private ioctls (with no sub-ioctls) */
2614/* note that they must be odd so that they have "get" semantics */
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302615/*
2616 * <ioctl>
2617 * addTspec - Add TSPEC for each AC
2618 *
2619 * @INPUT: 19 TSPEC params
2620 * @[arg0]: handle
2621 * @[arg1]: tid
2622 * @[arg2]: dir
2623 * @[arg3]: psb
2624 * @[arg4]: up
2625 * @[arg5]: nomMsduSize
2626 * @[arg6]: maxMsduSize
2627 * @[arg7]: minDataRate
2628 * @[arg8]: meanDataRate
2629 * @[arg9]: peakDataRate
2630 * @[arg10]: maxBurstSize
2631 * @[arg11]: minPhyRate
2632 * @[arg12]: sba
2633 * @[arg13]: minServiceIntv
2634 * @[arg14]: suspendIntv
2635 * @[arg15]: burstSizeDefn
2636 * @[arg16]: ackPolicy
2637 * @[arg17]: inactivityPeriod
2638 * @[arg18]: maxServiceIntv
2639 *
2640 * @OUTPUT: Success/Failure
2641 *
2642 * This IOCTL is used to add TSPEC for each AC.
2643 *
2644 * @E.g: iwpriv wlan0 addTspec <handle> <tid> <dir> <psb> <up> <nomMsduSize>
2645 * <maxMsduSize> <minDataRate> <meanDataRate>
2646 * <peakDataRate> <maxBurstSize> <minPhyRate>
2647 * <sba> <minServiceIntv> <suspendIntv>
2648 * <burstSizeDefn> <ackPolicy> <inactivityPeriod>
2649 * <maxServiceIntv>
2650 * iwpriv wlan0 addTspec 7001 6 2 1 6 0x80D0 0x80D0 0x14500 0x14500 0x14500
2651 * 0 0x5B8D80 0x2001 20 2000 0 0 0 2000
2652 * wlan0 addTspec:3
2653 *
2654 * Supported Feature: WMM
2655 *
2656 * Usage: Internal/External
2657 *
2658 * </ioctl>
2659 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302661/*
2662 * <ioctl>
2663 * delTspec - Delete TSPEC entry for each AC
2664 *
2665 * @INPUT: 1 TSPEC param
2666 * @[arg0]: handle
2667 *
2668 * @OUTPUT: Success/Failure
2669 *
2670 * This IOCTL is used to delete TSPEC entry for each AC.
2671 *
2672 * @E.g: iwpriv wlan0 delTspec <handle>
2673 * iwpriv wlan0 delTspec 7001
2674 * wlan0 delTspec:16
2675 *
2676 * Supported Feature: WMM
2677 *
2678 * Usage: Internal/External
2679 *
2680 * </ioctl>
2681 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302683/*
2684 * <ioctl>
2685 * getTspec - Get TSPEC entry for each AC
2686 *
2687 * @INPUT: 1 TSPEC param
2688 * @[arg0]: handle
2689 *
2690 * @OUTPUT: Success/Failure
2691 *
2692 * This IOCTL is used to get TSPEC entry for each AC.
2693 *
2694 * @E.g: iwpriv wlan0 getTspec <handle>
2695 * iwpriv wlan0 getTspec 7001
2696 * wlan0 delTspec:18
2697 *
2698 * Supported Feature: WMM
2699 *
2700 * Usage: Internal/External
2701 *
2702 * </ioctl>
2703 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706/* (SIOCIWFIRSTPRIV + 10) is currently unused */
2707/* (SIOCIWFIRSTPRIV + 12) is currently unused */
2708/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002709#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
2710#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711/* (SIOCIWFIRSTPRIV + 16) is currently unused */
2712/* (SIOCIWFIRSTPRIV + 17) is currently unused */
2713/* (SIOCIWFIRSTPRIV + 19) is currently unused */
2714
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716
2717/* Private ioctl for setting the host offload feature */
2718#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2719
2720/* Private ioctl to get the statistics */
2721#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2722
2723/* Private ioctl to set the Keep Alive Params */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302724/*
2725 * <ioctl>
2726 * setKeepAlive - Set the keep alive feature
2727 *
2728 * @INPUT: 28 bytes of information in the order of packet type, time period
2729 * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2730 *
2731 * @OUTPUT: None
2732 *
2733 * This IOCTL sets the keep alive feature to send either NULL
2734 * or unsolicited ARP response packets
2735 *
2736 * @E.g: iwpriv wlan0 setKeepAlive
2737 *
2738 * Supported Feature: STA
2739 *
2740 * Usage: Internal/External
2741 *
2742 * </ioctl>
2743 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2745
2746#ifdef WLAN_FEATURE_PACKET_FILTERING
2747/* Private ioctl to set the packet filtering params */
2748#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2749#endif
2750
2751
2752#ifdef FEATURE_WLAN_SCAN_PNO
2753/* Private ioctl to get the statistics */
2754#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2755#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302756/*
2757 * <ioctl>
2758 * SETBAND - Set the operational band
2759 *
2760 * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2761 *
2762 * @OUTPUT: None
2763 *
2764 * This IOCTL Set the operational band If the new band is different from the
2765 * current operational band, it aborts the pending scan requests, flushes
2766 * the existing scan results, and then change * the band capability
2767 *
2768 * @E.g: iwpriv wlan0 SETBAND <value>
2769 *
2770 * Supported Feature: STA
2771 *
2772 * Usage: Internal/External
2773 *
2774 * </ioctl>
2775 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
2777
Dustin Brown0cbc7572016-12-16 13:54:40 -08002778#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -08002779/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780
2781/* Private ioctls and their sub-ioctls */
2782#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
2783#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -07002784#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785#define WE_SET_FW_CRASH_INJECT 2
2786#endif
2787#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +05302788/* Private sub ioctl for enabling and setting histogram interval of profiling */
2789#define WE_ENABLE_FW_PROFILE 4
2790#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07002792/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002793#define WE_SET_WLAN_SUSPEND 6
2794#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002795
Dustin Brown8d2d0f52017-04-03 17:02:08 -07002796/*
2797 * <ioctl>
2798 * log_buffer - prints host/target related communication logs via dmesg
2799 *
2800 * @INPUT: Log Id, Count
2801 *
2802 * Log Id:
2803 * 0) HTC_CREDIT_HISTORY_LOG
2804 * 1) COMMAND_LOG,
2805 * 2) COMMAND_TX_CMP_LOG,
2806 * 3) MGMT_COMMAND_LOG,
2807 * 4) MGMT_COMMAND_TX_CMP_LOG,
2808 * 5) EVENT_LOG,
2809 * 6) RX_EVENT_LOG,
2810 * 7) MGMT_EVENT_LOG
2811 *
2812 * @OUTPUT: None
2813 *
2814 * @E.g:
2815 * # print up to 10 of the most recent records from HTC Credit History
2816 * iwpriv wlan0 log_buffer 0 10
2817 * # print up to 3 of the most recent records from Event Log
2818 * iwpriv wlan0 log_buffer 5 3
2819 *
2820 * Supported Feature: WLAN Trace
2821 *
2822 * Usage: Internal/External
2823 *
2824 * </ioctl>
2825 */
2826#define WE_LOG_BUFFER 8
2827
2828enum host_target_comm_log {
2829 HTC_CREDIT_HISTORY_LOG = 0,
2830 COMMAND_LOG,
2831 COMMAND_TX_CMP_LOG,
2832 MGMT_COMMAND_LOG,
2833 MGMT_COMMAND_TX_CMP_LOG,
2834 EVENT_LOG,
2835 RX_EVENT_LOG,
2836 MGMT_EVENT_LOG
2837};
2838
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839/* (SIOCIWFIRSTPRIV + 29) is currently unused */
2840
2841/* 802.11p IOCTL */
2842#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
2843
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302844/*
2845 * <ioctl>
2846 * getLinkSpeed - Gets the current link speed in Mbps
2847 *
2848 * @INPUT: None
2849 *
2850 * @OUTPUT: linkspeed in mbps
2851 * wlan0 getLinkSpeed:7
2852 *
2853 * This IOCTL is used get the current link speed in Mbps
2854 *
2855 * @E.g: iwpriv wlan0 getLinkSpeed
2856 *
2857 * Supported Feature: STA
2858 *
2859 * Usage: Internal/External
2860 *
2861 * </ioctl>
2862 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
2864
2865#define WLAN_STATS_INVALID 0
2866#define WLAN_STATS_RETRY_CNT 1
2867#define WLAN_STATS_MUL_RETRY_CNT 2
2868#define WLAN_STATS_TX_FRM_CNT 3
2869#define WLAN_STATS_RX_FRM_CNT 4
2870#define WLAN_STATS_FRM_DUP_CNT 5
2871#define WLAN_STATS_FAIL_CNT 6
2872#define WLAN_STATS_RTS_FAIL_CNT 7
2873#define WLAN_STATS_ACK_FAIL_CNT 8
2874#define WLAN_STATS_RTS_SUC_CNT 9
2875#define WLAN_STATS_RX_DISCARD_CNT 10
2876#define WLAN_STATS_RX_ERROR_CNT 11
2877#define WLAN_STATS_TX_BYTE_CNT 12
2878
2879#define WLAN_STATS_RX_BYTE_CNT 13
2880#define WLAN_STATS_RX_RATE 14
2881#define WLAN_STATS_TX_RATE 15
2882
2883#define WLAN_STATS_RX_UC_BYTE_CNT 16
2884#define WLAN_STATS_RX_MC_BYTE_CNT 17
2885#define WLAN_STATS_RX_BC_BYTE_CNT 18
2886#define WLAN_STATS_TX_UC_BYTE_CNT 19
2887#define WLAN_STATS_TX_MC_BYTE_CNT 20
2888#define WLAN_STATS_TX_BC_BYTE_CNT 21
2889
2890#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
2891 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
2892 *__p++ = __type; \
2893 *__p++ = __size; \
2894 memcpy(__p, __val, __size); \
2895 __p += __size; \
2896 __tlen += __size + 2; \
2897 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07002898 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 } \
2900 } while (0)
2901
2902#define VERSION_VALUE_MAX_LEN 32
2903
2904#define TX_PER_TRACKING_DEFAULT_RATIO 5
2905#define TX_PER_TRACKING_MAX_RATIO 10
2906#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
2907
2908#define WLAN_ADAPTER 0
2909#define P2P_ADAPTER 1
2910
2911/**
2912 * mem_alloc_copy_from_user_helper - copy from user helper
2913 * @wrqu_data: wireless extensions request data
2914 * @len: length of @wrqu_data
2915 *
2916 * Helper function to allocate buffer and copy user data.
2917 *
2918 * Return: On success return a pointer to a kernel buffer containing a
2919 * copy of the userspace data (with an additional NUL character
2920 * appended for safety). On failure return %NULL.
2921 */
2922void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2923{
2924 u8 *ptr = NULL;
2925
2926 /* in order to protect the code, an extra byte is post
2927 * appended to the buffer and the null termination is added.
2928 * However, when allocating (len+1) byte of memory, we need to
2929 * make sure that there is no uint overflow when doing
2930 * addition. In theory check len < UINT_MAX protects the uint
2931 * overflow. For wlan private ioctl, the buffer size is much
2932 * less than UINT_MAX, as a good guess, now, it is assumed
2933 * that the private command buffer size is no greater than 4K
2934 * (4096 bytes). So we use 4096 as the upper boundary for now.
2935 */
2936 if (len > MAX_USER_COMMAND_SIZE) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08002937 hdd_err("Invalid length: %zu max: %u",
2938 len, MAX_USER_COMMAND_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002939 return NULL;
2940 }
2941
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002942 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002944 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 return NULL;
2946 }
2947
2948 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002949 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002950 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 return NULL;
2952 }
2953 ptr[len] = '\0';
2954 return ptr;
2955}
2956
2957/**
2958 * hdd_priv_get_data() - Get pointer to ioctl private data
2959 * @p_priv_data: pointer to iw_point struct to be filled
2960 * @wrqu: Pointer to IOCTL Data received from userspace
2961 *
2962 * Helper function to get compatible struct iw_point passed to ioctl
2963 *
2964 * Return - 0 if p_priv_data successfully filled, error otherwise
2965 */
2966int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2967{
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002968 if ((NULL == p_priv_data) || (NULL == wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002969 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002970
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971#ifdef CONFIG_COMPAT
2972 if (is_compat_task()) {
2973 struct compat_iw_point *p_compat_priv_data;
2974
2975 /* Compat task:
2976 * typecast to compat structure and copy the members.
2977 */
2978 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2979
2980 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2981 p_priv_data->length = p_compat_priv_data->length;
2982 p_priv_data->flags = p_compat_priv_data->flags;
2983 } else {
2984#endif /* #ifdef CONFIG_COMPAT */
2985
2986 /* Non compat task: directly copy the structure. */
2987 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
2988
2989#ifdef CONFIG_COMPAT
2990 }
2991#endif /* #ifdef CONFIG_COMPAT */
2992
2993 return 0;
2994}
2995
Jeff Johnson441e1f72017-02-07 08:50:49 -08002996static int hdd_check_wext_control(enum hdd_wext_control wext_control,
2997 struct iw_request_info *info)
2998{
2999 switch (wext_control) {
3000 default:
3001 case hdd_wext_disabled:
3002 hdd_err("Rejecting disabled ioctl %x", info->cmd);
3003 return -ENOTSUPP;
3004 case hdd_wext_deprecated:
3005 hdd_warn("Using deprecated ioctl %x", info->cmd);
3006 return 0;
3007 case hdd_wext_enabled:
3008 return 0;
3009 }
3010}
3011
Jeff Johnson82797b62017-08-11 15:31:27 -07003012int hdd_check_standard_wext_control(struct hdd_context *hdd_ctx,
Jeff Johnson441e1f72017-02-07 08:50:49 -08003013 struct iw_request_info *info)
3014{
3015 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
3016 info);
3017}
3018
Jeff Johnson82797b62017-08-11 15:31:27 -07003019int hdd_check_private_wext_control(struct hdd_context *hdd_ctx,
Jeff Johnson441e1f72017-02-07 08:50:49 -08003020 struct iw_request_info *info)
3021{
3022 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
3023 info);
3024}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025
3026/**
3027 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003028 * @adapter: Pointer to the hdd adapter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 * @length: Size of the data copied
3030 * @buffer: Pointer to char buffer.
3031 * @buf_len: Length of the char buffer.
3032 *
3033 * This function called when the "iwpriv wlan0 get_stats" command is given.
3034 * It used to collect the txrx stats when the device is configured in SAP mode.
3035 *
3036 * Return - none
3037 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003038void hdd_wlan_get_stats(struct hdd_adapter *adapter, uint16_t *length,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 char *buffer, uint16_t buf_len)
3040{
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003041 struct hdd_tx_rx_stats *stats = &adapter->hdd_stats.tx_rx_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 uint32_t len = 0;
3043 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
3044 uint32_t total_rx_delv = 0, total_rx_refused = 0;
3045 int i = 0;
3046
3047 for (; i < NUM_CPUS; i++) {
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003048 total_rx_pkt += stats->rx_packets[i];
3049 total_rx_dropped += stats->rx_dropped[i];
3050 total_rx_delv += stats->rx_delivered[i];
3051 total_rx_refused += stats->rx_refused[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 }
3053
3054 len = scnprintf(buffer, buf_len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003055 "\nTransmit[%lu] - "
Mohit Khannad0b63f52017-02-18 18:05:52 -08003056 "called %u, dropped %u orphan %u,"
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003057 "\n[dropped] BK %u, BE %u, VI %u, VO %u"
3058 "\n[classified] BK %u, BE %u, VI %u, VO %u"
3059 "\n\nReceive[%lu] - "
3060 "packets %u, dropped %u, delivered %u, refused %u"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061 "\n",
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003062 qdf_system_ticks(),
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003063 stats->tx_called,
3064 stats->tx_dropped,
3065 stats->tx_orphaned,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003067 stats->tx_dropped_ac[SME_AC_BK],
3068 stats->tx_dropped_ac[SME_AC_BE],
3069 stats->tx_dropped_ac[SME_AC_VI],
3070 stats->tx_dropped_ac[SME_AC_VO],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003072 stats->tx_classified_ac[SME_AC_BK],
3073 stats->tx_classified_ac[SME_AC_BE],
3074 stats->tx_classified_ac[SME_AC_VI],
3075 stats->tx_classified_ac[SME_AC_VO],
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003076 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
3078 );
3079
3080 for (i = 0; i < NUM_CPUS; i++) {
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003081 if (stats->rx_packets[i] == 0)
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003082 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003084 "Rx CPU[%d]:"
3085 "packets %u, dropped %u, delivered %u, refused %u\n",
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003086 i, stats->rx_packets[i], stats->rx_dropped[i],
3087 stats->rx_delivered[i], stats->rx_refused[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088 }
3089
3090 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003091 "\nTX_FLOW"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 "\nCurrent status: %s"
3093 "\ntx-flow timer start count %u"
3094 "\npause count %u, unpause count %u",
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003095 (stats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
3096 stats->txflow_timer_cnt,
3097 stats->txflow_pause_cnt,
3098 stats->txflow_unpause_cnt);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099
Leo Changfdb45c32016-10-28 11:09:23 -07003100 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
Jeff Johnson1b780e42017-10-31 14:11:45 -07003101 adapter->session_id, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 *length = len + 1;
3103}
3104
3105/**
Dustin Brownd9322482017-01-09 12:46:03 -08003106 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
3107 * @hdd_ctx: The Hdd context owning the stats to be written
3108 * @buffer: The char buffer to write to
3109 * @max_len: The maximum number of chars to write
3110 *
3111 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
3112 *
3113 * Return - length of written content, negative number on error
3114 */
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003115static int wlan_hdd_write_suspend_resume_stats(struct hdd_context *hdd_ctx,
Dustin Brownd9322482017-01-09 12:46:03 -08003116 char *buffer, uint16_t max_len)
3117{
3118 QDF_STATUS status;
3119 struct suspend_resume_stats *sr_stats;
3120 struct sir_wake_lock_stats wow_stats;
3121
3122 sr_stats = &hdd_ctx->suspend_resume_stats;
3123
3124 status = wma_get_wakelock_stats(&wow_stats);
3125 if (QDF_IS_STATUS_ERROR(status)) {
3126 hdd_err("Failed to get WoW stats");
3127 return qdf_status_to_os_return(status);
3128 }
3129
3130 return scnprintf(buffer, max_len,
3131 "\n"
3132 "Suspends: %u\n"
3133 "Resumes: %u\n"
3134 "\n"
3135 "Suspend Fail Reasons\n"
3136 "\tIPA: %u\n"
3137 "\tRadar: %u\n"
3138 "\tRoam: %u\n"
3139 "\tScan: %u\n"
3140 "\tInitial Wakeup: %u\n"
3141 "\n"
3142 "WoW Wake Reasons\n"
3143 "\tunicast: %u\n"
3144 "\tbroadcast: %u\n"
3145 "\tIPv4 multicast: %u\n"
3146 "\tIPv6 multicast: %u\n"
3147 "\tIPv6 multicast RA: %u\n"
3148 "\tIPv6 multicast NS: %u\n"
3149 "\tIPv6 multicast NA: %u\n"
3150 "\tICMPv4: %u\n"
3151 "\tICMPv6: %u\n"
3152 "\tRSSI Breach: %u\n"
3153 "\tLow RSSI: %u\n"
3154 "\tG-Scan: %u\n"
3155 "\tPNO Complete: %u\n"
3156 "\tPNO Match: %u\n",
3157 sr_stats->suspends,
3158 sr_stats->resumes,
3159 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
3160 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
3161 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
3162 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
3163 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
3164 wow_stats.wow_ucast_wake_up_count,
3165 wow_stats.wow_bcast_wake_up_count,
3166 wow_stats.wow_ipv4_mcast_wake_up_count,
3167 wow_stats.wow_ipv6_mcast_wake_up_count,
3168 wow_stats.wow_ipv6_mcast_ra_stats,
3169 wow_stats.wow_ipv6_mcast_ns_stats,
3170 wow_stats.wow_ipv6_mcast_na_stats,
3171 wow_stats.wow_icmpv4_count,
3172 wow_stats.wow_icmpv6_count,
3173 wow_stats.wow_rssi_breach_wake_up_count,
3174 wow_stats.wow_low_rssi_wake_up_count,
3175 wow_stats.wow_gscan_wake_up_count,
3176 wow_stats.wow_pno_complete_wake_up_count,
3177 wow_stats.wow_pno_match_wake_up_count);
3178}
3179
3180/**
Govind Singha471e5e2015-10-12 17:11:14 +05303181 * hdd_wlan_list_fw_profile() - Get fw profiling points
3182 * @length: Size of the data copied
3183 * @buffer: Pointer to char buffer.
3184 * @buf_len: Length of the char buffer.
3185 *
3186 * This function called when the "iwpriv wlan0 listProfile" command is given.
3187 * It is used to get the supported profiling points in FW.
3188 *
3189 * Return - none
3190 */
3191void hdd_wlan_list_fw_profile(uint16_t *length,
3192 char *buffer, uint16_t buf_len)
3193{
3194 uint32_t len = 0;
3195
3196 len = scnprintf(buffer, buf_len,
3197 "PROF_CPU_IDLE: %u\n"
3198 "PROF_PPDU_PROC: %u\n"
3199 "PROF_PPDU_POST: %u\n"
3200 "PROF_HTT_TX_INPUT: %u\n"
3201 "PROF_MSDU_ENQ: %u\n"
3202 "PROF_PPDU_POST_HAL: %u\n"
3203 "PROF_COMPUTE_TX_TIME: %u\n",
3204 PROF_CPU_IDLE,
3205 PROF_PPDU_PROC,
3206 PROF_PPDU_POST,
3207 PROF_HTT_TX_INPUT,
3208 PROF_MSDU_ENQ,
3209 PROF_PPDU_POST_HAL,
3210 PROF_COMPUTE_TX_TIME);
3211
3212 *length = len + 1;
3213}
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003214/**
3215 * hdd_display_stats_help() - print statistics help
3216 *
3217 * Return: none
3218 */
3219void hdd_display_stats_help(void)
3220{
3221 hdd_err("iwpriv wlan0 dumpStats [option] - dump statistics");
3222 hdd_err("iwpriv wlan0 clearStats [option] - clear statistics");
3223 hdd_err("options:");
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003224 hdd_err(" 1 -- TXRX PATH statistics");
3225 hdd_err(" 2 -- TXRX HIST statistics");
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003226 hdd_err(" 3 -- TSO statistics");
3227 hdd_err(" 4 -- Network queue statistics");
3228 hdd_err(" 5 -- Flow control statistics");
3229 hdd_err(" 6 -- Per Layer statistics");
3230 hdd_err(" 7 -- Copy engine interrupt statistics");
3231 hdd_err(" 8 -- LRO statistics");
3232 hdd_err(" 9 -- NAPI statistics");
3233}
Govind Singha471e5e2015-10-12 17:11:14 +05303234
3235/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 * hdd_wlan_dump_stats() - display dump Stats
3237 * @adapter: adapter handle
3238 * @value: value from user
3239 *
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003240 * Return: 0 => success, error code on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07003242int hdd_wlan_dump_stats(struct hdd_adapter *adapter, int value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243{
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003244 int ret = 0;
3245 QDF_STATUS status;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003246 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247
3248 switch (value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003249 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
3251 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003252 case CDP_HDD_NETIF_OPER_HISTORY:
Mohit Khannaca4173b2017-09-12 21:52:19 -07003253 wlan_hdd_display_netif_queue_history
3254 (hdd_ctx,
3255 QDF_STATS_VERBOSITY_LEVEL_HIGH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003257 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05303258 hdd_display_hif_stats();
3259 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003260 case CDP_LRO_STATS:
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003261 hdd_lro_display_stats(hdd_ctx);
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003262 case CDP_NAPI_STATS:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003263 if (hdd_display_napi_stats()) {
3264 hdd_err("error displaying napi stats");
3265 ret = EFAULT;
3266 }
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003267 break;
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +05303268 case CDP_DISCONNECT_STATS:
3269 sme_display_disconnect_stats(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07003270 adapter->session_id);
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +05303271 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 default:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003273 status = cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC),
Mohit Khannaca4173b2017-09-12 21:52:19 -07003274 value,
3275 QDF_STATS_VERBOSITY_LEVEL_HIGH);
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003276 if (status == QDF_STATUS_E_INVAL) {
3277 hdd_display_stats_help();
3278 ret = EINVAL;
3279 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 break;
3281 }
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003282 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283}
3284
3285/**
3286 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303287 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 * @wrqu: Pointer to IOCTL REQUEST Data.
3289 * @extra: Pointer to destination buffer
3290 *
3291 * This function is used to get Wlan Driver, Firmware, & Hardware
3292 * Version information. If @wrqu and @extra are specified, then the
3293 * version string is returned. Otherwise it is simply printed to the
3294 * kernel log.
3295 *
3296 * Return: none
3297 */
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003298void hdd_wlan_get_version(struct hdd_context *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 char *extra)
3300{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303301 tSirVersionString wcnss_sw_version;
3302 const char *swversion;
3303 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003304 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303306 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003307 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 goto error;
3309 }
3310
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303311 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
3312 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303314 swversion = wcnss_sw_version;
3315 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
3316 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
3317 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
3318 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003319 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303321 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322
3323 if (wrqu && extra) {
3324 wrqu->data.length =
3325 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003326 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003328 msp_id, mspid, siid, crmid,
3329 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003331 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003333 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 }
3335error:
3336 return;
3337}
3338
3339/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003340 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003341 * @adapter: Adapter upon which the IBSS client is active
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003342 * @staIdx: Station index of the IBSS peer
3343 *
3344 * Return: a pointer to the MAC address of the IBSS peer if the peer is
3345 * found, otherwise %NULL.
3346 */
3347struct qdf_mac_addr *
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003348hdd_wlan_get_ibss_mac_addr_from_staid(struct hdd_adapter *adapter,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003349 uint8_t staIdx)
3350{
3351 uint8_t idx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003352 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003353
Naveen Rawatc45d1622016-07-05 12:20:09 -07003354 for (idx = 0; idx < MAX_PEERS; idx++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003355 if (HDD_WLAN_INVALID_STA_ID !=
Jeff Johnsond377dce2017-10-04 10:32:42 -07003356 sta_ctx->conn_info.staId[idx] &&
3357 staIdx == sta_ctx->conn_info.staId[idx]) {
3358 return &sta_ctx->conn_info.peerMacAddress[idx];
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003359 }
3360 }
3361 return NULL;
3362}
3363
3364/**
3365 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003366 * @adapter: Adapter upon which the IBSS client is active
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003367 * @staIdx: Station index of the IBSS peer
3368 *
3369 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
3370 * otherwise an appropriate QDF_STATUS_E_* failure code.
3371 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003372static QDF_STATUS hdd_wlan_get_ibss_peer_info(struct hdd_adapter *adapter,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003373 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003374{
3375 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003376 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
3377 struct hdd_station_ctx *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003378 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003379
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003380 INIT_COMPLETION(adapter->ibss_peer_info_comp);
3381 status = sme_request_ibss_peer_info(hHal, adapter,
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003382 hdd_get_ibss_peer_info_cb,
3383 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003384
3385 if (QDF_STATUS_SUCCESS == status) {
3386 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003387
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003388 rc = wait_for_completion_timeout
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003389 (&adapter->ibss_peer_info_comp,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003390 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3391 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003392 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003393 return QDF_STATUS_E_FAILURE;
3394 }
3395
3396 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003397 hdd_debug("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003398 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003399 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3400 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003401
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003402 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
3403 mac_addr, sizeof(mac_addr));
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003404 hdd_debug("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003405 mac_addr, (int)tx_rate,
3406 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003407 }
3408 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003409 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003410 }
3411
3412 return status;
3413}
3414
3415/**
3416 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003417 * @adapter: Adapter upon which the IBSS clients are active
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003418 *
3419 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
3420 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
3421 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003422static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(struct hdd_adapter *adapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003423{
3424 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003425 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
3426 struct hdd_station_ctx *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003427 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003428 int i;
3429
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003430 INIT_COMPLETION(adapter->ibss_peer_info_comp);
3431 status = sme_request_ibss_peer_info(hHal, adapter,
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003432 hdd_get_ibss_peer_info_cb,
3433 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003434
3435 if (QDF_STATUS_SUCCESS == status) {
3436 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003437
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003438 rc = wait_for_completion_timeout
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003439 (&adapter->ibss_peer_info_comp,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003440 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3441 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003442 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003443 return QDF_STATUS_E_FAILURE;
3444 }
3445
3446 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003447 hdd_debug("pPeerInfo->numIBSSPeers = %d ",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003448 (int)pPeerInfo->numPeers);
3449 for (i = 0; i < pPeerInfo->numPeers; i++) {
3450 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3451 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003452
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003453 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
3454 qdf_mem_copy(mac_addr,
3455 pPeerInfo->peerInfoParams[i].mac_addr,
3456 sizeof(mac_addr));
3457
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003458 hdd_debug(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003459 mac_addr, (int)tx_rate,
3460 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003461 }
3462 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003463 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003464 }
3465
3466 return status;
3467}
3468
3469/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 * hdd_wlan_get_freq() - Convert channel to frequency
3471 * @channel: channel to be converted
3472 * @pfreq: where to store the frequency
3473 *
3474 * Return: 1 on success, otherwise a negative errno
3475 */
3476int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
3477{
3478 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003479
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 if (channel > 0) {
3481 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
3482 if (channel == freq_chan_map[i].chan) {
3483 *pfreq = freq_chan_map[i].freq;
3484 return 1;
3485 }
3486 }
3487 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003488 hdd_err("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 return -EINVAL;
3490}
3491
Jeff Johnsona5444942017-01-23 13:11:08 -08003492struct rssi_priv {
3493 int8_t rssi;
3494};
3495
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496/**
3497 * hdd_get_rssi_cb() - "Get RSSI" callback function
3498 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08003499 * @sta_id: ID of the station
3500 * @context: opaque context originally passed to SME. HDD always passes
3501 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502 *
3503 * Return: None
3504 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003505static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506{
Jeff Johnsona5444942017-01-23 13:11:08 -08003507 struct hdd_request *request;
3508 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509
Jeff Johnsona5444942017-01-23 13:11:08 -08003510 request = hdd_request_get(context);
3511 if (!request) {
3512 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 return;
3514 }
3515
Jeff Johnsona5444942017-01-23 13:11:08 -08003516 priv = hdd_request_priv(request);
3517 priv->rssi = rssi;
3518 hdd_request_complete(request);
3519 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520}
3521
3522/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 * wlan_hdd_get_rssi() - Get the current RSSI
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003524 * @adapter: adapter upon which the measurement is requested
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 * @rssi_value: pointer to where the RSSI should be returned
3526 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303527 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003529QDF_STATUS wlan_hdd_get_rssi(struct hdd_adapter *adapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530{
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003531 struct hdd_context *hdd_ctx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003532 struct hdd_station_ctx *sta_ctx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303533 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08003534 int ret;
3535 void *cookie;
3536 struct hdd_request *request;
3537 struct rssi_priv *priv;
3538 static const struct hdd_request_params params = {
3539 .priv_size = sizeof(*priv),
3540 .timeout_ms = WLAN_WAIT_TIME_STATS,
3541 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003542
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003543 if (NULL == adapter) {
3544 hdd_err("Invalid context, adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303545 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 }
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +05303547 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003548 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3549 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 /* return a cached value */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003551 *rssi_value = adapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303552 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 }
3554
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003555 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003556 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557
Jeff Johnsond377dce2017-10-04 10:32:42 -07003558 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003559 hdd_debug("Not associated!, rssi on disconnect %d",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003560 adapter->rssi_on_disconnect);
3561 *rssi_value = adapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303562 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 }
3564
Jeff Johnson690fe952017-10-25 11:48:39 -07003565 if (sta_ctx->hdd_reassoc_scenario) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003566 hdd_debug("Roaming in progress, return cached RSSI");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003567 *rssi_value = adapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303568 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 }
3570
Jeff Johnsona5444942017-01-23 13:11:08 -08003571 request = hdd_request_alloc(&params);
3572 if (!request) {
3573 hdd_err("Request allocation failure, return cached RSSI");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003574 *rssi_value = adapter->rssi;
Jeff Johnsona5444942017-01-23 13:11:08 -08003575 return QDF_STATUS_SUCCESS;
3576 }
3577 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003579 hstatus = sme_get_rssi(hdd_ctx->hHal, hdd_get_rssi_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003580 sta_ctx->conn_info.staId[0],
3581 sta_ctx->conn_info.bssId, adapter->rssi,
Jeff Johnson8bd23352017-09-26 11:39:24 -07003582 cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303583 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003584 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 /* we'll returned a cached value below */
3586 } else {
3587 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08003588 ret = hdd_request_wait_for_response(request);
3589 if (ret) {
3590 hdd_warn("SME timed out while retrieving RSSI");
3591 /* we'll returned a cached value below */
3592 } else {
3593 /* update the adapter with the fresh results */
3594 priv = hdd_request_priv(request);
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +05303595 /*
3596 * update rssi only if its valid else return previous
3597 * valid rssi.
3598 */
3599 if (priv->rssi)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003600 adapter->rssi = priv->rssi;
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +05303601
3602 /*
3603 * for new connection there might be no valid previous
3604 * RSSI.
3605 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003606 if (!adapter->rssi) {
3607 hdd_get_rssi_snr_by_bssid(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003608 sta_ctx->conn_info.bssId.bytes,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003609 &adapter->rssi, NULL);
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +05303610 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 }
3612 }
3613
Jeff Johnsona5444942017-01-23 13:11:08 -08003614 /*
3615 * either we never sent a request, we sent a request and
3616 * received a response or we sent a request and timed out.
3617 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003619 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003621 *rssi_value = adapter->rssi;
Rajeev Kumar Sirasanagandla5bacf7f2017-05-10 15:31:40 +05303622 hdd_debug("RSSI = %d", *rssi_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303624 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625}
3626
Jeff Johnson002cb972017-01-23 14:59:07 -08003627struct snr_priv {
3628 int8_t snr;
3629};
3630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08003632 * hdd_get_snr_cb() - "Get SNR" callback function
3633 * @snr: Current SNR of the station
Jeff Johnson002cb972017-01-23 14:59:07 -08003634 * @sta_id: ID of the station
3635 * @context: opaque context originally passed to SME. HDD always passes
3636 * a cookie for the request context
Jeff Johnson8eaff302017-01-23 11:03:31 -08003637 *
3638 * Return: None
3639 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003640static void hdd_get_snr_cb(int8_t snr, uint32_t sta_id, void *context)
Jeff Johnson8eaff302017-01-23 11:03:31 -08003641{
Jeff Johnson002cb972017-01-23 14:59:07 -08003642 struct hdd_request *request;
3643 struct snr_priv *priv;
Jeff Johnson8eaff302017-01-23 11:03:31 -08003644
Jeff Johnson002cb972017-01-23 14:59:07 -08003645 request = hdd_request_get(context);
3646 if (!request) {
3647 hdd_err("Obsolete request");
Jeff Johnson8eaff302017-01-23 11:03:31 -08003648 return;
3649 }
3650
Jeff Johnson002cb972017-01-23 14:59:07 -08003651 /* propagate response back to requesting thread */
3652 priv = hdd_request_priv(request);
3653 priv->snr = snr;
3654 hdd_request_complete(request);
3655 hdd_request_put(request);
Jeff Johnson8eaff302017-01-23 11:03:31 -08003656}
3657
3658/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659 * wlan_hdd_get_snr() - Get the current SNR
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003660 * @adapter: adapter upon which the measurement is requested
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 * @snr: pointer to where the SNR should be returned
3662 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303663 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003665QDF_STATUS wlan_hdd_get_snr(struct hdd_adapter *adapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666{
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003667 struct hdd_context *hdd_ctx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003668 struct hdd_station_ctx *sta_ctx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303669 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 int valid;
Jeff Johnson002cb972017-01-23 14:59:07 -08003671 int ret;
3672 void *cookie;
3673 struct hdd_request *request;
3674 struct snr_priv *priv;
3675 static const struct hdd_request_params params = {
3676 .priv_size = sizeof(*priv),
3677 .timeout_ms = WLAN_WAIT_TIME_STATS,
3678 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303680 ENTER();
3681
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003682 if (NULL == adapter) {
3683 hdd_err("Invalid context, adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303684 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 }
3686
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003687 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003689 valid = wlan_hdd_validate_context(hdd_ctx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303690 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303691 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692
Jeff Johnsond377dce2017-10-04 10:32:42 -07003693 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694
Jeff Johnson002cb972017-01-23 14:59:07 -08003695 request = hdd_request_alloc(&params);
3696 if (!request) {
3697 hdd_err("Request allocation failure");
3698 return QDF_STATUS_E_FAULT;
3699 }
3700 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003702 hstatus = sme_get_snr(hdd_ctx->hHal, hdd_get_snr_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003703 sta_ctx->conn_info.staId[0],
3704 sta_ctx->conn_info.bssId, cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303705 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003706 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707 /* we'll returned a cached value below */
3708 } else {
3709 /* request was sent -- wait for the response */
Jeff Johnson002cb972017-01-23 14:59:07 -08003710 ret = hdd_request_wait_for_response(request);
3711 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003712 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713 /* we'll now returned a cached value below */
Jeff Johnson002cb972017-01-23 14:59:07 -08003714 } else {
3715 /* update the adapter with the fresh results */
3716 priv = hdd_request_priv(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003717 adapter->snr = priv->snr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718 }
3719 }
3720
Jeff Johnson002cb972017-01-23 14:59:07 -08003721 /*
3722 * either we never sent a request, we sent a request and
3723 * received a response or we sent a request and timed out.
3724 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003726 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003728 *snr = adapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303729 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303730 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731}
3732
Jeff Johnsone50427c2017-01-26 10:54:49 -08003733struct linkspeed_priv {
3734 tSirLinkSpeedInfo linkspeed_info;
3735};
3736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737static void
Jeff Johnsone50427c2017-01-26 10:54:49 -08003738hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739{
Jeff Johnsone50427c2017-01-26 10:54:49 -08003740 struct hdd_request *request;
3741 struct linkspeed_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003742
Jeff Johnsone50427c2017-01-26 10:54:49 -08003743 if (!linkspeed_info) {
3744 hdd_err("NULL linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 return;
3746 }
3747
Jeff Johnsone50427c2017-01-26 10:54:49 -08003748 request = hdd_request_get(context);
3749 if (!request) {
3750 hdd_err("Obsolete request");
3751 return;
3752 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753
Jeff Johnsone50427c2017-01-26 10:54:49 -08003754 priv = hdd_request_priv(request);
3755 priv->linkspeed_info = *linkspeed_info;
3756 hdd_request_complete(request);
3757 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758}
3759
Jeff Johnson3d278b02017-08-29 14:17:47 -07003760int wlan_hdd_get_linkspeed_for_peermac(struct hdd_adapter *adapter,
Jeff Johnsone50427c2017-01-26 10:54:49 -08003761 struct qdf_mac_addr *mac_address,
3762 uint32_t *linkspeed)
3763{
3764 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303765 QDF_STATUS status;
Jeff Johnsone50427c2017-01-26 10:54:49 -08003766 void *cookie;
3767 tSirLinkSpeedInfo *linkspeed_info;
3768 struct hdd_request *request;
3769 struct linkspeed_priv *priv;
3770 static const struct hdd_request_params params = {
3771 .priv_size = sizeof(*priv),
3772 .timeout_ms = WLAN_WAIT_TIME_STATS,
3773 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774
Jeff Johnsone50427c2017-01-26 10:54:49 -08003775 if ((!adapter) || (!linkspeed)) {
3776 hdd_err("NULL argument");
3777 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779
Jeff Johnsone50427c2017-01-26 10:54:49 -08003780 request = hdd_request_alloc(&params);
3781 if (!request) {
3782 hdd_err("Request allocation failure");
3783 ret = -ENOMEM;
3784 goto return_cached_value;
3785 }
3786
3787 cookie = hdd_request_cookie(request);
3788 priv = hdd_request_priv(request);
3789
3790 linkspeed_info = &priv->linkspeed_info;
3791 qdf_copy_macaddr(&linkspeed_info->peer_macaddr, mac_address);
3792 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(adapter),
3793 linkspeed_info,
3794 cookie, hdd_get_link_speed_cb);
3795 if (QDF_IS_STATUS_ERROR(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003796 hdd_err("Unable to retrieve statistics for link speed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003797 ret = qdf_status_to_os_return(status);
3798 goto cleanup;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 }
Jeff Johnsone50427c2017-01-26 10:54:49 -08003800 ret = hdd_request_wait_for_response(request);
3801 if (ret) {
3802 hdd_err("SME timed out while retrieving link speed");
3803 goto cleanup;
3804 }
3805 adapter->estimated_linkspeed = linkspeed_info->estLinkSpeed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806
Jeff Johnsone50427c2017-01-26 10:54:49 -08003807cleanup:
3808 /*
3809 * either we never sent a request, we sent a request and
3810 * received a response or we sent a request and timed out.
3811 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 */
Jeff Johnsone50427c2017-01-26 10:54:49 -08003813 hdd_request_put(request);
3814
3815return_cached_value:
3816 *linkspeed = adapter->estimated_linkspeed;
3817
3818 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819}
3820
Jeff Johnson4e632672017-10-03 11:40:51 -07003821int wlan_hdd_get_link_speed(struct hdd_adapter *adapter, uint32_t *link_speed)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822{
Jeff Johnson4e632672017-10-03 11:40:51 -07003823 struct hdd_context *hddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003824 struct hdd_station_ctx *hdd_stactx =
Jeff Johnson4e632672017-10-03 11:40:51 -07003825 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 int ret;
3827
3828 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05303829 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303832 /* Linkspeed is allowed only for P2P mode */
Jeff Johnson4e632672017-10-03 11:40:51 -07003833 if (adapter->device_mode != QDF_P2P_CLIENT_MODE) {
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303834 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
Jeff Johnson4e632672017-10-03 11:40:51 -07003835 hdd_device_mode_to_string(adapter->device_mode),
3836 adapter->device_mode);
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303837 return -ENOTSUPP;
3838 }
3839
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
3841 /* we are not connected so we don't have a classAstats */
3842 *link_speed = 0;
3843 } else {
Anurag Chouhan6d760662016-02-20 16:05:43 +05303844 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845
Anurag Chouhanc5548422016-02-24 18:33:27 +05303846 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003847
Jeff Johnson4e632672017-10-03 11:40:51 -07003848 ret = wlan_hdd_get_linkspeed_for_peermac(adapter, &bssid,
Jeff Johnsone50427c2017-01-26 10:54:49 -08003849 link_speed);
3850 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003851 hdd_err("Unable to retrieve SME linkspeed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003852 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 /* linkspeed in units of 500 kbps */
3855 *link_speed = (*link_speed) / 500;
3856 }
3857 return 0;
3858}
3859
Will Huang496b36c2017-07-11 16:38:50 +08003860struct peer_rssi_priv {
3861 struct sir_peer_sta_info peer_sta_info;
3862};
3863
3864/**
3865 * hdd_get_peer_rssi_cb() - get peer station's rssi callback
3866 * @sta_rssi: pointer of peer information
3867 * @context: get rssi callback context
3868 *
3869 * This function will fill rssi information to rssi priv
3870 * adapter
3871 *
3872 */
3873static void hdd_get_peer_rssi_cb(struct sir_peer_info_resp *sta_rssi,
3874 void *context)
3875{
3876 struct hdd_request *request;
3877 struct peer_rssi_priv *priv;
3878 struct sir_peer_info *rssi_info;
3879 uint8_t peer_num;
3880
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05303881 if ((!sta_rssi)) {
3882 hdd_err("Bad param, sta_rssi [%pK]", sta_rssi);
Will Huang496b36c2017-07-11 16:38:50 +08003883 return;
3884 }
3885
3886 request = hdd_request_get(context);
3887 if (!request) {
3888 hdd_err("Obsolete request");
3889 return;
3890 }
3891
3892 priv = hdd_request_priv(request);
3893
3894 peer_num = sta_rssi->count;
3895 rssi_info = sta_rssi->info;
3896
3897 hdd_debug("%d peers", peer_num);
3898
3899 if (peer_num > MAX_PEER_STA) {
3900 hdd_warn("Exceed max peer sta to handle one time %d", peer_num);
3901 peer_num = MAX_PEER_STA;
3902 }
3903
3904 qdf_mem_copy(priv->peer_sta_info.info, rssi_info,
3905 peer_num * sizeof(*rssi_info));
3906 priv->peer_sta_info.sta_num = peer_num;
3907
3908 hdd_request_complete(request);
3909 hdd_request_put(request);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05303910
Will Huang496b36c2017-07-11 16:38:50 +08003911}
3912
Jeff Johnson3d278b02017-08-29 14:17:47 -07003913int wlan_hdd_get_peer_rssi(struct hdd_adapter *adapter,
Will Huang496b36c2017-07-11 16:38:50 +08003914 struct qdf_mac_addr *macaddress,
3915 struct sir_peer_sta_info *peer_sta_info)
3916{
3917 QDF_STATUS status;
3918 void *cookie;
3919 int ret;
3920 struct sir_peer_info_req rssi_req;
3921 struct hdd_request *request;
3922 struct peer_rssi_priv *priv;
3923 static const struct hdd_request_params params = {
3924 .priv_size = sizeof(*priv),
3925 .timeout_ms = WLAN_WAIT_TIME_STATS,
3926 };
3927
3928 if (!adapter || !macaddress || !peer_sta_info) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003929 hdd_err("adapter [%pK], macaddress [%pK], peer_sta_info[%pK]",
Will Huang496b36c2017-07-11 16:38:50 +08003930 adapter, macaddress, peer_sta_info);
3931 return -EFAULT;
3932 }
3933
3934 request = hdd_request_alloc(&params);
3935 if (!request) {
3936 hdd_err("Request allocation failure");
3937 return -ENOMEM;
3938 }
3939
3940 cookie = hdd_request_cookie(request);
3941 priv = hdd_request_priv(request);
3942
3943 qdf_mem_copy(&rssi_req.peer_macaddr, macaddress,
3944 QDF_MAC_ADDR_SIZE);
Jeff Johnson1b780e42017-10-31 14:11:45 -07003945 rssi_req.sessionid = adapter->session_id;
Will Huang496b36c2017-07-11 16:38:50 +08003946 status = sme_get_peer_info(WLAN_HDD_GET_HAL_CTX(adapter),
3947 rssi_req,
3948 cookie,
3949 hdd_get_peer_rssi_cb);
3950 if (status != QDF_STATUS_SUCCESS) {
3951 hdd_err("Unable to retrieve statistics for rssi");
3952 ret = -EFAULT;
3953 } else {
3954 ret = hdd_request_wait_for_response(request);
3955 if (ret) {
3956 hdd_err("SME timed out while retrieving rssi");
3957 ret = -EFAULT;
3958 } else {
3959 *peer_sta_info = priv->peer_sta_info;
3960 ret = 0;
3961 }
3962 }
3963
3964 hdd_request_put(request);
3965
3966 return ret;
3967}
3968
3969struct peer_info_priv {
3970 struct sir_peer_sta_ext_info peer_sta_ext_info;
3971};
3972
3973/**
3974 * wlan_hdd_get_peer_info_cb() - get peer info callback
3975 * @sta_info: pointer of peer information
3976 * @context: get peer info callback context
3977 *
3978 * This function will fill stats info to peer info priv
3979 *
3980 */
3981static void wlan_hdd_get_peer_info_cb(struct sir_peer_info_ext_resp *sta_info,
3982 void *context)
3983{
3984 struct hdd_request *request;
3985 struct peer_info_priv *priv;
3986 uint8_t sta_num;
3987
3988 if ((!sta_info) || (!context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07003989 hdd_err("Bad param, sta_info [%pK] context [%pK]",
Will Huang496b36c2017-07-11 16:38:50 +08003990 sta_info, context);
3991 return;
3992 }
3993
3994 if (!sta_info->count) {
3995 hdd_err("Fail to get remote peer info");
3996 return;
3997 }
3998
3999 if (sta_info->count > MAX_PEER_STA) {
4000 hdd_warn("Exceed max peer number %d", sta_info->count);
4001 sta_num = MAX_PEER_STA;
4002 } else {
4003 sta_num = sta_info->count;
4004 }
4005
4006 request = hdd_request_get(context);
4007 if (!request) {
4008 hdd_err("Obsolete request");
4009 return;
4010 }
4011
4012 priv = hdd_request_priv(request);
4013
4014 priv->peer_sta_ext_info.sta_num = sta_num;
4015 qdf_mem_copy(&priv->peer_sta_ext_info.info,
4016 sta_info->info,
4017 sta_num * sizeof(sta_info->info[0]));
4018
4019 hdd_request_complete(request);
4020 hdd_request_put(request);
4021}
4022
Jeff Johnson3d278b02017-08-29 14:17:47 -07004023int wlan_hdd_get_peer_info(struct hdd_adapter *adapter,
Will Huang496b36c2017-07-11 16:38:50 +08004024 struct qdf_mac_addr macaddress,
4025 struct sir_peer_info_ext *peer_info_ext)
4026{
4027 QDF_STATUS status;
4028 void *cookie;
4029 int ret;
4030 struct sir_peer_info_ext_req peer_info_req;
4031 struct hdd_request *request;
4032 struct peer_info_priv *priv;
4033 static const struct hdd_request_params params = {
4034 .priv_size = sizeof(*priv),
4035 .timeout_ms = WLAN_WAIT_TIME_STATS,
4036 };
4037
4038 if (!adapter) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004039 hdd_err("adapter is NULL");
Will Huang496b36c2017-07-11 16:38:50 +08004040 return -EFAULT;
4041 }
4042
4043 request = hdd_request_alloc(&params);
4044 if (!request) {
4045 hdd_err("Request allocation failure");
4046 return -ENOMEM;
4047 }
4048
4049 cookie = hdd_request_cookie(request);
4050 priv = hdd_request_priv(request);
4051
4052 qdf_mem_copy(&peer_info_req.peer_macaddr, &macaddress,
4053 QDF_MAC_ADDR_SIZE);
Jeff Johnson1b780e42017-10-31 14:11:45 -07004054 peer_info_req.sessionid = adapter->session_id;
Will Huang496b36c2017-07-11 16:38:50 +08004055 peer_info_req.reset_after_request = 0;
4056 status = sme_get_peer_info_ext(WLAN_HDD_GET_HAL_CTX(adapter),
4057 &peer_info_req,
4058 cookie,
4059 wlan_hdd_get_peer_info_cb);
4060 if (status != QDF_STATUS_SUCCESS) {
4061 hdd_err("Unable to retrieve statistics for peer info");
4062 ret = -EFAULT;
4063 } else {
4064 ret = hdd_request_wait_for_response(request);
4065 if (ret) {
4066 hdd_err("SME timed out while retrieving peer info");
4067 ret = -EFAULT;
4068 } else {
4069 /* only support one peer by now */
4070 *peer_info_ext = priv->peer_sta_ext_info.info[0];
4071 ret = 0;
4072 }
4073 }
4074
4075 hdd_request_put(request);
4076
4077 return ret;
4078}
4079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004082 * @adapter: adapter who's IEs are to be cleared
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083 *
4084 * Return: None
4085 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004086void hdd_clear_roam_profile_ie(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087{
Jeff Johnson731bc322017-10-14 19:53:44 -07004088 struct hdd_station_ctx *sta_ctx;
Jeff Johnson2a722002017-09-30 20:02:35 -07004089 struct hdd_wext_state *pWextState =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004090 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004091
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004092 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093
4094 /* clear WPA/RSN/WSC IE information in the profile */
4095 pWextState->roamProfile.nWPAReqIELength = 0;
4096 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
4097 pWextState->roamProfile.nRSNReqIELength = 0;
4098 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
4099
4100#ifdef FEATURE_WLAN_WAPI
4101 pWextState->roamProfile.nWAPIReqIELength = 0;
4102 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
4103#endif
4104
4105 pWextState->roamProfile.bWPSAssociation = false;
4106 pWextState->roamProfile.bOSENAssociation = false;
4107 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
4108 pWextState->roamProfile.nAddIEScanLength = 0;
4109 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
4110 pWextState->roamProfile.nAddIEAssocLength = 0;
4111
4112 pWextState->roamProfile.EncryptionType.numEntries = 1;
4113 pWextState->roamProfile.EncryptionType.encryptionType[0]
4114 = eCSR_ENCRYPT_TYPE_NONE;
4115
4116 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4117 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
4118 = eCSR_ENCRYPT_TYPE_NONE;
4119
4120 pWextState->roamProfile.AuthType.numEntries = 1;
4121 pWextState->roamProfile.AuthType.authType[0] =
4122 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4123
Abhishek Singh3c9910e2017-01-06 17:56:47 +05304124 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
4125 QDF_MAC_ADDR_SIZE);
4126
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127#ifdef WLAN_FEATURE_11W
4128 pWextState->roamProfile.MFPEnabled = false;
4129 pWextState->roamProfile.MFPRequired = 0;
4130 pWextState->roamProfile.MFPCapable = 0;
4131#endif
4132
4133 pWextState->authKeyMgmt = 0;
4134
Yingying Tang3cc6b792016-10-20 17:00:37 +08004135 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
4136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137#ifdef FEATURE_WLAN_WAPI
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07004138 adapter->wapi_info.wapi_auth_mode = WAPI_AUTH_MODE_OPEN;
4139 adapter->wapi_info.wapi_mode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140#endif
4141
Jeff Johnson731bc322017-10-14 19:53:44 -07004142 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
4143 qdf_zero_macaddr(&sta_ctx->requested_bssid);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004144 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145}
4146
4147/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304148 * hdd_get_ldpc() - Get adapter LDPC
4149 * @adapter: adapter being queried
4150 * @value: where to store the value
4151 *
4152 * Return: 0 on success, negative errno on failure
4153 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004154int hdd_get_ldpc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304155{
4156 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4157 int ret;
4158
4159 ENTER();
Jeff Johnson1b780e42017-10-31 14:11:45 -07004160 ret = sme_get_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304161 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
4162 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004163 hdd_err("Failed to get LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304164 } else {
4165 *value = ret;
4166 ret = 0;
4167 }
4168 return ret;
4169}
4170
4171/**
4172 * hdd_set_ldpc() - Set adapter LDPC
4173 * @adapter: adapter being modified
4174 * @value: new LDPC value
4175 *
4176 * Return: 0 on success, negative errno on failure
4177 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004178int hdd_set_ldpc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304179{
4180 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4181 int ret;
4182
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004183 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304184 if (value) {
4185 /* make sure HT capabilities allow this */
4186 QDF_STATUS status;
4187 uint32_t cfg_value;
4188 union {
4189 uint16_t cfg_value16;
4190 tSirMacHTCapabilityInfo ht_cap_info;
4191 } u;
4192
4193 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4194 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004195 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304196 return -EIO;
4197 }
4198 u.cfg_value16 = cfg_value & 0xFFFF;
4199 if (!u.ht_cap_info.advCodingCap) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004200 hdd_err("LDCP not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304201 return -EINVAL;
4202 }
4203 }
4204
Jeff Johnson1b780e42017-10-31 14:11:45 -07004205 ret = sme_update_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304206 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
4207 value);
4208 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004209 hdd_err("Failed to set LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304210
4211 return ret;
4212}
4213
4214/**
4215 * hdd_get_tx_stbc() - Get adapter TX STBC
4216 * @adapter: adapter being queried
4217 * @value: where to store the value
4218 *
4219 * Return: 0 on success, negative errno on failure
4220 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004221int hdd_get_tx_stbc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304222{
4223 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4224 int ret;
4225
4226 ENTER();
Jeff Johnson1b780e42017-10-31 14:11:45 -07004227 ret = sme_get_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304228 WNI_CFG_HT_CAP_INFO_TX_STBC);
4229 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004230 hdd_err("Failed to get TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304231 } else {
4232 *value = ret;
4233 ret = 0;
4234 }
4235
4236 return ret;
4237}
4238
4239/**
4240 * hdd_set_tx_stbc() - Set adapter TX STBC
4241 * @adapter: adapter being modified
4242 * @value: new TX STBC value
4243 *
4244 * Return: 0 on success, negative errno on failure
4245 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004246int hdd_set_tx_stbc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304247{
4248 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4249 int ret;
4250
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004251 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304252 if (value) {
4253 /* make sure HT capabilities allow this */
4254 QDF_STATUS status;
4255 uint32_t cfg_value;
4256 union {
4257 uint16_t cfg_value16;
4258 tSirMacHTCapabilityInfo ht_cap_info;
4259 } u;
4260
4261 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4262 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004263 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304264 return -EIO;
4265 }
4266 u.cfg_value16 = cfg_value & 0xFFFF;
4267 if (!u.ht_cap_info.txSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004268 hdd_err("TX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304269 return -EINVAL;
4270 }
4271 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07004272 ret = sme_update_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304273 WNI_CFG_HT_CAP_INFO_TX_STBC,
4274 value);
4275 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004276 hdd_err("Failed to set TX STBC value");
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08004277 ret = sme_update_he_tx_stbc_cap(hal, adapter->session_id, value);
4278 if (ret)
4279 hdd_err("Failed to set HE TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304280
4281 return ret;
4282}
4283
4284/**
4285 * hdd_get_rx_stbc() - Get adapter RX STBC
4286 * @adapter: adapter being queried
4287 * @value: where to store the value
4288 *
4289 * Return: 0 on success, negative errno on failure
4290 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004291int hdd_get_rx_stbc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304292{
4293 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4294 int ret;
4295
4296 ENTER();
Jeff Johnson1b780e42017-10-31 14:11:45 -07004297 ret = sme_get_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304298 WNI_CFG_HT_CAP_INFO_RX_STBC);
4299 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004300 hdd_err("Failed to get RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304301 } else {
4302 *value = ret;
4303 ret = 0;
4304 }
4305
4306 return ret;
4307}
4308
4309/**
4310 * hdd_set_rx_stbc() - Set adapter RX STBC
4311 * @adapter: adapter being modified
4312 * @value: new RX STBC value
4313 *
4314 * Return: 0 on success, negative errno on failure
4315 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004316int hdd_set_rx_stbc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304317{
4318 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4319 int ret;
4320
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004321 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304322 if (value) {
4323 /* make sure HT capabilities allow this */
4324 QDF_STATUS status;
4325 uint32_t cfg_value;
4326 union {
4327 uint16_t cfg_value16;
4328 tSirMacHTCapabilityInfo ht_cap_info;
4329 } u;
4330
4331 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4332 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004333 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304334 return -EIO;
4335 }
4336 u.cfg_value16 = cfg_value & 0xFFFF;
4337 if (!u.ht_cap_info.rxSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004338 hdd_warn("RX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304339 return -EINVAL;
4340 }
4341 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07004342 ret = sme_update_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304343 WNI_CFG_HT_CAP_INFO_RX_STBC,
4344 value);
4345 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004346 hdd_err("Failed to set RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304347
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08004348 ret = sme_update_he_rx_stbc_cap(hal, adapter->session_id, value);
4349 if (ret)
4350 hdd_err("Failed to set HE RX STBC value");
4351
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304352 return ret;
4353}
4354
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004355int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate)
4356{
4357 int set_value;
4358
4359 if (sme_is_feature_supported_by_fw(DOT11AX))
4360 set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble);
4361 else
4362 set_value = (preamble << 6) | (nss << 4) | rate;
4363
4364 return set_value;
4365}
4366
Jeff Johnson3d278b02017-08-29 14:17:47 -07004367int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004368 struct sap_Config *sap_config)
4369{
4370 uint8_t preamble = 0, nss = 0, rix = 0;
4371 int ret;
4372
4373 if (!sap_config) {
4374 if (!sme_is_feature_supported_by_fw(DOT11AX)) {
4375 hdd_err("Target does not support 11ax");
4376 return -EIO;
4377 }
4378 } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax &&
4379 sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07004380 hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d",
4381 sap_config->SapHw_mode, sap_config->channel);
4382 return -EIO;
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004383 }
4384
4385 if (set_value != 0xff) {
4386 rix = RC_2_RATE_IDX_11AX(set_value);
4387 preamble = WMI_RATE_PREAMBLE_HE;
4388 nss = HT_RC_2_STREAMS_11AX(set_value);
4389
4390 set_value = hdd_assemble_rate_code(preamble, nss, rix);
4391 }
4392
4393 hdd_notice("SET_11AX_RATE val %d rix %d preamble %x nss %d",
4394 set_value, rix, preamble, nss);
4395
Jeff Johnson1b780e42017-10-31 14:11:45 -07004396 ret = wma_cli_set_command(adapter->session_id,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004397 WMI_VDEV_PARAM_FIXED_RATE,
4398 set_value, VDEV_CMD);
4399
4400 return ret;
4401}
4402
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304403/**
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004404 * hdd_get_aid_rc() - Get AID and rate code passed from user
4405 * @aid: pointer to AID
4406 * @rc: pointer to rate code
4407 * @set_value: value passed from user
4408 *
4409 * If target is 11ax capable, set_value will have AID left shifted 16 bits
4410 * and 16 bits for rate code. If the target is not 11ax capable, rate code
4411 * will only be 8 bits.
4412 *
4413 * Return: None
4414 */
4415static void hdd_get_aid_rc(uint8_t *aid, uint16_t *rc, int set_value)
4416{
4417 uint8_t rc_bits;
4418
4419 if (sme_is_feature_supported_by_fw(DOT11AX))
4420 rc_bits = 16;
4421 else
4422 rc_bits = 8;
4423
4424 *aid = set_value >> rc_bits;
4425 *rc = set_value & ((1 << (rc_bits + 1)) - 1);
4426}
4427
Jeff Johnson3d278b02017-08-29 14:17:47 -07004428int hdd_set_peer_rate(struct hdd_adapter *adapter, int set_value)
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004429{
4430 uint8_t aid, *peer_mac;
4431 uint16_t rc;
4432 QDF_STATUS status;
4433
4434 if (adapter->device_mode != QDF_SAP_MODE) {
4435 hdd_err("Invalid devicde mode - %d", adapter->device_mode);
4436 return -EINVAL;
4437 }
4438
4439 hdd_get_aid_rc(&aid, &rc, set_value);
4440
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07004441 if ((adapter->sta_info[aid].in_use) &&
4442 (OL_TXRX_PEER_STATE_CONN == adapter->sta_info[aid].peer_state)) {
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004443 peer_mac =
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07004444 (uint8_t *)&(adapter->sta_info[aid].sta_mac.bytes[0]);
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004445 hdd_info("Peer AID: %d MAC_ADDR: "MAC_ADDRESS_STR,
4446 aid, MAC_ADDR_ARRAY(peer_mac));
4447 } else {
4448 hdd_err("No matching peer found for AID: %d", aid);
4449 return -EINVAL;
4450 }
4451
4452 status = sme_set_peer_param(peer_mac, WMI_PEER_PARAM_FIXED_RATE,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004453 rc, adapter->session_id);
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004454 if (status != QDF_STATUS_SUCCESS) {
4455 hdd_err("Failed to set peer fixed rate - status: %d", status);
4456 return -EIO;
4457 }
4458
4459 return 0;
4460}
4461
4462/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
4464 * @dev: device upon which the ioctl was received
4465 * @info: ioctl request information
4466 * @wrqu: ioctl request data
4467 * @extra: ioctl extra data
4468 *
4469 * Return: 0 on success, non-zero on error
4470 */
4471static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
4472 union iwreq_data *wrqu, char *extra)
4473{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004474 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004475 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476 int ret;
4477
Dustin Brownfdf17c12018-03-14 12:55:34 -07004478 hdd_enter_dev(dev);
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004479
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4481 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4482 ret = wlan_hdd_validate_context(hdd_ctx);
4483 if (0 != ret)
4484 return ret;
4485
Jeff Johnson441e1f72017-02-07 08:50:49 -08004486 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4487 if (0 != ret)
4488 return ret;
4489
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 /* Do nothing for now */
4491 return 0;
4492}
4493
4494/**
4495 * iw_set_commit() - SSR wrapper function for __iw_set_commit
4496 * @dev: pointer to net_device
4497 * @info: pointer to iw_request_info
4498 * @wrqu: pointer to iwreq_data
4499 * @extra: extra
4500 *
4501 * Return: 0 on success, error number otherwise
4502 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004503static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 union iwreq_data *wrqu, char *extra)
4505{
4506 int ret;
4507
4508 cds_ssr_protect(__func__);
4509 ret = __iw_set_commit(dev, info, wrqu, extra);
4510 cds_ssr_unprotect(__func__);
4511
4512 return ret;
4513}
4514
4515/**
4516 * __iw_get_name() - SIOCGIWNAME ioctl handler
4517 * @dev: device upon which the ioctl was received
4518 * @info: ioctl request information
4519 * @wrqu: ioctl request data
4520 * @extra: ioctl extra data
4521 *
4522 * Return: 0 on success, non-zero on error
4523 */
4524static int __iw_get_name(struct net_device *dev,
4525 struct iw_request_info *info, char *wrqu, char *extra)
4526{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004527 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004528 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529 int ret;
4530
Dustin Brownfdf17c12018-03-14 12:55:34 -07004531 hdd_enter_dev(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532
4533 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4534 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4535 ret = wlan_hdd_validate_context(hdd_ctx);
4536 if (0 != ret)
4537 return ret;
4538
Jeff Johnson441e1f72017-02-07 08:50:49 -08004539 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4540 if (0 != ret)
4541 return ret;
4542
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
4544 EXIT();
4545 return 0;
4546}
4547
4548/**
4549 * __iw_get_name() - SSR wrapper for __iw_get_name
4550 * @dev: pointer to net_device
4551 * @info: pointer to iw_request_info
4552 * @wrqu: pointer to iwreq_data
4553 * @extra: extra
4554 *
4555 * Return: 0 on success, error number otherwise
4556 */
4557static int iw_get_name(struct net_device *dev,
4558 struct iw_request_info *info,
4559 char *wrqu, char *extra)
4560{
4561 int ret;
4562
4563 cds_ssr_protect(__func__);
4564 ret = __iw_get_name(dev, info, wrqu, extra);
4565 cds_ssr_unprotect(__func__);
4566
4567 return ret;
4568}
4569
4570/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 * __iw_get_range() - SIOCGIWRANGE ioctl handler
4572 * @dev: device upon which the ioctl was received
4573 * @info: ioctl request information
4574 * @wrqu: ioctl request data
4575 * @extra: ioctl extra data
4576 *
4577 * Return: 0 on success, non-zero on error
4578 */
4579static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
4580 union iwreq_data *wrqu, char *extra)
4581{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004582 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4583 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 struct iw_range *range = (struct iw_range *)extra;
4585
4586 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4587
4588 uint32_t num_channels = sizeof(channels);
4589 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4590 uint32_t a_len;
4591 uint32_t b_len;
4592 uint32_t active_phy_mode = 0;
4593 uint8_t index = 0, i;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004594 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 int ret;
4596
Dustin Brownfdf17c12018-03-14 12:55:34 -07004597 hdd_enter_dev(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004599 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 ret = wlan_hdd_validate_context(hdd_ctx);
4601 if (0 != ret)
4602 return ret;
4603
Jeff Johnson441e1f72017-02-07 08:50:49 -08004604 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4605 if (0 != ret)
4606 return ret;
4607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 wrqu->data.length = sizeof(struct iw_range);
4609 memset(range, 0, sizeof(struct iw_range));
4610
4611
4612 /*Get the phy mode */
4613 if (sme_cfg_get_int(hHal,
4614 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304615 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004616 hdd_debug("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617
4618 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
4619 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
4620 /*Get the supported rates for 11G band */
4621 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4622 if (sme_cfg_get_str(hHal,
4623 WNI_CFG_SUPPORTED_RATES_11A,
4624 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304625 &a_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004626 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 for (i = 0; i < a_len; i++) {
4630 range->bitrate[i] =
4631 ((supp_rates[i] & 0x7F) / 2) *
4632 1000000;
4633 }
4634 range->num_bitrates = a_len;
4635 } else {
4636 return -EIO;
4637 }
4638 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
4639 /*Get the supported rates for 11B band */
4640 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4641 if (sme_cfg_get_str(hHal,
4642 WNI_CFG_SUPPORTED_RATES_11B,
4643 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304644 &b_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004645 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004647
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 for (i = 0; i < b_len; i++) {
4649 range->bitrate[i] =
4650 ((supp_rates[i] & 0x7F) / 2) *
4651 1000000;
4652 }
4653 range->num_bitrates = b_len;
4654 } else {
4655 return -EIO;
4656 }
4657 }
4658 }
4659
4660 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
4661 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
4662 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
4663
4664 range->encoding_size[0] = 5;
4665 range->encoding_size[1] = 13;
4666 range->num_encoding_sizes = 2;
4667 range->max_encoding_tokens = MAX_WEP_KEYS;
4668
4669 /* we support through Wireless Extensions 22 */
4670 range->we_version_compiled = WIRELESS_EXT;
4671 range->we_version_source = 22;
4672
4673 /*Supported Channels and Frequencies */
4674 if (sme_cfg_get_str
4675 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304676 &num_channels) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004677 hdd_err("Failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 return -EIO;
4679 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004680 if (num_channels > IW_MAX_FREQUENCIES)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 num_channels = IW_MAX_FREQUENCIES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682
4683 range->num_channels = num_channels;
4684 range->num_frequency = num_channels;
4685
4686 for (index = 0; index < num_channels; index++) {
4687 uint32_t frq_indx = 0;
4688
4689 range->freq[index].i = channels[index];
4690 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
4691 if (channels[index] == freq_chan_map[frq_indx].chan) {
4692 range->freq[index].m =
4693 freq_chan_map[frq_indx].freq * 100000;
4694 range->freq[index].e = 1;
4695 break;
4696 }
4697 frq_indx++;
4698 }
4699 }
4700
4701 /* Event capability (kernel + driver) */
4702 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
4703 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
4704 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
4705 range->event_capa[1] = IW_EVENT_CAPA_K_1;
4706
4707 /*Encryption capability */
4708 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
4709 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
4710
4711 /* Txpower capability */
4712 range->txpower_capa = IW_TXPOW_MWATT;
4713
4714 /*Scanning capability */
4715#if WIRELESS_EXT >= 22
4716 range->scan_capa =
4717 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
4718#endif
4719
4720 EXIT();
4721 return 0;
4722}
4723
4724/**
4725 * iw_get_range() - SSR wrapper for __iw_get_range()
4726 * @dev: pointer to net_device
4727 * @info: pointer to iw_request_info
4728 * @wrqu: pointer to iwreq_data
4729 * @extra: pointer to extra ioctl payload
4730 *
4731 * Return: 0 on success, error number otherwise
4732 */
4733static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
4734 union iwreq_data *wrqu, char *extra)
4735{
4736 int ret;
4737
4738 cds_ssr_protect(__func__);
4739 ret = __iw_get_range(dev, info, wrqu, extra);
4740 cds_ssr_unprotect(__func__);
4741
4742 return ret;
4743}
4744
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004745struct class_a_stats {
4746 tCsrGlobalClassAStatsInfo class_a_stats;
4747};
4748
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749/**
4750 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004751 * @stats: pointer to Class A stats
4752 * @context: user context originally registered with SME (always the
4753 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 *
4755 * Return: None
4756 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004757static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004759 struct hdd_request *request;
4760 struct class_a_stats *priv;
4761 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004763 ENTER();
4764 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07004765 hdd_err("Bad param, stats [%pK] context [%pK]",
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004766 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767 return;
4768 }
4769
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004770 request = hdd_request_get(context);
4771 if (!request) {
4772 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004773 return;
4774 }
4775
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004776 returned_stats = stats;
4777 priv = hdd_request_priv(request);
4778 priv->class_a_stats = *returned_stats;
4779 hdd_request_complete(request);
4780 hdd_request_put(request);
4781 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782}
4783
4784/**
4785 * wlan_hdd_get_class_astats() - Get Class A statistics
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004786 * @adapter: adapter for which statistics are desired
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304788 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004790QDF_STATUS wlan_hdd_get_class_astats(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004791{
Jeff Johnsond377dce2017-10-04 10:32:42 -07004792 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304793 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004794 int ret;
4795 void *cookie;
4796 struct hdd_request *request;
4797 struct class_a_stats *priv;
4798 static const struct hdd_request_params params = {
4799 .priv_size = sizeof(*priv),
4800 .timeout_ms = WLAN_WAIT_TIME_STATS,
4801 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004803 if (NULL == adapter) {
4804 hdd_err("adapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304805 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004806 }
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +05304807 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004808 hdd_debug("Recovery in Progress. State: 0x%x Ignore!!!",
Prashanth Bhatta9e143052015-12-04 11:56:47 -08004809 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304810 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811 }
4812
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004813 request = hdd_request_alloc(&params);
4814 if (!request) {
4815 hdd_err("Request allocation failure");
4816 return QDF_STATUS_E_NOMEM;
4817 }
4818 cookie = hdd_request_cookie(request);
4819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 /* query only for Class A statistics (which include link speed) */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004821 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
4823 hdd_get_class_a_statistics_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07004824 sta_ctx->conn_info.staId[0],
Jeff Johnson1b780e42017-10-31 14:11:45 -07004825 cookie, adapter->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304826 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07004827 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004828 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829 }
4830
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004831 /* request was sent -- wait for the response */
4832 ret = hdd_request_wait_for_response(request);
4833 if (ret) {
4834 hdd_warn("SME timed out while retrieving Class A statistics");
4835 goto return_cached_results;
4836 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004838 /* update the adapter with the fresh results */
4839 priv = hdd_request_priv(request);
Jeff Johnson861dd4f2017-10-24 10:10:40 -07004840 adapter->hdd_stats.class_a_stat = priv->class_a_stats;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004841
4842return_cached_results:
4843 /*
4844 * either we never sent a request, we sent a request and
4845 * received a response or we sent a request and timed out.
4846 * regardless we are done with the request.
4847 */
4848 hdd_request_put(request);
4849
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304850 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851}
4852
Jeff Johnsondda167c2017-01-23 10:37:57 -08004853struct station_stats {
4854 tCsrSummaryStatsInfo summary_stats;
4855 tCsrGlobalClassAStatsInfo class_a_stats;
4856 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
4857};
4858
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859/**
4860 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08004861 * @stats: pointer to combined station stats
4862 * @context: user context originally registered with SME (always the
4863 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 *
4865 * Return: None
4866 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004867static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004868{
Jeff Johnsondda167c2017-01-23 10:37:57 -08004869 struct hdd_request *request;
4870 struct station_stats *priv;
4871 tCsrSummaryStatsInfo *summary_stats;
4872 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304873 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004874
Jeff Johnsondda167c2017-01-23 10:37:57 -08004875 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07004876 hdd_err("Bad param, pStats [%pK] pContext [%pK]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08004877 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878 return;
4879 }
4880
Jeff Johnsondda167c2017-01-23 10:37:57 -08004881 request = hdd_request_get(context);
4882 if (!request) {
4883 hdd_err("Obsolete request");
4884 return;
4885 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886
Jeff Johnsondda167c2017-01-23 10:37:57 -08004887 summary_stats = (tCsrSummaryStatsInfo *) stats;
4888 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304889 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08004890 (class_a_stats + 1);
4891 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004892
4893 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004894 priv->summary_stats = *summary_stats;
4895 priv->class_a_stats = *class_a_stats;
4896 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004897
Jeff Johnsondda167c2017-01-23 10:37:57 -08004898 hdd_request_complete(request);
4899 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900}
4901
4902/**
4903 * wlan_hdd_get_station_stats() - Get station statistics
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004904 * @adapter: adapter for which statistics are desired
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304906 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004908QDF_STATUS wlan_hdd_get_station_stats(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909{
Jeff Johnsond377dce2017-10-04 10:32:42 -07004910 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dustin Brown0f5260d2017-06-12 16:17:38 -07004911 QDF_STATUS status;
4912 int errno;
Jeff Johnsondda167c2017-01-23 10:37:57 -08004913 void *cookie;
4914 struct hdd_request *request;
4915 struct station_stats *priv;
4916 static const struct hdd_request_params params = {
4917 .priv_size = sizeof(*priv),
4918 .timeout_ms = WLAN_WAIT_TIME_STATS,
4919 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004921 if (NULL == adapter) {
4922 hdd_err("adapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304923 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924 }
4925
Jeff Johnsondda167c2017-01-23 10:37:57 -08004926 request = hdd_request_alloc(&params);
4927 if (!request) {
4928 hdd_err("Request allocation failure");
4929 return QDF_STATUS_E_NOMEM;
4930 }
4931 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932
4933 /* query only for Summary & Class A statistics */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004934 status = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(adapter),
Dustin Brown0f5260d2017-06-12 16:17:38 -07004935 eCSR_HDD,
4936 SME_SUMMARY_STATS |
4937 SME_GLOBAL_CLASSA_STATS |
4938 SME_PER_CHAIN_RSSI_STATS,
4939 hdd_get_station_statistics_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07004940 sta_ctx->conn_info.staId[0],
Dustin Brown0f5260d2017-06-12 16:17:38 -07004941 cookie,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004942 adapter->session_id);
Dustin Brown0f5260d2017-06-12 16:17:38 -07004943 if (QDF_IS_STATUS_ERROR(status)) {
4944 hdd_err("Failed to retrieve statistics, status %d", status);
4945 goto put_request;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946 }
4947
Dustin Brown0f5260d2017-06-12 16:17:38 -07004948 /* request was sent -- wait for the response */
4949 errno = hdd_request_wait_for_response(request);
4950 if (errno) {
4951 hdd_err("Failed to wait for statistics, errno %d", errno);
4952 goto put_request;
4953 }
4954
4955 /* update the adapter with the fresh results */
4956 priv = hdd_request_priv(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004957 adapter->hdd_stats.summary_stat = priv->summary_stats;
Jeff Johnson861dd4f2017-10-24 10:10:40 -07004958 adapter->hdd_stats.class_a_stat = priv->class_a_stats;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004959 adapter->hdd_stats.per_chain_rssi_stats = priv->per_chain_rssi_stats;
Dustin Brown0f5260d2017-06-12 16:17:38 -07004960
4961put_request:
Jeff Johnsondda167c2017-01-23 10:37:57 -08004962 /*
4963 * either we never sent a request, we sent a request and
4964 * received a response or we sent a request and timed out.
4965 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004966 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004967 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004968
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004969 /* either callback updated adapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304970 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971}
4972
4973/**
4974 * iw_get_linkspeed() - Get current link speed ioctl
4975 * @dev: device upon which the ioctl was received
4976 * @info: ioctl request information
4977 * @wrqu: ioctl request data
4978 * @extra: extra ioctl buffer
4979 *
4980 * Return: 0 on success, non-zero on error
4981 */
4982static int __iw_get_linkspeed(struct net_device *dev,
4983 struct iw_request_info *info,
4984 union iwreq_data *wrqu, char *extra)
4985{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004986 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987 char *pLinkSpeed = (char *)extra;
4988 int len = sizeof(uint32_t) + 1;
4989 uint32_t link_speed = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004990 struct hdd_context *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08004991 int ret;
4992 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993
Dustin Brownfdf17c12018-03-14 12:55:34 -07004994 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05304995
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004996 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08004997 ret = wlan_hdd_validate_context(hdd_ctx);
4998 if (0 != ret)
4999 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005000
Jeff Johnson441e1f72017-02-07 08:50:49 -08005001 ret = hdd_check_private_wext_control(hdd_ctx, info);
5002 if (0 != ret)
5003 return ret;
5004
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005005 ret = wlan_hdd_get_link_speed(adapter, &link_speed);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005006 if (0 != ret)
Jeff Johnson441e1f72017-02-07 08:50:49 -08005007 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005008
5009 wrqu->data.length = len;
5010 /* return the linkspeed as a string */
5011 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
5012 if ((rc < 0) || (rc >= len)) {
5013 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07005014 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015 return -EIO;
5016 }
5017
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305018 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019 /* a value is being successfully returned */
5020 return 0;
5021}
5022
5023static int iw_get_linkspeed(struct net_device *dev,
5024 struct iw_request_info *info,
5025 union iwreq_data *wrqu, char *extra)
5026{
5027 int ret;
5028
5029 cds_ssr_protect(__func__);
5030 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
5031 cds_ssr_unprotect(__func__);
5032
5033 return ret;
5034}
5035
5036/**
5037 * wlan_hdd_change_country_code_callback() - Change country code callback
5038 * @context: opaque context originally passed to SME. All functions
5039 * which use this callback pass the adapter upon which the country
5040 * code change is active
5041 *
5042 * This function is registered as the callback function when
5043 * sme_change_country_code() is invoked. Callers of
5044 * sme_change_country_code() subsequently wait for the adapter's
5045 * @change_country_code completion variable, so all this function
5046 * needs to do is set that completion variable so that execution can
5047 * continue.
5048 *
5049 * Return: none
5050 */
5051void wlan_hdd_change_country_code_callback(void *context)
5052{
5053
Jeff Johnson3d278b02017-08-29 14:17:47 -07005054 struct hdd_adapter *adapter = context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055
5056 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
5057 complete(&adapter->change_country_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005058}
5059
5060/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005061 * wlan_hdd_update_phymode() - handle change in PHY mode
5062 * @net: device upon which PHY mode change was received
5063 * @hal: umac handle for the driver
5064 * @new_phymode: new PHY mode for the device
5065 * @phddctx: pointer to the HDD context
5066 *
5067 * This function is called when the device is set to a new PHY mode.
5068 * It takes a holistic look at the desired PHY mode along with the
5069 * configured capabilities of the driver and the reported capabilities
5070 * of the hardware in order to correctly configure all PHY-related
5071 * parameters.
5072 *
5073 * Return: 0 on success, negative errno value on error
5074 */
5075int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005076 int new_phymode, struct hdd_context *phddctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077{
5078#ifdef QCA_HT_2040_COEX
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005079 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305080 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081#endif
5082 bool band_24 = false, band_5g = false;
5083 bool ch_bond24 = false, ch_bond5g = false;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305084 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087 eCsrPhyMode phymode = -EIO, old_phymode;
Srinivas Girigowda2fb677c2017-03-25 15:35:34 -07005088 enum hdd_dot11_mode hdd_dot11mode = phddctx->config->dot11Mode;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005089 enum band_info curr_band = BAND_ALL;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305090 int retval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091
5092 old_phymode = sme_get_phy_mode(hal);
5093
5094 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5095 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5096 nChannelBondingMode24GHz))
5097 ch_bond24 = true;
5098
5099 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5100 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5101 nChannelBondingMode5GHz))
5102 ch_bond5g = true;
5103
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005104 if (phddctx->config->nBandCapability == BAND_ALL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105 band_24 = band_5g = true;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005106 else if (phddctx->config->nBandCapability == BAND_2G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005107 band_24 = true;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005108 else if (phddctx->config->nBandCapability == BAND_5G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 band_5g = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005110
5111 vhtchanwidth = phddctx->config->vhtChannelWidth;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005112 hdd_debug("ch_bond24=%d ch_bond5g=%d band_24=%d band_5g=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005113 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
5114
5115 switch (new_phymode) {
5116 case IEEE80211_MODE_AUTO:
5117 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005118 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119 phymode = eCSR_DOT11_MODE_AUTO;
5120 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5121 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005122 curr_band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5124 } else {
5125 sme_set_phy_mode(hal, old_phymode);
5126 return -EIO;
5127 }
5128 break;
5129 case IEEE80211_MODE_11A:
5130 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005131 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 phymode = eCSR_DOT11_MODE_11a;
5133 hdd_dot11mode = eHDD_DOT11_MODE_11a;
5134 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005135 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136 } else {
5137 sme_set_phy_mode(hal, old_phymode);
5138 return -EIO;
5139 }
5140 break;
5141 case IEEE80211_MODE_11B:
5142 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005143 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144 phymode = eCSR_DOT11_MODE_11b;
5145 hdd_dot11mode = eHDD_DOT11_MODE_11b;
5146 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005147 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 } else {
5149 sme_set_phy_mode(hal, old_phymode);
5150 return -EIO;
5151 }
5152 break;
5153 case IEEE80211_MODE_11G:
5154 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005155 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 phymode = eCSR_DOT11_MODE_11g;
5157 hdd_dot11mode = eHDD_DOT11_MODE_11g;
5158 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005159 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 } else {
5161 sme_set_phy_mode(hal, old_phymode);
5162 return -EIO;
5163 }
5164 break;
5165 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
5166 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
5167 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
5168 */
5169 case IEEE80211_MODE_11NA_HT20:
5170 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005171 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172 phymode = eCSR_DOT11_MODE_11n;
5173 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5174 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005175 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005176 } else {
5177 sme_set_phy_mode(hal, old_phymode);
5178 return -EIO;
5179 }
5180 break;
5181 case IEEE80211_MODE_11NA_HT40:
5182 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005183 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184 phymode = eCSR_DOT11_MODE_11n;
5185 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5186 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005187 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005188 } else {
5189 sme_set_phy_mode(hal, old_phymode);
5190 return -EIO;
5191 }
5192 break;
5193 case IEEE80211_MODE_11NG_HT20:
5194 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005195 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005196 phymode = eCSR_DOT11_MODE_11n;
5197 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5198 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005199 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 } else {
5201 sme_set_phy_mode(hal, old_phymode);
5202 return -EIO;
5203 }
5204 break;
5205 case IEEE80211_MODE_11NG_HT40:
5206 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005207 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208 phymode = eCSR_DOT11_MODE_11n;
5209 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5210 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005211 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005212 } else {
5213 sme_set_phy_mode(hal, old_phymode);
5214 return -EIO;
5215 }
5216 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217 case IEEE80211_MODE_11AC_VHT20:
5218 case IEEE80211_MODE_11AC_VHT40:
5219 case IEEE80211_MODE_11AC_VHT80:
5220 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005221 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222 phymode = eCSR_DOT11_MODE_11ac;
5223 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
5224 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005225 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 } else {
5227 sme_set_phy_mode(hal, old_phymode);
5228 return -EIO;
5229 }
5230 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005231 case IEEE80211_MODE_2G_AUTO:
5232 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005233 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234 phymode = eCSR_DOT11_MODE_AUTO;
5235 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5236 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005237 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005238 } else {
5239 sme_set_phy_mode(hal, old_phymode);
5240 return -EIO;
5241 }
5242 break;
5243 case IEEE80211_MODE_5G_AUTO:
5244 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005245 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246 phymode = eCSR_DOT11_MODE_AUTO;
5247 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5248 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5249 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005250 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 } else {
5252 sme_set_phy_mode(hal, old_phymode);
5253 return -EIO;
5254 }
5255 break;
5256 case IEEE80211_MODE_11AGN:
5257 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005258 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005259 phymode = eCSR_DOT11_MODE_11n;
5260 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5261 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005262 curr_band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005263 } else {
5264 sme_set_phy_mode(hal, old_phymode);
5265 return -EIO;
5266 }
5267 break;
5268 default:
5269 return -EIO;
5270 }
5271
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005272 switch (new_phymode) {
5273 case IEEE80211_MODE_11AC_VHT20:
5274 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5275 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5276 break;
5277 case IEEE80211_MODE_11AC_VHT40:
5278 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5279 break;
5280 case IEEE80211_MODE_11AC_VHT80:
5281 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5282 break;
5283 default:
5284 vhtchanwidth = phddctx->config->vhtChannelWidth;
5285 break;
5286 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005287
5288 if (phymode != -EIO) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305289 sme_config = qdf_mem_malloc(sizeof(*sme_config));
5290 if (!sme_config) {
5291 hdd_err("Failed to allocate memory for sme_config");
5292 return -ENOMEM;
5293 }
5294 qdf_mem_zero(sme_config, sizeof(*sme_config));
5295 sme_get_config_param(hal, sme_config);
5296 sme_config->csrConfig.phyMode = phymode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297#ifdef QCA_HT_2040_COEX
5298 if (phymode == eCSR_DOT11_MODE_11n &&
5299 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305300 sme_config->csrConfig.obssEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005301 halStatus = sme_set_ht2040_mode(hal,
Jeff Johnson1b780e42017-10-31 14:11:45 -07005302 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305304 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005305 hdd_err("Failed to disable OBSS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305306 retval = -EIO;
5307 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308 }
5309 } else if (phymode == eCSR_DOT11_MODE_11n &&
5310 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305311 sme_config->csrConfig.obssEnabled = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 halStatus = sme_set_ht2040_mode(hal,
Jeff Johnson1b780e42017-10-31 14:11:45 -07005313 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305315 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005316 hdd_err("Failed to enable OBSS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305317 retval = -EIO;
5318 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005319 }
5320 }
5321#endif
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305322 sme_config->csrConfig.eBand = curr_band;
5323 sme_config->csrConfig.bandCapability = curr_band;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005324 if (curr_band == BAND_2G)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305325 sme_config->csrConfig.Is11hSupportEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 else
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305327 sme_config->csrConfig.Is11hSupportEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328 phddctx->config->Is11hSupportEnabled;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005329 if (curr_band == BAND_2G)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305330 sme_config->csrConfig.channelBondingMode24GHz = chwidth;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005331 else if (curr_band == BAND_2G)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305332 sme_config->csrConfig.channelBondingMode5GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 else {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305334 sme_config->csrConfig.channelBondingMode24GHz = chwidth;
5335 sme_config->csrConfig.channelBondingMode5GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336 }
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305337 sme_config->csrConfig.nVhtChannelWidth = vhtchanwidth;
5338 sme_update_config(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005339
5340 phddctx->config->dot11Mode = hdd_dot11mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 phddctx->config->nChannelBondingMode24GHz =
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305342 sme_config->csrConfig.channelBondingMode24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343 phddctx->config->nChannelBondingMode5GHz =
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305344 sme_config->csrConfig.channelBondingMode5GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005346 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005347 hdd_err("could not update config_dat");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305348 retval = -EIO;
5349 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005350 }
Rajeev Kumar Sirasanagandla4c9b6752017-07-25 20:35:20 +05305351
5352 if (band_5g) {
5353 struct ieee80211_supported_band *band;
5354
5355 band = phddctx->wiphy->bands[HDD_NL80211_BAND_5GHZ];
5356 if (phddctx->config->nChannelBondingMode5GHz)
5357 band->ht_cap.cap |=
5358 IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5359 else
5360 band->ht_cap.cap &=
5361 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5362 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005363
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005364 hdd_debug("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005365 phymode, chwidth, curr_band, vhtchanwidth);
5366 }
5367
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305368free:
5369 if (sme_config)
5370 qdf_mem_free(sme_config);
5371 return retval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005372}
5373
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005374struct temperature_priv {
5375 int temperature;
5376};
5377
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378/**
5379 * hdd_get_temperature_cb() - "Get Temperature" callback function
5380 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005381 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 *
5383 * This function is passed to sme_get_temperature() as the callback
5384 * function to be invoked when the temperature measurement is
5385 * available.
5386 *
5387 * Return: None
5388 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005389static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005391 struct hdd_request *request;
5392 struct temperature_priv *priv;
5393
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005395
5396 request = hdd_request_get(context);
5397 if (!request) {
5398 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 return;
5400 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005401
5402 priv = hdd_request_priv(request);
5403 priv->temperature = temperature;
5404 hdd_request_complete(request);
5405 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406 EXIT();
5407}
5408
5409/**
5410 * wlan_hdd_get_temperature() - get current device temperature
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005411 * @adapter: device upon which the request was made
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 * @temperature: pointer to where the temperature is to be returned
5413 *
5414 * Return: 0 if a temperature value (either current or cached) was
5415 * returned, otherwise a negative errno is returned.
5416 *
5417 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005418int wlan_hdd_get_temperature(struct hdd_adapter *adapter, int *temperature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305420 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005421 int ret;
5422 void *cookie;
5423 struct hdd_request *request;
5424 struct temperature_priv *priv;
5425 static const struct hdd_request_params params = {
5426 .priv_size = sizeof(*priv),
5427 .timeout_ms = WLAN_WAIT_TIME_STATS,
5428 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429
5430 ENTER();
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005431 if (NULL == adapter) {
5432 hdd_err("adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 return -EPERM;
5434 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005435
5436 request = hdd_request_alloc(&params);
5437 if (!request) {
5438 hdd_err("Request allocation failure");
5439 return -ENOMEM;
5440 }
5441 cookie = hdd_request_cookie(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005442 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005443 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305444 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005445 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005446 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005447 ret = hdd_request_wait_for_response(request);
5448 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005449 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005450 } else {
5451 /* update the adapter with the fresh results */
5452 priv = hdd_request_priv(request);
5453 if (priv->temperature)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005454 adapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455 }
5456 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005457
5458 /*
5459 * either we never sent a request, we sent a request and
5460 * received a response or we sent a request and timed out.
5461 * regardless we are done with the request.
5462 */
5463 hdd_request_put(request);
5464
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005465 *temperature = adapter->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 EXIT();
5467 return 0;
5468}
5469
Jeff Johnson011c4502017-10-05 15:25:56 -07005470static int hdd_validate_pdev_reset(int value)
5471{
5472 if ((value < 1) || (value > 5)) {
5473 hdd_warn(" Invalid value %d: Use any one of the below values\n"
5474 " TX_FLUSH = 1\n"
5475 " WARM_RESET = 2\n"
5476 " COLD_RESET = 3\n"
5477 " WARM_RESET_RESTORE_CAL = 4\n"
5478 " COLD_RESET_RESTORE_CAL = 5", value);
5479
5480 return -EINVAL;
5481 }
5482
5483 return 0;
5484}
5485
5486static int hdd_handle_pdev_reset(struct hdd_adapter *adapter, int value)
5487{
5488 int ret;
5489
5490 hdd_debug("%d", value);
5491
5492 ret = hdd_validate_pdev_reset(value);
5493 if (ret)
5494 return ret;
5495
Jeff Johnson1b780e42017-10-31 14:11:45 -07005496 ret = wma_cli_set_command(adapter->session_id,
Jeff Johnson011c4502017-10-05 15:25:56 -07005497 WMI_PDEV_PARAM_PDEV_RESET,
5498 value, PDEV_CMD);
5499
5500 return ret;
5501}
5502
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503/**
5504 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5505 * @dev: device upon which the ioctl was received
5506 * @info: ioctl request information
5507 * @wrqu: ioctl request data
5508 * @extra: ioctl extra data
5509 *
5510 * Return: 0 on success, non-zero on error
5511 */
5512static int __iw_setint_getnone(struct net_device *dev,
5513 struct iw_request_info *info,
5514 union iwreq_data *wrqu, char *extra)
5515{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005516 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5517 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005518 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005519 struct hdd_context *hdd_ctx;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305520 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 int *value = (int *)extra;
5522 int sub_cmd = value[0];
5523 int set_value = value[1];
5524 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305525 QDF_STATUS status;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08005526 void *soc = NULL;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08005527 struct cdp_pdev *pdev = NULL;
5528 struct cdp_vdev *vdev = NULL;
Venkata Sharath Chandra Manchala1e581102018-02-19 22:42:20 -08005529 struct cdp_txrx_stats_req req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530
Dustin Brownfdf17c12018-03-14 12:55:34 -07005531 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305532
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005533 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005534 ret = wlan_hdd_validate_context(hdd_ctx);
5535 if (0 != ret)
5536 return ret;
5537
Jeff Johnson441e1f72017-02-07 08:50:49 -08005538 ret = hdd_check_private_wext_control(hdd_ctx, info);
5539 if (0 != ret)
5540 return ret;
5541
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305542 sme_config = qdf_mem_malloc(sizeof(*sme_config));
5543 if (!sme_config) {
5544 hdd_err("failed to allocate memory for sme_config");
5545 return -ENOMEM;
5546 }
5547 qdf_mem_zero(sme_config, sizeof(*sme_config));
Jeff Johnson441e1f72017-02-07 08:50:49 -08005548
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549 switch (sub_cmd) {
5550 case WE_SET_11D_STATE:
5551 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305552 if (((ENABLE_11D == set_value)
5553 || (DISABLE_11D == set_value)) && hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305555 sme_get_config_param(hHal, sme_config);
5556 sme_config->csrConfig.Is11dSupportEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557 (bool) set_value;
5558
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005559 hdd_debug("11D state=%d!!",
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305560 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005561 Is11dSupportEnabled);
5562
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305563 sme_update_config(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005564 } else {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305565 ret = -EINVAL;
5566 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005567 }
5568 break;
5569 }
5570
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005571 case WE_SET_POWER:
5572 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305573 if (!hHal)
5574 return -EINVAL;
5575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 switch (set_value) {
5577 case 1:
5578 /* Enable PowerSave */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005579 sme_ps_enable_disable(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005580 SME_PS_ENABLE);
5581 break;
5582 case 2:
5583 /* Disable PowerSave */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005584 sme_ps_enable_disable(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005585 SME_PS_DISABLE);
5586 break;
5587 case 3: /* Enable UASPD */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005588 sme_ps_uapsd_enable(hHal, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005589 break;
5590 case 4: /* Disable UASPD */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005591 sme_ps_uapsd_disable(hHal, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592 break;
5593 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005594 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595 set_value);
5596 ret = -EINVAL;
5597 break;
5598 }
5599 break;
5600 }
5601
5602 case WE_SET_MAX_ASSOC:
5603 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305604 if (!hHal)
5605 return -EINVAL;
5606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5608 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5609 ret = -EINVAL;
5610 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5611 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305612 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005613 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005614 ret = -EIO;
5615 }
5616 break;
5617 }
5618
5619 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5620 if (set_value == 0 || set_value == 1)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005621 (WLAN_HDD_GET_CTX(adapter))->config->force_sap_acs =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005622 set_value;
5623 else
5624 ret = -EINVAL;
5625 break;
5626
5627 case WE_SET_DATA_INACTIVITY_TO:
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305628 if (!hHal)
5629 return -EINVAL;
5630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005631 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5632 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005633 (sme_cfg_set_int((WLAN_HDD_GET_CTX(adapter))->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305635 set_value) == QDF_STATUS_E_FAILURE)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005636 hdd_err("WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637 ret = -EINVAL;
5638 }
5639 break;
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05305640 case WE_SET_WOW_DATA_INACTIVITY_TO:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305641 if (!hHal) {
5642 ret = -EINVAL;
5643 goto free;
5644 }
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05305645
5646 if ((set_value < CFG_WOW_DATA_INACTIVITY_TIMEOUT_MIN) ||
5647 (set_value > CFG_WOW_DATA_INACTIVITY_TIMEOUT_MAX) ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005648 (sme_cfg_set_int((WLAN_HDD_GET_CTX(adapter))->hHal,
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05305649 WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT,
5650 set_value) == QDF_STATUS_E_FAILURE)) {
5651 hdd_err("WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT fail");
5652 ret = -EINVAL;
5653 }
5654 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005655 case WE_SET_MC_RATE:
5656 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305657 if (!hHal)
5658 return -EINVAL;
5659
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005660 ret = wlan_hdd_set_mc_rate(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 break;
5662 }
5663 case WE_SET_TX_POWER:
5664 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305665 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005666
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305667 if (!hHal)
5668 return -EINVAL;
5669
Jeff Johnsond377dce2017-10-04 10:32:42 -07005670 qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005671 if (sme_set_tx_power
Jeff Johnson1b780e42017-10-31 14:11:45 -07005672 (hHal, adapter->session_id, bssid,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005673 adapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305674 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005675 hdd_err("Setting tx power failed");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305676 ret = -EIO;
5677 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 }
5679 break;
5680 }
5681 case WE_SET_MAX_TX_POWER:
5682 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305683 struct qdf_mac_addr bssid;
5684 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005685
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305686 if (!hHal)
5687 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005688
5689 hdd_debug("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005690 set_value);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005691 qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssId);
5692 qdf_copy_macaddr(&selfMac, &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693
5694 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305695 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005696 hdd_err("Setting maximum tx power failed");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305697 ret = -EIO;
5698 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005699 }
5700
5701 break;
5702 }
5703 case WE_SET_MAX_TX_POWER_2_4:
5704 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005705 hdd_debug("Setting maximum tx power %d dBm for 2.4 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07005706 set_value);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005707 if (sme_set_max_tx_power_per_band(BAND_2G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305708 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005709 hdd_err("Setting max tx power failed for 2.4 GHz band");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305710 ret = -EIO;
5711 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005712 }
5713
5714 break;
5715 }
5716 case WE_SET_MAX_TX_POWER_5_0:
5717 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005718 hdd_debug("Setting maximum tx power %d dBm for 5.0 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07005719 set_value);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005720 if (sme_set_max_tx_power_per_band(BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305721 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005722 hdd_err("Setting max tx power failed for 5.0 GHz band");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305723 ret = -EIO;
5724 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725 }
5726
5727 break;
5728 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729
5730 case WE_SET_TM_LEVEL:
5731 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305732 if (!hHal)
5733 return -EINVAL;
5734
5735 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736 (void)sme_set_thermal_level(hHal, set_value);
5737 break;
5738 }
5739
5740 case WE_SET_PHYMODE:
5741 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005742 struct hdd_context *phddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07005743
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305744 if (!hHal)
5745 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005746
5747 ret =
5748 wlan_hdd_update_phymode(dev, hHal, set_value,
5749 phddctx);
5750 break;
5751 }
5752
5753 case WE_SET_NSS:
5754 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305755 if (!hHal)
5756 return -EINVAL;
5757
5758 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005759 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005760 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005761 ret = -EINVAL;
5762 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305763 if (QDF_STATUS_SUCCESS !=
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -08005764 hdd_update_nss(adapter, set_value))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005765 ret = -EINVAL;
5766 }
5767 break;
5768 }
5769
5770 case WE_SET_GTX_HT_MCS:
5771 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005772 hdd_debug("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005773 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005774 WMI_VDEV_PARAM_GTX_HT_MCS,
5775 set_value, GTX_CMD);
5776 break;
5777 }
5778
5779 case WE_SET_GTX_VHT_MCS:
5780 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005781 hdd_debug("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005783 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005784 WMI_VDEV_PARAM_GTX_VHT_MCS,
5785 set_value, GTX_CMD);
5786 break;
5787 }
5788
5789 case WE_SET_GTX_USRCFG:
5790 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005791 hdd_debug("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005792 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005793 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794 WMI_VDEV_PARAM_GTX_USR_CFG,
5795 set_value, GTX_CMD);
5796 break;
5797 }
5798
5799 case WE_SET_GTX_THRE:
5800 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005801 hdd_debug("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005802 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005803 WMI_VDEV_PARAM_GTX_THRE,
5804 set_value, GTX_CMD);
5805 break;
5806 }
5807
5808 case WE_SET_GTX_MARGIN:
5809 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005810 hdd_debug("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005811 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812 WMI_VDEV_PARAM_GTX_MARGIN,
5813 set_value, GTX_CMD);
5814 break;
5815 }
5816
5817 case WE_SET_GTX_STEP:
5818 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005819 hdd_debug("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005820 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005821 WMI_VDEV_PARAM_GTX_STEP,
5822 set_value, GTX_CMD);
5823 break;
5824 }
5825
5826 case WE_SET_GTX_MINTPC:
5827 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005828 hdd_debug("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005829 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005830 WMI_VDEV_PARAM_GTX_MINTPC,
5831 set_value, GTX_CMD);
5832 break;
5833 }
5834
5835 case WE_SET_GTX_BWMASK:
5836 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005837 hdd_debug("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005838 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005839 WMI_VDEV_PARAM_GTX_BW_MASK,
5840 set_value, GTX_CMD);
5841 break;
5842 }
5843
5844 case WE_SET_LDPC:
5845 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305846 if (!hHal)
5847 return -EINVAL;
5848
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005849 ret = hdd_set_ldpc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 break;
5851 }
5852
5853 case WE_SET_TX_STBC:
5854 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305855 if (!hHal)
5856 return -EINVAL;
5857
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005858 ret = hdd_set_tx_stbc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005859 break;
5860 }
5861
5862 case WE_SET_RX_STBC:
5863 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305864 if (!hHal)
5865 return -EINVAL;
5866
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005867 ret = hdd_set_rx_stbc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868 break;
5869 }
5870
5871 case WE_SET_SHORT_GI:
5872 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305873 if (!hHal)
5874 return -EINVAL;
5875
5876 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005877 ret = sme_update_ht_config(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005878 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
5879 set_value);
5880 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07005881 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005882 break;
5883 }
5884
5885 case WE_SET_RTSCTS:
5886 {
5887 uint32_t value;
5888
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305889 if (!hHal)
5890 return -EINVAL;
5891
5892 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005893 set_value);
5894
5895 if ((set_value & HDD_RTSCTS_EN_MASK) ==
5896 HDD_RTSCTS_ENABLE)
5897 value =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005898 (WLAN_HDD_GET_CTX(adapter))->config->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899 RTSThreshold;
5900 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
5901 || ((set_value & HDD_RTSCTS_EN_MASK) ==
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305902 HDD_CTS_ENABLE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305904 } else {
5905 ret = -EIO;
5906 goto free;
5907 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005908
Jeff Johnson1b780e42017-10-31 14:11:45 -07005909 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005910 WMI_VDEV_PARAM_ENABLE_RTSCTS,
5911 set_value, VDEV_CMD);
5912 if (!ret) {
5913 if (sme_cfg_set_int
5914 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305915 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005916 hdd_err("FAILED TO SET RTSCTS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305917 ret = -EIO;
5918 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005919 }
5920 }
5921
5922 break;
5923 }
5924
5925 case WE_SET_CHWIDTH:
5926 {
5927 bool chwidth = false;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005928 struct hdd_context *phddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07005929
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305930 if (!hHal)
5931 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 /*updating channel bonding only on 5Ghz */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005934 hdd_debug("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005935 set_value);
5936 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005937 hdd_err("Invalid channel width 0->20 1->40 2->80");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305938 ret = -EINVAL;
5939 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005940 }
5941
5942 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5943 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
5944 nChannelBondingMode5GHz)))
5945 chwidth = true;
5946
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305947 sme_get_config_param(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005948 switch (set_value) {
5949 case eHT_CHANNEL_WIDTH_20MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305950 sme_config->csrConfig.channelBondingMode5GHz =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5952 break;
5953 case eHT_CHANNEL_WIDTH_40MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305954 if (chwidth) {
5955 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956 channelBondingMode5GHz =
5957 phddctx->config->
5958 nChannelBondingMode5GHz;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305959 } else {
5960 ret = -EINVAL;
5961 goto free;
5962 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005963
5964 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005965 case eHT_CHANNEL_WIDTH_80MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305966 if (chwidth) {
5967 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005968 channelBondingMode5GHz =
5969 phddctx->config->
5970 nChannelBondingMode5GHz;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305971 } else {
5972 ret = -EINVAL;
5973 goto free;
5974 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975
5976 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005977
5978 default:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305979 ret = -EINVAL;
5980 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005981 }
5982
Jeff Johnson1b780e42017-10-31 14:11:45 -07005983 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984 WMI_VDEV_PARAM_CHWIDTH,
5985 set_value, VDEV_CMD);
5986 if (!ret)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305987 sme_update_config(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005988
5989 break;
5990 }
5991
5992 case WE_SET_ANI_EN_DIS:
5993 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005994 hdd_debug("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005996 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005997 WMI_PDEV_PARAM_ANI_ENABLE,
5998 set_value, PDEV_CMD);
5999 break;
6000 }
6001
6002 case WE_SET_ANI_POLL_PERIOD:
6003 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006004 hdd_debug("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006005 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006006 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6008 set_value, PDEV_CMD);
6009 break;
6010 }
6011
6012 case WE_SET_ANI_LISTEN_PERIOD:
6013 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006014 hdd_debug("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006016 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6018 set_value, PDEV_CMD);
6019 break;
6020 }
6021
6022 case WE_SET_ANI_OFDM_LEVEL:
6023 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006024 hdd_debug("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006026 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6028 set_value, PDEV_CMD);
6029 break;
6030 }
6031
6032 case WE_SET_ANI_CCK_LEVEL:
6033 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006034 hdd_debug("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006036 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6038 set_value, PDEV_CMD);
6039 break;
6040 }
6041
6042 case WE_SET_DYNAMIC_BW:
6043 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006044 hdd_debug("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006046 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006047 WMI_PDEV_PARAM_DYNAMIC_BW,
6048 set_value, PDEV_CMD);
6049 break;
6050 }
6051
6052 case WE_SET_CTS_CBW:
6053 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006054 hdd_debug("WE_SET_CTS_CBW val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006055 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 WMI_PDEV_PARAM_CTS_CBW,
6057 set_value, PDEV_CMD);
6058 break;
6059 }
6060
6061 case WE_SET_11N_RATE:
6062 {
6063 uint8_t preamble = 0, nss = 0, rix = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006064
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006065 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006066 set_value);
6067
6068 if (set_value != 0xff) {
6069 rix = RC_2_RATE_IDX(set_value);
6070 if (set_value & 0x80) {
6071 preamble = WMI_RATE_PREAMBLE_HT;
6072 nss = HT_RC_2_STREAMS(set_value) - 1;
6073 } else {
6074 nss = 0;
6075 rix = RC_2_RATE_IDX(set_value);
6076 if (set_value & 0x10) {
6077 preamble =
6078 WMI_RATE_PREAMBLE_CCK;
6079 if (rix != 0x3)
6080 /* Enable Short
6081 * preamble always for
6082 * CCK except 1mbps
6083 */
6084 rix |= 0x4;
6085 } else {
6086 preamble =
6087 WMI_RATE_PREAMBLE_OFDM;
6088 }
6089 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006090 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006092 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093 set_value, rix, preamble, nss);
6094
Jeff Johnson1b780e42017-10-31 14:11:45 -07006095 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006096 WMI_VDEV_PARAM_FIXED_RATE,
6097 set_value, VDEV_CMD);
6098 break;
6099 }
6100
6101 case WE_SET_VHT_RATE:
6102 {
6103 uint8_t preamble = 0, nss = 0, rix = 0;
6104
6105 if (set_value != 0xff) {
6106 rix = RC_2_RATE_IDX_11AC(set_value);
6107 preamble = WMI_RATE_PREAMBLE_VHT;
6108 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
6109
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006110 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006111 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006112 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006113 set_value, rix, preamble, nss);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006114 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006115 WMI_VDEV_PARAM_FIXED_RATE,
6116 set_value, VDEV_CMD);
6117 break;
6118 }
6119
6120 case WE_SET_AMPDU:
6121 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006122 hdd_debug("SET AMPDU val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006123 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006124 GEN_VDEV_PARAM_AMPDU,
6125 set_value, GEN_CMD);
6126 break;
6127 }
6128
6129 case WE_SET_AMSDU:
6130 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006131 hdd_debug("SET AMSDU val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006132 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006133 GEN_VDEV_PARAM_AMSDU,
6134 set_value, GEN_CMD);
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07006135 /* Update the stored ini value */
6136 if (!ret)
6137 hdd_ctx->config->max_amsdu_num = set_value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006138 break;
6139 }
6140
6141 case WE_SET_BURST_ENABLE:
6142 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006143 hdd_debug("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006144 if ((set_value == 0) || (set_value == 1)) {
Jeff Johnson1b780e42017-10-31 14:11:45 -07006145 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006146 WMI_PDEV_PARAM_BURST_ENABLE,
6147 set_value, PDEV_CMD);
6148 } else
6149 ret = -EINVAL;
6150 break;
6151 }
6152 case WE_SET_BURST_DUR:
6153 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006154 hdd_debug("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07006155 if ((set_value > 0) && (set_value <= 102400))
Jeff Johnson1b780e42017-10-31 14:11:45 -07006156 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157 WMI_PDEV_PARAM_BURST_DUR,
6158 set_value, PDEV_CMD);
6159 else
6160 ret = -EINVAL;
6161 break;
6162 }
6163
6164 case WE_SET_TX_CHAINMASK:
6165 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006166 hdd_debug("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006167 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006168 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6170 set_value, PDEV_CMD);
6171 break;
6172 }
6173
6174 case WE_SET_RX_CHAINMASK:
6175 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006176 hdd_debug("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006177 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006178 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006179 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6180 set_value, PDEV_CMD);
6181 break;
6182 }
6183
6184 case WE_SET_TXPOW_2G:
6185 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006186 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006187 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006188 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006189 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6190 set_value, PDEV_CMD);
6191 break;
6192 }
6193
6194 case WE_SET_TXPOW_5G:
6195 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006196 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006197 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006198 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6200 set_value, PDEV_CMD);
6201 break;
6202 }
6203
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006204 /* Firmware debug log */
6205 case WE_DBGLOG_LOG_LEVEL:
6206 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006207 hdd_debug("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006208 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006209 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210 WMI_DBGLOG_LOG_LEVEL,
6211 set_value, DBG_CMD);
6212 break;
6213 }
6214
6215 case WE_DBGLOG_VAP_ENABLE:
6216 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006217 hdd_debug("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006218 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006219 WMI_DBGLOG_VAP_ENABLE,
6220 set_value, DBG_CMD);
6221 break;
6222 }
6223
6224 case WE_DBGLOG_VAP_DISABLE:
6225 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006226 hdd_debug("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006227 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006228 WMI_DBGLOG_VAP_DISABLE,
6229 set_value, DBG_CMD);
6230 break;
6231 }
6232
6233 case WE_DBGLOG_MODULE_ENABLE:
6234 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006235 hdd_debug("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006236 set_value);
6237 hdd_ctx->fw_log_settings.enable = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006238 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006239 WMI_DBGLOG_MODULE_ENABLE,
6240 set_value, DBG_CMD);
6241 break;
6242 }
6243
6244 case WE_DBGLOG_MODULE_DISABLE:
6245 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006246 hdd_debug("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006247 set_value);
6248 hdd_ctx->fw_log_settings.enable = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006249 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006250 WMI_DBGLOG_MODULE_DISABLE,
6251 set_value, DBG_CMD);
6252 break;
6253 }
6254 case WE_DBGLOG_MOD_LOG_LEVEL:
6255 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006256 hdd_debug("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006257 set_value);
6258
6259 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
6260 hdd_ctx->fw_log_settings.index = 0;
6261
6262 hdd_ctx->fw_log_settings.
6263 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
6264 set_value;
6265 hdd_ctx->fw_log_settings.index++;
6266
Jeff Johnson1b780e42017-10-31 14:11:45 -07006267 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006268 WMI_DBGLOG_MOD_LOG_LEVEL,
6269 set_value, DBG_CMD);
6270 break;
6271 }
6272
6273 case WE_DBGLOG_TYPE:
6274 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006275 hdd_debug("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006276 hdd_ctx->fw_log_settings.dl_type = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006277 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006278 WMI_DBGLOG_TYPE,
6279 set_value, DBG_CMD);
6280 break;
6281 }
6282 case WE_DBGLOG_REPORT_ENABLE:
6283 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006284 hdd_debug("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006285 set_value);
6286 hdd_ctx->fw_log_settings.dl_report = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006287 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006288 WMI_DBGLOG_REPORT_ENABLE,
6289 set_value, DBG_CMD);
6290 break;
6291 }
6292
6293 case WE_SET_TXRX_FWSTATS:
6294 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006295 hdd_debug("WE_SET_TXRX_FWSTATS val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006296 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006297 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
6298 set_value, VDEV_CMD);
6299 break;
6300 }
6301
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006302 case WE_SET_TXRX_STATS:
6303 {
6304 hdd_notice("WE_SET_TXRX_STATS val %d", set_value);
6305 ret = cds_get_datapath_handles(&soc, &pdev, &vdev,
Jeff Johnson1b780e42017-10-31 14:11:45 -07006306 adapter->session_id);
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006307
Venkata Sharath Chandra Manchalabcdfdb12017-03-29 19:25:45 -07006308 if (ret != 0) {
6309 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
6310 "Invalid handles");
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006311 break;
Venkata Sharath Chandra Manchalabcdfdb12017-03-29 19:25:45 -07006312 }
Venkata Sharath Chandra Manchala1e581102018-02-19 22:42:20 -08006313
6314 req.stats = set_value;
6315 req.channel = adapter->session.station.conn_info.operationChannel;
6316 ret = cdp_txrx_stats_request(soc, vdev, &req);
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006317 break;
6318 }
6319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006320 case WE_TXRX_FWSTATS_RESET:
6321 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006322 hdd_debug("WE_TXRX_FWSTATS_RESET val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006323 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006324 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
6325 set_value, VDEV_CMD);
6326 break;
6327 }
6328
6329 case WE_DUMP_STATS:
6330 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006331 hdd_debug("WE_DUMP_STATS val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006332 ret = hdd_wlan_dump_stats(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006333 break;
6334 }
6335
6336 case WE_CLEAR_STATS:
6337 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006338 hdd_debug("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006339 switch (set_value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006340 case CDP_HDD_STATS:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006341 memset(&adapter->stats, 0, sizeof(adapter->stats));
6342 memset(&adapter->hdd_stats, 0,
6343 sizeof(adapter->hdd_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006344 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006345 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006346 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
6347 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006348 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006349 wlan_hdd_clear_netif_queue_history(hdd_ctx);
6350 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006351 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05306352 hdd_clear_hif_stats();
6353 break;
Yun Park1027e8c2017-10-13 15:17:37 -07006354 case CDP_NAPI_STATS:
6355 hdd_clear_napi_stats();
6356 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006357 default:
Leo Changfdb45c32016-10-28 11:09:23 -07006358 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
6359 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006360 }
6361 break;
6362 }
6363
6364 case WE_PPS_PAID_MATCH:
6365 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006366 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306367 ret = -EINVAL;
6368 goto free;
6369 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006370
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006371 hdd_debug("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006372 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006373 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006374 WMI_VDEV_PPS_PAID_MATCH,
6375 set_value, PPS_CMD);
6376 break;
6377 }
6378
6379 case WE_PPS_GID_MATCH:
6380 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006381 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306382 ret = -EINVAL;
6383 goto free;
6384 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006385 hdd_debug("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006386 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006387 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006388 WMI_VDEV_PPS_GID_MATCH,
6389 set_value, PPS_CMD);
6390 break;
6391 }
6392
6393 case WE_PPS_EARLY_TIM_CLEAR:
6394 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006395 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306396 ret = -EINVAL;
6397 goto free;
6398 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006399 hdd_debug(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006400 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006401 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006402 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6403 set_value, PPS_CMD);
6404 break;
6405 }
6406
6407 case WE_PPS_EARLY_DTIM_CLEAR:
6408 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006409 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306410 ret = -EINVAL;
6411 goto free;
6412 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006413 hdd_debug("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006414 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006415 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006416 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6417 set_value, PPS_CMD);
6418 break;
6419 }
6420
6421 case WE_PPS_EOF_PAD_DELIM:
6422 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006423 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306424 ret = -EINVAL;
6425 goto free;
6426 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006427 hdd_debug("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006428 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006429 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006430 WMI_VDEV_PPS_EOF_PAD_DELIM,
6431 set_value, PPS_CMD);
6432 break;
6433 }
6434
6435 case WE_PPS_MACADDR_MISMATCH:
6436 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006437 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306438 ret = -EINVAL;
6439 goto free;
6440 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006441 hdd_debug("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006442 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006443 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006444 WMI_VDEV_PPS_MACADDR_MISMATCH,
6445 set_value, PPS_CMD);
6446 break;
6447 }
6448
6449 case WE_PPS_DELIM_CRC_FAIL:
6450 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006451 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306452 ret = -EINVAL;
6453 goto free;
6454 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006455 hdd_debug("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006456 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006457 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006458 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6459 set_value, PPS_CMD);
6460 break;
6461 }
6462
6463 case WE_PPS_GID_NSTS_ZERO:
6464 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006465 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306466 ret = -EINVAL;
6467 goto free;
6468 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006469 hdd_debug("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006470 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006471 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006472 WMI_VDEV_PPS_GID_NSTS_ZERO,
6473 set_value, PPS_CMD);
6474 break;
6475 }
6476
6477 case WE_PPS_RSSI_CHECK:
6478 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006479 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306480 ret = -EINVAL;
6481 goto free;
6482 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006483 hdd_debug("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006484 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006485 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486 WMI_VDEV_PPS_RSSI_CHECK,
6487 set_value, PPS_CMD);
6488 break;
6489 }
6490
6491 case WE_PPS_5G_EBT:
6492 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006493 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306494 ret = -EINVAL;
6495 goto free;
6496 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006497
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006498 hdd_debug("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006499 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006500 WMI_VDEV_PPS_5G_EBT,
6501 set_value, PPS_CMD);
6502 break;
6503 }
6504
6505 case WE_SET_HTSMPS:
6506 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006507 hdd_debug("WE_SET_HTSMPS val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006508 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006509 WMI_STA_SMPS_FORCE_MODE_CMDID,
6510 set_value, VDEV_CMD);
6511 break;
6512 }
6513
6514 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6515 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006516 hdd_debug("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006517 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006518 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006519 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6520 set_value, QPOWER_CMD);
6521 break;
6522 }
6523
6524 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6525 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006526 hdd_debug("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006527 set_value);
6528 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006529 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006530 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6531 set_value, QPOWER_CMD);
6532 break;
6533 }
6534
6535 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6536 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006537 hdd_debug("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006538 set_value);
6539 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006540 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006541 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6542 set_value, QPOWER_CMD);
6543 break;
6544 }
6545
6546 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6547 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006548 hdd_debug("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006549 set_value);
6550 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006551 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006552 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6553 set_value, QPOWER_CMD);
6554 break;
6555 }
6556
6557 case WE_MCC_CONFIG_LATENCY:
6558 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006559 wlan_hdd_set_mcc_latency(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006560 break;
6561 }
6562
6563 case WE_MCC_CONFIG_QUOTA:
6564 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006565 hdd_debug("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006566 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006567 ret = wlan_hdd_set_mcc_p2p_quota(adapter,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08006568 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006569 break;
6570 }
6571 case WE_SET_DEBUG_LOG:
6572 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006573 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07006574
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05306575 if (!hHal)
6576 return -EINVAL;
6577
Nirav Shah1da77682016-05-03 20:16:39 +05306578
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006579 hdd_ctx->config->gEnableDebugLog = set_value;
6580 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6581 break;
6582 }
6583 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6584 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006585 hdd_debug("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006586 if ((set_value == 0) || (set_value == 1))
6587 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006588 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006589 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6590 set_value, VDEV_CMD);
6591 else
6592 ret = -EINVAL;
6593 break;
6594 }
6595 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6596 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006597 hdd_debug("SET early_rx bmiss val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006598 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006599 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6600 set_value, VDEV_CMD);
6601 break;
6602 }
6603 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6604 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006605 hdd_debug("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006606 set_value);
6607 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006608 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006609 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6610 set_value, VDEV_CMD);
6611 break;
6612 }
6613 case WE_SET_EARLY_RX_SLOP_STEP:
6614 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006615 hdd_debug("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006616 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006617 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006618 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6619 set_value, VDEV_CMD);
6620 break;
6621 }
6622 case WE_SET_EARLY_RX_INIT_SLOP:
6623 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006624 hdd_debug("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006625 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006626 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006627 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6628 set_value, VDEV_CMD);
6629 break;
6630 }
6631 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6632 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006633 hdd_debug("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006634 if ((set_value == 0) || (set_value == 1))
6635 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006636 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006637 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6638 set_value, VDEV_CMD);
6639 else
6640 ret = -EINVAL;
6641 break;
6642 }
6643 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6644 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006645 hdd_debug("SET early_rx drift sample %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006646 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006647 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6648 set_value, VDEV_CMD);
6649 break;
6650 }
6651 case WE_SET_SCAN_DISABLE:
6652 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05306653 if (!hHal)
6654 return -EINVAL;
6655
6656 hdd_notice("SET SCAN DISABLE %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006657 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(adapter), set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006658 break;
6659 }
Govind Singha471e5e2015-10-12 17:11:14 +05306660 case WE_START_FW_PROFILE:
6661 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006662 hdd_debug("WE_START_FW_PROFILE %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006663 ret = wma_cli_set_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +05306664 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6665 set_value, DBG_CMD);
6666 break;
6667 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306668 case WE_SET_CHANNEL:
6669 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006670 hdd_debug("Set Channel %d Session ID %d mode %d", set_value,
Jeff Johnson1b780e42017-10-31 14:11:45 -07006671 adapter->session_id, adapter->device_mode);
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05306672 if (!hHal)
6673 return -EINVAL;
6674
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306675
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006676 if ((QDF_STA_MODE == adapter->device_mode) ||
6677 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306678
6679 status = sme_ext_change_channel(hHal,
Jeff Johnson1b780e42017-10-31 14:11:45 -07006680 set_value, adapter->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306681 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006682 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306683 status);
6684 ret = -EINVAL;
6685 }
6686 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006687 hdd_err("change channel not supported for device mode %d",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006688 adapter->device_mode);
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306689 ret = -EINVAL;
6690 }
6691 break;
6692 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306693 case WE_SET_CONC_SYSTEM_PREF:
6694 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006695 hdd_debug("New preference: %d", set_value);
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306696 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6697 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6698 hdd_err("Invalid system preference %d", set_value);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306699 ret = -EINVAL;
6700 goto free;
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306701 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306702
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306703 /* hdd_ctx, hdd_ctx->config are already checked for null */
6704 hdd_ctx->config->conc_system_pref = set_value;
6705 break;
6706 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006707 case WE_SET_11AX_RATE:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006708 ret = hdd_set_11ax_rate(adapter, set_value, NULL);
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006709 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07006710 case WE_SET_DCM:
6711 hdd_notice("Set WMI_VDEV_PARAM_HE_DCM: %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006712 ret = wma_cli_set_command(adapter->session_id,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07006713 WMI_VDEV_PARAM_HE_DCM, set_value,
6714 VDEV_CMD);
6715 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07006716 case WE_SET_RANGE_EXT:
6717 hdd_notice("Set WMI_VDEV_PARAM_HE_RANGE_EXT: %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006718 ret = wma_cli_set_command(adapter->session_id,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07006719 WMI_VDEV_PARAM_HE_RANGE_EXT,
6720 set_value, VDEV_CMD);
6721 break;
Jeff Johnson011c4502017-10-05 15:25:56 -07006722 case WE_SET_PDEV_RESET:
6723 ret = hdd_handle_pdev_reset(adapter, set_value);
6724 break;
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05306725 case WE_SET_MODULATED_DTIM:
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05306726 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6727 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6728 hdd_err("Invalid gEnableModuleDTIM value %d",
6729 set_value);
6730 return -EINVAL;
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05306731 }
Jeff Johnsonc66d3102018-02-28 11:58:26 -08006732
6733 hdd_ctx->config->enableModulatedDTIM = set_value;
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05306734 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006735 default:
Rajeev Kumard0565362018-03-01 12:02:01 -08006736 hdd_debug("Invalid sub command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006737 ret = -EINVAL;
6738 break;
6739 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306740 EXIT();
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306741free:
6742 qdf_mem_free(sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006743 return ret;
6744}
6745
6746static int iw_setint_getnone(struct net_device *dev,
6747 struct iw_request_info *info,
6748 union iwreq_data *wrqu,
6749 char *extra)
6750{
6751 int ret;
6752
6753 cds_ssr_protect(__func__);
6754 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6755 cds_ssr_unprotect(__func__);
6756
6757 return ret;
6758}
6759
6760/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006761 * __iw_setnone_get_threeint() - return three value to up layer.
6762 *
6763 * @dev: pointer of net_device of this wireless card
6764 * @info: meta data about Request sent
6765 * @wrqu: include request info
6766 * @extra: buf used for in/Output
6767 *
6768 * Return: execute result
6769 */
6770static int __iw_setnone_get_threeint(struct net_device *dev,
6771 struct iw_request_info *info,
6772 union iwreq_data *wrqu, char *extra)
6773{
6774 int ret = 0; /* success */
6775 uint32_t *value = (int *)extra;
Jeff Johnson3d278b02017-08-29 14:17:47 -07006776 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006777 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006778
Dustin Brownfdf17c12018-03-14 12:55:34 -07006779 hdd_enter_dev(dev);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006780 ret = wlan_hdd_validate_context(hdd_ctx);
6781 if (0 != ret)
6782 return ret;
6783
Jeff Johnson441e1f72017-02-07 08:50:49 -08006784 ret = hdd_check_private_wext_control(hdd_ctx, info);
6785 if (0 != ret)
6786 return ret;
6787
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006788 hdd_debug("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006789 switch (value[0]) {
6790 case WE_GET_TSF:
6791 ret = hdd_indicate_tsf(adapter, value, 3);
6792 break;
6793 default:
6794 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6795 break;
6796 }
6797 return ret;
6798}
6799
6800/**
6801 * iw_setnone_get_threeint() - return three value to up layer.
6802 *
6803 * @dev: pointer of net_device of this wireless card
6804 * @info: meta data about Request sent
6805 * @wrqu: include request info
6806 * @extra: buf used for in/Output
6807 *
6808 * Return: execute result
6809 */
6810static int iw_setnone_get_threeint(struct net_device *dev,
6811 struct iw_request_info *info,
6812 union iwreq_data *wrqu, char *extra)
6813{
6814 int ret;
6815
6816 cds_ssr_protect(__func__);
6817 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6818 cds_ssr_unprotect(__func__);
6819
6820 return ret;
6821}
6822
6823/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006824 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6825 * @dev: device upon which the ioctl was received
6826 * @info: ioctl request information
6827 * @wrqu: ioctl request data
6828 * @extra: ioctl extra data
6829 *
6830 * Return: 0 on success, non-zero on error
6831 */
6832static int __iw_setchar_getnone(struct net_device *dev,
6833 struct iw_request_info *info,
6834 union iwreq_data *wrqu, char *extra)
6835{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306836 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006837 int sub_cmd;
6838 int ret;
6839 char *pBuffer = NULL;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006840 struct hdd_adapter *adapter = (netdev_priv(dev));
6841 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006842 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006843 struct iw_point s_priv_data;
6844
Dustin Brownfdf17c12018-03-14 12:55:34 -07006845 hdd_enter_dev(dev);
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006846
Mukul Sharma34777c62015-11-02 20:22:30 +05306847 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006848 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306849 return -EPERM;
6850 }
6851
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006852 ret = wlan_hdd_validate_context(hdd_ctx);
6853 if (0 != ret)
6854 return ret;
6855
Jeff Johnson441e1f72017-02-07 08:50:49 -08006856 ret = hdd_check_private_wext_control(hdd_ctx, info);
6857 if (0 != ret)
6858 return ret;
6859
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006860 /* helper function to get iwreq_data with compat handling. */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006861 if (hdd_priv_get_data(&s_priv_data, wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006862 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006863
6864 /* make sure all params are correctly passed to function */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006865 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006866 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006867
6868 sub_cmd = s_priv_data.flags;
6869
6870 /* ODD number is used for set, copy data using copy_from_user */
6871 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6872 s_priv_data.length);
6873 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006874 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006875 return -ENOMEM;
6876 }
6877
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006878 hdd_debug("Received length: %d data: %s",
6879 s_priv_data.length, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006880
6881 switch (sub_cmd) {
6882 case WE_WOWL_ADD_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006883 hdd_debug("ADD_PTRN");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006884 hdd_add_wowl_ptrn(adapter, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006885 break;
6886 case WE_WOWL_DEL_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006887 hdd_debug("DEL_PTRN");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006888 hdd_del_wowl_ptrn(adapter, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006889 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006890 case WE_NEIGHBOR_REPORT_REQUEST:
6891 {
6892 tRrmNeighborReq neighborReq;
6893 tRrmNeighborRspCallbackInfo callbackInfo;
6894
6895 if (pConfig->fRrmEnable) {
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306896 neighborReq.neighbor_report_offload = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006897 neighborReq.no_ssid =
6898 (s_priv_data.length - 1) ? false : true;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306899 hdd_debug("Neighbor Request ssid present %d",
6900 neighborReq.no_ssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006901 if (!neighborReq.no_ssid) {
6902 neighborReq.ssid.length =
6903 (s_priv_data.length - 1) >
6904 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306905 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006906 pBuffer,
6907 neighborReq.ssid.length);
6908 }
6909
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306910 /*
6911 * If 11k offload is supported by FW and enabled
6912 * in the ini, set the offload to true
6913 */
6914 if (hdd_ctx->config->is_11k_offload_supported &&
6915 (hdd_ctx->config->offload_11k_enable_bitmask &
6916 OFFLOAD_11K_BITMASK_NEIGHBOR_REPORT_REQUEST)) {
6917 hdd_debug("Neighbor report offloaded to FW");
6918 neighborReq.neighbor_report_offload = true;
6919 }
6920
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006921 callbackInfo.neighborRspCallback = NULL;
6922 callbackInfo.neighborRspCallbackContext = NULL;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306923 callbackInfo.timeout = 5000; /* 5 seconds */
6924 sme_neighbor_report_request(
6925 WLAN_HDD_GET_HAL_CTX(adapter),
6926 adapter->session_id,
6927 &neighborReq,
6928 &callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006929 } else {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006930 hdd_err("Ignoring neighbor request as RRM not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006931 ret = -EINVAL;
6932 }
6933 }
6934 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006935 case WE_SET_AP_WPS_IE:
Wu Gao02bd75b2017-10-13 18:34:02 +08006936 hdd_debug("Received WE_SET_AP_WPS_IE, won't process");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006937 break;
6938 case WE_SET_CONFIG:
6939 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006940 if (QDF_STATUS_SUCCESS != vstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006941 ret = -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006942
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006943 break;
6944 default:
6945 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006946 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006947 sub_cmd);
6948 ret = -EINVAL;
6949 break;
6950 }
6951 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07006952 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306953 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006954 return ret;
6955}
6956
6957static int iw_setchar_getnone(struct net_device *dev,
6958 struct iw_request_info *info,
6959 union iwreq_data *wrqu, char *extra)
6960{
6961 int ret;
6962
6963 cds_ssr_protect(__func__);
6964 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6965 cds_ssr_unprotect(__func__);
6966
6967 return ret;
6968}
6969
6970/**
6971 * iw_setnone_getint() - Generic "get integer" private ioctl handler
6972 * @dev: device upon which the ioctl was received
6973 * @info: ioctl request information
6974 * @wrqu: ioctl request data
6975 * @extra: ioctl extra data
6976 *
6977 * Return: 0 on success, non-zero on error
6978 */
6979static int __iw_setnone_getint(struct net_device *dev,
6980 struct iw_request_info *info,
6981 union iwreq_data *wrqu, char *extra)
6982{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006983 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6984 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006985 int *value = (int *)extra;
6986 int ret;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306987 tSmeConfigParams *sme_config;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006988 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006989
Dustin Brownfdf17c12018-03-14 12:55:34 -07006990 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306991
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006992 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006993 ret = wlan_hdd_validate_context(hdd_ctx);
6994 if (0 != ret)
6995 return ret;
6996
Jeff Johnson441e1f72017-02-07 08:50:49 -08006997 ret = hdd_check_private_wext_control(hdd_ctx, info);
6998 if (0 != ret)
6999 return ret;
7000
Rajeev Kumar1117fcf2018-02-15 16:25:19 -08007001 sme_config = qdf_mem_malloc(sizeof(*sme_config));
7002 if (!sme_config) {
7003 hdd_err("failed to allocate memory for sme_config");
7004 return -ENOMEM;
7005 }
7006
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007007 switch (value[0]) {
7008 case WE_GET_11D_STATE:
7009 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307010 sme_get_config_param(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007011
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307012 *value = sme_config->csrConfig.Is11dSupportEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007013
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007014 hdd_debug("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007015
7016 break;
7017 }
7018
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007019 case WE_GET_WLAN_DBG:
7020 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307021 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007022 *value = 0;
7023 break;
7024 }
7025 case WE_GET_MAX_ASSOC:
7026 {
7027 if (sme_cfg_get_int
7028 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307029 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007030 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007031 ret = -EIO;
7032 }
7033 break;
7034 }
7035 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
7036 *value = (WLAN_HDD_GET_CTX(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007037 adapter))->config->force_sap_acs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007038 break;
7039
7040 case WE_GET_CONCURRENCY_MODE:
7041 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08007042 *value = policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007043
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007044 hdd_debug("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007045 break;
7046 }
7047
7048 case WE_GET_NSS:
7049 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307050 sme_get_config_param(hHal, sme_config);
7051 *value = (sme_config->csrConfig.enable2x2 == 0) ? 1 : 2;
Srinivas Girigowda576b2352017-08-25 14:44:26 -07007052 if (policy_mgr_is_current_hwmode_dbs(hdd_ctx->hdd_psoc))
7053 *value = *value - 1;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007054 hdd_debug("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007055 break;
7056 }
7057
7058 case WE_GET_GTX_HT_MCS:
7059 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007060 hdd_debug("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007061 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007062 WMI_VDEV_PARAM_GTX_HT_MCS,
7063 GTX_CMD);
7064 break;
7065 }
7066
7067 case WE_GET_GTX_VHT_MCS:
7068 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007069 hdd_debug("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007070 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007071 WMI_VDEV_PARAM_GTX_VHT_MCS,
7072 GTX_CMD);
7073 break;
7074 }
7075
7076 case WE_GET_GTX_USRCFG:
7077 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007078 hdd_debug("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007079 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007080 WMI_VDEV_PARAM_GTX_USR_CFG,
7081 GTX_CMD);
7082 break;
7083 }
7084
7085 case WE_GET_GTX_THRE:
7086 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007087 hdd_debug("GET WMI_VDEV_PARAM_GTX_THRE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007088 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007089 WMI_VDEV_PARAM_GTX_THRE,
7090 GTX_CMD);
7091 break;
7092 }
7093
7094 case WE_GET_GTX_MARGIN:
7095 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007096 hdd_debug("GET WMI_VDEV_PARAM_GTX_MARGIN");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007097 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007098 WMI_VDEV_PARAM_GTX_MARGIN,
7099 GTX_CMD);
7100 break;
7101 }
7102
7103 case WE_GET_GTX_STEP:
7104 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007105 hdd_debug("GET WMI_VDEV_PARAM_GTX_STEP");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007106 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007107 WMI_VDEV_PARAM_GTX_STEP,
7108 GTX_CMD);
7109 break;
7110 }
7111
7112 case WE_GET_GTX_MINTPC:
7113 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007114 hdd_debug("GET WMI_VDEV_PARAM_GTX_MINTPC");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007115 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007116 WMI_VDEV_PARAM_GTX_MINTPC,
7117 GTX_CMD);
7118 break;
7119 }
7120
7121 case WE_GET_GTX_BWMASK:
7122 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007123 hdd_debug("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007124 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007125 WMI_VDEV_PARAM_GTX_BW_MASK,
7126 GTX_CMD);
7127 break;
7128 }
7129
7130 case WE_GET_LDPC:
7131 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007132 ret = hdd_get_ldpc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007133 break;
7134 }
7135
7136 case WE_GET_TX_STBC:
7137 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007138 ret = hdd_get_tx_stbc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007139 break;
7140 }
7141
7142 case WE_GET_RX_STBC:
7143 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007144 ret = hdd_get_rx_stbc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007145 break;
7146 }
7147
7148 case WE_GET_SHORT_GI:
7149 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007150 hdd_debug("GET WMI_VDEV_PARAM_SGI");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007151 *value = wma_cli_get_command(adapter->session_id,
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08007152 WMI_VDEV_PARAM_SGI,
7153 VDEV_CMD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007154 break;
7155 }
7156
7157 case WE_GET_RTSCTS:
7158 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007159 hdd_debug("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007160 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007161 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7162 VDEV_CMD);
7163 break;
7164 }
7165
7166 case WE_GET_CHWIDTH:
7167 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007168 hdd_debug("GET WMI_VDEV_PARAM_CHWIDTH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007169 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007170 WMI_VDEV_PARAM_CHWIDTH,
7171 VDEV_CMD);
7172 break;
7173 }
7174
7175 case WE_GET_ANI_EN_DIS:
7176 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007177 hdd_debug("GET WMI_PDEV_PARAM_ANI_ENABLE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007178 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007179 WMI_PDEV_PARAM_ANI_ENABLE,
7180 PDEV_CMD);
7181 break;
7182 }
7183
7184 case WE_GET_ANI_POLL_PERIOD:
7185 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007186 hdd_debug("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007187 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007188 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
7189 PDEV_CMD);
7190 break;
7191 }
7192
7193 case WE_GET_ANI_LISTEN_PERIOD:
7194 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007195 hdd_debug("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007196 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007197 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
7198 PDEV_CMD);
7199 break;
7200 }
7201
7202 case WE_GET_ANI_OFDM_LEVEL:
7203 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007204 hdd_debug("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007205 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007206 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
7207 PDEV_CMD);
7208 break;
7209 }
7210
7211 case WE_GET_ANI_CCK_LEVEL:
7212 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007213 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007214 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007215 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
7216 PDEV_CMD);
7217 break;
7218 }
7219
7220 case WE_GET_DYNAMIC_BW:
7221 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007222 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007223 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007224 WMI_PDEV_PARAM_DYNAMIC_BW,
7225 PDEV_CMD);
7226 break;
7227 }
7228
7229 case WE_GET_11N_RATE:
7230 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007231 hdd_debug("GET WMI_VDEV_PARAM_FIXED_RATE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007232 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007233 WMI_VDEV_PARAM_FIXED_RATE,
7234 VDEV_CMD);
7235 break;
7236 }
7237
7238 case WE_GET_AMPDU:
7239 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007240 hdd_debug("GET AMPDU");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007241 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007242 GEN_VDEV_PARAM_AMPDU,
7243 GEN_CMD);
7244 break;
7245 }
7246
7247 case WE_GET_AMSDU:
7248 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007249 hdd_debug("GET AMSDU");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007250 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007251 GEN_VDEV_PARAM_AMSDU,
7252 GEN_CMD);
7253 break;
7254 }
7255
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007256 case WE_GET_ROAM_SYNCH_DELAY:
7257 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007258 hdd_debug("GET ROAM SYNCH DELAY");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007259 *value = wma_cli_get_command(adapter->session_id,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007260 GEN_VDEV_ROAM_SYNCH_DELAY,
7261 GEN_CMD);
7262 break;
7263 }
7264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007265 case WE_GET_BURST_ENABLE:
7266 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007267 hdd_debug("GET Burst enable value");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007268 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007269 WMI_PDEV_PARAM_BURST_ENABLE,
7270 PDEV_CMD);
7271 break;
7272 }
7273 case WE_GET_BURST_DUR:
7274 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007275 hdd_debug("GET Burst Duration value");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007276 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007277 WMI_PDEV_PARAM_BURST_DUR,
7278 PDEV_CMD);
7279 break;
7280 }
7281
7282 case WE_GET_TX_CHAINMASK:
7283 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007284 hdd_debug("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007285 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007286 WMI_PDEV_PARAM_TX_CHAIN_MASK,
7287 PDEV_CMD);
7288 break;
7289 }
7290
7291 case WE_GET_RX_CHAINMASK:
7292 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007293 hdd_debug("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007294 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007295 WMI_PDEV_PARAM_RX_CHAIN_MASK,
7296 PDEV_CMD);
7297 break;
7298 }
7299
7300 case WE_GET_TXPOW_2G:
7301 {
7302 uint32_t txpow2g = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007303 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007304
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007305 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007306 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007307 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
7308 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307309 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007310 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7311 &txpow2g)) {
7312 return -EIO;
7313 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007314 hdd_debug("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007315 break;
7316 }
7317
7318 case WE_GET_TXPOW_5G:
7319 {
7320 uint32_t txpow5g = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007321 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007322
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007323 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007324 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007325 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
7326 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307327 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007328 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7329 &txpow5g)) {
7330 return -EIO;
7331 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007332 hdd_debug("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007333 break;
7334 }
7335
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007336 case WE_GET_PPS_PAID_MATCH:
7337 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007338 hdd_debug("GET WMI_VDEV_PPS_PAID_MATCH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007339 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007340 WMI_VDEV_PPS_PAID_MATCH,
7341 PPS_CMD);
7342 break;
7343 }
7344
7345 case WE_GET_PPS_GID_MATCH:
7346 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007347 hdd_debug("GET WMI_VDEV_PPS_GID_MATCH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007348 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007349 WMI_VDEV_PPS_GID_MATCH,
7350 PPS_CMD);
7351 break;
7352 }
7353
7354 case WE_GET_PPS_EARLY_TIM_CLEAR:
7355 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007356 hdd_debug("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007357 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007358 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
7359 PPS_CMD);
7360 break;
7361 }
7362
7363 case WE_GET_PPS_EARLY_DTIM_CLEAR:
7364 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007365 hdd_debug("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007366 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007367 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
7368 PPS_CMD);
7369 break;
7370 }
7371
7372 case WE_GET_PPS_EOF_PAD_DELIM:
7373 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007374 hdd_debug("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007375 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007376 WMI_VDEV_PPS_EOF_PAD_DELIM,
7377 PPS_CMD);
7378 break;
7379 }
7380
7381 case WE_GET_PPS_MACADDR_MISMATCH:
7382 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007383 hdd_debug("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007384 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007385 WMI_VDEV_PPS_MACADDR_MISMATCH,
7386 PPS_CMD);
7387 break;
7388 }
7389
7390 case WE_GET_PPS_DELIM_CRC_FAIL:
7391 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007392 hdd_debug("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007393 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007394 WMI_VDEV_PPS_DELIM_CRC_FAIL,
7395 PPS_CMD);
7396 break;
7397 }
7398
7399 case WE_GET_PPS_GID_NSTS_ZERO:
7400 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007401 hdd_debug("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007402 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007403 WMI_VDEV_PPS_GID_NSTS_ZERO,
7404 PPS_CMD);
7405 break;
7406 }
7407
7408 case WE_GET_PPS_RSSI_CHECK:
7409 {
7410
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007411 hdd_debug("GET WMI_VDEV_PPS_RSSI_CHECK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007412 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007413 WMI_VDEV_PPS_RSSI_CHECK,
7414 PPS_CMD);
7415 break;
7416 }
7417
7418 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
7419 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007420 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007421 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007422 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
7423 QPOWER_CMD);
7424 break;
7425 }
7426
7427 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
7428 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007429 hdd_debug("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007430 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007431 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
7432 QPOWER_CMD);
7433 break;
7434 }
7435
7436 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
7437 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007438 hdd_debug("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007439 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007440 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
7441 QPOWER_CMD);
7442 break;
7443 }
7444
7445 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
7446 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007447 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007448 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007449 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
7450 QPOWER_CMD);
7451 break;
7452 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07007453 case WE_CAP_TSF:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007454 ret = hdd_capture_tsf(adapter, (uint32_t *)value, 1);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07007455 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007456 case WE_GET_TEMPERATURE:
7457 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007458 hdd_debug("WE_GET_TEMPERATURE");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007459 ret = wlan_hdd_get_temperature(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007460 break;
7461 }
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07007462 case WE_GET_DCM:
7463 hdd_notice("GET WMI_VDEV_PARAM_HE_DCM");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007464 *value = wma_cli_get_command(adapter->session_id,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07007465 WMI_VDEV_PARAM_HE_DCM,
7466 VDEV_CMD);
7467 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07007468 case WE_GET_RANGE_EXT:
7469 hdd_notice("GET WMI_VDEV_PARAM_HE_RANGE_EXT");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007470 *value = wma_cli_get_command(adapter->session_id,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07007471 WMI_VDEV_PARAM_HE_RANGE_EXT,
7472 VDEV_CMD);
7473 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007474 default:
7475 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007476 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007477 value[0]);
7478 break;
7479 }
7480 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307481 EXIT();
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307482 qdf_mem_free(sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007483 return ret;
7484}
7485
7486static int iw_setnone_getint(struct net_device *dev,
7487 struct iw_request_info *info,
7488 union iwreq_data *wrqu, char *extra)
7489{
7490 int ret;
7491
7492 cds_ssr_protect(__func__);
7493 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7494 cds_ssr_unprotect(__func__);
7495
7496 return ret;
7497}
7498
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307499static int hdd_set_fwtest(int argc, int cmd, int value)
7500{
7501 struct set_fwtest_params *fw_test;
7502
7503 /* check for max number of arguments */
7504 if (argc > (WMA_MAX_NUM_ARGS) ||
7505 argc != HDD_FWTEST_PARAMS) {
7506 hdd_err("Too Many args %d", argc);
7507 return -EINVAL;
7508 }
7509 /*
7510 * check if number of arguments are 3 then, check
7511 * then set the default value for sounding interval.
7512 */
7513 if (HDD_FWTEST_PARAMS == argc) {
7514 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7515 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7516 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7517 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7518 }
7519 /* check sounding interval value should not exceed to max */
7520 if (value > HDD_FWTEST_MAX_VALUE) {
7521 hdd_err("Invalid arguments value should not exceed max: %d",
7522 value);
7523 return -EINVAL;
7524 }
7525 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7526 if (NULL == fw_test) {
7527 hdd_err("qdf_mem_malloc failed for fw_test");
7528 return -ENOMEM;
7529 }
7530 fw_test->arg = cmd;
7531 fw_test->value = value;
7532 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7533 qdf_mem_free(fw_test);
7534 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7535 return -EINVAL;
7536 }
7537 return 0;
7538}
7539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007540/**
7541 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7542 * @dev: device upon which the ioctl was received
7543 * @info: ioctl request information
7544 * @wrqu: ioctl request data
7545 * @extra: ioctl extra data
7546 *
7547 * Return: 0 on success, non-zero on error
7548 */
7549static int __iw_set_three_ints_getnone(struct net_device *dev,
7550 struct iw_request_info *info,
7551 union iwreq_data *wrqu, char *extra)
7552{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007553 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007554 int *value = (int *)extra;
7555 int sub_cmd = value[0];
7556 int ret;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007557 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007558
Dustin Brownfdf17c12018-03-14 12:55:34 -07007559 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307560
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007561 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007562 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007563 return -EPERM;
7564 }
7565
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007566 ret = wlan_hdd_validate_context(hdd_ctx);
7567 if (0 != ret)
7568 return ret;
7569
Jeff Johnson441e1f72017-02-07 08:50:49 -08007570 ret = hdd_check_private_wext_control(hdd_ctx, info);
7571 if (0 != ret)
7572 return ret;
7573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007574 switch (sub_cmd) {
7575
7576 case WE_SET_WLAN_DBG:
Dustin Brown36e2e5c2017-05-16 15:41:37 -07007577 qdf_print_set_category_verbose(qdf_get_pidx(), value[1],
7578 value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007579 break;
7580 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307581 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007582 break;
7583
7584 /* value[3] the acs band is not required as start and end channels are
7585 * enough but this cmd is maintained under set three ints for historic
7586 * reasons.
7587 */
7588 case WE_SET_SAP_CHANNELS:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007589 if (wlan_hdd_validate_operation_channel(adapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307590 QDF_STATUS_SUCCESS ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007591 wlan_hdd_validate_operation_channel(adapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307592 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007593 ret = -EINVAL;
7594 } else {
7595 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7596 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7597 }
7598 break;
7599 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7600 hdd_debug("Ioctl to set dual mac scan config");
Tushnim Bhattacharyya49ed8ab2017-05-26 18:20:10 -07007601 if (hdd_ctx->config->dual_mac_feature_disable ==
7602 DISABLE_DBS_CXN_AND_SCAN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007603 hdd_err("Dual mac feature is disabled from INI");
7604 return -EPERM;
7605 }
7606 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08007607 policy_mgr_set_dual_mac_scan_config(hdd_ctx->hdd_psoc,
7608 value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007609 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307610 case WE_SET_FW_TEST:
7611 {
7612 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7613 if (ret) {
7614 hdd_err("Not able to set fwtest %d", ret);
7615 return ret;
7616 }
7617 }
7618 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007619 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007620 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007621 break;
7622
7623 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307624 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007625 return ret;
7626}
7627
7628int iw_set_three_ints_getnone(struct net_device *dev,
7629 struct iw_request_info *info,
7630 union iwreq_data *wrqu, char *extra)
7631{
7632 int ret;
7633
7634 cds_ssr_protect(__func__);
7635 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7636 cds_ssr_unprotect(__func__);
7637
7638 return ret;
7639}
7640
7641/**
7642 * hdd_connection_state_string() - Get connection state string
7643 * @connection_state: enum to be converted to a string
7644 *
7645 * Return: the string equivalent of @connection_state
7646 */
7647static const char *
7648hdd_connection_state_string(eConnectionState connection_state)
7649{
7650 switch (connection_state) {
7651 CASE_RETURN_STRING(eConnectionState_NotConnected);
7652 CASE_RETURN_STRING(eConnectionState_Connecting);
7653 CASE_RETURN_STRING(eConnectionState_Associated);
7654 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7655 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7656 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7657 default:
7658 return "UNKNOWN";
7659 }
7660}
7661
Naveen Rawat910726a2017-03-06 11:42:51 -08007662#if defined(FEATURE_OEM_DATA_SUPPORT)
7663/**
7664 * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
7665 * wifi_pos api to get oem data caps
7666 * @dev: net device upon which the request was received
7667 * @info: ioctl request information
7668 * @wrqu: ioctl request data
7669 * @extra: ioctl data payload
7670 *
7671 * Return: 0 for success, negative errno value on failure
7672 */
7673static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
7674 struct iw_request_info *info,
7675 union iwreq_data *wrqu, char *extra)
7676{
7677 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7678}
7679#elif defined(WIFI_POS_CONVERGED)
7680static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
7681 struct iw_request_info *info,
7682 union iwreq_data *wrqu, char *extra)
7683{
Jeff Johnson3d278b02017-08-29 14:17:47 -07007684 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007685 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Naveen Rawat910726a2017-03-06 11:42:51 -08007686
7687 return os_if_wifi_pos_populate_caps(hdd_ctx->hdd_psoc,
7688 (struct wifi_pos_driver_caps *)extra);
7689}
7690#else
7691static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
7692 struct iw_request_info *info,
7693 union iwreq_data *wrqu, char *extra)
7694{
7695 return -ENOTSUPP;
7696}
7697#endif
7698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007699/**
7700 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7701 * @dev: device upon which the ioctl was received
7702 * @info: ioctl request information
7703 * @wrqu: ioctl request data
7704 * @extra: ioctl extra data
7705 *
7706 * Return: 0 on success, non-zero on error
7707 */
7708static int __iw_get_char_setnone(struct net_device *dev,
7709 struct iw_request_info *info,
7710 union iwreq_data *wrqu, char *extra)
7711{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007712 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007713 int sub_cmd = wrqu->data.flags;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007714 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007715 int ret;
7716#ifdef WLAN_FEATURE_11W
Jeff Johnson2a722002017-09-30 20:02:35 -07007717 struct hdd_wext_state *pWextState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007718#endif
7719
7720#ifdef WLAN_FEATURE_11W
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007721 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007722#endif
7723
Dustin Brownfdf17c12018-03-14 12:55:34 -07007724 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307725
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007726 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007727 ret = wlan_hdd_validate_context(hdd_ctx);
7728 if (0 != ret)
7729 return ret;
7730
Jeff Johnson441e1f72017-02-07 08:50:49 -08007731 ret = hdd_check_private_wext_control(hdd_ctx, info);
7732 if (0 != ret)
7733 return ret;
7734
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007735 switch (sub_cmd) {
7736 case WE_WLAN_VERSION:
7737 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307738 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007739 break;
7740 }
7741
7742 case WE_GET_STATS:
7743 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007744 hdd_wlan_get_stats(adapter, &(wrqu->data.length),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007745 extra, WE_MAX_STR_LEN);
7746 break;
7747 }
7748
Dustin Brownd9322482017-01-09 12:46:03 -08007749 case WE_GET_SUSPEND_RESUME_STATS:
7750 {
7751 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
7752 WE_MAX_STR_LEN);
7753 if (ret >= 0) {
7754 wrqu->data.length = ret;
7755 ret = 0;
7756 }
7757
7758 break;
7759 }
7760
Govind Singha471e5e2015-10-12 17:11:14 +05307761 case WE_LIST_FW_PROFILE:
7762 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7763 extra, WE_MAX_STR_LEN);
7764 break;
7765
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007766 /* The case prints the current state of the HDD, SME, CSR, PE,
7767 * TL it can be extended for WDI Global State as well. And
7768 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7769 * and P2P_GO have not been added as of now.
7770 */
7771 case WE_GET_STATES:
7772 {
7773 int buf = 0, len = 0;
7774 int adapter_num = 0;
7775 int count = 0, check = 1;
7776
7777 tHalHandle hHal = NULL;
7778 tpAniSirGlobal pMac = NULL;
Jeff Johnsond377dce2017-10-04 10:32:42 -07007779 struct hdd_station_ctx *sta_ctx = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007780
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007781 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson3d278b02017-08-29 14:17:47 -07007782 struct hdd_adapter *useAdapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007783
7784 /* Print wlan0 or p2p0 states based on the adapter_num
7785 * by using the correct adapter
7786 */
7787 while (adapter_num < 2) {
7788 if (WLAN_ADAPTER == adapter_num) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007789 useAdapter = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007790 buf =
7791 scnprintf(extra + len,
7792 WE_MAX_STR_LEN - len,
7793 "\n\n wlan0 States:-");
7794 len += buf;
7795 } else if (P2P_ADAPTER == adapter_num) {
7796 buf =
7797 scnprintf(extra + len,
7798 WE_MAX_STR_LEN - len,
7799 "\n\n p2p0 States:-");
7800 len += buf;
7801
Jeff Johnsonce2ee982017-09-03 09:27:35 -07007802 if (!hdd_ctx) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007803 buf =
7804 scnprintf(extra + len,
7805 WE_MAX_STR_LEN -
7806 len,
Jeff Johnsonce2ee982017-09-03 09:27:35 -07007807 "\n hdd_ctx is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007808 len += buf;
7809 break;
7810 }
7811
7812 /* Printing p2p0 states only in the
7813 * case when the device is configured
7814 * as a p2p_client
7815 */
7816 useAdapter =
Jeff Johnsonce2ee982017-09-03 09:27:35 -07007817 hdd_get_adapter(hdd_ctx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007818 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007819 if (!useAdapter) {
7820 buf =
7821 scnprintf(extra + len,
7822 WE_MAX_STR_LEN -
7823 len,
7824 "\n Device not configured as P2P_CLIENT.");
7825 len += buf;
7826 break;
7827 }
7828 }
7829
7830 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7831 if (!hHal) {
7832 buf =
7833 scnprintf(extra + len,
7834 WE_MAX_STR_LEN - len,
7835 "\n pMac is NULL");
7836 len += buf;
7837 break;
7838 }
7839 pMac = PMAC_STRUCT(hHal);
7840 if (!pMac) {
7841 buf =
7842 scnprintf(extra + len,
7843 WE_MAX_STR_LEN - len,
7844 "\n pMac is NULL");
7845 len += buf;
7846 break;
7847 }
Jeff Johnsond377dce2017-10-04 10:32:42 -07007848 sta_ctx =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007849 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7850
7851
7852 buf =
7853 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7854 "\n HDD Conn State - %s "
Srinivas Girigowdab9086af2017-10-14 14:41:13 -07007855 "\n\n SME State:"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007856 "\n Neighbour Roam State - %s"
7857 "\n CSR State - %s"
7858 "\n CSR Substate - %s",
7859 hdd_connection_state_string
Jeff Johnsond377dce2017-10-04 10:32:42 -07007860 (sta_ctx->conn_info.connState),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007861 mac_trace_get_neighbour_roam_state
7862 (sme_get_neighbor_roam_state
Jeff Johnson1b780e42017-10-31 14:11:45 -07007863 (hHal, useAdapter->session_id)),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007864 mac_trace_getcsr_roam_state
7865 (sme_get_current_roam_state
Jeff Johnson1b780e42017-10-31 14:11:45 -07007866 (hHal, useAdapter->session_id)),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007867 mac_trace_getcsr_roam_sub_state
7868 (sme_get_current_roam_sub_state
Jeff Johnson1b780e42017-10-31 14:11:45 -07007869 (hHal, useAdapter->session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007870 );
7871 len += buf;
7872 adapter_num++;
7873 }
7874
Mukul Sharma81661ae2015-10-30 20:26:02 +05307875 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007876 /* Printing Lim State starting with global lim states */
7877 buf =
7878 scnprintf(extra + len, WE_MAX_STR_LEN - len,
Srinivas Girigowdab9086af2017-10-14 14:41:13 -07007879 "\n\n LIM STATES:-"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007880 "\n Global Sme State - %s "
7881 "\n Global mlm State - %s " "\n",
7882 mac_trace_get_lim_sme_state
7883 (sme_get_lim_sme_state(hHal)),
7884 mac_trace_get_lim_mlm_state
7885 (sme_get_lim_sme_state(hHal))
7886 );
7887 len += buf;
7888
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007889 while (check < 3 && count < 255) {
7890 if (sme_is_lim_session_valid(hHal, count)) {
7891 buf =
7892 scnprintf(extra + len,
7893 WE_MAX_STR_LEN -
7894 len,
7895 "\n Lim Valid Session %d:-"
7896 "\n PE Sme State - %s "
7897 "\n PE Mlm State - %s "
7898 "\n", check,
7899 mac_trace_get_lim_sme_state
7900 (sme_get_lim_sme_session_state
7901 (hHal, count)),
7902 mac_trace_get_lim_mlm_state
7903 (sme_get_lim_mlm_session_state
7904 (hHal, count))
7905 );
7906
7907 len += buf;
7908 check++;
7909 }
7910 count++;
7911 }
7912 }
7913
7914 wrqu->data.length = strlen(extra) + 1;
7915 break;
7916 }
7917
7918 case WE_GET_CFG:
7919 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007920 hdd_debug("Printing CLD global INI Config");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007921 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007922 extra,
7923 QCSAP_IOCTL_MAX_STR_LEN);
7924 wrqu->data.length = strlen(extra) + 1;
7925 break;
7926 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007927 case WE_GET_RSSI:
7928 {
7929 int8_t s7Rssi = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007930
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007931 wlan_hdd_get_rssi(adapter, &s7Rssi);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007932 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7933 wrqu->data.length = strlen(extra) + 1;
7934 break;
7935 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007936
7937 case WE_GET_WMM_STATUS:
7938 {
7939 snprintf(extra, WE_MAX_STR_LEN,
7940 "\nDir: 0=up, 1=down, 3=both\n"
7941 "|------------------------|\n"
7942 "|AC | ACM |Admitted| Dir |\n"
7943 "|------------------------|\n"
7944 "|VO | %d | %3s | %d |\n"
7945 "|VI | %d | %3s | %d |\n"
7946 "|BE | %d | %3s | %d |\n"
7947 "|BK | %d | %3s | %d |\n"
7948 "|------------------------|\n",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007949 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007950 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007951 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007952 wmmAcStatus[SME_AC_VO].
7953 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007954 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007955 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
7956 ts_info.direction,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007957 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007958 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007959 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007960 wmmAcStatus[SME_AC_VI].
7961 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007962 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
7964 ts_info.direction,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007965 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007966 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007967 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007968 wmmAcStatus[SME_AC_BE].
7969 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007970 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007971 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
7972 ts_info.direction,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007973 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007974 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007975 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007976 wmmAcStatus[SME_AC_BK].
7977 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007978 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007979 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
7980 ts_info.direction);
7981
7982 wrqu->data.length = strlen(extra) + 1;
7983 break;
7984 }
7985 case WE_GET_CHANNEL_LIST:
7986 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307987 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007988 uint8_t i, len;
7989 char *buf;
7990 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
7991 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007992 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007993
Srinivas Girigowdac231df62017-03-24 18:27:57 -07007994 struct channel_list_info channel_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007995
7996 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05307997 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007998 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307999 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008000 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008001 return -EINVAL;
8002 }
8003 buf = extra;
8004 /*
8005 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
8006 * Maximum buffer needed = 5 * number of channels.
8007 * Check ifsufficient buffer is available and then
8008 * proceed to fill the buffer.
8009 */
8010 if (WE_MAX_STR_LEN <
8011 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008012 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008013 return -EINVAL;
8014 }
8015 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
8016 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308017 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008018 ubuf, &ubuf_len)) {
8019 /* Printing Country code in getChannelList */
8020 for (i = 0; i < (ubuf_len - 1); i++)
8021 len += scnprintf(buf + len,
8022 WE_MAX_STR_LEN - len,
8023 "%c", ubuf[i]);
8024 }
8025 for (i = 0; i < channel_list.num_channels; i++) {
8026 len +=
8027 scnprintf(buf + len, WE_MAX_STR_LEN - len,
8028 " %u", channel_list.channels[i]);
8029 }
8030 wrqu->data.length = strlen(extra) + 1;
8031
8032 break;
8033 }
8034#ifdef FEATURE_WLAN_TDLS
8035 case WE_GET_TDLS_PEERS:
8036 {
8037 wrqu->data.length =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008038 wlan_hdd_tdls_get_all_peers(adapter, extra,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008039 WE_MAX_STR_LEN) + 1;
8040 break;
8041 }
8042#endif
8043#ifdef WLAN_FEATURE_11W
8044 case WE_GET_11W_INFO:
8045 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008046 hdd_debug("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008047 pWextState->roamProfile.MFPEnabled);
8048
8049 snprintf(extra, WE_MAX_STR_LEN,
8050 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
8051 "\n Number of Unprotected Disassocs %d"
8052 "\n Number of Unprotected Deauths %d",
8053 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
8054 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
8055 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
8056 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
8057 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
8058 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
8059 pWextState->roamProfile.MFPEnabled,
Jeff Johnsondc179f42017-10-21 11:27:26 -07008060 adapter->hdd_stats.hdd_pmf_stats.
8061 num_unprot_disassoc_rx,
8062 adapter->hdd_stats.hdd_pmf_stats.
8063 num_unprot_deauth_rx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008064
8065 wrqu->data.length = strlen(extra) + 1;
8066 break;
8067 }
8068#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008069 case WE_GET_IBSS_STA_INFO:
8070 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07008071 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008072 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008073 int idx = 0;
8074 int length = 0, buf = 0;
8075
Naveen Rawatc45d1622016-07-05 12:20:09 -07008076 for (idx = 0; idx < MAX_PEERS; idx++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07008077 if (HDD_WLAN_INVALID_STA_ID !=
Jeff Johnsond377dce2017-10-04 10:32:42 -07008078 sta_ctx->conn_info.staId[idx]) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008079 buf = snprintf
8080 ((extra + length),
8081 WE_MAX_STR_LEN - length,
8082 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Jeff Johnsond377dce2017-10-04 10:32:42 -07008083 sta_ctx->conn_info.staId[idx],
8084 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008085 peerMacAddress[idx].bytes[0],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008086 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008087 peerMacAddress[idx].bytes[1],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008088 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008089 peerMacAddress[idx].bytes[2],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008090 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008091 peerMacAddress[idx].bytes[3],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008092 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008093 peerMacAddress[idx].bytes[4],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008094 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008095 peerMacAddress[idx].bytes[5]
8096 );
8097 length += buf;
8098 }
8099 }
8100 wrqu->data.length = strlen(extra) + 1;
8101 break;
8102 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008103 case WE_GET_PHYMODE:
8104 {
8105 bool ch_bond24 = false, ch_bond5g = false;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008106 struct hdd_context *hddctx = WLAN_HDD_GET_CTX(adapter);
8107 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008108 eCsrPhyMode phymode;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008109 enum band_info currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008110 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008111
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008112 sme_config = qdf_mem_malloc(sizeof(*sme_config));
8113 if (!sme_config) {
8114 hdd_err("Out of memory");
8115 ret = -ENOMEM;
8116 break;
8117 }
8118
8119 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008120 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008121 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008122 ch_bond24 = true;
8123
8124 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008125 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008126 ch_bond5g = true;
8127
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008128 qdf_mem_free(sme_config);
8129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008130 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308131 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008132 sme_get_freq_band(hal, &currBand))) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008133 hdd_err("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008134 return -EIO;
8135 }
8136
8137 switch (phymode) {
8138 case eCSR_DOT11_MODE_AUTO:
8139 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
8140 break;
8141 case eCSR_DOT11_MODE_11n:
8142 case eCSR_DOT11_MODE_11n_ONLY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008143 if (currBand == BAND_2G) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008144 if (ch_bond24)
8145 snprintf(extra, WE_MAX_STR_LEN,
8146 "11NGHT40");
8147 else
8148 snprintf(extra, WE_MAX_STR_LEN,
8149 "11NGHT20");
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008150 } else if (currBand == BAND_5G) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008151 if (ch_bond5g)
8152 snprintf(extra, WE_MAX_STR_LEN,
8153 "11NAHT40");
8154 else
8155 snprintf(extra, WE_MAX_STR_LEN,
8156 "11NAHT20");
8157 } else {
8158 snprintf(extra, WE_MAX_STR_LEN, "11N");
8159 }
8160 break;
8161 case eCSR_DOT11_MODE_abg:
8162 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
8163 break;
8164 case eCSR_DOT11_MODE_11a:
8165 snprintf(extra, WE_MAX_STR_LEN, "11A");
8166 break;
8167 case eCSR_DOT11_MODE_11b:
8168 case eCSR_DOT11_MODE_11b_ONLY:
8169 snprintf(extra, WE_MAX_STR_LEN, "11B");
8170 break;
8171 case eCSR_DOT11_MODE_11g:
8172 case eCSR_DOT11_MODE_11g_ONLY:
8173 snprintf(extra, WE_MAX_STR_LEN, "11G");
8174 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008175 case eCSR_DOT11_MODE_11ac:
8176 case eCSR_DOT11_MODE_11ac_ONLY:
8177 if (hddctx->config->vhtChannelWidth ==
8178 eHT_CHANNEL_WIDTH_20MHZ)
8179 snprintf(extra, WE_MAX_STR_LEN,
8180 "11ACVHT20");
8181 else if (hddctx->config->vhtChannelWidth ==
8182 eHT_CHANNEL_WIDTH_40MHZ)
8183 snprintf(extra, WE_MAX_STR_LEN,
8184 "11ACVHT40");
8185 else if (hddctx->config->vhtChannelWidth ==
8186 eHT_CHANNEL_WIDTH_80MHZ)
8187 snprintf(extra, WE_MAX_STR_LEN,
8188 "11ACVHT80");
8189 else if (hddctx->config->vhtChannelWidth ==
8190 eHT_CHANNEL_WIDTH_160MHZ)
8191 snprintf(extra, WE_MAX_STR_LEN,
8192 "11ACVHT160");
8193 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08008194 case eCSR_DOT11_MODE_11ax:
8195 case eCSR_DOT11_MODE_11ax_ONLY:
8196 /* currently using vhtChannelWidth */
8197 if (hddctx->config->vhtChannelWidth ==
8198 eHT_CHANNEL_WIDTH_20MHZ)
8199 snprintf(extra, WE_MAX_STR_LEN,
8200 "11AX_HE_20");
8201 else if (hddctx->config->vhtChannelWidth ==
8202 eHT_CHANNEL_WIDTH_40MHZ)
8203 snprintf(extra, WE_MAX_STR_LEN,
8204 "11AX_HE_40");
8205 else if (hddctx->config->vhtChannelWidth ==
8206 eHT_CHANNEL_WIDTH_80MHZ)
8207 snprintf(extra, WE_MAX_STR_LEN,
8208 "11AX_HE_80");
8209 else if (hddctx->config->vhtChannelWidth ==
8210 eHT_CHANNEL_WIDTH_160MHZ)
8211 snprintf(extra, WE_MAX_STR_LEN,
8212 "11AX_HE_160");
8213 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008214 }
8215
8216 wrqu->data.length = strlen(extra) + 1;
8217 break;
8218 }
8219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008220 case WE_GET_OEM_DATA_CAP:
Naveen Rawat910726a2017-03-06 11:42:51 -08008221 return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008222 case WE_GET_SNR:
8223 {
8224 int8_t s7snr = 0;
8225 int status = 0;
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008226 struct hdd_context *hdd_ctx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07008227 struct hdd_station_ctx *sta_ctx;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008228
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008229 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008230 status = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308231 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008232 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308233
Jeff Johnsond377dce2017-10-04 10:32:42 -07008234 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008235 if (0 == hdd_ctx->config->fEnableSNRMonitoring ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008236 eConnectionState_Associated !=
Jeff Johnsond377dce2017-10-04 10:32:42 -07008237 sta_ctx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008238 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008239 hdd_ctx->config->fEnableSNRMonitoring,
Jeff Johnsond377dce2017-10-04 10:32:42 -07008240 sta_ctx->conn_info.connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008241 return -ENONET;
8242 }
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008243 wlan_hdd_get_snr(adapter, &s7snr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008244 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
8245 wrqu->data.length = strlen(extra) + 1;
8246 break;
8247 }
8248 default:
8249 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008250 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008251 sub_cmd);
8252 break;
8253 }
8254 }
Dustin Brownd9322482017-01-09 12:46:03 -08008255
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308256 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -08008257 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008258}
8259
8260static int iw_get_char_setnone(struct net_device *dev,
8261 struct iw_request_info *info,
8262 union iwreq_data *wrqu, char *extra)
8263{
8264 int ret;
8265
8266 cds_ssr_protect(__func__);
8267 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
8268 cds_ssr_unprotect(__func__);
8269
8270 return ret;
8271}
8272
8273/**
8274 * iw_setnone_getnone() - Generic "action" private ioctl handler
8275 * @dev: device upon which the ioctl was received
8276 * @info: ioctl request information
8277 * @wrqu: ioctl request data
8278 * @extra: ioctl extra data
8279 *
8280 * Return: 0 on success, non-zero on error
8281 */
8282static int __iw_setnone_getnone(struct net_device *dev,
8283 struct iw_request_info *info,
8284 union iwreq_data *wrqu, char *extra)
8285{
Jeff Johnson3d278b02017-08-29 14:17:47 -07008286 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008287 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008288 int ret;
8289 int sub_cmd;
8290
Dustin Brownfdf17c12018-03-14 12:55:34 -07008291 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308292
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008293 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008294 ret = wlan_hdd_validate_context(hdd_ctx);
8295 if (0 != ret)
8296 return ret;
8297
Jeff Johnson441e1f72017-02-07 08:50:49 -08008298 ret = hdd_check_private_wext_control(hdd_ctx, info);
8299 if (0 != ret)
8300 return ret;
8301
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008302#ifdef CONFIG_COMPAT
8303 /* this ioctl is a special case where a sub-ioctl is used and both
8304 * the number of get and set args is 0. in this specific case the
8305 * logic in iwpriv places the sub_cmd in the data.flags portion of
8306 * the iwreq. unfortunately the location of this field will be
8307 * different between 32-bit and 64-bit userspace, and the standard
8308 * compat support in the kernel does not handle this case. so we
8309 * need to explicitly handle it here.
8310 */
8311 if (is_compat_task()) {
8312 struct compat_iw_point *compat_iw_point =
8313 (struct compat_iw_point *)&wrqu->data;
8314 sub_cmd = compat_iw_point->flags;
8315 } else {
8316 sub_cmd = wrqu->data.flags;
8317 }
8318#else
8319 sub_cmd = wrqu->data.flags;
8320#endif
8321
8322 switch (sub_cmd) {
8323 case WE_GET_RECOVERY_STAT:
8324 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008325 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008326
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008327 sme_get_recovery_stats(hal);
8328 break;
8329 }
8330
Govind Singha471e5e2015-10-12 17:11:14 +05308331 case WE_GET_FW_PROFILE_DATA:
Jeff Johnson1b780e42017-10-31 14:11:45 -07008332 ret = wma_cli_set_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +05308333 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
8334 0, DBG_CMD);
8335 break;
8336
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008337 case WE_IBSS_GET_PEER_INFO_ALL:
8338 {
8339 hdd_wlan_get_ibss_peer_info_all(adapter);
8340 break;
8341 }
8342
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008343 case WE_SET_REASSOC_TRIGGER:
8344 {
Jeff Johnson3d278b02017-08-29 14:17:47 -07008345 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008346
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008347 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308348 tSirMacAddr bssid;
Krunal Sonibfd05492017-10-03 15:48:37 -07008349 uint32_t roamId = INVALID_ROAM_ID;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308350 uint8_t operating_ch =
Jeff Johnsonb9424862017-10-30 08:49:35 -07008351 adapter->session.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008352 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008353
Jeff Johnson1b780e42017-10-31 14:11:45 -07008354 sme_get_modify_profile_fields(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008355 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308356 if (roaming_offload_enabled(hdd_ctx)) {
8357 qdf_mem_copy(bssid,
Jeff Johnsonb9424862017-10-30 08:49:35 -07008358 &adapter->session.station.conn_info.bssId,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308359 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -08008360 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308361 bssid, operating_ch);
8362 } else {
Jeff Johnson1b780e42017-10-31 14:11:45 -07008363 sme_roam_reassoc(hdd_ctx->hHal, adapter->session_id,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308364 NULL, modProfileFields, &roamId, 1);
8365 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008366 return 0;
8367 }
8368
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008369 case WE_STOP_OBSS_SCAN:
8370 {
8371 /*
8372 * 1.OBSS Scan is mandatory while operating in 2.4GHz
8373 * 2.OBSS scan is stopped by Firmware during the disassociation
8374 * 3.OBSS stop comamnd is added for debugging purpose
8375 */
8376 tHalHandle hal;
8377
8378 hal = WLAN_HDD_GET_HAL_CTX(adapter);
8379 if (hal == NULL) {
8380 hdd_err("hal context is NULL");
8381 return -EINVAL;
8382 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07008383 sme_ht40_stop_obss_scan(hal, adapter->session_id);
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008384 }
8385 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008386 default:
8387 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008388 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008389 break;
8390 }
8391 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308392 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008393 return ret;
8394}
8395
8396static int iw_setnone_getnone(struct net_device *dev,
8397 struct iw_request_info *info,
8398 union iwreq_data *wrqu, char *extra)
8399{
8400 int ret;
8401
8402 cds_ssr_protect(__func__);
8403 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
8404 cds_ssr_unprotect(__func__);
8405
8406 return ret;
8407}
8408
Krunal Sonia6e505b2017-01-12 12:25:18 -08008409#ifdef MPC_UT_FRAMEWORK
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008410static int iw_get_policy_manager_ut_ops(struct hdd_context *hdd_ctx,
Jeff Johnson3d278b02017-08-29 14:17:47 -07008411 struct hdd_adapter *adapter, int sub_cmd, int *apps_args)
Krunal Sonia6e505b2017-01-12 12:25:18 -08008412{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -08008413 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08008414 case WE_POLICY_MANAGER_CLIST_CMD:
8415 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008416 hdd_debug("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008417 policy_mgr_incr_connection_count_utfw(hdd_ctx->hdd_psoc,
8418 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
8419 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008420 }
8421 break;
8422
8423 case WE_POLICY_MANAGER_DLIST_CMD:
8424 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008425 hdd_debug("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008426 policy_mgr_decr_connection_count_utfw(hdd_ctx->hdd_psoc,
8427 apps_args[0], apps_args[1]);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008428 }
8429 break;
8430
8431 case WE_POLICY_MANAGER_ULIST_CMD:
8432 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008433 hdd_debug("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008434 policy_mgr_update_connection_info_utfw(hdd_ctx->hdd_psoc,
8435 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
8436 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008437 }
8438 break;
8439
8440 case WE_POLICY_MANAGER_DBS_CMD:
8441 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008442 hdd_debug("<iwpriv wlan0 pm_dbs> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -08008443 if (apps_args[0] == 0)
8444 wma_set_dbs_capability_ut(0);
8445 else
8446 wma_set_dbs_capability_ut(1);
8447
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008448 if (apps_args[1] >= PM_THROUGHPUT &&
8449 apps_args[1] <= PM_LATENCY) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08008450 pr_info("setting system pref to [%d]\n", apps_args[1]);
8451 hdd_ctx->config->conc_system_pref = apps_args[1];
8452 }
8453 }
8454 break;
8455
8456 case WE_POLICY_MANAGER_PCL_CMD:
8457 {
8458 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8459 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
8460 uint32_t pcl_len = 0, i = 0;
8461
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07008462 hdd_debug("<iwpriv wlan0 pm_pcl> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -08008463
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008464 policy_mgr_get_pcl(hdd_ctx->hdd_psoc, apps_args[0],
Krunal Sonia6e505b2017-01-12 12:25:18 -08008465 pcl, &pcl_len,
8466 weight_list, QDF_ARRAY_SIZE(weight_list));
8467 pr_info("PCL list for role[%d] is {", apps_args[0]);
8468 for (i = 0 ; i < pcl_len; i++)
8469 pr_info(" %d, ", pcl[i]);
8470 pr_info("}--------->\n");
8471 }
8472 break;
8473
8474 case WE_POLICY_SET_HW_MODE_CMD:
8475 {
8476 if (apps_args[0] == 0) {
8477 hdd_err("set hw mode for single mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008478 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07008479 adapter->session_id,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008480 HW_MODE_SS_2x2,
8481 HW_MODE_80_MHZ,
8482 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8483 HW_MODE_DBS_NONE,
8484 HW_MODE_AGILE_DFS_NONE,
8485 HW_MODE_SBS_NONE,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08008486 SIR_UPDATE_REASON_UT, PM_NOP);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008487 } else if (apps_args[0] == 1) {
8488 hdd_err("set hw mode for dual mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008489 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07008490 adapter->session_id,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008491 HW_MODE_SS_1x1,
8492 HW_MODE_80_MHZ,
8493 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8494 HW_MODE_DBS,
8495 HW_MODE_AGILE_DFS_NONE,
8496 HW_MODE_SBS_NONE,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08008497 SIR_UPDATE_REASON_UT, PM_NOP);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008498 }
8499 }
8500 break;
8501
8502 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8503 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008504 enum policy_mgr_conc_next_action action;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008505
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07008506 hdd_debug("<iwpriv wlan0 pm_query_action> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008507 action = policy_mgr_current_connections_update(
8508 hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07008509 adapter->session_id, apps_args[0],
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008510 SIR_UPDATE_REASON_UT);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008511 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8512 }
8513 break;
8514
8515 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8516 {
8517 bool allow;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008518
8519 hdd_notice("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008520 allow = policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008521 apps_args[0], apps_args[1], apps_args[2]);
8522 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8523 }
8524 break;
8525
8526 case WE_POLICY_MANAGER_SCENARIO_CMD:
8527 {
8528 clean_report(hdd_ctx);
8529 if (apps_args[0] == 1) {
8530 wlan_hdd_one_connection_scenario(hdd_ctx);
8531 } else if (apps_args[0] == 2) {
8532 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008533 6, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008534 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008535 36, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008536 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008537 6, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008538 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008539 36, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008540 } else if (apps_args[0] == 3) {
8541 /* MCC on same band with 2x2 same mac*/
8542 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008543 6, 11, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008544 /* MCC on diff band with 2x2 same mac*/
8545 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008546 6, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008547 /* MCC on diff band with 1x1 diff mac */
8548 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008549 36, 6, POLICY_MGR_ONE_ONE, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008550 /* MCC on diff band with 1x1 same mac */
8551 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008552 36, 6, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008553 /* SCC on same band with 2x2 same mac */
8554 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008555 36, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008556 /* SCC on same band with 1x1 same mac */
8557 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008558 36, 36, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008559 /* MCC on same band with 2x2 same mac */
8560 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008561 36, 149, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008562 /* MCC on same band with 1x1 same mac */
8563 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008564 36, 149, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008565 }
8566 print_report(hdd_ctx);
8567 }
8568 break;
8569 }
8570 return 0;
8571}
8572#else
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008573static int iw_get_policy_manager_ut_ops(struct hdd_context *hdd_ctx,
Jeff Johnson3d278b02017-08-29 14:17:47 -07008574 struct hdd_adapter *adapter, int sub_cmd, int *apps_args)
Krunal Sonia6e505b2017-01-12 12:25:18 -08008575{
8576 return 0;
8577}
8578#endif
8579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008580/**
Liangwei Dong2a7f2912018-02-07 17:08:17 +08008581 * hdd_ch_avoid_unit_cmd - unit test ch avoidance
8582 * @hdd_ctx: hdd_context
8583 * @num_args: input args number
8584 * @apps_args: args data ptr
8585 *
8586 * This is to inject a ch avoid event to do unit test SAP chan avoidance.
8587 *
8588 * Return: void
8589 */
8590#if WLAN_DEBUG
8591static void hdd_ch_avoid_unit_cmd(struct hdd_context *hdd_ctx,
8592 int num_args, int *apps_args)
8593{
8594 struct ch_avoid_ind_type ch_avoid;
8595 int cnt = 0, i;
8596
8597 if (num_args < 2 || num_args > CH_AVOID_MAX_RANGE * 2 ||
8598 num_args % 2 != 0)
8599 return;
8600 hdd_info("simulate ch avoid num_args %d", num_args);
8601 for (i = 0; i < num_args && i < CH_AVOID_MAX_RANGE * 2; i++) {
8602 ch_avoid.avoid_freq_range[cnt].start_freq =
8603 apps_args[i];
8604 ch_avoid.avoid_freq_range[cnt].end_freq =
8605 apps_args[++i];
8606
8607 hdd_info("simulate ch avoid [%d %d]",
8608 ch_avoid.avoid_freq_range[cnt].start_freq,
8609 ch_avoid.avoid_freq_range[cnt].end_freq);
8610 cnt++;
8611 }
8612 ch_avoid.ch_avoid_range_cnt = cnt;
8613 ucfg_reg_unit_simulate_ch_avoid(hdd_ctx->hdd_psoc, &ch_avoid);
8614}
8615#else
8616static void hdd_ch_avoid_unit_cmd(struct hdd_context *hdd_ctx,
8617 int num_args, int *apps_args)
8618{
8619}
8620#endif
8621/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008622 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8623 * @dev: device upon which the ioctl was received
8624 * @info: ioctl request information
8625 * @wrqu: ioctl request data
8626 * @extra: ioctl extra data
8627 *
8628 * This is an SSR-protected generic handler for private ioctls which
8629 * take multiple arguments. Note that this implementation is also
8630 * somewhat unique in that it is shared by both STA-mode and SAP-mode
8631 * interfaces.
8632 *
8633 * Return: 0 on success, non-zero on error
8634 */
8635static int __iw_set_var_ints_getnone(struct net_device *dev,
8636 struct iw_request_info *info,
8637 union iwreq_data *wrqu, char *extra)
8638{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008639 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8640 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008641 int sub_cmd;
8642 int *apps_args = (int *) extra;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008643 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008644 int ret, num_args;
8645
Dustin Brownfdf17c12018-03-14 12:55:34 -07008646 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308647
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008648 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008649 ret = wlan_hdd_validate_context(hdd_ctx);
8650 if (0 != ret)
8651 return ret;
8652
Jeff Johnson441e1f72017-02-07 08:50:49 -08008653 ret = hdd_check_private_wext_control(hdd_ctx, info);
8654 if (0 != ret)
8655 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008656
8657 sub_cmd = wrqu->data.flags;
8658 num_args = wrqu->data.length;
8659
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008660 hdd_debug("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008661
8662 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008663 case WE_IBSS_GET_PEER_INFO:
8664 {
8665 pr_info("Station ID = %d\n", apps_args[0]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008666 hdd_wlan_get_ibss_peer_info(adapter, apps_args[0]);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008667 }
8668 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008669
8670 case WE_P2P_NOA_CMD:
8671 {
Srinivas Girigowda5d5fdc52017-03-24 22:30:57 -07008672 struct p2p_app_set_ps p2pNoA;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008673
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008674 if (adapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08008675 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
8676 hdd_device_mode_to_string(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008677 adapter->device_mode),
8678 adapter->device_mode);
Rajeev Kumar274034c2015-11-23 11:28:58 -08008679 return -EINVAL;
8680 }
8681
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008682 p2pNoA.opp_ps = apps_args[0];
8683 p2pNoA.ctWindow = apps_args[1];
8684 p2pNoA.duration = apps_args[2];
8685 p2pNoA.interval = apps_args[3];
8686 p2pNoA.count = apps_args[4];
8687 p2pNoA.single_noa_duration = apps_args[5];
8688 p2pNoA.psSelection = apps_args[6];
8689
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008690 hdd_debug("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
Jeff Johnson99bac312016-06-28 10:38:18 -07008691 apps_args[0], apps_args[1], apps_args[2],
8692 apps_args[3], apps_args[4],
8693 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008694
8695 hdd_set_p2p_ps(dev, &p2pNoA);
8696
8697 }
8698 break;
8699
8700 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8701 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008702 hdd_debug("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
Jeff Johnson99bac312016-06-28 10:38:18 -07008703 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308704 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008705 }
8706 break;
8707
8708 case WE_MTRACE_DUMP_CMD:
8709 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008710 hdd_debug("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
Jeff Johnson99bac312016-06-28 10:38:18 -07008711 apps_args[0], apps_args[1],
8712 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308713 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008714 apps_args[1], apps_args[2],
8715 apps_args[3]);
8716
8717 }
8718 break;
8719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008720 case WE_POLICY_MANAGER_CINFO_CMD:
8721 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008722 struct policy_mgr_conc_connection_info *conn_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008723 uint32_t i = 0, len = 0;
8724
Krunal Sonia6e505b2017-01-12 12:25:18 -08008725 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008726 conn_info = policy_mgr_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008727 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008728 for (i = 0; i < len; i++) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07008729 pr_info("|table_index[%d]\t\t\n", i);
8730 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
8731 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
8732 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
8733 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
8734 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
8735 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
8736 pr_info("+--------------------------+\n");
8737 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008738 }
8739 }
8740 break;
8741
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008742 case WE_UNIT_TEST_CMD:
8743 {
Krunal Soniaadaa272017-10-04 16:42:55 -07008744 QDF_STATUS status;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008745
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008746 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8747 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Krunal Soniaadaa272017-10-04 16:42:55 -07008748 hdd_err("Invalid MODULE ID %d", apps_args[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008749 return -EINVAL;
8750 }
Krunal Soniaadaa272017-10-04 16:42:55 -07008751 if ((apps_args[1] >= (WMA_MAX_NUM_ARGS)) ||
Anurag Chouhan77564182016-09-03 16:38:01 +05308752 (apps_args[1] < 0)) {
Krunal Soniaadaa272017-10-04 16:42:55 -07008753 hdd_err("Too Many/Few args %d", apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008754 return -EINVAL;
8755 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07008756 status = sme_send_unit_test_cmd(adapter->session_id,
Krunal Soniaadaa272017-10-04 16:42:55 -07008757 apps_args[0],
8758 apps_args[1],
8759 &apps_args[2]);
8760 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson21d63bb2017-10-07 17:45:33 -07008761 hdd_err("sme_send_unit_test_cmd returned %d", status);
8762 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008763 }
8764 }
8765 break;
8766#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8767 case WE_LED_FLASHING_PARAM:
8768 {
8769 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008771 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008772 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008773 return -EINVAL;
8774 }
8775 for (i = 0; i < num_args; i++) {
8776 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008777 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008778 return -EINVAL;
8779 }
8780 }
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008781 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008782 0, apps_args[0], apps_args[1]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008783 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008784 1, apps_args[2], apps_args[3]);
8785 }
8786 break;
8787#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05308788 case WE_SET_PKTLOG:
8789 {
8790 int ret;
8791
8792 if (num_args < 1 || num_args > 2) {
8793 hdd_err("pktlog: either 1 or 2 parameters are required");
8794 return -EINVAL;
8795 }
8796
8797 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
8798 apps_args[1]);
8799 if (ret)
8800 return ret;
8801 break;
8802 }
8803
Manjeet Singhf82ed072016-07-08 11:40:00 +05308804 case WE_MAC_PWR_DEBUG_CMD:
8805 {
8806 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008807 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Manjeet Singhf82ed072016-07-08 11:40:00 +05308808 int i, j;
8809
8810 if (num_args < 3) {
8811 hdd_err("number of arguments can't be null %d",
8812 num_args);
8813 return -EINVAL;
8814 }
8815 if (num_args - 3 != apps_args[2]) {
8816 hdd_err("arg list of size %d doesn't match num_args %d",
8817 num_args-3, apps_args[2]);
8818 return -EINVAL;
8819 }
8820 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8821 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8822 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8823 return -EINVAL;
8824 }
8825 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8826 hdd_err("Too Many args %d", apps_args[2]);
8827 return -EINVAL;
8828 }
8829 mac_pwr_dbg_args.pdev_id = apps_args[0];
8830 mac_pwr_dbg_args.module_id = apps_args[1];
8831 mac_pwr_dbg_args.num_args = apps_args[2];
8832
8833 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8834 mac_pwr_dbg_args.args[i] = apps_args[j];
8835
8836 if (QDF_STATUS_SUCCESS !=
Jeff Johnson1b780e42017-10-31 14:11:45 -07008837 sme_process_mac_pwr_dbg_cmd(hal, adapter->session_id,
Manjeet Singhf82ed072016-07-08 11:40:00 +05308838 &mac_pwr_dbg_args)) {
8839 return -EINVAL;
8840 }
8841 }
8842 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -08008843 case WE_POLICY_MANAGER_CLIST_CMD:
8844 case WE_POLICY_MANAGER_DLIST_CMD:
8845 case WE_POLICY_MANAGER_ULIST_CMD:
8846 case WE_POLICY_MANAGER_DBS_CMD:
8847 case WE_POLICY_MANAGER_PCL_CMD:
8848 case WE_POLICY_SET_HW_MODE_CMD:
8849 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8850 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8851 case WE_POLICY_MANAGER_SCENARIO_CMD:
8852 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008853 iw_get_policy_manager_ut_ops(hdd_ctx, adapter,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008854 sub_cmd, apps_args);
8855 }
8856 break;
Liangwei Dong2a7f2912018-02-07 17:08:17 +08008857 case WE_SET_CHAN_AVOID:
8858 {
8859 hdd_ch_avoid_unit_cmd(hdd_ctx, num_args, apps_args);
8860 }
8861 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008862 default:
8863 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008864 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008865 }
8866 break;
8867 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308868 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008869 return 0;
8870}
8871
8872/**
8873 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8874 * @dev: pointer to net_device structure
8875 * @info: pointer to iw_request_info structure
8876 * @wrqu: pointer to iwreq_data
8877 * @extra; extra
8878 *
8879 * Return: 0 on success, error number otherwise
8880 *
8881 */
8882static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8883 struct iw_request_info *info,
8884 union iwreq_data *wrqu, char *extra)
8885{
8886 union iwreq_data u_priv_wrqu;
8887 int apps_args[MAX_VAR_ARGS] = {0};
8888 int ret, num_args;
8889
Mukul Sharma64a70e82015-11-02 20:05:09 +05308890 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008891 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308892 return -EPERM;
8893 }
8894
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008895 /* Helper function to get iwreq_data with compat handling. */
8896 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8897 return -EINVAL;
8898
8899 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008900 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008901 return -EINVAL;
8902 }
8903
8904 num_args = u_priv_wrqu.data.length;
8905 if (num_args > MAX_VAR_ARGS)
8906 num_args = MAX_VAR_ARGS;
8907
8908 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8909 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008910 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008911 return -EFAULT;
8912 }
8913
8914 cds_ssr_protect(__func__);
8915 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8916 (char *)&apps_args);
8917 cds_ssr_unprotect(__func__);
8918 return ret;
8919}
8920
8921/**
8922 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8923 * @dev: device upon which the ioctl was received
8924 * @info: ioctl request information
8925 * @wrqu: ioctl request data
8926 * @extra: ioctl extra data
8927 *
8928 * This is a generic handler for private ioctls which take multiple
8929 * arguments. Note that this implementation is also somewhat unique
8930 * in that it is shared by both STA-mode and SAP-mode interfaces.
8931 *
8932 * Return: 0 on success, non-zero on error
8933 */
8934int iw_set_var_ints_getnone(struct net_device *dev,
8935 struct iw_request_info *info,
8936 union iwreq_data *wrqu, char *extra)
8937{
8938 int ret;
8939
8940 cds_ssr_protect(__func__);
8941 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8942 cds_ssr_unprotect(__func__);
8943 return ret;
8944}
8945
8946/**
8947 * iw_add_tspec - Add TSpec private ioctl handler
8948 * @dev: device upon which the ioctl was received
8949 * @info: ioctl request information
8950 * @wrqu: ioctl request data
8951 * @extra: ioctl extra data
8952 *
8953 * Return: 0 on success, non-zero on error
8954 */
8955static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
8956 union iwreq_data *wrqu, char *extra)
8957{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008958 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -07008959 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008960 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8961 int params[HDD_WLAN_WMM_PARAM_COUNT];
Abhishek Singh12be60f2017-08-11 13:52:42 +05308962 struct sme_qos_wmmtspecinfo tSpec;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008963 uint32_t handle;
8964 struct iw_point s_priv_data;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008965 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008966 int ret;
8967
Dustin Brownfdf17c12018-03-14 12:55:34 -07008968 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308969
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008970 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008971 ret = wlan_hdd_validate_context(hdd_ctx);
8972 if (0 != ret)
8973 return ret;
8974
Jeff Johnson441e1f72017-02-07 08:50:49 -08008975 ret = hdd_check_private_wext_control(hdd_ctx, info);
8976 if (0 != ret)
8977 return ret;
8978
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008979 /* make sure the application is sufficiently priviledged */
8980 /* note that the kernel will do this for "set" ioctls, but since */
8981 /* this ioctl wants to return status to user space it must be */
8982 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008983 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008984 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008985
8986 /* we must be associated in order to add a tspec */
Jeff Johnsond377dce2017-10-04 10:32:42 -07008987 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008988 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8989 return 0;
8990 }
8991 /* since we are defined to be a "get" ioctl, and since the number */
8992 /* of params exceeds the number of params that wireless extensions */
8993 /* will pass down in the iwreq_data, we must copy the "set" params. */
8994 /* We must handle the compat for iwreq_data in 32U/64K environment. */
8995
8996 /* helper function to get iwreq_data with compat handling. */
8997 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8998 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8999 return 0;
9000 }
9001 /* make sure all params are correctly passed to function */
9002 if ((NULL == s_priv_data.pointer) ||
9003 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
9004 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9005 return 0;
9006 }
9007 /* from user space ourselves */
9008 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
9009 /* hmmm, can't get them */
9010 return -EIO;
9011 }
9012 /* clear the tspec */
9013 memset(&tSpec, 0, sizeof(tSpec));
9014
9015 /* validate the handle */
9016 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9017 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9018 /* that one is reserved */
9019 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9020 return 0;
9021 }
9022 /* validate the TID */
9023 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
9024 /* out of range */
9025 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9026 return 0;
9027 }
9028 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
9029
9030 /* validate the direction */
9031 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
9032 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
9033 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
9034 break;
9035
9036 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
9037 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
9038 break;
9039
9040 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
9041 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
9042 break;
9043
9044 default:
9045 /* unknown */
9046 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9047 return 0;
9048 }
9049
9050 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
9051
9052 /* validate the user priority */
9053 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
9054 /* out of range */
9055 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9056 return 0;
9057 }
9058 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
9059 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009060 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009061 return 0;
9062 }
9063
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009064 hdd_debug("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009065 tSpec.ts_info.psb, tSpec.ts_info.up);
9066
9067 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
9068 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
9069 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
9070 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
9071 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
9072 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
9073 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
9074 tSpec.surplus_bw_allowance =
9075 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
9076 tSpec.min_service_interval =
9077 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
9078 tSpec.max_service_interval =
9079 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
9080 tSpec.suspension_interval =
9081 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
9082 tSpec.inactivity_interval =
9083 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
9084
9085 tSpec.ts_info.burst_size_defn =
9086 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
9087
9088 /* validate the ts info ack policy */
9089 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
9090 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
9091 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
9092 break;
9093
9094 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
9095 tSpec.ts_info.ack_policy =
9096 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
9097 break;
9098
9099 default:
9100 /* unknown */
9101 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9102 return 0;
9103 }
9104
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009105 *pStatus = hdd_wmm_addts(adapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309106 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009107 return 0;
9108}
9109
9110static int iw_add_tspec(struct net_device *dev,
9111 struct iw_request_info *info,
9112 union iwreq_data *wrqu, char *extra)
9113{
9114 int ret;
9115
9116 cds_ssr_protect(__func__);
9117 ret = __iw_add_tspec(dev, info, wrqu, extra);
9118 cds_ssr_unprotect(__func__);
9119
9120 return ret;
9121}
9122
9123/**
9124 * iw_del_tspec - Delete TSpec private ioctl handler
9125 * @dev: device upon which the ioctl was received
9126 * @info: ioctl request information
9127 * @wrqu: ioctl request data
9128 * @extra: ioctl extra data
9129 *
9130 * Return: 0 on success, non-zero on error
9131 */
9132static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
9133 union iwreq_data *wrqu, char *extra)
9134{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009135 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009136 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009137 int *params = (int *)extra;
9138 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9139 uint32_t handle;
9140 int ret;
9141
Dustin Brownfdf17c12018-03-14 12:55:34 -07009142 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309143
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009144 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009145 ret = wlan_hdd_validate_context(hdd_ctx);
9146 if (0 != ret)
9147 return ret;
9148
Jeff Johnson441e1f72017-02-07 08:50:49 -08009149 ret = hdd_check_private_wext_control(hdd_ctx, info);
9150 if (0 != ret)
9151 return ret;
9152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009153 /* make sure the application is sufficiently priviledged */
9154 /* note that the kernel will do this for "set" ioctls, but since */
9155 /* this ioctl wants to return status to user space it must be */
9156 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009157 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009158 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009159
9160 /* although we are defined to be a "get" ioctl, the params we require */
9161 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9162 /* is no need to copy the params from user space */
9163
9164 /* validate the handle */
9165 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9166 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9167 /* that one is reserved */
9168 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9169 return 0;
9170 }
9171
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009172 *pStatus = hdd_wmm_delts(adapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309173 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009174 return 0;
9175}
9176
9177static int iw_del_tspec(struct net_device *dev,
9178 struct iw_request_info *info,
9179 union iwreq_data *wrqu, char *extra)
9180{
9181 int ret;
9182
9183 cds_ssr_protect(__func__);
9184 ret = __iw_del_tspec(dev, info, wrqu, extra);
9185 cds_ssr_unprotect(__func__);
9186
9187 return ret;
9188}
9189
9190/**
9191 * iw_get_tspec - Get TSpec private ioctl handler
9192 * @dev: device upon which the ioctl was received
9193 * @info: ioctl request information
9194 * @wrqu: ioctl request data
9195 * @extra: ioctl extra data
9196 *
9197 * Return: 0 on success, non-zero on error
9198 */
9199static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
9200 union iwreq_data *wrqu, char *extra)
9201{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009202 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009203 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009204 int *params = (int *)extra;
9205 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9206 uint32_t handle;
9207 int ret;
9208
Dustin Brownfdf17c12018-03-14 12:55:34 -07009209 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309210
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009211 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009212 ret = wlan_hdd_validate_context(hdd_ctx);
9213 if (0 != ret)
9214 return ret;
9215
Jeff Johnson441e1f72017-02-07 08:50:49 -08009216 ret = hdd_check_private_wext_control(hdd_ctx, info);
9217 if (0 != ret)
9218 return ret;
9219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009220 /* although we are defined to be a "get" ioctl, the params we require */
9221 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9222 /* is no need to copy the params from user space */
9223
9224 /* validate the handle */
9225 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9226 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9227 /* that one is reserved */
9228 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9229 return 0;
9230 }
9231
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009232 *pStatus = hdd_wmm_checkts(adapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309233 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009234 return 0;
9235}
9236
9237static int iw_get_tspec(struct net_device *dev,
9238 struct iw_request_info *info,
9239 union iwreq_data *wrqu, char *extra)
9240{
9241 int ret;
9242
9243 cds_ssr_protect(__func__);
9244 ret = __iw_get_tspec(dev, info, wrqu, extra);
9245 cds_ssr_unprotect(__func__);
9246
9247 return ret;
9248}
9249
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009250/**
9251 * iw_set_fties - Set FT IEs private ioctl handler
9252 * @dev: device upon which the ioctl was received
9253 * @info: ioctl request information
9254 * @wrqu: ioctl request data
9255 * @extra: ioctl extra data
9256 *
9257 * Each time the supplicant has the auth_request or reassoc request
9258 * IEs ready they are pushed to the driver. The driver will in turn
9259 * use it to send out the auth req and reassoc req for 11r FT Assoc.
9260 *
9261 * Return: 0 on success, non-zero on error
9262 */
9263static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
9264 union iwreq_data *wrqu, char *extra)
9265{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009266 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -07009267 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009268 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009269 int ret;
9270
Dustin Brownfdf17c12018-03-14 12:55:34 -07009271 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309272
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009273 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009274 ret = wlan_hdd_validate_context(hdd_ctx);
9275 if (0 != ret)
9276 return ret;
9277
Jeff Johnson441e1f72017-02-07 08:50:49 -08009278 ret = hdd_check_private_wext_control(hdd_ctx, info);
9279 if (0 != ret)
9280 return ret;
9281
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009282 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009283 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009284 return -EINVAL;
9285 }
9286 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009287 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009288 return -EINVAL;
9289 }
9290 /* Added for debug on reception of Re-assoc Req. */
Jeff Johnsond377dce2017-10-04 10:32:42 -07009291 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009292 hdd_debug("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009293 wrqu->data.length);
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009294 hdd_debug("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009295 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009296 hdd_debug("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009297
9298 /* Pass the received FT IEs to SME */
Jeff Johnson1b780e42017-10-31 14:11:45 -07009299 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(adapter), adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009300 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309301 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009302 return 0;
9303}
9304
9305static int iw_set_fties(struct net_device *dev,
9306 struct iw_request_info *info,
9307 union iwreq_data *wrqu, char *extra)
9308{
9309 int ret;
9310
9311 cds_ssr_protect(__func__);
9312 ret = __iw_set_fties(dev, info, wrqu, extra);
9313 cds_ssr_unprotect(__func__);
9314
9315 return ret;
9316}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009317
Dustin Brown0cbc7572016-12-16 13:54:40 -08009318/**
9319 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
9320 * @dev: device upon which the ioctl was received
9321 * @info: ioctl request information
9322 * @wrqu: ioctl request data
9323 * @extra: ioctl extra data
9324 *
Dustin Brown860566f2017-01-31 15:24:43 -08009325 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
9326 * time being to provide guidance in migrating to standard APIs.
9327 *
Dustin Brown0cbc7572016-12-16 13:54:40 -08009328 * Return: 0 on success, non-zero on error
9329 */
9330static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
9331 struct iw_request_info *info,
9332 union iwreq_data *wrqu,
9333 char *extra)
9334{
Dustin Brown860566f2017-01-31 15:24:43 -08009335 hdd_err("\n"
9336 "setMCBCFilter is obsolete. Use the following instead:\n"
9337 "Configure multicast filtering via the ‘ip’ command.\n"
9338 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
9339 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
9340 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
9341 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
9342 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07009343 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -08009344}
9345
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009346/**
9347 * iw_set_host_offload - Set host offload ioctl handler
9348 * @dev: device upon which the ioctl was received
9349 * @info: ioctl request information
9350 * @wrqu: ioctl request data
9351 * @extra: ioctl extra data
9352 *
9353 * Return: 0 on success, non-zero on error
9354 */
9355static int __iw_set_host_offload(struct net_device *dev,
9356 struct iw_request_info *info,
9357 union iwreq_data *wrqu, char *extra)
9358{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009359 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowda077143e2017-03-25 10:47:27 -07009360 struct host_offload_req *pRequest = (struct host_offload_req *) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009361 tSirHostOffloadReq offloadRequest;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009362 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009363 int ret;
9364
Dustin Brownfdf17c12018-03-14 12:55:34 -07009365 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309366
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009367 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009368 ret = wlan_hdd_validate_context(hdd_ctx);
9369 if (0 != ret)
9370 return ret;
9371
Jeff Johnson441e1f72017-02-07 08:50:49 -08009372 ret = hdd_check_private_wext_control(hdd_ctx, info);
9373 if (0 != ret)
9374 return ret;
9375
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009376 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009377 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009378 return -EINVAL;
9379 }
9380
9381 /* Debug display of request components. */
9382 switch (pRequest->offloadType) {
9383 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009384 hdd_debug("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009385 switch (pRequest->enableOrDisable) {
9386 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009387 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009388 break;
9389 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009390 hdd_debug(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009391 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009392 hdd_debug(" ARP offload enable");
9393 hdd_debug(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009394 pRequest->params.hostIpv4Addr[0],
9395 pRequest->params.hostIpv4Addr[1],
9396 pRequest->params.hostIpv4Addr[2],
9397 pRequest->params.hostIpv4Addr[3]);
9398 }
9399 break;
9400
9401 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009402 hdd_debug("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009403 switch (pRequest->enableOrDisable) {
9404 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009405 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009406 break;
9407 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009408 hdd_debug(" enable");
9409 hdd_debug(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009410 *(uint16_t *) (pRequest->params.hostIpv6Addr),
9411 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9412 2),
9413 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9414 4),
9415 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9416 6),
9417 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9418 8),
9419 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9420 10),
9421 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9422 12),
9423 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9424 14));
9425 }
9426 }
9427
Hanumanth Reddy Pothula8fcade52017-12-01 13:49:40 +05309428 qdf_mem_zero(&offloadRequest, sizeof(offloadRequest));
9429 offloadRequest.offloadType = pRequest->offloadType;
9430 offloadRequest.enableOrDisable = pRequest->enableOrDisable;
9431 qdf_mem_copy(&offloadRequest.params, &pRequest->params,
9432 sizeof(pRequest->params));
9433 qdf_mem_copy(&offloadRequest.bssid, &pRequest->bssId.bytes,
9434 QDF_MAC_ADDR_SIZE);
9435
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309436 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009437 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07009438 adapter->session_id, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009439 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009440 return -EINVAL;
9441 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309442 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009443 return 0;
9444}
9445
9446static int iw_set_host_offload(struct net_device *dev,
9447 struct iw_request_info *info,
9448 union iwreq_data *wrqu, char *extra)
9449{
9450 int ret;
9451
9452 cds_ssr_protect(__func__);
9453 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9454 cds_ssr_unprotect(__func__);
9455
9456 return ret;
9457}
9458
9459/**
9460 * iw_set_keepalive_params - Set keepalive params ioctl handler
9461 * @dev: device upon which the ioctl was received
9462 * @info: ioctl request information
9463 * @wrqu: ioctl request data
9464 * @extra: ioctl extra data
9465 *
9466 * Return: 0 on success, non-zero on error
9467 */
9468static int __iw_set_keepalive_params(struct net_device *dev,
9469 struct iw_request_info *info,
9470 union iwreq_data *wrqu, char *extra)
9471{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009472 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009473 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009474 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009475 int ret;
9476
Dustin Brownfdf17c12018-03-14 12:55:34 -07009477 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309478
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009479 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009480 ret = wlan_hdd_validate_context(hdd_ctx);
9481 if (0 != ret)
9482 return ret;
9483
Jeff Johnson441e1f72017-02-07 08:50:49 -08009484 ret = hdd_check_private_wext_control(hdd_ctx, info);
9485 if (0 != ret)
9486 return ret;
9487
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009488 if (wrqu->data.length != sizeof(*request)) {
9489 hdd_err("Invalid length %d", wrqu->data.length);
9490 return -EINVAL;
9491 }
9492
9493 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
9494 hdd_err("Value of timePeriod %d exceed Max limit %d",
9495 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009496 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
9497 return -EINVAL;
9498 }
9499
9500 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009501 hdd_debug("Set Keep Alive Request : TimePeriod %d size %zu",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009502 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009503
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009504 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009505 case WLAN_KEEP_ALIVE_NULL_PKT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009506 hdd_debug("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009507 break;
9508
9509 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009510 hdd_debug("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009511
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009512 hdd_debug("Host IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009513 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
9514 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009515
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009516 hdd_debug("Dest IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009517 request->destIpv4Addr[0], request->destIpv4Addr[1],
9518 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009519
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009520 hdd_debug("Dest MAC address: "MAC_ADDRESS_STR,
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08009521 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009522 break;
9523 }
9524
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009525 hdd_debug("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009526
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309527 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009528 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07009529 adapter->session_id, request)) {
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009530 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009531 return -EINVAL;
9532 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309533 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009534 return 0;
9535}
9536
9537static int iw_set_keepalive_params(struct net_device *dev,
9538 struct iw_request_info *info,
9539 union iwreq_data *wrqu,
9540 char *extra)
9541{
9542 int ret;
9543
9544 cds_ssr_protect(__func__);
9545 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9546 cds_ssr_unprotect(__func__);
9547
9548 return ret;
9549}
9550
9551#ifdef WLAN_FEATURE_PACKET_FILTERING
9552/**
9553 * wlan_hdd_set_filter() - Set packet filter
9554 * @hdd_ctx: Global HDD context
9555 * @request: Packet filter request struct
9556 * @sessionId: Target session for the request
9557 *
9558 * Return: 0 on success, non-zero on error
9559 */
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +05309560int wlan_hdd_set_filter(struct hdd_context *hdd_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009561 struct pkt_filter_cfg *request,
9562 uint8_t sessionId)
9563{
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309564 struct pmo_rcv_pkt_fltr_cfg *pmo_set_pkt_fltr_req = NULL;
9565 struct pmo_rcv_pkt_fltr_clear_param *pmo_clr_pkt_fltr_param = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009566 int i = 0;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309567 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009568
9569 if (hdd_ctx->config->disablePacketFilter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009570 hdd_warn("Packet filtering disabled in ini");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009571 return 0;
9572 }
9573
9574 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009575 hdd_debug("Packet Filter Request : FA %d params %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009576 request->filter_action, request->num_params);
9577
9578 switch (request->filter_action) {
9579 case HDD_RCV_FILTER_SET:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009580 hdd_debug("Set Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009581 request->filter_id);
9582
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309583 pmo_set_pkt_fltr_req =
9584 qdf_mem_malloc(sizeof(*pmo_set_pkt_fltr_req));
9585 if (!pmo_set_pkt_fltr_req) {
Mukul Sharmad75a6672017-06-22 15:40:53 +05309586 hdd_err("unable to allocate pmo_set_pkt_fltr_req");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309587 return QDF_STATUS_E_NOMEM;
9588 }
9589
9590 pmo_set_pkt_fltr_req->filter_id = request->filter_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009591 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
9592 hdd_err("Number of Params exceed Max limit %d",
9593 request->num_params);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309594 status = QDF_STATUS_E_INVAL;
9595 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009596 }
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309597 pmo_set_pkt_fltr_req->num_params = request->num_params;
9598 pmo_set_pkt_fltr_req->coalesce_time = 0;
Srinivas Girigowdabbbecad2017-06-28 16:01:48 -07009599 pmo_set_pkt_fltr_req->filter_type = PMO_RCV_FILTER_TYPE_FILTER_PKT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009600 for (i = 0; i < request->num_params; i++) {
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309601 pmo_set_pkt_fltr_req->params_data[i].protocol_layer =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009602 request->params_data[i].protocol_layer;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309603 pmo_set_pkt_fltr_req->params_data[i].compare_flag =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009604 request->params_data[i].compare_flag;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309605 pmo_set_pkt_fltr_req->params_data[i].data_offset =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009606 request->params_data[i].data_offset;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309607 pmo_set_pkt_fltr_req->params_data[i].data_length =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009608 request->params_data[i].data_length;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309609 pmo_set_pkt_fltr_req->params_data[i].reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009610
Dustin Brown4d1e8462016-12-14 12:12:24 -08009611 if (request->params_data[i].data_offset >
9612 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
9613 hdd_err("Invalid data offset %u for param %d (max = %d)",
9614 request->params_data[i].data_offset,
9615 i,
9616 SIR_MAX_FILTER_TEST_DATA_OFFSET);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309617 status = QDF_STATUS_E_INVAL;
9618 goto out;
Dustin Brown4d1e8462016-12-14 12:12:24 -08009619 }
9620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009621 if (request->params_data[i].data_length >
9622 SIR_MAX_FILTER_TEST_DATA_LEN) {
9623 hdd_err("Error invalid data length %d",
9624 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309625 status = QDF_STATUS_E_INVAL;
9626 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009627 }
9628
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009629 hdd_debug("Proto %d Comp Flag %d Filter Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009630 request->params_data[i].protocol_layer,
9631 request->params_data[i].compare_flag,
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309632 pmo_set_pkt_fltr_req->filter_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009633
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009634 hdd_debug("Data Offset %d Data Len %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009635 request->params_data[i].data_offset,
9636 request->params_data[i].data_length);
9637
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309638 if (sizeof(
9639 pmo_set_pkt_fltr_req->params_data[i].compare_data)
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07009640 < (request->params_data[i].data_length)) {
9641 hdd_err("Error invalid data length %d",
9642 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309643 status = QDF_STATUS_E_INVAL;
9644 goto out;
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07009645 }
9646
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309647 memcpy(
9648 &pmo_set_pkt_fltr_req->params_data[i].compare_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009649 request->params_data[i].compare_data,
9650 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309651 memcpy(&pmo_set_pkt_fltr_req->params_data[i].data_mask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009652 request->params_data[i].data_mask,
9653 request->params_data[i].data_length);
9654
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009655 hdd_debug("CData %d CData %d CData %d CData %d CData %d CData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009656 request->params_data[i].compare_data[0],
9657 request->params_data[i].compare_data[1],
9658 request->params_data[i].compare_data[2],
9659 request->params_data[i].compare_data[3],
9660 request->params_data[i].compare_data[4],
9661 request->params_data[i].compare_data[5]);
9662
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009663 hdd_debug("MData %d MData %d MData %d MData %d MData %d MData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009664 request->params_data[i].data_mask[0],
9665 request->params_data[i].data_mask[1],
9666 request->params_data[i].data_mask[2],
9667 request->params_data[i].data_mask[3],
9668 request->params_data[i].data_mask[4],
9669 request->params_data[i].data_mask[5]);
9670 }
9671
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309672 if (QDF_STATUS_SUCCESS !=
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309673 pmo_ucfg_set_pkt_filter(hdd_ctx->hdd_psoc,
9674 pmo_set_pkt_fltr_req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009675 sessionId)) {
9676 hdd_err("Failure to execute Set Filter");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309677 status = QDF_STATUS_E_INVAL;
9678 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009679 }
9680
9681 break;
9682
9683 case HDD_RCV_FILTER_CLEAR:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009684 hdd_debug("Clear Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009685 request->filter_id);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309686
9687 pmo_clr_pkt_fltr_param = qdf_mem_malloc(
9688 sizeof(*pmo_clr_pkt_fltr_param));
9689 if (!pmo_clr_pkt_fltr_param) {
9690 hdd_err("unable to allocate pmo_clr_pkt_fltr_param");
9691 return QDF_STATUS_E_NOMEM;
9692 }
9693
9694 pmo_clr_pkt_fltr_param->filter_id = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309695 if (QDF_STATUS_SUCCESS !=
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309696 pmo_ucfg_clear_pkt_filter(hdd_ctx->hdd_psoc,
9697 pmo_clr_pkt_fltr_param,
9698 sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009699 hdd_err("Failure to execute Clear Filter");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309700 status = QDF_STATUS_E_INVAL;
9701 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009702 }
9703 break;
9704
9705 default:
9706 hdd_err("Packet Filter Request: Invalid %d",
9707 request->filter_action);
9708 return -EINVAL;
9709 }
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309710
9711out:
9712 if (pmo_set_pkt_fltr_req)
9713 qdf_mem_free(pmo_set_pkt_fltr_req);
9714 if (pmo_clr_pkt_fltr_param)
9715 qdf_mem_free(pmo_clr_pkt_fltr_param);
9716
9717 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009718}
9719
9720/**
9721 * __iw_set_packet_filter_params() - set packet filter parameters in target
9722 * @dev: Pointer to netdev
9723 * @info: Pointer to iw request info
9724 * @wrqu: Pointer to data
9725 * @extra: Pointer to extra data
9726 *
9727 * Return: 0 on success, non-zero on error
9728 */
9729static int __iw_set_packet_filter_params(struct net_device *dev,
9730 struct iw_request_info *info,
9731 union iwreq_data *wrqu, char *extra)
9732{
9733 int ret;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009734 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009735 struct iw_point priv_data;
Jeff Johnson3d278b02017-08-29 14:17:47 -07009736 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009737 struct pkt_filter_cfg *request = NULL;
9738
Mukul Sharma472382f2015-11-02 20:16:31 +05309739 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009740 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309741 return -EPERM;
9742 }
9743
Dustin Brownfdf17c12018-03-14 12:55:34 -07009744 hdd_enter_dev(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309745
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009746 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9747 ret = wlan_hdd_validate_context(hdd_ctx);
9748 if (0 != ret)
9749 return ret;
9750
Jeff Johnson441e1f72017-02-07 08:50:49 -08009751 ret = hdd_check_private_wext_control(hdd_ctx, info);
9752 if (0 != ret)
9753 return ret;
9754
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009755 if (hdd_priv_get_data(&priv_data, wrqu)) {
9756 hdd_err("failed to get priv data");
9757 return -EINVAL;
9758 }
9759
9760 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07009761 hdd_err("invalid priv data %pK or invalid priv data length %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009762 priv_data.pointer, priv_data.length);
9763 return -EINVAL;
9764 }
9765
Arun Khandavalli75d246b2017-08-07 19:46:06 +05309766 if (adapter->device_mode != QDF_STA_MODE) {
9767 hdd_err("Packet filter not supported for this mode :%d",
9768 adapter->device_mode);
9769 return -ENOTSUPP;
9770 }
9771
Mukul Sharmabe846bb2017-05-09 17:41:52 +05309772 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) {
9773 hdd_err("Packet filter not supported in disconnected state");
9774 return -ENOTSUPP;
9775 }
9776
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009777 /* copy data using copy_from_user */
9778 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9779 priv_data.length);
9780 if (NULL == request) {
9781 hdd_err("mem_alloc_copy_from_user_helper fail");
9782 return -ENOMEM;
9783 }
9784
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +05309785 if (request->filter_action == HDD_RCV_FILTER_SET)
9786 hdd_ctx->user_configured_pkt_filter_rules |=
9787 1 << request->filter_id;
9788 else if (request->filter_action == HDD_RCV_FILTER_CLEAR)
9789 hdd_ctx->user_configured_pkt_filter_rules &=
9790 ~(1 << request->filter_id);
9791
Jeff Johnson1b780e42017-10-31 14:11:45 -07009792 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009793
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07009794 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309795 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009796 return ret;
9797}
9798
9799/**
9800 * iw_set_packet_filter_params() - set packet filter parameters in target
9801 * @dev: Pointer to netdev
9802 * @info: Pointer to iw request info
9803 * @wrqu: Pointer to data
9804 * @extra: Pointer to extra data
9805 *
9806 * Return: 0 on success, non-zero on error
9807 */
9808static int iw_set_packet_filter_params(struct net_device *dev,
9809 struct iw_request_info *info,
9810 union iwreq_data *wrqu, char *extra)
9811{
9812 int ret;
9813
9814 cds_ssr_protect(__func__);
9815 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9816 cds_ssr_unprotect(__func__);
9817
9818 return ret;
9819}
9820#endif
9821
Jeff Johnsonced658b2018-03-08 09:54:01 -08009822struct hdd_statistics_priv {
9823 tCsrSummaryStatsInfo summary_stats;
9824 tCsrGlobalClassAStatsInfo class_a_stats;
9825 tCsrGlobalClassDStatsInfo class_d_stats;
9826};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009827
Jeff Johnsond37833f2018-03-07 14:22:44 -08009828/**
9829 * hdd_statistics_cb() - "Get statistics" callback function
Jeff Johnsonced658b2018-03-08 09:54:01 -08009830 * @stats: statistics payload
9831 * @context: opaque context originally passed to SME. HDD always passes
9832 * a cookie for the request context
Jeff Johnsond37833f2018-03-07 14:22:44 -08009833 *
9834 * Return: None
9835 */
Jeff Johnsonced658b2018-03-08 09:54:01 -08009836static void hdd_statistics_cb(void *stats, void *context)
Jeff Johnsond37833f2018-03-07 14:22:44 -08009837{
Jeff Johnsonced658b2018-03-08 09:54:01 -08009838 struct hdd_request *request;
9839 struct hdd_statistics_priv *priv;
9840 tCsrSummaryStatsInfo *summary_stats;
9841 tCsrGlobalClassAStatsInfo *class_a_stats;
9842 tCsrGlobalClassDStatsInfo *class_d_stats;
Jeff Johnsond37833f2018-03-07 14:22:44 -08009843
Jeff Johnsonced658b2018-03-08 09:54:01 -08009844 request = hdd_request_get(context);
9845 if (!request) {
9846 hdd_err("Obsolete request");
9847 return;
Jeff Johnsond37833f2018-03-07 14:22:44 -08009848 }
9849
Jeff Johnsonced658b2018-03-08 09:54:01 -08009850 priv = hdd_request_priv(request);
9851
9852 summary_stats = (tCsrSummaryStatsInfo *)stats;
9853 priv->summary_stats = *summary_stats;
9854
9855 class_a_stats = (tCsrGlobalClassAStatsInfo *)(summary_stats + 1);
9856 priv->class_a_stats = *class_a_stats;
9857
9858 class_d_stats = (tCsrGlobalClassDStatsInfo *)(class_a_stats + 1);
9859 priv->class_d_stats = *class_d_stats;
9860
9861 hdd_request_complete(request);
9862 hdd_request_put(request);
Jeff Johnsond37833f2018-03-07 14:22:44 -08009863}
9864
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009865static int __iw_get_statistics(struct net_device *dev,
9866 struct iw_request_info *info,
9867 union iwreq_data *wrqu, char *extra)
9868{
9869
Jeff Johnsonced658b2018-03-08 09:54:01 -08009870 QDF_STATUS status;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009871 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9872 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsonced658b2018-03-08 09:54:01 -08009873 struct hdd_station_ctx *sta_ctx;
9874 char *p;
9875 int tlen;
9876 tCsrSummaryStatsInfo *summary_stats =
9877 &(adapter->hdd_stats.summary_stat);
9878 tCsrGlobalClassAStatsInfo *class_a_stats =
9879 &(adapter->hdd_stats.class_a_stat);
9880 tCsrGlobalClassDStatsInfo *class_d_stats =
9881 &(adapter->hdd_stats.class_d_stat);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009882 int ret;
Jeff Johnsonced658b2018-03-08 09:54:01 -08009883 void *cookie;
9884 struct hdd_request *request;
9885 struct hdd_statistics_priv *priv;
9886 static const struct hdd_request_params params = {
9887 .priv_size = sizeof(*priv),
9888 .timeout_ms = WLAN_WAIT_TIME_STATS,
9889 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009890
Dustin Brownfdf17c12018-03-14 12:55:34 -07009891 hdd_enter_dev(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009892
9893 ret = wlan_hdd_validate_context(hdd_ctx);
9894 if (0 != ret)
9895 return ret;
9896
Jeff Johnson441e1f72017-02-07 08:50:49 -08009897 ret = hdd_check_private_wext_control(hdd_ctx, info);
9898 if (0 != ret)
9899 return ret;
9900
Jeff Johnsonced658b2018-03-08 09:54:01 -08009901 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
9902 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
9903 wrqu->data.length = 0;
9904 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009905 }
9906
Jeff Johnsonced658b2018-03-08 09:54:01 -08009907 request = hdd_request_alloc(&params);
9908 if (!request) {
9909 hdd_warn("request allocation failed");
9910 goto return_cached_stats;
9911 }
9912
9913 cookie = hdd_request_cookie(request);
9914
9915 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9916 SME_SUMMARY_STATS |
9917 SME_GLOBAL_CLASSA_STATS |
9918 SME_GLOBAL_CLASSD_STATS,
9919 hdd_statistics_cb,
9920 sta_ctx->conn_info.staId[0],
9921 cookie, adapter->session_id);
9922
9923 if (QDF_STATUS_SUCCESS != status) {
9924 hdd_warn("Unable to retrieve SME statistics");
9925 goto put_request;
9926 }
9927
9928 /* request was sent -- wait for the response */
9929 ret = hdd_request_wait_for_response(request);
9930 if (ret) {
9931 hdd_err("Failed to wait for statistics, errno %d", ret);
9932 goto put_request;
9933 }
9934
9935 /* update the adapter cache with the fresh results */
9936 priv = hdd_request_priv(request);
9937 *summary_stats = priv->summary_stats;
9938 *class_a_stats = priv->class_a_stats;
9939 *class_d_stats = priv->class_d_stats;
9940
9941put_request:
9942 /*
9943 * either we never sent a request, we sent a request and
9944 * received a response or we sent a request and timed out.
9945 * regardless we are done with the request.
9946 */
9947 hdd_request_put(request);
9948
9949return_cached_stats:
9950 p = extra;
9951 tlen = 0;
9952
9953 FILL_TLV(p, WLAN_STATS_RETRY_CNT,
9954 sizeof(summary_stats->retry_cnt),
9955 &(summary_stats->retry_cnt[0]), tlen);
9956
9957 FILL_TLV(p, WLAN_STATS_MUL_RETRY_CNT,
9958 sizeof(summary_stats->multiple_retry_cnt),
9959 &(summary_stats->multiple_retry_cnt[0]), tlen);
9960
9961 FILL_TLV(p, WLAN_STATS_TX_FRM_CNT,
9962 sizeof(summary_stats->tx_frm_cnt),
9963 &(summary_stats->tx_frm_cnt[0]), tlen);
9964
9965 FILL_TLV(p, WLAN_STATS_RX_FRM_CNT,
9966 sizeof(summary_stats->rx_frm_cnt),
9967 &(summary_stats->rx_frm_cnt), tlen);
9968
9969 FILL_TLV(p, WLAN_STATS_FRM_DUP_CNT,
9970 sizeof(summary_stats->frm_dup_cnt),
9971 &(summary_stats->frm_dup_cnt), tlen);
9972
9973 FILL_TLV(p, WLAN_STATS_FAIL_CNT,
9974 sizeof(summary_stats->fail_cnt),
9975 &(summary_stats->fail_cnt[0]), tlen);
9976
9977 FILL_TLV(p, WLAN_STATS_RTS_FAIL_CNT,
9978 sizeof(summary_stats->rts_fail_cnt),
9979 &(summary_stats->rts_fail_cnt), tlen);
9980
9981 FILL_TLV(p, WLAN_STATS_ACK_FAIL_CNT,
9982 sizeof(summary_stats->ack_fail_cnt),
9983 &(summary_stats->ack_fail_cnt), tlen);
9984
9985 FILL_TLV(p, WLAN_STATS_RTS_SUC_CNT,
9986 sizeof(summary_stats->rts_succ_cnt),
9987 &(summary_stats->rts_succ_cnt), tlen);
9988
9989 FILL_TLV(p, WLAN_STATS_RX_DISCARD_CNT,
9990 sizeof(summary_stats->rx_discard_cnt),
9991 &(summary_stats->rx_discard_cnt), tlen);
9992
9993 FILL_TLV(p, WLAN_STATS_RX_ERROR_CNT,
9994 sizeof(summary_stats->rx_error_cnt),
9995 &(summary_stats->rx_error_cnt), tlen);
9996
9997 FILL_TLV(p, WLAN_STATS_TX_BYTE_CNT,
9998 sizeof(class_d_stats->tx_uc_byte_cnt[0]),
9999 &(class_d_stats->tx_uc_byte_cnt[0]), tlen);
10000
10001 FILL_TLV(p, WLAN_STATS_RX_BYTE_CNT,
10002 sizeof(class_d_stats->rx_byte_cnt),
10003 &(class_d_stats->rx_byte_cnt), tlen);
10004
10005 FILL_TLV(p, WLAN_STATS_RX_RATE,
10006 sizeof(class_d_stats->rx_rate),
10007 &(class_d_stats->rx_rate), tlen);
10008
10009 /* Transmit rate, in units of 500 kbit/sec */
10010 FILL_TLV(p, WLAN_STATS_TX_RATE,
10011 sizeof(class_a_stats->tx_rate),
10012 &(class_a_stats->tx_rate), tlen);
10013
10014 FILL_TLV(p, WLAN_STATS_RX_UC_BYTE_CNT,
10015 sizeof(class_d_stats->rx_uc_byte_cnt[0]),
10016 &(class_d_stats->rx_uc_byte_cnt[0]), tlen);
10017 FILL_TLV(p, WLAN_STATS_RX_MC_BYTE_CNT,
10018 sizeof(class_d_stats->rx_mc_byte_cnt),
10019 &(class_d_stats->rx_mc_byte_cnt), tlen);
10020 FILL_TLV(p, WLAN_STATS_RX_BC_BYTE_CNT,
10021 sizeof(class_d_stats->rx_bc_byte_cnt),
10022 &(class_d_stats->rx_bc_byte_cnt), tlen);
10023 FILL_TLV(p, WLAN_STATS_TX_UC_BYTE_CNT,
10024 sizeof(class_d_stats->tx_uc_byte_cnt[0]),
10025 &(class_d_stats->tx_uc_byte_cnt[0]), tlen);
10026 FILL_TLV(p, WLAN_STATS_TX_MC_BYTE_CNT,
10027 sizeof(class_d_stats->tx_mc_byte_cnt),
10028 &(class_d_stats->tx_mc_byte_cnt), tlen);
10029 FILL_TLV(p, WLAN_STATS_TX_BC_BYTE_CNT,
10030 sizeof(class_d_stats->tx_bc_byte_cnt),
10031 &(class_d_stats->tx_bc_byte_cnt), tlen);
10032
10033 wrqu->data.length = tlen;
10034
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010035 EXIT();
10036
10037 return 0;
10038}
10039
10040static int iw_get_statistics(struct net_device *dev,
10041 struct iw_request_info *info,
10042 union iwreq_data *wrqu, char *extra)
10043{
10044 int ret;
10045
10046 cds_ssr_protect(__func__);
10047 ret = __iw_get_statistics(dev, info, wrqu, extra);
10048 cds_ssr_unprotect(__func__);
10049
10050 return ret;
10051}
10052
10053#ifdef FEATURE_WLAN_SCAN_PNO
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010054/*Max Len for PNO notification*/
10055#define MAX_PNO_NOTIFY_LEN 100
Abhishek Singh0481d662017-04-11 18:20:11 +053010056static void found_pref_network_cb(struct wlan_objmgr_vdev *vdev,
10057 struct scan_event *event, void *args)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010058{
Abhishek Singh0481d662017-04-11 18:20:11 +053010059 struct vdev_osif_priv *osif_priv;
10060 struct wireless_dev *wdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010061 union iwreq_data wrqu;
10062 char buf[MAX_PNO_NOTIFY_LEN + 1];
10063
Abhishek Singh0481d662017-04-11 18:20:11 +053010064 wlan_vdev_obj_lock(vdev);
10065 osif_priv = wlan_vdev_get_ospriv(vdev);
10066 wlan_vdev_obj_unlock(vdev);
10067 if (!osif_priv) {
10068 hdd_err("osif_priv is null");
10069 return;
10070 }
10071
10072 wdev = osif_priv->wdev;
10073 if (!wdev) {
10074 hdd_err("wdev is null");
10075 return;
10076 }
10077
10078 hdd_debug("A preferred network was found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010079
10080 /* create the event */
Abhishek Singh0481d662017-04-11 18:20:11 +053010081 qdf_mem_zero(&wrqu, sizeof(wrqu));
10082 qdf_mem_zero(buf, sizeof(buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010083
10084 snprintf(buf, MAX_PNO_NOTIFY_LEN,
Abhishek Singh0481d662017-04-11 18:20:11 +053010085 "QCOM: Found preferred network:");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010086
10087 wrqu.data.pointer = buf;
10088 wrqu.data.length = strlen(buf);
10089
10090 /* send the event */
10091
Abhishek Singh0481d662017-04-11 18:20:11 +053010092 wireless_send_event(wdev->netdev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010093}
10094
10095/**
10096 * __iw_set_pno() - Preferred Network Offload ioctl handler
10097 * @dev: device upon which the ioctl was received
10098 * @info: ioctl request information
10099 * @wrqu: ioctl request data
10100 * @extra: ioctl extra data
10101 *
10102 * This function parses a Preferred Network Offload command
10103 * Input is string based and expected to be of the form:
10104 *
10105 * <enable(1) | disable(0)>
10106 * when enabling:
10107 * <number of networks>
10108 * for each network:
10109 * <ssid_len> <ssid> <authentication> <encryption>
10110 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070010111 * <scan_time (seconds)>
10112 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010113 * <suspend mode>
10114 *
10115 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070010116 * 1 2 4 test 0 0 3 1 6 11 2 40 5 test2 4 4 6 1 2 3 4 5 6 1 0 5 2 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010117 *
10118 * this translates into:
10119 * -----------------------------
10120 * enable PNO
10121 * 2 networks
10122 * Network 1:
10123 * test - with authentication type 0 and encryption type 0,
10124 * search on 3 channels: 1 6 and 11,
10125 * SSID bcast type is unknown (directed probe will be sent if
10126 * AP not found) and must meet -40dBm RSSI
10127 * Network 2:
10128 * test2 - with authentication type 4 and encryption type 4,
10129 * search on 6 channels 1, 2, 3, 4, 5 and 6
10130 * bcast type is non-bcast (directed probe will be sent)
10131 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010132 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070010133 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010134 */
10135static int __iw_set_pno(struct net_device *dev,
10136 struct iw_request_info *info,
10137 union iwreq_data *wrqu, char *extra)
10138{
Jeff Johnson3d278b02017-08-29 14:17:47 -070010139 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010140 struct hdd_context *hdd_ctx;
Abhishek Singh0481d662017-04-11 18:20:11 +053010141 uint8_t value;
10142 struct wlan_objmgr_vdev *vdev;
10143 struct wlan_objmgr_psoc *psoc;
10144 int ret = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010145 int offset;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010146 char *ptr, *data;
Abhishek Singh0481d662017-04-11 18:20:11 +053010147 uint8_t i, j, params;
10148 QDF_STATUS status;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010149 size_t len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010150
10151 /* request is a large struct, so we make it static to avoid
10152 * stack overflow. This API is only invoked via ioctl, so it
10153 * is serialized by the kernel rtnl_lock and hence does not
10154 * need to be reentrant
10155 */
Abhishek Singh0481d662017-04-11 18:20:11 +053010156 static struct pno_scan_req_params req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010157
Dustin Brownfdf17c12018-03-14 12:55:34 -070010158 hdd_enter_dev(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010159
10160 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10161 ret = wlan_hdd_validate_context(hdd_ctx);
10162 if (ret)
10163 return ret;
10164
Jeff Johnson441e1f72017-02-07 08:50:49 -080010165 ret = hdd_check_private_wext_control(hdd_ctx, info);
10166 if (0 != ret)
10167 return ret;
10168
Abhishek Singh0481d662017-04-11 18:20:11 +053010169 vdev = wlan_objmgr_get_vdev_by_macaddr_from_pdev(hdd_ctx->hdd_pdev,
10170 dev->dev_addr, WLAN_LEGACY_MAC_ID);
10171 if (!vdev) {
10172 hdd_err("vdev object is NULL");
10173 return -EIO;
10174 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010175
Abhishek Singh0481d662017-04-11 18:20:11 +053010176 hdd_debug("PNO data len %d data %s", wrqu->data.length, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010177
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010178 /* making sure argument string ends with '\0' */
10179 len = (wrqu->data.length + 1);
10180 data = qdf_mem_malloc(len);
10181 if (!data) {
10182 hdd_err("fail to allocate memory %zu", len);
10183 return -EINVAL;
10184 }
10185 qdf_mem_copy(data, extra, (len-1));
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010186 ptr = data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010187
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010188 if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010189 hdd_err("PNO enable input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010190 ret = -EINVAL;
10191 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010192 }
10193
Abhishek Singh0481d662017-04-11 18:20:11 +053010194 if (!value) {
10195 status = ucfg_scan_pno_stop(vdev);
10196 if (QDF_IS_STATUS_ERROR(status)) {
10197 hdd_err("Failed to disabled PNO");
10198 ret = -EINVAL;
10199 } else {
10200 hdd_debug("PNO scan disabled");
10201 }
10202 goto exit;
10203 }
10204
10205 if (ucfg_scan_get_pno_in_progress(vdev)) {
10206 hdd_debug("pno is already in progress");
10207 ret = -EBUSY;
10208 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010209 }
10210
10211 ptr += offset;
10212
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010213 if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010214 hdd_err("PNO count input not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010215 ret = -EINVAL;
10216 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010217 }
Abhishek Singh0481d662017-04-11 18:20:11 +053010218 req.networks_cnt = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010219
Abhishek Singh0481d662017-04-11 18:20:11 +053010220 hdd_debug("PNO enable networks count %d offset %d",
10221 req.networks_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010222
Abhishek Singh0481d662017-04-11 18:20:11 +053010223 if ((0 == req.networks_cnt) ||
10224 (req.networks_cnt > SCAN_PNO_MAX_SUPP_NETWORKS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010225 hdd_err("Network count %d invalid",
Abhishek Singh0481d662017-04-11 18:20:11 +053010226 req.networks_cnt);
10227 ret = -EINVAL;
10228 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010229 }
10230
10231 ptr += offset;
10232
Abhishek Singh0481d662017-04-11 18:20:11 +053010233 for (i = 0; i < req.networks_cnt; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010234
Abhishek Singh0481d662017-04-11 18:20:11 +053010235 req.networks_list[i].ssid.length = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010236
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010237 params = sscanf(ptr, " %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010238 &(req.networks_list[i].ssid.length),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010239 &offset);
10240
10241 if (1 != params) {
10242 hdd_err("PNO ssid length input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010243 ret = -EINVAL;
10244 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010245 }
10246
Abhishek Singh0481d662017-04-11 18:20:11 +053010247 if ((0 == req.networks_list[i].ssid.length) ||
10248 (req.networks_list[i].ssid.length > 32)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010249 hdd_err("SSID Len %d is not correct for network %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010250 req.networks_list[i].ssid.length, i);
10251 ret = -EINVAL;
10252 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010253 }
10254
10255 /* Advance to SSID */
10256 ptr += offset;
10257
Abhishek Singh0481d662017-04-11 18:20:11 +053010258 memcpy(req.networks_list[i].ssid.ssid, ptr,
10259 req.networks_list[i].ssid.length);
10260 ptr += req.networks_list[i].ssid.length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010261
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010262 params = sscanf(ptr, " %u %u %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010263 &(req.networks_list[i].authentication),
10264 &(req.networks_list[i].encryption),
10265 &(req.networks_list[i].channel_cnt),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010266 &offset);
10267
10268 if (3 != params) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010269 hdd_err("Incorrect cmd %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010270 ret = -EINVAL;
10271 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010272 }
10273
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010274 hdd_debug("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010275 req.networks_list[i].ssid.length,
10276 req.networks_list[i].ssid.length,
10277 req.networks_list[i].ssid.ssid,
10278 req.networks_list[i].authentication,
10279 req.networks_list[i].encryption,
10280 req.networks_list[i].channel_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010281
10282 /* Advance to channel list */
10283 ptr += offset;
10284
Abhishek Singh0481d662017-04-11 18:20:11 +053010285 if (SCAN_PNO_MAX_NETW_CHANNELS_EX <
10286 req.networks_list[i].channel_cnt) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010287 hdd_err("Incorrect number of channels");
Abhishek Singh0481d662017-04-11 18:20:11 +053010288 ret = -EINVAL;
10289 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010290 }
10291
Abhishek Singh0481d662017-04-11 18:20:11 +053010292 if (0 != req.networks_list[i].channel_cnt) {
10293 for (j = 0; j < req.networks_list[i].channel_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010294 j++) {
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010295 if (1 != sscanf(ptr, " %hhu %n", &value,
Abhishek Singh0481d662017-04-11 18:20:11 +053010296 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010297 hdd_err("PNO network channel is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010298 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010299 ret = -EINVAL;
10300 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010301 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010302 if (!IS_CHANNEL_VALID(value)) {
10303 hdd_err("invalid channel: %hhu", value);
10304 ret = -EINVAL;
10305 goto exit;
10306 }
Abhishek Singh0481d662017-04-11 18:20:11 +053010307 req.networks_list[i].channels[j] =
10308 cds_chan_to_freq(value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010309 /* Advance to next channel number */
10310 ptr += offset;
10311 }
10312 }
10313
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010314 if (1 != sscanf(ptr, " %u %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010315 &(req.networks_list[i].bc_new_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010316 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010317 hdd_err("PNO broadcast network type is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010318 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010319 ret = -EINVAL;
10320 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010321 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010322 if (req.networks_list[i].bc_new_type > 2) {
10323 hdd_err("invalid bcast nw type: %u",
10324 req.networks_list[i].bc_new_type);
10325 ret = -EINVAL;
10326 goto exit;
10327 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010328
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010329 hdd_debug("PNO bcastNetwType %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010330 req.networks_list[i].bc_new_type, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010331
10332 /* Advance to rssi Threshold */
10333 ptr += offset;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010334 if (1 != sscanf(ptr, " %d %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010335 &(req.networks_list[i].rssi_thresh),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010336 &offset)) {
10337 hdd_err("PNO rssi threshold input is not valid %s",
10338 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010339 ret = -EINVAL;
10340 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010341 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010342 hdd_debug("PNO rssi %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010343 req.networks_list[i].rssi_thresh, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010344 /* Advance to next network */
10345 ptr += offset;
10346 } /* For ucNetworkCount */
10347
Abhishek Singh0481d662017-04-11 18:20:11 +053010348 req.fast_scan_period = 0;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010349 if (sscanf(ptr, " %u %n", &(req.fast_scan_period), &offset) > 0) {
Abhishek Singh0481d662017-04-11 18:20:11 +053010350 req.fast_scan_period *= MSEC_PER_SEC;
Dustin Brown43e87292016-10-10 10:38:25 -070010351 ptr += offset;
10352 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010353 if (req.fast_scan_period == 0) {
10354 hdd_err("invalid fast scan period %u",
10355 req.fast_scan_period);
10356 ret = -EINVAL;
10357 goto exit;
10358 }
Dustin Brown43e87292016-10-10 10:38:25 -070010359
Abhishek Singh0481d662017-04-11 18:20:11 +053010360 req.fast_scan_max_cycles = 0;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010361 if (sscanf(ptr, " %hhu %n", &value,
Dustin Brown43e87292016-10-10 10:38:25 -070010362 &offset) > 0)
10363 ptr += offset;
Abhishek Singh0481d662017-04-11 18:20:11 +053010364 req.fast_scan_max_cycles = value;
Dustin Brown43e87292016-10-10 10:38:25 -070010365
Abhishek Singh0481d662017-04-11 18:20:11 +053010366 wlan_pdev_obj_lock(hdd_ctx->hdd_pdev);
10367 psoc = wlan_pdev_get_psoc(hdd_ctx->hdd_pdev);
10368 wlan_pdev_obj_unlock(hdd_ctx->hdd_pdev);
10369 ucfg_scan_register_pno_cb(psoc,
10370 found_pref_network_cb, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010371
Abhishek Singh0481d662017-04-11 18:20:11 +053010372 ucfg_scan_get_pno_def_params(vdev, &req);
10373 status = ucfg_scan_pno_start(vdev, &req);
10374 if (QDF_IS_STATUS_ERROR(status)) {
10375 hdd_err("Failed to enable PNO");
10376 ret = -EINVAL;
10377 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010378
Abhishek Singh0481d662017-04-11 18:20:11 +053010379exit:
10380 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010381
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010382 qdf_mem_free(data);
Abhishek Singh0481d662017-04-11 18:20:11 +053010383 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010384}
10385
10386static int iw_set_pno(struct net_device *dev,
10387 struct iw_request_info *info,
10388 union iwreq_data *wrqu, char *extra)
10389{
10390 int ret;
10391
10392 cds_ssr_protect(__func__);
10393 ret = __iw_set_pno(dev, info, wrqu, extra);
10394 cds_ssr_unprotect(__func__);
10395
10396 return ret;
10397}
10398#endif /* FEATURE_WLAN_SCAN_PNO */
10399
10400/* Common function to SetBand */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010401int hdd_reg_set_band(struct net_device *dev, u8 ui_band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010402{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010403 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
10404 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010405 enum band_info band;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010406 QDF_STATUS status;
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010407 struct hdd_context *hdd_ctx;
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010408 enum band_info currBand;
10409 enum band_info connectedBand;
10410 long lrc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010411
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010412 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010413
10414 switch (ui_band) {
10415 case WLAN_HDD_UI_BAND_AUTO:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010416 band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010417 break;
10418 case WLAN_HDD_UI_BAND_5_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010419 band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010420 break;
10421 case WLAN_HDD_UI_BAND_2_4_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010422 band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010423 break;
10424 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070010425 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010426 return -EINVAL;
10427 }
10428
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010429 hdd_debug("change band to %u", band);
10430
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010431 if ((band == BAND_2G && hdd_ctx->config->nBandCapability == 2) ||
Rajeev Kumar Sirasanagandla4c9b6752017-07-25 20:35:20 +053010432 (band == BAND_5G && hdd_ctx->config->nBandCapability == 1) ||
10433 (band == BAND_ALL && hdd_ctx->config->nBandCapability != 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010434 hdd_err("band value %u violate INI settings %u",
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010435 band, hdd_ctx->config->nBandCapability);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010436 return -EIO;
10437 }
10438
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010439 if (band == BAND_ALL) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010440 hdd_debug("Auto band received. Setting band same as ini value %d",
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010441 hdd_ctx->config->nBandCapability);
10442 band = hdd_ctx->config->nBandCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010443 }
10444
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010445 if (QDF_STATUS_SUCCESS != ucfg_reg_get_curr_band(hdd_ctx->hdd_pdev,
Amar Singhal58b45ef2017-08-01 13:43:54 -070010446 &currBand)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010447 hdd_debug("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010448 return -EIO;
10449 }
10450
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010451 if (currBand == band)
10452 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010453
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010454 hdd_ctx->curr_band = band;
Amar Singhal58b45ef2017-08-01 13:43:54 -070010455
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010456 /* Change band request received.
10457 * Abort pending scan requests, flush the existing scan results,
10458 * and change the band capability
10459 */
10460 hdd_debug("Current band value = %u, new setting %u ",
10461 currBand, band);
10462
Dustin Brown920397d2017-12-13 16:27:50 -080010463 hdd_for_each_adapter(hdd_ctx, adapter) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010464 hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010465 wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID,
Jeff Johnson1b780e42017-10-31 14:11:45 -070010466 adapter->session_id, INVALID_SCAN_ID, false);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010467 connectedBand = hdd_conn_get_connected_band(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010468 WLAN_HDD_GET_STATION_CTX_PTR(adapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010469
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010470 /* Handling is done only for STA and P2P */
10471 if (band != BAND_ALL &&
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010472 ((adapter->device_mode == QDF_STA_MODE) ||
10473 (adapter->device_mode == QDF_P2P_CLIENT_MODE)) &&
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010474 (hdd_conn_is_connected(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010475 WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010476 && (connectedBand != band)) {
10477 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010478
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010479 /* STA already connected on current
10480 * band, So issue disconnect first,
10481 * then change the band
10482 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010483
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010484 hdd_debug("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010485 hdd_device_mode_to_string(adapter->device_mode),
10486 adapter->device_mode, currBand, band);
10487 INIT_COMPLETION(adapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010488
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010489 status = sme_roam_disconnect(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010490 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -070010491 adapter->session_id,
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010492 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010493
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010494 if (QDF_STATUS_SUCCESS != status) {
10495 hdd_err("sme_roam_disconnect failure, status: %d",
Jeff Johnson99bac312016-06-28 10:38:18 -070010496 (int)status);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010497 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010498 }
10499
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010500 lrc = wait_for_completion_timeout(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010501 &adapter->disconnect_comp_var,
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010502 msecs_to_jiffies(
10503 WLAN_WAIT_TIME_DISCONNECT));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010504
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010505 if (lrc == 0) {
10506 hdd_err("Timeout while waiting for csr_roam_disconnect");
10507 return -ETIMEDOUT;
10508 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010509 }
10510
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010511 sme_scan_flush_result(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010512 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010513
Dustin Brown920397d2017-12-13 16:27:50 -080010514 if (QDF_IS_STATUS_ERROR(ucfg_reg_set_band(hdd_ctx->hdd_pdev, band))) {
10515 hdd_err("Failed to set the band value to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010516 return -EINVAL;
10517 }
10518
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010519 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010520}
10521
10522static int __iw_set_band_config(struct net_device *dev,
10523 struct iw_request_info *info,
10524 union iwreq_data *wrqu, char *extra)
10525{
Jeff Johnson3d278b02017-08-29 14:17:47 -070010526 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010527 struct hdd_context *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -080010528 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010529 int *value = (int *)extra;
10530
Dustin Brownfdf17c12018-03-14 12:55:34 -070010531 hdd_enter_dev(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010532
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010533 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010534 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010535 return -EPERM;
10536 }
10537
Jeff Johnson441e1f72017-02-07 08:50:49 -080010538 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10539 ret = hdd_check_private_wext_control(hdd_ctx, info);
10540 if (0 != ret)
10541 return ret;
10542
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010543 return hdd_reg_set_band(dev, value[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010544}
10545
10546static int iw_set_band_config(struct net_device *dev,
10547 struct iw_request_info *info,
10548 union iwreq_data *wrqu, char *extra)
10549{
10550 int ret;
10551
10552 cds_ssr_protect(__func__);
10553 ret = __iw_set_band_config(dev, info, wrqu, extra);
10554 cds_ssr_unprotect(__func__);
10555
10556 return ret;
10557}
10558
Arunk Khandavalli062fb032017-10-04 12:18:15 +053010559int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010560 uint32_t bandwidth)
10561{
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010562 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -070010563 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010564 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
10565 QDF_STATUS status;
10566 tHalHandle hal_hdl = hdd_ctx->hHal;
10567 struct qdf_mac_addr bssid;
10568 tCsrRoamProfile roam_profile;
Amar Singhal5cccafe2017-02-15 12:42:58 -080010569 struct ch_params ch_params;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010570
10571 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
10572 hdd_err("Not supported, device is not in monitor mode");
10573 return -EINVAL;
10574 }
10575
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010576 hdd_debug("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080010577 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010578 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
10579 roam_profile.ChannelInfo.numOfChannels = 1;
10580 roam_profile.phyMode = ch_info->phy_mode;
10581 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070010582 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010583
Jeff Johnson1e851a12017-10-28 14:36:12 -070010584 qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010585 QDF_MAC_ADDR_SIZE);
10586
10587 ch_params.ch_width = bandwidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070010588 wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params);
Manjunathappa Prakashc4dc9382017-03-07 18:50:33 -080010589 if (ch_params.ch_width == CH_WIDTH_INVALID) {
10590 hdd_err("Invalid capture channel or bandwidth for a country");
10591 return -EINVAL;
10592 }
Krunal Sonied3bc8e2018-01-26 12:13:34 -080010593 if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan,
10594 POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) {
10595 hdd_err("Failed to change hw mode");
10596 return -EINVAL;
10597 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070010598
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010599 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
10600 &roam_profile);
10601 if (status) {
10602 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
10603 status);
10604 }
10605
Arunk Khandavalli062fb032017-10-04 12:18:15 +053010606 adapter->mon_chan = chan;
10607 adapter->mon_bandwidth = bandwidth;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010608 return qdf_status_to_os_return(status);
10609}
10610
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010611static int printk_adapter(void *priv, const char *fmt, ...)
10612{
10613 int ret;
10614 va_list args;
10615
10616 va_start(args, fmt);
10617 ret = vprintk(fmt, args);
10618 ret += printk("\n");
10619 va_end(args);
10620
10621 return ret;
10622}
10623
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010624static void hdd_ioctl_log_buffer(int log_id, uint32_t count)
10625{
10626 qdf_abstract_print *print = &printk_adapter;
10627
10628 switch (log_id) {
10629 case HTC_CREDIT_HISTORY_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010630 cds_print_htc_credit_history(count, print, NULL);
10631 break;
10632 case COMMAND_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010633 wma_print_wmi_cmd_log(count, print, NULL);
10634 break;
10635 case COMMAND_TX_CMP_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010636 wma_print_wmi_cmd_tx_cmp_log(count, print, NULL);
10637 break;
10638 case MGMT_COMMAND_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010639 wma_print_wmi_mgmt_cmd_log(count, print, NULL);
10640 break;
10641 case MGMT_COMMAND_TX_CMP_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010642 wma_print_wmi_mgmt_cmd_tx_cmp_log(count, print, NULL);
10643 break;
10644 case EVENT_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010645 wma_print_wmi_event_log(count, print, NULL);
10646 break;
10647 case RX_EVENT_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010648 wma_print_wmi_rx_event_log(count, print, NULL);
10649 break;
10650 case MGMT_EVENT_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010651 wma_print_wmi_mgmt_event_log(count, print, NULL);
10652 break;
10653 default:
10654 print(NULL, "Invalid Log Id %d", log_id);
10655 break;
10656 }
10657}
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010658
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010659static int __iw_set_two_ints_getnone(struct net_device *dev,
10660 struct iw_request_info *info,
10661 union iwreq_data *wrqu, char *extra)
10662{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010663 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010664 int *value = (int *)extra;
10665 int sub_cmd = value[0];
10666 int ret;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010667 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010668
Dustin Brownfdf17c12018-03-14 12:55:34 -070010669 hdd_enter_dev(dev);
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010670
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010671 ret = wlan_hdd_validate_context(hdd_ctx);
10672 if (0 != ret)
10673 return ret;
10674
Jeff Johnson441e1f72017-02-07 08:50:49 -080010675 ret = hdd_check_private_wext_control(hdd_ctx, info);
10676 if (0 != ret)
10677 return ret;
10678
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010679 switch (sub_cmd) {
10680 case WE_SET_SMPS_PARAM:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010681 hdd_debug("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Jeff Johnson1b780e42017-10-31 14:11:45 -070010682 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010683 WMI_STA_SMPS_PARAM_CMDID,
10684 value[1] << WMA_SMPS_PARAM_VALUE_S
10685 | value[2],
10686 VDEV_CMD);
10687 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070010688#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010689 case WE_SET_FW_CRASH_INJECT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010690 hdd_debug("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010691 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053010692 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
10693 value[1], value[2]);
SaidiReddy Yenugacc733af2016-11-09 17:45:42 +053010694 if (!hdd_ctx->config->crash_inject_enabled) {
10695 hdd_err("Crash Inject ini disabled, Ignore Crash Inject");
10696 return 0;
10697 }
Yue Ma06152352017-06-20 18:08:58 -070010698 if (value[1] == 3) {
Anurag Chouhan4085ff72017-10-05 18:09:56 +053010699 cds_trigger_recovery(QDF_REASON_UNSPECIFIED);
Yue Ma06152352017-06-20 18:08:58 -070010700 return 0;
10701 }
Jeff Johnson1b780e42017-10-31 14:11:45 -070010702 ret = wma_cli_set2_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010703 GEN_PARAM_CRASH_INJECT,
10704 value[1], value[2], GEN_CMD);
10705 break;
10706#endif
Govind Singha471e5e2015-10-12 17:11:14 +053010707 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010708 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010709 value[1], value[2]);
Jeff Johnson1b780e42017-10-31 14:11:45 -070010710 ret = wma_cli_set2_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +053010711 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
10712 value[1], value[2], DBG_CMD);
10713 break;
10714 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070010715 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010716 value[1], value[2]);
Jeff Johnson1b780e42017-10-31 14:11:45 -070010717 ret = wma_cli_set2_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +053010718 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
10719 value[1], value[2], DBG_CMD);
10720 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010721 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
10722 hdd_debug("Ioctl to set dual fw mode config");
Tushnim Bhattacharyya49ed8ab2017-05-26 18:20:10 -070010723 if (hdd_ctx->config->dual_mac_feature_disable ==
10724 DISABLE_DBS_CXN_AND_SCAN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010725 hdd_err("Dual mac feature is disabled from INI");
10726 return -EPERM;
10727 }
10728 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010729 policy_mgr_set_dual_mac_fw_mode_config(hdd_ctx->hdd_psoc,
10730 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010731 break;
10732 case WE_DUMP_DP_TRACE_LEVEL:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010733 hdd_debug("WE_DUMP_DP_TRACE_LEVEL: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010734 value[1], value[2]);
10735 if (value[1] == DUMP_DP_TRACE)
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -070010736 qdf_dp_trace_dump_all(value[2],
10737 QDF_TRACE_DEFAULT_PDEV_ID);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053010738 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
10739 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053010740 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
10741 qdf_dp_trace_clear_buffer();
Mohit Khannaf8f96822017-05-17 17:11:59 -070010742 else if (value[1] == DISABLE_DP_TRACE_LIVE_MODE)
10743 qdf_dp_trace_disable_live_mode();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010744 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010745 case WE_SET_MON_MODE_CHAN:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010746 ret = wlan_hdd_set_mon_chan(adapter, value[1], value[2]);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010747 break;
Dustin Brown54096432017-02-23 13:00:44 -080010748 case WE_SET_WLAN_SUSPEND: {
Dustin Brown3ed3e9b2017-03-23 12:57:58 -070010749 hdd_info("STA unit-test suspend(%d, %d)", value[1], value[2]);
Dustin Brown54096432017-02-23 13:00:44 -080010750 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
10751 value[1], value[2]);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010752 break;
Dustin Brown54096432017-02-23 13:00:44 -080010753 }
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010754 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070010755 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010756 break;
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010757 case WE_LOG_BUFFER: {
10758 int log_id = value[1];
10759 uint32_t count = value[2] < 0 ? 0 : value[2];
10760
10761 hdd_ioctl_log_buffer(log_id, count);
10762
10763 break;
10764 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010765 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070010766 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010767 break;
10768 }
10769
10770 return ret;
10771}
10772
10773static int iw_set_two_ints_getnone(struct net_device *dev,
10774 struct iw_request_info *info,
10775 union iwreq_data *wrqu, char *extra)
10776{
10777 int ret;
10778
10779 cds_ssr_protect(__func__);
10780 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
10781 cds_ssr_unprotect(__func__);
10782
10783 return ret;
10784}
10785
10786/* Define the Wireless Extensions to the Linux Network Device structure */
10787/* A number of these routines are NULL (meaning they are not implemented.) */
10788
10789static const iw_handler we_handler[] = {
10790 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10791 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10792 (iw_handler) NULL, /* SIOCSIWNWID */
10793 (iw_handler) NULL, /* SIOCGIWNWID */
Jeff Johnson7b0f3a22017-10-15 21:25:28 -070010794 (iw_handler) NULL, /* SIOCSIWFREQ */
Jeff Johnson52002c02017-10-15 21:18:52 -070010795 (iw_handler) NULL, /* SIOCGIWFREQ */
Jeff Johnson31fd71a2017-10-15 21:13:09 -070010796 (iw_handler) NULL, /* SIOCSIWMODE */
Jeff Johnson88aa1a22017-10-15 21:06:34 -070010797 (iw_handler) NULL, /* SIOCGIWMODE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010798 (iw_handler) NULL, /* SIOCSIWSENS */
10799 (iw_handler) NULL, /* SIOCGIWSENS */
10800 (iw_handler) NULL, /* SIOCSIWRANGE */
10801 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10802 (iw_handler) NULL, /* SIOCSIWPRIV */
10803 (iw_handler) NULL, /* SIOCGIWPRIV */
10804 (iw_handler) NULL, /* SIOCSIWSTATS */
10805 (iw_handler) NULL, /* SIOCGIWSTATS */
10806 (iw_handler) NULL, /* SIOCSIWSPY */
10807 (iw_handler) NULL, /* SIOCGIWSPY */
10808 (iw_handler) NULL, /* SIOCSIWTHRSPY */
10809 (iw_handler) NULL, /* SIOCGIWTHRSPY */
Jeff Johnson5ff10172017-10-15 18:45:27 -070010810 (iw_handler) NULL, /* SIOCSIWAP */
Jeff Johnsonb07d3ff2017-10-15 18:38:53 -070010811 (iw_handler) NULL, /* SIOCGIWAP */
Jeff Johnson2165afc2017-10-15 18:33:12 -070010812 (iw_handler) NULL, /* SIOCSIWMLME */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010813 (iw_handler) NULL, /* SIOCGIWAPLIST */
Jeff Johnsond73a5432017-10-15 18:12:52 -070010814 (iw_handler) NULL, /* SIOCSIWSCAN */
10815 (iw_handler) NULL, /* SIOCGIWSCAN */
10816 (iw_handler) NULL, /* SIOCSIWESSID */
Jeff Johnson3c6c0ef2017-10-15 17:59:14 -070010817 (iw_handler) NULL, /* SIOCGIWESSID */
Jeff Johnson90448a82017-10-15 16:35:25 -070010818 (iw_handler) NULL, /* SIOCSIWNICKN */
Jeff Johnson22ba2a42017-10-15 15:53:39 -070010819 (iw_handler) NULL, /* SIOCGIWNICKN */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010820 (iw_handler) NULL, /* -- hole -- */
10821 (iw_handler) NULL, /* -- hole -- */
Jeff Johnson64b26982017-10-15 15:48:38 -070010822 (iw_handler) NULL, /* SIOCSIWRATE */
Jeff Johnson7b5b8e72017-10-15 15:41:00 -070010823 (iw_handler) NULL, /* SIOCGIWRATE */
Jeff Johnsonf2316482017-10-15 14:57:02 -070010824 (iw_handler) NULL, /* SIOCSIWRTS */
Jeff Johnsona95d5ca2017-10-15 14:49:45 -070010825 (iw_handler) NULL, /* SIOCGIWRTS */
Jeff Johnson40d70102017-10-15 14:39:01 -070010826 (iw_handler) NULL, /* SIOCSIWFRAG */
Jeff Johnson75956d32017-10-15 13:53:36 -070010827 (iw_handler) NULL, /* SIOCGIWFRAG */
Jeff Johnson744676f2017-10-15 12:56:16 -070010828 (iw_handler) NULL, /* SIOCSIWTXPOW */
Jeff Johnson918d35e2017-10-15 12:50:26 -070010829 (iw_handler) NULL, /* SIOCGIWTXPOW */
Jeff Johnsond8995042017-10-15 12:45:45 -070010830 (iw_handler) NULL, /* SIOCSIWRETRY */
Jeff Johnson00367e22017-10-15 12:40:15 -070010831 (iw_handler) NULL, /* SIOCGIWRETRY */
Jeff Johnson140e07a2017-10-15 12:32:29 -070010832 (iw_handler) NULL, /* SIOCSIWENCODE */
Jeff Johnsone84e8d02017-10-15 12:22:58 -070010833 (iw_handler) NULL, /* SIOCGIWENCODE */
Jeff Johnson955e0582017-10-15 11:56:52 -070010834 (iw_handler) NULL, /* SIOCSIWPOWER */
Jeff Johnson330d8dc2017-10-15 11:43:13 -070010835 (iw_handler) NULL, /* SIOCGIWPOWER */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010836 (iw_handler) NULL, /* -- hole -- */
10837 (iw_handler) NULL, /* -- hole -- */
Jeff Johnson4bcdafa2017-10-15 11:33:42 -070010838 (iw_handler) NULL, /* SIOCSIWGENIE */
Jeff Johnsonf6562c62017-10-15 11:24:05 -070010839 (iw_handler) NULL, /* SIOCGIWGENIE */
Jeff Johnson079f7de2017-10-15 11:04:08 -070010840 (iw_handler) NULL, /* SIOCSIWAUTH */
Jeff Johnson4139b822017-10-15 10:55:03 -070010841 (iw_handler) NULL, /* SIOCGIWAUTH */
Jeff Johnson5b300822017-10-15 10:44:40 -070010842 (iw_handler) NULL, /* SIOCSIWENCODEEXT */
Jeff Johnson6b747052017-10-15 10:29:04 -070010843 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010844 (iw_handler) NULL, /* SIOCSIWPMKSA */
10845};
10846
10847static const iw_handler we_private[] = {
10848
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010849 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone,
10850 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint,
10851 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010852 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10853 iw_set_three_ints_getnone,
10854 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010855 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010856 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10857 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010858 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
10859 iw_setnone_get_threeint,
Nirav Shaheb017be2018-02-15 11:20:58 +053010860#ifdef WLAN_FEATURE_FIPS
Jeff Johnson6fa1e012017-04-05 06:40:53 -070010861 [WLAN_PRIV_FIPS_TEST - SIOCIWFIRSTPRIV] = hdd_fips_test,
Nirav Shaheb017be2018-02-15 11:20:58 +053010862#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010863 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10864 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10865 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010866 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010867 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10868 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10869 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
10870 iw_set_keepalive_params,
10871#ifdef WLAN_FEATURE_PACKET_FILTERING
10872 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
10873 iw_set_packet_filter_params,
10874#endif
10875#ifdef FEATURE_WLAN_SCAN_PNO
10876 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
10877#endif
10878 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080010879 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
10880 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010881 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
10882 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10883 iw_set_two_ints_getnone,
10884 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
10885 iw_set_dot11p_channel_sched,
10886};
10887
10888/*Maximum command length can be only 15 */
10889static const struct iw_priv_args we_private_args[] = {
10890
10891 /* handlers for main ioctl */
10892 {WLAN_PRIV_SET_INT_GET_NONE,
10893 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10894 0,
10895 ""},
10896
10897 /* handlers for sub-ioctl */
10898 {WE_SET_11D_STATE,
10899 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10900 0,
10901 "set11Dstate"},
10902
10903 {WE_WOWL,
10904 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10905 0,
10906 "wowl"},
10907
10908 {WE_SET_POWER,
10909 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10910 0,
10911 "setPower"},
10912
10913 {WE_SET_MAX_ASSOC,
10914 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10915 0,
10916 "setMaxAssoc"},
10917
10918 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10919 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10920 "setAutoChannel" },
10921
10922 {WE_SET_SCAN_DISABLE,
10923 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10924 0,
10925 "scan_disable"},
10926
10927 {WE_SET_DATA_INACTIVITY_TO,
10928 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10929 0,
10930 "inactivityTO"},
10931
Mukul Sharmaed92f2f2017-04-20 00:06:28 +053010932 {WE_SET_WOW_DATA_INACTIVITY_TO,
10933 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10934 0,
10935 "wow_ito"},
10936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010937 {WE_SET_MAX_TX_POWER,
10938 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10939 0,
10940 "setMaxTxPower"},
10941
10942 {WE_SET_TX_POWER,
10943 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10944 0,
10945 "setTxPower"},
10946
10947 {WE_SET_MC_RATE,
10948 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10949 0,
10950 "setMcRate"},
10951
10952 {WE_SET_MAX_TX_POWER_2_4,
10953 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10954 0,
10955 "setTxMaxPower2G"},
10956
10957 {WE_SET_MAX_TX_POWER_5_0,
10958 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10959 0,
10960 "setTxMaxPower5G"},
10961
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010962 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010963 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010964 0,
10965 "pktlog"},
10966
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010967 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10968 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010969 * will support both
10970 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010971 {WE_SET_MAX_TX_POWER,
10972 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10973 0,
10974 "setTxMaxPower"},
10975
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010976 {WE_SET_TM_LEVEL,
10977 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10978 0,
10979 "setTmLevel"},
10980
10981 {WE_SET_PHYMODE,
10982 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10983 0,
10984 "setphymode"},
10985
10986 {WE_SET_NSS,
10987 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10988 0,
10989 "nss"},
10990
10991 {WE_SET_LDPC,
10992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10993 0,
10994 "ldpc"},
10995
10996 {WE_SET_TX_STBC,
10997 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10998 0,
10999 "tx_stbc"},
11000
11001 {WE_SET_RX_STBC,
11002 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11003 0,
11004 "rx_stbc"},
11005
11006 {WE_SET_SHORT_GI,
11007 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11008 0,
11009 "shortgi"},
11010
11011 {WE_SET_RTSCTS,
11012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11013 0,
11014 "enablertscts"},
11015
11016 {WE_SET_CHWIDTH,
11017 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11018 0,
11019 "chwidth"},
11020
11021 {WE_SET_ANI_EN_DIS,
11022 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11023 0,
11024 "anienable"},
11025
11026 {WE_SET_ANI_POLL_PERIOD,
11027 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11028 0,
11029 "aniplen"},
11030
11031 {WE_SET_ANI_LISTEN_PERIOD,
11032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11033 0,
11034 "anilislen"},
11035
11036 {WE_SET_ANI_OFDM_LEVEL,
11037 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11038 0,
11039 "aniofdmlvl"},
11040
11041 {WE_SET_ANI_CCK_LEVEL,
11042 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11043 0,
11044 "aniccklvl"},
11045
11046 {WE_SET_DYNAMIC_BW,
11047 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11048 0,
11049 "cwmenable"},
11050
11051 {WE_SET_CTS_CBW,
11052 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11053 0,
11054 "cts_cbw" },
11055
11056 {WE_SET_GTX_HT_MCS,
11057 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11058 0,
11059 "gtxHTMcs"},
11060
11061 {WE_SET_GTX_VHT_MCS,
11062 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11063 0,
11064 "gtxVHTMcs"},
11065
11066 {WE_SET_GTX_USRCFG,
11067 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11068 0,
11069 "gtxUsrCfg"},
11070
11071 {WE_SET_GTX_THRE,
11072 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11073 0,
11074 "gtxThre"},
11075
11076 {WE_SET_GTX_MARGIN,
11077 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11078 0,
11079 "gtxMargin"},
11080
11081 {WE_SET_GTX_STEP,
11082 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11083 0,
11084 "gtxStep"},
11085
11086 {WE_SET_GTX_MINTPC,
11087 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11088 0,
11089 "gtxMinTpc"},
11090
11091 {WE_SET_GTX_BWMASK,
11092 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11093 0,
11094 "gtxBWMask"},
11095
11096 {WE_SET_TX_CHAINMASK,
11097 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11098 0,
11099 "txchainmask"},
11100
11101 {WE_SET_RX_CHAINMASK,
11102 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11103 0,
11104 "rxchainmask"},
11105
11106 {WE_SET_11N_RATE,
11107 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11108 0,
11109 "set11NRates"},
11110
11111 {WE_SET_VHT_RATE,
11112 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11113 0,
11114 "set11ACRates"},
11115
11116 {WE_SET_AMPDU,
11117 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11118 0,
11119 "ampdu"},
11120
11121 {WE_SET_AMSDU,
11122 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11123 0,
11124 "amsdu"},
11125
11126 {WE_SET_BURST_ENABLE,
11127 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11128 0,
11129 "burst_enable"},
11130
11131 {WE_SET_BURST_DUR,
11132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11133 0,
11134 "burst_dur"},
11135
11136 {WE_SET_TXPOW_2G,
11137 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11138 0,
11139 "txpow2g"},
11140
11141 {WE_SET_TXPOW_5G,
11142 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11143 0,
11144 "txpow5g"},
11145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011146 /* Sub-cmds DBGLOG specific commands */
11147 {WE_DBGLOG_LOG_LEVEL,
11148 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11149 0,
11150 "dl_loglevel"},
11151
11152 {WE_DBGLOG_VAP_ENABLE,
11153 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11154 0,
11155 "dl_vapon"},
11156
11157 {WE_DBGLOG_VAP_DISABLE,
11158 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11159 0,
11160 "dl_vapoff"},
11161
11162 {WE_DBGLOG_MODULE_ENABLE,
11163 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11164 0,
11165 "dl_modon"},
11166
11167 {WE_DBGLOG_MODULE_DISABLE,
11168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11169 0,
11170 "dl_modoff"},
11171
11172 {WE_DBGLOG_MOD_LOG_LEVEL,
11173 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11174 0,
11175 "dl_mod_loglevel"},
11176
11177 {WE_DBGLOG_TYPE,
11178 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11179 0,
11180 "dl_type"},
11181 {WE_DBGLOG_REPORT_ENABLE,
11182 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11183 0,
11184 "dl_report"},
11185
11186 {WE_SET_TXRX_FWSTATS,
11187 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11188 0,
11189 "txrx_fw_stats"},
11190
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080011191 {WE_SET_TXRX_STATS,
11192 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11193 0,
11194 "txrx_stats"},
11195
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011196 {WE_TXRX_FWSTATS_RESET,
11197 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11198 0,
11199 "txrx_fw_st_rst"},
11200
11201 {WE_PPS_PAID_MATCH,
11202 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11203 0, "paid_match"},
11204
11205 {WE_PPS_GID_MATCH,
11206 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11207 0, "gid_match"},
11208
11209 {WE_PPS_EARLY_TIM_CLEAR,
11210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11211 0, "tim_clear"},
11212
11213 {WE_PPS_EARLY_DTIM_CLEAR,
11214 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11215 0, "dtim_clear"},
11216
11217 {WE_PPS_EOF_PAD_DELIM,
11218 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11219 0, "eof_delim"},
11220
11221 {WE_PPS_MACADDR_MISMATCH,
11222 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11223 0, "mac_match"},
11224
11225 {WE_PPS_DELIM_CRC_FAIL,
11226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11227 0, "delim_fail"},
11228
11229 {WE_PPS_GID_NSTS_ZERO,
11230 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11231 0, "nsts_zero"},
11232
11233 {WE_PPS_RSSI_CHECK,
11234 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11235 0, "rssi_chk"},
11236
11237 {WE_PPS_5G_EBT,
11238 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11239 0, "5g_ebt"},
11240
11241 {WE_SET_HTSMPS,
11242 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11243 0, "htsmps"},
11244
11245 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
11246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11247 0, "set_qpspollcnt"},
11248
11249 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
11250 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11251 0, "set_qtxwake"},
11252
11253 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
11254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11255 0, "set_qwakeintv"},
11256
11257 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
11258 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11259 0, "set_qnodatapoll"},
11260
11261 /* handlers for MCC time quota and latency sub ioctls */
11262 {WE_MCC_CONFIG_LATENCY,
11263 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11264 0, "setMccLatency"},
11265
11266 {WE_MCC_CONFIG_QUOTA,
11267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11268 0, "setMccQuota"},
11269
11270 {WE_SET_DEBUG_LOG,
11271 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11272 0, "setDbgLvl"},
11273
11274 /* handlers for early_rx power save */
11275 {WE_SET_EARLY_RX_ADJUST_ENABLE,
11276 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11277 0, "erx_enable"},
11278
11279 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
11280 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11281 0, "erx_bmiss_val"},
11282
11283 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
11284 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11285 0, "erx_bmiss_smpl"},
11286
11287 {WE_SET_EARLY_RX_SLOP_STEP,
11288 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11289 0, "erx_slop_step"},
11290
11291 {WE_SET_EARLY_RX_INIT_SLOP,
11292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11293 0, "erx_init_slop"},
11294
11295 {WE_SET_EARLY_RX_ADJUST_PAUSE,
11296 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11297 0, "erx_adj_pause"},
11298
11299 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
11300 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11301 0, "erx_dri_sample"},
11302
11303 {WE_DUMP_STATS,
11304 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11305 0, "dumpStats"},
11306
11307 {WE_CLEAR_STATS,
11308 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11309 0, "clearStats"},
11310
Govind Singha471e5e2015-10-12 17:11:14 +053011311 {WE_START_FW_PROFILE,
11312 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11313 0, "startProfile"},
11314
Abhishek Singh1bdb1572015-10-16 16:24:19 +053011315 {WE_SET_CHANNEL,
11316 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11317 0, "setChanChange" },
11318
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053011319 {WE_SET_CONC_SYSTEM_PREF,
11320 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11321 0, "setConcSysPref" },
11322
Jeff Johnson011c4502017-10-05 15:25:56 -070011323 {WE_SET_PDEV_RESET,
11324 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11325 0, "pdev_reset" },
11326
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +053011327 {WE_SET_MODULATED_DTIM,
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -080011328 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11329 0, "setModDTIM" },
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +053011330
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011331 {WLAN_PRIV_SET_NONE_GET_INT,
11332 0,
11333 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11334 ""},
11335
11336 /* handlers for sub-ioctl */
11337 {WE_GET_11D_STATE,
11338 0,
11339 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11340 "get11Dstate"},
11341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011342 {WE_GET_WLAN_DBG,
11343 0,
11344 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11345 "getwlandbg"},
11346
11347 {WE_GET_MAX_ASSOC,
11348 0,
11349 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11350 "getMaxAssoc"},
11351
11352 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11353 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11354 "getAutoChannel" },
11355
11356 {WE_GET_CONCURRENCY_MODE,
11357 0,
11358 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11359 "getconcurrency"},
11360
11361 {WE_GET_NSS,
11362 0,
11363 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11364 "get_nss"},
11365
11366 {WE_GET_LDPC,
11367 0,
11368 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11369 "get_ldpc"},
11370
11371 {WE_GET_TX_STBC,
11372 0,
11373 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11374 "get_tx_stbc"},
11375
11376 {WE_GET_RX_STBC,
11377 0,
11378 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11379 "get_rx_stbc"},
11380
11381 {WE_GET_SHORT_GI,
11382 0,
11383 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11384 "get_shortgi"},
11385
11386 {WE_GET_RTSCTS,
11387 0,
11388 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11389 "get_rtscts"},
11390
11391 {WE_GET_CHWIDTH,
11392 0,
11393 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11394 "get_chwidth"},
11395
11396 {WE_GET_ANI_EN_DIS,
11397 0,
11398 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11399 "get_anienable"},
11400
11401 {WE_GET_ANI_POLL_PERIOD,
11402 0,
11403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11404 "get_aniplen"},
11405
11406 {WE_GET_ANI_LISTEN_PERIOD,
11407 0,
11408 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11409 "get_anilislen"},
11410
11411 {WE_GET_ANI_OFDM_LEVEL,
11412 0,
11413 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11414 "get_aniofdmlvl"},
11415
11416 {WE_GET_ANI_CCK_LEVEL,
11417 0,
11418 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11419 "get_aniccklvl"},
11420
11421 {WE_GET_DYNAMIC_BW,
11422 0,
11423 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11424 "get_cwmenable"},
11425
11426 {WE_GET_GTX_HT_MCS,
11427 0,
11428 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11429 "get_gtxHTMcs"},
11430
11431 {WE_GET_GTX_VHT_MCS,
11432 0,
11433 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11434 "get_gtxVHTMcs"},
11435
11436 {WE_GET_GTX_USRCFG,
11437 0,
11438 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11439 "get_gtxUsrCfg"},
11440
11441 {WE_GET_GTX_THRE,
11442 0,
11443 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11444 "get_gtxThre"},
11445
11446 {WE_GET_GTX_MARGIN,
11447 0,
11448 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11449 "get_gtxMargin"},
11450
11451 {WE_GET_GTX_STEP,
11452 0,
11453 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11454 "get_gtxStep"},
11455
11456 {WE_GET_GTX_MINTPC,
11457 0,
11458 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11459 "get_gtxMinTpc"},
11460
11461 {WE_GET_GTX_BWMASK,
11462 0,
11463 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11464 "get_gtxBWMask"},
11465
11466 {WE_GET_TX_CHAINMASK,
11467 0,
11468 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11469 "get_txchainmask"},
11470
11471 {WE_GET_RX_CHAINMASK,
11472 0,
11473 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11474 "get_rxchainmask"},
11475
11476 {WE_GET_11N_RATE,
11477 0,
11478 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11479 "get_11nrate"},
11480
11481 {WE_GET_AMPDU,
11482 0,
11483 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11484 "get_ampdu"},
11485
11486 {WE_GET_AMSDU,
11487 0,
11488 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11489 "get_amsdu"},
11490
11491 {WE_GET_BURST_ENABLE,
11492 0,
11493 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11494 "get_burst_en"},
11495
11496 {WE_GET_BURST_DUR,
11497 0,
11498 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11499 "get_burst_dur"},
11500
11501 {WE_GET_TXPOW_2G,
11502 0,
11503 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11504 "get_txpow2g"},
11505
11506 {WE_GET_TXPOW_5G,
11507 0,
11508 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11509 "get_txpow5g"},
11510
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011511 {WE_GET_PPS_PAID_MATCH,
11512 0,
11513 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11514 "get_paid_match"},
11515
11516 {WE_GET_PPS_GID_MATCH,
11517 0,
11518 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11519 "get_gid_match"},
11520
11521 {WE_GET_PPS_EARLY_TIM_CLEAR,
11522 0,
11523 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11524 "get_tim_clear"},
11525
11526 {WE_GET_PPS_EARLY_DTIM_CLEAR,
11527 0,
11528 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11529 "get_dtim_clear"},
11530
11531 {WE_GET_PPS_EOF_PAD_DELIM,
11532 0,
11533 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11534 "get_eof_delim"},
11535
11536 {WE_GET_PPS_MACADDR_MISMATCH,
11537 0,
11538 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11539 "get_mac_match"},
11540
11541 {WE_GET_PPS_DELIM_CRC_FAIL,
11542 0,
11543 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11544 "get_delim_fail"},
11545
11546 {WE_GET_PPS_GID_NSTS_ZERO,
11547 0,
11548 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11549 "get_nsts_zero"},
11550
11551 {WE_GET_PPS_RSSI_CHECK,
11552 0,
11553 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11554 "get_rssi_chk"},
11555
11556 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
11557 0,
11558 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11559 "get_qpspollcnt"},
11560
11561 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
11562 0,
11563 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11564 "get_qtxwake"},
11565
11566 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
11567 0,
11568 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11569 "get_qwakeintv"},
11570
11571 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
11572 0,
11573 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11574 "get_qnodatapoll"},
11575
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011576 {WE_CAP_TSF,
11577 0,
11578 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11579 "cap_tsf"},
11580
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011581 {WE_GET_TEMPERATURE,
11582 0,
11583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11584 "get_temp"},
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070011585 {WE_GET_DCM,
11586 0,
11587 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11588 "get_dcm"},
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070011589 {WE_GET_RANGE_EXT,
11590 0,
11591 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11592 "get_range_ext"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011593 /* handlers for main ioctl */
11594 {WLAN_PRIV_SET_CHAR_GET_NONE,
11595 IW_PRIV_TYPE_CHAR | 512,
11596 0,
11597 ""},
11598
11599 /* handlers for sub-ioctl */
11600 {WE_WOWL_ADD_PTRN,
11601 IW_PRIV_TYPE_CHAR | 512,
11602 0,
11603 "wowlAddPtrn"},
11604
11605 {WE_WOWL_DEL_PTRN,
11606 IW_PRIV_TYPE_CHAR | 512,
11607 0,
11608 "wowlDelPtrn"},
11609
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011610 /* handlers for sub-ioctl */
11611 {WE_NEIGHBOR_REPORT_REQUEST,
11612 IW_PRIV_TYPE_CHAR | 512,
11613 0,
11614 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080011615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011616 {WE_SET_AP_WPS_IE,
11617 IW_PRIV_TYPE_CHAR | 512,
11618 0,
11619 "set_ap_wps_ie"},
11620
11621 {WE_SET_CONFIG,
11622 IW_PRIV_TYPE_CHAR | 512,
11623 0,
11624 "setConfig"},
11625
11626 /* handlers for main ioctl */
11627 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
11628 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11629 0,
11630 ""},
11631
11632 /* handlers for sub-ioctl */
11633 {WE_SET_WLAN_DBG,
11634 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11635 0,
11636 "setwlandbg"},
11637
11638 /* handlers for sub-ioctl */
11639 {WE_SET_DP_TRACE,
11640 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11641 0,
11642 "set_dp_trace"},
11643
11644 {WE_SET_SAP_CHANNELS,
11645 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11646 0,
11647 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053011648
11649 {WE_SET_FW_TEST,
11650 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11651 0, "fw_test"},
11652
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011653 /* handlers for main ioctl */
11654 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
11655 0,
11656 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11657 "" },
11658 {WE_GET_TSF,
11659 0,
11660 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11661 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011662
11663 {WE_SET_DUAL_MAC_SCAN_CONFIG,
11664 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11665 0,
11666 "set_scan_cfg"},
11667
11668 /* handlers for main ioctl */
11669 {WLAN_PRIV_GET_CHAR_SET_NONE,
11670 0,
11671 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11672 ""},
11673
11674 /* handlers for sub-ioctl */
11675 {WE_WLAN_VERSION,
11676 0,
11677 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11678 "version"},
11679 {WE_GET_STATS,
11680 0,
11681 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11682 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080011683 {WE_GET_SUSPEND_RESUME_STATS,
11684 0,
11685 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11686 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053011687 {WE_LIST_FW_PROFILE,
11688 0,
11689 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11690 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011691 {WE_GET_STATES,
11692 0,
11693 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11694 "getHostStates"},
11695 {WE_GET_CFG,
11696 0,
11697 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11698 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011699 {WE_GET_RSSI,
11700 0,
11701 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11702 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011703 {WE_GET_WMM_STATUS,
11704 0,
11705 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11706 "getWmmStatus"},
11707 {
11708 WE_GET_CHANNEL_LIST,
11709 0,
11710 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11711 "getChannelList"
11712 },
11713#ifdef FEATURE_WLAN_TDLS
11714 {
11715 WE_GET_TDLS_PEERS,
11716 0,
11717 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11718 "getTdlsPeers"
11719 },
11720#endif
11721#ifdef WLAN_FEATURE_11W
11722 {
11723 WE_GET_11W_INFO,
11724 0,
11725 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11726 "getPMFInfo"
11727 },
11728#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011729 {
11730 WE_GET_IBSS_STA_INFO,
11731 0,
11732 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11733 "getIbssSTAs"
11734 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011735 {WE_GET_PHYMODE,
11736 0,
11737 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11738 "getphymode"},
Naveen Rawat910726a2017-03-06 11:42:51 -080011739#if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011740 {WE_GET_OEM_DATA_CAP,
11741 0,
11742 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11743 "getOemDataCap"},
Naveen Rawat910726a2017-03-06 11:42:51 -080011744#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011745 {WE_GET_SNR,
11746 0,
11747 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11748 "getSNR"},
11749
11750 /* handlers for main ioctl */
11751 {WLAN_PRIV_SET_NONE_GET_NONE,
11752 0,
11753 0,
11754 ""},
11755
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011756 /* handlers for sub-ioctl */
11757 {
11758 WE_IBSS_GET_PEER_INFO_ALL,
11759 0,
11760 0,
11761 "ibssPeerInfoAll"
11762 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011763 {WE_GET_RECOVERY_STAT,
11764 0,
11765 0,
11766 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053011767
11768 {WE_GET_FW_PROFILE_DATA,
11769 0,
11770 0,
11771 "getProfileData"},
11772
11773 {WE_SET_REASSOC_TRIGGER,
11774 0,
11775 0,
11776 "reassoc"},
11777
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080011778 {WE_STOP_OBSS_SCAN,
11779 0,
11780 0,
11781 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011782 /* handlers for main ioctl */
11783 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
11784 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11785 0,
11786 ""},
11787
11788 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011789 {WE_IBSS_GET_PEER_INFO,
11790 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11791 0,
11792 "ibssPeerInfo"},
11793
Rachit Kankane0baf6e72018-01-19 15:01:50 +053011794#ifdef TRACE_RECORD
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011795 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011796 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11797 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11798 0,
11799 "setdumplog"},
11800
11801 {WE_MTRACE_DUMP_CMD,
11802 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11803 0,
11804 "dumplog"},
Rachit Kankane0baf6e72018-01-19 15:01:50 +053011805#endif
Krunal Sonia6e505b2017-01-12 12:25:18 -080011806
11807 {WE_POLICY_MANAGER_CINFO_CMD,
11808 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11809 0,
11810 "pm_cinfo"},
11811
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011812#ifdef MPC_UT_FRAMEWORK
11813 {WE_POLICY_MANAGER_CLIST_CMD,
11814 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11815 0,
11816 "pm_clist"},
11817
11818 {WE_POLICY_MANAGER_DLIST_CMD,
11819 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11820 0,
11821 "pm_dlist"},
11822
11823 {WE_POLICY_MANAGER_DBS_CMD,
11824 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11825 0,
11826 "pm_dbs"},
11827
11828 {WE_POLICY_MANAGER_PCL_CMD,
11829 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11830 0,
11831 "pm_pcl"},
11832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011833 {WE_POLICY_MANAGER_ULIST_CMD,
11834 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11835 0,
11836 "pm_ulist"},
11837
11838 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
11839 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11840 0,
11841 "pm_query_action"},
11842
11843 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
11844 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11845 0,
11846 "pm_query_allow"},
11847
11848 {WE_POLICY_MANAGER_SCENARIO_CMD,
11849 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11850 0,
11851 "pm_run_scenario"},
11852
11853 {WE_POLICY_SET_HW_MODE_CMD,
11854 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11855 0,
11856 "pm_set_hw_mode"},
11857#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011858 {
11859 WE_UNIT_TEST_CMD,
11860 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11861 0,
11862 "setUnitTestCmd"
11863 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053011864 {
11865 WE_MAC_PWR_DEBUG_CMD,
11866 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11867 0,
11868 "halPwrDebug"
11869 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011870
11871#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11872 {WE_LED_FLASHING_PARAM,
11873 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11874 0,
11875 "gpio_control"},
11876#endif
Liangwei Dong2a7f2912018-02-07 17:08:17 +080011877#ifdef WLAN_DEBUG
11878 {WE_SET_CHAN_AVOID,
11879 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11880 0,
11881 "ch_avoid"},
11882#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011883 /* handlers for main ioctl */
Jeff Johnson6fa1e012017-04-05 06:40:53 -070011884 {WLAN_PRIV_FIPS_TEST,
11885 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11886 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11887 "fips_test"},
11888
11889 /* handlers for main ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011890 {WLAN_PRIV_ADD_TSPEC,
11891 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11892 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11893 "addTspec"},
11894
11895 /* handlers for main ioctl */
11896 {WLAN_PRIV_DEL_TSPEC,
11897 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11898 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11899 "delTspec"},
11900
11901 /* handlers for main ioctl */
11902 {WLAN_PRIV_GET_TSPEC,
11903 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11904 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11905 "getTspec"},
11906
11907 /* handlers for main ioctl - host offload */
11908 {
11909 WLAN_PRIV_SET_HOST_OFFLOAD,
Srinivas Girigowda077143e2017-03-25 10:47:27 -070011910 IW_PRIV_TYPE_BYTE | sizeof(struct host_offload_req),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011911 0,
11912 "setHostOffload"
11913 }
11914 ,
11915
11916 {
11917 WLAN_GET_WLAN_STATISTICS,
11918 0,
11919 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11920 "getWlanStats"
11921 }
11922 ,
11923
11924 {
11925 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011926 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11927 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011928 0,
11929 "setKeepAlive"
11930 }
11931 ,
11932#ifdef WLAN_FEATURE_PACKET_FILTERING
11933 {
11934 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053011935 IW_PRIV_TYPE_BYTE |
11936 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011937 0,
11938 "setPktFilter"
11939 }
11940 ,
11941#endif
11942#ifdef FEATURE_WLAN_SCAN_PNO
11943 {
11944 WLAN_SET_PNO,
11945 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11946 0,
11947 "setpno"
11948 }
11949 ,
11950#endif
11951 {
11952 WLAN_SET_BAND_CONFIG,
11953 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11954 0,
11955 "SETBAND"
11956 }
11957 ,
11958 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080011959 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080011960 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011961 0,
11962 "setMCBCFilter"
11963 }
11964 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011965
11966 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011967 WLAN_GET_LINK_SPEED,
11968 IW_PRIV_TYPE_CHAR | 18,
11969 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11970 }
11971 ,
11972
11973 /* handlers for main ioctl */
11974 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
11975 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11976 0,
11977 ""}
11978 ,
11979 {WE_SET_SMPS_PARAM,
11980 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11981 0, "set_smps_param"}
11982 ,
11983 {WLAN_SET_DOT11P_CHANNEL_SCHED,
11984 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
11985 0, "set_dot11p" }
11986 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070011987#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011988 {WE_SET_FW_CRASH_INJECT,
11989 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11990 0, "crash_inject"}
11991 ,
Rachit Kankaneb1035622018-01-24 18:41:35 +053011992#if defined(WMI_INTERFACE_EVENT_LOGGING) || defined(FEATURE_HTC_CREDIT_HISTORY)
Dustin Brown8d2d0f52017-04-03 17:02:08 -070011993 {WE_LOG_BUFFER,
11994 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11995 0, "log_buffer"}
11996 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011997#endif
Rachit Kankaneb1035622018-01-24 18:41:35 +053011998#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070011999#ifdef WLAN_SUSPEND_RESUME_TEST
12000 {WE_SET_WLAN_SUSPEND,
12001 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12002 0, "wlan_suspend"}
12003 ,
12004 {WE_SET_WLAN_RESUME,
12005 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12006 0, "wlan_resume"}
12007 ,
12008#endif
Govind Singha471e5e2015-10-12 17:11:14 +053012009 {WE_ENABLE_FW_PROFILE,
12010 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12011 0, "enableProfile"}
12012 ,
12013 {WE_SET_FW_PROFILE_HIST_INTVL,
12014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12015 0, "set_hist_intvl"}
12016 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012017 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
12018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12019 0, "set_fw_mode_cfg"}
12020 ,
12021 {WE_DUMP_DP_TRACE_LEVEL,
12022 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12023 0, "dump_dp_trace"}
12024 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012025 {WE_SET_MON_MODE_CHAN,
12026 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12027 0, "setMonChan"}
12028 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070012029
12030 {WE_GET_ROAM_SYNCH_DELAY,
12031 0,
12032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12033 "hostroamdelay"}
12034 ,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -080012035 {WE_SET_11AX_RATE,
12036 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12037 0,
12038 "set_11ax_rate"}
12039 ,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070012040 {WE_SET_DCM,
12041 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12042 0,
12043 "enable_dcm"}
12044 ,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070012045 {WE_SET_RANGE_EXT,
12046 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12047 0,
Naveen Rawat53448ea2017-11-27 11:43:18 -080012048 "range_ext"}
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070012049 ,
Naveen Rawatc921c7b2017-06-13 17:29:51 -070012050
12051 {WLAN_PRIV_SET_FTIES,
12052 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
12053 0,
12054 "set_ft_ies"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012055};
12056
12057const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053012058 .num_standard = QDF_ARRAY_SIZE(we_handler),
12059 .num_private = QDF_ARRAY_SIZE(we_private),
12060 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012061
12062 .standard = (iw_handler *) we_handler,
12063 .private = (iw_handler *) we_private,
12064 .private_args = we_private_args,
12065 .get_wireless_stats = NULL,
12066};
12067
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012068/* hdd_set_wext() - configures bss parameters
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012069 * @adapter: handle to adapter context
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012070 *
12071 * Returns: none
12072 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012073static int hdd_set_wext(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012074{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012075 struct hdd_wext_state *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -070012076 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012077
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012078 ENTER();
12079
12080 if (!pwextBuf) {
12081 hdd_err("ERROR: pwextBuf is NULL");
12082 return QDF_STATUS_E_FAILURE;
12083 }
12084
Jeff Johnsond377dce2017-10-04 10:32:42 -070012085 if (!sta_ctx) {
12086 hdd_err("ERROR: sta_ctx is NULL");
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012087 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070012088 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012089
12090 /* Now configure the roaming profile links. To SSID and bssid. */
12091 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -070012092 pwextBuf->roamProfile.SSIDs.SSIDList = &sta_ctx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012093
12094 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -070012095 pwextBuf->roamProfile.BSSIDs.bssid = &sta_ctx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012096
12097 /*Set the numOfChannels to zero to scan all the channels */
12098 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
12099 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
12100
12101 /* Default is no encryption */
12102 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
12103 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
12104 eCSR_ENCRYPT_TYPE_NONE;
12105
12106 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
12107 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
12108 eCSR_ENCRYPT_TYPE_NONE;
12109
12110 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
12111
12112 /* Default is no authentication */
12113 pwextBuf->roamProfile.AuthType.numEntries = 1;
12114 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
12115
12116 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnsonce4a8342017-10-14 13:12:22 -070012117 sta_ctx->wpa_versions = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012118
12119 /*Set the default scan mode */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012120 adapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012121
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012122 hdd_clear_roam_profile_ie(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012123
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012124 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012125 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012126
12127}
12128
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012129#ifdef WLAN_FEATURE_FILS_SK
Jeff Johnson2a722002017-09-30 20:02:35 -070012130static void hdd_initialize_fils_info(struct hdd_wext_state *pwextBuf)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012131{
12132 pwextBuf->roamProfile.fils_con_info = NULL;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053012133 pwextBuf->roamProfile.hlp_ie = NULL;
12134 pwextBuf->roamProfile.hlp_ie_len = 0;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012135}
12136#else
Jeff Johnson2a722002017-09-30 20:02:35 -070012137static void hdd_initialize_fils_info(struct hdd_wext_state *pwextBuf)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012138{ }
12139#endif
12140
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070012141/**
12142 * hdd_register_wext() - register wext context
12143 * @dev: net device handle
12144 *
12145 * Registers wext interface context for a given net device
12146 *
12147 * Returns: 0 on success, errno on failure
12148 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012149int hdd_register_wext(struct net_device *dev)
12150{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012151 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12152 struct hdd_wext_state *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053012153 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012154
12155 ENTER();
12156
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012157 if (!pwextBuf) {
Dustin Brownbacc48f2018-03-14 14:48:44 -070012158 hdd_err("ERROR: pwextBuf is NULL");
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012159 return QDF_STATUS_E_FAILURE;
12160 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070012161
12162 /* Zero the memory. This zeros the profile structure */
Jeff Johnson2a722002017-09-30 20:02:35 -070012163 memset(pwextBuf, 0, sizeof(struct hdd_wext_state));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012164
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012165 status = hdd_set_wext(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012166
Anurag Chouhance0dc992016-02-16 18:18:03 +053012167 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012168 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012169 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012170 }
12171
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012172 hdd_initialize_fils_info(pwextBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012173 /* Register as a wireless device */
12174 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
12175
12176 EXIT();
12177 return 0;
12178}
12179
12180int hdd_unregister_wext(struct net_device *dev)
12181{
Jeff Johnson36e74c42017-09-18 08:15:42 -070012182 hdd_debug("dev(%pK)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012183
12184 if (dev != NULL) {
12185 rtnl_lock();
12186 dev->wireless_handlers = NULL;
12187 rtnl_unlock();
12188 }
12189
12190 return 0;
12191}