blob: a488cbea2fa4d345594cb7e42cf0078271c5f629 [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/**
4081 * hdd_statistics_cb() - "Get statistics" callback function
4082 * @pStats: statistics payload
4083 * @pContext: opaque context originally passed to SME. HDD always passes
4084 * a pointer to an adapter
4085 *
4086 * Return: None
4087 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004088static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004090 struct hdd_adapter *adapter = (struct hdd_adapter *) pContext;
Jeff Johnson07f94742017-08-14 15:55:40 -07004091 struct hdd_stats *pStatsCache = NULL;
Jeff Johnson2a722002017-09-30 20:02:35 -07004092 struct hdd_wext_state *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05304093 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094
4095 tCsrSummaryStatsInfo *pSummaryStats = NULL;
4096 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004099 if (adapter != NULL)
4100 pStatsCache = &adapter->hdd_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101
4102 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
4103 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Jeff Johnsonf2dac4f2017-03-16 11:41:31 -07004104 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105
4106 if (pStatsCache != NULL) {
4107 /* copy the stats into the cache we keep in the
4108 * adapter instance structure
4109 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304110 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 sizeof(pStatsCache->summary_stat));
Jeff Johnson861dd4f2017-10-24 10:10:40 -07004112 qdf_mem_copy(&pStatsCache->class_a_stat, pClassAStats,
4113 sizeof(pStatsCache->class_a_stat));
Jeff Johnsonf8cadec2017-10-24 10:21:25 -07004114 qdf_mem_copy(&pStatsCache->class_d_stat, pClassDStats,
4115 sizeof(pStatsCache->class_d_stat));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 }
4117
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004118 if (adapter) {
4119 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304120 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05304121 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004122 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123 return;
4124 }
4125 }
4126}
4127
4128/**
4129 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004130 * @adapter: adapter who's IEs are to be cleared
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 *
4132 * Return: None
4133 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004134void hdd_clear_roam_profile_ie(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135{
Jeff Johnson731bc322017-10-14 19:53:44 -07004136 struct hdd_station_ctx *sta_ctx;
Jeff Johnson2a722002017-09-30 20:02:35 -07004137 struct hdd_wext_state *pWextState =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004138 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004139
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004140 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004141
4142 /* clear WPA/RSN/WSC IE information in the profile */
4143 pWextState->roamProfile.nWPAReqIELength = 0;
4144 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
4145 pWextState->roamProfile.nRSNReqIELength = 0;
4146 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
4147
4148#ifdef FEATURE_WLAN_WAPI
4149 pWextState->roamProfile.nWAPIReqIELength = 0;
4150 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
4151#endif
4152
4153 pWextState->roamProfile.bWPSAssociation = false;
4154 pWextState->roamProfile.bOSENAssociation = false;
4155 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
4156 pWextState->roamProfile.nAddIEScanLength = 0;
4157 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
4158 pWextState->roamProfile.nAddIEAssocLength = 0;
4159
4160 pWextState->roamProfile.EncryptionType.numEntries = 1;
4161 pWextState->roamProfile.EncryptionType.encryptionType[0]
4162 = eCSR_ENCRYPT_TYPE_NONE;
4163
4164 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4165 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
4166 = eCSR_ENCRYPT_TYPE_NONE;
4167
4168 pWextState->roamProfile.AuthType.numEntries = 1;
4169 pWextState->roamProfile.AuthType.authType[0] =
4170 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4171
Abhishek Singh3c9910e2017-01-06 17:56:47 +05304172 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
4173 QDF_MAC_ADDR_SIZE);
4174
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175#ifdef WLAN_FEATURE_11W
4176 pWextState->roamProfile.MFPEnabled = false;
4177 pWextState->roamProfile.MFPRequired = 0;
4178 pWextState->roamProfile.MFPCapable = 0;
4179#endif
4180
4181 pWextState->authKeyMgmt = 0;
4182
Yingying Tang3cc6b792016-10-20 17:00:37 +08004183 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
4184
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185#ifdef FEATURE_WLAN_WAPI
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07004186 adapter->wapi_info.wapi_auth_mode = WAPI_AUTH_MODE_OPEN;
4187 adapter->wapi_info.wapi_mode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004188#endif
4189
Jeff Johnson731bc322017-10-14 19:53:44 -07004190 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
4191 qdf_zero_macaddr(&sta_ctx->requested_bssid);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004192 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193}
4194
4195/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304196 * hdd_get_ldpc() - Get adapter LDPC
4197 * @adapter: adapter being queried
4198 * @value: where to store the value
4199 *
4200 * Return: 0 on success, negative errno on failure
4201 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004202int hdd_get_ldpc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304203{
4204 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4205 int ret;
4206
4207 ENTER();
Jeff Johnson1b780e42017-10-31 14:11:45 -07004208 ret = sme_get_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304209 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
4210 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004211 hdd_err("Failed to get LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304212 } else {
4213 *value = ret;
4214 ret = 0;
4215 }
4216 return ret;
4217}
4218
4219/**
4220 * hdd_set_ldpc() - Set adapter LDPC
4221 * @adapter: adapter being modified
4222 * @value: new LDPC value
4223 *
4224 * Return: 0 on success, negative errno on failure
4225 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004226int hdd_set_ldpc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304227{
4228 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4229 int ret;
4230
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004231 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304232 if (value) {
4233 /* make sure HT capabilities allow this */
4234 QDF_STATUS status;
4235 uint32_t cfg_value;
4236 union {
4237 uint16_t cfg_value16;
4238 tSirMacHTCapabilityInfo ht_cap_info;
4239 } u;
4240
4241 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4242 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004243 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304244 return -EIO;
4245 }
4246 u.cfg_value16 = cfg_value & 0xFFFF;
4247 if (!u.ht_cap_info.advCodingCap) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004248 hdd_err("LDCP not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304249 return -EINVAL;
4250 }
4251 }
4252
Jeff Johnson1b780e42017-10-31 14:11:45 -07004253 ret = sme_update_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304254 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
4255 value);
4256 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004257 hdd_err("Failed to set LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304258
4259 return ret;
4260}
4261
4262/**
4263 * hdd_get_tx_stbc() - Get adapter TX STBC
4264 * @adapter: adapter being queried
4265 * @value: where to store the value
4266 *
4267 * Return: 0 on success, negative errno on failure
4268 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004269int hdd_get_tx_stbc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304270{
4271 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4272 int ret;
4273
4274 ENTER();
Jeff Johnson1b780e42017-10-31 14:11:45 -07004275 ret = sme_get_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304276 WNI_CFG_HT_CAP_INFO_TX_STBC);
4277 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004278 hdd_err("Failed to get TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304279 } else {
4280 *value = ret;
4281 ret = 0;
4282 }
4283
4284 return ret;
4285}
4286
4287/**
4288 * hdd_set_tx_stbc() - Set adapter TX STBC
4289 * @adapter: adapter being modified
4290 * @value: new TX STBC value
4291 *
4292 * Return: 0 on success, negative errno on failure
4293 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004294int hdd_set_tx_stbc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304295{
4296 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4297 int ret;
4298
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004299 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304300 if (value) {
4301 /* make sure HT capabilities allow this */
4302 QDF_STATUS status;
4303 uint32_t cfg_value;
4304 union {
4305 uint16_t cfg_value16;
4306 tSirMacHTCapabilityInfo ht_cap_info;
4307 } u;
4308
4309 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4310 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004311 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304312 return -EIO;
4313 }
4314 u.cfg_value16 = cfg_value & 0xFFFF;
4315 if (!u.ht_cap_info.txSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004316 hdd_err("TX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304317 return -EINVAL;
4318 }
4319 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07004320 ret = sme_update_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304321 WNI_CFG_HT_CAP_INFO_TX_STBC,
4322 value);
4323 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004324 hdd_err("Failed to set TX STBC value");
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08004325 ret = sme_update_he_tx_stbc_cap(hal, adapter->session_id, value);
4326 if (ret)
4327 hdd_err("Failed to set HE TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304328
4329 return ret;
4330}
4331
4332/**
4333 * hdd_get_rx_stbc() - Get adapter RX STBC
4334 * @adapter: adapter being queried
4335 * @value: where to store the value
4336 *
4337 * Return: 0 on success, negative errno on failure
4338 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004339int hdd_get_rx_stbc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304340{
4341 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4342 int ret;
4343
4344 ENTER();
Jeff Johnson1b780e42017-10-31 14:11:45 -07004345 ret = sme_get_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304346 WNI_CFG_HT_CAP_INFO_RX_STBC);
4347 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004348 hdd_err("Failed to get RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304349 } else {
4350 *value = ret;
4351 ret = 0;
4352 }
4353
4354 return ret;
4355}
4356
4357/**
4358 * hdd_set_rx_stbc() - Set adapter RX STBC
4359 * @adapter: adapter being modified
4360 * @value: new RX STBC value
4361 *
4362 * Return: 0 on success, negative errno on failure
4363 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004364int hdd_set_rx_stbc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304365{
4366 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4367 int ret;
4368
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004369 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304370 if (value) {
4371 /* make sure HT capabilities allow this */
4372 QDF_STATUS status;
4373 uint32_t cfg_value;
4374 union {
4375 uint16_t cfg_value16;
4376 tSirMacHTCapabilityInfo ht_cap_info;
4377 } u;
4378
4379 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4380 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004381 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304382 return -EIO;
4383 }
4384 u.cfg_value16 = cfg_value & 0xFFFF;
4385 if (!u.ht_cap_info.rxSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004386 hdd_warn("RX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304387 return -EINVAL;
4388 }
4389 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07004390 ret = sme_update_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304391 WNI_CFG_HT_CAP_INFO_RX_STBC,
4392 value);
4393 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004394 hdd_err("Failed to set RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304395
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08004396 ret = sme_update_he_rx_stbc_cap(hal, adapter->session_id, value);
4397 if (ret)
4398 hdd_err("Failed to set HE RX STBC value");
4399
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304400 return ret;
4401}
4402
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004403int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate)
4404{
4405 int set_value;
4406
4407 if (sme_is_feature_supported_by_fw(DOT11AX))
4408 set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble);
4409 else
4410 set_value = (preamble << 6) | (nss << 4) | rate;
4411
4412 return set_value;
4413}
4414
Jeff Johnson3d278b02017-08-29 14:17:47 -07004415int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004416 struct sap_Config *sap_config)
4417{
4418 uint8_t preamble = 0, nss = 0, rix = 0;
4419 int ret;
4420
4421 if (!sap_config) {
4422 if (!sme_is_feature_supported_by_fw(DOT11AX)) {
4423 hdd_err("Target does not support 11ax");
4424 return -EIO;
4425 }
4426 } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax &&
4427 sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07004428 hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d",
4429 sap_config->SapHw_mode, sap_config->channel);
4430 return -EIO;
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004431 }
4432
4433 if (set_value != 0xff) {
4434 rix = RC_2_RATE_IDX_11AX(set_value);
4435 preamble = WMI_RATE_PREAMBLE_HE;
4436 nss = HT_RC_2_STREAMS_11AX(set_value);
4437
4438 set_value = hdd_assemble_rate_code(preamble, nss, rix);
4439 }
4440
4441 hdd_notice("SET_11AX_RATE val %d rix %d preamble %x nss %d",
4442 set_value, rix, preamble, nss);
4443
Jeff Johnson1b780e42017-10-31 14:11:45 -07004444 ret = wma_cli_set_command(adapter->session_id,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004445 WMI_VDEV_PARAM_FIXED_RATE,
4446 set_value, VDEV_CMD);
4447
4448 return ret;
4449}
4450
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304451/**
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004452 * hdd_get_aid_rc() - Get AID and rate code passed from user
4453 * @aid: pointer to AID
4454 * @rc: pointer to rate code
4455 * @set_value: value passed from user
4456 *
4457 * If target is 11ax capable, set_value will have AID left shifted 16 bits
4458 * and 16 bits for rate code. If the target is not 11ax capable, rate code
4459 * will only be 8 bits.
4460 *
4461 * Return: None
4462 */
4463static void hdd_get_aid_rc(uint8_t *aid, uint16_t *rc, int set_value)
4464{
4465 uint8_t rc_bits;
4466
4467 if (sme_is_feature_supported_by_fw(DOT11AX))
4468 rc_bits = 16;
4469 else
4470 rc_bits = 8;
4471
4472 *aid = set_value >> rc_bits;
4473 *rc = set_value & ((1 << (rc_bits + 1)) - 1);
4474}
4475
Jeff Johnson3d278b02017-08-29 14:17:47 -07004476int hdd_set_peer_rate(struct hdd_adapter *adapter, int set_value)
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004477{
4478 uint8_t aid, *peer_mac;
4479 uint16_t rc;
4480 QDF_STATUS status;
4481
4482 if (adapter->device_mode != QDF_SAP_MODE) {
4483 hdd_err("Invalid devicde mode - %d", adapter->device_mode);
4484 return -EINVAL;
4485 }
4486
4487 hdd_get_aid_rc(&aid, &rc, set_value);
4488
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07004489 if ((adapter->sta_info[aid].in_use) &&
4490 (OL_TXRX_PEER_STATE_CONN == adapter->sta_info[aid].peer_state)) {
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004491 peer_mac =
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07004492 (uint8_t *)&(adapter->sta_info[aid].sta_mac.bytes[0]);
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004493 hdd_info("Peer AID: %d MAC_ADDR: "MAC_ADDRESS_STR,
4494 aid, MAC_ADDR_ARRAY(peer_mac));
4495 } else {
4496 hdd_err("No matching peer found for AID: %d", aid);
4497 return -EINVAL;
4498 }
4499
4500 status = sme_set_peer_param(peer_mac, WMI_PEER_PARAM_FIXED_RATE,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004501 rc, adapter->session_id);
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004502 if (status != QDF_STATUS_SUCCESS) {
4503 hdd_err("Failed to set peer fixed rate - status: %d", status);
4504 return -EIO;
4505 }
4506
4507 return 0;
4508}
4509
4510/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
4512 * @dev: device upon which the ioctl was received
4513 * @info: ioctl request information
4514 * @wrqu: ioctl request data
4515 * @extra: ioctl extra data
4516 *
4517 * Return: 0 on success, non-zero on error
4518 */
4519static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
4520 union iwreq_data *wrqu, char *extra)
4521{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004522 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004523 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524 int ret;
4525
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004526 ENTER_DEV(dev);
4527
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004528 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4529 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4530 ret = wlan_hdd_validate_context(hdd_ctx);
4531 if (0 != ret)
4532 return ret;
4533
Jeff Johnson441e1f72017-02-07 08:50:49 -08004534 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4535 if (0 != ret)
4536 return ret;
4537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538 /* Do nothing for now */
4539 return 0;
4540}
4541
4542/**
4543 * iw_set_commit() - SSR wrapper function for __iw_set_commit
4544 * @dev: pointer to net_device
4545 * @info: pointer to iw_request_info
4546 * @wrqu: pointer to iwreq_data
4547 * @extra: extra
4548 *
4549 * Return: 0 on success, error number otherwise
4550 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004551static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004552 union iwreq_data *wrqu, char *extra)
4553{
4554 int ret;
4555
4556 cds_ssr_protect(__func__);
4557 ret = __iw_set_commit(dev, info, wrqu, extra);
4558 cds_ssr_unprotect(__func__);
4559
4560 return ret;
4561}
4562
4563/**
4564 * __iw_get_name() - SIOCGIWNAME ioctl handler
4565 * @dev: device upon which the ioctl was received
4566 * @info: ioctl request information
4567 * @wrqu: ioctl request data
4568 * @extra: ioctl extra data
4569 *
4570 * Return: 0 on success, non-zero on error
4571 */
4572static int __iw_get_name(struct net_device *dev,
4573 struct iw_request_info *info, char *wrqu, char *extra)
4574{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004575 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004576 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 int ret;
4578
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004579 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580
4581 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4582 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4583 ret = wlan_hdd_validate_context(hdd_ctx);
4584 if (0 != ret)
4585 return ret;
4586
Jeff Johnson441e1f72017-02-07 08:50:49 -08004587 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4588 if (0 != ret)
4589 return ret;
4590
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
4592 EXIT();
4593 return 0;
4594}
4595
4596/**
4597 * __iw_get_name() - SSR wrapper for __iw_get_name
4598 * @dev: pointer to net_device
4599 * @info: pointer to iw_request_info
4600 * @wrqu: pointer to iwreq_data
4601 * @extra: extra
4602 *
4603 * Return: 0 on success, error number otherwise
4604 */
4605static int iw_get_name(struct net_device *dev,
4606 struct iw_request_info *info,
4607 char *wrqu, char *extra)
4608{
4609 int ret;
4610
4611 cds_ssr_protect(__func__);
4612 ret = __iw_get_name(dev, info, wrqu, extra);
4613 cds_ssr_unprotect(__func__);
4614
4615 return ret;
4616}
4617
4618/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 * __iw_get_range() - SIOCGIWRANGE ioctl handler
4620 * @dev: device upon which the ioctl was received
4621 * @info: ioctl request information
4622 * @wrqu: ioctl request data
4623 * @extra: ioctl extra data
4624 *
4625 * Return: 0 on success, non-zero on error
4626 */
4627static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
4628 union iwreq_data *wrqu, char *extra)
4629{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004630 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4631 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 struct iw_range *range = (struct iw_range *)extra;
4633
4634 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4635
4636 uint32_t num_channels = sizeof(channels);
4637 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4638 uint32_t a_len;
4639 uint32_t b_len;
4640 uint32_t active_phy_mode = 0;
4641 uint8_t index = 0, i;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004642 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 int ret;
4644
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004645 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004647 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 ret = wlan_hdd_validate_context(hdd_ctx);
4649 if (0 != ret)
4650 return ret;
4651
Jeff Johnson441e1f72017-02-07 08:50:49 -08004652 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4653 if (0 != ret)
4654 return ret;
4655
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 wrqu->data.length = sizeof(struct iw_range);
4657 memset(range, 0, sizeof(struct iw_range));
4658
4659
4660 /*Get the phy mode */
4661 if (sme_cfg_get_int(hHal,
4662 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304663 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004664 hdd_debug("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665
4666 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
4667 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
4668 /*Get the supported rates for 11G band */
4669 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4670 if (sme_cfg_get_str(hHal,
4671 WNI_CFG_SUPPORTED_RATES_11A,
4672 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304673 &a_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004674 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004676
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 for (i = 0; i < a_len; i++) {
4678 range->bitrate[i] =
4679 ((supp_rates[i] & 0x7F) / 2) *
4680 1000000;
4681 }
4682 range->num_bitrates = a_len;
4683 } else {
4684 return -EIO;
4685 }
4686 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
4687 /*Get the supported rates for 11B band */
4688 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4689 if (sme_cfg_get_str(hHal,
4690 WNI_CFG_SUPPORTED_RATES_11B,
4691 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304692 &b_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004693 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 for (i = 0; i < b_len; i++) {
4697 range->bitrate[i] =
4698 ((supp_rates[i] & 0x7F) / 2) *
4699 1000000;
4700 }
4701 range->num_bitrates = b_len;
4702 } else {
4703 return -EIO;
4704 }
4705 }
4706 }
4707
4708 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
4709 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
4710 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
4711
4712 range->encoding_size[0] = 5;
4713 range->encoding_size[1] = 13;
4714 range->num_encoding_sizes = 2;
4715 range->max_encoding_tokens = MAX_WEP_KEYS;
4716
4717 /* we support through Wireless Extensions 22 */
4718 range->we_version_compiled = WIRELESS_EXT;
4719 range->we_version_source = 22;
4720
4721 /*Supported Channels and Frequencies */
4722 if (sme_cfg_get_str
4723 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304724 &num_channels) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004725 hdd_err("Failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726 return -EIO;
4727 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004728 if (num_channels > IW_MAX_FREQUENCIES)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 num_channels = IW_MAX_FREQUENCIES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004730
4731 range->num_channels = num_channels;
4732 range->num_frequency = num_channels;
4733
4734 for (index = 0; index < num_channels; index++) {
4735 uint32_t frq_indx = 0;
4736
4737 range->freq[index].i = channels[index];
4738 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
4739 if (channels[index] == freq_chan_map[frq_indx].chan) {
4740 range->freq[index].m =
4741 freq_chan_map[frq_indx].freq * 100000;
4742 range->freq[index].e = 1;
4743 break;
4744 }
4745 frq_indx++;
4746 }
4747 }
4748
4749 /* Event capability (kernel + driver) */
4750 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
4751 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
4752 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
4753 range->event_capa[1] = IW_EVENT_CAPA_K_1;
4754
4755 /*Encryption capability */
4756 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
4757 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
4758
4759 /* Txpower capability */
4760 range->txpower_capa = IW_TXPOW_MWATT;
4761
4762 /*Scanning capability */
4763#if WIRELESS_EXT >= 22
4764 range->scan_capa =
4765 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
4766#endif
4767
4768 EXIT();
4769 return 0;
4770}
4771
4772/**
4773 * iw_get_range() - SSR wrapper for __iw_get_range()
4774 * @dev: pointer to net_device
4775 * @info: pointer to iw_request_info
4776 * @wrqu: pointer to iwreq_data
4777 * @extra: pointer to extra ioctl payload
4778 *
4779 * Return: 0 on success, error number otherwise
4780 */
4781static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
4782 union iwreq_data *wrqu, char *extra)
4783{
4784 int ret;
4785
4786 cds_ssr_protect(__func__);
4787 ret = __iw_get_range(dev, info, wrqu, extra);
4788 cds_ssr_unprotect(__func__);
4789
4790 return ret;
4791}
4792
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004793struct class_a_stats {
4794 tCsrGlobalClassAStatsInfo class_a_stats;
4795};
4796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004797/**
4798 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004799 * @stats: pointer to Class A stats
4800 * @context: user context originally registered with SME (always the
4801 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802 *
4803 * Return: None
4804 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004805static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004806{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004807 struct hdd_request *request;
4808 struct class_a_stats *priv;
4809 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004811 ENTER();
4812 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07004813 hdd_err("Bad param, stats [%pK] context [%pK]",
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004814 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815 return;
4816 }
4817
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004818 request = hdd_request_get(context);
4819 if (!request) {
4820 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004821 return;
4822 }
4823
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004824 returned_stats = stats;
4825 priv = hdd_request_priv(request);
4826 priv->class_a_stats = *returned_stats;
4827 hdd_request_complete(request);
4828 hdd_request_put(request);
4829 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830}
4831
4832/**
4833 * wlan_hdd_get_class_astats() - Get Class A statistics
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004834 * @adapter: adapter for which statistics are desired
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304836 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004838QDF_STATUS wlan_hdd_get_class_astats(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839{
Jeff Johnsond377dce2017-10-04 10:32:42 -07004840 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304841 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004842 int ret;
4843 void *cookie;
4844 struct hdd_request *request;
4845 struct class_a_stats *priv;
4846 static const struct hdd_request_params params = {
4847 .priv_size = sizeof(*priv),
4848 .timeout_ms = WLAN_WAIT_TIME_STATS,
4849 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004850
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004851 if (NULL == adapter) {
4852 hdd_err("adapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304853 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004854 }
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +05304855 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004856 hdd_debug("Recovery in Progress. State: 0x%x Ignore!!!",
Prashanth Bhatta9e143052015-12-04 11:56:47 -08004857 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304858 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859 }
4860
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004861 request = hdd_request_alloc(&params);
4862 if (!request) {
4863 hdd_err("Request allocation failure");
4864 return QDF_STATUS_E_NOMEM;
4865 }
4866 cookie = hdd_request_cookie(request);
4867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004868 /* query only for Class A statistics (which include link speed) */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004869 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
4871 hdd_get_class_a_statistics_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07004872 sta_ctx->conn_info.staId[0],
Jeff Johnson1b780e42017-10-31 14:11:45 -07004873 cookie, adapter->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304874 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07004875 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004876 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004877 }
4878
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004879 /* request was sent -- wait for the response */
4880 ret = hdd_request_wait_for_response(request);
4881 if (ret) {
4882 hdd_warn("SME timed out while retrieving Class A statistics");
4883 goto return_cached_results;
4884 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004886 /* update the adapter with the fresh results */
4887 priv = hdd_request_priv(request);
Jeff Johnson861dd4f2017-10-24 10:10:40 -07004888 adapter->hdd_stats.class_a_stat = priv->class_a_stats;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004889
4890return_cached_results:
4891 /*
4892 * either we never sent a request, we sent a request and
4893 * received a response or we sent a request and timed out.
4894 * regardless we are done with the request.
4895 */
4896 hdd_request_put(request);
4897
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304898 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004899}
4900
Jeff Johnsondda167c2017-01-23 10:37:57 -08004901struct station_stats {
4902 tCsrSummaryStatsInfo summary_stats;
4903 tCsrGlobalClassAStatsInfo class_a_stats;
4904 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
4905};
4906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907/**
4908 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08004909 * @stats: pointer to combined station stats
4910 * @context: user context originally registered with SME (always the
4911 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912 *
4913 * Return: None
4914 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004915static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004916{
Jeff Johnsondda167c2017-01-23 10:37:57 -08004917 struct hdd_request *request;
4918 struct station_stats *priv;
4919 tCsrSummaryStatsInfo *summary_stats;
4920 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304921 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922
Jeff Johnsondda167c2017-01-23 10:37:57 -08004923 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07004924 hdd_err("Bad param, pStats [%pK] pContext [%pK]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08004925 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 return;
4927 }
4928
Jeff Johnsondda167c2017-01-23 10:37:57 -08004929 request = hdd_request_get(context);
4930 if (!request) {
4931 hdd_err("Obsolete request");
4932 return;
4933 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004934
Jeff Johnsondda167c2017-01-23 10:37:57 -08004935 summary_stats = (tCsrSummaryStatsInfo *) stats;
4936 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304937 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08004938 (class_a_stats + 1);
4939 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004940
4941 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004942 priv->summary_stats = *summary_stats;
4943 priv->class_a_stats = *class_a_stats;
4944 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004945
Jeff Johnsondda167c2017-01-23 10:37:57 -08004946 hdd_request_complete(request);
4947 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948}
4949
4950/**
4951 * wlan_hdd_get_station_stats() - Get station statistics
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004952 * @adapter: adapter for which statistics are desired
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304954 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004956QDF_STATUS wlan_hdd_get_station_stats(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957{
Jeff Johnsond377dce2017-10-04 10:32:42 -07004958 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dustin Brown0f5260d2017-06-12 16:17:38 -07004959 QDF_STATUS status;
4960 int errno;
Jeff Johnsondda167c2017-01-23 10:37:57 -08004961 void *cookie;
4962 struct hdd_request *request;
4963 struct station_stats *priv;
4964 static const struct hdd_request_params params = {
4965 .priv_size = sizeof(*priv),
4966 .timeout_ms = WLAN_WAIT_TIME_STATS,
4967 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004968
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004969 if (NULL == adapter) {
4970 hdd_err("adapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304971 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004972 }
4973
Jeff Johnsondda167c2017-01-23 10:37:57 -08004974 request = hdd_request_alloc(&params);
4975 if (!request) {
4976 hdd_err("Request allocation failure");
4977 return QDF_STATUS_E_NOMEM;
4978 }
4979 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980
4981 /* query only for Summary & Class A statistics */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004982 status = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(adapter),
Dustin Brown0f5260d2017-06-12 16:17:38 -07004983 eCSR_HDD,
4984 SME_SUMMARY_STATS |
4985 SME_GLOBAL_CLASSA_STATS |
4986 SME_PER_CHAIN_RSSI_STATS,
4987 hdd_get_station_statistics_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07004988 sta_ctx->conn_info.staId[0],
Dustin Brown0f5260d2017-06-12 16:17:38 -07004989 cookie,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004990 adapter->session_id);
Dustin Brown0f5260d2017-06-12 16:17:38 -07004991 if (QDF_IS_STATUS_ERROR(status)) {
4992 hdd_err("Failed to retrieve statistics, status %d", status);
4993 goto put_request;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994 }
4995
Dustin Brown0f5260d2017-06-12 16:17:38 -07004996 /* request was sent -- wait for the response */
4997 errno = hdd_request_wait_for_response(request);
4998 if (errno) {
4999 hdd_err("Failed to wait for statistics, errno %d", errno);
5000 goto put_request;
5001 }
5002
5003 /* update the adapter with the fresh results */
5004 priv = hdd_request_priv(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005005 adapter->hdd_stats.summary_stat = priv->summary_stats;
Jeff Johnson861dd4f2017-10-24 10:10:40 -07005006 adapter->hdd_stats.class_a_stat = priv->class_a_stats;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005007 adapter->hdd_stats.per_chain_rssi_stats = priv->per_chain_rssi_stats;
Dustin Brown0f5260d2017-06-12 16:17:38 -07005008
5009put_request:
Jeff Johnsondda167c2017-01-23 10:37:57 -08005010 /*
5011 * either we never sent a request, we sent a request and
5012 * received a response or we sent a request and timed out.
5013 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08005015 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005016
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005017 /* either callback updated adapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305018 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019}
5020
5021/**
5022 * iw_get_linkspeed() - Get current link speed ioctl
5023 * @dev: device upon which the ioctl was received
5024 * @info: ioctl request information
5025 * @wrqu: ioctl request data
5026 * @extra: extra ioctl buffer
5027 *
5028 * Return: 0 on success, non-zero on error
5029 */
5030static int __iw_get_linkspeed(struct net_device *dev,
5031 struct iw_request_info *info,
5032 union iwreq_data *wrqu, char *extra)
5033{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005034 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035 char *pLinkSpeed = (char *)extra;
5036 int len = sizeof(uint32_t) + 1;
5037 uint32_t link_speed = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005038 struct hdd_context *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08005039 int ret;
5040 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005041
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005042 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305043
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005044 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08005045 ret = wlan_hdd_validate_context(hdd_ctx);
5046 if (0 != ret)
5047 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048
Jeff Johnson441e1f72017-02-07 08:50:49 -08005049 ret = hdd_check_private_wext_control(hdd_ctx, info);
5050 if (0 != ret)
5051 return ret;
5052
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005053 ret = wlan_hdd_get_link_speed(adapter, &link_speed);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005054 if (0 != ret)
Jeff Johnson441e1f72017-02-07 08:50:49 -08005055 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005056
5057 wrqu->data.length = len;
5058 /* return the linkspeed as a string */
5059 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
5060 if ((rc < 0) || (rc >= len)) {
5061 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07005062 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005063 return -EIO;
5064 }
5065
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305066 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005067 /* a value is being successfully returned */
5068 return 0;
5069}
5070
5071static int iw_get_linkspeed(struct net_device *dev,
5072 struct iw_request_info *info,
5073 union iwreq_data *wrqu, char *extra)
5074{
5075 int ret;
5076
5077 cds_ssr_protect(__func__);
5078 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
5079 cds_ssr_unprotect(__func__);
5080
5081 return ret;
5082}
5083
5084/**
5085 * wlan_hdd_change_country_code_callback() - Change country code callback
5086 * @context: opaque context originally passed to SME. All functions
5087 * which use this callback pass the adapter upon which the country
5088 * code change is active
5089 *
5090 * This function is registered as the callback function when
5091 * sme_change_country_code() is invoked. Callers of
5092 * sme_change_country_code() subsequently wait for the adapter's
5093 * @change_country_code completion variable, so all this function
5094 * needs to do is set that completion variable so that execution can
5095 * continue.
5096 *
5097 * Return: none
5098 */
5099void wlan_hdd_change_country_code_callback(void *context)
5100{
5101
Jeff Johnson3d278b02017-08-29 14:17:47 -07005102 struct hdd_adapter *adapter = context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103
5104 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
5105 complete(&adapter->change_country_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106}
5107
5108/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 * wlan_hdd_update_phymode() - handle change in PHY mode
5110 * @net: device upon which PHY mode change was received
5111 * @hal: umac handle for the driver
5112 * @new_phymode: new PHY mode for the device
5113 * @phddctx: pointer to the HDD context
5114 *
5115 * This function is called when the device is set to a new PHY mode.
5116 * It takes a holistic look at the desired PHY mode along with the
5117 * configured capabilities of the driver and the reported capabilities
5118 * of the hardware in order to correctly configure all PHY-related
5119 * parameters.
5120 *
5121 * Return: 0 on success, negative errno value on error
5122 */
5123int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005124 int new_phymode, struct hdd_context *phddctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005125{
5126#ifdef QCA_HT_2040_COEX
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005127 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305128 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129#endif
5130 bool band_24 = false, band_5g = false;
5131 bool ch_bond24 = false, ch_bond5g = false;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305132 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005133 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005135 eCsrPhyMode phymode = -EIO, old_phymode;
Srinivas Girigowda2fb677c2017-03-25 15:35:34 -07005136 enum hdd_dot11_mode hdd_dot11mode = phddctx->config->dot11Mode;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005137 enum band_info curr_band = BAND_ALL;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305138 int retval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005139
5140 old_phymode = sme_get_phy_mode(hal);
5141
5142 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5143 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5144 nChannelBondingMode24GHz))
5145 ch_bond24 = true;
5146
5147 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5148 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5149 nChannelBondingMode5GHz))
5150 ch_bond5g = true;
5151
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005152 if (phddctx->config->nBandCapability == BAND_ALL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153 band_24 = band_5g = true;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005154 else if (phddctx->config->nBandCapability == BAND_2G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155 band_24 = true;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005156 else if (phddctx->config->nBandCapability == BAND_5G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005157 band_5g = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158
5159 vhtchanwidth = phddctx->config->vhtChannelWidth;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005160 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 -08005161 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
5162
5163 switch (new_phymode) {
5164 case IEEE80211_MODE_AUTO:
5165 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005166 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167 phymode = eCSR_DOT11_MODE_AUTO;
5168 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5169 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005170 curr_band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5172 } else {
5173 sme_set_phy_mode(hal, old_phymode);
5174 return -EIO;
5175 }
5176 break;
5177 case IEEE80211_MODE_11A:
5178 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005179 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005180 phymode = eCSR_DOT11_MODE_11a;
5181 hdd_dot11mode = eHDD_DOT11_MODE_11a;
5182 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005183 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184 } else {
5185 sme_set_phy_mode(hal, old_phymode);
5186 return -EIO;
5187 }
5188 break;
5189 case IEEE80211_MODE_11B:
5190 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005191 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192 phymode = eCSR_DOT11_MODE_11b;
5193 hdd_dot11mode = eHDD_DOT11_MODE_11b;
5194 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005195 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005196 } else {
5197 sme_set_phy_mode(hal, old_phymode);
5198 return -EIO;
5199 }
5200 break;
5201 case IEEE80211_MODE_11G:
5202 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005203 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005204 phymode = eCSR_DOT11_MODE_11g;
5205 hdd_dot11mode = eHDD_DOT11_MODE_11g;
5206 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005207 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208 } else {
5209 sme_set_phy_mode(hal, old_phymode);
5210 return -EIO;
5211 }
5212 break;
5213 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
5214 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
5215 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
5216 */
5217 case IEEE80211_MODE_11NA_HT20:
5218 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005219 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005220 phymode = eCSR_DOT11_MODE_11n;
5221 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5222 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005223 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224 } else {
5225 sme_set_phy_mode(hal, old_phymode);
5226 return -EIO;
5227 }
5228 break;
5229 case IEEE80211_MODE_11NA_HT40:
5230 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005231 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005232 phymode = eCSR_DOT11_MODE_11n;
5233 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5234 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005235 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005236 } else {
5237 sme_set_phy_mode(hal, old_phymode);
5238 return -EIO;
5239 }
5240 break;
5241 case IEEE80211_MODE_11NG_HT20:
5242 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005243 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244 phymode = eCSR_DOT11_MODE_11n;
5245 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5246 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005247 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005248 } else {
5249 sme_set_phy_mode(hal, old_phymode);
5250 return -EIO;
5251 }
5252 break;
5253 case IEEE80211_MODE_11NG_HT40:
5254 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005255 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005256 phymode = eCSR_DOT11_MODE_11n;
5257 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5258 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005259 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260 } else {
5261 sme_set_phy_mode(hal, old_phymode);
5262 return -EIO;
5263 }
5264 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005265 case IEEE80211_MODE_11AC_VHT20:
5266 case IEEE80211_MODE_11AC_VHT40:
5267 case IEEE80211_MODE_11AC_VHT80:
5268 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005269 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270 phymode = eCSR_DOT11_MODE_11ac;
5271 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
5272 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005273 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005274 } else {
5275 sme_set_phy_mode(hal, old_phymode);
5276 return -EIO;
5277 }
5278 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005279 case IEEE80211_MODE_2G_AUTO:
5280 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005281 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005282 phymode = eCSR_DOT11_MODE_AUTO;
5283 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5284 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005285 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 } else {
5287 sme_set_phy_mode(hal, old_phymode);
5288 return -EIO;
5289 }
5290 break;
5291 case IEEE80211_MODE_5G_AUTO:
5292 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005293 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 phymode = eCSR_DOT11_MODE_AUTO;
5295 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5296 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5297 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005298 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 } else {
5300 sme_set_phy_mode(hal, old_phymode);
5301 return -EIO;
5302 }
5303 break;
5304 case IEEE80211_MODE_11AGN:
5305 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005306 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 phymode = eCSR_DOT11_MODE_11n;
5308 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5309 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005310 curr_band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005311 } else {
5312 sme_set_phy_mode(hal, old_phymode);
5313 return -EIO;
5314 }
5315 break;
5316 default:
5317 return -EIO;
5318 }
5319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005320 switch (new_phymode) {
5321 case IEEE80211_MODE_11AC_VHT20:
5322 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5323 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5324 break;
5325 case IEEE80211_MODE_11AC_VHT40:
5326 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5327 break;
5328 case IEEE80211_MODE_11AC_VHT80:
5329 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5330 break;
5331 default:
5332 vhtchanwidth = phddctx->config->vhtChannelWidth;
5333 break;
5334 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005335
5336 if (phymode != -EIO) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305337 sme_config = qdf_mem_malloc(sizeof(*sme_config));
5338 if (!sme_config) {
5339 hdd_err("Failed to allocate memory for sme_config");
5340 return -ENOMEM;
5341 }
5342 qdf_mem_zero(sme_config, sizeof(*sme_config));
5343 sme_get_config_param(hal, sme_config);
5344 sme_config->csrConfig.phyMode = phymode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345#ifdef QCA_HT_2040_COEX
5346 if (phymode == eCSR_DOT11_MODE_11n &&
5347 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305348 sme_config->csrConfig.obssEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 halStatus = sme_set_ht2040_mode(hal,
Jeff Johnson1b780e42017-10-31 14:11:45 -07005350 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005351 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305352 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005353 hdd_err("Failed to disable OBSS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305354 retval = -EIO;
5355 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356 }
5357 } else if (phymode == eCSR_DOT11_MODE_11n &&
5358 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305359 sme_config->csrConfig.obssEnabled = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360 halStatus = sme_set_ht2040_mode(hal,
Jeff Johnson1b780e42017-10-31 14:11:45 -07005361 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005362 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305363 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005364 hdd_err("Failed to enable OBSS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305365 retval = -EIO;
5366 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005367 }
5368 }
5369#endif
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305370 sme_config->csrConfig.eBand = curr_band;
5371 sme_config->csrConfig.bandCapability = curr_band;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005372 if (curr_band == BAND_2G)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305373 sme_config->csrConfig.Is11hSupportEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374 else
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305375 sme_config->csrConfig.Is11hSupportEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376 phddctx->config->Is11hSupportEnabled;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005377 if (curr_band == BAND_2G)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305378 sme_config->csrConfig.channelBondingMode24GHz = chwidth;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005379 else if (curr_band == BAND_2G)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305380 sme_config->csrConfig.channelBondingMode5GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381 else {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305382 sme_config->csrConfig.channelBondingMode24GHz = chwidth;
5383 sme_config->csrConfig.channelBondingMode5GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384 }
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305385 sme_config->csrConfig.nVhtChannelWidth = vhtchanwidth;
5386 sme_update_config(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387
5388 phddctx->config->dot11Mode = hdd_dot11mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005389 phddctx->config->nChannelBondingMode24GHz =
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305390 sme_config->csrConfig.channelBondingMode24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005391 phddctx->config->nChannelBondingMode5GHz =
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305392 sme_config->csrConfig.channelBondingMode5GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005393 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005394 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005395 hdd_err("could not update config_dat");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305396 retval = -EIO;
5397 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005398 }
Rajeev Kumar Sirasanagandla4c9b6752017-07-25 20:35:20 +05305399
5400 if (band_5g) {
5401 struct ieee80211_supported_band *band;
5402
5403 band = phddctx->wiphy->bands[HDD_NL80211_BAND_5GHZ];
5404 if (phddctx->config->nChannelBondingMode5GHz)
5405 band->ht_cap.cap |=
5406 IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5407 else
5408 band->ht_cap.cap &=
5409 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5410 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005411
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005412 hdd_debug("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 phymode, chwidth, curr_band, vhtchanwidth);
5414 }
5415
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305416free:
5417 if (sme_config)
5418 qdf_mem_free(sme_config);
5419 return retval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005420}
5421
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005422struct temperature_priv {
5423 int temperature;
5424};
5425
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005426/**
5427 * hdd_get_temperature_cb() - "Get Temperature" callback function
5428 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005429 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 *
5431 * This function is passed to sme_get_temperature() as the callback
5432 * function to be invoked when the temperature measurement is
5433 * available.
5434 *
5435 * Return: None
5436 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005437static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005439 struct hdd_request *request;
5440 struct temperature_priv *priv;
5441
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005442 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005443
5444 request = hdd_request_get(context);
5445 if (!request) {
5446 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 return;
5448 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005449
5450 priv = hdd_request_priv(request);
5451 priv->temperature = temperature;
5452 hdd_request_complete(request);
5453 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005454 EXIT();
5455}
5456
5457/**
5458 * wlan_hdd_get_temperature() - get current device temperature
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005459 * @adapter: device upon which the request was made
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005460 * @temperature: pointer to where the temperature is to be returned
5461 *
5462 * Return: 0 if a temperature value (either current or cached) was
5463 * returned, otherwise a negative errno is returned.
5464 *
5465 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005466int wlan_hdd_get_temperature(struct hdd_adapter *adapter, int *temperature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005467{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305468 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005469 int ret;
5470 void *cookie;
5471 struct hdd_request *request;
5472 struct temperature_priv *priv;
5473 static const struct hdd_request_params params = {
5474 .priv_size = sizeof(*priv),
5475 .timeout_ms = WLAN_WAIT_TIME_STATS,
5476 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477
5478 ENTER();
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005479 if (NULL == adapter) {
5480 hdd_err("adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005481 return -EPERM;
5482 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005483
5484 request = hdd_request_alloc(&params);
5485 if (!request) {
5486 hdd_err("Request allocation failure");
5487 return -ENOMEM;
5488 }
5489 cookie = hdd_request_cookie(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005490 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005491 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305492 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005493 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005495 ret = hdd_request_wait_for_response(request);
5496 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005497 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005498 } else {
5499 /* update the adapter with the fresh results */
5500 priv = hdd_request_priv(request);
5501 if (priv->temperature)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005502 adapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503 }
5504 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005505
5506 /*
5507 * either we never sent a request, we sent a request and
5508 * received a response or we sent a request and timed out.
5509 * regardless we are done with the request.
5510 */
5511 hdd_request_put(request);
5512
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005513 *temperature = adapter->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514 EXIT();
5515 return 0;
5516}
5517
Jeff Johnson011c4502017-10-05 15:25:56 -07005518static int hdd_validate_pdev_reset(int value)
5519{
5520 if ((value < 1) || (value > 5)) {
5521 hdd_warn(" Invalid value %d: Use any one of the below values\n"
5522 " TX_FLUSH = 1\n"
5523 " WARM_RESET = 2\n"
5524 " COLD_RESET = 3\n"
5525 " WARM_RESET_RESTORE_CAL = 4\n"
5526 " COLD_RESET_RESTORE_CAL = 5", value);
5527
5528 return -EINVAL;
5529 }
5530
5531 return 0;
5532}
5533
5534static int hdd_handle_pdev_reset(struct hdd_adapter *adapter, int value)
5535{
5536 int ret;
5537
5538 hdd_debug("%d", value);
5539
5540 ret = hdd_validate_pdev_reset(value);
5541 if (ret)
5542 return ret;
5543
Jeff Johnson1b780e42017-10-31 14:11:45 -07005544 ret = wma_cli_set_command(adapter->session_id,
Jeff Johnson011c4502017-10-05 15:25:56 -07005545 WMI_PDEV_PARAM_PDEV_RESET,
5546 value, PDEV_CMD);
5547
5548 return ret;
5549}
5550
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551/**
5552 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5553 * @dev: device upon which the ioctl was received
5554 * @info: ioctl request information
5555 * @wrqu: ioctl request data
5556 * @extra: ioctl extra data
5557 *
5558 * Return: 0 on success, non-zero on error
5559 */
5560static int __iw_setint_getnone(struct net_device *dev,
5561 struct iw_request_info *info,
5562 union iwreq_data *wrqu, char *extra)
5563{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005564 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5565 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005566 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005567 struct hdd_context *hdd_ctx;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305568 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569 int *value = (int *)extra;
5570 int sub_cmd = value[0];
5571 int set_value = value[1];
5572 int ret;
5573 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305574 QDF_STATUS status;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08005575 void *soc = NULL;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08005576 struct cdp_pdev *pdev = NULL;
5577 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005579 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305580
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005581 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 ret = wlan_hdd_validate_context(hdd_ctx);
5583 if (0 != ret)
5584 return ret;
5585
Jeff Johnson441e1f72017-02-07 08:50:49 -08005586 ret = hdd_check_private_wext_control(hdd_ctx, info);
5587 if (0 != ret)
5588 return ret;
5589
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305590 sme_config = qdf_mem_malloc(sizeof(*sme_config));
5591 if (!sme_config) {
5592 hdd_err("failed to allocate memory for sme_config");
5593 return -ENOMEM;
5594 }
5595 qdf_mem_zero(sme_config, sizeof(*sme_config));
Jeff Johnson441e1f72017-02-07 08:50:49 -08005596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597 switch (sub_cmd) {
5598 case WE_SET_11D_STATE:
5599 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305600 if (((ENABLE_11D == set_value)
5601 || (DISABLE_11D == set_value)) && hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305603 sme_get_config_param(hHal, sme_config);
5604 sme_config->csrConfig.Is11dSupportEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605 (bool) set_value;
5606
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005607 hdd_debug("11D state=%d!!",
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305608 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005609 Is11dSupportEnabled);
5610
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305611 sme_update_config(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005612 } else {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305613 ret = -EINVAL;
5614 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 }
5616 break;
5617 }
5618
5619 case WE_WOWL:
5620 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305621 if (!hHal)
5622 return -EINVAL;
5623
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624 switch (set_value) {
5625 case 0x00:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005626 hdd_exit_wowl(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005627 break;
5628 case 0x01:
5629 case 0x02:
5630 case 0x03:
5631 enable_mp = (set_value & 0x01) ? 1 : 0;
5632 enable_pbm = (set_value & 0x02) ? 1 : 0;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005633 hdd_debug("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634 (enable_mp ? "YES" : "NO"),
5635 (enable_pbm ? "YES" : "NO"));
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005636 hdd_enter_wowl(adapter, enable_mp, enable_pbm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637 break;
5638 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005639 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005640 set_value);
5641 ret = -EINVAL;
5642 break;
5643 }
5644
5645 break;
5646 }
5647 case WE_SET_POWER:
5648 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305649 if (!hHal)
5650 return -EINVAL;
5651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005652 switch (set_value) {
5653 case 1:
5654 /* Enable PowerSave */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005655 sme_ps_enable_disable(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005656 SME_PS_ENABLE);
5657 break;
5658 case 2:
5659 /* Disable PowerSave */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005660 sme_ps_enable_disable(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 SME_PS_DISABLE);
5662 break;
5663 case 3: /* Enable UASPD */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005664 sme_ps_uapsd_enable(hHal, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665 break;
5666 case 4: /* Disable UASPD */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005667 sme_ps_uapsd_disable(hHal, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005668 break;
5669 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005670 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005671 set_value);
5672 ret = -EINVAL;
5673 break;
5674 }
5675 break;
5676 }
5677
5678 case WE_SET_MAX_ASSOC:
5679 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305680 if (!hHal)
5681 return -EINVAL;
5682
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005683 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5684 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5685 ret = -EINVAL;
5686 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5687 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305688 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005689 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005690 ret = -EIO;
5691 }
5692 break;
5693 }
5694
5695 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5696 if (set_value == 0 || set_value == 1)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005697 (WLAN_HDD_GET_CTX(adapter))->config->force_sap_acs =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005698 set_value;
5699 else
5700 ret = -EINVAL;
5701 break;
5702
5703 case WE_SET_DATA_INACTIVITY_TO:
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305704 if (!hHal)
5705 return -EINVAL;
5706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5708 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005709 (sme_cfg_set_int((WLAN_HDD_GET_CTX(adapter))->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005710 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305711 set_value) == QDF_STATUS_E_FAILURE)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005712 hdd_err("WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 ret = -EINVAL;
5714 }
5715 break;
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05305716 case WE_SET_WOW_DATA_INACTIVITY_TO:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305717 if (!hHal) {
5718 ret = -EINVAL;
5719 goto free;
5720 }
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05305721
5722 if ((set_value < CFG_WOW_DATA_INACTIVITY_TIMEOUT_MIN) ||
5723 (set_value > CFG_WOW_DATA_INACTIVITY_TIMEOUT_MAX) ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005724 (sme_cfg_set_int((WLAN_HDD_GET_CTX(adapter))->hHal,
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05305725 WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT,
5726 set_value) == QDF_STATUS_E_FAILURE)) {
5727 hdd_err("WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT fail");
5728 ret = -EINVAL;
5729 }
5730 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731 case WE_SET_MC_RATE:
5732 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305733 if (!hHal)
5734 return -EINVAL;
5735
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005736 ret = wlan_hdd_set_mc_rate(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005737 break;
5738 }
5739 case WE_SET_TX_POWER:
5740 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305741 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305743 if (!hHal)
5744 return -EINVAL;
5745
Jeff Johnsond377dce2017-10-04 10:32:42 -07005746 qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747 if (sme_set_tx_power
Jeff Johnson1b780e42017-10-31 14:11:45 -07005748 (hHal, adapter->session_id, bssid,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005749 adapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305750 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005751 hdd_err("Setting tx power failed");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305752 ret = -EIO;
5753 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005754 }
5755 break;
5756 }
5757 case WE_SET_MAX_TX_POWER:
5758 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305759 struct qdf_mac_addr bssid;
5760 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005761
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305762 if (!hHal)
5763 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005764
5765 hdd_debug("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005766 set_value);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005767 qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssId);
5768 qdf_copy_macaddr(&selfMac, &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005769
5770 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305771 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005772 hdd_err("Setting maximum tx power failed");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305773 ret = -EIO;
5774 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005775 }
5776
5777 break;
5778 }
5779 case WE_SET_MAX_TX_POWER_2_4:
5780 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005781 hdd_debug("Setting maximum tx power %d dBm for 2.4 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07005782 set_value);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005783 if (sme_set_max_tx_power_per_band(BAND_2G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305784 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005785 hdd_err("Setting max tx power failed for 2.4 GHz band");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305786 ret = -EIO;
5787 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788 }
5789
5790 break;
5791 }
5792 case WE_SET_MAX_TX_POWER_5_0:
5793 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005794 hdd_debug("Setting maximum tx power %d dBm for 5.0 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07005795 set_value);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005796 if (sme_set_max_tx_power_per_band(BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305797 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005798 hdd_err("Setting max tx power failed for 5.0 GHz band");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305799 ret = -EIO;
5800 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005801 }
5802
5803 break;
5804 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005805
5806 case WE_SET_TM_LEVEL:
5807 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305808 if (!hHal)
5809 return -EINVAL;
5810
5811 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812 (void)sme_set_thermal_level(hHal, set_value);
5813 break;
5814 }
5815
5816 case WE_SET_PHYMODE:
5817 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005818 struct hdd_context *phddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07005819
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305820 if (!hHal)
5821 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005822
5823 ret =
5824 wlan_hdd_update_phymode(dev, hHal, set_value,
5825 phddctx);
5826 break;
5827 }
5828
5829 case WE_SET_NSS:
5830 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305831 if (!hHal)
5832 return -EINVAL;
5833
5834 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005836 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005837 ret = -EINVAL;
5838 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305839 if (QDF_STATUS_SUCCESS !=
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -08005840 hdd_update_nss(adapter, set_value))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 ret = -EINVAL;
5842 }
5843 break;
5844 }
5845
5846 case WE_SET_GTX_HT_MCS:
5847 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005848 hdd_debug("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005849 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 WMI_VDEV_PARAM_GTX_HT_MCS,
5851 set_value, GTX_CMD);
5852 break;
5853 }
5854
5855 case WE_SET_GTX_VHT_MCS:
5856 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005857 hdd_debug("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005859 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860 WMI_VDEV_PARAM_GTX_VHT_MCS,
5861 set_value, GTX_CMD);
5862 break;
5863 }
5864
5865 case WE_SET_GTX_USRCFG:
5866 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005867 hdd_debug("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005869 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005870 WMI_VDEV_PARAM_GTX_USR_CFG,
5871 set_value, GTX_CMD);
5872 break;
5873 }
5874
5875 case WE_SET_GTX_THRE:
5876 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005877 hdd_debug("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005878 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005879 WMI_VDEV_PARAM_GTX_THRE,
5880 set_value, GTX_CMD);
5881 break;
5882 }
5883
5884 case WE_SET_GTX_MARGIN:
5885 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005886 hdd_debug("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005887 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005888 WMI_VDEV_PARAM_GTX_MARGIN,
5889 set_value, GTX_CMD);
5890 break;
5891 }
5892
5893 case WE_SET_GTX_STEP:
5894 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005895 hdd_debug("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005896 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005897 WMI_VDEV_PARAM_GTX_STEP,
5898 set_value, GTX_CMD);
5899 break;
5900 }
5901
5902 case WE_SET_GTX_MINTPC:
5903 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005904 hdd_debug("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005905 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906 WMI_VDEV_PARAM_GTX_MINTPC,
5907 set_value, GTX_CMD);
5908 break;
5909 }
5910
5911 case WE_SET_GTX_BWMASK:
5912 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005913 hdd_debug("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005914 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005915 WMI_VDEV_PARAM_GTX_BW_MASK,
5916 set_value, GTX_CMD);
5917 break;
5918 }
5919
5920 case WE_SET_LDPC:
5921 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305922 if (!hHal)
5923 return -EINVAL;
5924
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005925 ret = hdd_set_ldpc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005926 break;
5927 }
5928
5929 case WE_SET_TX_STBC:
5930 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305931 if (!hHal)
5932 return -EINVAL;
5933
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005934 ret = hdd_set_tx_stbc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005935 break;
5936 }
5937
5938 case WE_SET_RX_STBC:
5939 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305940 if (!hHal)
5941 return -EINVAL;
5942
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005943 ret = hdd_set_rx_stbc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944 break;
5945 }
5946
5947 case WE_SET_SHORT_GI:
5948 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305949 if (!hHal)
5950 return -EINVAL;
5951
5952 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005953 ret = sme_update_ht_config(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005954 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
5955 set_value);
5956 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07005957 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005958 break;
5959 }
5960
5961 case WE_SET_RTSCTS:
5962 {
5963 uint32_t value;
5964
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305965 if (!hHal)
5966 return -EINVAL;
5967
5968 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005969 set_value);
5970
5971 if ((set_value & HDD_RTSCTS_EN_MASK) ==
5972 HDD_RTSCTS_ENABLE)
5973 value =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005974 (WLAN_HDD_GET_CTX(adapter))->config->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975 RTSThreshold;
5976 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
5977 || ((set_value & HDD_RTSCTS_EN_MASK) ==
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305978 HDD_CTS_ENABLE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005979 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305980 } else {
5981 ret = -EIO;
5982 goto free;
5983 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984
Jeff Johnson1b780e42017-10-31 14:11:45 -07005985 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986 WMI_VDEV_PARAM_ENABLE_RTSCTS,
5987 set_value, VDEV_CMD);
5988 if (!ret) {
5989 if (sme_cfg_set_int
5990 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305991 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005992 hdd_err("FAILED TO SET RTSCTS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305993 ret = -EIO;
5994 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 }
5996 }
5997
5998 break;
5999 }
6000
6001 case WE_SET_CHWIDTH:
6002 {
6003 bool chwidth = false;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006004 struct hdd_context *phddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07006005
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05306006 if (!hHal)
6007 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009 /*updating channel bonding only on 5Ghz */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006010 hdd_debug("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011 set_value);
6012 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006013 hdd_err("Invalid channel width 0->20 1->40 2->80");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306014 ret = -EINVAL;
6015 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 }
6017
6018 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
6019 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
6020 nChannelBondingMode5GHz)))
6021 chwidth = true;
6022
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306023 sme_get_config_param(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006024 switch (set_value) {
6025 case eHT_CHANNEL_WIDTH_20MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306026 sme_config->csrConfig.channelBondingMode5GHz =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
6028 break;
6029 case eHT_CHANNEL_WIDTH_40MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306030 if (chwidth) {
6031 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006032 channelBondingMode5GHz =
6033 phddctx->config->
6034 nChannelBondingMode5GHz;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306035 } else {
6036 ret = -EINVAL;
6037 goto free;
6038 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006039
6040 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006041 case eHT_CHANNEL_WIDTH_80MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306042 if (chwidth) {
6043 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044 channelBondingMode5GHz =
6045 phddctx->config->
6046 nChannelBondingMode5GHz;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306047 } else {
6048 ret = -EINVAL;
6049 goto free;
6050 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051
6052 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006053
6054 default:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306055 ret = -EINVAL;
6056 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006057 }
6058
Jeff Johnson1b780e42017-10-31 14:11:45 -07006059 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 WMI_VDEV_PARAM_CHWIDTH,
6061 set_value, VDEV_CMD);
6062 if (!ret)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306063 sme_update_config(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006064
6065 break;
6066 }
6067
6068 case WE_SET_ANI_EN_DIS:
6069 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006070 hdd_debug("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006072 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006073 WMI_PDEV_PARAM_ANI_ENABLE,
6074 set_value, PDEV_CMD);
6075 break;
6076 }
6077
6078 case WE_SET_ANI_POLL_PERIOD:
6079 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006080 hdd_debug("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006082 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006083 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6084 set_value, PDEV_CMD);
6085 break;
6086 }
6087
6088 case WE_SET_ANI_LISTEN_PERIOD:
6089 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006090 hdd_debug("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006092 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6094 set_value, PDEV_CMD);
6095 break;
6096 }
6097
6098 case WE_SET_ANI_OFDM_LEVEL:
6099 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006100 hdd_debug("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006101 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006102 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006103 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6104 set_value, PDEV_CMD);
6105 break;
6106 }
6107
6108 case WE_SET_ANI_CCK_LEVEL:
6109 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006110 hdd_debug("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006111 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006112 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006113 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6114 set_value, PDEV_CMD);
6115 break;
6116 }
6117
6118 case WE_SET_DYNAMIC_BW:
6119 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006120 hdd_debug("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006121 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006122 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123 WMI_PDEV_PARAM_DYNAMIC_BW,
6124 set_value, PDEV_CMD);
6125 break;
6126 }
6127
6128 case WE_SET_CTS_CBW:
6129 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006130 hdd_debug("WE_SET_CTS_CBW val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006131 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006132 WMI_PDEV_PARAM_CTS_CBW,
6133 set_value, PDEV_CMD);
6134 break;
6135 }
6136
6137 case WE_SET_11N_RATE:
6138 {
6139 uint8_t preamble = 0, nss = 0, rix = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006140
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006141 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006142 set_value);
6143
6144 if (set_value != 0xff) {
6145 rix = RC_2_RATE_IDX(set_value);
6146 if (set_value & 0x80) {
6147 preamble = WMI_RATE_PREAMBLE_HT;
6148 nss = HT_RC_2_STREAMS(set_value) - 1;
6149 } else {
6150 nss = 0;
6151 rix = RC_2_RATE_IDX(set_value);
6152 if (set_value & 0x10) {
6153 preamble =
6154 WMI_RATE_PREAMBLE_CCK;
6155 if (rix != 0x3)
6156 /* Enable Short
6157 * preamble always for
6158 * CCK except 1mbps
6159 */
6160 rix |= 0x4;
6161 } else {
6162 preamble =
6163 WMI_RATE_PREAMBLE_OFDM;
6164 }
6165 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006166 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006167 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006168 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169 set_value, rix, preamble, nss);
6170
Jeff Johnson1b780e42017-10-31 14:11:45 -07006171 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006172 WMI_VDEV_PARAM_FIXED_RATE,
6173 set_value, VDEV_CMD);
6174 break;
6175 }
6176
6177 case WE_SET_VHT_RATE:
6178 {
6179 uint8_t preamble = 0, nss = 0, rix = 0;
6180
6181 if (set_value != 0xff) {
6182 rix = RC_2_RATE_IDX_11AC(set_value);
6183 preamble = WMI_RATE_PREAMBLE_VHT;
6184 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
6185
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006186 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006187 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006188 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006189 set_value, rix, preamble, nss);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006190 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006191 WMI_VDEV_PARAM_FIXED_RATE,
6192 set_value, VDEV_CMD);
6193 break;
6194 }
6195
6196 case WE_SET_AMPDU:
6197 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006198 hdd_debug("SET AMPDU val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006199 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006200 GEN_VDEV_PARAM_AMPDU,
6201 set_value, GEN_CMD);
6202 break;
6203 }
6204
6205 case WE_SET_AMSDU:
6206 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006207 hdd_debug("SET AMSDU val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006208 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006209 GEN_VDEV_PARAM_AMSDU,
6210 set_value, GEN_CMD);
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07006211 /* Update the stored ini value */
6212 if (!ret)
6213 hdd_ctx->config->max_amsdu_num = set_value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006214 break;
6215 }
6216
6217 case WE_SET_BURST_ENABLE:
6218 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006219 hdd_debug("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006220 if ((set_value == 0) || (set_value == 1)) {
Jeff Johnson1b780e42017-10-31 14:11:45 -07006221 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006222 WMI_PDEV_PARAM_BURST_ENABLE,
6223 set_value, PDEV_CMD);
6224 } else
6225 ret = -EINVAL;
6226 break;
6227 }
6228 case WE_SET_BURST_DUR:
6229 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006230 hdd_debug("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07006231 if ((set_value > 0) && (set_value <= 102400))
Jeff Johnson1b780e42017-10-31 14:11:45 -07006232 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006233 WMI_PDEV_PARAM_BURST_DUR,
6234 set_value, PDEV_CMD);
6235 else
6236 ret = -EINVAL;
6237 break;
6238 }
6239
6240 case WE_SET_TX_CHAINMASK:
6241 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006242 hdd_debug("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006243 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006244 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006245 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6246 set_value, PDEV_CMD);
6247 break;
6248 }
6249
6250 case WE_SET_RX_CHAINMASK:
6251 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006252 hdd_debug("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006253 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006254 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006255 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6256 set_value, PDEV_CMD);
6257 break;
6258 }
6259
6260 case WE_SET_TXPOW_2G:
6261 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006262 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006263 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006264 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6266 set_value, PDEV_CMD);
6267 break;
6268 }
6269
6270 case WE_SET_TXPOW_5G:
6271 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006272 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006273 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006274 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006275 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6276 set_value, PDEV_CMD);
6277 break;
6278 }
6279
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006280 /* Firmware debug log */
6281 case WE_DBGLOG_LOG_LEVEL:
6282 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006283 hdd_debug("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006284 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006285 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006286 WMI_DBGLOG_LOG_LEVEL,
6287 set_value, DBG_CMD);
6288 break;
6289 }
6290
6291 case WE_DBGLOG_VAP_ENABLE:
6292 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006293 hdd_debug("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006294 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006295 WMI_DBGLOG_VAP_ENABLE,
6296 set_value, DBG_CMD);
6297 break;
6298 }
6299
6300 case WE_DBGLOG_VAP_DISABLE:
6301 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006302 hdd_debug("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006303 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006304 WMI_DBGLOG_VAP_DISABLE,
6305 set_value, DBG_CMD);
6306 break;
6307 }
6308
6309 case WE_DBGLOG_MODULE_ENABLE:
6310 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006311 hdd_debug("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006312 set_value);
6313 hdd_ctx->fw_log_settings.enable = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006314 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006315 WMI_DBGLOG_MODULE_ENABLE,
6316 set_value, DBG_CMD);
6317 break;
6318 }
6319
6320 case WE_DBGLOG_MODULE_DISABLE:
6321 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006322 hdd_debug("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006323 set_value);
6324 hdd_ctx->fw_log_settings.enable = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006325 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006326 WMI_DBGLOG_MODULE_DISABLE,
6327 set_value, DBG_CMD);
6328 break;
6329 }
6330 case WE_DBGLOG_MOD_LOG_LEVEL:
6331 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006332 hdd_debug("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006333 set_value);
6334
6335 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
6336 hdd_ctx->fw_log_settings.index = 0;
6337
6338 hdd_ctx->fw_log_settings.
6339 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
6340 set_value;
6341 hdd_ctx->fw_log_settings.index++;
6342
Jeff Johnson1b780e42017-10-31 14:11:45 -07006343 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006344 WMI_DBGLOG_MOD_LOG_LEVEL,
6345 set_value, DBG_CMD);
6346 break;
6347 }
6348
6349 case WE_DBGLOG_TYPE:
6350 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006351 hdd_debug("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006352 hdd_ctx->fw_log_settings.dl_type = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006353 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006354 WMI_DBGLOG_TYPE,
6355 set_value, DBG_CMD);
6356 break;
6357 }
6358 case WE_DBGLOG_REPORT_ENABLE:
6359 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006360 hdd_debug("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006361 set_value);
6362 hdd_ctx->fw_log_settings.dl_report = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006363 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006364 WMI_DBGLOG_REPORT_ENABLE,
6365 set_value, DBG_CMD);
6366 break;
6367 }
6368
6369 case WE_SET_TXRX_FWSTATS:
6370 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006371 hdd_debug("WE_SET_TXRX_FWSTATS val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006372 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006373 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
6374 set_value, VDEV_CMD);
6375 break;
6376 }
6377
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006378 case WE_SET_TXRX_STATS:
6379 {
6380 hdd_notice("WE_SET_TXRX_STATS val %d", set_value);
6381 ret = cds_get_datapath_handles(&soc, &pdev, &vdev,
Jeff Johnson1b780e42017-10-31 14:11:45 -07006382 adapter->session_id);
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006383
Venkata Sharath Chandra Manchalabcdfdb12017-03-29 19:25:45 -07006384 if (ret != 0) {
6385 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
6386 "Invalid handles");
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006387 break;
Venkata Sharath Chandra Manchalabcdfdb12017-03-29 19:25:45 -07006388 }
6389 ret = cdp_txrx_stats(soc, vdev, set_value);
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006390 break;
6391 }
6392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006393 case WE_TXRX_FWSTATS_RESET:
6394 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006395 hdd_debug("WE_TXRX_FWSTATS_RESET val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006396 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006397 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
6398 set_value, VDEV_CMD);
6399 break;
6400 }
6401
6402 case WE_DUMP_STATS:
6403 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006404 hdd_debug("WE_DUMP_STATS val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006405 ret = hdd_wlan_dump_stats(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006406 break;
6407 }
6408
6409 case WE_CLEAR_STATS:
6410 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006411 hdd_debug("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006412 switch (set_value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006413 case CDP_HDD_STATS:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006414 memset(&adapter->stats, 0, sizeof(adapter->stats));
6415 memset(&adapter->hdd_stats, 0,
6416 sizeof(adapter->hdd_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006417 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006418 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006419 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
6420 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006421 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006422 wlan_hdd_clear_netif_queue_history(hdd_ctx);
6423 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006424 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05306425 hdd_clear_hif_stats();
6426 break;
Yun Park1027e8c2017-10-13 15:17:37 -07006427 case CDP_NAPI_STATS:
6428 hdd_clear_napi_stats();
6429 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006430 default:
Leo Changfdb45c32016-10-28 11:09:23 -07006431 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
6432 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006433 }
6434 break;
6435 }
6436
6437 case WE_PPS_PAID_MATCH:
6438 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006439 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306440 ret = -EINVAL;
6441 goto free;
6442 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006443
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006444 hdd_debug("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006445 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006446 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006447 WMI_VDEV_PPS_PAID_MATCH,
6448 set_value, PPS_CMD);
6449 break;
6450 }
6451
6452 case WE_PPS_GID_MATCH:
6453 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006454 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306455 ret = -EINVAL;
6456 goto free;
6457 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006458 hdd_debug("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006459 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006460 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006461 WMI_VDEV_PPS_GID_MATCH,
6462 set_value, PPS_CMD);
6463 break;
6464 }
6465
6466 case WE_PPS_EARLY_TIM_CLEAR:
6467 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006468 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306469 ret = -EINVAL;
6470 goto free;
6471 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006472 hdd_debug(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006473 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006474 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006475 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6476 set_value, PPS_CMD);
6477 break;
6478 }
6479
6480 case WE_PPS_EARLY_DTIM_CLEAR:
6481 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006482 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306483 ret = -EINVAL;
6484 goto free;
6485 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006486 hdd_debug("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006487 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006488 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6490 set_value, PPS_CMD);
6491 break;
6492 }
6493
6494 case WE_PPS_EOF_PAD_DELIM:
6495 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006496 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306497 ret = -EINVAL;
6498 goto free;
6499 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006500 hdd_debug("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006501 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006502 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006503 WMI_VDEV_PPS_EOF_PAD_DELIM,
6504 set_value, PPS_CMD);
6505 break;
6506 }
6507
6508 case WE_PPS_MACADDR_MISMATCH:
6509 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006510 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306511 ret = -EINVAL;
6512 goto free;
6513 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006514 hdd_debug("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006515 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006516 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006517 WMI_VDEV_PPS_MACADDR_MISMATCH,
6518 set_value, PPS_CMD);
6519 break;
6520 }
6521
6522 case WE_PPS_DELIM_CRC_FAIL:
6523 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006524 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306525 ret = -EINVAL;
6526 goto free;
6527 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006528 hdd_debug("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006529 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006530 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006531 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6532 set_value, PPS_CMD);
6533 break;
6534 }
6535
6536 case WE_PPS_GID_NSTS_ZERO:
6537 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006538 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306539 ret = -EINVAL;
6540 goto free;
6541 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006542 hdd_debug("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006543 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006544 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006545 WMI_VDEV_PPS_GID_NSTS_ZERO,
6546 set_value, PPS_CMD);
6547 break;
6548 }
6549
6550 case WE_PPS_RSSI_CHECK:
6551 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006552 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306553 ret = -EINVAL;
6554 goto free;
6555 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006556 hdd_debug("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006557 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006558 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006559 WMI_VDEV_PPS_RSSI_CHECK,
6560 set_value, PPS_CMD);
6561 break;
6562 }
6563
6564 case WE_PPS_5G_EBT:
6565 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006566 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306567 ret = -EINVAL;
6568 goto free;
6569 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006570
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006571 hdd_debug("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006572 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006573 WMI_VDEV_PPS_5G_EBT,
6574 set_value, PPS_CMD);
6575 break;
6576 }
6577
6578 case WE_SET_HTSMPS:
6579 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006580 hdd_debug("WE_SET_HTSMPS val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006581 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582 WMI_STA_SMPS_FORCE_MODE_CMDID,
6583 set_value, VDEV_CMD);
6584 break;
6585 }
6586
6587 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6588 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006589 hdd_debug("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006590 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006591 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006592 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6593 set_value, QPOWER_CMD);
6594 break;
6595 }
6596
6597 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6598 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006599 hdd_debug("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006600 set_value);
6601 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006602 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006603 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6604 set_value, QPOWER_CMD);
6605 break;
6606 }
6607
6608 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6609 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006610 hdd_debug("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006611 set_value);
6612 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006613 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006614 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6615 set_value, QPOWER_CMD);
6616 break;
6617 }
6618
6619 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6620 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006621 hdd_debug("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006622 set_value);
6623 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006624 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006625 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6626 set_value, QPOWER_CMD);
6627 break;
6628 }
6629
6630 case WE_MCC_CONFIG_LATENCY:
6631 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006632 wlan_hdd_set_mcc_latency(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006633 break;
6634 }
6635
6636 case WE_MCC_CONFIG_QUOTA:
6637 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006638 hdd_debug("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006639 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006640 ret = wlan_hdd_set_mcc_p2p_quota(adapter,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08006641 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006642 break;
6643 }
6644 case WE_SET_DEBUG_LOG:
6645 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006646 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07006647
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05306648 if (!hHal)
6649 return -EINVAL;
6650
Nirav Shah1da77682016-05-03 20:16:39 +05306651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006652 hdd_ctx->config->gEnableDebugLog = set_value;
6653 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6654 break;
6655 }
6656 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6657 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006658 hdd_debug("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006659 if ((set_value == 0) || (set_value == 1))
6660 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006661 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006662 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6663 set_value, VDEV_CMD);
6664 else
6665 ret = -EINVAL;
6666 break;
6667 }
6668 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6669 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006670 hdd_debug("SET early_rx bmiss val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006671 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006672 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6673 set_value, VDEV_CMD);
6674 break;
6675 }
6676 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6677 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006678 hdd_debug("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006679 set_value);
6680 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006681 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006682 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6683 set_value, VDEV_CMD);
6684 break;
6685 }
6686 case WE_SET_EARLY_RX_SLOP_STEP:
6687 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006688 hdd_debug("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006689 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006690 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006691 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6692 set_value, VDEV_CMD);
6693 break;
6694 }
6695 case WE_SET_EARLY_RX_INIT_SLOP:
6696 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006697 hdd_debug("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006698 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006699 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006700 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6701 set_value, VDEV_CMD);
6702 break;
6703 }
6704 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6705 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006706 hdd_debug("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006707 if ((set_value == 0) || (set_value == 1))
6708 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006709 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006710 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6711 set_value, VDEV_CMD);
6712 else
6713 ret = -EINVAL;
6714 break;
6715 }
6716 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6717 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006718 hdd_debug("SET early_rx drift sample %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006719 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006720 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6721 set_value, VDEV_CMD);
6722 break;
6723 }
6724 case WE_SET_SCAN_DISABLE:
6725 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05306726 if (!hHal)
6727 return -EINVAL;
6728
6729 hdd_notice("SET SCAN DISABLE %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006730 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(adapter), set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006731 break;
6732 }
Govind Singha471e5e2015-10-12 17:11:14 +05306733 case WE_START_FW_PROFILE:
6734 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006735 hdd_debug("WE_START_FW_PROFILE %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006736 ret = wma_cli_set_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +05306737 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6738 set_value, DBG_CMD);
6739 break;
6740 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306741 case WE_SET_CHANNEL:
6742 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006743 hdd_debug("Set Channel %d Session ID %d mode %d", set_value,
Jeff Johnson1b780e42017-10-31 14:11:45 -07006744 adapter->session_id, adapter->device_mode);
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05306745 if (!hHal)
6746 return -EINVAL;
6747
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306748
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006749 if ((QDF_STA_MODE == adapter->device_mode) ||
6750 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306751
6752 status = sme_ext_change_channel(hHal,
Jeff Johnson1b780e42017-10-31 14:11:45 -07006753 set_value, adapter->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306754 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006755 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306756 status);
6757 ret = -EINVAL;
6758 }
6759 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006760 hdd_err("change channel not supported for device mode %d",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006761 adapter->device_mode);
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306762 ret = -EINVAL;
6763 }
6764 break;
6765 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306766 case WE_SET_CONC_SYSTEM_PREF:
6767 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006768 hdd_debug("New preference: %d", set_value);
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306769 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6770 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6771 hdd_err("Invalid system preference %d", set_value);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306772 ret = -EINVAL;
6773 goto free;
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306774 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306775
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306776 /* hdd_ctx, hdd_ctx->config are already checked for null */
6777 hdd_ctx->config->conc_system_pref = set_value;
6778 break;
6779 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006780 case WE_SET_11AX_RATE:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006781 ret = hdd_set_11ax_rate(adapter, set_value, NULL);
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006782 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07006783 case WE_SET_DCM:
6784 hdd_notice("Set WMI_VDEV_PARAM_HE_DCM: %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006785 ret = wma_cli_set_command(adapter->session_id,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07006786 WMI_VDEV_PARAM_HE_DCM, set_value,
6787 VDEV_CMD);
6788 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07006789 case WE_SET_RANGE_EXT:
6790 hdd_notice("Set WMI_VDEV_PARAM_HE_RANGE_EXT: %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006791 ret = wma_cli_set_command(adapter->session_id,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07006792 WMI_VDEV_PARAM_HE_RANGE_EXT,
6793 set_value, VDEV_CMD);
6794 break;
Jeff Johnson011c4502017-10-05 15:25:56 -07006795 case WE_SET_PDEV_RESET:
6796 ret = hdd_handle_pdev_reset(adapter, set_value);
6797 break;
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05306798 case WE_SET_MODULATED_DTIM:
6799 {
6800 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6801 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6802 hdd_err("Invalid gEnableModuleDTIM value %d",
6803 set_value);
6804 return -EINVAL;
6805 } else {
6806 hdd_ctx->config->enableModulatedDTIM = set_value;
6807 }
6808 break;
6809 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006810 default:
Jeff Johnson011c4502017-10-05 15:25:56 -07006811 hdd_err("Invalid sub command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006812 ret = -EINVAL;
6813 break;
6814 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306815 EXIT();
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306816free:
6817 qdf_mem_free(sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006818 return ret;
6819}
6820
6821static int iw_setint_getnone(struct net_device *dev,
6822 struct iw_request_info *info,
6823 union iwreq_data *wrqu,
6824 char *extra)
6825{
6826 int ret;
6827
6828 cds_ssr_protect(__func__);
6829 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6830 cds_ssr_unprotect(__func__);
6831
6832 return ret;
6833}
6834
6835/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006836 * __iw_setnone_get_threeint() - return three value to up layer.
6837 *
6838 * @dev: pointer of net_device of this wireless card
6839 * @info: meta data about Request sent
6840 * @wrqu: include request info
6841 * @extra: buf used for in/Output
6842 *
6843 * Return: execute result
6844 */
6845static int __iw_setnone_get_threeint(struct net_device *dev,
6846 struct iw_request_info *info,
6847 union iwreq_data *wrqu, char *extra)
6848{
6849 int ret = 0; /* success */
6850 uint32_t *value = (int *)extra;
Jeff Johnson3d278b02017-08-29 14:17:47 -07006851 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006852 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006853
6854 ENTER_DEV(dev);
6855 ret = wlan_hdd_validate_context(hdd_ctx);
6856 if (0 != ret)
6857 return ret;
6858
Jeff Johnson441e1f72017-02-07 08:50:49 -08006859 ret = hdd_check_private_wext_control(hdd_ctx, info);
6860 if (0 != ret)
6861 return ret;
6862
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006863 hdd_debug("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006864 switch (value[0]) {
6865 case WE_GET_TSF:
6866 ret = hdd_indicate_tsf(adapter, value, 3);
6867 break;
6868 default:
6869 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6870 break;
6871 }
6872 return ret;
6873}
6874
6875/**
6876 * iw_setnone_get_threeint() - return three value to up layer.
6877 *
6878 * @dev: pointer of net_device of this wireless card
6879 * @info: meta data about Request sent
6880 * @wrqu: include request info
6881 * @extra: buf used for in/Output
6882 *
6883 * Return: execute result
6884 */
6885static int iw_setnone_get_threeint(struct net_device *dev,
6886 struct iw_request_info *info,
6887 union iwreq_data *wrqu, char *extra)
6888{
6889 int ret;
6890
6891 cds_ssr_protect(__func__);
6892 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6893 cds_ssr_unprotect(__func__);
6894
6895 return ret;
6896}
6897
6898/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6900 * @dev: device upon which the ioctl was received
6901 * @info: ioctl request information
6902 * @wrqu: ioctl request data
6903 * @extra: ioctl extra data
6904 *
6905 * Return: 0 on success, non-zero on error
6906 */
6907static int __iw_setchar_getnone(struct net_device *dev,
6908 struct iw_request_info *info,
6909 union iwreq_data *wrqu, char *extra)
6910{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306911 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006912 int sub_cmd;
6913 int ret;
6914 char *pBuffer = NULL;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006915 struct hdd_adapter *adapter = (netdev_priv(dev));
6916 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006917 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006918 struct iw_point s_priv_data;
6919
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006920 ENTER_DEV(dev);
6921
Mukul Sharma34777c62015-11-02 20:22:30 +05306922 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006923 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306924 return -EPERM;
6925 }
6926
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006927 ret = wlan_hdd_validate_context(hdd_ctx);
6928 if (0 != ret)
6929 return ret;
6930
Jeff Johnson441e1f72017-02-07 08:50:49 -08006931 ret = hdd_check_private_wext_control(hdd_ctx, info);
6932 if (0 != ret)
6933 return ret;
6934
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006935 /* helper function to get iwreq_data with compat handling. */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006936 if (hdd_priv_get_data(&s_priv_data, wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006937 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006938
6939 /* make sure all params are correctly passed to function */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006940 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006941 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006942
6943 sub_cmd = s_priv_data.flags;
6944
6945 /* ODD number is used for set, copy data using copy_from_user */
6946 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6947 s_priv_data.length);
6948 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006949 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006950 return -ENOMEM;
6951 }
6952
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006953 hdd_debug("Received length: %d data: %s",
6954 s_priv_data.length, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006955
6956 switch (sub_cmd) {
6957 case WE_WOWL_ADD_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006958 hdd_debug("ADD_PTRN");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006959 hdd_add_wowl_ptrn(adapter, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006960 break;
6961 case WE_WOWL_DEL_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006962 hdd_debug("DEL_PTRN");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006963 hdd_del_wowl_ptrn(adapter, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006964 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006965 case WE_NEIGHBOR_REPORT_REQUEST:
6966 {
6967 tRrmNeighborReq neighborReq;
6968 tRrmNeighborRspCallbackInfo callbackInfo;
6969
6970 if (pConfig->fRrmEnable) {
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306971 neighborReq.neighbor_report_offload = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006972 neighborReq.no_ssid =
6973 (s_priv_data.length - 1) ? false : true;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306974 hdd_debug("Neighbor Request ssid present %d",
6975 neighborReq.no_ssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006976 if (!neighborReq.no_ssid) {
6977 neighborReq.ssid.length =
6978 (s_priv_data.length - 1) >
6979 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306980 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006981 pBuffer,
6982 neighborReq.ssid.length);
6983 }
6984
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306985 /*
6986 * If 11k offload is supported by FW and enabled
6987 * in the ini, set the offload to true
6988 */
6989 if (hdd_ctx->config->is_11k_offload_supported &&
6990 (hdd_ctx->config->offload_11k_enable_bitmask &
6991 OFFLOAD_11K_BITMASK_NEIGHBOR_REPORT_REQUEST)) {
6992 hdd_debug("Neighbor report offloaded to FW");
6993 neighborReq.neighbor_report_offload = true;
6994 }
6995
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006996 callbackInfo.neighborRspCallback = NULL;
6997 callbackInfo.neighborRspCallbackContext = NULL;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306998 callbackInfo.timeout = 5000; /* 5 seconds */
6999 sme_neighbor_report_request(
7000 WLAN_HDD_GET_HAL_CTX(adapter),
7001 adapter->session_id,
7002 &neighborReq,
7003 &callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007004 } else {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007005 hdd_err("Ignoring neighbor request as RRM not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007006 ret = -EINVAL;
7007 }
7008 }
7009 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007010 case WE_SET_AP_WPS_IE:
Wu Gao02bd75b2017-10-13 18:34:02 +08007011 hdd_debug("Received WE_SET_AP_WPS_IE, won't process");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007012 break;
7013 case WE_SET_CONFIG:
7014 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007015 if (QDF_STATUS_SUCCESS != vstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007016 ret = -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007017
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007018 break;
7019 default:
7020 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007021 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007022 sub_cmd);
7023 ret = -EINVAL;
7024 break;
7025 }
7026 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07007027 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307028 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007029 return ret;
7030}
7031
7032static int iw_setchar_getnone(struct net_device *dev,
7033 struct iw_request_info *info,
7034 union iwreq_data *wrqu, char *extra)
7035{
7036 int ret;
7037
7038 cds_ssr_protect(__func__);
7039 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
7040 cds_ssr_unprotect(__func__);
7041
7042 return ret;
7043}
7044
7045/**
7046 * iw_setnone_getint() - Generic "get integer" private ioctl handler
7047 * @dev: device upon which the ioctl was received
7048 * @info: ioctl request information
7049 * @wrqu: ioctl request data
7050 * @extra: ioctl extra data
7051 *
7052 * Return: 0 on success, non-zero on error
7053 */
7054static int __iw_setnone_getint(struct net_device *dev,
7055 struct iw_request_info *info,
7056 union iwreq_data *wrqu, char *extra)
7057{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007058 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7059 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007060 int *value = (int *)extra;
7061 int ret;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307062 tSmeConfigParams *sme_config;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007063 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007064
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007065 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307066
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007067 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007068 ret = wlan_hdd_validate_context(hdd_ctx);
7069 if (0 != ret)
7070 return ret;
7071
Jeff Johnson441e1f72017-02-07 08:50:49 -08007072 ret = hdd_check_private_wext_control(hdd_ctx, info);
7073 if (0 != ret)
7074 return ret;
7075
Rajeev Kumar1117fcf2018-02-15 16:25:19 -08007076 sme_config = qdf_mem_malloc(sizeof(*sme_config));
7077 if (!sme_config) {
7078 hdd_err("failed to allocate memory for sme_config");
7079 return -ENOMEM;
7080 }
7081
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007082 switch (value[0]) {
7083 case WE_GET_11D_STATE:
7084 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307085 sme_get_config_param(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007086
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307087 *value = sme_config->csrConfig.Is11dSupportEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007088
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007089 hdd_debug("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007090
7091 break;
7092 }
7093
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007094 case WE_GET_WLAN_DBG:
7095 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307096 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007097 *value = 0;
7098 break;
7099 }
7100 case WE_GET_MAX_ASSOC:
7101 {
7102 if (sme_cfg_get_int
7103 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307104 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007105 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007106 ret = -EIO;
7107 }
7108 break;
7109 }
7110 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
7111 *value = (WLAN_HDD_GET_CTX(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007112 adapter))->config->force_sap_acs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007113 break;
7114
7115 case WE_GET_CONCURRENCY_MODE:
7116 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08007117 *value = policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007118
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007119 hdd_debug("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007120 break;
7121 }
7122
7123 case WE_GET_NSS:
7124 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307125 sme_get_config_param(hHal, sme_config);
7126 *value = (sme_config->csrConfig.enable2x2 == 0) ? 1 : 2;
Srinivas Girigowda576b2352017-08-25 14:44:26 -07007127 if (policy_mgr_is_current_hwmode_dbs(hdd_ctx->hdd_psoc))
7128 *value = *value - 1;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007129 hdd_debug("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007130 break;
7131 }
7132
7133 case WE_GET_GTX_HT_MCS:
7134 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007135 hdd_debug("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007136 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007137 WMI_VDEV_PARAM_GTX_HT_MCS,
7138 GTX_CMD);
7139 break;
7140 }
7141
7142 case WE_GET_GTX_VHT_MCS:
7143 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007144 hdd_debug("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007145 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007146 WMI_VDEV_PARAM_GTX_VHT_MCS,
7147 GTX_CMD);
7148 break;
7149 }
7150
7151 case WE_GET_GTX_USRCFG:
7152 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007153 hdd_debug("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007154 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007155 WMI_VDEV_PARAM_GTX_USR_CFG,
7156 GTX_CMD);
7157 break;
7158 }
7159
7160 case WE_GET_GTX_THRE:
7161 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007162 hdd_debug("GET WMI_VDEV_PARAM_GTX_THRE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007163 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007164 WMI_VDEV_PARAM_GTX_THRE,
7165 GTX_CMD);
7166 break;
7167 }
7168
7169 case WE_GET_GTX_MARGIN:
7170 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007171 hdd_debug("GET WMI_VDEV_PARAM_GTX_MARGIN");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007172 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007173 WMI_VDEV_PARAM_GTX_MARGIN,
7174 GTX_CMD);
7175 break;
7176 }
7177
7178 case WE_GET_GTX_STEP:
7179 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007180 hdd_debug("GET WMI_VDEV_PARAM_GTX_STEP");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007181 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007182 WMI_VDEV_PARAM_GTX_STEP,
7183 GTX_CMD);
7184 break;
7185 }
7186
7187 case WE_GET_GTX_MINTPC:
7188 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007189 hdd_debug("GET WMI_VDEV_PARAM_GTX_MINTPC");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007190 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007191 WMI_VDEV_PARAM_GTX_MINTPC,
7192 GTX_CMD);
7193 break;
7194 }
7195
7196 case WE_GET_GTX_BWMASK:
7197 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007198 hdd_debug("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007199 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007200 WMI_VDEV_PARAM_GTX_BW_MASK,
7201 GTX_CMD);
7202 break;
7203 }
7204
7205 case WE_GET_LDPC:
7206 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007207 ret = hdd_get_ldpc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007208 break;
7209 }
7210
7211 case WE_GET_TX_STBC:
7212 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007213 ret = hdd_get_tx_stbc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007214 break;
7215 }
7216
7217 case WE_GET_RX_STBC:
7218 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007219 ret = hdd_get_rx_stbc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007220 break;
7221 }
7222
7223 case WE_GET_SHORT_GI:
7224 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007225 hdd_debug("GET WMI_VDEV_PARAM_SGI");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007226 *value = wma_cli_get_command(adapter->session_id,
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08007227 WMI_VDEV_PARAM_SGI,
7228 VDEV_CMD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007229 break;
7230 }
7231
7232 case WE_GET_RTSCTS:
7233 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007234 hdd_debug("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007235 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007236 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7237 VDEV_CMD);
7238 break;
7239 }
7240
7241 case WE_GET_CHWIDTH:
7242 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007243 hdd_debug("GET WMI_VDEV_PARAM_CHWIDTH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007244 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007245 WMI_VDEV_PARAM_CHWIDTH,
7246 VDEV_CMD);
7247 break;
7248 }
7249
7250 case WE_GET_ANI_EN_DIS:
7251 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007252 hdd_debug("GET WMI_PDEV_PARAM_ANI_ENABLE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007253 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007254 WMI_PDEV_PARAM_ANI_ENABLE,
7255 PDEV_CMD);
7256 break;
7257 }
7258
7259 case WE_GET_ANI_POLL_PERIOD:
7260 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007261 hdd_debug("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007262 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007263 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
7264 PDEV_CMD);
7265 break;
7266 }
7267
7268 case WE_GET_ANI_LISTEN_PERIOD:
7269 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007270 hdd_debug("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007271 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007272 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
7273 PDEV_CMD);
7274 break;
7275 }
7276
7277 case WE_GET_ANI_OFDM_LEVEL:
7278 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007279 hdd_debug("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007280 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007281 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
7282 PDEV_CMD);
7283 break;
7284 }
7285
7286 case WE_GET_ANI_CCK_LEVEL:
7287 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007288 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007289 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007290 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
7291 PDEV_CMD);
7292 break;
7293 }
7294
7295 case WE_GET_DYNAMIC_BW:
7296 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007297 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007298 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007299 WMI_PDEV_PARAM_DYNAMIC_BW,
7300 PDEV_CMD);
7301 break;
7302 }
7303
7304 case WE_GET_11N_RATE:
7305 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007306 hdd_debug("GET WMI_VDEV_PARAM_FIXED_RATE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007307 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007308 WMI_VDEV_PARAM_FIXED_RATE,
7309 VDEV_CMD);
7310 break;
7311 }
7312
7313 case WE_GET_AMPDU:
7314 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007315 hdd_debug("GET AMPDU");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007316 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007317 GEN_VDEV_PARAM_AMPDU,
7318 GEN_CMD);
7319 break;
7320 }
7321
7322 case WE_GET_AMSDU:
7323 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007324 hdd_debug("GET AMSDU");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007325 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007326 GEN_VDEV_PARAM_AMSDU,
7327 GEN_CMD);
7328 break;
7329 }
7330
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007331 case WE_GET_ROAM_SYNCH_DELAY:
7332 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007333 hdd_debug("GET ROAM SYNCH DELAY");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007334 *value = wma_cli_get_command(adapter->session_id,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007335 GEN_VDEV_ROAM_SYNCH_DELAY,
7336 GEN_CMD);
7337 break;
7338 }
7339
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007340 case WE_GET_BURST_ENABLE:
7341 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007342 hdd_debug("GET Burst enable value");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007343 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007344 WMI_PDEV_PARAM_BURST_ENABLE,
7345 PDEV_CMD);
7346 break;
7347 }
7348 case WE_GET_BURST_DUR:
7349 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007350 hdd_debug("GET Burst Duration value");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007351 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007352 WMI_PDEV_PARAM_BURST_DUR,
7353 PDEV_CMD);
7354 break;
7355 }
7356
7357 case WE_GET_TX_CHAINMASK:
7358 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007359 hdd_debug("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007360 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007361 WMI_PDEV_PARAM_TX_CHAIN_MASK,
7362 PDEV_CMD);
7363 break;
7364 }
7365
7366 case WE_GET_RX_CHAINMASK:
7367 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007368 hdd_debug("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007369 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007370 WMI_PDEV_PARAM_RX_CHAIN_MASK,
7371 PDEV_CMD);
7372 break;
7373 }
7374
7375 case WE_GET_TXPOW_2G:
7376 {
7377 uint32_t txpow2g = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007378 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007379
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007380 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007381 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007382 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
7383 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307384 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007385 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7386 &txpow2g)) {
7387 return -EIO;
7388 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007389 hdd_debug("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007390 break;
7391 }
7392
7393 case WE_GET_TXPOW_5G:
7394 {
7395 uint32_t txpow5g = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007396 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007397
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007398 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007399 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007400 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
7401 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307402 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007403 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7404 &txpow5g)) {
7405 return -EIO;
7406 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007407 hdd_debug("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007408 break;
7409 }
7410
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007411 case WE_GET_PPS_PAID_MATCH:
7412 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007413 hdd_debug("GET WMI_VDEV_PPS_PAID_MATCH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007414 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007415 WMI_VDEV_PPS_PAID_MATCH,
7416 PPS_CMD);
7417 break;
7418 }
7419
7420 case WE_GET_PPS_GID_MATCH:
7421 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007422 hdd_debug("GET WMI_VDEV_PPS_GID_MATCH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007423 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007424 WMI_VDEV_PPS_GID_MATCH,
7425 PPS_CMD);
7426 break;
7427 }
7428
7429 case WE_GET_PPS_EARLY_TIM_CLEAR:
7430 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007431 hdd_debug("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007432 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007433 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
7434 PPS_CMD);
7435 break;
7436 }
7437
7438 case WE_GET_PPS_EARLY_DTIM_CLEAR:
7439 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007440 hdd_debug("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007441 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007442 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
7443 PPS_CMD);
7444 break;
7445 }
7446
7447 case WE_GET_PPS_EOF_PAD_DELIM:
7448 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007449 hdd_debug("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007450 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007451 WMI_VDEV_PPS_EOF_PAD_DELIM,
7452 PPS_CMD);
7453 break;
7454 }
7455
7456 case WE_GET_PPS_MACADDR_MISMATCH:
7457 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007458 hdd_debug("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007459 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007460 WMI_VDEV_PPS_MACADDR_MISMATCH,
7461 PPS_CMD);
7462 break;
7463 }
7464
7465 case WE_GET_PPS_DELIM_CRC_FAIL:
7466 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007467 hdd_debug("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007468 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007469 WMI_VDEV_PPS_DELIM_CRC_FAIL,
7470 PPS_CMD);
7471 break;
7472 }
7473
7474 case WE_GET_PPS_GID_NSTS_ZERO:
7475 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007476 hdd_debug("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007477 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007478 WMI_VDEV_PPS_GID_NSTS_ZERO,
7479 PPS_CMD);
7480 break;
7481 }
7482
7483 case WE_GET_PPS_RSSI_CHECK:
7484 {
7485
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007486 hdd_debug("GET WMI_VDEV_PPS_RSSI_CHECK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007487 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007488 WMI_VDEV_PPS_RSSI_CHECK,
7489 PPS_CMD);
7490 break;
7491 }
7492
7493 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
7494 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007495 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007496 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007497 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
7498 QPOWER_CMD);
7499 break;
7500 }
7501
7502 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
7503 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007504 hdd_debug("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007505 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007506 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
7507 QPOWER_CMD);
7508 break;
7509 }
7510
7511 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
7512 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007513 hdd_debug("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007514 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007515 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
7516 QPOWER_CMD);
7517 break;
7518 }
7519
7520 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
7521 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007522 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007523 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007524 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
7525 QPOWER_CMD);
7526 break;
7527 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07007528 case WE_CAP_TSF:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007529 ret = hdd_capture_tsf(adapter, (uint32_t *)value, 1);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07007530 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007531 case WE_GET_TEMPERATURE:
7532 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007533 hdd_debug("WE_GET_TEMPERATURE");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007534 ret = wlan_hdd_get_temperature(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007535 break;
7536 }
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07007537 case WE_GET_DCM:
7538 hdd_notice("GET WMI_VDEV_PARAM_HE_DCM");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007539 *value = wma_cli_get_command(adapter->session_id,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07007540 WMI_VDEV_PARAM_HE_DCM,
7541 VDEV_CMD);
7542 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07007543 case WE_GET_RANGE_EXT:
7544 hdd_notice("GET WMI_VDEV_PARAM_HE_RANGE_EXT");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007545 *value = wma_cli_get_command(adapter->session_id,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07007546 WMI_VDEV_PARAM_HE_RANGE_EXT,
7547 VDEV_CMD);
7548 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007549 default:
7550 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007551 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007552 value[0]);
7553 break;
7554 }
7555 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307556 EXIT();
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307557 qdf_mem_free(sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007558 return ret;
7559}
7560
7561static int iw_setnone_getint(struct net_device *dev,
7562 struct iw_request_info *info,
7563 union iwreq_data *wrqu, char *extra)
7564{
7565 int ret;
7566
7567 cds_ssr_protect(__func__);
7568 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7569 cds_ssr_unprotect(__func__);
7570
7571 return ret;
7572}
7573
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307574static int hdd_set_fwtest(int argc, int cmd, int value)
7575{
7576 struct set_fwtest_params *fw_test;
7577
7578 /* check for max number of arguments */
7579 if (argc > (WMA_MAX_NUM_ARGS) ||
7580 argc != HDD_FWTEST_PARAMS) {
7581 hdd_err("Too Many args %d", argc);
7582 return -EINVAL;
7583 }
7584 /*
7585 * check if number of arguments are 3 then, check
7586 * then set the default value for sounding interval.
7587 */
7588 if (HDD_FWTEST_PARAMS == argc) {
7589 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7590 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7591 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7592 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7593 }
7594 /* check sounding interval value should not exceed to max */
7595 if (value > HDD_FWTEST_MAX_VALUE) {
7596 hdd_err("Invalid arguments value should not exceed max: %d",
7597 value);
7598 return -EINVAL;
7599 }
7600 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7601 if (NULL == fw_test) {
7602 hdd_err("qdf_mem_malloc failed for fw_test");
7603 return -ENOMEM;
7604 }
7605 fw_test->arg = cmd;
7606 fw_test->value = value;
7607 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7608 qdf_mem_free(fw_test);
7609 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7610 return -EINVAL;
7611 }
7612 return 0;
7613}
7614
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007615/**
7616 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7617 * @dev: device upon which the ioctl was received
7618 * @info: ioctl request information
7619 * @wrqu: ioctl request data
7620 * @extra: ioctl extra data
7621 *
7622 * Return: 0 on success, non-zero on error
7623 */
7624static int __iw_set_three_ints_getnone(struct net_device *dev,
7625 struct iw_request_info *info,
7626 union iwreq_data *wrqu, char *extra)
7627{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007628 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007629 int *value = (int *)extra;
7630 int sub_cmd = value[0];
7631 int ret;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007632 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007633
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007634 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307635
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007636 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007637 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007638 return -EPERM;
7639 }
7640
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007641 ret = wlan_hdd_validate_context(hdd_ctx);
7642 if (0 != ret)
7643 return ret;
7644
Jeff Johnson441e1f72017-02-07 08:50:49 -08007645 ret = hdd_check_private_wext_control(hdd_ctx, info);
7646 if (0 != ret)
7647 return ret;
7648
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007649 switch (sub_cmd) {
7650
7651 case WE_SET_WLAN_DBG:
Dustin Brown36e2e5c2017-05-16 15:41:37 -07007652 qdf_print_set_category_verbose(qdf_get_pidx(), value[1],
7653 value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007654 break;
7655 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307656 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007657 break;
7658
7659 /* value[3] the acs band is not required as start and end channels are
7660 * enough but this cmd is maintained under set three ints for historic
7661 * reasons.
7662 */
7663 case WE_SET_SAP_CHANNELS:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007664 if (wlan_hdd_validate_operation_channel(adapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307665 QDF_STATUS_SUCCESS ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007666 wlan_hdd_validate_operation_channel(adapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307667 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007668 ret = -EINVAL;
7669 } else {
7670 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7671 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7672 }
7673 break;
7674 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7675 hdd_debug("Ioctl to set dual mac scan config");
Tushnim Bhattacharyya49ed8ab2017-05-26 18:20:10 -07007676 if (hdd_ctx->config->dual_mac_feature_disable ==
7677 DISABLE_DBS_CXN_AND_SCAN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007678 hdd_err("Dual mac feature is disabled from INI");
7679 return -EPERM;
7680 }
7681 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08007682 policy_mgr_set_dual_mac_scan_config(hdd_ctx->hdd_psoc,
7683 value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007684 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307685 case WE_SET_FW_TEST:
7686 {
7687 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7688 if (ret) {
7689 hdd_err("Not able to set fwtest %d", ret);
7690 return ret;
7691 }
7692 }
7693 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007694 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007695 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007696 break;
7697
7698 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307699 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007700 return ret;
7701}
7702
7703int iw_set_three_ints_getnone(struct net_device *dev,
7704 struct iw_request_info *info,
7705 union iwreq_data *wrqu, char *extra)
7706{
7707 int ret;
7708
7709 cds_ssr_protect(__func__);
7710 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7711 cds_ssr_unprotect(__func__);
7712
7713 return ret;
7714}
7715
7716/**
7717 * hdd_connection_state_string() - Get connection state string
7718 * @connection_state: enum to be converted to a string
7719 *
7720 * Return: the string equivalent of @connection_state
7721 */
7722static const char *
7723hdd_connection_state_string(eConnectionState connection_state)
7724{
7725 switch (connection_state) {
7726 CASE_RETURN_STRING(eConnectionState_NotConnected);
7727 CASE_RETURN_STRING(eConnectionState_Connecting);
7728 CASE_RETURN_STRING(eConnectionState_Associated);
7729 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7730 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7731 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7732 default:
7733 return "UNKNOWN";
7734 }
7735}
7736
Naveen Rawat910726a2017-03-06 11:42:51 -08007737#if defined(FEATURE_OEM_DATA_SUPPORT)
7738/**
7739 * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
7740 * wifi_pos api to get oem data caps
7741 * @dev: net device upon which the request was received
7742 * @info: ioctl request information
7743 * @wrqu: ioctl request data
7744 * @extra: ioctl data payload
7745 *
7746 * Return: 0 for success, negative errno value on failure
7747 */
7748static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
7749 struct iw_request_info *info,
7750 union iwreq_data *wrqu, char *extra)
7751{
7752 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7753}
7754#elif defined(WIFI_POS_CONVERGED)
7755static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
7756 struct iw_request_info *info,
7757 union iwreq_data *wrqu, char *extra)
7758{
Jeff Johnson3d278b02017-08-29 14:17:47 -07007759 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007760 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Naveen Rawat910726a2017-03-06 11:42:51 -08007761
7762 return os_if_wifi_pos_populate_caps(hdd_ctx->hdd_psoc,
7763 (struct wifi_pos_driver_caps *)extra);
7764}
7765#else
7766static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
7767 struct iw_request_info *info,
7768 union iwreq_data *wrqu, char *extra)
7769{
7770 return -ENOTSUPP;
7771}
7772#endif
7773
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007774/**
7775 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7776 * @dev: device upon which the ioctl was received
7777 * @info: ioctl request information
7778 * @wrqu: ioctl request data
7779 * @extra: ioctl extra data
7780 *
7781 * Return: 0 on success, non-zero on error
7782 */
7783static int __iw_get_char_setnone(struct net_device *dev,
7784 struct iw_request_info *info,
7785 union iwreq_data *wrqu, char *extra)
7786{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007787 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007788 int sub_cmd = wrqu->data.flags;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007789 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007790 int ret;
7791#ifdef WLAN_FEATURE_11W
Jeff Johnson2a722002017-09-30 20:02:35 -07007792 struct hdd_wext_state *pWextState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007793#endif
7794
7795#ifdef WLAN_FEATURE_11W
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007796 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007797#endif
7798
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007799 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307800
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007801 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007802 ret = wlan_hdd_validate_context(hdd_ctx);
7803 if (0 != ret)
7804 return ret;
7805
Jeff Johnson441e1f72017-02-07 08:50:49 -08007806 ret = hdd_check_private_wext_control(hdd_ctx, info);
7807 if (0 != ret)
7808 return ret;
7809
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007810 switch (sub_cmd) {
7811 case WE_WLAN_VERSION:
7812 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307813 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007814 break;
7815 }
7816
7817 case WE_GET_STATS:
7818 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007819 hdd_wlan_get_stats(adapter, &(wrqu->data.length),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007820 extra, WE_MAX_STR_LEN);
7821 break;
7822 }
7823
Dustin Brownd9322482017-01-09 12:46:03 -08007824 case WE_GET_SUSPEND_RESUME_STATS:
7825 {
7826 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
7827 WE_MAX_STR_LEN);
7828 if (ret >= 0) {
7829 wrqu->data.length = ret;
7830 ret = 0;
7831 }
7832
7833 break;
7834 }
7835
Govind Singha471e5e2015-10-12 17:11:14 +05307836 case WE_LIST_FW_PROFILE:
7837 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7838 extra, WE_MAX_STR_LEN);
7839 break;
7840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007841 /* The case prints the current state of the HDD, SME, CSR, PE,
7842 * TL it can be extended for WDI Global State as well. And
7843 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7844 * and P2P_GO have not been added as of now.
7845 */
7846 case WE_GET_STATES:
7847 {
7848 int buf = 0, len = 0;
7849 int adapter_num = 0;
7850 int count = 0, check = 1;
7851
7852 tHalHandle hHal = NULL;
7853 tpAniSirGlobal pMac = NULL;
Jeff Johnsond377dce2017-10-04 10:32:42 -07007854 struct hdd_station_ctx *sta_ctx = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007855
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007856 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson3d278b02017-08-29 14:17:47 -07007857 struct hdd_adapter *useAdapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007858
7859 /* Print wlan0 or p2p0 states based on the adapter_num
7860 * by using the correct adapter
7861 */
7862 while (adapter_num < 2) {
7863 if (WLAN_ADAPTER == adapter_num) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007864 useAdapter = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007865 buf =
7866 scnprintf(extra + len,
7867 WE_MAX_STR_LEN - len,
7868 "\n\n wlan0 States:-");
7869 len += buf;
7870 } else if (P2P_ADAPTER == adapter_num) {
7871 buf =
7872 scnprintf(extra + len,
7873 WE_MAX_STR_LEN - len,
7874 "\n\n p2p0 States:-");
7875 len += buf;
7876
Jeff Johnsonce2ee982017-09-03 09:27:35 -07007877 if (!hdd_ctx) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007878 buf =
7879 scnprintf(extra + len,
7880 WE_MAX_STR_LEN -
7881 len,
Jeff Johnsonce2ee982017-09-03 09:27:35 -07007882 "\n hdd_ctx is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007883 len += buf;
7884 break;
7885 }
7886
7887 /* Printing p2p0 states only in the
7888 * case when the device is configured
7889 * as a p2p_client
7890 */
7891 useAdapter =
Jeff Johnsonce2ee982017-09-03 09:27:35 -07007892 hdd_get_adapter(hdd_ctx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007893 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007894 if (!useAdapter) {
7895 buf =
7896 scnprintf(extra + len,
7897 WE_MAX_STR_LEN -
7898 len,
7899 "\n Device not configured as P2P_CLIENT.");
7900 len += buf;
7901 break;
7902 }
7903 }
7904
7905 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7906 if (!hHal) {
7907 buf =
7908 scnprintf(extra + len,
7909 WE_MAX_STR_LEN - len,
7910 "\n pMac is NULL");
7911 len += buf;
7912 break;
7913 }
7914 pMac = PMAC_STRUCT(hHal);
7915 if (!pMac) {
7916 buf =
7917 scnprintf(extra + len,
7918 WE_MAX_STR_LEN - len,
7919 "\n pMac is NULL");
7920 len += buf;
7921 break;
7922 }
Jeff Johnsond377dce2017-10-04 10:32:42 -07007923 sta_ctx =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007924 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7925
7926
7927 buf =
7928 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7929 "\n HDD Conn State - %s "
Srinivas Girigowdab9086af2017-10-14 14:41:13 -07007930 "\n\n SME State:"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007931 "\n Neighbour Roam State - %s"
7932 "\n CSR State - %s"
7933 "\n CSR Substate - %s",
7934 hdd_connection_state_string
Jeff Johnsond377dce2017-10-04 10:32:42 -07007935 (sta_ctx->conn_info.connState),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007936 mac_trace_get_neighbour_roam_state
7937 (sme_get_neighbor_roam_state
Jeff Johnson1b780e42017-10-31 14:11:45 -07007938 (hHal, useAdapter->session_id)),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007939 mac_trace_getcsr_roam_state
7940 (sme_get_current_roam_state
Jeff Johnson1b780e42017-10-31 14:11:45 -07007941 (hHal, useAdapter->session_id)),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007942 mac_trace_getcsr_roam_sub_state
7943 (sme_get_current_roam_sub_state
Jeff Johnson1b780e42017-10-31 14:11:45 -07007944 (hHal, useAdapter->session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007945 );
7946 len += buf;
7947 adapter_num++;
7948 }
7949
Mukul Sharma81661ae2015-10-30 20:26:02 +05307950 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007951 /* Printing Lim State starting with global lim states */
7952 buf =
7953 scnprintf(extra + len, WE_MAX_STR_LEN - len,
Srinivas Girigowdab9086af2017-10-14 14:41:13 -07007954 "\n\n LIM STATES:-"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007955 "\n Global Sme State - %s "
7956 "\n Global mlm State - %s " "\n",
7957 mac_trace_get_lim_sme_state
7958 (sme_get_lim_sme_state(hHal)),
7959 mac_trace_get_lim_mlm_state
7960 (sme_get_lim_sme_state(hHal))
7961 );
7962 len += buf;
7963
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007964 while (check < 3 && count < 255) {
7965 if (sme_is_lim_session_valid(hHal, count)) {
7966 buf =
7967 scnprintf(extra + len,
7968 WE_MAX_STR_LEN -
7969 len,
7970 "\n Lim Valid Session %d:-"
7971 "\n PE Sme State - %s "
7972 "\n PE Mlm State - %s "
7973 "\n", check,
7974 mac_trace_get_lim_sme_state
7975 (sme_get_lim_sme_session_state
7976 (hHal, count)),
7977 mac_trace_get_lim_mlm_state
7978 (sme_get_lim_mlm_session_state
7979 (hHal, count))
7980 );
7981
7982 len += buf;
7983 check++;
7984 }
7985 count++;
7986 }
7987 }
7988
7989 wrqu->data.length = strlen(extra) + 1;
7990 break;
7991 }
7992
7993 case WE_GET_CFG:
7994 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007995 hdd_debug("Printing CLD global INI Config");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007996 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007997 extra,
7998 QCSAP_IOCTL_MAX_STR_LEN);
7999 wrqu->data.length = strlen(extra) + 1;
8000 break;
8001 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008002 case WE_GET_RSSI:
8003 {
8004 int8_t s7Rssi = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008005
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008006 wlan_hdd_get_rssi(adapter, &s7Rssi);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008007 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
8008 wrqu->data.length = strlen(extra) + 1;
8009 break;
8010 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008011
8012 case WE_GET_WMM_STATUS:
8013 {
8014 snprintf(extra, WE_MAX_STR_LEN,
8015 "\nDir: 0=up, 1=down, 3=both\n"
8016 "|------------------------|\n"
8017 "|AC | ACM |Admitted| Dir |\n"
8018 "|------------------------|\n"
8019 "|VO | %d | %3s | %d |\n"
8020 "|VI | %d | %3s | %d |\n"
8021 "|BE | %d | %3s | %d |\n"
8022 "|BK | %d | %3s | %d |\n"
8023 "|------------------------|\n",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008024 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008025 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008026 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008027 wmmAcStatus[SME_AC_VO].
8028 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008029 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008030 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
8031 ts_info.direction,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008032 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008033 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008034 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008035 wmmAcStatus[SME_AC_VI].
8036 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008037 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008038 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
8039 ts_info.direction,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008040 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008041 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008042 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008043 wmmAcStatus[SME_AC_BE].
8044 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008045 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008046 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
8047 ts_info.direction,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008048 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008049 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008050 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008051 wmmAcStatus[SME_AC_BK].
8052 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07008053 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008054 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
8055 ts_info.direction);
8056
8057 wrqu->data.length = strlen(extra) + 1;
8058 break;
8059 }
8060 case WE_GET_CHANNEL_LIST:
8061 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308062 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008063 uint8_t i, len;
8064 char *buf;
8065 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
8066 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008067 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008068
Srinivas Girigowdac231df62017-03-24 18:27:57 -07008069 struct channel_list_info channel_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008070
8071 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05308072 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008073 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308074 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008075 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008076 return -EINVAL;
8077 }
8078 buf = extra;
8079 /*
8080 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
8081 * Maximum buffer needed = 5 * number of channels.
8082 * Check ifsufficient buffer is available and then
8083 * proceed to fill the buffer.
8084 */
8085 if (WE_MAX_STR_LEN <
8086 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008087 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008088 return -EINVAL;
8089 }
8090 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
8091 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308092 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008093 ubuf, &ubuf_len)) {
8094 /* Printing Country code in getChannelList */
8095 for (i = 0; i < (ubuf_len - 1); i++)
8096 len += scnprintf(buf + len,
8097 WE_MAX_STR_LEN - len,
8098 "%c", ubuf[i]);
8099 }
8100 for (i = 0; i < channel_list.num_channels; i++) {
8101 len +=
8102 scnprintf(buf + len, WE_MAX_STR_LEN - len,
8103 " %u", channel_list.channels[i]);
8104 }
8105 wrqu->data.length = strlen(extra) + 1;
8106
8107 break;
8108 }
8109#ifdef FEATURE_WLAN_TDLS
8110 case WE_GET_TDLS_PEERS:
8111 {
8112 wrqu->data.length =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008113 wlan_hdd_tdls_get_all_peers(adapter, extra,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008114 WE_MAX_STR_LEN) + 1;
8115 break;
8116 }
8117#endif
8118#ifdef WLAN_FEATURE_11W
8119 case WE_GET_11W_INFO:
8120 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008121 hdd_debug("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008122 pWextState->roamProfile.MFPEnabled);
8123
8124 snprintf(extra, WE_MAX_STR_LEN,
8125 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
8126 "\n Number of Unprotected Disassocs %d"
8127 "\n Number of Unprotected Deauths %d",
8128 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
8129 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
8130 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
8131 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
8132 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
8133 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
8134 pWextState->roamProfile.MFPEnabled,
Jeff Johnsondc179f42017-10-21 11:27:26 -07008135 adapter->hdd_stats.hdd_pmf_stats.
8136 num_unprot_disassoc_rx,
8137 adapter->hdd_stats.hdd_pmf_stats.
8138 num_unprot_deauth_rx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008139
8140 wrqu->data.length = strlen(extra) + 1;
8141 break;
8142 }
8143#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008144 case WE_GET_IBSS_STA_INFO:
8145 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07008146 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008147 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008148 int idx = 0;
8149 int length = 0, buf = 0;
8150
Naveen Rawatc45d1622016-07-05 12:20:09 -07008151 for (idx = 0; idx < MAX_PEERS; idx++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07008152 if (HDD_WLAN_INVALID_STA_ID !=
Jeff Johnsond377dce2017-10-04 10:32:42 -07008153 sta_ctx->conn_info.staId[idx]) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008154 buf = snprintf
8155 ((extra + length),
8156 WE_MAX_STR_LEN - length,
8157 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Jeff Johnsond377dce2017-10-04 10:32:42 -07008158 sta_ctx->conn_info.staId[idx],
8159 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008160 peerMacAddress[idx].bytes[0],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008161 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008162 peerMacAddress[idx].bytes[1],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008163 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008164 peerMacAddress[idx].bytes[2],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008165 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008166 peerMacAddress[idx].bytes[3],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008167 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008168 peerMacAddress[idx].bytes[4],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008169 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008170 peerMacAddress[idx].bytes[5]
8171 );
8172 length += buf;
8173 }
8174 }
8175 wrqu->data.length = strlen(extra) + 1;
8176 break;
8177 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008178 case WE_GET_PHYMODE:
8179 {
8180 bool ch_bond24 = false, ch_bond5g = false;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008181 struct hdd_context *hddctx = WLAN_HDD_GET_CTX(adapter);
8182 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008183 eCsrPhyMode phymode;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008184 enum band_info currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008185 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008186
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008187 sme_config = qdf_mem_malloc(sizeof(*sme_config));
8188 if (!sme_config) {
8189 hdd_err("Out of memory");
8190 ret = -ENOMEM;
8191 break;
8192 }
8193
8194 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008195 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008196 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008197 ch_bond24 = true;
8198
8199 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008200 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008201 ch_bond5g = true;
8202
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008203 qdf_mem_free(sme_config);
8204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008205 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308206 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008207 sme_get_freq_band(hal, &currBand))) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008208 hdd_err("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008209 return -EIO;
8210 }
8211
8212 switch (phymode) {
8213 case eCSR_DOT11_MODE_AUTO:
8214 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
8215 break;
8216 case eCSR_DOT11_MODE_11n:
8217 case eCSR_DOT11_MODE_11n_ONLY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008218 if (currBand == BAND_2G) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008219 if (ch_bond24)
8220 snprintf(extra, WE_MAX_STR_LEN,
8221 "11NGHT40");
8222 else
8223 snprintf(extra, WE_MAX_STR_LEN,
8224 "11NGHT20");
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008225 } else if (currBand == BAND_5G) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008226 if (ch_bond5g)
8227 snprintf(extra, WE_MAX_STR_LEN,
8228 "11NAHT40");
8229 else
8230 snprintf(extra, WE_MAX_STR_LEN,
8231 "11NAHT20");
8232 } else {
8233 snprintf(extra, WE_MAX_STR_LEN, "11N");
8234 }
8235 break;
8236 case eCSR_DOT11_MODE_abg:
8237 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
8238 break;
8239 case eCSR_DOT11_MODE_11a:
8240 snprintf(extra, WE_MAX_STR_LEN, "11A");
8241 break;
8242 case eCSR_DOT11_MODE_11b:
8243 case eCSR_DOT11_MODE_11b_ONLY:
8244 snprintf(extra, WE_MAX_STR_LEN, "11B");
8245 break;
8246 case eCSR_DOT11_MODE_11g:
8247 case eCSR_DOT11_MODE_11g_ONLY:
8248 snprintf(extra, WE_MAX_STR_LEN, "11G");
8249 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008250 case eCSR_DOT11_MODE_11ac:
8251 case eCSR_DOT11_MODE_11ac_ONLY:
8252 if (hddctx->config->vhtChannelWidth ==
8253 eHT_CHANNEL_WIDTH_20MHZ)
8254 snprintf(extra, WE_MAX_STR_LEN,
8255 "11ACVHT20");
8256 else if (hddctx->config->vhtChannelWidth ==
8257 eHT_CHANNEL_WIDTH_40MHZ)
8258 snprintf(extra, WE_MAX_STR_LEN,
8259 "11ACVHT40");
8260 else if (hddctx->config->vhtChannelWidth ==
8261 eHT_CHANNEL_WIDTH_80MHZ)
8262 snprintf(extra, WE_MAX_STR_LEN,
8263 "11ACVHT80");
8264 else if (hddctx->config->vhtChannelWidth ==
8265 eHT_CHANNEL_WIDTH_160MHZ)
8266 snprintf(extra, WE_MAX_STR_LEN,
8267 "11ACVHT160");
8268 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08008269 case eCSR_DOT11_MODE_11ax:
8270 case eCSR_DOT11_MODE_11ax_ONLY:
8271 /* currently using vhtChannelWidth */
8272 if (hddctx->config->vhtChannelWidth ==
8273 eHT_CHANNEL_WIDTH_20MHZ)
8274 snprintf(extra, WE_MAX_STR_LEN,
8275 "11AX_HE_20");
8276 else if (hddctx->config->vhtChannelWidth ==
8277 eHT_CHANNEL_WIDTH_40MHZ)
8278 snprintf(extra, WE_MAX_STR_LEN,
8279 "11AX_HE_40");
8280 else if (hddctx->config->vhtChannelWidth ==
8281 eHT_CHANNEL_WIDTH_80MHZ)
8282 snprintf(extra, WE_MAX_STR_LEN,
8283 "11AX_HE_80");
8284 else if (hddctx->config->vhtChannelWidth ==
8285 eHT_CHANNEL_WIDTH_160MHZ)
8286 snprintf(extra, WE_MAX_STR_LEN,
8287 "11AX_HE_160");
8288 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008289 }
8290
8291 wrqu->data.length = strlen(extra) + 1;
8292 break;
8293 }
8294
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008295 case WE_GET_OEM_DATA_CAP:
Naveen Rawat910726a2017-03-06 11:42:51 -08008296 return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008297 case WE_GET_SNR:
8298 {
8299 int8_t s7snr = 0;
8300 int status = 0;
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008301 struct hdd_context *hdd_ctx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07008302 struct hdd_station_ctx *sta_ctx;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008303
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008304 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008305 status = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308306 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008307 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308308
Jeff Johnsond377dce2017-10-04 10:32:42 -07008309 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008310 if (0 == hdd_ctx->config->fEnableSNRMonitoring ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008311 eConnectionState_Associated !=
Jeff Johnsond377dce2017-10-04 10:32:42 -07008312 sta_ctx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008313 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008314 hdd_ctx->config->fEnableSNRMonitoring,
Jeff Johnsond377dce2017-10-04 10:32:42 -07008315 sta_ctx->conn_info.connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008316 return -ENONET;
8317 }
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008318 wlan_hdd_get_snr(adapter, &s7snr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008319 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
8320 wrqu->data.length = strlen(extra) + 1;
8321 break;
8322 }
8323 default:
8324 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008325 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008326 sub_cmd);
8327 break;
8328 }
8329 }
Dustin Brownd9322482017-01-09 12:46:03 -08008330
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308331 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -08008332 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008333}
8334
8335static int iw_get_char_setnone(struct net_device *dev,
8336 struct iw_request_info *info,
8337 union iwreq_data *wrqu, char *extra)
8338{
8339 int ret;
8340
8341 cds_ssr_protect(__func__);
8342 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
8343 cds_ssr_unprotect(__func__);
8344
8345 return ret;
8346}
8347
8348/**
8349 * iw_setnone_getnone() - Generic "action" private ioctl handler
8350 * @dev: device upon which the ioctl was received
8351 * @info: ioctl request information
8352 * @wrqu: ioctl request data
8353 * @extra: ioctl extra data
8354 *
8355 * Return: 0 on success, non-zero on error
8356 */
8357static int __iw_setnone_getnone(struct net_device *dev,
8358 struct iw_request_info *info,
8359 union iwreq_data *wrqu, char *extra)
8360{
Jeff Johnson3d278b02017-08-29 14:17:47 -07008361 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008362 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008363 int ret;
8364 int sub_cmd;
8365
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008366 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308367
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008368 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008369 ret = wlan_hdd_validate_context(hdd_ctx);
8370 if (0 != ret)
8371 return ret;
8372
Jeff Johnson441e1f72017-02-07 08:50:49 -08008373 ret = hdd_check_private_wext_control(hdd_ctx, info);
8374 if (0 != ret)
8375 return ret;
8376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008377#ifdef CONFIG_COMPAT
8378 /* this ioctl is a special case where a sub-ioctl is used and both
8379 * the number of get and set args is 0. in this specific case the
8380 * logic in iwpriv places the sub_cmd in the data.flags portion of
8381 * the iwreq. unfortunately the location of this field will be
8382 * different between 32-bit and 64-bit userspace, and the standard
8383 * compat support in the kernel does not handle this case. so we
8384 * need to explicitly handle it here.
8385 */
8386 if (is_compat_task()) {
8387 struct compat_iw_point *compat_iw_point =
8388 (struct compat_iw_point *)&wrqu->data;
8389 sub_cmd = compat_iw_point->flags;
8390 } else {
8391 sub_cmd = wrqu->data.flags;
8392 }
8393#else
8394 sub_cmd = wrqu->data.flags;
8395#endif
8396
8397 switch (sub_cmd) {
8398 case WE_GET_RECOVERY_STAT:
8399 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008400 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008401
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008402 sme_get_recovery_stats(hal);
8403 break;
8404 }
8405
Govind Singha471e5e2015-10-12 17:11:14 +05308406 case WE_GET_FW_PROFILE_DATA:
Jeff Johnson1b780e42017-10-31 14:11:45 -07008407 ret = wma_cli_set_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +05308408 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
8409 0, DBG_CMD);
8410 break;
8411
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008412 case WE_IBSS_GET_PEER_INFO_ALL:
8413 {
8414 hdd_wlan_get_ibss_peer_info_all(adapter);
8415 break;
8416 }
8417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008418 case WE_SET_REASSOC_TRIGGER:
8419 {
Jeff Johnson3d278b02017-08-29 14:17:47 -07008420 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008421
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008422 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308423 tSirMacAddr bssid;
Krunal Sonibfd05492017-10-03 15:48:37 -07008424 uint32_t roamId = INVALID_ROAM_ID;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308425 uint8_t operating_ch =
Jeff Johnsonb9424862017-10-30 08:49:35 -07008426 adapter->session.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008427 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008428
Jeff Johnson1b780e42017-10-31 14:11:45 -07008429 sme_get_modify_profile_fields(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008430 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308431 if (roaming_offload_enabled(hdd_ctx)) {
8432 qdf_mem_copy(bssid,
Jeff Johnsonb9424862017-10-30 08:49:35 -07008433 &adapter->session.station.conn_info.bssId,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308434 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -08008435 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308436 bssid, operating_ch);
8437 } else {
Jeff Johnson1b780e42017-10-31 14:11:45 -07008438 sme_roam_reassoc(hdd_ctx->hHal, adapter->session_id,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308439 NULL, modProfileFields, &roamId, 1);
8440 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008441 return 0;
8442 }
8443
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008444 case WE_STOP_OBSS_SCAN:
8445 {
8446 /*
8447 * 1.OBSS Scan is mandatory while operating in 2.4GHz
8448 * 2.OBSS scan is stopped by Firmware during the disassociation
8449 * 3.OBSS stop comamnd is added for debugging purpose
8450 */
8451 tHalHandle hal;
8452
8453 hal = WLAN_HDD_GET_HAL_CTX(adapter);
8454 if (hal == NULL) {
8455 hdd_err("hal context is NULL");
8456 return -EINVAL;
8457 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07008458 sme_ht40_stop_obss_scan(hal, adapter->session_id);
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008459 }
8460 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008461 default:
8462 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008463 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008464 break;
8465 }
8466 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308467 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008468 return ret;
8469}
8470
8471static int iw_setnone_getnone(struct net_device *dev,
8472 struct iw_request_info *info,
8473 union iwreq_data *wrqu, char *extra)
8474{
8475 int ret;
8476
8477 cds_ssr_protect(__func__);
8478 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
8479 cds_ssr_unprotect(__func__);
8480
8481 return ret;
8482}
8483
Krunal Sonia6e505b2017-01-12 12:25:18 -08008484#ifdef MPC_UT_FRAMEWORK
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008485static int iw_get_policy_manager_ut_ops(struct hdd_context *hdd_ctx,
Jeff Johnson3d278b02017-08-29 14:17:47 -07008486 struct hdd_adapter *adapter, int sub_cmd, int *apps_args)
Krunal Sonia6e505b2017-01-12 12:25:18 -08008487{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -08008488 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08008489 case WE_POLICY_MANAGER_CLIST_CMD:
8490 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008491 hdd_debug("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008492 policy_mgr_incr_connection_count_utfw(hdd_ctx->hdd_psoc,
8493 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
8494 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008495 }
8496 break;
8497
8498 case WE_POLICY_MANAGER_DLIST_CMD:
8499 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008500 hdd_debug("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008501 policy_mgr_decr_connection_count_utfw(hdd_ctx->hdd_psoc,
8502 apps_args[0], apps_args[1]);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008503 }
8504 break;
8505
8506 case WE_POLICY_MANAGER_ULIST_CMD:
8507 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008508 hdd_debug("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008509 policy_mgr_update_connection_info_utfw(hdd_ctx->hdd_psoc,
8510 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
8511 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008512 }
8513 break;
8514
8515 case WE_POLICY_MANAGER_DBS_CMD:
8516 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008517 hdd_debug("<iwpriv wlan0 pm_dbs> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -08008518 if (apps_args[0] == 0)
8519 wma_set_dbs_capability_ut(0);
8520 else
8521 wma_set_dbs_capability_ut(1);
8522
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008523 if (apps_args[1] >= PM_THROUGHPUT &&
8524 apps_args[1] <= PM_LATENCY) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08008525 pr_info("setting system pref to [%d]\n", apps_args[1]);
8526 hdd_ctx->config->conc_system_pref = apps_args[1];
8527 }
8528 }
8529 break;
8530
8531 case WE_POLICY_MANAGER_PCL_CMD:
8532 {
8533 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8534 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
8535 uint32_t pcl_len = 0, i = 0;
8536
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07008537 hdd_debug("<iwpriv wlan0 pm_pcl> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -08008538
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008539 policy_mgr_get_pcl(hdd_ctx->hdd_psoc, apps_args[0],
Krunal Sonia6e505b2017-01-12 12:25:18 -08008540 pcl, &pcl_len,
8541 weight_list, QDF_ARRAY_SIZE(weight_list));
8542 pr_info("PCL list for role[%d] is {", apps_args[0]);
8543 for (i = 0 ; i < pcl_len; i++)
8544 pr_info(" %d, ", pcl[i]);
8545 pr_info("}--------->\n");
8546 }
8547 break;
8548
8549 case WE_POLICY_SET_HW_MODE_CMD:
8550 {
8551 if (apps_args[0] == 0) {
8552 hdd_err("set hw mode for single mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008553 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07008554 adapter->session_id,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008555 HW_MODE_SS_2x2,
8556 HW_MODE_80_MHZ,
8557 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8558 HW_MODE_DBS_NONE,
8559 HW_MODE_AGILE_DFS_NONE,
8560 HW_MODE_SBS_NONE,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08008561 SIR_UPDATE_REASON_UT, PM_NOP);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008562 } else if (apps_args[0] == 1) {
8563 hdd_err("set hw mode for dual mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008564 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07008565 adapter->session_id,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008566 HW_MODE_SS_1x1,
8567 HW_MODE_80_MHZ,
8568 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8569 HW_MODE_DBS,
8570 HW_MODE_AGILE_DFS_NONE,
8571 HW_MODE_SBS_NONE,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08008572 SIR_UPDATE_REASON_UT, PM_NOP);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008573 }
8574 }
8575 break;
8576
8577 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8578 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008579 enum policy_mgr_conc_next_action action;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008580
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07008581 hdd_debug("<iwpriv wlan0 pm_query_action> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008582 action = policy_mgr_current_connections_update(
8583 hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07008584 adapter->session_id, apps_args[0],
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008585 SIR_UPDATE_REASON_UT);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008586 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8587 }
8588 break;
8589
8590 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8591 {
8592 bool allow;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008593
8594 hdd_notice("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008595 allow = policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008596 apps_args[0], apps_args[1], apps_args[2]);
8597 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8598 }
8599 break;
8600
8601 case WE_POLICY_MANAGER_SCENARIO_CMD:
8602 {
8603 clean_report(hdd_ctx);
8604 if (apps_args[0] == 1) {
8605 wlan_hdd_one_connection_scenario(hdd_ctx);
8606 } else if (apps_args[0] == 2) {
8607 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008608 6, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008609 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008610 36, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008611 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008612 6, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008613 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008614 36, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008615 } else if (apps_args[0] == 3) {
8616 /* MCC on same band with 2x2 same mac*/
8617 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008618 6, 11, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008619 /* MCC on diff band with 2x2 same mac*/
8620 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008621 6, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008622 /* MCC on diff band with 1x1 diff mac */
8623 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008624 36, 6, POLICY_MGR_ONE_ONE, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008625 /* MCC on diff band with 1x1 same mac */
8626 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008627 36, 6, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008628 /* SCC on same band with 2x2 same mac */
8629 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008630 36, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008631 /* SCC on same band with 1x1 same mac */
8632 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008633 36, 36, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008634 /* MCC on same band with 2x2 same mac */
8635 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008636 36, 149, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008637 /* MCC on same band with 1x1 same mac */
8638 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008639 36, 149, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008640 }
8641 print_report(hdd_ctx);
8642 }
8643 break;
8644 }
8645 return 0;
8646}
8647#else
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008648static int iw_get_policy_manager_ut_ops(struct hdd_context *hdd_ctx,
Jeff Johnson3d278b02017-08-29 14:17:47 -07008649 struct hdd_adapter *adapter, int sub_cmd, int *apps_args)
Krunal Sonia6e505b2017-01-12 12:25:18 -08008650{
8651 return 0;
8652}
8653#endif
8654
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008655/**
Liangwei Dong2a7f2912018-02-07 17:08:17 +08008656 * hdd_ch_avoid_unit_cmd - unit test ch avoidance
8657 * @hdd_ctx: hdd_context
8658 * @num_args: input args number
8659 * @apps_args: args data ptr
8660 *
8661 * This is to inject a ch avoid event to do unit test SAP chan avoidance.
8662 *
8663 * Return: void
8664 */
8665#if WLAN_DEBUG
8666static void hdd_ch_avoid_unit_cmd(struct hdd_context *hdd_ctx,
8667 int num_args, int *apps_args)
8668{
8669 struct ch_avoid_ind_type ch_avoid;
8670 int cnt = 0, i;
8671
8672 if (num_args < 2 || num_args > CH_AVOID_MAX_RANGE * 2 ||
8673 num_args % 2 != 0)
8674 return;
8675 hdd_info("simulate ch avoid num_args %d", num_args);
8676 for (i = 0; i < num_args && i < CH_AVOID_MAX_RANGE * 2; i++) {
8677 ch_avoid.avoid_freq_range[cnt].start_freq =
8678 apps_args[i];
8679 ch_avoid.avoid_freq_range[cnt].end_freq =
8680 apps_args[++i];
8681
8682 hdd_info("simulate ch avoid [%d %d]",
8683 ch_avoid.avoid_freq_range[cnt].start_freq,
8684 ch_avoid.avoid_freq_range[cnt].end_freq);
8685 cnt++;
8686 }
8687 ch_avoid.ch_avoid_range_cnt = cnt;
8688 ucfg_reg_unit_simulate_ch_avoid(hdd_ctx->hdd_psoc, &ch_avoid);
8689}
8690#else
8691static void hdd_ch_avoid_unit_cmd(struct hdd_context *hdd_ctx,
8692 int num_args, int *apps_args)
8693{
8694}
8695#endif
8696/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008697 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8698 * @dev: device upon which the ioctl was received
8699 * @info: ioctl request information
8700 * @wrqu: ioctl request data
8701 * @extra: ioctl extra data
8702 *
8703 * This is an SSR-protected generic handler for private ioctls which
8704 * take multiple arguments. Note that this implementation is also
8705 * somewhat unique in that it is shared by both STA-mode and SAP-mode
8706 * interfaces.
8707 *
8708 * Return: 0 on success, non-zero on error
8709 */
8710static int __iw_set_var_ints_getnone(struct net_device *dev,
8711 struct iw_request_info *info,
8712 union iwreq_data *wrqu, char *extra)
8713{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008714 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8715 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008716 int sub_cmd;
8717 int *apps_args = (int *) extra;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008718 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008719 int ret, num_args;
8720
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008721 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308722
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008723 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008724 ret = wlan_hdd_validate_context(hdd_ctx);
8725 if (0 != ret)
8726 return ret;
8727
Jeff Johnson441e1f72017-02-07 08:50:49 -08008728 ret = hdd_check_private_wext_control(hdd_ctx, info);
8729 if (0 != ret)
8730 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008731
8732 sub_cmd = wrqu->data.flags;
8733 num_args = wrqu->data.length;
8734
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008735 hdd_debug("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008736
8737 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008738 case WE_IBSS_GET_PEER_INFO:
8739 {
8740 pr_info("Station ID = %d\n", apps_args[0]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008741 hdd_wlan_get_ibss_peer_info(adapter, apps_args[0]);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008742 }
8743 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008744
8745 case WE_P2P_NOA_CMD:
8746 {
Srinivas Girigowda5d5fdc52017-03-24 22:30:57 -07008747 struct p2p_app_set_ps p2pNoA;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008748
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008749 if (adapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08008750 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
8751 hdd_device_mode_to_string(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008752 adapter->device_mode),
8753 adapter->device_mode);
Rajeev Kumar274034c2015-11-23 11:28:58 -08008754 return -EINVAL;
8755 }
8756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008757 p2pNoA.opp_ps = apps_args[0];
8758 p2pNoA.ctWindow = apps_args[1];
8759 p2pNoA.duration = apps_args[2];
8760 p2pNoA.interval = apps_args[3];
8761 p2pNoA.count = apps_args[4];
8762 p2pNoA.single_noa_duration = apps_args[5];
8763 p2pNoA.psSelection = apps_args[6];
8764
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008765 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 -07008766 apps_args[0], apps_args[1], apps_args[2],
8767 apps_args[3], apps_args[4],
8768 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008769
8770 hdd_set_p2p_ps(dev, &p2pNoA);
8771
8772 }
8773 break;
8774
8775 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8776 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008777 hdd_debug("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
Jeff Johnson99bac312016-06-28 10:38:18 -07008778 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308779 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008780 }
8781 break;
8782
8783 case WE_MTRACE_DUMP_CMD:
8784 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008785 hdd_debug("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
Jeff Johnson99bac312016-06-28 10:38:18 -07008786 apps_args[0], apps_args[1],
8787 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308788 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008789 apps_args[1], apps_args[2],
8790 apps_args[3]);
8791
8792 }
8793 break;
8794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008795 case WE_POLICY_MANAGER_CINFO_CMD:
8796 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008797 struct policy_mgr_conc_connection_info *conn_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008798 uint32_t i = 0, len = 0;
8799
Krunal Sonia6e505b2017-01-12 12:25:18 -08008800 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008801 conn_info = policy_mgr_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008802 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008803 for (i = 0; i < len; i++) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07008804 pr_info("|table_index[%d]\t\t\n", i);
8805 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
8806 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
8807 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
8808 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
8809 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
8810 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
8811 pr_info("+--------------------------+\n");
8812 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008813 }
8814 }
8815 break;
8816
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008817 case WE_UNIT_TEST_CMD:
8818 {
Krunal Soniaadaa272017-10-04 16:42:55 -07008819 QDF_STATUS status;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008820
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008821 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8822 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Krunal Soniaadaa272017-10-04 16:42:55 -07008823 hdd_err("Invalid MODULE ID %d", apps_args[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008824 return -EINVAL;
8825 }
Krunal Soniaadaa272017-10-04 16:42:55 -07008826 if ((apps_args[1] >= (WMA_MAX_NUM_ARGS)) ||
Anurag Chouhan77564182016-09-03 16:38:01 +05308827 (apps_args[1] < 0)) {
Krunal Soniaadaa272017-10-04 16:42:55 -07008828 hdd_err("Too Many/Few args %d", apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008829 return -EINVAL;
8830 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07008831 status = sme_send_unit_test_cmd(adapter->session_id,
Krunal Soniaadaa272017-10-04 16:42:55 -07008832 apps_args[0],
8833 apps_args[1],
8834 &apps_args[2]);
8835 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson21d63bb2017-10-07 17:45:33 -07008836 hdd_err("sme_send_unit_test_cmd returned %d", status);
8837 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008838 }
8839 }
8840 break;
8841#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8842 case WE_LED_FLASHING_PARAM:
8843 {
8844 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008845
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008846 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008847 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008848 return -EINVAL;
8849 }
8850 for (i = 0; i < num_args; i++) {
8851 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008852 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008853 return -EINVAL;
8854 }
8855 }
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008856 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008857 0, apps_args[0], apps_args[1]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008858 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008859 1, apps_args[2], apps_args[3]);
8860 }
8861 break;
8862#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05308863 case WE_SET_PKTLOG:
8864 {
8865 int ret;
8866
8867 if (num_args < 1 || num_args > 2) {
8868 hdd_err("pktlog: either 1 or 2 parameters are required");
8869 return -EINVAL;
8870 }
8871
8872 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
8873 apps_args[1]);
8874 if (ret)
8875 return ret;
8876 break;
8877 }
8878
Manjeet Singhf82ed072016-07-08 11:40:00 +05308879 case WE_MAC_PWR_DEBUG_CMD:
8880 {
8881 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008882 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Manjeet Singhf82ed072016-07-08 11:40:00 +05308883 int i, j;
8884
8885 if (num_args < 3) {
8886 hdd_err("number of arguments can't be null %d",
8887 num_args);
8888 return -EINVAL;
8889 }
8890 if (num_args - 3 != apps_args[2]) {
8891 hdd_err("arg list of size %d doesn't match num_args %d",
8892 num_args-3, apps_args[2]);
8893 return -EINVAL;
8894 }
8895 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8896 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8897 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8898 return -EINVAL;
8899 }
8900 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8901 hdd_err("Too Many args %d", apps_args[2]);
8902 return -EINVAL;
8903 }
8904 mac_pwr_dbg_args.pdev_id = apps_args[0];
8905 mac_pwr_dbg_args.module_id = apps_args[1];
8906 mac_pwr_dbg_args.num_args = apps_args[2];
8907
8908 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8909 mac_pwr_dbg_args.args[i] = apps_args[j];
8910
8911 if (QDF_STATUS_SUCCESS !=
Jeff Johnson1b780e42017-10-31 14:11:45 -07008912 sme_process_mac_pwr_dbg_cmd(hal, adapter->session_id,
Manjeet Singhf82ed072016-07-08 11:40:00 +05308913 &mac_pwr_dbg_args)) {
8914 return -EINVAL;
8915 }
8916 }
8917 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -08008918 case WE_POLICY_MANAGER_CLIST_CMD:
8919 case WE_POLICY_MANAGER_DLIST_CMD:
8920 case WE_POLICY_MANAGER_ULIST_CMD:
8921 case WE_POLICY_MANAGER_DBS_CMD:
8922 case WE_POLICY_MANAGER_PCL_CMD:
8923 case WE_POLICY_SET_HW_MODE_CMD:
8924 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8925 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8926 case WE_POLICY_MANAGER_SCENARIO_CMD:
8927 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008928 iw_get_policy_manager_ut_ops(hdd_ctx, adapter,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008929 sub_cmd, apps_args);
8930 }
8931 break;
Liangwei Dong2a7f2912018-02-07 17:08:17 +08008932 case WE_SET_CHAN_AVOID:
8933 {
8934 hdd_ch_avoid_unit_cmd(hdd_ctx, num_args, apps_args);
8935 }
8936 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008937 default:
8938 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008939 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008940 }
8941 break;
8942 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308943 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008944 return 0;
8945}
8946
8947/**
8948 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8949 * @dev: pointer to net_device structure
8950 * @info: pointer to iw_request_info structure
8951 * @wrqu: pointer to iwreq_data
8952 * @extra; extra
8953 *
8954 * Return: 0 on success, error number otherwise
8955 *
8956 */
8957static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8958 struct iw_request_info *info,
8959 union iwreq_data *wrqu, char *extra)
8960{
8961 union iwreq_data u_priv_wrqu;
8962 int apps_args[MAX_VAR_ARGS] = {0};
8963 int ret, num_args;
8964
Mukul Sharma64a70e82015-11-02 20:05:09 +05308965 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008966 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308967 return -EPERM;
8968 }
8969
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008970 /* Helper function to get iwreq_data with compat handling. */
8971 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8972 return -EINVAL;
8973
8974 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008975 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008976 return -EINVAL;
8977 }
8978
8979 num_args = u_priv_wrqu.data.length;
8980 if (num_args > MAX_VAR_ARGS)
8981 num_args = MAX_VAR_ARGS;
8982
8983 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8984 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008985 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008986 return -EFAULT;
8987 }
8988
8989 cds_ssr_protect(__func__);
8990 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8991 (char *)&apps_args);
8992 cds_ssr_unprotect(__func__);
8993 return ret;
8994}
8995
8996/**
8997 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8998 * @dev: device upon which the ioctl was received
8999 * @info: ioctl request information
9000 * @wrqu: ioctl request data
9001 * @extra: ioctl extra data
9002 *
9003 * This is a generic handler for private ioctls which take multiple
9004 * arguments. Note that this implementation is also somewhat unique
9005 * in that it is shared by both STA-mode and SAP-mode interfaces.
9006 *
9007 * Return: 0 on success, non-zero on error
9008 */
9009int iw_set_var_ints_getnone(struct net_device *dev,
9010 struct iw_request_info *info,
9011 union iwreq_data *wrqu, char *extra)
9012{
9013 int ret;
9014
9015 cds_ssr_protect(__func__);
9016 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
9017 cds_ssr_unprotect(__func__);
9018 return ret;
9019}
9020
9021/**
9022 * iw_add_tspec - Add TSpec private ioctl handler
9023 * @dev: device upon which the ioctl was received
9024 * @info: ioctl request information
9025 * @wrqu: ioctl request data
9026 * @extra: ioctl extra data
9027 *
9028 * Return: 0 on success, non-zero on error
9029 */
9030static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
9031 union iwreq_data *wrqu, char *extra)
9032{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009033 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -07009034 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009035 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9036 int params[HDD_WLAN_WMM_PARAM_COUNT];
Abhishek Singh12be60f2017-08-11 13:52:42 +05309037 struct sme_qos_wmmtspecinfo tSpec;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009038 uint32_t handle;
9039 struct iw_point s_priv_data;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009040 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009041 int ret;
9042
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009043 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309044
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009045 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009046 ret = wlan_hdd_validate_context(hdd_ctx);
9047 if (0 != ret)
9048 return ret;
9049
Jeff Johnson441e1f72017-02-07 08:50:49 -08009050 ret = hdd_check_private_wext_control(hdd_ctx, info);
9051 if (0 != ret)
9052 return ret;
9053
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009054 /* make sure the application is sufficiently priviledged */
9055 /* note that the kernel will do this for "set" ioctls, but since */
9056 /* this ioctl wants to return status to user space it must be */
9057 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009058 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009059 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009060
9061 /* we must be associated in order to add a tspec */
Jeff Johnsond377dce2017-10-04 10:32:42 -07009062 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009063 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9064 return 0;
9065 }
9066 /* since we are defined to be a "get" ioctl, and since the number */
9067 /* of params exceeds the number of params that wireless extensions */
9068 /* will pass down in the iwreq_data, we must copy the "set" params. */
9069 /* We must handle the compat for iwreq_data in 32U/64K environment. */
9070
9071 /* helper function to get iwreq_data with compat handling. */
9072 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
9073 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9074 return 0;
9075 }
9076 /* make sure all params are correctly passed to function */
9077 if ((NULL == s_priv_data.pointer) ||
9078 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
9079 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9080 return 0;
9081 }
9082 /* from user space ourselves */
9083 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
9084 /* hmmm, can't get them */
9085 return -EIO;
9086 }
9087 /* clear the tspec */
9088 memset(&tSpec, 0, sizeof(tSpec));
9089
9090 /* validate the handle */
9091 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9092 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9093 /* that one is reserved */
9094 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9095 return 0;
9096 }
9097 /* validate the TID */
9098 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
9099 /* out of range */
9100 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9101 return 0;
9102 }
9103 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
9104
9105 /* validate the direction */
9106 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
9107 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
9108 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
9109 break;
9110
9111 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
9112 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
9113 break;
9114
9115 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
9116 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
9117 break;
9118
9119 default:
9120 /* unknown */
9121 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9122 return 0;
9123 }
9124
9125 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
9126
9127 /* validate the user priority */
9128 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
9129 /* out of range */
9130 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9131 return 0;
9132 }
9133 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
9134 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009135 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009136 return 0;
9137 }
9138
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009139 hdd_debug("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009140 tSpec.ts_info.psb, tSpec.ts_info.up);
9141
9142 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
9143 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
9144 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
9145 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
9146 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
9147 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
9148 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
9149 tSpec.surplus_bw_allowance =
9150 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
9151 tSpec.min_service_interval =
9152 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
9153 tSpec.max_service_interval =
9154 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
9155 tSpec.suspension_interval =
9156 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
9157 tSpec.inactivity_interval =
9158 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
9159
9160 tSpec.ts_info.burst_size_defn =
9161 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
9162
9163 /* validate the ts info ack policy */
9164 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
9165 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
9166 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
9167 break;
9168
9169 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
9170 tSpec.ts_info.ack_policy =
9171 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
9172 break;
9173
9174 default:
9175 /* unknown */
9176 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9177 return 0;
9178 }
9179
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009180 *pStatus = hdd_wmm_addts(adapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309181 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009182 return 0;
9183}
9184
9185static int iw_add_tspec(struct net_device *dev,
9186 struct iw_request_info *info,
9187 union iwreq_data *wrqu, char *extra)
9188{
9189 int ret;
9190
9191 cds_ssr_protect(__func__);
9192 ret = __iw_add_tspec(dev, info, wrqu, extra);
9193 cds_ssr_unprotect(__func__);
9194
9195 return ret;
9196}
9197
9198/**
9199 * iw_del_tspec - Delete TSpec private ioctl handler
9200 * @dev: device upon which the ioctl was received
9201 * @info: ioctl request information
9202 * @wrqu: ioctl request data
9203 * @extra: ioctl extra data
9204 *
9205 * Return: 0 on success, non-zero on error
9206 */
9207static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
9208 union iwreq_data *wrqu, char *extra)
9209{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009210 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009211 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009212 int *params = (int *)extra;
9213 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9214 uint32_t handle;
9215 int ret;
9216
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009217 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309218
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009219 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009220 ret = wlan_hdd_validate_context(hdd_ctx);
9221 if (0 != ret)
9222 return ret;
9223
Jeff Johnson441e1f72017-02-07 08:50:49 -08009224 ret = hdd_check_private_wext_control(hdd_ctx, info);
9225 if (0 != ret)
9226 return ret;
9227
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009228 /* make sure the application is sufficiently priviledged */
9229 /* note that the kernel will do this for "set" ioctls, but since */
9230 /* this ioctl wants to return status to user space it must be */
9231 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009232 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009233 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009234
9235 /* although we are defined to be a "get" ioctl, the params we require */
9236 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9237 /* is no need to copy the params from user space */
9238
9239 /* validate the handle */
9240 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9241 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9242 /* that one is reserved */
9243 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9244 return 0;
9245 }
9246
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009247 *pStatus = hdd_wmm_delts(adapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309248 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009249 return 0;
9250}
9251
9252static int iw_del_tspec(struct net_device *dev,
9253 struct iw_request_info *info,
9254 union iwreq_data *wrqu, char *extra)
9255{
9256 int ret;
9257
9258 cds_ssr_protect(__func__);
9259 ret = __iw_del_tspec(dev, info, wrqu, extra);
9260 cds_ssr_unprotect(__func__);
9261
9262 return ret;
9263}
9264
9265/**
9266 * iw_get_tspec - Get TSpec private ioctl handler
9267 * @dev: device upon which the ioctl was received
9268 * @info: ioctl request information
9269 * @wrqu: ioctl request data
9270 * @extra: ioctl extra data
9271 *
9272 * Return: 0 on success, non-zero on error
9273 */
9274static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
9275 union iwreq_data *wrqu, char *extra)
9276{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009277 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009278 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009279 int *params = (int *)extra;
9280 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9281 uint32_t handle;
9282 int ret;
9283
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009284 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309285
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009286 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009287 ret = wlan_hdd_validate_context(hdd_ctx);
9288 if (0 != ret)
9289 return ret;
9290
Jeff Johnson441e1f72017-02-07 08:50:49 -08009291 ret = hdd_check_private_wext_control(hdd_ctx, info);
9292 if (0 != ret)
9293 return ret;
9294
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009295 /* although we are defined to be a "get" ioctl, the params we require */
9296 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9297 /* is no need to copy the params from user space */
9298
9299 /* validate the handle */
9300 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9301 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9302 /* that one is reserved */
9303 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9304 return 0;
9305 }
9306
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009307 *pStatus = hdd_wmm_checkts(adapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309308 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009309 return 0;
9310}
9311
9312static int iw_get_tspec(struct net_device *dev,
9313 struct iw_request_info *info,
9314 union iwreq_data *wrqu, char *extra)
9315{
9316 int ret;
9317
9318 cds_ssr_protect(__func__);
9319 ret = __iw_get_tspec(dev, info, wrqu, extra);
9320 cds_ssr_unprotect(__func__);
9321
9322 return ret;
9323}
9324
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009325/**
9326 * iw_set_fties - Set FT IEs private ioctl handler
9327 * @dev: device upon which the ioctl was received
9328 * @info: ioctl request information
9329 * @wrqu: ioctl request data
9330 * @extra: ioctl extra data
9331 *
9332 * Each time the supplicant has the auth_request or reassoc request
9333 * IEs ready they are pushed to the driver. The driver will in turn
9334 * use it to send out the auth req and reassoc req for 11r FT Assoc.
9335 *
9336 * Return: 0 on success, non-zero on error
9337 */
9338static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
9339 union iwreq_data *wrqu, char *extra)
9340{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009341 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -07009342 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009343 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009344 int ret;
9345
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009346 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309347
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009348 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009349 ret = wlan_hdd_validate_context(hdd_ctx);
9350 if (0 != ret)
9351 return ret;
9352
Jeff Johnson441e1f72017-02-07 08:50:49 -08009353 ret = hdd_check_private_wext_control(hdd_ctx, info);
9354 if (0 != ret)
9355 return ret;
9356
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009357 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009358 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009359 return -EINVAL;
9360 }
9361 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009362 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009363 return -EINVAL;
9364 }
9365 /* Added for debug on reception of Re-assoc Req. */
Jeff Johnsond377dce2017-10-04 10:32:42 -07009366 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009367 hdd_debug("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009368 wrqu->data.length);
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009369 hdd_debug("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009370 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009371 hdd_debug("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009372
9373 /* Pass the received FT IEs to SME */
Jeff Johnson1b780e42017-10-31 14:11:45 -07009374 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(adapter), adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009375 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309376 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009377 return 0;
9378}
9379
9380static int iw_set_fties(struct net_device *dev,
9381 struct iw_request_info *info,
9382 union iwreq_data *wrqu, char *extra)
9383{
9384 int ret;
9385
9386 cds_ssr_protect(__func__);
9387 ret = __iw_set_fties(dev, info, wrqu, extra);
9388 cds_ssr_unprotect(__func__);
9389
9390 return ret;
9391}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009392
Dustin Brown0cbc7572016-12-16 13:54:40 -08009393/**
9394 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
9395 * @dev: device upon which the ioctl was received
9396 * @info: ioctl request information
9397 * @wrqu: ioctl request data
9398 * @extra: ioctl extra data
9399 *
Dustin Brown860566f2017-01-31 15:24:43 -08009400 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
9401 * time being to provide guidance in migrating to standard APIs.
9402 *
Dustin Brown0cbc7572016-12-16 13:54:40 -08009403 * Return: 0 on success, non-zero on error
9404 */
9405static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
9406 struct iw_request_info *info,
9407 union iwreq_data *wrqu,
9408 char *extra)
9409{
Dustin Brown860566f2017-01-31 15:24:43 -08009410 hdd_err("\n"
9411 "setMCBCFilter is obsolete. Use the following instead:\n"
9412 "Configure multicast filtering via the ‘ip’ command.\n"
9413 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
9414 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
9415 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
9416 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
9417 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07009418 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -08009419}
9420
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009421/**
9422 * iw_set_host_offload - Set host offload ioctl handler
9423 * @dev: device upon which the ioctl was received
9424 * @info: ioctl request information
9425 * @wrqu: ioctl request data
9426 * @extra: ioctl extra data
9427 *
9428 * Return: 0 on success, non-zero on error
9429 */
9430static int __iw_set_host_offload(struct net_device *dev,
9431 struct iw_request_info *info,
9432 union iwreq_data *wrqu, char *extra)
9433{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009434 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowda077143e2017-03-25 10:47:27 -07009435 struct host_offload_req *pRequest = (struct host_offload_req *) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009436 tSirHostOffloadReq offloadRequest;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009437 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009438 int ret;
9439
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009440 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309441
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009442 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009443 ret = wlan_hdd_validate_context(hdd_ctx);
9444 if (0 != ret)
9445 return ret;
9446
Jeff Johnson441e1f72017-02-07 08:50:49 -08009447 ret = hdd_check_private_wext_control(hdd_ctx, info);
9448 if (0 != ret)
9449 return ret;
9450
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009451 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009452 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009453 return -EINVAL;
9454 }
9455
9456 /* Debug display of request components. */
9457 switch (pRequest->offloadType) {
9458 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009459 hdd_debug("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009460 switch (pRequest->enableOrDisable) {
9461 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009462 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009463 break;
9464 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009465 hdd_debug(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009466 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009467 hdd_debug(" ARP offload enable");
9468 hdd_debug(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009469 pRequest->params.hostIpv4Addr[0],
9470 pRequest->params.hostIpv4Addr[1],
9471 pRequest->params.hostIpv4Addr[2],
9472 pRequest->params.hostIpv4Addr[3]);
9473 }
9474 break;
9475
9476 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009477 hdd_debug("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009478 switch (pRequest->enableOrDisable) {
9479 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009480 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009481 break;
9482 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009483 hdd_debug(" enable");
9484 hdd_debug(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009485 *(uint16_t *) (pRequest->params.hostIpv6Addr),
9486 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9487 2),
9488 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9489 4),
9490 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9491 6),
9492 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9493 8),
9494 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9495 10),
9496 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9497 12),
9498 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9499 14));
9500 }
9501 }
9502
Hanumanth Reddy Pothula8fcade52017-12-01 13:49:40 +05309503 qdf_mem_zero(&offloadRequest, sizeof(offloadRequest));
9504 offloadRequest.offloadType = pRequest->offloadType;
9505 offloadRequest.enableOrDisable = pRequest->enableOrDisable;
9506 qdf_mem_copy(&offloadRequest.params, &pRequest->params,
9507 sizeof(pRequest->params));
9508 qdf_mem_copy(&offloadRequest.bssid, &pRequest->bssId.bytes,
9509 QDF_MAC_ADDR_SIZE);
9510
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309511 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009512 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07009513 adapter->session_id, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009514 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009515 return -EINVAL;
9516 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309517 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009518 return 0;
9519}
9520
9521static int iw_set_host_offload(struct net_device *dev,
9522 struct iw_request_info *info,
9523 union iwreq_data *wrqu, char *extra)
9524{
9525 int ret;
9526
9527 cds_ssr_protect(__func__);
9528 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9529 cds_ssr_unprotect(__func__);
9530
9531 return ret;
9532}
9533
9534/**
9535 * iw_set_keepalive_params - Set keepalive params ioctl handler
9536 * @dev: device upon which the ioctl was received
9537 * @info: ioctl request information
9538 * @wrqu: ioctl request data
9539 * @extra: ioctl extra data
9540 *
9541 * Return: 0 on success, non-zero on error
9542 */
9543static int __iw_set_keepalive_params(struct net_device *dev,
9544 struct iw_request_info *info,
9545 union iwreq_data *wrqu, char *extra)
9546{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009547 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009548 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009549 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009550 int ret;
9551
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009552 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309553
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009554 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009555 ret = wlan_hdd_validate_context(hdd_ctx);
9556 if (0 != ret)
9557 return ret;
9558
Jeff Johnson441e1f72017-02-07 08:50:49 -08009559 ret = hdd_check_private_wext_control(hdd_ctx, info);
9560 if (0 != ret)
9561 return ret;
9562
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009563 if (wrqu->data.length != sizeof(*request)) {
9564 hdd_err("Invalid length %d", wrqu->data.length);
9565 return -EINVAL;
9566 }
9567
9568 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
9569 hdd_err("Value of timePeriod %d exceed Max limit %d",
9570 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009571 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
9572 return -EINVAL;
9573 }
9574
9575 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009576 hdd_debug("Set Keep Alive Request : TimePeriod %d size %zu",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009577 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009578
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009579 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009580 case WLAN_KEEP_ALIVE_NULL_PKT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009581 hdd_debug("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009582 break;
9583
9584 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009585 hdd_debug("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009586
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009587 hdd_debug("Host IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009588 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
9589 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009590
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009591 hdd_debug("Dest IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009592 request->destIpv4Addr[0], request->destIpv4Addr[1],
9593 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009594
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009595 hdd_debug("Dest MAC address: "MAC_ADDRESS_STR,
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08009596 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009597 break;
9598 }
9599
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009600 hdd_debug("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009601
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309602 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009603 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07009604 adapter->session_id, request)) {
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009605 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009606 return -EINVAL;
9607 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309608 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009609 return 0;
9610}
9611
9612static int iw_set_keepalive_params(struct net_device *dev,
9613 struct iw_request_info *info,
9614 union iwreq_data *wrqu,
9615 char *extra)
9616{
9617 int ret;
9618
9619 cds_ssr_protect(__func__);
9620 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9621 cds_ssr_unprotect(__func__);
9622
9623 return ret;
9624}
9625
9626#ifdef WLAN_FEATURE_PACKET_FILTERING
9627/**
9628 * wlan_hdd_set_filter() - Set packet filter
9629 * @hdd_ctx: Global HDD context
9630 * @request: Packet filter request struct
9631 * @sessionId: Target session for the request
9632 *
9633 * Return: 0 on success, non-zero on error
9634 */
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +05309635int wlan_hdd_set_filter(struct hdd_context *hdd_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009636 struct pkt_filter_cfg *request,
9637 uint8_t sessionId)
9638{
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309639 struct pmo_rcv_pkt_fltr_cfg *pmo_set_pkt_fltr_req = NULL;
9640 struct pmo_rcv_pkt_fltr_clear_param *pmo_clr_pkt_fltr_param = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009641 int i = 0;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309642 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009643
9644 if (hdd_ctx->config->disablePacketFilter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009645 hdd_warn("Packet filtering disabled in ini");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009646 return 0;
9647 }
9648
9649 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009650 hdd_debug("Packet Filter Request : FA %d params %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009651 request->filter_action, request->num_params);
9652
9653 switch (request->filter_action) {
9654 case HDD_RCV_FILTER_SET:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009655 hdd_debug("Set Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009656 request->filter_id);
9657
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309658 pmo_set_pkt_fltr_req =
9659 qdf_mem_malloc(sizeof(*pmo_set_pkt_fltr_req));
9660 if (!pmo_set_pkt_fltr_req) {
Mukul Sharmad75a6672017-06-22 15:40:53 +05309661 hdd_err("unable to allocate pmo_set_pkt_fltr_req");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309662 return QDF_STATUS_E_NOMEM;
9663 }
9664
9665 pmo_set_pkt_fltr_req->filter_id = request->filter_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009666 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
9667 hdd_err("Number of Params exceed Max limit %d",
9668 request->num_params);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309669 status = QDF_STATUS_E_INVAL;
9670 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009671 }
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309672 pmo_set_pkt_fltr_req->num_params = request->num_params;
9673 pmo_set_pkt_fltr_req->coalesce_time = 0;
Srinivas Girigowdabbbecad2017-06-28 16:01:48 -07009674 pmo_set_pkt_fltr_req->filter_type = PMO_RCV_FILTER_TYPE_FILTER_PKT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009675 for (i = 0; i < request->num_params; i++) {
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309676 pmo_set_pkt_fltr_req->params_data[i].protocol_layer =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009677 request->params_data[i].protocol_layer;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309678 pmo_set_pkt_fltr_req->params_data[i].compare_flag =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009679 request->params_data[i].compare_flag;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309680 pmo_set_pkt_fltr_req->params_data[i].data_offset =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009681 request->params_data[i].data_offset;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309682 pmo_set_pkt_fltr_req->params_data[i].data_length =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009683 request->params_data[i].data_length;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309684 pmo_set_pkt_fltr_req->params_data[i].reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009685
Dustin Brown4d1e8462016-12-14 12:12:24 -08009686 if (request->params_data[i].data_offset >
9687 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
9688 hdd_err("Invalid data offset %u for param %d (max = %d)",
9689 request->params_data[i].data_offset,
9690 i,
9691 SIR_MAX_FILTER_TEST_DATA_OFFSET);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309692 status = QDF_STATUS_E_INVAL;
9693 goto out;
Dustin Brown4d1e8462016-12-14 12:12:24 -08009694 }
9695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009696 if (request->params_data[i].data_length >
9697 SIR_MAX_FILTER_TEST_DATA_LEN) {
9698 hdd_err("Error invalid data length %d",
9699 request->params_data[i].data_length);
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
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009704 hdd_debug("Proto %d Comp Flag %d Filter Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009705 request->params_data[i].protocol_layer,
9706 request->params_data[i].compare_flag,
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309707 pmo_set_pkt_fltr_req->filter_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009708
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009709 hdd_debug("Data Offset %d Data Len %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009710 request->params_data[i].data_offset,
9711 request->params_data[i].data_length);
9712
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309713 if (sizeof(
9714 pmo_set_pkt_fltr_req->params_data[i].compare_data)
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07009715 < (request->params_data[i].data_length)) {
9716 hdd_err("Error invalid data length %d",
9717 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309718 status = QDF_STATUS_E_INVAL;
9719 goto out;
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07009720 }
9721
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309722 memcpy(
9723 &pmo_set_pkt_fltr_req->params_data[i].compare_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009724 request->params_data[i].compare_data,
9725 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309726 memcpy(&pmo_set_pkt_fltr_req->params_data[i].data_mask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009727 request->params_data[i].data_mask,
9728 request->params_data[i].data_length);
9729
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009730 hdd_debug("CData %d CData %d CData %d CData %d CData %d CData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009731 request->params_data[i].compare_data[0],
9732 request->params_data[i].compare_data[1],
9733 request->params_data[i].compare_data[2],
9734 request->params_data[i].compare_data[3],
9735 request->params_data[i].compare_data[4],
9736 request->params_data[i].compare_data[5]);
9737
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009738 hdd_debug("MData %d MData %d MData %d MData %d MData %d MData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009739 request->params_data[i].data_mask[0],
9740 request->params_data[i].data_mask[1],
9741 request->params_data[i].data_mask[2],
9742 request->params_data[i].data_mask[3],
9743 request->params_data[i].data_mask[4],
9744 request->params_data[i].data_mask[5]);
9745 }
9746
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309747 if (QDF_STATUS_SUCCESS !=
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309748 pmo_ucfg_set_pkt_filter(hdd_ctx->hdd_psoc,
9749 pmo_set_pkt_fltr_req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009750 sessionId)) {
9751 hdd_err("Failure to execute Set Filter");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309752 status = QDF_STATUS_E_INVAL;
9753 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009754 }
9755
9756 break;
9757
9758 case HDD_RCV_FILTER_CLEAR:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009759 hdd_debug("Clear Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009760 request->filter_id);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309761
9762 pmo_clr_pkt_fltr_param = qdf_mem_malloc(
9763 sizeof(*pmo_clr_pkt_fltr_param));
9764 if (!pmo_clr_pkt_fltr_param) {
9765 hdd_err("unable to allocate pmo_clr_pkt_fltr_param");
9766 return QDF_STATUS_E_NOMEM;
9767 }
9768
9769 pmo_clr_pkt_fltr_param->filter_id = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309770 if (QDF_STATUS_SUCCESS !=
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309771 pmo_ucfg_clear_pkt_filter(hdd_ctx->hdd_psoc,
9772 pmo_clr_pkt_fltr_param,
9773 sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009774 hdd_err("Failure to execute Clear Filter");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309775 status = QDF_STATUS_E_INVAL;
9776 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009777 }
9778 break;
9779
9780 default:
9781 hdd_err("Packet Filter Request: Invalid %d",
9782 request->filter_action);
9783 return -EINVAL;
9784 }
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309785
9786out:
9787 if (pmo_set_pkt_fltr_req)
9788 qdf_mem_free(pmo_set_pkt_fltr_req);
9789 if (pmo_clr_pkt_fltr_param)
9790 qdf_mem_free(pmo_clr_pkt_fltr_param);
9791
9792 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009793}
9794
9795/**
9796 * __iw_set_packet_filter_params() - set packet filter parameters in target
9797 * @dev: Pointer to netdev
9798 * @info: Pointer to iw request info
9799 * @wrqu: Pointer to data
9800 * @extra: Pointer to extra data
9801 *
9802 * Return: 0 on success, non-zero on error
9803 */
9804static int __iw_set_packet_filter_params(struct net_device *dev,
9805 struct iw_request_info *info,
9806 union iwreq_data *wrqu, char *extra)
9807{
9808 int ret;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009809 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009810 struct iw_point priv_data;
Jeff Johnson3d278b02017-08-29 14:17:47 -07009811 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009812 struct pkt_filter_cfg *request = NULL;
9813
Mukul Sharma472382f2015-11-02 20:16:31 +05309814 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009815 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309816 return -EPERM;
9817 }
9818
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009819 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309820
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009821 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9822 ret = wlan_hdd_validate_context(hdd_ctx);
9823 if (0 != ret)
9824 return ret;
9825
Jeff Johnson441e1f72017-02-07 08:50:49 -08009826 ret = hdd_check_private_wext_control(hdd_ctx, info);
9827 if (0 != ret)
9828 return ret;
9829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009830 if (hdd_priv_get_data(&priv_data, wrqu)) {
9831 hdd_err("failed to get priv data");
9832 return -EINVAL;
9833 }
9834
9835 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07009836 hdd_err("invalid priv data %pK or invalid priv data length %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009837 priv_data.pointer, priv_data.length);
9838 return -EINVAL;
9839 }
9840
Arun Khandavalli75d246b2017-08-07 19:46:06 +05309841 if (adapter->device_mode != QDF_STA_MODE) {
9842 hdd_err("Packet filter not supported for this mode :%d",
9843 adapter->device_mode);
9844 return -ENOTSUPP;
9845 }
9846
Mukul Sharmabe846bb2017-05-09 17:41:52 +05309847 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) {
9848 hdd_err("Packet filter not supported in disconnected state");
9849 return -ENOTSUPP;
9850 }
9851
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009852 /* copy data using copy_from_user */
9853 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9854 priv_data.length);
9855 if (NULL == request) {
9856 hdd_err("mem_alloc_copy_from_user_helper fail");
9857 return -ENOMEM;
9858 }
9859
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +05309860 if (request->filter_action == HDD_RCV_FILTER_SET)
9861 hdd_ctx->user_configured_pkt_filter_rules |=
9862 1 << request->filter_id;
9863 else if (request->filter_action == HDD_RCV_FILTER_CLEAR)
9864 hdd_ctx->user_configured_pkt_filter_rules &=
9865 ~(1 << request->filter_id);
9866
Jeff Johnson1b780e42017-10-31 14:11:45 -07009867 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009868
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07009869 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309870 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009871 return ret;
9872}
9873
9874/**
9875 * iw_set_packet_filter_params() - set packet filter parameters in target
9876 * @dev: Pointer to netdev
9877 * @info: Pointer to iw request info
9878 * @wrqu: Pointer to data
9879 * @extra: Pointer to extra data
9880 *
9881 * Return: 0 on success, non-zero on error
9882 */
9883static int iw_set_packet_filter_params(struct net_device *dev,
9884 struct iw_request_info *info,
9885 union iwreq_data *wrqu, char *extra)
9886{
9887 int ret;
9888
9889 cds_ssr_protect(__func__);
9890 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9891 cds_ssr_unprotect(__func__);
9892
9893 return ret;
9894}
9895#endif
9896
9897
9898static int __iw_get_statistics(struct net_device *dev,
9899 struct iw_request_info *info,
9900 union iwreq_data *wrqu, char *extra)
9901{
9902
Anurag Chouhance0dc992016-02-16 18:18:03 +05309903 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309904 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson2a722002017-09-30 20:02:35 -07009905 struct hdd_wext_state *pWextState;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009906 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9907 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009908 char *p = extra;
9909 int tlen = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009910 tCsrSummaryStatsInfo *pStats = &(adapter->hdd_stats.summary_stat);
Jeff Johnson861dd4f2017-10-24 10:10:40 -07009911 tCsrGlobalClassAStatsInfo *aStats = &(adapter->hdd_stats.class_a_stat);
Jeff Johnsonf8cadec2017-10-24 10:21:25 -07009912 tCsrGlobalClassDStatsInfo *dStats = &(adapter->hdd_stats.class_d_stat);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009913 int ret;
9914
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009915 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009916
9917 ret = wlan_hdd_validate_context(hdd_ctx);
9918 if (0 != ret)
9919 return ret;
9920
Jeff Johnson441e1f72017-02-07 08:50:49 -08009921 ret = hdd_check_private_wext_control(hdd_ctx, info);
9922 if (0 != ret)
9923 return ret;
9924
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009925 if (eConnectionState_Associated !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009926 (WLAN_HDD_GET_STATION_CTX_PTR(adapter))->conn_info.connState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009927
9928 wrqu->txpower.value = 0;
9929 } else {
9930 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9931 SME_SUMMARY_STATS |
9932 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -08009933 SME_GLOBAL_CLASSD_STATS,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07009934 hdd_statistics_cb,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009935 (WLAN_HDD_GET_STATION_CTX_PTR
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009936 (adapter))->conn_info.staId[0],
Jeff Johnson1b780e42017-10-31 14:11:45 -07009937 adapter, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009938
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309939 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009940 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009941 return -EINVAL;
9942 }
9943
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009944 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009945
Nachiket Kukade0396b732017-11-14 16:35:16 +05309946 qdf_status = qdf_wait_for_event_completion(
9947 &pWextState->hdd_qdf_event,
9948 WLAN_WAIT_TIME_STATS);
9949
Anurag Chouhance0dc992016-02-16 18:18:03 +05309950 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009951 hdd_err("SME timeout while retrieving statistics");
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009952 /* Remove the SME statistics list by
9953 * passing NULL in callback argument
9954 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009955 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9956 SME_SUMMARY_STATS |
9957 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -08009958 SME_GLOBAL_CLASSD_STATS,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07009959 NULL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009960 (WLAN_HDD_GET_STATION_CTX_PTR
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009961 (adapter))->conn_info.
9962 staId[0], adapter,
Jeff Johnson1b780e42017-10-31 14:11:45 -07009963 adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009964
9965 return -EINVAL;
9966 }
9967 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
9968 (uint8_t) sizeof(pStats->retry_cnt),
9969 (char *)&(pStats->retry_cnt[0]), tlen);
9970
9971 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
9972 (uint8_t) sizeof(pStats->multiple_retry_cnt),
9973 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
9974
9975 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
9976 (uint8_t) sizeof(pStats->tx_frm_cnt),
9977 (char *)&(pStats->tx_frm_cnt[0]), tlen);
9978
9979 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
9980 (uint8_t) sizeof(pStats->rx_frm_cnt),
9981 (char *)&(pStats->rx_frm_cnt), tlen);
9982
9983 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
9984 (uint8_t) sizeof(pStats->frm_dup_cnt),
9985 (char *)&(pStats->frm_dup_cnt), tlen);
9986
9987 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
9988 (uint8_t) sizeof(pStats->fail_cnt),
9989 (char *)&(pStats->fail_cnt[0]), tlen);
9990
9991 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
9992 (uint8_t) sizeof(pStats->rts_fail_cnt),
9993 (char *)&(pStats->rts_fail_cnt), tlen);
9994
9995 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
9996 (uint8_t) sizeof(pStats->ack_fail_cnt),
9997 (char *)&(pStats->ack_fail_cnt), tlen);
9998
9999 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
10000 (uint8_t) sizeof(pStats->rts_succ_cnt),
10001 (char *)&(pStats->rts_succ_cnt), tlen);
10002
10003 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
10004 (uint8_t) sizeof(pStats->rx_discard_cnt),
10005 (char *)&(pStats->rx_discard_cnt), tlen);
10006
10007 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
10008 (uint8_t) sizeof(pStats->rx_error_cnt),
10009 (char *)&(pStats->rx_error_cnt), tlen);
10010
10011 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
10012 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
10013 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
10014
10015 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
10016 (uint8_t) sizeof(dStats->rx_byte_cnt),
10017 (char *)&(dStats->rx_byte_cnt), tlen);
10018
10019 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
10020 (uint8_t) sizeof(dStats->rx_rate),
10021 (char *)&(dStats->rx_rate), tlen);
10022
10023 /* Transmit rate, in units of 500 kbit/sec */
10024 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
10025 (uint8_t) sizeof(aStats->tx_rate),
10026 (char *)&(aStats->tx_rate), tlen);
10027
10028 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
10029 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
10030 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
10031 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
10032 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
10033 (char *)&(dStats->rx_mc_byte_cnt), tlen);
10034 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
10035 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
10036 (char *)&(dStats->rx_bc_byte_cnt), tlen);
10037 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
10038 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
10039 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
10040 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
10041 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
10042 (char *)&(dStats->tx_mc_byte_cnt), tlen);
10043 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
10044 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
10045 (char *)&(dStats->tx_bc_byte_cnt), tlen);
10046
10047 wrqu->data.length = tlen;
10048
10049 }
10050
10051 EXIT();
10052
10053 return 0;
10054}
10055
10056static int iw_get_statistics(struct net_device *dev,
10057 struct iw_request_info *info,
10058 union iwreq_data *wrqu, char *extra)
10059{
10060 int ret;
10061
10062 cds_ssr_protect(__func__);
10063 ret = __iw_get_statistics(dev, info, wrqu, extra);
10064 cds_ssr_unprotect(__func__);
10065
10066 return ret;
10067}
10068
10069#ifdef FEATURE_WLAN_SCAN_PNO
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010070/*Max Len for PNO notification*/
10071#define MAX_PNO_NOTIFY_LEN 100
Abhishek Singh0481d662017-04-11 18:20:11 +053010072static void found_pref_network_cb(struct wlan_objmgr_vdev *vdev,
10073 struct scan_event *event, void *args)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010074{
Abhishek Singh0481d662017-04-11 18:20:11 +053010075 struct vdev_osif_priv *osif_priv;
10076 struct wireless_dev *wdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010077 union iwreq_data wrqu;
10078 char buf[MAX_PNO_NOTIFY_LEN + 1];
10079
Abhishek Singh0481d662017-04-11 18:20:11 +053010080 wlan_vdev_obj_lock(vdev);
10081 osif_priv = wlan_vdev_get_ospriv(vdev);
10082 wlan_vdev_obj_unlock(vdev);
10083 if (!osif_priv) {
10084 hdd_err("osif_priv is null");
10085 return;
10086 }
10087
10088 wdev = osif_priv->wdev;
10089 if (!wdev) {
10090 hdd_err("wdev is null");
10091 return;
10092 }
10093
10094 hdd_debug("A preferred network was found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010095
10096 /* create the event */
Abhishek Singh0481d662017-04-11 18:20:11 +053010097 qdf_mem_zero(&wrqu, sizeof(wrqu));
10098 qdf_mem_zero(buf, sizeof(buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010099
10100 snprintf(buf, MAX_PNO_NOTIFY_LEN,
Abhishek Singh0481d662017-04-11 18:20:11 +053010101 "QCOM: Found preferred network:");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010102
10103 wrqu.data.pointer = buf;
10104 wrqu.data.length = strlen(buf);
10105
10106 /* send the event */
10107
Abhishek Singh0481d662017-04-11 18:20:11 +053010108 wireless_send_event(wdev->netdev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010109}
10110
10111/**
10112 * __iw_set_pno() - Preferred Network Offload ioctl handler
10113 * @dev: device upon which the ioctl was received
10114 * @info: ioctl request information
10115 * @wrqu: ioctl request data
10116 * @extra: ioctl extra data
10117 *
10118 * This function parses a Preferred Network Offload command
10119 * Input is string based and expected to be of the form:
10120 *
10121 * <enable(1) | disable(0)>
10122 * when enabling:
10123 * <number of networks>
10124 * for each network:
10125 * <ssid_len> <ssid> <authentication> <encryption>
10126 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070010127 * <scan_time (seconds)>
10128 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010129 * <suspend mode>
10130 *
10131 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070010132 * 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 -080010133 *
10134 * this translates into:
10135 * -----------------------------
10136 * enable PNO
10137 * 2 networks
10138 * Network 1:
10139 * test - with authentication type 0 and encryption type 0,
10140 * search on 3 channels: 1 6 and 11,
10141 * SSID bcast type is unknown (directed probe will be sent if
10142 * AP not found) and must meet -40dBm RSSI
10143 * Network 2:
10144 * test2 - with authentication type 4 and encryption type 4,
10145 * search on 6 channels 1, 2, 3, 4, 5 and 6
10146 * bcast type is non-bcast (directed probe will be sent)
10147 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010148 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070010149 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010150 */
10151static int __iw_set_pno(struct net_device *dev,
10152 struct iw_request_info *info,
10153 union iwreq_data *wrqu, char *extra)
10154{
Jeff Johnson3d278b02017-08-29 14:17:47 -070010155 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010156 struct hdd_context *hdd_ctx;
Abhishek Singh0481d662017-04-11 18:20:11 +053010157 uint8_t value;
10158 struct wlan_objmgr_vdev *vdev;
10159 struct wlan_objmgr_psoc *psoc;
10160 int ret = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010161 int offset;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010162 char *ptr, *data;
Abhishek Singh0481d662017-04-11 18:20:11 +053010163 uint8_t i, j, params;
10164 QDF_STATUS status;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010165 size_t len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010166
10167 /* request is a large struct, so we make it static to avoid
10168 * stack overflow. This API is only invoked via ioctl, so it
10169 * is serialized by the kernel rtnl_lock and hence does not
10170 * need to be reentrant
10171 */
Abhishek Singh0481d662017-04-11 18:20:11 +053010172 static struct pno_scan_req_params req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010173
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010174 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010175
10176 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10177 ret = wlan_hdd_validate_context(hdd_ctx);
10178 if (ret)
10179 return ret;
10180
Jeff Johnson441e1f72017-02-07 08:50:49 -080010181 ret = hdd_check_private_wext_control(hdd_ctx, info);
10182 if (0 != ret)
10183 return ret;
10184
Abhishek Singh0481d662017-04-11 18:20:11 +053010185 vdev = wlan_objmgr_get_vdev_by_macaddr_from_pdev(hdd_ctx->hdd_pdev,
10186 dev->dev_addr, WLAN_LEGACY_MAC_ID);
10187 if (!vdev) {
10188 hdd_err("vdev object is NULL");
10189 return -EIO;
10190 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010191
Abhishek Singh0481d662017-04-11 18:20:11 +053010192 hdd_debug("PNO data len %d data %s", wrqu->data.length, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010193
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010194 /* making sure argument string ends with '\0' */
10195 len = (wrqu->data.length + 1);
10196 data = qdf_mem_malloc(len);
10197 if (!data) {
10198 hdd_err("fail to allocate memory %zu", len);
10199 return -EINVAL;
10200 }
10201 qdf_mem_copy(data, extra, (len-1));
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010202 ptr = data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010203
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010204 if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010205 hdd_err("PNO enable input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010206 ret = -EINVAL;
10207 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010208 }
10209
Abhishek Singh0481d662017-04-11 18:20:11 +053010210 if (!value) {
10211 status = ucfg_scan_pno_stop(vdev);
10212 if (QDF_IS_STATUS_ERROR(status)) {
10213 hdd_err("Failed to disabled PNO");
10214 ret = -EINVAL;
10215 } else {
10216 hdd_debug("PNO scan disabled");
10217 }
10218 goto exit;
10219 }
10220
10221 if (ucfg_scan_get_pno_in_progress(vdev)) {
10222 hdd_debug("pno is already in progress");
10223 ret = -EBUSY;
10224 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010225 }
10226
10227 ptr += offset;
10228
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010229 if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010230 hdd_err("PNO count input not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010231 ret = -EINVAL;
10232 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010233 }
Abhishek Singh0481d662017-04-11 18:20:11 +053010234 req.networks_cnt = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010235
Abhishek Singh0481d662017-04-11 18:20:11 +053010236 hdd_debug("PNO enable networks count %d offset %d",
10237 req.networks_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010238
Abhishek Singh0481d662017-04-11 18:20:11 +053010239 if ((0 == req.networks_cnt) ||
10240 (req.networks_cnt > SCAN_PNO_MAX_SUPP_NETWORKS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010241 hdd_err("Network count %d invalid",
Abhishek Singh0481d662017-04-11 18:20:11 +053010242 req.networks_cnt);
10243 ret = -EINVAL;
10244 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010245 }
10246
10247 ptr += offset;
10248
Abhishek Singh0481d662017-04-11 18:20:11 +053010249 for (i = 0; i < req.networks_cnt; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010250
Abhishek Singh0481d662017-04-11 18:20:11 +053010251 req.networks_list[i].ssid.length = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010252
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010253 params = sscanf(ptr, " %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010254 &(req.networks_list[i].ssid.length),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010255 &offset);
10256
10257 if (1 != params) {
10258 hdd_err("PNO ssid length input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010259 ret = -EINVAL;
10260 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010261 }
10262
Abhishek Singh0481d662017-04-11 18:20:11 +053010263 if ((0 == req.networks_list[i].ssid.length) ||
10264 (req.networks_list[i].ssid.length > 32)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010265 hdd_err("SSID Len %d is not correct for network %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010266 req.networks_list[i].ssid.length, i);
10267 ret = -EINVAL;
10268 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010269 }
10270
10271 /* Advance to SSID */
10272 ptr += offset;
10273
Abhishek Singh0481d662017-04-11 18:20:11 +053010274 memcpy(req.networks_list[i].ssid.ssid, ptr,
10275 req.networks_list[i].ssid.length);
10276 ptr += req.networks_list[i].ssid.length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010277
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010278 params = sscanf(ptr, " %u %u %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010279 &(req.networks_list[i].authentication),
10280 &(req.networks_list[i].encryption),
10281 &(req.networks_list[i].channel_cnt),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010282 &offset);
10283
10284 if (3 != params) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010285 hdd_err("Incorrect cmd %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010286 ret = -EINVAL;
10287 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010288 }
10289
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010290 hdd_debug("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010291 req.networks_list[i].ssid.length,
10292 req.networks_list[i].ssid.length,
10293 req.networks_list[i].ssid.ssid,
10294 req.networks_list[i].authentication,
10295 req.networks_list[i].encryption,
10296 req.networks_list[i].channel_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010297
10298 /* Advance to channel list */
10299 ptr += offset;
10300
Abhishek Singh0481d662017-04-11 18:20:11 +053010301 if (SCAN_PNO_MAX_NETW_CHANNELS_EX <
10302 req.networks_list[i].channel_cnt) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010303 hdd_err("Incorrect number of channels");
Abhishek Singh0481d662017-04-11 18:20:11 +053010304 ret = -EINVAL;
10305 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010306 }
10307
Abhishek Singh0481d662017-04-11 18:20:11 +053010308 if (0 != req.networks_list[i].channel_cnt) {
10309 for (j = 0; j < req.networks_list[i].channel_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010310 j++) {
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010311 if (1 != sscanf(ptr, " %hhu %n", &value,
Abhishek Singh0481d662017-04-11 18:20:11 +053010312 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010313 hdd_err("PNO network channel is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010314 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010315 ret = -EINVAL;
10316 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010317 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010318 if (!IS_CHANNEL_VALID(value)) {
10319 hdd_err("invalid channel: %hhu", value);
10320 ret = -EINVAL;
10321 goto exit;
10322 }
Abhishek Singh0481d662017-04-11 18:20:11 +053010323 req.networks_list[i].channels[j] =
10324 cds_chan_to_freq(value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010325 /* Advance to next channel number */
10326 ptr += offset;
10327 }
10328 }
10329
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010330 if (1 != sscanf(ptr, " %u %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010331 &(req.networks_list[i].bc_new_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010332 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010333 hdd_err("PNO broadcast network type is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010334 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010335 ret = -EINVAL;
10336 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010337 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010338 if (req.networks_list[i].bc_new_type > 2) {
10339 hdd_err("invalid bcast nw type: %u",
10340 req.networks_list[i].bc_new_type);
10341 ret = -EINVAL;
10342 goto exit;
10343 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010344
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010345 hdd_debug("PNO bcastNetwType %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010346 req.networks_list[i].bc_new_type, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010347
10348 /* Advance to rssi Threshold */
10349 ptr += offset;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010350 if (1 != sscanf(ptr, " %d %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010351 &(req.networks_list[i].rssi_thresh),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010352 &offset)) {
10353 hdd_err("PNO rssi threshold input is not valid %s",
10354 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010355 ret = -EINVAL;
10356 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010357 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010358 hdd_debug("PNO rssi %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010359 req.networks_list[i].rssi_thresh, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010360 /* Advance to next network */
10361 ptr += offset;
10362 } /* For ucNetworkCount */
10363
Abhishek Singh0481d662017-04-11 18:20:11 +053010364 req.fast_scan_period = 0;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010365 if (sscanf(ptr, " %u %n", &(req.fast_scan_period), &offset) > 0) {
Abhishek Singh0481d662017-04-11 18:20:11 +053010366 req.fast_scan_period *= MSEC_PER_SEC;
Dustin Brown43e87292016-10-10 10:38:25 -070010367 ptr += offset;
10368 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010369 if (req.fast_scan_period == 0) {
10370 hdd_err("invalid fast scan period %u",
10371 req.fast_scan_period);
10372 ret = -EINVAL;
10373 goto exit;
10374 }
Dustin Brown43e87292016-10-10 10:38:25 -070010375
Abhishek Singh0481d662017-04-11 18:20:11 +053010376 req.fast_scan_max_cycles = 0;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010377 if (sscanf(ptr, " %hhu %n", &value,
Dustin Brown43e87292016-10-10 10:38:25 -070010378 &offset) > 0)
10379 ptr += offset;
Abhishek Singh0481d662017-04-11 18:20:11 +053010380 req.fast_scan_max_cycles = value;
Dustin Brown43e87292016-10-10 10:38:25 -070010381
Abhishek Singh0481d662017-04-11 18:20:11 +053010382 wlan_pdev_obj_lock(hdd_ctx->hdd_pdev);
10383 psoc = wlan_pdev_get_psoc(hdd_ctx->hdd_pdev);
10384 wlan_pdev_obj_unlock(hdd_ctx->hdd_pdev);
10385 ucfg_scan_register_pno_cb(psoc,
10386 found_pref_network_cb, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010387
Abhishek Singh0481d662017-04-11 18:20:11 +053010388 ucfg_scan_get_pno_def_params(vdev, &req);
10389 status = ucfg_scan_pno_start(vdev, &req);
10390 if (QDF_IS_STATUS_ERROR(status)) {
10391 hdd_err("Failed to enable PNO");
10392 ret = -EINVAL;
10393 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010394
Abhishek Singh0481d662017-04-11 18:20:11 +053010395exit:
10396 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010397
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010398 qdf_mem_free(data);
Abhishek Singh0481d662017-04-11 18:20:11 +053010399 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010400}
10401
10402static int iw_set_pno(struct net_device *dev,
10403 struct iw_request_info *info,
10404 union iwreq_data *wrqu, char *extra)
10405{
10406 int ret;
10407
10408 cds_ssr_protect(__func__);
10409 ret = __iw_set_pno(dev, info, wrqu, extra);
10410 cds_ssr_unprotect(__func__);
10411
10412 return ret;
10413}
10414#endif /* FEATURE_WLAN_SCAN_PNO */
10415
10416/* Common function to SetBand */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010417int hdd_reg_set_band(struct net_device *dev, u8 ui_band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010418{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010419 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
10420 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010421 enum band_info band;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010422 QDF_STATUS status;
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010423 struct hdd_context *hdd_ctx;
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010424 enum band_info currBand;
10425 enum band_info connectedBand;
10426 long lrc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010427
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010428 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010429
10430 switch (ui_band) {
10431 case WLAN_HDD_UI_BAND_AUTO:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010432 band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010433 break;
10434 case WLAN_HDD_UI_BAND_5_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010435 band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010436 break;
10437 case WLAN_HDD_UI_BAND_2_4_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010438 band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010439 break;
10440 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070010441 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010442 return -EINVAL;
10443 }
10444
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010445 hdd_debug("change band to %u", band);
10446
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010447 if ((band == BAND_2G && hdd_ctx->config->nBandCapability == 2) ||
Rajeev Kumar Sirasanagandla4c9b6752017-07-25 20:35:20 +053010448 (band == BAND_5G && hdd_ctx->config->nBandCapability == 1) ||
10449 (band == BAND_ALL && hdd_ctx->config->nBandCapability != 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010450 hdd_err("band value %u violate INI settings %u",
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010451 band, hdd_ctx->config->nBandCapability);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010452 return -EIO;
10453 }
10454
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010455 if (band == BAND_ALL) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010456 hdd_debug("Auto band received. Setting band same as ini value %d",
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010457 hdd_ctx->config->nBandCapability);
10458 band = hdd_ctx->config->nBandCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010459 }
10460
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010461 if (QDF_STATUS_SUCCESS != ucfg_reg_get_curr_band(hdd_ctx->hdd_pdev,
Amar Singhal58b45ef2017-08-01 13:43:54 -070010462 &currBand)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010463 hdd_debug("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010464 return -EIO;
10465 }
10466
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010467 if (currBand == band)
10468 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010469
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010470 hdd_ctx->curr_band = band;
Amar Singhal58b45ef2017-08-01 13:43:54 -070010471
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010472 /* Change band request received.
10473 * Abort pending scan requests, flush the existing scan results,
10474 * and change the band capability
10475 */
10476 hdd_debug("Current band value = %u, new setting %u ",
10477 currBand, band);
10478
Dustin Brown920397d2017-12-13 16:27:50 -080010479 hdd_for_each_adapter(hdd_ctx, adapter) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010480 hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010481 wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID,
Jeff Johnson1b780e42017-10-31 14:11:45 -070010482 adapter->session_id, INVALID_SCAN_ID, false);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010483 connectedBand = hdd_conn_get_connected_band(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010484 WLAN_HDD_GET_STATION_CTX_PTR(adapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010485
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010486 /* Handling is done only for STA and P2P */
10487 if (band != BAND_ALL &&
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010488 ((adapter->device_mode == QDF_STA_MODE) ||
10489 (adapter->device_mode == QDF_P2P_CLIENT_MODE)) &&
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010490 (hdd_conn_is_connected(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010491 WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010492 && (connectedBand != band)) {
10493 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010494
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010495 /* STA already connected on current
10496 * band, So issue disconnect first,
10497 * then change the band
10498 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010499
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010500 hdd_debug("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010501 hdd_device_mode_to_string(adapter->device_mode),
10502 adapter->device_mode, currBand, band);
10503 INIT_COMPLETION(adapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010504
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010505 status = sme_roam_disconnect(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010506 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -070010507 adapter->session_id,
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010508 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010509
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010510 if (QDF_STATUS_SUCCESS != status) {
10511 hdd_err("sme_roam_disconnect failure, status: %d",
Jeff Johnson99bac312016-06-28 10:38:18 -070010512 (int)status);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010513 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010514 }
10515
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010516 lrc = wait_for_completion_timeout(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010517 &adapter->disconnect_comp_var,
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010518 msecs_to_jiffies(
10519 WLAN_WAIT_TIME_DISCONNECT));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010520
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010521 if (lrc == 0) {
10522 hdd_err("Timeout while waiting for csr_roam_disconnect");
10523 return -ETIMEDOUT;
10524 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010525 }
10526
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010527 sme_scan_flush_result(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010528 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010529
Dustin Brown920397d2017-12-13 16:27:50 -080010530 if (QDF_IS_STATUS_ERROR(ucfg_reg_set_band(hdd_ctx->hdd_pdev, band))) {
10531 hdd_err("Failed to set the band value to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010532 return -EINVAL;
10533 }
10534
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010535 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010536}
10537
10538static int __iw_set_band_config(struct net_device *dev,
10539 struct iw_request_info *info,
10540 union iwreq_data *wrqu, char *extra)
10541{
Jeff Johnson3d278b02017-08-29 14:17:47 -070010542 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010543 struct hdd_context *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -080010544 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010545 int *value = (int *)extra;
10546
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010547 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010548
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010549 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010550 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010551 return -EPERM;
10552 }
10553
Jeff Johnson441e1f72017-02-07 08:50:49 -080010554 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10555 ret = hdd_check_private_wext_control(hdd_ctx, info);
10556 if (0 != ret)
10557 return ret;
10558
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010559 return hdd_reg_set_band(dev, value[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010560}
10561
10562static int iw_set_band_config(struct net_device *dev,
10563 struct iw_request_info *info,
10564 union iwreq_data *wrqu, char *extra)
10565{
10566 int ret;
10567
10568 cds_ssr_protect(__func__);
10569 ret = __iw_set_band_config(dev, info, wrqu, extra);
10570 cds_ssr_unprotect(__func__);
10571
10572 return ret;
10573}
10574
Arunk Khandavalli062fb032017-10-04 12:18:15 +053010575int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010576 uint32_t bandwidth)
10577{
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010578 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -070010579 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010580 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
10581 QDF_STATUS status;
10582 tHalHandle hal_hdl = hdd_ctx->hHal;
10583 struct qdf_mac_addr bssid;
10584 tCsrRoamProfile roam_profile;
Amar Singhal5cccafe2017-02-15 12:42:58 -080010585 struct ch_params ch_params;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010586
10587 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
10588 hdd_err("Not supported, device is not in monitor mode");
10589 return -EINVAL;
10590 }
10591
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010592 hdd_debug("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080010593 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010594 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
10595 roam_profile.ChannelInfo.numOfChannels = 1;
10596 roam_profile.phyMode = ch_info->phy_mode;
10597 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070010598 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010599
Jeff Johnson1e851a12017-10-28 14:36:12 -070010600 qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010601 QDF_MAC_ADDR_SIZE);
10602
10603 ch_params.ch_width = bandwidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070010604 wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params);
Manjunathappa Prakashc4dc9382017-03-07 18:50:33 -080010605 if (ch_params.ch_width == CH_WIDTH_INVALID) {
10606 hdd_err("Invalid capture channel or bandwidth for a country");
10607 return -EINVAL;
10608 }
Krunal Sonied3bc8e2018-01-26 12:13:34 -080010609 if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan,
10610 POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) {
10611 hdd_err("Failed to change hw mode");
10612 return -EINVAL;
10613 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070010614
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010615 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
10616 &roam_profile);
10617 if (status) {
10618 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
10619 status);
10620 }
10621
Arunk Khandavalli062fb032017-10-04 12:18:15 +053010622 adapter->mon_chan = chan;
10623 adapter->mon_bandwidth = bandwidth;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010624 return qdf_status_to_os_return(status);
10625}
10626
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010627static int printk_adapter(void *priv, const char *fmt, ...)
10628{
10629 int ret;
10630 va_list args;
10631
10632 va_start(args, fmt);
10633 ret = vprintk(fmt, args);
10634 ret += printk("\n");
10635 va_end(args);
10636
10637 return ret;
10638}
10639
10640#ifdef WMI_INTERFACE_EVENT_LOGGING
10641static void hdd_ioctl_log_buffer(int log_id, uint32_t count)
10642{
10643 qdf_abstract_print *print = &printk_adapter;
10644
10645 switch (log_id) {
10646 case HTC_CREDIT_HISTORY_LOG:
10647 print(NULL, "HTC Credit History (count %u)", count);
10648 cds_print_htc_credit_history(count, print, NULL);
10649 break;
10650 case COMMAND_LOG:
10651 print(NULL, "Command Log (count %u)", count);
10652 wma_print_wmi_cmd_log(count, print, NULL);
10653 break;
10654 case COMMAND_TX_CMP_LOG:
10655 print(NULL, "Command Tx Complete Log (count %u)", count);
10656 wma_print_wmi_cmd_tx_cmp_log(count, print, NULL);
10657 break;
10658 case MGMT_COMMAND_LOG:
10659 print(NULL, "Management Command Log (count %u)", count);
10660 wma_print_wmi_mgmt_cmd_log(count, print, NULL);
10661 break;
10662 case MGMT_COMMAND_TX_CMP_LOG:
10663 print(NULL, "Management Command Tx Complete Log (count %u)",
10664 count);
10665 wma_print_wmi_mgmt_cmd_tx_cmp_log(count, print, NULL);
10666 break;
10667 case EVENT_LOG:
10668 print(NULL, "Event Log (count %u)", count);
10669 wma_print_wmi_event_log(count, print, NULL);
10670 break;
10671 case RX_EVENT_LOG:
10672 print(NULL, "Rx Event Log (count %u)", count);
10673 wma_print_wmi_rx_event_log(count, print, NULL);
10674 break;
10675 case MGMT_EVENT_LOG:
10676 print(NULL, "Management Event Log (count %u)", count);
10677 wma_print_wmi_mgmt_event_log(count, print, NULL);
10678 break;
10679 default:
10680 print(NULL, "Invalid Log Id %d", log_id);
10681 break;
10682 }
10683}
10684#else
10685static inline void hdd_ioctl_log_buffer(int log_id, uint32_t count)
10686{
10687}
10688#endif /* WMI_INTERFACE_EVENT_LOGGING */
10689
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010690static int __iw_set_two_ints_getnone(struct net_device *dev,
10691 struct iw_request_info *info,
10692 union iwreq_data *wrqu, char *extra)
10693{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010694 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010695 int *value = (int *)extra;
10696 int sub_cmd = value[0];
10697 int ret;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010698 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010699
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010700 ENTER_DEV(dev);
10701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010702 ret = wlan_hdd_validate_context(hdd_ctx);
10703 if (0 != ret)
10704 return ret;
10705
Jeff Johnson441e1f72017-02-07 08:50:49 -080010706 ret = hdd_check_private_wext_control(hdd_ctx, info);
10707 if (0 != ret)
10708 return ret;
10709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010710 switch (sub_cmd) {
10711 case WE_SET_SMPS_PARAM:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010712 hdd_debug("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Jeff Johnson1b780e42017-10-31 14:11:45 -070010713 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010714 WMI_STA_SMPS_PARAM_CMDID,
10715 value[1] << WMA_SMPS_PARAM_VALUE_S
10716 | value[2],
10717 VDEV_CMD);
10718 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070010719#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010720 case WE_SET_FW_CRASH_INJECT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010721 hdd_debug("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010722 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053010723 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
10724 value[1], value[2]);
SaidiReddy Yenugacc733af2016-11-09 17:45:42 +053010725 if (!hdd_ctx->config->crash_inject_enabled) {
10726 hdd_err("Crash Inject ini disabled, Ignore Crash Inject");
10727 return 0;
10728 }
Yue Ma06152352017-06-20 18:08:58 -070010729 if (value[1] == 3) {
Anurag Chouhan4085ff72017-10-05 18:09:56 +053010730 cds_trigger_recovery(QDF_REASON_UNSPECIFIED);
Yue Ma06152352017-06-20 18:08:58 -070010731 return 0;
10732 }
Jeff Johnson1b780e42017-10-31 14:11:45 -070010733 ret = wma_cli_set2_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010734 GEN_PARAM_CRASH_INJECT,
10735 value[1], value[2], GEN_CMD);
10736 break;
10737#endif
Govind Singha471e5e2015-10-12 17:11:14 +053010738 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010739 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010740 value[1], value[2]);
Jeff Johnson1b780e42017-10-31 14:11:45 -070010741 ret = wma_cli_set2_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +053010742 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
10743 value[1], value[2], DBG_CMD);
10744 break;
10745 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070010746 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010747 value[1], value[2]);
Jeff Johnson1b780e42017-10-31 14:11:45 -070010748 ret = wma_cli_set2_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +053010749 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
10750 value[1], value[2], DBG_CMD);
10751 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010752 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
10753 hdd_debug("Ioctl to set dual fw mode config");
Tushnim Bhattacharyya49ed8ab2017-05-26 18:20:10 -070010754 if (hdd_ctx->config->dual_mac_feature_disable ==
10755 DISABLE_DBS_CXN_AND_SCAN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010756 hdd_err("Dual mac feature is disabled from INI");
10757 return -EPERM;
10758 }
10759 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010760 policy_mgr_set_dual_mac_fw_mode_config(hdd_ctx->hdd_psoc,
10761 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010762 break;
10763 case WE_DUMP_DP_TRACE_LEVEL:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010764 hdd_debug("WE_DUMP_DP_TRACE_LEVEL: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010765 value[1], value[2]);
10766 if (value[1] == DUMP_DP_TRACE)
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -070010767 qdf_dp_trace_dump_all(value[2],
10768 QDF_TRACE_DEFAULT_PDEV_ID);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053010769 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
10770 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053010771 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
10772 qdf_dp_trace_clear_buffer();
Mohit Khannaf8f96822017-05-17 17:11:59 -070010773 else if (value[1] == DISABLE_DP_TRACE_LIVE_MODE)
10774 qdf_dp_trace_disable_live_mode();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010775 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010776 case WE_SET_MON_MODE_CHAN:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010777 ret = wlan_hdd_set_mon_chan(adapter, value[1], value[2]);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010778 break;
Dustin Brown54096432017-02-23 13:00:44 -080010779 case WE_SET_WLAN_SUSPEND: {
Dustin Brown3ed3e9b2017-03-23 12:57:58 -070010780 hdd_info("STA unit-test suspend(%d, %d)", value[1], value[2]);
Dustin Brown54096432017-02-23 13:00:44 -080010781 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
10782 value[1], value[2]);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010783 break;
Dustin Brown54096432017-02-23 13:00:44 -080010784 }
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010785 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070010786 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010787 break;
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010788 case WE_LOG_BUFFER: {
10789 int log_id = value[1];
10790 uint32_t count = value[2] < 0 ? 0 : value[2];
10791
10792 hdd_ioctl_log_buffer(log_id, count);
10793
10794 break;
10795 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010796 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070010797 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010798 break;
10799 }
10800
10801 return ret;
10802}
10803
10804static int iw_set_two_ints_getnone(struct net_device *dev,
10805 struct iw_request_info *info,
10806 union iwreq_data *wrqu, char *extra)
10807{
10808 int ret;
10809
10810 cds_ssr_protect(__func__);
10811 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
10812 cds_ssr_unprotect(__func__);
10813
10814 return ret;
10815}
10816
10817/* Define the Wireless Extensions to the Linux Network Device structure */
10818/* A number of these routines are NULL (meaning they are not implemented.) */
10819
10820static const iw_handler we_handler[] = {
10821 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10822 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10823 (iw_handler) NULL, /* SIOCSIWNWID */
10824 (iw_handler) NULL, /* SIOCGIWNWID */
Jeff Johnson7b0f3a22017-10-15 21:25:28 -070010825 (iw_handler) NULL, /* SIOCSIWFREQ */
Jeff Johnson52002c02017-10-15 21:18:52 -070010826 (iw_handler) NULL, /* SIOCGIWFREQ */
Jeff Johnson31fd71a2017-10-15 21:13:09 -070010827 (iw_handler) NULL, /* SIOCSIWMODE */
Jeff Johnson88aa1a22017-10-15 21:06:34 -070010828 (iw_handler) NULL, /* SIOCGIWMODE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010829 (iw_handler) NULL, /* SIOCSIWSENS */
10830 (iw_handler) NULL, /* SIOCGIWSENS */
10831 (iw_handler) NULL, /* SIOCSIWRANGE */
10832 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10833 (iw_handler) NULL, /* SIOCSIWPRIV */
10834 (iw_handler) NULL, /* SIOCGIWPRIV */
10835 (iw_handler) NULL, /* SIOCSIWSTATS */
10836 (iw_handler) NULL, /* SIOCGIWSTATS */
10837 (iw_handler) NULL, /* SIOCSIWSPY */
10838 (iw_handler) NULL, /* SIOCGIWSPY */
10839 (iw_handler) NULL, /* SIOCSIWTHRSPY */
10840 (iw_handler) NULL, /* SIOCGIWTHRSPY */
Jeff Johnson5ff10172017-10-15 18:45:27 -070010841 (iw_handler) NULL, /* SIOCSIWAP */
Jeff Johnsonb07d3ff2017-10-15 18:38:53 -070010842 (iw_handler) NULL, /* SIOCGIWAP */
Jeff Johnson2165afc2017-10-15 18:33:12 -070010843 (iw_handler) NULL, /* SIOCSIWMLME */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010844 (iw_handler) NULL, /* SIOCGIWAPLIST */
Jeff Johnsond73a5432017-10-15 18:12:52 -070010845 (iw_handler) NULL, /* SIOCSIWSCAN */
10846 (iw_handler) NULL, /* SIOCGIWSCAN */
10847 (iw_handler) NULL, /* SIOCSIWESSID */
Jeff Johnson3c6c0ef2017-10-15 17:59:14 -070010848 (iw_handler) NULL, /* SIOCGIWESSID */
Jeff Johnson90448a82017-10-15 16:35:25 -070010849 (iw_handler) NULL, /* SIOCSIWNICKN */
Jeff Johnson22ba2a42017-10-15 15:53:39 -070010850 (iw_handler) NULL, /* SIOCGIWNICKN */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010851 (iw_handler) NULL, /* -- hole -- */
10852 (iw_handler) NULL, /* -- hole -- */
Jeff Johnson64b26982017-10-15 15:48:38 -070010853 (iw_handler) NULL, /* SIOCSIWRATE */
Jeff Johnson7b5b8e72017-10-15 15:41:00 -070010854 (iw_handler) NULL, /* SIOCGIWRATE */
Jeff Johnsonf2316482017-10-15 14:57:02 -070010855 (iw_handler) NULL, /* SIOCSIWRTS */
Jeff Johnsona95d5ca2017-10-15 14:49:45 -070010856 (iw_handler) NULL, /* SIOCGIWRTS */
Jeff Johnson40d70102017-10-15 14:39:01 -070010857 (iw_handler) NULL, /* SIOCSIWFRAG */
Jeff Johnson75956d32017-10-15 13:53:36 -070010858 (iw_handler) NULL, /* SIOCGIWFRAG */
Jeff Johnson744676f2017-10-15 12:56:16 -070010859 (iw_handler) NULL, /* SIOCSIWTXPOW */
Jeff Johnson918d35e2017-10-15 12:50:26 -070010860 (iw_handler) NULL, /* SIOCGIWTXPOW */
Jeff Johnsond8995042017-10-15 12:45:45 -070010861 (iw_handler) NULL, /* SIOCSIWRETRY */
Jeff Johnson00367e22017-10-15 12:40:15 -070010862 (iw_handler) NULL, /* SIOCGIWRETRY */
Jeff Johnson140e07a2017-10-15 12:32:29 -070010863 (iw_handler) NULL, /* SIOCSIWENCODE */
Jeff Johnsone84e8d02017-10-15 12:22:58 -070010864 (iw_handler) NULL, /* SIOCGIWENCODE */
Jeff Johnson955e0582017-10-15 11:56:52 -070010865 (iw_handler) NULL, /* SIOCSIWPOWER */
Jeff Johnson330d8dc2017-10-15 11:43:13 -070010866 (iw_handler) NULL, /* SIOCGIWPOWER */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010867 (iw_handler) NULL, /* -- hole -- */
10868 (iw_handler) NULL, /* -- hole -- */
Jeff Johnson4bcdafa2017-10-15 11:33:42 -070010869 (iw_handler) NULL, /* SIOCSIWGENIE */
Jeff Johnsonf6562c62017-10-15 11:24:05 -070010870 (iw_handler) NULL, /* SIOCGIWGENIE */
Jeff Johnson079f7de2017-10-15 11:04:08 -070010871 (iw_handler) NULL, /* SIOCSIWAUTH */
Jeff Johnson4139b822017-10-15 10:55:03 -070010872 (iw_handler) NULL, /* SIOCGIWAUTH */
Jeff Johnson5b300822017-10-15 10:44:40 -070010873 (iw_handler) NULL, /* SIOCSIWENCODEEXT */
Jeff Johnson6b747052017-10-15 10:29:04 -070010874 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010875 (iw_handler) NULL, /* SIOCSIWPMKSA */
10876};
10877
10878static const iw_handler we_private[] = {
10879
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010880 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone,
10881 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint,
10882 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010883 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10884 iw_set_three_ints_getnone,
10885 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010886 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010887 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10888 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010889 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
10890 iw_setnone_get_threeint,
Nirav Shaheb017be2018-02-15 11:20:58 +053010891#ifdef WLAN_FEATURE_FIPS
Jeff Johnson6fa1e012017-04-05 06:40:53 -070010892 [WLAN_PRIV_FIPS_TEST - SIOCIWFIRSTPRIV] = hdd_fips_test,
Nirav Shaheb017be2018-02-15 11:20:58 +053010893#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010894 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10895 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10896 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010897 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010898 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10899 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10900 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
10901 iw_set_keepalive_params,
10902#ifdef WLAN_FEATURE_PACKET_FILTERING
10903 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
10904 iw_set_packet_filter_params,
10905#endif
10906#ifdef FEATURE_WLAN_SCAN_PNO
10907 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
10908#endif
10909 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080010910 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
10911 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010912 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
10913 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10914 iw_set_two_ints_getnone,
10915 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
10916 iw_set_dot11p_channel_sched,
10917};
10918
10919/*Maximum command length can be only 15 */
10920static const struct iw_priv_args we_private_args[] = {
10921
10922 /* handlers for main ioctl */
10923 {WLAN_PRIV_SET_INT_GET_NONE,
10924 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10925 0,
10926 ""},
10927
10928 /* handlers for sub-ioctl */
10929 {WE_SET_11D_STATE,
10930 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10931 0,
10932 "set11Dstate"},
10933
10934 {WE_WOWL,
10935 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10936 0,
10937 "wowl"},
10938
10939 {WE_SET_POWER,
10940 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10941 0,
10942 "setPower"},
10943
10944 {WE_SET_MAX_ASSOC,
10945 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10946 0,
10947 "setMaxAssoc"},
10948
10949 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10950 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10951 "setAutoChannel" },
10952
10953 {WE_SET_SCAN_DISABLE,
10954 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10955 0,
10956 "scan_disable"},
10957
10958 {WE_SET_DATA_INACTIVITY_TO,
10959 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10960 0,
10961 "inactivityTO"},
10962
Mukul Sharmaed92f2f2017-04-20 00:06:28 +053010963 {WE_SET_WOW_DATA_INACTIVITY_TO,
10964 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10965 0,
10966 "wow_ito"},
10967
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010968 {WE_SET_MAX_TX_POWER,
10969 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10970 0,
10971 "setMaxTxPower"},
10972
10973 {WE_SET_TX_POWER,
10974 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10975 0,
10976 "setTxPower"},
10977
10978 {WE_SET_MC_RATE,
10979 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10980 0,
10981 "setMcRate"},
10982
10983 {WE_SET_MAX_TX_POWER_2_4,
10984 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10985 0,
10986 "setTxMaxPower2G"},
10987
10988 {WE_SET_MAX_TX_POWER_5_0,
10989 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10990 0,
10991 "setTxMaxPower5G"},
10992
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010993 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010994 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010995 0,
10996 "pktlog"},
10997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010998 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10999 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080011000 * will support both
11001 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011002 {WE_SET_MAX_TX_POWER,
11003 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11004 0,
11005 "setTxMaxPower"},
11006
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011007 {WE_SET_TM_LEVEL,
11008 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11009 0,
11010 "setTmLevel"},
11011
11012 {WE_SET_PHYMODE,
11013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11014 0,
11015 "setphymode"},
11016
11017 {WE_SET_NSS,
11018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11019 0,
11020 "nss"},
11021
11022 {WE_SET_LDPC,
11023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11024 0,
11025 "ldpc"},
11026
11027 {WE_SET_TX_STBC,
11028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11029 0,
11030 "tx_stbc"},
11031
11032 {WE_SET_RX_STBC,
11033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11034 0,
11035 "rx_stbc"},
11036
11037 {WE_SET_SHORT_GI,
11038 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11039 0,
11040 "shortgi"},
11041
11042 {WE_SET_RTSCTS,
11043 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11044 0,
11045 "enablertscts"},
11046
11047 {WE_SET_CHWIDTH,
11048 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11049 0,
11050 "chwidth"},
11051
11052 {WE_SET_ANI_EN_DIS,
11053 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11054 0,
11055 "anienable"},
11056
11057 {WE_SET_ANI_POLL_PERIOD,
11058 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11059 0,
11060 "aniplen"},
11061
11062 {WE_SET_ANI_LISTEN_PERIOD,
11063 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11064 0,
11065 "anilislen"},
11066
11067 {WE_SET_ANI_OFDM_LEVEL,
11068 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11069 0,
11070 "aniofdmlvl"},
11071
11072 {WE_SET_ANI_CCK_LEVEL,
11073 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11074 0,
11075 "aniccklvl"},
11076
11077 {WE_SET_DYNAMIC_BW,
11078 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11079 0,
11080 "cwmenable"},
11081
11082 {WE_SET_CTS_CBW,
11083 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11084 0,
11085 "cts_cbw" },
11086
11087 {WE_SET_GTX_HT_MCS,
11088 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11089 0,
11090 "gtxHTMcs"},
11091
11092 {WE_SET_GTX_VHT_MCS,
11093 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11094 0,
11095 "gtxVHTMcs"},
11096
11097 {WE_SET_GTX_USRCFG,
11098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11099 0,
11100 "gtxUsrCfg"},
11101
11102 {WE_SET_GTX_THRE,
11103 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11104 0,
11105 "gtxThre"},
11106
11107 {WE_SET_GTX_MARGIN,
11108 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11109 0,
11110 "gtxMargin"},
11111
11112 {WE_SET_GTX_STEP,
11113 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11114 0,
11115 "gtxStep"},
11116
11117 {WE_SET_GTX_MINTPC,
11118 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11119 0,
11120 "gtxMinTpc"},
11121
11122 {WE_SET_GTX_BWMASK,
11123 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11124 0,
11125 "gtxBWMask"},
11126
11127 {WE_SET_TX_CHAINMASK,
11128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11129 0,
11130 "txchainmask"},
11131
11132 {WE_SET_RX_CHAINMASK,
11133 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11134 0,
11135 "rxchainmask"},
11136
11137 {WE_SET_11N_RATE,
11138 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11139 0,
11140 "set11NRates"},
11141
11142 {WE_SET_VHT_RATE,
11143 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11144 0,
11145 "set11ACRates"},
11146
11147 {WE_SET_AMPDU,
11148 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11149 0,
11150 "ampdu"},
11151
11152 {WE_SET_AMSDU,
11153 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11154 0,
11155 "amsdu"},
11156
11157 {WE_SET_BURST_ENABLE,
11158 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11159 0,
11160 "burst_enable"},
11161
11162 {WE_SET_BURST_DUR,
11163 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11164 0,
11165 "burst_dur"},
11166
11167 {WE_SET_TXPOW_2G,
11168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11169 0,
11170 "txpow2g"},
11171
11172 {WE_SET_TXPOW_5G,
11173 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11174 0,
11175 "txpow5g"},
11176
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011177 /* Sub-cmds DBGLOG specific commands */
11178 {WE_DBGLOG_LOG_LEVEL,
11179 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11180 0,
11181 "dl_loglevel"},
11182
11183 {WE_DBGLOG_VAP_ENABLE,
11184 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11185 0,
11186 "dl_vapon"},
11187
11188 {WE_DBGLOG_VAP_DISABLE,
11189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11190 0,
11191 "dl_vapoff"},
11192
11193 {WE_DBGLOG_MODULE_ENABLE,
11194 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11195 0,
11196 "dl_modon"},
11197
11198 {WE_DBGLOG_MODULE_DISABLE,
11199 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11200 0,
11201 "dl_modoff"},
11202
11203 {WE_DBGLOG_MOD_LOG_LEVEL,
11204 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11205 0,
11206 "dl_mod_loglevel"},
11207
11208 {WE_DBGLOG_TYPE,
11209 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11210 0,
11211 "dl_type"},
11212 {WE_DBGLOG_REPORT_ENABLE,
11213 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11214 0,
11215 "dl_report"},
11216
11217 {WE_SET_TXRX_FWSTATS,
11218 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11219 0,
11220 "txrx_fw_stats"},
11221
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080011222 {WE_SET_TXRX_STATS,
11223 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11224 0,
11225 "txrx_stats"},
11226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011227 {WE_TXRX_FWSTATS_RESET,
11228 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11229 0,
11230 "txrx_fw_st_rst"},
11231
11232 {WE_PPS_PAID_MATCH,
11233 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11234 0, "paid_match"},
11235
11236 {WE_PPS_GID_MATCH,
11237 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11238 0, "gid_match"},
11239
11240 {WE_PPS_EARLY_TIM_CLEAR,
11241 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11242 0, "tim_clear"},
11243
11244 {WE_PPS_EARLY_DTIM_CLEAR,
11245 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11246 0, "dtim_clear"},
11247
11248 {WE_PPS_EOF_PAD_DELIM,
11249 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11250 0, "eof_delim"},
11251
11252 {WE_PPS_MACADDR_MISMATCH,
11253 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11254 0, "mac_match"},
11255
11256 {WE_PPS_DELIM_CRC_FAIL,
11257 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11258 0, "delim_fail"},
11259
11260 {WE_PPS_GID_NSTS_ZERO,
11261 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11262 0, "nsts_zero"},
11263
11264 {WE_PPS_RSSI_CHECK,
11265 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11266 0, "rssi_chk"},
11267
11268 {WE_PPS_5G_EBT,
11269 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11270 0, "5g_ebt"},
11271
11272 {WE_SET_HTSMPS,
11273 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11274 0, "htsmps"},
11275
11276 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
11277 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11278 0, "set_qpspollcnt"},
11279
11280 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
11281 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11282 0, "set_qtxwake"},
11283
11284 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
11285 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11286 0, "set_qwakeintv"},
11287
11288 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
11289 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11290 0, "set_qnodatapoll"},
11291
11292 /* handlers for MCC time quota and latency sub ioctls */
11293 {WE_MCC_CONFIG_LATENCY,
11294 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11295 0, "setMccLatency"},
11296
11297 {WE_MCC_CONFIG_QUOTA,
11298 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11299 0, "setMccQuota"},
11300
11301 {WE_SET_DEBUG_LOG,
11302 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11303 0, "setDbgLvl"},
11304
11305 /* handlers for early_rx power save */
11306 {WE_SET_EARLY_RX_ADJUST_ENABLE,
11307 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11308 0, "erx_enable"},
11309
11310 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
11311 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11312 0, "erx_bmiss_val"},
11313
11314 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
11315 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11316 0, "erx_bmiss_smpl"},
11317
11318 {WE_SET_EARLY_RX_SLOP_STEP,
11319 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11320 0, "erx_slop_step"},
11321
11322 {WE_SET_EARLY_RX_INIT_SLOP,
11323 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11324 0, "erx_init_slop"},
11325
11326 {WE_SET_EARLY_RX_ADJUST_PAUSE,
11327 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11328 0, "erx_adj_pause"},
11329
11330 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
11331 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11332 0, "erx_dri_sample"},
11333
11334 {WE_DUMP_STATS,
11335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11336 0, "dumpStats"},
11337
11338 {WE_CLEAR_STATS,
11339 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11340 0, "clearStats"},
11341
Govind Singha471e5e2015-10-12 17:11:14 +053011342 {WE_START_FW_PROFILE,
11343 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11344 0, "startProfile"},
11345
Abhishek Singh1bdb1572015-10-16 16:24:19 +053011346 {WE_SET_CHANNEL,
11347 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11348 0, "setChanChange" },
11349
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053011350 {WE_SET_CONC_SYSTEM_PREF,
11351 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11352 0, "setConcSysPref" },
11353
Jeff Johnson011c4502017-10-05 15:25:56 -070011354 {WE_SET_PDEV_RESET,
11355 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11356 0, "pdev_reset" },
11357
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +053011358 {WE_SET_MODULATED_DTIM,
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -080011359 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11360 0, "setModDTIM" },
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +053011361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011362 {WLAN_PRIV_SET_NONE_GET_INT,
11363 0,
11364 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11365 ""},
11366
11367 /* handlers for sub-ioctl */
11368 {WE_GET_11D_STATE,
11369 0,
11370 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11371 "get11Dstate"},
11372
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011373 {WE_GET_WLAN_DBG,
11374 0,
11375 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11376 "getwlandbg"},
11377
11378 {WE_GET_MAX_ASSOC,
11379 0,
11380 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11381 "getMaxAssoc"},
11382
11383 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11384 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11385 "getAutoChannel" },
11386
11387 {WE_GET_CONCURRENCY_MODE,
11388 0,
11389 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11390 "getconcurrency"},
11391
11392 {WE_GET_NSS,
11393 0,
11394 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11395 "get_nss"},
11396
11397 {WE_GET_LDPC,
11398 0,
11399 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11400 "get_ldpc"},
11401
11402 {WE_GET_TX_STBC,
11403 0,
11404 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11405 "get_tx_stbc"},
11406
11407 {WE_GET_RX_STBC,
11408 0,
11409 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11410 "get_rx_stbc"},
11411
11412 {WE_GET_SHORT_GI,
11413 0,
11414 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11415 "get_shortgi"},
11416
11417 {WE_GET_RTSCTS,
11418 0,
11419 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11420 "get_rtscts"},
11421
11422 {WE_GET_CHWIDTH,
11423 0,
11424 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11425 "get_chwidth"},
11426
11427 {WE_GET_ANI_EN_DIS,
11428 0,
11429 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11430 "get_anienable"},
11431
11432 {WE_GET_ANI_POLL_PERIOD,
11433 0,
11434 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11435 "get_aniplen"},
11436
11437 {WE_GET_ANI_LISTEN_PERIOD,
11438 0,
11439 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11440 "get_anilislen"},
11441
11442 {WE_GET_ANI_OFDM_LEVEL,
11443 0,
11444 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11445 "get_aniofdmlvl"},
11446
11447 {WE_GET_ANI_CCK_LEVEL,
11448 0,
11449 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11450 "get_aniccklvl"},
11451
11452 {WE_GET_DYNAMIC_BW,
11453 0,
11454 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11455 "get_cwmenable"},
11456
11457 {WE_GET_GTX_HT_MCS,
11458 0,
11459 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11460 "get_gtxHTMcs"},
11461
11462 {WE_GET_GTX_VHT_MCS,
11463 0,
11464 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11465 "get_gtxVHTMcs"},
11466
11467 {WE_GET_GTX_USRCFG,
11468 0,
11469 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11470 "get_gtxUsrCfg"},
11471
11472 {WE_GET_GTX_THRE,
11473 0,
11474 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11475 "get_gtxThre"},
11476
11477 {WE_GET_GTX_MARGIN,
11478 0,
11479 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11480 "get_gtxMargin"},
11481
11482 {WE_GET_GTX_STEP,
11483 0,
11484 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11485 "get_gtxStep"},
11486
11487 {WE_GET_GTX_MINTPC,
11488 0,
11489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11490 "get_gtxMinTpc"},
11491
11492 {WE_GET_GTX_BWMASK,
11493 0,
11494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11495 "get_gtxBWMask"},
11496
11497 {WE_GET_TX_CHAINMASK,
11498 0,
11499 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11500 "get_txchainmask"},
11501
11502 {WE_GET_RX_CHAINMASK,
11503 0,
11504 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11505 "get_rxchainmask"},
11506
11507 {WE_GET_11N_RATE,
11508 0,
11509 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11510 "get_11nrate"},
11511
11512 {WE_GET_AMPDU,
11513 0,
11514 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11515 "get_ampdu"},
11516
11517 {WE_GET_AMSDU,
11518 0,
11519 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11520 "get_amsdu"},
11521
11522 {WE_GET_BURST_ENABLE,
11523 0,
11524 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11525 "get_burst_en"},
11526
11527 {WE_GET_BURST_DUR,
11528 0,
11529 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11530 "get_burst_dur"},
11531
11532 {WE_GET_TXPOW_2G,
11533 0,
11534 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11535 "get_txpow2g"},
11536
11537 {WE_GET_TXPOW_5G,
11538 0,
11539 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11540 "get_txpow5g"},
11541
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011542 {WE_GET_PPS_PAID_MATCH,
11543 0,
11544 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11545 "get_paid_match"},
11546
11547 {WE_GET_PPS_GID_MATCH,
11548 0,
11549 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11550 "get_gid_match"},
11551
11552 {WE_GET_PPS_EARLY_TIM_CLEAR,
11553 0,
11554 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11555 "get_tim_clear"},
11556
11557 {WE_GET_PPS_EARLY_DTIM_CLEAR,
11558 0,
11559 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11560 "get_dtim_clear"},
11561
11562 {WE_GET_PPS_EOF_PAD_DELIM,
11563 0,
11564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11565 "get_eof_delim"},
11566
11567 {WE_GET_PPS_MACADDR_MISMATCH,
11568 0,
11569 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11570 "get_mac_match"},
11571
11572 {WE_GET_PPS_DELIM_CRC_FAIL,
11573 0,
11574 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11575 "get_delim_fail"},
11576
11577 {WE_GET_PPS_GID_NSTS_ZERO,
11578 0,
11579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11580 "get_nsts_zero"},
11581
11582 {WE_GET_PPS_RSSI_CHECK,
11583 0,
11584 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11585 "get_rssi_chk"},
11586
11587 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
11588 0,
11589 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11590 "get_qpspollcnt"},
11591
11592 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
11593 0,
11594 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11595 "get_qtxwake"},
11596
11597 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
11598 0,
11599 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11600 "get_qwakeintv"},
11601
11602 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
11603 0,
11604 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11605 "get_qnodatapoll"},
11606
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011607 {WE_CAP_TSF,
11608 0,
11609 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11610 "cap_tsf"},
11611
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011612 {WE_GET_TEMPERATURE,
11613 0,
11614 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11615 "get_temp"},
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070011616 {WE_GET_DCM,
11617 0,
11618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11619 "get_dcm"},
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070011620 {WE_GET_RANGE_EXT,
11621 0,
11622 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11623 "get_range_ext"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011624 /* handlers for main ioctl */
11625 {WLAN_PRIV_SET_CHAR_GET_NONE,
11626 IW_PRIV_TYPE_CHAR | 512,
11627 0,
11628 ""},
11629
11630 /* handlers for sub-ioctl */
11631 {WE_WOWL_ADD_PTRN,
11632 IW_PRIV_TYPE_CHAR | 512,
11633 0,
11634 "wowlAddPtrn"},
11635
11636 {WE_WOWL_DEL_PTRN,
11637 IW_PRIV_TYPE_CHAR | 512,
11638 0,
11639 "wowlDelPtrn"},
11640
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011641 /* handlers for sub-ioctl */
11642 {WE_NEIGHBOR_REPORT_REQUEST,
11643 IW_PRIV_TYPE_CHAR | 512,
11644 0,
11645 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080011646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011647 {WE_SET_AP_WPS_IE,
11648 IW_PRIV_TYPE_CHAR | 512,
11649 0,
11650 "set_ap_wps_ie"},
11651
11652 {WE_SET_CONFIG,
11653 IW_PRIV_TYPE_CHAR | 512,
11654 0,
11655 "setConfig"},
11656
11657 /* handlers for main ioctl */
11658 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
11659 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11660 0,
11661 ""},
11662
11663 /* handlers for sub-ioctl */
11664 {WE_SET_WLAN_DBG,
11665 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11666 0,
11667 "setwlandbg"},
11668
11669 /* handlers for sub-ioctl */
11670 {WE_SET_DP_TRACE,
11671 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11672 0,
11673 "set_dp_trace"},
11674
11675 {WE_SET_SAP_CHANNELS,
11676 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11677 0,
11678 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053011679
11680 {WE_SET_FW_TEST,
11681 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11682 0, "fw_test"},
11683
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011684 /* handlers for main ioctl */
11685 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
11686 0,
11687 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11688 "" },
11689 {WE_GET_TSF,
11690 0,
11691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11692 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011693
11694 {WE_SET_DUAL_MAC_SCAN_CONFIG,
11695 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11696 0,
11697 "set_scan_cfg"},
11698
11699 /* handlers for main ioctl */
11700 {WLAN_PRIV_GET_CHAR_SET_NONE,
11701 0,
11702 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11703 ""},
11704
11705 /* handlers for sub-ioctl */
11706 {WE_WLAN_VERSION,
11707 0,
11708 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11709 "version"},
11710 {WE_GET_STATS,
11711 0,
11712 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11713 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080011714 {WE_GET_SUSPEND_RESUME_STATS,
11715 0,
11716 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11717 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053011718 {WE_LIST_FW_PROFILE,
11719 0,
11720 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11721 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011722 {WE_GET_STATES,
11723 0,
11724 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11725 "getHostStates"},
11726 {WE_GET_CFG,
11727 0,
11728 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11729 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011730 {WE_GET_RSSI,
11731 0,
11732 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11733 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011734 {WE_GET_WMM_STATUS,
11735 0,
11736 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11737 "getWmmStatus"},
11738 {
11739 WE_GET_CHANNEL_LIST,
11740 0,
11741 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11742 "getChannelList"
11743 },
11744#ifdef FEATURE_WLAN_TDLS
11745 {
11746 WE_GET_TDLS_PEERS,
11747 0,
11748 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11749 "getTdlsPeers"
11750 },
11751#endif
11752#ifdef WLAN_FEATURE_11W
11753 {
11754 WE_GET_11W_INFO,
11755 0,
11756 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11757 "getPMFInfo"
11758 },
11759#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011760 {
11761 WE_GET_IBSS_STA_INFO,
11762 0,
11763 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11764 "getIbssSTAs"
11765 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011766 {WE_GET_PHYMODE,
11767 0,
11768 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11769 "getphymode"},
Naveen Rawat910726a2017-03-06 11:42:51 -080011770#if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011771 {WE_GET_OEM_DATA_CAP,
11772 0,
11773 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11774 "getOemDataCap"},
Naveen Rawat910726a2017-03-06 11:42:51 -080011775#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011776 {WE_GET_SNR,
11777 0,
11778 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11779 "getSNR"},
11780
11781 /* handlers for main ioctl */
11782 {WLAN_PRIV_SET_NONE_GET_NONE,
11783 0,
11784 0,
11785 ""},
11786
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011787 /* handlers for sub-ioctl */
11788 {
11789 WE_IBSS_GET_PEER_INFO_ALL,
11790 0,
11791 0,
11792 "ibssPeerInfoAll"
11793 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011794 {WE_GET_RECOVERY_STAT,
11795 0,
11796 0,
11797 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053011798
11799 {WE_GET_FW_PROFILE_DATA,
11800 0,
11801 0,
11802 "getProfileData"},
11803
11804 {WE_SET_REASSOC_TRIGGER,
11805 0,
11806 0,
11807 "reassoc"},
11808
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080011809 {WE_STOP_OBSS_SCAN,
11810 0,
11811 0,
11812 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011813 /* handlers for main ioctl */
11814 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
11815 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11816 0,
11817 ""},
11818
11819 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011820 {WE_IBSS_GET_PEER_INFO,
11821 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11822 0,
11823 "ibssPeerInfo"},
11824
11825 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011826 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11827 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11828 0,
11829 "setdumplog"},
11830
11831 {WE_MTRACE_DUMP_CMD,
11832 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11833 0,
11834 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080011835
11836 {WE_POLICY_MANAGER_CINFO_CMD,
11837 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11838 0,
11839 "pm_cinfo"},
11840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011841#ifdef MPC_UT_FRAMEWORK
11842 {WE_POLICY_MANAGER_CLIST_CMD,
11843 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11844 0,
11845 "pm_clist"},
11846
11847 {WE_POLICY_MANAGER_DLIST_CMD,
11848 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11849 0,
11850 "pm_dlist"},
11851
11852 {WE_POLICY_MANAGER_DBS_CMD,
11853 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11854 0,
11855 "pm_dbs"},
11856
11857 {WE_POLICY_MANAGER_PCL_CMD,
11858 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11859 0,
11860 "pm_pcl"},
11861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011862 {WE_POLICY_MANAGER_ULIST_CMD,
11863 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11864 0,
11865 "pm_ulist"},
11866
11867 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
11868 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11869 0,
11870 "pm_query_action"},
11871
11872 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
11873 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11874 0,
11875 "pm_query_allow"},
11876
11877 {WE_POLICY_MANAGER_SCENARIO_CMD,
11878 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11879 0,
11880 "pm_run_scenario"},
11881
11882 {WE_POLICY_SET_HW_MODE_CMD,
11883 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11884 0,
11885 "pm_set_hw_mode"},
11886#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011887 {
11888 WE_UNIT_TEST_CMD,
11889 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11890 0,
11891 "setUnitTestCmd"
11892 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053011893 {
11894 WE_MAC_PWR_DEBUG_CMD,
11895 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11896 0,
11897 "halPwrDebug"
11898 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011899
11900#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11901 {WE_LED_FLASHING_PARAM,
11902 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11903 0,
11904 "gpio_control"},
11905#endif
Liangwei Dong2a7f2912018-02-07 17:08:17 +080011906#ifdef WLAN_DEBUG
11907 {WE_SET_CHAN_AVOID,
11908 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11909 0,
11910 "ch_avoid"},
11911#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011912 /* handlers for main ioctl */
Jeff Johnson6fa1e012017-04-05 06:40:53 -070011913 {WLAN_PRIV_FIPS_TEST,
11914 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11915 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11916 "fips_test"},
11917
11918 /* handlers for main ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011919 {WLAN_PRIV_ADD_TSPEC,
11920 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11921 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11922 "addTspec"},
11923
11924 /* handlers for main ioctl */
11925 {WLAN_PRIV_DEL_TSPEC,
11926 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11927 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11928 "delTspec"},
11929
11930 /* handlers for main ioctl */
11931 {WLAN_PRIV_GET_TSPEC,
11932 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11933 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11934 "getTspec"},
11935
11936 /* handlers for main ioctl - host offload */
11937 {
11938 WLAN_PRIV_SET_HOST_OFFLOAD,
Srinivas Girigowda077143e2017-03-25 10:47:27 -070011939 IW_PRIV_TYPE_BYTE | sizeof(struct host_offload_req),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011940 0,
11941 "setHostOffload"
11942 }
11943 ,
11944
11945 {
11946 WLAN_GET_WLAN_STATISTICS,
11947 0,
11948 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11949 "getWlanStats"
11950 }
11951 ,
11952
11953 {
11954 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011955 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11956 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011957 0,
11958 "setKeepAlive"
11959 }
11960 ,
11961#ifdef WLAN_FEATURE_PACKET_FILTERING
11962 {
11963 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053011964 IW_PRIV_TYPE_BYTE |
11965 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011966 0,
11967 "setPktFilter"
11968 }
11969 ,
11970#endif
11971#ifdef FEATURE_WLAN_SCAN_PNO
11972 {
11973 WLAN_SET_PNO,
11974 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11975 0,
11976 "setpno"
11977 }
11978 ,
11979#endif
11980 {
11981 WLAN_SET_BAND_CONFIG,
11982 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11983 0,
11984 "SETBAND"
11985 }
11986 ,
11987 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080011988 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080011989 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011990 0,
11991 "setMCBCFilter"
11992 }
11993 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011994
11995 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011996 WLAN_GET_LINK_SPEED,
11997 IW_PRIV_TYPE_CHAR | 18,
11998 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11999 }
12000 ,
12001
12002 /* handlers for main ioctl */
12003 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
12004 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12005 0,
12006 ""}
12007 ,
12008 {WE_SET_SMPS_PARAM,
12009 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12010 0, "set_smps_param"}
12011 ,
12012 {WLAN_SET_DOT11P_CHANNEL_SCHED,
12013 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
12014 0, "set_dot11p" }
12015 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070012016#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012017 {WE_SET_FW_CRASH_INJECT,
12018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12019 0, "crash_inject"}
12020 ,
Dustin Brown8d2d0f52017-04-03 17:02:08 -070012021 {WE_LOG_BUFFER,
12022 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12023 0, "log_buffer"}
12024 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012025#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012026#ifdef WLAN_SUSPEND_RESUME_TEST
12027 {WE_SET_WLAN_SUSPEND,
12028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12029 0, "wlan_suspend"}
12030 ,
12031 {WE_SET_WLAN_RESUME,
12032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12033 0, "wlan_resume"}
12034 ,
12035#endif
Govind Singha471e5e2015-10-12 17:11:14 +053012036 {WE_ENABLE_FW_PROFILE,
12037 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12038 0, "enableProfile"}
12039 ,
12040 {WE_SET_FW_PROFILE_HIST_INTVL,
12041 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12042 0, "set_hist_intvl"}
12043 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012044 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
12045 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12046 0, "set_fw_mode_cfg"}
12047 ,
12048 {WE_DUMP_DP_TRACE_LEVEL,
12049 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12050 0, "dump_dp_trace"}
12051 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012052 {WE_SET_MON_MODE_CHAN,
12053 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12054 0, "setMonChan"}
12055 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070012056
12057 {WE_GET_ROAM_SYNCH_DELAY,
12058 0,
12059 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12060 "hostroamdelay"}
12061 ,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -080012062 {WE_SET_11AX_RATE,
12063 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12064 0,
12065 "set_11ax_rate"}
12066 ,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070012067 {WE_SET_DCM,
12068 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12069 0,
12070 "enable_dcm"}
12071 ,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070012072 {WE_SET_RANGE_EXT,
12073 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12074 0,
Naveen Rawat53448ea2017-11-27 11:43:18 -080012075 "range_ext"}
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070012076 ,
Naveen Rawatc921c7b2017-06-13 17:29:51 -070012077
12078 {WLAN_PRIV_SET_FTIES,
12079 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
12080 0,
12081 "set_ft_ies"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012082};
12083
12084const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053012085 .num_standard = QDF_ARRAY_SIZE(we_handler),
12086 .num_private = QDF_ARRAY_SIZE(we_private),
12087 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012088
12089 .standard = (iw_handler *) we_handler,
12090 .private = (iw_handler *) we_private,
12091 .private_args = we_private_args,
12092 .get_wireless_stats = NULL,
12093};
12094
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012095/* hdd_set_wext() - configures bss parameters
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012096 * @adapter: handle to adapter context
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012097 *
12098 * Returns: none
12099 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012100static int hdd_set_wext(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012101{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012102 struct hdd_wext_state *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -070012103 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012104
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012105 ENTER();
12106
12107 if (!pwextBuf) {
12108 hdd_err("ERROR: pwextBuf is NULL");
12109 return QDF_STATUS_E_FAILURE;
12110 }
12111
Jeff Johnsond377dce2017-10-04 10:32:42 -070012112 if (!sta_ctx) {
12113 hdd_err("ERROR: sta_ctx is NULL");
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012114 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070012115 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012116
12117 /* Now configure the roaming profile links. To SSID and bssid. */
12118 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -070012119 pwextBuf->roamProfile.SSIDs.SSIDList = &sta_ctx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012120
12121 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -070012122 pwextBuf->roamProfile.BSSIDs.bssid = &sta_ctx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012123
12124 /*Set the numOfChannels to zero to scan all the channels */
12125 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
12126 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
12127
12128 /* Default is no encryption */
12129 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
12130 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
12131 eCSR_ENCRYPT_TYPE_NONE;
12132
12133 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
12134 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
12135 eCSR_ENCRYPT_TYPE_NONE;
12136
12137 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
12138
12139 /* Default is no authentication */
12140 pwextBuf->roamProfile.AuthType.numEntries = 1;
12141 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
12142
12143 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnsonce4a8342017-10-14 13:12:22 -070012144 sta_ctx->wpa_versions = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012145
12146 /*Set the default scan mode */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012147 adapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012148
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012149 hdd_clear_roam_profile_ie(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012150
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012151 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012152 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012153
12154}
12155
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012156#ifdef WLAN_FEATURE_FILS_SK
Jeff Johnson2a722002017-09-30 20:02:35 -070012157static void hdd_initialize_fils_info(struct hdd_wext_state *pwextBuf)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012158{
12159 pwextBuf->roamProfile.fils_con_info = NULL;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053012160 pwextBuf->roamProfile.hlp_ie = NULL;
12161 pwextBuf->roamProfile.hlp_ie_len = 0;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012162}
12163#else
Jeff Johnson2a722002017-09-30 20:02:35 -070012164static void hdd_initialize_fils_info(struct hdd_wext_state *pwextBuf)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012165{ }
12166#endif
12167
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070012168/**
12169 * hdd_register_wext() - register wext context
12170 * @dev: net device handle
12171 *
12172 * Registers wext interface context for a given net device
12173 *
12174 * Returns: 0 on success, errno on failure
12175 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012176int hdd_register_wext(struct net_device *dev)
12177{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012178 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12179 struct hdd_wext_state *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053012180 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012181
12182 ENTER();
12183
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012184 if (!pwextBuf) {
12185 hdd_err(FL("ERROR: pwextBuf is NULL"));
12186 return QDF_STATUS_E_FAILURE;
12187 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070012188
12189 /* Zero the memory. This zeros the profile structure */
Jeff Johnson2a722002017-09-30 20:02:35 -070012190 memset(pwextBuf, 0, sizeof(struct hdd_wext_state));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012191
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012192 status = hdd_set_wext(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012193
Anurag Chouhance0dc992016-02-16 18:18:03 +053012194 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012195 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012196 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012197 }
12198
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012199 status = qdf_event_create(&pwextBuf->hdd_qdf_event);
12200 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012201 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012202 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012203 }
12204
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012205 hdd_initialize_fils_info(pwextBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012206 /* Register as a wireless device */
12207 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
12208
12209 EXIT();
12210 return 0;
12211}
12212
12213int hdd_unregister_wext(struct net_device *dev)
12214{
Jeff Johnson36e74c42017-09-18 08:15:42 -070012215 hdd_debug("dev(%pK)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012216
12217 if (dev != NULL) {
12218 rtnl_lock();
12219 dev->wireless_handlers = NULL;
12220 rtnl_unlock();
12221 }
12222
12223 return 0;
12224}