blob: dc84990ae313e3e1679ebea4d92953695d36c4e3 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_wext.c
30 *
31 * Linux Wireless Extensions Implementation
32 */
33
34#include <linux/version.h>
35#include <linux/module.h>
36#include <linux/kernel.h>
37#include <linux/init.h>
38#include <linux/wireless.h>
39#include <mac_trace.h>
40#include <wlan_hdd_includes.h>
41#include <cds_api.h>
Rajeev Kumarea95edd2017-01-11 20:49:36 -080042#include "scheduler_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043#include <net/arp.h>
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080044#include <cdp_txrx_cmn.h>
Manjunathappa Prakash3454fd62016-04-01 08:52:06 -070045#include <cdp_txrx_stats.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "sir_params.h"
47#include "csr_api.h"
48#include "csr_inside_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include "sme_rrm_internal.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include <ani_global.h>
51#include "dot11f.h"
52#include <wlan_hdd_wowl.h>
53#include <wlan_hdd_cfg.h>
54#include <wlan_hdd_wmm.h>
55#include "utils_api.h"
56#include "wlan_hdd_p2p.h"
57#ifdef FEATURE_WLAN_TDLS
58#include "wlan_hdd_tdls.h"
59#endif
60
61#include "cds_ieee80211_common.h"
62#include "ol_if_athvar.h"
63#include "dbglog_host.h"
64#include "wma.h"
65
66#include "wlan_hdd_power.h"
67#include "qwlan_version.h"
68#include "wlan_hdd_host_offload.h"
69
70#include <linux/wireless.h>
71#include <net/cfg80211.h>
72
73#include "wlan_hdd_misc.h"
74
75#include "qc_sap_ioctl.h"
76#include "sme_api.h"
77#include "wma_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053078#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079#include "wlan_hdd_assoc.h"
80#include "wlan_hdd_ioctl.h"
81#include "wlan_hdd_scan.h"
82#include "sme_power_save_api.h"
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080083#include "wlan_policy_mgr_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084#include "wlan_hdd_conc_ut.h"
Jeff Johnson6fa1e012017-04-05 06:40:53 -070085#include "wlan_hdd_fips.h"
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070086#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087#include "wlan_hdd_ocb.h"
88#include "wlan_hdd_napi.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080089#include "cdp_txrx_flow_ctrl_legacy.h"
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070090#include "wlan_hdd_nan_datapath.h"
Nirav Shahbf1b0332016-05-25 14:27:39 +053091#include "wlan_hdd_stats.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070092#ifdef WLAN_SUSPEND_RESUME_TEST
93#include "wlan_hdd_driver_ops.h"
94#include "hif.h"
Rajeev Kumar9bb2e852016-09-24 12:29:25 -070095#include "pld_common.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070096#endif
Dhanashri Atree7d442a2016-07-14 18:20:29 -070097#include "wlan_hdd_lro.h"
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053098#include "cds_utils.h"
Jeff Johnsona6ace5b2017-01-23 07:11:02 -080099#include "wlan_hdd_request_manager.h"
Naveen Rawat910726a2017-03-06 11:42:51 -0800100#include "os_if_wifi_pos.h"
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -0800101#include <cdp_txrx_stats.h>
102#include <cds_api.h>
Abhishek Singh0481d662017-04-11 18:20:11 +0530103#include <wlan_osif_priv.h>
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700104#include "wlan_hdd_regulatory.h"
105#include "wlan_reg_ucfg_api.h"
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +0530106#include "wlan_hdd_packet_filter_api.h"
Abhishek Singh0481d662017-04-11 18:20:11 +0530107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108#define HDD_FINISH_ULA_TIME_OUT 800
109#define HDD_SET_MCBC_FILTERS_TO_FW 1
110#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112/* To Validate Channel against the Frequency and Vice-Versa */
Srinivas Girigowda48592672017-03-25 14:58:44 -0700113static const struct ccp_freq_chan_map freq_chan_map[] = {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
115 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
116 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
117 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
118 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
119 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
120 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
121 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
122 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
123 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
124 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
125 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
126
Srinivas Girigowdafba82a02017-03-24 21:26:35 -0700127#define FREQ_CHAN_MAP_TABLE_SIZE QDF_ARRAY_SIZE(freq_chan_map)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128
129/* Private ioctls and their sub-ioctls */
130#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
131#define WE_SET_11D_STATE 1
132#define WE_WOWL 2
133#define WE_SET_POWER 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530134/*
135 * <ioctl>
136 * setMaxAssoc - Sets the maximum number of associated stations
137 *
138 * @INPUT: 1 to 32
139 *
140 * @OUTPUT: None
141 *
142 * This IOTCL sets the maximum number of associated stations
143 *
144 * @E.g: iwpriv wlan0 setMaxAssoc <value>
145 *
146 * Supported Feature: STA
147 *
148 * Usage: Internal/External
149 *
150 * </ioctl>
151 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152#define WE_SET_MAX_ASSOC 4
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +0530153/*
154 * <ioctl>
155 * scan_diable - Disable scan
156 *
157 * @INPUT: set_value
158 *
159 * @OUTPUT: None
160 *
161 * This IOCTL is used to set disable scan
162 *
163 * @E.g: iwpriv wlan0 scan_disable 1
164 *
165 * Supported Feature: Scan
166 *
167 * Usage: Internal/External
168 *
169 * </ioctl>
170 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171#define WE_SET_SCAN_DISABLE 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530172/*
173 * <ioctl>
174 * inactivityTO - sets the timeout value for inactivity data while
175 * in power save mode
176 *
177 * @INPUT: int1…..int255
178 *
179 * @OUTPUT: None
180 *
181 * This IOCTL set the timeout value for inactivity data in power save mode
182 *
183 * @E.g: iwpriv wlan0 inactivityTO 20
184 *
185 * Supported Feature: STA
186 *
187 * Usage: Internal/External
188 *
189 * </ioctl>
190 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191#define WE_SET_DATA_INACTIVITY_TO 6
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530192/*
193 * <ioctl>
194 * setMaxTxPower - Dynamically sets the maximum transmission power
195 *
196 * @INPUT: Transmission power in dBm
197 *
198 * @OUTPUT: None
199 *
200 * This IOCTL dynamically sets the maximum transmission power
201 * This setting does not persist over reboots
202 *
203 * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
204 *
205 * Supported Feature: STA
206 *
207 * Usage: Internal/External
208 *
209 * </ioctl>
210 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211#define WE_SET_MAX_TX_POWER 7
Jeff Johnsonfab9b252017-10-28 15:44:34 -0700212/* 8 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213#define WE_SET_TM_LEVEL 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530214/*
215 * <ioctl>
216 * setphymode - Set the phymode dynamically
217 *
218 * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
219 *
220 * @OUTPUT: None
221 *
222 * This IOCTL sets the phymode dynamically
223 *
224 * @E.g: iwpriv wlan0 setphymode 10
225 *
226 * Supported Feature: STA
227 *
228 * Usage: Internal/External
229 *
230 * </ioctl>
231 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232#define WE_SET_PHYMODE 10
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530233/*
234 * <ioctl>
235 * nss - Set the number of spatial streams
236 *
237 * @INPUT: int1…..int3
238 *
239 * @OUTPUT: None
240 *
241 * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
242 *
243 * @E.g: iwpriv wlan0 nss 2
244 *
245 * Supported Feature: STA
246 *
247 * Usage: Internal/External
248 *
249 * </ioctl>
250 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251#define WE_SET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530252/*
253 * <ioctl>
254 * ldpc - Enables or disables LDPC
255 *
256 * @INPUT: 0 – Disable, 1 - Enable
257 *
258 * @OUTPUT: None
259 *
260 * This IOCTL enables or disables LDPC
261 *
262 * @E.g: iwpriv wlan0 ldpc 1
263 *
264 * Supported Feature: STA
265 *
266 * Usage: Internal/External
267 *
268 * </ioctl>
269 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270#define WE_SET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530271/*
272 * <ioctl>
273 * tx_stbc - Enables or disables tx_stbc
274 *
275 * @INPUT: Int 0 – Disable, 1 - Enable
276 *
277 * @OUTPUT: None
278 *
279 * This IOTCL used to enables or disables tx_stbc
280 *
281 * @E.g: iwpriv wlan0 tx_stbc <value>
282 *
283 * Supported Feature: STA
284 *
285 * Usage: Internal/External
286 *
287 * </ioctl>
288 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289#define WE_SET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530290/*
291 * <ioctl>
292 * rx_stbc - Set the rx_stbc parameter
293 *
294 * @INPUT: Int 0 – Disable, 1 - Enable
295 *
296 * @OUTPUT: None
297 *
298 * This IOTCL used to set rx_stbc parameter
299 *
300 * @E.g: iwpriv wlan0 rx_stbc <value>
301 *
302 * Supported Feature: STA
303 *
304 * Usage: Internal/External
305 *
306 * </ioctl>
307 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308#define WE_SET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530309/*
310 * <ioctl>
311 * shortgi - Enables or disables a short-guard interval
312 *
313 * @INPUT: Int 0 – Disable, 1 - Enable
314 *
315 * @OUTPUT: None
316 *
317 * This IOCTL enables or disables a short-guard interval.
318 *
319 * @E.g: iwpriv wlan0 shortgi <value>
320 *
321 * Supported Feature: STA
322 *
323 * Usage: Internal/External
324 *
325 * </ioctl>
326 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327#define WE_SET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530328/*
329 * <ioctl>
330 * enablertscts - enables or disables rts/cts.
331 *
332 * @INPUT: 1-Enable , 0-Disable
333 *
334 * @OUTPUT: None
335 *
336 * This IOCTL enables or disables rts/cts.
337 *
338 * @E.g: iwpriv wlan0 enablertscts <value>
339 *
340 * Supported Feature: STA
341 *
342 * Usage: Internal/External
343 *
344 * </ioctl>
345 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346#define WE_SET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530347/*
348 * <ioctl>
349 * chwidth - Set the channel bandwidth
350 *
351 * @INPUT: 0-20mhz to 3-160mhz
352 *
353 * @OUTPUT: None
354 *
355 * This IOTCL used to set the channel bandwidth
356 *
357 * @E.g: iwpriv wlan0 chwidth 1
358 *
359 * Supported Feature: STA
360 *
361 * Usage: Internal/External
362 *
363 * </ioctl>
364 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365#define WE_SET_CHWIDTH 17
366#define WE_SET_ANI_EN_DIS 18
367#define WE_SET_ANI_POLL_PERIOD 19
368#define WE_SET_ANI_LISTEN_PERIOD 20
369#define WE_SET_ANI_OFDM_LEVEL 21
370#define WE_SET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530371/*
372 * <ioctl>
373 * cwmenable - Enables or disables the dynamic channel bandwidth
374 *
375 * @INPUT: 0-Disable, 1-Enable
376 *
377 * @OUTPUT: None
378 *
379 * This IOTCL used to enables or disables the dynamic channel bandwidth
380 *
381 * @E.g: iwpriv wlan0 cwmenable <value>
382 *
383 * Supported Feature: STA
384 *
385 * Usage: Internal/External
386 *
387 * </ioctl>
388 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389#define WE_SET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530390/*
391 * <ioctl>
392 * txchainmask - This IOCTL sets the current Tx chain mask
393 *
394 * @INPUT: Mask Value
395 *
396 * @OUTPUT: None
397 *
398 * This IOCTL sets the current Tx chain mask
399 *
400 * @E.g: iwpriv wlan0 txchainmask 1
401 *
402 * Supported Feature: STA
403 *
404 * Usage: Internal/External
405 *
406 * </ioctl>
407 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408#define WE_SET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530409/*
410 * <ioctl>
411 * rxchainmask - Sets the current Rx chain mask
412 *
413 * @INPUT: Mask Value
414 *
415 * @OUTPUT: None
416 *
417 * This IOCTL sets the current Rx chain mask. This command is the
418 * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
419 *
420 * @E.g: iwpriv wlan0 rxchainmask <value>
421 *
422 * Supported Feature: STA
423 *
424 * Usage: Internal/External
425 *
426 * </ioctl>
427 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428#define WE_SET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530429/*
430 * <ioctl>
431 * set11NRates - Fixes the Tx data rate of the 11N mode.
432 *
433 * @INPUT: 0x1b to 0x8f
434 *
435 * @OUTPUT: None
436 *
437 * This IOCTL fixes the Tx data rate of the 11N mode.
438 *
439 * @E.g: iwpriv wlan0 set11NRates 0x85
440 *
441 * Supported Feature: STA
442 *
443 * Usage: Internal/External
444 *
445 * </ioctl>
446 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447#define WE_SET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530448/*
449 * <ioctl>
450 * ampdu - Set the the maximum subframe of ampdu
451 *
452 * @INPUT: int 1 to int 63
453 *
454 * @OUTPUT: None
455 *
456 * This IOCTL sets the maximum subframe of ampdu.
457 *
458 * @E.g: iwpriv wlan0 ampdu 9
459 *
460 * Supported Feature: STA
461 *
462 * Usage: Internal/External
463 *
464 * </ioctl>
465 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466#define WE_SET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530467/*
468 * <ioctl>
469 * amsdu - Sets the maximum subframe of amsdu.
470 *
471 * @INPUT: int 1 to int 31
472 *
473 * @OUTPUT: None
474 *
475 * This IOCTL sets the maximum subframe of amsdu.
476 *
477 * @E.g: iwpriv wlan0 amsdu 9
478 *
479 * Supported Feature: STA
480 *
481 * Usage: Internal/External
482 *
483 * </ioctl>
484 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485#define WE_SET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530486/*
487 * <ioctl>
488 * txpow2g - current 2 GHz Tx power setting
489 *
490 * @INPUT: Tx power in dBm
491 *
492 * @OUTPUT: None
493 *
494 * This IOTCL used to set 2 ghz tx power
495 *
496 * @E.g: iwpriv wlan0 txpow2g
497 *
498 * Supported Feature: STA
499 *
500 * Usage: Internal/External
501 *
502 * </ioctl>
503 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800504#define WE_SET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530505/*
506 * <ioctl>
507 * txpow5g - Current 5 GHz tx power setting
508 *
509 * @INPUT: Tx power in dBm
510 *
511 * @OUTPUT: None
512 *
513 * This IOTCL used to set the 5 ghz txpower
514 *
515 * @E.g: iwpriv wlan0 txpow5g
516 *
517 * Supported Feature: STA
518 *
519 * Usage: Internal/External
520 *
521 * </ioctl>
522 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523#define WE_SET_TXPOW_5G 30
524/* Private ioctl for firmware debug log */
525#define WE_DBGLOG_LOG_LEVEL 31
526#define WE_DBGLOG_VAP_ENABLE 32
527#define WE_DBGLOG_VAP_DISABLE 33
528#define WE_DBGLOG_MODULE_ENABLE 34
529#define WE_DBGLOG_MODULE_DISABLE 35
530#define WE_DBGLOG_MOD_LOG_LEVEL 36
531#define WE_DBGLOG_TYPE 37
532#define WE_SET_TXRX_FWSTATS 38
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530533/*
534 * <ioctl>
535 * set11ACRates - Fixes the Tx data rate of 11AC
536 *
537 * @INPUT: 0x1 to 0x9
538 *
539 * @OUTPUT: None
540 *
541 * This IOCTL fixes the Tx data rate of 11AC.
542 *
543 * @E.g: iwpriv wlan0 set11ACRates 0x9
544 *
545 * Supported Feature: STA
546 *
547 * Usage: Internal/External
548 *
549 * </ioctl>
550 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551#define WE_SET_VHT_RATE 39
552#define WE_DBGLOG_REPORT_ENABLE 40
553#define WE_TXRX_FWSTATS_RESET 41
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530554/*
555 * <ioctl>
556 * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
557 *
558 * @INPUT: Transmission power in dBm
559 *
560 * @OUTPUT: None
561 *
562 * This IOCTL sets the maximum transmit power for the 2.4-GHz band
563 * This setting does not persist over reboots
564 *
565 * @E.g: iwpriv wlan0 setTxMaxPower2G 10
566 *
567 * Supported Feature: STA
568 *
569 * Usage: Internal/External
570 *
571 * </ioctl>
572 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573#define WE_SET_MAX_TX_POWER_2_4 42
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530574/*
575 * <ioctl>
576 * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
577 *
578 * @INPUT: Transmission power in dBm
579 *
580 * @OUTPUT: None
581 *
582 * This IOCTL sets the maximum transmit power for the 5-GHz band
583 * This setting does not persist over reboots
584 *
585 * @E.g: iwpriv wlan0 setTxMaxPower5G 10
586 *
587 * Supported Feature: STA
588 *
589 * Usage: Internal/External
590 *
591 * </ioctl>
592 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800594#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595/* Private ioctl for packet powe save */
596#define WE_PPS_PAID_MATCH 45
597#define WE_PPS_GID_MATCH 46
598#define WE_PPS_EARLY_TIM_CLEAR 47
599#define WE_PPS_EARLY_DTIM_CLEAR 48
600#define WE_PPS_EOF_PAD_DELIM 49
601#define WE_PPS_MACADDR_MISMATCH 50
602#define WE_PPS_DELIM_CRC_FAIL 51
603#define WE_PPS_GID_NSTS_ZERO 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530604/*
605 * <ioctl>
606 * rssi_chk - Chek the rssi
607 *
608 * @INPUT: One argument as input
609 *
610 * @OUTPUT: rssi
611 * wlan0 rssi_chk:56
612 *
613 * This IOTCL used to chek rssi
614 *
615 * @E.g: iwpriv wlan0 rssi_chk <value>
616 *
617 * Supported Feature: STA
618 *
619 * Usage: Internal/External
620 *
621 * </ioctl>
622 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623#define WE_PPS_RSSI_CHECK 53
Agrawal Ashishbafaff12016-12-27 17:43:08 +0530624/*
625 * <ioctl>
626 * setAutoChannel - set ACS enable/disable
627 *
628 * @INPUT: None
629 *
630 * @OUTPUT: None
631 *
632 * This IOCTL is used to set SAP ACS eanble/disable
633 *
634 * @E.g: iwpriv wlan0 setAutoChannel 0
635 *
636 * Supported Feature: SAP
637 *
638 * Usage: Internal/External
639 *
640 * </ioctl>
641 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530643/*
644 * <ioctl>
645 * htsmps - Sets the htsmps
646 *
647 * @INPUT: Atleast one int argument
648 *
649 * @OUTPUT: None
650 *
651 * This IOTCL used to set htsmps
652 *
653 * @E.g: iwpriv wlan0 htsmps <value>
654 *
655 * Supported Feature: STA
656 *
657 * Usage: Internal/External
658 *
659 * </ioctl>
660 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661#define WE_SET_HTSMPS 55
662/* Private ioctl for QPower */
663#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
664#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
665#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
666#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530667/*
668 * <ioctl>
669 * burst_enable - Enables or disables the burst feature
670 *
671 * @INPUT: 0-Disable, 1-Enable
672 *
673 * @OUTPUT: None
674 *
675 * This IOCTL enables or disables the burst feature.
676 *
677 * @E.g: iwpriv wlan0 burst_enable 0
678 *
679 * Supported Feature: STA
680 *
681 * Usage: Internal/External
682 *
683 * </ioctl>
684 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685#define WE_SET_BURST_ENABLE 60
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530686/*
687 * <ioctl>
688 * burst_dur - Enables or disables the burst feature
689 *
690 * @INPUT: int 1…..int 8191 in microseconds
691 *
692 * @OUTPUT: None
693 *
694 * This IOCTL sets the burst duration.
695 *
696 * @E.g: iwpriv wlan0 burst_dur <value>
697 *
698 * Supported Feature: STA
699 *
700 * Usage: Internal/External
701 *
702 * </ioctl>
703 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704#define WE_SET_BURST_DUR 61
705/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530706/*
707 * <ioctl>
708 * gtxHTMcs - Set the tx HTM value
709 *
710 * @INPUT: Atleast one int orgument
711 *
712 * @OUTPUT: None
713 *
714 * This IOTCL sets htm tx value
715 *
716 * @E.g: iwpriv wlan0 gtxHTMcs <value>
717 *
718 * Supported Feature: STA
719 *
720 * Usage: Internal/External
721 *
722 * </ioctl>
723 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724#define WE_SET_GTX_HT_MCS 62
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530725/*
726 * <ioctl>
727 * gtxVHTMcs - Set gtxVHTMcs value
728 *
729 * @INPUT: Atleast one int argument
730 *
731 * @OUTPUT: None
732 *
733 * This IOTCL used to set gtxVHTMcs value
734 *
735 * @E.g: iwpriv wlan0 gtxVHTMcs <value>
736 *
737 * Supported Feature: STA
738 *
739 * Usage: Internal/External
740 *
741 * </ioctl>
742 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743#define WE_SET_GTX_VHT_MCS 63
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530744/*
745 * <ioctl>
746 * gtxUsrCfg - Host request for GTX mask
747 *
748 * @INPUT: Atleast one int orgument
749 *
750 * @OUTPUT: None
751 *
752 * This IOTCL used send the host request for GTX mask
753 *
754 * @E.g: iwpriv wlan0 gtxUsrCfg <value>
755 *
756 * Supported Feature: STA
757 *
758 * Usage: Internal/External
759 *
760 * </ioctl>
761 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762#define WE_SET_GTX_USRCFG 64
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530763/*
764 * <ioctl>
765 * gtxThre - Set the tx threshold
766 *
767 * @INPUT: Atleast one int argument
768 *
769 * @OUTPUT: None
770 *
771 * This IOTCL used to set tx threshold
772 *
773 * @E.g: iwpriv wlan0 gtxThre <value>
774 *
775 * Supported Feature: STA
776 *
777 * Usage: Internal/External
778 *
779 * </ioctl>
780 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781#define WE_SET_GTX_THRE 65
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530782/*
783 * <ioctl>
784 * gtxMargin - Set the gtxMargin
785 *
786 * @INPUT: 1 to 32
787 *
788 * @OUTPUT: None
789 *
790 * This IOTCL use dto set gtxMargin
791 *
792 * @E.g: iwpriv wlan0 gtxMargini <value>
793 *
794 * Supported Feature: STA
795 *
796 * Usage: Internal/External
797 *
798 * </ioctl>
799 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800#define WE_SET_GTX_MARGIN 66
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530801/*
802 * <ioctl>
803 * gtxStep - Set the gtxStep
804 *
805 * @INPUT: None
806 *
807 * @OUTPUT: None
808 *
809 * This IOTCL used to sets gtxStep
810 *
811 * @E.g: iwpriv wlan0 gtxStep <value>
812 *
813 * Supported Feature: STA
814 *
815 * Usage: Internal/External
816 *
817 * </ioctl>
818 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819#define WE_SET_GTX_STEP 67
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530820/*
821 * <ioctl>
822 * gtxMinTpc - Sets the gtxMinTpc
823 *
824 * @INPUT: Atleast one int argument
825 *
826 * @OUTPUT: None
827 *
828 * This IOTCL sets the tx MinTpc
829 *
830 * @E.g: iwpriv wlan0 gtxMinTpc <value>
831 *
832 * Supported Feature: STA
833 *
834 * Usage: Internal/External
835 *
836 * </ioctl>
837 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838#define WE_SET_GTX_MINTPC 68
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530839/*
840 * <ioctl>
841 * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
842 *
843 * @INPUT: Mask value
844 *
845 * @OUTPUT: None
846 *
847 * This IOTCL used to set gtxBWMask
848 *
849 * @E.g: iwpriv wlan0 gtxBWMask <value>
850 *
851 * Supported Feature: STA
852 *
853 * Usage: Internal/External
854 *
855 * </ioctl>
856 */
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530857
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530858#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530859/*
860 * <ioctl>
861 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
862 *
863 * @INPUT: set_value
864 *
865 * @OUTPUT: None
866 *
867 * This IOCTL is used to set the MCC latency value in milliseconds
868 * during STA-P2P concurrency.
869 *
870 * If 0ms latency is provided, then FW will set to a default.
871 * Otherwise, latency must be at least 30ms.
872 *
873 * @E.g: iwpriv wlan0 setMccLatency 40
874 *
875 *
876 * Supported Feature: Concurrency
877 *
878 * Usage: Internal/External
879 *
880 * </ioctl>
881 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530883
884/*
885 * <ioctl>
886 * setMccQuota- Set the quota for P2P cases
887 *
888 * @INPUT: set_value [0,100]
889 *
890 * @OUTPUT: None
891 *
892 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
893 *
894 * Currently used to set time quota for 2 MCC vdevs/adapters using
895 * (operating channel, quota) for each mode.
896 * The info is provided run time using iwpriv command:
897 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
898 * Note: the quota provided in command is for the same mode in cmd.
899 * HDD checks if MCC mode is active, gets the second mode and its
900 * operating chan.
901 * Quota for the 2nd role is calculated as 100 - quota of first mode.
902 *
903 * @E.g: iwpriv wlan0 setMccQuota 50
904 * iwpriv p2p0 setMccQuota 50
905 *
906 * Supported Feature: Concurrency
907 *
908 * Usage: Internal/External
909 *
910 * </ioctl>
911 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912#define WE_MCC_CONFIG_QUOTA 71
913/* Private IOCTL for debug connection issues */
914#define WE_SET_DEBUG_LOG 72
915#ifdef WE_SET_TX_POWER
916#undef WE_SET_TX_POWER
917#endif
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -0800918
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530919/*
920 * <ioctl>
921 * setTxPower - Set the current transmit power
922 *
923 * @INPUT: Transmission power in dBm
924 *
925 * @OUTPUT: None
926 *
927 * This IOCTL sets the current transmit power.
928 * This setting does not persist over reboots.
929 *
930 * @E.g: iwpriv wlan0 setTxPower 10
931 *
932 * Supported Feature: STA
933 *
934 * Usage: Internal/External
935 *
936 * </ioctl>
937 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938#define WE_SET_TX_POWER 74
939/* Private ioctl for earlyrx power save feature */
940#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
941#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
942#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
943#define WE_SET_EARLY_RX_SLOP_STEP 78
944#define WE_SET_EARLY_RX_INIT_SLOP 79
945#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530946/*
947 * <ioctl>
948 * setMcRate - Set the data rate for multicast data
949 *
950 * @INPUT: 1 to 32
951 *
952 * @OUTPUT: None
953 *
954 * This IOCTL sets the data rate for multicast data. Note that this command
955 * is allowed only in STA, IBSS, or QCMobileAP mode
956 *
957 * @E.g: iwpriv wlan0 setMcRate <value>
958 *
959 * Supported Feature: STA
960 *
961 * Usage: Internal/External
962 *
963 * </ioctl>
964 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965#define WE_SET_MC_RATE 81
966#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
967/* Private ioctl for packet power save */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530968/*
969 * <ioctl>
970 * 5g_ebt - Sets the 5g_ebt
971 *
972 * @INPUT: <value>
973 *
974 * @OUTPUT: None
975 *
976 * This IOTCL used to set 5g_ebt
977 *
978 * @E.g: iwpriv wlan0 5g_ebt <value>
979 *
980 * Supported Feature: STA
981 *
982 * Usage: Internal/External
983 *
984 * </ioctl>
985 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986#define WE_PPS_5G_EBT 83
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530987/*
988 * <ioctl>
989 * cts_cbw - Set CTS channel BW for dynamic BW adjustment
990 *
991 * @INPUT: 20 t0 160
992 *
993 * @OUTPUT: None
994 *
995 * This IOTCL used to set CTS channel BW for dynamic BW adjustment
996 *
997 * @E.g: iwpriv wlan0 cts_cbw <value>
998 *
999 * Supported Feature: STA
1000 *
1001 * Usage: Internal/External
1002 *
1003 * </ioctl>
1004 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005#define WE_SET_CTS_CBW 84
1006#define WE_DUMP_STATS 85
1007#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +05301008/* Private sub ioctl for starting/stopping the profiling */
1009#define WE_START_FW_PROFILE 87
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301010
Abhishek Singh3c507012016-12-01 11:15:42 +05301011/*
1012 * <ioctl>
1013 * setChanChange - Initiate channel change
1014 *
1015 * @INPUT: channel number to switch to.
1016 *
1017 * @OUTPUT: None
1018 *
1019 * This IOCTL is used to initiate a channel change.
1020 * If called on STA/CLI interface it will send the
1021 * ECSA action frame to the connected SAP/GO asking to
1022 * initiate the ECSA, if supported.
1023 * If called on SAP/GO interface it will initiate
1024 * ECSA and ask connected peers to move to new channel.
1025 *
1026 * @E.g: iwpriv wlan0 setChanChange <channel>
1027 * iwpriv wlan0 setChanChange 1
1028 *
1029 * Supported Feature: ECSA
1030 *
1031 * Usage: Internal/External
1032 *
1033 * </ioctl>
1034 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +05301035#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05301036#define WE_SET_CONC_SYSTEM_PREF 89
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08001037#define WE_SET_TXRX_STATS 90
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08001039/*
1040 * <ioctl>
1041 * set_11ax_rate - set 11ax rates to FW
1042 *
1043 * @INPUT: rate code
1044 *
1045 * @OUTPUT: None
1046 *
1047 * This IOCTL fixes the Tx data rate of 11AX.
1048 *
1049 * @E.g: iwpriv wlan0 set_11ax_rate <rate code>
1050 *
1051 * Supported Feature: STA/SAP
1052 *
1053 * Usage: Internal
1054 *
1055 * </ioctl>
1056 */
1057#define WE_SET_11AX_RATE 91
1058
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001059/*
1060 * <ioctl>
1061 * enable_dcm - enable Dual Carrier Modulation(DCM)
1062 *
1063 * @INPUT: 0/1
1064 *
1065 * @OUTPUT: None
1066 *
1067 * This IOCTL enables/disables DCM.
1068 *
1069 * @E.g: iwpriv wlan0 enable_dcm <0/1>
1070 *
1071 * Supported Feature: STA/SAP
1072 *
1073 * Usage: Internal
1074 *
1075 * </ioctl>
1076 */
1077#define WE_SET_DCM 92
1078
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001079/*
1080 * <ioctl>
Naveen Rawat53448ea2017-11-27 11:43:18 -08001081 * range_ext - enable Range extension
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001082 *
1083 * @INPUT: 0/1
1084 *
1085 * @OUTPUT: None
1086 *
1087 * This IOCTL enables/disables Range extension.
1088 *
Naveen Rawat53448ea2017-11-27 11:43:18 -08001089 * @E.g: iwpriv wlan0 range_ext <1/0>
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001090 *
1091 * Supported Feature: STA/SAP
1092 *
1093 * Usage: Internal
1094 *
1095 * </ioctl>
1096 */
1097#define WE_SET_RANGE_EXT 93
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001098
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301099/*
1100 * <ioctl>
1101 * wow_ito - sets the timeout value for inactivity data while
1102 * in power save mode during wow
1103 *
1104 * @INPUT: int
1105 *
1106 * @OUTPUT: None
1107 *
1108 * This IOCTL set the timeout value for inactivity data in power save mode
1109 *
1110 * @E.g: iwpriv wlan0 wow_ito 20
1111 *
1112 * Supported Feature: STA
1113 *
1114 * Usage: External
1115 *
1116 * </ioctl>
Jeff Johnsondcf84ce2017-10-05 09:26:24 -07001117 */
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301118#define WE_SET_WOW_DATA_INACTIVITY_TO 94
1119
Jeff Johnson011c4502017-10-05 15:25:56 -07001120/*
1121 * <ioctl>
1122 * pdev_reset - reset the pdev
1123 *
1124 * @INPUT: Reset command to initiate:
1125 * TX_FLUSH = 1
1126 * WARM_RESET = 2
1127 * COLD_RESET = 3
1128 * WARM_RESET_RESTORE_CAL = 4
1129 * COLD_RESET_RESTORE_CAL = 5
1130 *
1131 * @OUTPUT: None
1132 *
1133 * This IOCTL is used to reset the pdev. The primary use is
1134 * for internal testing. It is not expected that this will
1135 * be used on a production device.
1136 *
1137 * @E.g: iwpriv wlan0 pdev_reset <command>
1138 * iwpriv wlan0 pdev_reset 1
1139 *
1140 * Supported Feature: None
1141 *
1142 * Usage: Internal
1143 *
1144 * </ioctl>
1145 */
1146#define WE_SET_PDEV_RESET 95
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301147
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05301148/*
1149 * setModDTIM - Change Modulated DTIM
1150 *
1151 * @INPUT: set_value.
1152 *
1153 * @OUTPUT: None
1154 *
1155 * This IOCTL is used to change modulated DTIM
1156 * value without WIFI OFF/ON.
1157 *
1158 * @E.g: iwpriv wlan0 setModDTIM <value>
1159 * iwpriv wlan0 setModDTIM 2
1160 *
1161 * Supported Feature: N/A
1162 *
1163 * Usage: Internal/External
1164 *
1165 * </ioctl>
1166 */
1167#define WE_SET_MODULATED_DTIM 96
1168
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169/* Private ioctls and their sub-ioctls */
1170#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
1171#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172#define WE_SET_SAP_CHANNELS 3
1173#define WE_GET_WLAN_DBG 4
1174#define WE_GET_MAX_ASSOC 6
1175/* 7 is unused */
1176#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +05301177
1178/*
1179 * <ioctl>
1180 * getconcurrency - Get concurrency mode
1181 *
1182 * @INPUT: None
1183 *
1184 * @OUTPUT: It shows concurrency value
1185 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
1186 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
1187 * 8:OCB 9:EPPING 10:QVIT 11:NDI
1188 *
1189 * This IOCTL is used to retrieve concurrency mode.
1190 *
1191 * @E.g: iwpriv wlan0 getconcurrency
1192 * wlan0 getconcurrency:5
1193 * Above value shows STA+P2P_Client
1194 *
1195 * Supported Feature: Concurrency
1196 *
1197 * Usage: Internal/External
1198 *
1199 * </ioctl>
1200 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201#define WE_GET_CONCURRENCY_MODE 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301202/*
1203 * <ioctl>
1204 * get_nss - Get the number of spatial STBC streams (NSS)
1205 *
1206 * @INPUT: None
1207 *
1208 * @OUTPUT: NSS
1209 * wlan0 get_nss:2
1210 *
1211 * This IOTCL used to get the number of spatial STBC streams
1212 *
1213 * @E.g: iwpriv wlan0 get_nss
1214 *
1215 * Supported Feature: STA
1216 *
1217 * Usage: Internal/External
1218 *
1219 * </ioctl>
1220 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221#define WE_GET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301222/*
1223 * <ioctl>
1224 * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1225 *
1226 * @INPUT: None
1227 *
1228 * @OUTPUT: ldpc
1229 * wlan0 get_ldpc:1
1230 *
1231 * This IOTCL used to gets the low density parity check (LDPC)
1232 *
1233 * @E.g: iwpriv wlan0 get_ldpc
1234 *
1235 * Supported Feature: STA
1236 *
1237 * Usage: Internal/External
1238 *
1239 * </ioctl>
1240 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241#define WE_GET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301242/*
1243 * <ioctl>
1244 * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1245 *
1246 * @INPUT: None
1247 *
1248 * @OUTPUT: TXSTBC
1249 * wlan0 get_tx_stbc:1
1250 *
1251 * This IOTCL get the value of the current Tx space time block code (STBC)
1252 *
1253 * @E.g: iwpriv wlan0 get_tx_stbc
1254 *
1255 * Supported Feature: STA
1256 *
1257 * Usage: Internal/External
1258 *
1259 * </ioctl>
1260 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261#define WE_GET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301262/*
1263 * <ioctl>
1264 * get_rx_stbc - Gets the value of the current Rx STBC
1265 *
1266 * @INPUT: None
1267 *
1268 * @OUTPUT: Rx STBC
1269 * wlan0 get_rx_stbc:1
1270 *
1271 * This IOTCL used to get the value of the current Rx STBC
1272 *
1273 * @E.g: iwpriv wlan0 get_rx_stbc
1274 *
1275 * Supported Feature: STA
1276 *
1277 * Usage: Internal/External
1278 *
1279 * </ioctl>
1280 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281#define WE_GET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301282/*
1283 * <ioctl>
1284 * get_shortgi - Get the value of the current short GI setting
1285 *
1286 * @INPUT: None
1287 *
1288 * @OUTPUT: Enable/disable of shortgi
1289 * wlan0 get_shortgi:1
1290 *
1291 * This IOCTL gets the value of the current short GI setting
1292 *
1293 * @E.g: iwpriv wlan0 get_shortgi
1294 *
1295 * Supported Feature: STA
1296 *
1297 * Usage: Internal/External
1298 *
1299 * </ioctl>
1300 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301#define WE_GET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301302/*
1303 * <ioctl>
1304 * get_rtscts - Get the value of the current RTS/CTS setting.
1305 *
1306 * @INPUT: None
1307 *
1308 * @OUTPUT: Enable/disable of RTS/CTS
1309 * wlan0 get_rtscts:33
1310 *
1311 * This IOTCL get the value of the current RTS/CTS setting.
1312 *
1313 * @E.g: iwpriv wlan0 get_rtscts
1314 *
1315 * Supported Feature: STA
1316 *
1317 * Usage: Internal/External
1318 *
1319 * </ioctl>
1320 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321#define WE_GET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301322/*
1323 * <ioctl>
1324 * get_chwidth - Get the current channel width setting
1325 *
1326 * @INPUT: None
1327 *
1328 * @OUTPUT: channel width
1329 * wlan0 get_chwidth:0
1330 *
1331 * This IOTCL get the current channel width setting.
1332 *
1333 * @E.g: iwpriv wlan0 get_chwidth
1334 *
1335 * Supported Feature: STA
1336 *
1337 * Usage: Internal/External
1338 *
1339 * </ioctl>
1340 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341#define WE_GET_CHWIDTH 17
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301342/*
1343 * <ioctl>
1344 * get_anienable - Get the anienable
1345 *
1346 * @INPUT: None
1347 *
1348 * @OUTPUT:
1349 * wlan0 get_anienable:0
1350 *
1351 * This IOTCL get the anienable
1352 *
1353 * @E.g: iwpriv wlan0 get_anienable
1354 *
1355 * Supported Feature: STA
1356 *
1357 * Usage: Internal/External
1358 *
1359 * </ioctl>
1360 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361#define WE_GET_ANI_EN_DIS 18
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301362/*
1363 * <ioctl>
1364 * get_aniplen - Get the aniplen
1365 *
1366 * @INPUT: None
1367 *
1368 * @OUTPUT:
1369 * wlan0 get_aniplen:0
1370 *
1371 * This IOTCL get the aniplen
1372 *
1373 * @E.g: iwpriv wlan0 get_aniplen
1374 *
1375 * Supported Feature: STA
1376 *
1377 * Usage: Internal/External
1378 *
1379 * </ioctl>
1380 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381#define WE_GET_ANI_POLL_PERIOD 19
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301382/*
1383 * <ioctl>
1384 * get_anilislen- Get the anilislen
1385 *
1386 * @INPUT: None
1387 *
1388 * @OUTPUT:
1389 * wlan0 get_anilislen:0
1390 *
1391 * This IOTCL used to get anilislen
1392 *
1393 * @E.g: iwpriv wlan0 get_anilislen
1394 *
1395 * Supported Feature: STA
1396 *
1397 * Usage: Internal/External
1398 *
1399 * </ioctl>
1400 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401#define WE_GET_ANI_LISTEN_PERIOD 20
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301402/*
1403 * <ioctl>
1404 * get_aniofdmlvl - Get the OFDM level
1405 *
1406 * @INPUT: None
1407 *
1408 * @OUTPUT: OFDM
1409 * wlan0 get_aniofdmlvl:0
1410 *
1411 * This IOTCL used to get ofdm level
1412 *
1413 * @E.g: iwpriv wlan0 get_aniofdmlvl
1414 *
1415 * Supported Feature: STA
1416 *
1417 * Usage: Internal/External
1418 *
1419 * </ioctl>
1420 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421#define WE_GET_ANI_OFDM_LEVEL 21
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301422/*
1423 * <ioctl>
1424 * get_aniccklvl - Get the cck level
1425 *
1426 * @INPUT: None
1427 *
1428 * @OUTPUT:
1429 * wlan0 get_aniccklvl:0
1430 *
1431 * This IOTCL used to get cck level
1432 *
1433 * @E.g: iwpriv wlan0 get_aniccklvl
1434 *
1435 * Supported Feature: STA
1436 *
1437 * Usage: Internal/External
1438 *
1439 * </ioctl>
1440 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441#define WE_GET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301442/*
1443 * <ioctl>
1444 * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1445 *
1446 * @INPUT: None
1447 *
1448 * @OUTPUT: Enable/disable dynamic channel bandwidth
1449 * wlan0 get_cwmenable:0
1450 *
1451 * This IOTCL get the value of the dynamic channel bandwidth setting
1452 *
1453 * @E.g: iwpriv wlan0 get_cwmenable
1454 *
1455 * Supported Feature: STA
1456 *
1457 * Usage: Internal/External
1458 *
1459 * </ioctl>
1460 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461#define WE_GET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301462/*
1463 * <ioctl>
1464 * get_txchainmask - Get the txchainmask that was set
1465 *
1466 * @INPUT: None
1467 *
1468 * @OUTPUT: txchainmask
1469 * wlan0 get_txchainmask:1
1470 *
1471 * This IOCTL gets the txchainmask that was set
1472 * This command is useful if it was previously set
1473 *
1474 * @E.g: iwpriv wlan0 get_txchainmask
1475 *
1476 * Supported Feature: STA
1477 *
1478 * Usage: Internal/External
1479 *
1480 * </ioctl>
1481 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482#define WE_GET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301483/*
1484 * <ioctl>
1485 * get_rxchainmask - Get the rxchainmask that was set
1486 *
1487 * @INPUT: None
1488 *
1489 * @OUTPUT: rxchainmask
1490 * wlan0 get_rxchainmask:1
1491 *
1492 * This IOCTL gets the rxchainmask that was set
1493 * This command is useful only if it was previously set.
1494 *
1495 * @E.g: iwpriv wlan0 get_rxchainmask
1496 *
1497 * Supported Feature: STA
1498 *
1499 * Usage: Internal/External
1500 *
1501 * </ioctl>
1502 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503#define WE_GET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301504/*
1505 * <ioctl>
1506 * get_11nrate - Get the fixed Tx data rate
1507 *
1508 * @INPUT: None
1509 *
1510 * @OUTPUT: Using this command does not return the same value as set
1511 * wlan0 get_11nrate:0
1512 *
1513 * This IOCTL gets the fixed Tx data rate
1514 * This command is useful only if setting the fixed Tx rate.
1515 *
1516 * @E.g: iwpriv wlan0 get_11nrate
1517 *
1518 * Supported Feature: STA
1519 *
1520 * Usage: Internal/External
1521 *
1522 * </ioctl>
1523 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524#define WE_GET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301525/*
1526 * <ioctl>
1527 * get_ampdu - Get the maximum subframe of ampdu
1528 *
1529 * @INPUT: None
1530 *
1531 * @OUTPUT: Maximum subframe of ampdu
1532 * wlan0 get_ampdu:1
1533 *
1534 * This IOCTL gets the maximum subframe of ampdu
1535 * This command is useful only if setting ampdu.
1536 *
1537 * @E.g: iwpriv wlan0 get_ampdu
1538 *
1539 * Supported Feature: STA
1540 *
1541 * Usage: Internal/External
1542 *
1543 * </ioctl>
1544 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545#define WE_GET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301546/*
1547 * <ioctl>
1548 * get_amsdu - Get the maximum subframe of amsdu
1549 *
1550 * @INPUT: None
1551 *
1552 * @OUTPUT: Maximum subframe of amsdu
1553 * wlan0 get_amsdu:1
1554 *
1555 * This IOCTL gets the maximum subframe of amsdu.
1556 * This command is useful only if setting amsdu
1557 *
1558 * @E.g: iwpriv wlan0 get_amsdu
1559 *
1560 * Supported Feature: STA
1561 *
1562 * Usage: Internal/External
1563 *
1564 * </ioctl>
1565 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566#define WE_GET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301567/*
1568 * <ioctl>
1569 * get_txpow2g - Get the current 2 GHz Tx power setting
1570 *
1571 * @INPUT: None
1572 *
1573 * @OUTPUT: Tx Power in dbm
1574 * wlan0 get_txpow2g:0
1575 *
1576 * This IOCTL gets the current 2 GHz Tx power setting
1577 * This command is useful if setting Tx power
1578 *
1579 * @E.g: iwpriv wlan0 get_txpow2g
1580 *
1581 * Supported Feature: STA
1582 *
1583 * Usage: Internal/External
1584 *
1585 * </ioctl>
1586 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587#define WE_GET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301588/*
1589 * <ioctl>
1590 * get_txpow5g - Get the current 5 GHz Tx power setting
1591 *
1592 * @INPUT: None
1593 *
1594 * @OUTPUT: Tx Power in dbm
1595 * wlan0 get_txpow5g:0
1596 *
1597 * This IOCTL gets the current 5 GHz Tx power setting
1598 * This command is useful if setting Tx power
1599 *
1600 * @E.g: iwpriv wlan0 get_txpow5g
1601 *
1602 * Supported Feature: STA
1603 *
1604 * Usage: Internal/External
1605 *
1606 * </ioctl>
1607 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -08001609/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610#define WE_GET_PPS_PAID_MATCH 32
1611#define WE_GET_PPS_GID_MATCH 33
1612#define WE_GET_PPS_EARLY_TIM_CLEAR 34
1613#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
1614#define WE_GET_PPS_EOF_PAD_DELIM 36
1615#define WE_GET_PPS_MACADDR_MISMATCH 37
1616#define WE_GET_PPS_DELIM_CRC_FAIL 38
1617#define WE_GET_PPS_GID_NSTS_ZERO 39
1618#define WE_GET_PPS_RSSI_CHECK 40
1619/* Private ioctl for QPower */
1620#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
1621#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
1622#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
1623#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301624/*
1625 * <ioctl>
1626 * get_burst_en - Enables or disables the burst feature
1627 *
1628 * @INPUT: None
1629 *
1630 * @OUTPUT: Enable/disable of burst feature
1631 * wlan0 get_burst_en:1
1632 *
1633 * This IOCTL enables or disables the burst feature
1634 *
1635 * @E.g: iwpriv wlan0 get_burst_en
1636 *
1637 * Supported Feature:STA
1638 *
1639 * Usage: Internal/External
1640 *
1641 * </ioctl>
1642 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643#define WE_GET_BURST_ENABLE 45
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301644/*
1645 * <ioctl>
1646 * get_burst_dur - Get the burst duration
1647 *
1648 * @INPUT: None
1649 *
1650 * @OUTPUT: Duration in microseconds
1651 * wlan0 get_burst_dur:8160
1652 *
1653 * This IOCTL gets the burst duration
1654 * This command is useful if setting burst enable
1655 *
1656 * @E.g: iwpriv wlan0 get_burst_dur
1657 *
1658 * Supported Feature: STA
1659 *
1660 * Usage: Internal/External
1661 *
1662 * </ioctl>
1663 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664#define WE_GET_BURST_DUR 46
1665/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301666/*
1667 * <ioctl>
1668 * get_gtxHTMcs - Get the tx HTM
1669 *
1670 * @INPUT: None
1671 *
1672 * @OUTPUT: HTM
1673 * wlan0 get_gtxHTMcs:32896
1674 *
1675 * This IOTCL used to get HTM
1676 *
1677 * @E.g: iwpriv wlan0 get_gtxHTMcs
1678 *
1679 * Supported Feature: STA
1680 *
1681 * Usage: Internal/External
1682 *
1683 * </ioctl>
1684 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685#define WE_GET_GTX_HT_MCS 47
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301686/*
1687 * <ioctl>
1688 * get_gtxVHTMcs - Get the VHTM
1689 *
1690 * @INPUT: None
1691 *
1692 * @OUTPUT: VHTM
1693 * wlan0 get_gtxVHTMcs:524800
1694 *
1695 * This IOTCL used to get the VHTM
1696 *
1697 * @E.g: iwpriv wlan0 get_gtxVHTMcs
1698 *
1699 * Supported Feature: STA
1700 *
1701 * Usage: Internal/External
1702 *
1703 * </ioctl>
1704 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705#define WE_GET_GTX_VHT_MCS 48
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301706/*
1707 * <ioctl>
1708 * get_gtxUsrCfg - Get the tx cfg
1709 *
1710 * @INPUT: None
1711 *
1712 * @OUTPUT: TXCFG
1713 * wlan0 get_gtxUsrCfg:32
1714 *
1715 * This IOTCL used to get the tx cfg
1716 *
1717 * @E.g: iwpriv wlan0 get_gtxUsrCfg
1718 *
1719 * Supported Feature: STA
1720 *
1721 * Usage: Internal/External
1722 *
1723 * </ioctl>
1724 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725#define WE_GET_GTX_USRCFG 49
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301726/*
1727 * <ioctl>
1728 * get_gtxThre - Get the tx threshold
1729 *
1730 * @INPUT: None
1731 *
1732 * @OUTPUT: Threshold
1733 * wlan0 get_gtxThre:3
1734 *
1735 * This IOCTL is used to get tx threshold
1736 *
1737 * @E.g: iwpriv wlan0 get_gtxThre
1738 *
1739 * Supported Feature: STA
1740 *
1741 * Usage: Internal/External
1742 *
1743 * </ioctl>
1744 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745#define WE_GET_GTX_THRE 50
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301746/*
1747 * <ioctl>
1748 * get_gtxMargin - Get the tx margin
1749 *
1750 * @INPUT: None
1751 *
1752 * @OUTPUT: GTXMARGIN
1753 * wlan0 get_gtxMargin:2
1754 *
1755 * This IOCTL is used to set tx margin
1756 *
1757 * @E.g: iwpriv wlan0 get_gtxMargin
1758 *
1759 * Supported Feature: STA
1760 *
1761 * Usage: Internal/External
1762 *
1763 * </ioctl>
1764 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765#define WE_GET_GTX_MARGIN 51
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301766/*
1767 * <ioctl>
1768 * get_gtxStep - Get the tx step
1769 *
1770 * @INPUT: None
1771 *
1772 * @OUTPUT: GTXSTEP
1773 * wlan0 get_gtxStep:0
1774 *
1775 * This IOCTL is used to get the gtx step
1776 *
1777 * @E.g: iwpriv wlan0 get_gtxStep
1778 *
1779 * Supported Feature: STA
1780 *
1781 * Usage: Internal/External
1782 *
1783 * </ioctl>
1784 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785#define WE_GET_GTX_STEP 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301786/*
1787 * <ioctl>
1788 * get_gtxMinTpc - Get the tx miminum tpc
1789 *
1790 * @INPUT: None
1791 *
1792 * @OUTPUT: TPC
1793 * wlan0 get_gtxMinTpc:0
1794 *
1795 * This IOCTL is used to get tx miminum tpc
1796 *
1797 * @E.g: iwpriv wlan0 get_gtxMinTpc
1798 *
1799 * Supported Feature: STA
1800 *
1801 * Usage: Internal/External
1802 *
1803 * </ioctl>
1804 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805#define WE_GET_GTX_MINTPC 53
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301806/*
1807 * <ioctl>
1808 * get_gtxBWMask - Get the tx BW MASK
1809 *
1810 * @INPUT: None
1811 *
1812 * @OUTPUT: MASK
1813 * wlan0 get_gtxBWMask:15
1814 *
1815 * This IOCTL is used get gtx bw mask
1816 *
1817 * @E.g: iwpriv wlan0 get_gtxBWMask
1818 *
1819 * Supported Feature: STA
1820 *
1821 * Usage: Internal/External
1822 *
1823 * </ioctl>
1824 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825#define WE_GET_GTX_BWMASK 54
1826#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001827#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07001828#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001830/*
1831 * <ioctl>
1832 * get_dcm - Get dcm enablement value
1833 *
1834 * @INPUT: None
1835 *
1836 * @OUTPUT: 0/1
1837 * wlan0 get_dcm
1838 *
1839 * This IOCTL is used get dcm value
1840 *
1841 * Supported Feature: STA/SAP
1842 *
1843 * Usage: Internal
1844 *
1845 * </ioctl>
1846 */
1847#define WE_GET_DCM 60
1848
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001849/*
1850 * <ioctl>
1851 * get_dcm - Get range extension enablement value
1852 *
1853 * @INPUT: None
1854 *
1855 * @OUTPUT: 0/1
1856 * wlan0 get_range_ext
1857 *
1858 * This IOCTL is used get range_extension value
1859 *
1860 * Supported Feature: STA/SAP
1861 *
1862 * Usage: Internal
1863 *
1864 * </ioctl>
1865 */
1866#define WE_GET_RANGE_EXT 61
1867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868/* Private ioctls and their sub-ioctls */
1869#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
1870
1871/* Private ioctls and their sub-ioctls */
1872#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
1873#define WE_WOWL_ADD_PTRN 1
1874#define WE_WOWL_DEL_PTRN 2
Sreelakshmi Konamkided64d72017-02-23 10:39:26 +05301875/*
1876 * <ioctl>
1877 * neighbor - Send neighbor report request
1878 *
1879 * @INPUT: string
1880 *
1881 * @OUTPUT: None
1882 *
1883 * This IOCTL create a Neighbor report request and send it to peer
1884 *
1885 * @E.g: iwpriv wlan0 neighbor "SSID"
1886 *
1887 * Supported Feature: 11k
1888 *
1889 * Usage: Internal/External
1890 *
1891 * </ioctl>
1892 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893#define WE_NEIGHBOR_REPORT_REQUEST 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301894/*
1895 * <ioctl>
1896 * set_ap_wps_ie - Set the P2P IE of the probe response
1897 *
1898 * @INPUT: string
1899 *
1900 * @OUTPUT: None
1901 *
1902 * This IOCTL sets the P2P IE of the probe response
1903 *
1904 * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1905 *
1906 * Supported Feature: STA
1907 *
1908 * Usage: Internal/External
1909 *
1910 * </ioctl>
1911 */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07001912#define WE_SET_AP_WPS_IE 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913#define WE_SET_CONFIG 5
1914
1915/* Private ioctls and their sub-ioctls */
1916#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
1917#define WE_SET_WLAN_DBG 1
1918#define WE_SET_DP_TRACE 2
1919#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05301920#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921
1922/* Private ioctls and their sub-ioctls */
1923#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
1924#define WE_WLAN_VERSION 1
1925#define WE_GET_STATS 2
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301926/*
1927 * <ioctl>
1928 * getConfig - gets the values of all configurations listed in WCNSS
1929 *
1930 * @INPUT: None
1931 *
1932 * @OUTPUT: Current configuration to the sys log
1933 * wlan0 getConfig: WLAN configuration written to system log
1934 *
1935 * This IOCTL gets the values of all configurations listed in WCNSS
1936 *
1937 * @E.g: iwpriv wlan0 getConfig
1938 *
1939 * Supported Feature: STA
1940 *
1941 * Usage: Internal/External
1942 *
1943 * </ioctl>
1944 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945#define WE_GET_CFG 3
1946#define WE_GET_WMM_STATUS 4
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301947/*
1948 * <ioctl>
1949 * getChannelList - Get the available channel list while in QCMobileAP
1950 *
1951 * @INPUT: None
1952 *
1953 * @OUTPUT: Channel list
1954 * wlan0 getChannelList:36 US 1..165
1955 *
1956 * This IOCTL gets the available channel list while in QCMobileAP
1957 *
1958 * @E.g: iwpriv wlan0 getChannelList
1959 *
1960 * Supported Feature: STA
1961 *
1962 * Usage: Internal/External
1963 *
1964 * </ioctl>
1965 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966#define WE_GET_CHANNEL_LIST 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301967/*
1968 * <ioctl>
1969 * getRSSI - Get the Received Signal Strength Indicator
1970 *
1971 * @INPUT: None
1972 *
1973 * @OUTPUT: RSSI
1974 * wlan0 getRSSI:rsssi=-32
1975 *
1976 * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1977 *
1978 * @E.g: iwpriv wlan0 getRSSI
1979 *
1980 * Supported Feature: STA
1981 *
1982 * Usage: Internal/External
1983 *
1984 * </ioctl>
1985 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -08001987
1988/*
1989 * <ioctl>
1990 * getSuspendStats - Get suspend/resume stats
1991 *
1992 * @INPUT: None
1993 *
1994 * @OUTPUT: character string containing formatted suspend/resume stats
1995 *
1996 * This ioctl is used to get suspend/resume stats formatted for display.
1997 * Currently it includes suspend/resume counts, wow wake up reasons, and
1998 * suspend fail reasons.
1999 *
2000 * @E.g: iwpriv wlan0 getSuspendStats
2001 * iwpriv wlan0 getSuspendStats
2002 *
2003 * Supported Feature: suspend/resume
2004 *
2005 * Usage: Internal
2006 *
2007 * </ioctl>
2008 */
2009#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302011/*
2012 * <ioctl>
2013 * getTdlsPeers - Get all TDLS peers.
2014 *
2015 * @INPUT: None
2016 *
2017 * @OUTPUT: Returns the MAC address of all the TDLS peers
2018 * wlan0 getTdlsPeers:
2019 * MAC Id cap up RSSI
2020 * ---------------------------------
2021 * 00:0a:f5:0e:bd:18 2 Y Y -44
2022 * 00:0a:f5:bf:0e:12 0 N N 0
2023 *
2024 * This IOCTL is used to get all TDLS peers.
2025 *
2026 * @E.g: iwpriv wlan0 getTdlsPeers
2027 *
2028 * Supported Feature: TDLS
2029 *
2030 * Usage: Internal/External
2031 *
2032 * </ioctl>
2033 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034#define WE_GET_TDLS_PEERS 8
2035#endif
2036#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +05302037/*
2038 * <ioctl>
2039 * getPMFInfo - get the PMF info of the connected session
2040 *
2041 * @INPUT: None
2042 *
2043 * @OUTPUT:
2044 * wlan0 getPMFInfo:
2045 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
2046 * Number of Unprotected Disassocs 0
2047 * Number of Unprotected Deauths 0
2048 *
2049 * This IOCTL is used to get the PMF stats/status of the current
2050 * connection.
2051 *
2052 * @e.g:iwpriv wlan0 getPMFInfo
2053 *
2054 * Supported Feature: PMF
2055 *
2056 * Usage: Internal/External
2057 *
2058 * </ioctl>
2059 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060#define WE_GET_11W_INFO 9
2061#endif
2062#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +05302063/*
2064 * <ioctl>
2065 * getIbssSTAs - get ibss sta info
2066 *
2067 * @INPUT: None
2068 *
2069 * @OUTPUT: Give the MAC of the IBSS STA
2070 * wlan0 getIbssSTAs:
2071 * 1 .8c:fd:f0:01:9c:bf
2072 *
2073 * This IOCTL is used to get ibss sta info
2074 *
2075 * @E.g: iwpriv wlan0 getIbssSTAs
2076 *
2077 * Supported Feature: IBSS
2078 *
2079 * Usage: Internal/External
2080 *
2081 * </ioctl>
2082 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002083#define WE_GET_IBSS_STA_INFO 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302084/*
2085 * <ioctl>
2086 * getphymode - Get the current phymode.
2087 *
2088 * @INPUT: None
2089 *
2090 * @OUTPUT: In phymode
2091 * wlan0 getphymode:AUTO MODE
2092 *
2093 * This IOCTL used to gets the current phymode.
2094 *
2095 * @E.g: iwpriv wlan0 getphymode
2096 *
2097 * Supported Feature: STA
2098 *
2099 * Usage: Internal/External
2100 *
2101 * </ioctl>
2102 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103#define WE_GET_PHYMODE 12
Naveen Rawat910726a2017-03-06 11:42:51 -08002104
2105/*
2106 * <ioctl>
2107 * getOemDataCap - Get the oem data caps.
2108 *
2109 * @INPUT: None
2110 *
2111 * @OUTPUT: oem data capability
2112 *
2113 * This IOCTL used to gets the current oem data cap.
2114 *
2115 * @E.g: iwpriv wlan0 getOemDataCap
2116 *
2117 * Usage: Internal/External
2118 *
2119 * </ioctl>
2120 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121#define WE_GET_OEM_DATA_CAP 13
Naveen Rawat910726a2017-03-06 11:42:51 -08002122
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302123/*
2124 * <ioctl>
2125 * getSNR - Enable SNR Monitoring
2126 *
2127 * @INPUT: None
2128 *
2129 * @OUTPUT: Signal strength/ratio
2130 * wlan0 getSNR:1
2131 *
2132 * This IOCTL is used to get ibss sta info
2133 *
2134 * @E.g: iwpriv wlan0 getSNR
2135 *
2136 * Supported Feature: STA
2137 *
2138 * Usage: Internal/External
2139 *
2140 * </ioctl>
2141 */
Naveen Rawat910726a2017-03-06 11:42:51 -08002142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +05302144#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145
2146/* Private ioctls and their sub-ioctls */
2147#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
Selvaraj, Sridharf7939832017-03-25 16:59:50 +05302148
2149/*
2150 * <ioctl>
2151 * reassoc - Trigger STA re-association to the connected AP
2152 *
2153 * @INPUT: None
2154 *
2155 * @OUTPUT: None
2156 *
2157 * This IOCTL is used to trigger STA reassociation to the connected AP.
2158 *
2159 * @E.g: iwpriv wlan0 reassoc
2160 *
2161 * Supported Feature: Roaming
2162 *
2163 * Usage: Internal
2164 *
2165 * </ioctl>
2166 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +05302168/*
2169 * <ioctl>
2170 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
2171 *
2172 * @INPUT: None
2173 *
2174 * @OUTPUT: print ibss peer in info logs
2175 * pPeerInfo->numIBSSPeers = 1
2176 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2177 *
2178 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
2179 * in info logs
2180 *
2181 * @E.g: iwpriv wlan0 ibssPeerInfoAll
2182 *
2183 * Supported Feature: IBSS
2184 *
2185 * Usage: Internal/External
2186 *
2187 * </ioctl>
2188 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002189#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -08002190/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002191#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002192#define WE_GET_FW_PROFILE_DATA 18
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +05302193/*
2194 * <ioctl>
2195 * stop_obss_scan - Stop obss scan
2196 *
2197 * @INPUT: None
2198 *
2199 * @OUTPUT: None
2200 *
2201 * This IOCTL is used to stop obss scan
2202 *
2203 * @E.g: iwpriv wlan0 stop_obss_scan
2204 *
2205 * Supported Feature: Scan
2206 *
2207 * Usage: Internal/External
2208 *
2209 * </ioctl>
2210 */
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002211#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212
2213/* Private ioctls and their sub-ioctls */
2214#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
2215
2216#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +05302217/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218
Manjeet Singhf82ed072016-07-08 11:40:00 +05302219#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220
Kabilan Kannan6894e6a2017-11-09 14:37:55 -08002221/* subcommand 5 is unused */
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302222
Abhishek Singh49b654e2016-12-01 16:11:17 +05302223/*
2224 * <ioctl>
2225 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
2226 *
2227 * @INPUT: staid
2228 *
2229 * @OUTPUT: print ibss peer corresponding to staid in info logs
2230 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2231 *
2232 * This IOCTL is used to print the specific ibss peers's MAC,
2233 * rate and RSSI in info logs
2234 *
2235 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
2236 * iwpriv wlan0 ibssPeerInfo 0
2237 *
2238 * Supported Feature: IBSS
2239 *
2240 * Usage: Internal/External
2241 *
2242 * </ioctl>
2243 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002244#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245#define WE_UNIT_TEST_CMD 7
2246
2247#define WE_MTRACE_DUMP_CMD 8
2248#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
2249
2250
2251#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2252#define WE_LED_FLASHING_PARAM 10
2253#endif
2254
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302255/*
2256 * <ioctl>
2257 * pm_clist - Increments the index value of the concurrent connection list
2258 * and update with the input parameters provided.
2259 *
2260 * @INPUT: Following 8 arguments:
2261 * @vdev_id: vdev id
2262 * @tx_streams: TX streams
2263 * @rx_streams: RX streams
2264 * @chain_mask: Chain mask
2265 * @type: vdev_type
2266 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2267 * @sub_type: vdev_subtype
2268 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2269 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2270 * @channel: Channel
2271 * @mac: Mac id
2272 *
2273 * @OUTPUT: None
2274 *
2275 * This IOCTL is used to increments the index value of the concurrent connection
2276 * list and update with the input parameters provided.
2277 *
2278 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
2279 * sub_type channel mac
2280 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
2281 *
2282 * Supported Feature: DBS
2283 *
2284 * Usage: Internal/External
2285 *
2286 * </ioctl>
2287 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302289
2290/*
2291 * <ioctl>
2292 * pm_dlist - Delete the index from the concurrent connection list that is
2293 * present in the given vdev_id.
2294 *
2295 * @INPUT: delete_all, vdev_id
2296 * @delete_all: delete all indices
2297 * @vdev_id: vdev id
2298 *
2299 * @OUTPUT: None
2300 *
2301 * This IOCTL is used to delete the index from the concurrent connection list
2302 * that is present in the given vdev_id.
2303 *
2304 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
2305 * iwpriv wlan0 pm_dlist 0 1
2306 *
2307 * Supported Feature: DBS
2308 *
2309 * Usage: Internal/External
2310 *
2311 * </ioctl>
2312 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302314
2315/*
2316 * <ioctl>
2317 * pm_dbs - Set dbs capability and system preference
2318 *
2319 * @INPUT: dbs, system_pref
2320 * @dbs: Value of DBS capability to be set
2321 * @system_pref: System preference
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002322 * 0:PM_THROUGHPUT 1: PM_POWERSAVE 2: PM_LATENCY
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302323 *
2324 * @OUTPUT: None
2325 *
2326 * This IOCTL is used to set dbs capability and system preference.
2327 *
2328 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
2329 * iwpriv wlan0 pm_dbs 1 0
2330 *
2331 * Supported Feature: DBS
2332 *
2333 * Usage: Internal/External
2334 *
2335 * </ioctl>
2336 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302338
2339/*
2340 * <ioctl>
2341 * pm_pcl - Set pcl for concurrency mode.
2342 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002343 * @INPUT: policy_mgr_con_mode
2344 * @policy_mgr_con_mode: concurrency mode for PCL table
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302345 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2346 *
2347 * @OUTPUT: None
2348 *
2349 * This IOCTL is used to set pcl for concurrency mode.
2350 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002351 * @E.g: iwpriv wlan0 pm_pcl policy_mgr_con_mode
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302352 * iwpriv wlan0 pm_pcl 0
2353 *
2354 * Supported Feature: DBS
2355 *
2356 * Usage: Internal/External
2357 *
2358 * </ioctl>
2359 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302361
2362/*
2363 * <ioctl>
2364 * pm_cinfo - Shows the concurrent connection list.
2365 *
2366 * @INPUT: None
2367 *
2368 * @OUTPUT: None
2369 *
2370 * This IOCTL is used to show the concurrent connection list.
2371 *
2372 * @E.g: iwpriv wlan0 pm_cinfo
2373 *
2374 * Supported Feature: DBS
2375 *
2376 * Usage: Internal/External
2377 *
2378 * </ioctl>
2379 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302381
2382/*
2383 * <ioctl>
2384 * pm_ulist - Updates the index value of the concurrent connection list
2385 * with the input parameters provided.
2386 *
2387 * @INPUT: Following 8 arguments:
2388 * @vdev_id: vdev id
2389 * @tx_streams: TX streams
2390 * @rx_streams: RX streams
2391 * @chain_mask: Chain mask
2392 * @type: vdev_type
2393 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2394 * @sub_type: vdev_subtype
2395 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2396 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2397 * @channel: Channel
2398 * @mac: Mac id
2399 *
2400 * @OUTPUT: None
2401 *
2402 * This IOCTL is used to updates the index value of the concurrent
2403 * connection list with the input parameters provided.
2404 *
2405 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
2406 * sub_type channel mac
2407 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
2408 *
2409 * Supported Feature: DBS
2410 *
2411 * Usage: Internal/External
2412 *
2413 * </ioctl>
2414 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302416
2417/*
2418 * <ioctl>
2419 * pm_query_action - Initiate actions needed on current connections as
2420 * per the channel provided.
2421 *
2422 * @INPUT: channel
2423 * @channel: Channel on which new connection will be.
2424 *
2425 * @OUTPUT: None
2426 *
2427 * This IOCTL is used to initiate actions needed on current connections
2428 * as per the channel provided.
2429 *
2430 * @E.g: iwpriv wlan0 pm_query_action channel
2431 * iwpriv wlan0 pm_query_action 6
2432 *
2433 * Supported Feature: DBS
2434 *
2435 * Usage: Internal/External
2436 *
2437 * </ioctl>
2438 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302440
2441/*
2442 * <ioctl>
2443 * pm_query_allow - Checks for allowed concurrency combination
2444 *
2445 * @INPUT: mode, channel, bandwidth
2446 * @mode: new connection mode
2447 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2448 * @channel: channel on which new connection is coming up
2449 * @bandwidth: Bandwidth requested by the connection
2450 * 0:None 1:5MHz 2:10MHz 3:20MHz
2451 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
2452 *
2453 * @OUTPUT: None
2454 *
2455 * This IOCTL is used to checks for allowed concurrency combination.
2456 *
2457 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
2458 * iwpriv wlan0 pm_query_allow 0 6 4
2459 *
2460 * Supported Feature: DBS
2461 *
2462 * Usage: Internal/External
2463 *
2464 * </ioctl>
2465 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302467
2468/*
2469 * <ioctl>
2470 * pm_run_scenario - Create scenario with number of connections provided.
2471 *
2472 * @INPUT: num_of_conn
2473 * @num_of_conn: the number of connections (values: 1~3)
2474 *
2475 * @OUTPUT: None
2476 *
2477 * This IOCTL is used to create scenario with the number of connections
2478 * provided.
2479 *
2480 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
2481 * iwpriv wlan0 pm_run_scenario 1
2482 *
2483 * Supported Feature: DBS
2484 *
2485 * Usage: Internal/External
2486 *
2487 * </ioctl>
2488 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302490
2491/*
2492 * <ioctl>
2493 * pm_set_hw_mode - Set hardware for single/dual mac.
2494 *
2495 * @INPUT: hw_mode
2496 * 0:single mac 1:dual mac
2497 *
2498 * @OUTPUT: None
2499 *
2500 * This IOCTL is used to set hardware for single/dual mac.
2501 *
2502 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
2503 * iwpriv wlan0 pm_set_hw_mode 1
2504 *
2505 * Supported Feature: DBS
2506 *
2507 * Usage: Internal/External
2508 *
2509 * </ioctl>
2510 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511#define WE_POLICY_SET_HW_MODE_CMD 20
2512
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302513/*
2514 * <ioctl>
Liangwei Dong2a7f2912018-02-07 17:08:17 +08002515 * ch_avoid - unit test SAP channel avoidance
2516 *
2517 * @INPUT: chan avoid ranges
2518 *
2519 * @OUTPUT: none
2520 *
2521 * This IOCTL is used to fake a channel avoidance event.
2522 * To test SAP/GO chan switch during chan avoid event process.
2523 *
2524 * @E.g: iwpriv wlan0 ch_avoid 2452 2462
2525 *
2526 * Supported Feature: SAP chan avoidance.
2527 *
2528 * Usage: Internal
2529 *
2530 * </ioctl>
2531 */
2532#define WE_SET_CHAN_AVOID 21
2533
2534/*
2535 * <ioctl>
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302536 * set_scan_cfg - Set dual MAC scan config parameters.
2537 *
2538 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2539 * @dbs: Value of DBS bit
2540 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2541 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2542 *
2543 * @OUTPUT: None
2544 *
2545 * This IOCTL is used to set the dual MAC scan config.
2546 *
2547 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2548 * single_mac_scan_with_dbs
2549 * iwpriv wlan0 set_scan_cfg 1 0 1
2550 *
2551 * Supported Feature: DBS
2552 *
2553 * Usage: Internal/External
2554 *
2555 * </ioctl>
2556 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302558
2559/*
2560 * <ioctl>
2561 * set_fw_mode_cfg - Sets the dual mac FW mode config
2562 *
2563 * @INPUT: dbs, dfs
2564 * @dbs: DBS bit
2565 * @dfs: Agile DFS bit
2566 *
2567 * @OUTPUT: None
2568 *
2569 * This IOCTL is used to set the dual mac FW mode config.
2570 *
2571 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2572 * iwpriv wlan0 set_fw_mode_cfg 1 1
2573 *
2574 * Supported Feature: DBS
2575 *
2576 * Usage: Internal/External
2577 *
2578 * </ioctl>
2579 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07002581#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582
2583#ifdef FEATURE_WLAN_TDLS
2584#undef MAX_VAR_ARGS
2585#define MAX_VAR_ARGS 11
2586#else
2587#undef MAX_VAR_ARGS
2588#define MAX_VAR_ARGS 9
2589#endif
2590
Jeff Johnson6fa1e012017-04-05 06:40:53 -07002591/*
2592 * <ioctl>
2593 * fips_test - Perform a FIPS test
2594 *
2595 * @INPUT: Binary representation of the following packed structure
2596 *
2597 * @OUTPUT: Binary representation of the following packed structure
2598 *
2599 * This IOCTL is used to perform FIPS certification testing
2600 *
2601 * @E.g: iwpriv wlan0 fips_test <test vector>
2602 *
2603 * iwpriv wlan0 fips_test <tbd>
2604 *
2605 * Supported Feature: FIPS
2606 *
2607 * Usage: Internal
2608 *
2609 * </ioctl>
2610 */
2611#define WLAN_PRIV_FIPS_TEST (SIOCIWFIRSTPRIV + 8)
2612
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613/* Private ioctls (with no sub-ioctls) */
2614/* note that they must be odd so that they have "get" semantics */
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302615/*
2616 * <ioctl>
2617 * addTspec - Add TSPEC for each AC
2618 *
2619 * @INPUT: 19 TSPEC params
2620 * @[arg0]: handle
2621 * @[arg1]: tid
2622 * @[arg2]: dir
2623 * @[arg3]: psb
2624 * @[arg4]: up
2625 * @[arg5]: nomMsduSize
2626 * @[arg6]: maxMsduSize
2627 * @[arg7]: minDataRate
2628 * @[arg8]: meanDataRate
2629 * @[arg9]: peakDataRate
2630 * @[arg10]: maxBurstSize
2631 * @[arg11]: minPhyRate
2632 * @[arg12]: sba
2633 * @[arg13]: minServiceIntv
2634 * @[arg14]: suspendIntv
2635 * @[arg15]: burstSizeDefn
2636 * @[arg16]: ackPolicy
2637 * @[arg17]: inactivityPeriod
2638 * @[arg18]: maxServiceIntv
2639 *
2640 * @OUTPUT: Success/Failure
2641 *
2642 * This IOCTL is used to add TSPEC for each AC.
2643 *
2644 * @E.g: iwpriv wlan0 addTspec <handle> <tid> <dir> <psb> <up> <nomMsduSize>
2645 * <maxMsduSize> <minDataRate> <meanDataRate>
2646 * <peakDataRate> <maxBurstSize> <minPhyRate>
2647 * <sba> <minServiceIntv> <suspendIntv>
2648 * <burstSizeDefn> <ackPolicy> <inactivityPeriod>
2649 * <maxServiceIntv>
2650 * iwpriv wlan0 addTspec 7001 6 2 1 6 0x80D0 0x80D0 0x14500 0x14500 0x14500
2651 * 0 0x5B8D80 0x2001 20 2000 0 0 0 2000
2652 * wlan0 addTspec:3
2653 *
2654 * Supported Feature: WMM
2655 *
2656 * Usage: Internal/External
2657 *
2658 * </ioctl>
2659 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302661/*
2662 * <ioctl>
2663 * delTspec - Delete TSPEC entry for each AC
2664 *
2665 * @INPUT: 1 TSPEC param
2666 * @[arg0]: handle
2667 *
2668 * @OUTPUT: Success/Failure
2669 *
2670 * This IOCTL is used to delete TSPEC entry for each AC.
2671 *
2672 * @E.g: iwpriv wlan0 delTspec <handle>
2673 * iwpriv wlan0 delTspec 7001
2674 * wlan0 delTspec:16
2675 *
2676 * Supported Feature: WMM
2677 *
2678 * Usage: Internal/External
2679 *
2680 * </ioctl>
2681 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302683/*
2684 * <ioctl>
2685 * getTspec - Get TSPEC entry for each AC
2686 *
2687 * @INPUT: 1 TSPEC param
2688 * @[arg0]: handle
2689 *
2690 * @OUTPUT: Success/Failure
2691 *
2692 * This IOCTL is used to get TSPEC entry for each AC.
2693 *
2694 * @E.g: iwpriv wlan0 getTspec <handle>
2695 * iwpriv wlan0 getTspec 7001
2696 * wlan0 delTspec:18
2697 *
2698 * Supported Feature: WMM
2699 *
2700 * Usage: Internal/External
2701 *
2702 * </ioctl>
2703 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706/* (SIOCIWFIRSTPRIV + 10) is currently unused */
2707/* (SIOCIWFIRSTPRIV + 12) is currently unused */
2708/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002709#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
2710#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711/* (SIOCIWFIRSTPRIV + 16) is currently unused */
2712/* (SIOCIWFIRSTPRIV + 17) is currently unused */
2713/* (SIOCIWFIRSTPRIV + 19) is currently unused */
2714
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716
2717/* Private ioctl for setting the host offload feature */
2718#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2719
2720/* Private ioctl to get the statistics */
2721#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2722
2723/* Private ioctl to set the Keep Alive Params */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302724/*
2725 * <ioctl>
2726 * setKeepAlive - Set the keep alive feature
2727 *
2728 * @INPUT: 28 bytes of information in the order of packet type, time period
2729 * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2730 *
2731 * @OUTPUT: None
2732 *
2733 * This IOCTL sets the keep alive feature to send either NULL
2734 * or unsolicited ARP response packets
2735 *
2736 * @E.g: iwpriv wlan0 setKeepAlive
2737 *
2738 * Supported Feature: STA
2739 *
2740 * Usage: Internal/External
2741 *
2742 * </ioctl>
2743 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2745
2746#ifdef WLAN_FEATURE_PACKET_FILTERING
2747/* Private ioctl to set the packet filtering params */
2748#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2749#endif
2750
2751
2752#ifdef FEATURE_WLAN_SCAN_PNO
2753/* Private ioctl to get the statistics */
2754#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2755#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302756/*
2757 * <ioctl>
2758 * SETBAND - Set the operational band
2759 *
2760 * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2761 *
2762 * @OUTPUT: None
2763 *
2764 * This IOCTL Set the operational band If the new band is different from the
2765 * current operational band, it aborts the pending scan requests, flushes
2766 * the existing scan results, and then change * the band capability
2767 *
2768 * @E.g: iwpriv wlan0 SETBAND <value>
2769 *
2770 * Supported Feature: STA
2771 *
2772 * Usage: Internal/External
2773 *
2774 * </ioctl>
2775 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
2777
Dustin Brown0cbc7572016-12-16 13:54:40 -08002778#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -08002779/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780
2781/* Private ioctls and their sub-ioctls */
2782#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
2783#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -07002784#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785#define WE_SET_FW_CRASH_INJECT 2
2786#endif
2787#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +05302788/* Private sub ioctl for enabling and setting histogram interval of profiling */
2789#define WE_ENABLE_FW_PROFILE 4
2790#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07002792/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002793#define WE_SET_WLAN_SUSPEND 6
2794#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002795
Dustin Brown8d2d0f52017-04-03 17:02:08 -07002796/*
2797 * <ioctl>
2798 * log_buffer - prints host/target related communication logs via dmesg
2799 *
2800 * @INPUT: Log Id, Count
2801 *
2802 * Log Id:
2803 * 0) HTC_CREDIT_HISTORY_LOG
2804 * 1) COMMAND_LOG,
2805 * 2) COMMAND_TX_CMP_LOG,
2806 * 3) MGMT_COMMAND_LOG,
2807 * 4) MGMT_COMMAND_TX_CMP_LOG,
2808 * 5) EVENT_LOG,
2809 * 6) RX_EVENT_LOG,
2810 * 7) MGMT_EVENT_LOG
2811 *
2812 * @OUTPUT: None
2813 *
2814 * @E.g:
2815 * # print up to 10 of the most recent records from HTC Credit History
2816 * iwpriv wlan0 log_buffer 0 10
2817 * # print up to 3 of the most recent records from Event Log
2818 * iwpriv wlan0 log_buffer 5 3
2819 *
2820 * Supported Feature: WLAN Trace
2821 *
2822 * Usage: Internal/External
2823 *
2824 * </ioctl>
2825 */
2826#define WE_LOG_BUFFER 8
2827
2828enum host_target_comm_log {
2829 HTC_CREDIT_HISTORY_LOG = 0,
2830 COMMAND_LOG,
2831 COMMAND_TX_CMP_LOG,
2832 MGMT_COMMAND_LOG,
2833 MGMT_COMMAND_TX_CMP_LOG,
2834 EVENT_LOG,
2835 RX_EVENT_LOG,
2836 MGMT_EVENT_LOG
2837};
2838
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839/* (SIOCIWFIRSTPRIV + 29) is currently unused */
2840
2841/* 802.11p IOCTL */
2842#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
2843
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302844/*
2845 * <ioctl>
2846 * getLinkSpeed - Gets the current link speed in Mbps
2847 *
2848 * @INPUT: None
2849 *
2850 * @OUTPUT: linkspeed in mbps
2851 * wlan0 getLinkSpeed:7
2852 *
2853 * This IOCTL is used get the current link speed in Mbps
2854 *
2855 * @E.g: iwpriv wlan0 getLinkSpeed
2856 *
2857 * Supported Feature: STA
2858 *
2859 * Usage: Internal/External
2860 *
2861 * </ioctl>
2862 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
2864
2865#define WLAN_STATS_INVALID 0
2866#define WLAN_STATS_RETRY_CNT 1
2867#define WLAN_STATS_MUL_RETRY_CNT 2
2868#define WLAN_STATS_TX_FRM_CNT 3
2869#define WLAN_STATS_RX_FRM_CNT 4
2870#define WLAN_STATS_FRM_DUP_CNT 5
2871#define WLAN_STATS_FAIL_CNT 6
2872#define WLAN_STATS_RTS_FAIL_CNT 7
2873#define WLAN_STATS_ACK_FAIL_CNT 8
2874#define WLAN_STATS_RTS_SUC_CNT 9
2875#define WLAN_STATS_RX_DISCARD_CNT 10
2876#define WLAN_STATS_RX_ERROR_CNT 11
2877#define WLAN_STATS_TX_BYTE_CNT 12
2878
2879#define WLAN_STATS_RX_BYTE_CNT 13
2880#define WLAN_STATS_RX_RATE 14
2881#define WLAN_STATS_TX_RATE 15
2882
2883#define WLAN_STATS_RX_UC_BYTE_CNT 16
2884#define WLAN_STATS_RX_MC_BYTE_CNT 17
2885#define WLAN_STATS_RX_BC_BYTE_CNT 18
2886#define WLAN_STATS_TX_UC_BYTE_CNT 19
2887#define WLAN_STATS_TX_MC_BYTE_CNT 20
2888#define WLAN_STATS_TX_BC_BYTE_CNT 21
2889
2890#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
2891 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
2892 *__p++ = __type; \
2893 *__p++ = __size; \
2894 memcpy(__p, __val, __size); \
2895 __p += __size; \
2896 __tlen += __size + 2; \
2897 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07002898 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 } \
2900 } while (0)
2901
2902#define VERSION_VALUE_MAX_LEN 32
2903
2904#define TX_PER_TRACKING_DEFAULT_RATIO 5
2905#define TX_PER_TRACKING_MAX_RATIO 10
2906#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
2907
2908#define WLAN_ADAPTER 0
2909#define P2P_ADAPTER 1
2910
2911/**
2912 * mem_alloc_copy_from_user_helper - copy from user helper
2913 * @wrqu_data: wireless extensions request data
2914 * @len: length of @wrqu_data
2915 *
2916 * Helper function to allocate buffer and copy user data.
2917 *
2918 * Return: On success return a pointer to a kernel buffer containing a
2919 * copy of the userspace data (with an additional NUL character
2920 * appended for safety). On failure return %NULL.
2921 */
2922void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2923{
2924 u8 *ptr = NULL;
2925
2926 /* in order to protect the code, an extra byte is post
2927 * appended to the buffer and the null termination is added.
2928 * However, when allocating (len+1) byte of memory, we need to
2929 * make sure that there is no uint overflow when doing
2930 * addition. In theory check len < UINT_MAX protects the uint
2931 * overflow. For wlan private ioctl, the buffer size is much
2932 * less than UINT_MAX, as a good guess, now, it is assumed
2933 * that the private command buffer size is no greater than 4K
2934 * (4096 bytes). So we use 4096 as the upper boundary for now.
2935 */
2936 if (len > MAX_USER_COMMAND_SIZE) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08002937 hdd_err("Invalid length: %zu max: %u",
2938 len, MAX_USER_COMMAND_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002939 return NULL;
2940 }
2941
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002942 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002944 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 return NULL;
2946 }
2947
2948 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002949 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002950 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 return NULL;
2952 }
2953 ptr[len] = '\0';
2954 return ptr;
2955}
2956
2957/**
2958 * hdd_priv_get_data() - Get pointer to ioctl private data
2959 * @p_priv_data: pointer to iw_point struct to be filled
2960 * @wrqu: Pointer to IOCTL Data received from userspace
2961 *
2962 * Helper function to get compatible struct iw_point passed to ioctl
2963 *
2964 * Return - 0 if p_priv_data successfully filled, error otherwise
2965 */
2966int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2967{
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002968 if ((NULL == p_priv_data) || (NULL == wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002969 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002970
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971#ifdef CONFIG_COMPAT
2972 if (is_compat_task()) {
2973 struct compat_iw_point *p_compat_priv_data;
2974
2975 /* Compat task:
2976 * typecast to compat structure and copy the members.
2977 */
2978 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2979
2980 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2981 p_priv_data->length = p_compat_priv_data->length;
2982 p_priv_data->flags = p_compat_priv_data->flags;
2983 } else {
2984#endif /* #ifdef CONFIG_COMPAT */
2985
2986 /* Non compat task: directly copy the structure. */
2987 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
2988
2989#ifdef CONFIG_COMPAT
2990 }
2991#endif /* #ifdef CONFIG_COMPAT */
2992
2993 return 0;
2994}
2995
Jeff Johnson441e1f72017-02-07 08:50:49 -08002996static int hdd_check_wext_control(enum hdd_wext_control wext_control,
2997 struct iw_request_info *info)
2998{
2999 switch (wext_control) {
3000 default:
3001 case hdd_wext_disabled:
3002 hdd_err("Rejecting disabled ioctl %x", info->cmd);
3003 return -ENOTSUPP;
3004 case hdd_wext_deprecated:
3005 hdd_warn("Using deprecated ioctl %x", info->cmd);
3006 return 0;
3007 case hdd_wext_enabled:
3008 return 0;
3009 }
3010}
3011
Jeff Johnson82797b62017-08-11 15:31:27 -07003012int hdd_check_standard_wext_control(struct hdd_context *hdd_ctx,
Jeff Johnson441e1f72017-02-07 08:50:49 -08003013 struct iw_request_info *info)
3014{
3015 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
3016 info);
3017}
3018
Jeff Johnson82797b62017-08-11 15:31:27 -07003019int hdd_check_private_wext_control(struct hdd_context *hdd_ctx,
Jeff Johnson441e1f72017-02-07 08:50:49 -08003020 struct iw_request_info *info)
3021{
3022 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
3023 info);
3024}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025
3026/**
3027 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003028 * @adapter: Pointer to the hdd adapter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 * @length: Size of the data copied
3030 * @buffer: Pointer to char buffer.
3031 * @buf_len: Length of the char buffer.
3032 *
3033 * This function called when the "iwpriv wlan0 get_stats" command is given.
3034 * It used to collect the txrx stats when the device is configured in SAP mode.
3035 *
3036 * Return - none
3037 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003038void hdd_wlan_get_stats(struct hdd_adapter *adapter, uint16_t *length,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 char *buffer, uint16_t buf_len)
3040{
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003041 struct hdd_tx_rx_stats *stats = &adapter->hdd_stats.tx_rx_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 uint32_t len = 0;
3043 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
3044 uint32_t total_rx_delv = 0, total_rx_refused = 0;
3045 int i = 0;
3046
3047 for (; i < NUM_CPUS; i++) {
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003048 total_rx_pkt += stats->rx_packets[i];
3049 total_rx_dropped += stats->rx_dropped[i];
3050 total_rx_delv += stats->rx_delivered[i];
3051 total_rx_refused += stats->rx_refused[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 }
3053
3054 len = scnprintf(buffer, buf_len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003055 "\nTransmit[%lu] - "
Mohit Khannad0b63f52017-02-18 18:05:52 -08003056 "called %u, dropped %u orphan %u,"
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003057 "\n[dropped] BK %u, BE %u, VI %u, VO %u"
3058 "\n[classified] BK %u, BE %u, VI %u, VO %u"
3059 "\n\nReceive[%lu] - "
3060 "packets %u, dropped %u, delivered %u, refused %u"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061 "\n",
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003062 qdf_system_ticks(),
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003063 stats->tx_called,
3064 stats->tx_dropped,
3065 stats->tx_orphaned,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003067 stats->tx_dropped_ac[SME_AC_BK],
3068 stats->tx_dropped_ac[SME_AC_BE],
3069 stats->tx_dropped_ac[SME_AC_VI],
3070 stats->tx_dropped_ac[SME_AC_VO],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003072 stats->tx_classified_ac[SME_AC_BK],
3073 stats->tx_classified_ac[SME_AC_BE],
3074 stats->tx_classified_ac[SME_AC_VI],
3075 stats->tx_classified_ac[SME_AC_VO],
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003076 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
3078 );
3079
3080 for (i = 0; i < NUM_CPUS; i++) {
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003081 if (stats->rx_packets[i] == 0)
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003082 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003084 "Rx CPU[%d]:"
3085 "packets %u, dropped %u, delivered %u, refused %u\n",
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003086 i, stats->rx_packets[i], stats->rx_dropped[i],
3087 stats->rx_delivered[i], stats->rx_refused[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088 }
3089
3090 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003091 "\nTX_FLOW"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 "\nCurrent status: %s"
3093 "\ntx-flow timer start count %u"
3094 "\npause count %u, unpause count %u",
Jeff Johnson6ced42c2017-10-20 12:48:11 -07003095 (stats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
3096 stats->txflow_timer_cnt,
3097 stats->txflow_pause_cnt,
3098 stats->txflow_unpause_cnt);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099
Leo Changfdb45c32016-10-28 11:09:23 -07003100 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
Jeff Johnson1b780e42017-10-31 14:11:45 -07003101 adapter->session_id, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 *length = len + 1;
3103}
3104
3105/**
Dustin Brownd9322482017-01-09 12:46:03 -08003106 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
3107 * @hdd_ctx: The Hdd context owning the stats to be written
3108 * @buffer: The char buffer to write to
3109 * @max_len: The maximum number of chars to write
3110 *
3111 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
3112 *
3113 * Return - length of written content, negative number on error
3114 */
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003115static int wlan_hdd_write_suspend_resume_stats(struct hdd_context *hdd_ctx,
Dustin Brownd9322482017-01-09 12:46:03 -08003116 char *buffer, uint16_t max_len)
3117{
3118 QDF_STATUS status;
3119 struct suspend_resume_stats *sr_stats;
3120 struct sir_wake_lock_stats wow_stats;
3121
3122 sr_stats = &hdd_ctx->suspend_resume_stats;
3123
3124 status = wma_get_wakelock_stats(&wow_stats);
3125 if (QDF_IS_STATUS_ERROR(status)) {
3126 hdd_err("Failed to get WoW stats");
3127 return qdf_status_to_os_return(status);
3128 }
3129
3130 return scnprintf(buffer, max_len,
3131 "\n"
3132 "Suspends: %u\n"
3133 "Resumes: %u\n"
3134 "\n"
3135 "Suspend Fail Reasons\n"
3136 "\tIPA: %u\n"
3137 "\tRadar: %u\n"
3138 "\tRoam: %u\n"
3139 "\tScan: %u\n"
3140 "\tInitial Wakeup: %u\n"
3141 "\n"
3142 "WoW Wake Reasons\n"
3143 "\tunicast: %u\n"
3144 "\tbroadcast: %u\n"
3145 "\tIPv4 multicast: %u\n"
3146 "\tIPv6 multicast: %u\n"
3147 "\tIPv6 multicast RA: %u\n"
3148 "\tIPv6 multicast NS: %u\n"
3149 "\tIPv6 multicast NA: %u\n"
3150 "\tICMPv4: %u\n"
3151 "\tICMPv6: %u\n"
3152 "\tRSSI Breach: %u\n"
3153 "\tLow RSSI: %u\n"
3154 "\tG-Scan: %u\n"
3155 "\tPNO Complete: %u\n"
3156 "\tPNO Match: %u\n",
3157 sr_stats->suspends,
3158 sr_stats->resumes,
3159 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
3160 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
3161 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
3162 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
3163 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
3164 wow_stats.wow_ucast_wake_up_count,
3165 wow_stats.wow_bcast_wake_up_count,
3166 wow_stats.wow_ipv4_mcast_wake_up_count,
3167 wow_stats.wow_ipv6_mcast_wake_up_count,
3168 wow_stats.wow_ipv6_mcast_ra_stats,
3169 wow_stats.wow_ipv6_mcast_ns_stats,
3170 wow_stats.wow_ipv6_mcast_na_stats,
3171 wow_stats.wow_icmpv4_count,
3172 wow_stats.wow_icmpv6_count,
3173 wow_stats.wow_rssi_breach_wake_up_count,
3174 wow_stats.wow_low_rssi_wake_up_count,
3175 wow_stats.wow_gscan_wake_up_count,
3176 wow_stats.wow_pno_complete_wake_up_count,
3177 wow_stats.wow_pno_match_wake_up_count);
3178}
3179
3180/**
Govind Singha471e5e2015-10-12 17:11:14 +05303181 * hdd_wlan_list_fw_profile() - Get fw profiling points
3182 * @length: Size of the data copied
3183 * @buffer: Pointer to char buffer.
3184 * @buf_len: Length of the char buffer.
3185 *
3186 * This function called when the "iwpriv wlan0 listProfile" command is given.
3187 * It is used to get the supported profiling points in FW.
3188 *
3189 * Return - none
3190 */
3191void hdd_wlan_list_fw_profile(uint16_t *length,
3192 char *buffer, uint16_t buf_len)
3193{
3194 uint32_t len = 0;
3195
3196 len = scnprintf(buffer, buf_len,
3197 "PROF_CPU_IDLE: %u\n"
3198 "PROF_PPDU_PROC: %u\n"
3199 "PROF_PPDU_POST: %u\n"
3200 "PROF_HTT_TX_INPUT: %u\n"
3201 "PROF_MSDU_ENQ: %u\n"
3202 "PROF_PPDU_POST_HAL: %u\n"
3203 "PROF_COMPUTE_TX_TIME: %u\n",
3204 PROF_CPU_IDLE,
3205 PROF_PPDU_PROC,
3206 PROF_PPDU_POST,
3207 PROF_HTT_TX_INPUT,
3208 PROF_MSDU_ENQ,
3209 PROF_PPDU_POST_HAL,
3210 PROF_COMPUTE_TX_TIME);
3211
3212 *length = len + 1;
3213}
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003214/**
3215 * hdd_display_stats_help() - print statistics help
3216 *
3217 * Return: none
3218 */
3219void hdd_display_stats_help(void)
3220{
3221 hdd_err("iwpriv wlan0 dumpStats [option] - dump statistics");
3222 hdd_err("iwpriv wlan0 clearStats [option] - clear statistics");
3223 hdd_err("options:");
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003224 hdd_err(" 1 -- TXRX PATH statistics");
3225 hdd_err(" 2 -- TXRX HIST statistics");
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003226 hdd_err(" 3 -- TSO statistics");
3227 hdd_err(" 4 -- Network queue statistics");
3228 hdd_err(" 5 -- Flow control statistics");
3229 hdd_err(" 6 -- Per Layer statistics");
3230 hdd_err(" 7 -- Copy engine interrupt statistics");
3231 hdd_err(" 8 -- LRO statistics");
3232 hdd_err(" 9 -- NAPI statistics");
3233}
Govind Singha471e5e2015-10-12 17:11:14 +05303234
3235/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 * hdd_wlan_dump_stats() - display dump Stats
3237 * @adapter: adapter handle
3238 * @value: value from user
3239 *
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003240 * Return: 0 => success, error code on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07003242int hdd_wlan_dump_stats(struct hdd_adapter *adapter, int value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243{
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003244 int ret = 0;
3245 QDF_STATUS status;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003246 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247
3248 switch (value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003249 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
3251 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003252 case CDP_HDD_NETIF_OPER_HISTORY:
Mohit Khannaca4173b2017-09-12 21:52:19 -07003253 wlan_hdd_display_netif_queue_history
3254 (hdd_ctx,
3255 QDF_STATS_VERBOSITY_LEVEL_HIGH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003257 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05303258 hdd_display_hif_stats();
3259 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003260 case CDP_LRO_STATS:
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003261 hdd_lro_display_stats(hdd_ctx);
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003262 case CDP_NAPI_STATS:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003263 if (hdd_display_napi_stats()) {
3264 hdd_err("error displaying napi stats");
3265 ret = EFAULT;
3266 }
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003267 break;
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +05303268 case CDP_DISCONNECT_STATS:
3269 sme_display_disconnect_stats(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07003270 adapter->session_id);
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +05303271 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 default:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003273 status = cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC),
Mohit Khannaca4173b2017-09-12 21:52:19 -07003274 value,
3275 QDF_STATS_VERBOSITY_LEVEL_HIGH);
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003276 if (status == QDF_STATUS_E_INVAL) {
3277 hdd_display_stats_help();
3278 ret = EINVAL;
3279 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 break;
3281 }
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003282 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283}
3284
3285/**
3286 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303287 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 * @wrqu: Pointer to IOCTL REQUEST Data.
3289 * @extra: Pointer to destination buffer
3290 *
3291 * This function is used to get Wlan Driver, Firmware, & Hardware
3292 * Version information. If @wrqu and @extra are specified, then the
3293 * version string is returned. Otherwise it is simply printed to the
3294 * kernel log.
3295 *
3296 * Return: none
3297 */
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003298void hdd_wlan_get_version(struct hdd_context *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 char *extra)
3300{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303301 tSirVersionString wcnss_sw_version;
3302 const char *swversion;
3303 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003304 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303306 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003307 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 goto error;
3309 }
3310
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303311 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
3312 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303314 swversion = wcnss_sw_version;
3315 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
3316 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
3317 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
3318 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003319 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303321 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322
3323 if (wrqu && extra) {
3324 wrqu->data.length =
3325 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003326 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003328 msp_id, mspid, siid, crmid,
3329 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003331 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003333 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 }
3335error:
3336 return;
3337}
3338
3339/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003340 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003341 * @adapter: Adapter upon which the IBSS client is active
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003342 * @staIdx: Station index of the IBSS peer
3343 *
3344 * Return: a pointer to the MAC address of the IBSS peer if the peer is
3345 * found, otherwise %NULL.
3346 */
3347struct qdf_mac_addr *
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003348hdd_wlan_get_ibss_mac_addr_from_staid(struct hdd_adapter *adapter,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003349 uint8_t staIdx)
3350{
3351 uint8_t idx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003352 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003353
Naveen Rawatc45d1622016-07-05 12:20:09 -07003354 for (idx = 0; idx < MAX_PEERS; idx++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003355 if (HDD_WLAN_INVALID_STA_ID !=
Jeff Johnsond377dce2017-10-04 10:32:42 -07003356 sta_ctx->conn_info.staId[idx] &&
3357 staIdx == sta_ctx->conn_info.staId[idx]) {
3358 return &sta_ctx->conn_info.peerMacAddress[idx];
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003359 }
3360 }
3361 return NULL;
3362}
3363
3364/**
3365 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003366 * @adapter: Adapter upon which the IBSS client is active
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003367 * @staIdx: Station index of the IBSS peer
3368 *
3369 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
3370 * otherwise an appropriate QDF_STATUS_E_* failure code.
3371 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003372static QDF_STATUS hdd_wlan_get_ibss_peer_info(struct hdd_adapter *adapter,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003373 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003374{
3375 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003376 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
3377 struct hdd_station_ctx *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003378 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003379
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003380 INIT_COMPLETION(adapter->ibss_peer_info_comp);
3381 status = sme_request_ibss_peer_info(hHal, adapter,
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003382 hdd_get_ibss_peer_info_cb,
3383 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003384
3385 if (QDF_STATUS_SUCCESS == status) {
3386 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003387
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003388 rc = wait_for_completion_timeout
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003389 (&adapter->ibss_peer_info_comp,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003390 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3391 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003392 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003393 return QDF_STATUS_E_FAILURE;
3394 }
3395
3396 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003397 hdd_debug("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003398 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003399 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3400 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003401
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003402 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
3403 mac_addr, sizeof(mac_addr));
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003404 hdd_debug("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003405 mac_addr, (int)tx_rate,
3406 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003407 }
3408 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003409 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003410 }
3411
3412 return status;
3413}
3414
3415/**
3416 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003417 * @adapter: Adapter upon which the IBSS clients are active
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003418 *
3419 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
3420 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
3421 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003422static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(struct hdd_adapter *adapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003423{
3424 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003425 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
3426 struct hdd_station_ctx *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003427 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003428 int i;
3429
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003430 INIT_COMPLETION(adapter->ibss_peer_info_comp);
3431 status = sme_request_ibss_peer_info(hHal, adapter,
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003432 hdd_get_ibss_peer_info_cb,
3433 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003434
3435 if (QDF_STATUS_SUCCESS == status) {
3436 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003437
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003438 rc = wait_for_completion_timeout
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003439 (&adapter->ibss_peer_info_comp,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003440 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3441 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003442 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003443 return QDF_STATUS_E_FAILURE;
3444 }
3445
3446 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003447 hdd_debug("pPeerInfo->numIBSSPeers = %d ",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003448 (int)pPeerInfo->numPeers);
3449 for (i = 0; i < pPeerInfo->numPeers; i++) {
3450 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3451 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003452
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003453 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
3454 qdf_mem_copy(mac_addr,
3455 pPeerInfo->peerInfoParams[i].mac_addr,
3456 sizeof(mac_addr));
3457
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003458 hdd_debug(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003459 mac_addr, (int)tx_rate,
3460 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003461 }
3462 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003463 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003464 }
3465
3466 return status;
3467}
3468
3469/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 * hdd_wlan_get_freq() - Convert channel to frequency
3471 * @channel: channel to be converted
3472 * @pfreq: where to store the frequency
3473 *
3474 * Return: 1 on success, otherwise a negative errno
3475 */
3476int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
3477{
3478 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003479
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 if (channel > 0) {
3481 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
3482 if (channel == freq_chan_map[i].chan) {
3483 *pfreq = freq_chan_map[i].freq;
3484 return 1;
3485 }
3486 }
3487 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003488 hdd_err("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 return -EINVAL;
3490}
3491
Jeff Johnsona5444942017-01-23 13:11:08 -08003492struct rssi_priv {
3493 int8_t rssi;
3494};
3495
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496/**
3497 * hdd_get_rssi_cb() - "Get RSSI" callback function
3498 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08003499 * @sta_id: ID of the station
3500 * @context: opaque context originally passed to SME. HDD always passes
3501 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502 *
3503 * Return: None
3504 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003505static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506{
Jeff Johnsona5444942017-01-23 13:11:08 -08003507 struct hdd_request *request;
3508 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509
Jeff Johnsona5444942017-01-23 13:11:08 -08003510 request = hdd_request_get(context);
3511 if (!request) {
3512 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 return;
3514 }
3515
Jeff Johnsona5444942017-01-23 13:11:08 -08003516 priv = hdd_request_priv(request);
3517 priv->rssi = rssi;
3518 hdd_request_complete(request);
3519 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520}
3521
3522/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 * wlan_hdd_get_rssi() - Get the current RSSI
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003524 * @adapter: adapter upon which the measurement is requested
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 * @rssi_value: pointer to where the RSSI should be returned
3526 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303527 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003529QDF_STATUS wlan_hdd_get_rssi(struct hdd_adapter *adapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530{
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003531 struct hdd_context *hdd_ctx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003532 struct hdd_station_ctx *sta_ctx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303533 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08003534 int ret;
3535 void *cookie;
3536 struct hdd_request *request;
3537 struct rssi_priv *priv;
3538 static const struct hdd_request_params params = {
3539 .priv_size = sizeof(*priv),
3540 .timeout_ms = WLAN_WAIT_TIME_STATS,
3541 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003542
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003543 if (NULL == adapter) {
3544 hdd_err("Invalid context, adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303545 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 }
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +05303547 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003548 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3549 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 /* return a cached value */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003551 *rssi_value = adapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303552 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 }
3554
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003555 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003556 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557
Jeff Johnsond377dce2017-10-04 10:32:42 -07003558 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003559 hdd_debug("Not associated!, rssi on disconnect %d",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003560 adapter->rssi_on_disconnect);
3561 *rssi_value = adapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303562 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 }
3564
Jeff Johnson690fe952017-10-25 11:48:39 -07003565 if (sta_ctx->hdd_reassoc_scenario) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003566 hdd_debug("Roaming in progress, return cached RSSI");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003567 *rssi_value = adapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303568 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 }
3570
Jeff Johnsona5444942017-01-23 13:11:08 -08003571 request = hdd_request_alloc(&params);
3572 if (!request) {
3573 hdd_err("Request allocation failure, return cached RSSI");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003574 *rssi_value = adapter->rssi;
Jeff Johnsona5444942017-01-23 13:11:08 -08003575 return QDF_STATUS_SUCCESS;
3576 }
3577 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003579 hstatus = sme_get_rssi(hdd_ctx->hHal, hdd_get_rssi_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003580 sta_ctx->conn_info.staId[0],
3581 sta_ctx->conn_info.bssId, adapter->rssi,
Jeff Johnson8bd23352017-09-26 11:39:24 -07003582 cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303583 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003584 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 /* we'll returned a cached value below */
3586 } else {
3587 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08003588 ret = hdd_request_wait_for_response(request);
3589 if (ret) {
3590 hdd_warn("SME timed out while retrieving RSSI");
3591 /* we'll returned a cached value below */
3592 } else {
3593 /* update the adapter with the fresh results */
3594 priv = hdd_request_priv(request);
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +05303595 /*
3596 * update rssi only if its valid else return previous
3597 * valid rssi.
3598 */
3599 if (priv->rssi)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003600 adapter->rssi = priv->rssi;
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +05303601
3602 /*
3603 * for new connection there might be no valid previous
3604 * RSSI.
3605 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003606 if (!adapter->rssi) {
3607 hdd_get_rssi_snr_by_bssid(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003608 sta_ctx->conn_info.bssId.bytes,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003609 &adapter->rssi, NULL);
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +05303610 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 }
3612 }
3613
Jeff Johnsona5444942017-01-23 13:11:08 -08003614 /*
3615 * either we never sent a request, we sent a request and
3616 * received a response or we sent a request and timed out.
3617 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003619 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003621 *rssi_value = adapter->rssi;
Rajeev Kumar Sirasanagandla5bacf7f2017-05-10 15:31:40 +05303622 hdd_debug("RSSI = %d", *rssi_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303624 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625}
3626
Jeff Johnson002cb972017-01-23 14:59:07 -08003627struct snr_priv {
3628 int8_t snr;
3629};
3630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08003632 * hdd_get_snr_cb() - "Get SNR" callback function
3633 * @snr: Current SNR of the station
Jeff Johnson002cb972017-01-23 14:59:07 -08003634 * @sta_id: ID of the station
3635 * @context: opaque context originally passed to SME. HDD always passes
3636 * a cookie for the request context
Jeff Johnson8eaff302017-01-23 11:03:31 -08003637 *
3638 * Return: None
3639 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003640static void hdd_get_snr_cb(int8_t snr, uint32_t sta_id, void *context)
Jeff Johnson8eaff302017-01-23 11:03:31 -08003641{
Jeff Johnson002cb972017-01-23 14:59:07 -08003642 struct hdd_request *request;
3643 struct snr_priv *priv;
Jeff Johnson8eaff302017-01-23 11:03:31 -08003644
Jeff Johnson002cb972017-01-23 14:59:07 -08003645 request = hdd_request_get(context);
3646 if (!request) {
3647 hdd_err("Obsolete request");
Jeff Johnson8eaff302017-01-23 11:03:31 -08003648 return;
3649 }
3650
Jeff Johnson002cb972017-01-23 14:59:07 -08003651 /* propagate response back to requesting thread */
3652 priv = hdd_request_priv(request);
3653 priv->snr = snr;
3654 hdd_request_complete(request);
3655 hdd_request_put(request);
Jeff Johnson8eaff302017-01-23 11:03:31 -08003656}
3657
3658/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659 * wlan_hdd_get_snr() - Get the current SNR
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003660 * @adapter: adapter upon which the measurement is requested
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 * @snr: pointer to where the SNR should be returned
3662 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303663 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003665QDF_STATUS wlan_hdd_get_snr(struct hdd_adapter *adapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666{
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003667 struct hdd_context *hdd_ctx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003668 struct hdd_station_ctx *sta_ctx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303669 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 int valid;
Jeff Johnson002cb972017-01-23 14:59:07 -08003671 int ret;
3672 void *cookie;
3673 struct hdd_request *request;
3674 struct snr_priv *priv;
3675 static const struct hdd_request_params params = {
3676 .priv_size = sizeof(*priv),
3677 .timeout_ms = WLAN_WAIT_TIME_STATS,
3678 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303680 ENTER();
3681
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003682 if (NULL == adapter) {
3683 hdd_err("Invalid context, adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303684 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 }
3686
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003687 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003689 valid = wlan_hdd_validate_context(hdd_ctx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303690 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303691 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692
Jeff Johnsond377dce2017-10-04 10:32:42 -07003693 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694
Jeff Johnson002cb972017-01-23 14:59:07 -08003695 request = hdd_request_alloc(&params);
3696 if (!request) {
3697 hdd_err("Request allocation failure");
3698 return QDF_STATUS_E_FAULT;
3699 }
3700 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003702 hstatus = sme_get_snr(hdd_ctx->hHal, hdd_get_snr_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003703 sta_ctx->conn_info.staId[0],
3704 sta_ctx->conn_info.bssId, cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303705 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003706 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707 /* we'll returned a cached value below */
3708 } else {
3709 /* request was sent -- wait for the response */
Jeff Johnson002cb972017-01-23 14:59:07 -08003710 ret = hdd_request_wait_for_response(request);
3711 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003712 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713 /* we'll now returned a cached value below */
Jeff Johnson002cb972017-01-23 14:59:07 -08003714 } else {
3715 /* update the adapter with the fresh results */
3716 priv = hdd_request_priv(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003717 adapter->snr = priv->snr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718 }
3719 }
3720
Jeff Johnson002cb972017-01-23 14:59:07 -08003721 /*
3722 * either we never sent a request, we sent a request and
3723 * received a response or we sent a request and timed out.
3724 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003726 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003728 *snr = adapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303729 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303730 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731}
3732
Jeff Johnsone50427c2017-01-26 10:54:49 -08003733struct linkspeed_priv {
3734 tSirLinkSpeedInfo linkspeed_info;
3735};
3736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737static void
Jeff Johnsone50427c2017-01-26 10:54:49 -08003738hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739{
Jeff Johnsone50427c2017-01-26 10:54:49 -08003740 struct hdd_request *request;
3741 struct linkspeed_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003742
Jeff Johnsone50427c2017-01-26 10:54:49 -08003743 if (!linkspeed_info) {
3744 hdd_err("NULL linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 return;
3746 }
3747
Jeff Johnsone50427c2017-01-26 10:54:49 -08003748 request = hdd_request_get(context);
3749 if (!request) {
3750 hdd_err("Obsolete request");
3751 return;
3752 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753
Jeff Johnsone50427c2017-01-26 10:54:49 -08003754 priv = hdd_request_priv(request);
3755 priv->linkspeed_info = *linkspeed_info;
3756 hdd_request_complete(request);
3757 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758}
3759
Jeff Johnson3d278b02017-08-29 14:17:47 -07003760int wlan_hdd_get_linkspeed_for_peermac(struct hdd_adapter *adapter,
Jeff Johnsone50427c2017-01-26 10:54:49 -08003761 struct qdf_mac_addr *mac_address,
3762 uint32_t *linkspeed)
3763{
3764 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303765 QDF_STATUS status;
Jeff Johnsone50427c2017-01-26 10:54:49 -08003766 void *cookie;
3767 tSirLinkSpeedInfo *linkspeed_info;
3768 struct hdd_request *request;
3769 struct linkspeed_priv *priv;
3770 static const struct hdd_request_params params = {
3771 .priv_size = sizeof(*priv),
3772 .timeout_ms = WLAN_WAIT_TIME_STATS,
3773 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774
Jeff Johnsone50427c2017-01-26 10:54:49 -08003775 if ((!adapter) || (!linkspeed)) {
3776 hdd_err("NULL argument");
3777 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779
Jeff Johnsone50427c2017-01-26 10:54:49 -08003780 request = hdd_request_alloc(&params);
3781 if (!request) {
3782 hdd_err("Request allocation failure");
3783 ret = -ENOMEM;
3784 goto return_cached_value;
3785 }
3786
3787 cookie = hdd_request_cookie(request);
3788 priv = hdd_request_priv(request);
3789
3790 linkspeed_info = &priv->linkspeed_info;
3791 qdf_copy_macaddr(&linkspeed_info->peer_macaddr, mac_address);
3792 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(adapter),
3793 linkspeed_info,
3794 cookie, hdd_get_link_speed_cb);
3795 if (QDF_IS_STATUS_ERROR(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003796 hdd_err("Unable to retrieve statistics for link speed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003797 ret = qdf_status_to_os_return(status);
3798 goto cleanup;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 }
Jeff Johnsone50427c2017-01-26 10:54:49 -08003800 ret = hdd_request_wait_for_response(request);
3801 if (ret) {
3802 hdd_err("SME timed out while retrieving link speed");
3803 goto cleanup;
3804 }
3805 adapter->estimated_linkspeed = linkspeed_info->estLinkSpeed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806
Jeff Johnsone50427c2017-01-26 10:54:49 -08003807cleanup:
3808 /*
3809 * either we never sent a request, we sent a request and
3810 * received a response or we sent a request and timed out.
3811 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 */
Jeff Johnsone50427c2017-01-26 10:54:49 -08003813 hdd_request_put(request);
3814
3815return_cached_value:
3816 *linkspeed = adapter->estimated_linkspeed;
3817
3818 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819}
3820
Jeff Johnson4e632672017-10-03 11:40:51 -07003821int wlan_hdd_get_link_speed(struct hdd_adapter *adapter, uint32_t *link_speed)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822{
Jeff Johnson4e632672017-10-03 11:40:51 -07003823 struct hdd_context *hddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003824 struct hdd_station_ctx *hdd_stactx =
Jeff Johnson4e632672017-10-03 11:40:51 -07003825 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 int ret;
3827
3828 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05303829 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303832 /* Linkspeed is allowed only for P2P mode */
Jeff Johnson4e632672017-10-03 11:40:51 -07003833 if (adapter->device_mode != QDF_P2P_CLIENT_MODE) {
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303834 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
Jeff Johnson4e632672017-10-03 11:40:51 -07003835 hdd_device_mode_to_string(adapter->device_mode),
3836 adapter->device_mode);
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303837 return -ENOTSUPP;
3838 }
3839
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
3841 /* we are not connected so we don't have a classAstats */
3842 *link_speed = 0;
3843 } else {
Anurag Chouhan6d760662016-02-20 16:05:43 +05303844 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845
Anurag Chouhanc5548422016-02-24 18:33:27 +05303846 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003847
Jeff Johnson4e632672017-10-03 11:40:51 -07003848 ret = wlan_hdd_get_linkspeed_for_peermac(adapter, &bssid,
Jeff Johnsone50427c2017-01-26 10:54:49 -08003849 link_speed);
3850 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003851 hdd_err("Unable to retrieve SME linkspeed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003852 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 /* linkspeed in units of 500 kbps */
3855 *link_speed = (*link_speed) / 500;
3856 }
3857 return 0;
3858}
3859
Will Huang496b36c2017-07-11 16:38:50 +08003860struct peer_rssi_priv {
3861 struct sir_peer_sta_info peer_sta_info;
3862};
3863
3864/**
3865 * hdd_get_peer_rssi_cb() - get peer station's rssi callback
3866 * @sta_rssi: pointer of peer information
3867 * @context: get rssi callback context
3868 *
3869 * This function will fill rssi information to rssi priv
3870 * adapter
3871 *
3872 */
3873static void hdd_get_peer_rssi_cb(struct sir_peer_info_resp *sta_rssi,
3874 void *context)
3875{
3876 struct hdd_request *request;
3877 struct peer_rssi_priv *priv;
3878 struct sir_peer_info *rssi_info;
3879 uint8_t peer_num;
3880
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05303881 if ((!sta_rssi)) {
3882 hdd_err("Bad param, sta_rssi [%pK]", sta_rssi);
Will Huang496b36c2017-07-11 16:38:50 +08003883 return;
3884 }
3885
3886 request = hdd_request_get(context);
3887 if (!request) {
3888 hdd_err("Obsolete request");
3889 return;
3890 }
3891
3892 priv = hdd_request_priv(request);
3893
3894 peer_num = sta_rssi->count;
3895 rssi_info = sta_rssi->info;
3896
3897 hdd_debug("%d peers", peer_num);
3898
3899 if (peer_num > MAX_PEER_STA) {
3900 hdd_warn("Exceed max peer sta to handle one time %d", peer_num);
3901 peer_num = MAX_PEER_STA;
3902 }
3903
3904 qdf_mem_copy(priv->peer_sta_info.info, rssi_info,
3905 peer_num * sizeof(*rssi_info));
3906 priv->peer_sta_info.sta_num = peer_num;
3907
3908 hdd_request_complete(request);
3909 hdd_request_put(request);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05303910
Will Huang496b36c2017-07-11 16:38:50 +08003911}
3912
Jeff Johnson3d278b02017-08-29 14:17:47 -07003913int wlan_hdd_get_peer_rssi(struct hdd_adapter *adapter,
Will Huang496b36c2017-07-11 16:38:50 +08003914 struct qdf_mac_addr *macaddress,
3915 struct sir_peer_sta_info *peer_sta_info)
3916{
3917 QDF_STATUS status;
3918 void *cookie;
3919 int ret;
3920 struct sir_peer_info_req rssi_req;
3921 struct hdd_request *request;
3922 struct peer_rssi_priv *priv;
3923 static const struct hdd_request_params params = {
3924 .priv_size = sizeof(*priv),
3925 .timeout_ms = WLAN_WAIT_TIME_STATS,
3926 };
3927
3928 if (!adapter || !macaddress || !peer_sta_info) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003929 hdd_err("adapter [%pK], macaddress [%pK], peer_sta_info[%pK]",
Will Huang496b36c2017-07-11 16:38:50 +08003930 adapter, macaddress, peer_sta_info);
3931 return -EFAULT;
3932 }
3933
3934 request = hdd_request_alloc(&params);
3935 if (!request) {
3936 hdd_err("Request allocation failure");
3937 return -ENOMEM;
3938 }
3939
3940 cookie = hdd_request_cookie(request);
3941 priv = hdd_request_priv(request);
3942
3943 qdf_mem_copy(&rssi_req.peer_macaddr, macaddress,
3944 QDF_MAC_ADDR_SIZE);
Jeff Johnson1b780e42017-10-31 14:11:45 -07003945 rssi_req.sessionid = adapter->session_id;
Will Huang496b36c2017-07-11 16:38:50 +08003946 status = sme_get_peer_info(WLAN_HDD_GET_HAL_CTX(adapter),
3947 rssi_req,
3948 cookie,
3949 hdd_get_peer_rssi_cb);
3950 if (status != QDF_STATUS_SUCCESS) {
3951 hdd_err("Unable to retrieve statistics for rssi");
3952 ret = -EFAULT;
3953 } else {
3954 ret = hdd_request_wait_for_response(request);
3955 if (ret) {
3956 hdd_err("SME timed out while retrieving rssi");
3957 ret = -EFAULT;
3958 } else {
3959 *peer_sta_info = priv->peer_sta_info;
3960 ret = 0;
3961 }
3962 }
3963
3964 hdd_request_put(request);
3965
3966 return ret;
3967}
3968
3969struct peer_info_priv {
3970 struct sir_peer_sta_ext_info peer_sta_ext_info;
3971};
3972
3973/**
3974 * wlan_hdd_get_peer_info_cb() - get peer info callback
3975 * @sta_info: pointer of peer information
3976 * @context: get peer info callback context
3977 *
3978 * This function will fill stats info to peer info priv
3979 *
3980 */
3981static void wlan_hdd_get_peer_info_cb(struct sir_peer_info_ext_resp *sta_info,
3982 void *context)
3983{
3984 struct hdd_request *request;
3985 struct peer_info_priv *priv;
3986 uint8_t sta_num;
3987
3988 if ((!sta_info) || (!context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07003989 hdd_err("Bad param, sta_info [%pK] context [%pK]",
Will Huang496b36c2017-07-11 16:38:50 +08003990 sta_info, context);
3991 return;
3992 }
3993
3994 if (!sta_info->count) {
3995 hdd_err("Fail to get remote peer info");
3996 return;
3997 }
3998
3999 if (sta_info->count > MAX_PEER_STA) {
4000 hdd_warn("Exceed max peer number %d", sta_info->count);
4001 sta_num = MAX_PEER_STA;
4002 } else {
4003 sta_num = sta_info->count;
4004 }
4005
4006 request = hdd_request_get(context);
4007 if (!request) {
4008 hdd_err("Obsolete request");
4009 return;
4010 }
4011
4012 priv = hdd_request_priv(request);
4013
4014 priv->peer_sta_ext_info.sta_num = sta_num;
4015 qdf_mem_copy(&priv->peer_sta_ext_info.info,
4016 sta_info->info,
4017 sta_num * sizeof(sta_info->info[0]));
4018
4019 hdd_request_complete(request);
4020 hdd_request_put(request);
4021}
4022
Jeff Johnson3d278b02017-08-29 14:17:47 -07004023int wlan_hdd_get_peer_info(struct hdd_adapter *adapter,
Will Huang496b36c2017-07-11 16:38:50 +08004024 struct qdf_mac_addr macaddress,
4025 struct sir_peer_info_ext *peer_info_ext)
4026{
4027 QDF_STATUS status;
4028 void *cookie;
4029 int ret;
4030 struct sir_peer_info_ext_req peer_info_req;
4031 struct hdd_request *request;
4032 struct peer_info_priv *priv;
4033 static const struct hdd_request_params params = {
4034 .priv_size = sizeof(*priv),
4035 .timeout_ms = WLAN_WAIT_TIME_STATS,
4036 };
4037
4038 if (!adapter) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004039 hdd_err("adapter is NULL");
Will Huang496b36c2017-07-11 16:38:50 +08004040 return -EFAULT;
4041 }
4042
4043 request = hdd_request_alloc(&params);
4044 if (!request) {
4045 hdd_err("Request allocation failure");
4046 return -ENOMEM;
4047 }
4048
4049 cookie = hdd_request_cookie(request);
4050 priv = hdd_request_priv(request);
4051
4052 qdf_mem_copy(&peer_info_req.peer_macaddr, &macaddress,
4053 QDF_MAC_ADDR_SIZE);
Jeff Johnson1b780e42017-10-31 14:11:45 -07004054 peer_info_req.sessionid = adapter->session_id;
Will Huang496b36c2017-07-11 16:38:50 +08004055 peer_info_req.reset_after_request = 0;
4056 status = sme_get_peer_info_ext(WLAN_HDD_GET_HAL_CTX(adapter),
4057 &peer_info_req,
4058 cookie,
4059 wlan_hdd_get_peer_info_cb);
4060 if (status != QDF_STATUS_SUCCESS) {
4061 hdd_err("Unable to retrieve statistics for peer info");
4062 ret = -EFAULT;
4063 } else {
4064 ret = hdd_request_wait_for_response(request);
4065 if (ret) {
4066 hdd_err("SME timed out while retrieving peer info");
4067 ret = -EFAULT;
4068 } else {
4069 /* only support one peer by now */
4070 *peer_info_ext = priv->peer_sta_ext_info.info[0];
4071 ret = 0;
4072 }
4073 }
4074
4075 hdd_request_put(request);
4076
4077 return ret;
4078}
4079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004082 * @adapter: adapter who's IEs are to be cleared
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083 *
4084 * Return: None
4085 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004086void hdd_clear_roam_profile_ie(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087{
Jeff Johnson731bc322017-10-14 19:53:44 -07004088 struct hdd_station_ctx *sta_ctx;
Jeff Johnson2a722002017-09-30 20:02:35 -07004089 struct hdd_wext_state *pWextState =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004090 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004091
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004092 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093
4094 /* clear WPA/RSN/WSC IE information in the profile */
4095 pWextState->roamProfile.nWPAReqIELength = 0;
4096 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
4097 pWextState->roamProfile.nRSNReqIELength = 0;
4098 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
4099
4100#ifdef FEATURE_WLAN_WAPI
4101 pWextState->roamProfile.nWAPIReqIELength = 0;
4102 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
4103#endif
4104
4105 pWextState->roamProfile.bWPSAssociation = false;
4106 pWextState->roamProfile.bOSENAssociation = false;
4107 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
4108 pWextState->roamProfile.nAddIEScanLength = 0;
4109 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
4110 pWextState->roamProfile.nAddIEAssocLength = 0;
4111
4112 pWextState->roamProfile.EncryptionType.numEntries = 1;
4113 pWextState->roamProfile.EncryptionType.encryptionType[0]
4114 = eCSR_ENCRYPT_TYPE_NONE;
4115
4116 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4117 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
4118 = eCSR_ENCRYPT_TYPE_NONE;
4119
4120 pWextState->roamProfile.AuthType.numEntries = 1;
4121 pWextState->roamProfile.AuthType.authType[0] =
4122 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4123
Abhishek Singh3c9910e2017-01-06 17:56:47 +05304124 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
4125 QDF_MAC_ADDR_SIZE);
4126
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127#ifdef WLAN_FEATURE_11W
4128 pWextState->roamProfile.MFPEnabled = false;
4129 pWextState->roamProfile.MFPRequired = 0;
4130 pWextState->roamProfile.MFPCapable = 0;
4131#endif
4132
4133 pWextState->authKeyMgmt = 0;
4134
Yingying Tang3cc6b792016-10-20 17:00:37 +08004135 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
4136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137#ifdef FEATURE_WLAN_WAPI
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07004138 adapter->wapi_info.wapi_auth_mode = WAPI_AUTH_MODE_OPEN;
4139 adapter->wapi_info.wapi_mode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140#endif
4141
Jeff Johnson731bc322017-10-14 19:53:44 -07004142 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
4143 qdf_zero_macaddr(&sta_ctx->requested_bssid);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004144 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145}
4146
4147/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304148 * hdd_get_ldpc() - Get adapter LDPC
4149 * @adapter: adapter being queried
4150 * @value: where to store the value
4151 *
4152 * Return: 0 on success, negative errno on failure
4153 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004154int hdd_get_ldpc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304155{
4156 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4157 int ret;
4158
4159 ENTER();
Jeff Johnson1b780e42017-10-31 14:11:45 -07004160 ret = sme_get_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304161 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
4162 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004163 hdd_err("Failed to get LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304164 } else {
4165 *value = ret;
4166 ret = 0;
4167 }
4168 return ret;
4169}
4170
4171/**
4172 * hdd_set_ldpc() - Set adapter LDPC
4173 * @adapter: adapter being modified
4174 * @value: new LDPC value
4175 *
4176 * Return: 0 on success, negative errno on failure
4177 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004178int hdd_set_ldpc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304179{
4180 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4181 int ret;
4182
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004183 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304184 if (value) {
4185 /* make sure HT capabilities allow this */
4186 QDF_STATUS status;
4187 uint32_t cfg_value;
4188 union {
4189 uint16_t cfg_value16;
4190 tSirMacHTCapabilityInfo ht_cap_info;
4191 } u;
4192
4193 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4194 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004195 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304196 return -EIO;
4197 }
4198 u.cfg_value16 = cfg_value & 0xFFFF;
4199 if (!u.ht_cap_info.advCodingCap) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004200 hdd_err("LDCP not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304201 return -EINVAL;
4202 }
4203 }
4204
Jeff Johnson1b780e42017-10-31 14:11:45 -07004205 ret = sme_update_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304206 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
4207 value);
4208 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004209 hdd_err("Failed to set LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304210
4211 return ret;
4212}
4213
4214/**
4215 * hdd_get_tx_stbc() - Get adapter TX STBC
4216 * @adapter: adapter being queried
4217 * @value: where to store the value
4218 *
4219 * Return: 0 on success, negative errno on failure
4220 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004221int hdd_get_tx_stbc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304222{
4223 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4224 int ret;
4225
4226 ENTER();
Jeff Johnson1b780e42017-10-31 14:11:45 -07004227 ret = sme_get_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304228 WNI_CFG_HT_CAP_INFO_TX_STBC);
4229 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004230 hdd_err("Failed to get TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304231 } else {
4232 *value = ret;
4233 ret = 0;
4234 }
4235
4236 return ret;
4237}
4238
4239/**
4240 * hdd_set_tx_stbc() - Set adapter TX STBC
4241 * @adapter: adapter being modified
4242 * @value: new TX STBC value
4243 *
4244 * Return: 0 on success, negative errno on failure
4245 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004246int hdd_set_tx_stbc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304247{
4248 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4249 int ret;
4250
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004251 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304252 if (value) {
4253 /* make sure HT capabilities allow this */
4254 QDF_STATUS status;
4255 uint32_t cfg_value;
4256 union {
4257 uint16_t cfg_value16;
4258 tSirMacHTCapabilityInfo ht_cap_info;
4259 } u;
4260
4261 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4262 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004263 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304264 return -EIO;
4265 }
4266 u.cfg_value16 = cfg_value & 0xFFFF;
4267 if (!u.ht_cap_info.txSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004268 hdd_err("TX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304269 return -EINVAL;
4270 }
4271 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07004272 ret = sme_update_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304273 WNI_CFG_HT_CAP_INFO_TX_STBC,
4274 value);
4275 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004276 hdd_err("Failed to set TX STBC value");
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08004277 ret = sme_update_he_tx_stbc_cap(hal, adapter->session_id, value);
4278 if (ret)
4279 hdd_err("Failed to set HE TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304280
4281 return ret;
4282}
4283
4284/**
4285 * hdd_get_rx_stbc() - Get adapter RX STBC
4286 * @adapter: adapter being queried
4287 * @value: where to store the value
4288 *
4289 * Return: 0 on success, negative errno on failure
4290 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004291int hdd_get_rx_stbc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304292{
4293 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4294 int ret;
4295
4296 ENTER();
Jeff Johnson1b780e42017-10-31 14:11:45 -07004297 ret = sme_get_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304298 WNI_CFG_HT_CAP_INFO_RX_STBC);
4299 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004300 hdd_err("Failed to get RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304301 } else {
4302 *value = ret;
4303 ret = 0;
4304 }
4305
4306 return ret;
4307}
4308
4309/**
4310 * hdd_set_rx_stbc() - Set adapter RX STBC
4311 * @adapter: adapter being modified
4312 * @value: new RX STBC value
4313 *
4314 * Return: 0 on success, negative errno on failure
4315 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004316int hdd_set_rx_stbc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304317{
4318 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4319 int ret;
4320
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004321 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304322 if (value) {
4323 /* make sure HT capabilities allow this */
4324 QDF_STATUS status;
4325 uint32_t cfg_value;
4326 union {
4327 uint16_t cfg_value16;
4328 tSirMacHTCapabilityInfo ht_cap_info;
4329 } u;
4330
4331 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4332 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004333 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304334 return -EIO;
4335 }
4336 u.cfg_value16 = cfg_value & 0xFFFF;
4337 if (!u.ht_cap_info.rxSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004338 hdd_warn("RX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304339 return -EINVAL;
4340 }
4341 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07004342 ret = sme_update_ht_config(hal, adapter->session_id,
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304343 WNI_CFG_HT_CAP_INFO_RX_STBC,
4344 value);
4345 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004346 hdd_err("Failed to set RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304347
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08004348 ret = sme_update_he_rx_stbc_cap(hal, adapter->session_id, value);
4349 if (ret)
4350 hdd_err("Failed to set HE RX STBC value");
4351
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304352 return ret;
4353}
4354
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004355int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate)
4356{
4357 int set_value;
4358
4359 if (sme_is_feature_supported_by_fw(DOT11AX))
4360 set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble);
4361 else
4362 set_value = (preamble << 6) | (nss << 4) | rate;
4363
4364 return set_value;
4365}
4366
Jeff Johnson3d278b02017-08-29 14:17:47 -07004367int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004368 struct sap_Config *sap_config)
4369{
4370 uint8_t preamble = 0, nss = 0, rix = 0;
4371 int ret;
4372
4373 if (!sap_config) {
4374 if (!sme_is_feature_supported_by_fw(DOT11AX)) {
4375 hdd_err("Target does not support 11ax");
4376 return -EIO;
4377 }
4378 } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax &&
4379 sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07004380 hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d",
4381 sap_config->SapHw_mode, sap_config->channel);
4382 return -EIO;
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004383 }
4384
4385 if (set_value != 0xff) {
4386 rix = RC_2_RATE_IDX_11AX(set_value);
4387 preamble = WMI_RATE_PREAMBLE_HE;
4388 nss = HT_RC_2_STREAMS_11AX(set_value);
4389
4390 set_value = hdd_assemble_rate_code(preamble, nss, rix);
4391 }
4392
4393 hdd_notice("SET_11AX_RATE val %d rix %d preamble %x nss %d",
4394 set_value, rix, preamble, nss);
4395
Jeff Johnson1b780e42017-10-31 14:11:45 -07004396 ret = wma_cli_set_command(adapter->session_id,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004397 WMI_VDEV_PARAM_FIXED_RATE,
4398 set_value, VDEV_CMD);
4399
4400 return ret;
4401}
4402
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304403/**
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004404 * hdd_get_aid_rc() - Get AID and rate code passed from user
4405 * @aid: pointer to AID
4406 * @rc: pointer to rate code
4407 * @set_value: value passed from user
4408 *
4409 * If target is 11ax capable, set_value will have AID left shifted 16 bits
4410 * and 16 bits for rate code. If the target is not 11ax capable, rate code
4411 * will only be 8 bits.
4412 *
4413 * Return: None
4414 */
4415static void hdd_get_aid_rc(uint8_t *aid, uint16_t *rc, int set_value)
4416{
4417 uint8_t rc_bits;
4418
4419 if (sme_is_feature_supported_by_fw(DOT11AX))
4420 rc_bits = 16;
4421 else
4422 rc_bits = 8;
4423
4424 *aid = set_value >> rc_bits;
4425 *rc = set_value & ((1 << (rc_bits + 1)) - 1);
4426}
4427
Jeff Johnson3d278b02017-08-29 14:17:47 -07004428int hdd_set_peer_rate(struct hdd_adapter *adapter, int set_value)
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004429{
4430 uint8_t aid, *peer_mac;
4431 uint16_t rc;
4432 QDF_STATUS status;
4433
4434 if (adapter->device_mode != QDF_SAP_MODE) {
4435 hdd_err("Invalid devicde mode - %d", adapter->device_mode);
4436 return -EINVAL;
4437 }
4438
4439 hdd_get_aid_rc(&aid, &rc, set_value);
4440
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07004441 if ((adapter->sta_info[aid].in_use) &&
4442 (OL_TXRX_PEER_STATE_CONN == adapter->sta_info[aid].peer_state)) {
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004443 peer_mac =
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07004444 (uint8_t *)&(adapter->sta_info[aid].sta_mac.bytes[0]);
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004445 hdd_info("Peer AID: %d MAC_ADDR: "MAC_ADDRESS_STR,
4446 aid, MAC_ADDR_ARRAY(peer_mac));
4447 } else {
4448 hdd_err("No matching peer found for AID: %d", aid);
4449 return -EINVAL;
4450 }
4451
4452 status = sme_set_peer_param(peer_mac, WMI_PEER_PARAM_FIXED_RATE,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004453 rc, adapter->session_id);
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004454 if (status != QDF_STATUS_SUCCESS) {
4455 hdd_err("Failed to set peer fixed rate - status: %d", status);
4456 return -EIO;
4457 }
4458
4459 return 0;
4460}
4461
4462/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
4464 * @dev: device upon which the ioctl was received
4465 * @info: ioctl request information
4466 * @wrqu: ioctl request data
4467 * @extra: ioctl extra data
4468 *
4469 * Return: 0 on success, non-zero on error
4470 */
4471static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
4472 union iwreq_data *wrqu, char *extra)
4473{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004474 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004475 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476 int ret;
4477
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004478 ENTER_DEV(dev);
4479
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4481 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4482 ret = wlan_hdd_validate_context(hdd_ctx);
4483 if (0 != ret)
4484 return ret;
4485
Jeff Johnson441e1f72017-02-07 08:50:49 -08004486 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4487 if (0 != ret)
4488 return ret;
4489
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 /* Do nothing for now */
4491 return 0;
4492}
4493
4494/**
4495 * iw_set_commit() - SSR wrapper function for __iw_set_commit
4496 * @dev: pointer to net_device
4497 * @info: pointer to iw_request_info
4498 * @wrqu: pointer to iwreq_data
4499 * @extra: extra
4500 *
4501 * Return: 0 on success, error number otherwise
4502 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004503static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 union iwreq_data *wrqu, char *extra)
4505{
4506 int ret;
4507
4508 cds_ssr_protect(__func__);
4509 ret = __iw_set_commit(dev, info, wrqu, extra);
4510 cds_ssr_unprotect(__func__);
4511
4512 return ret;
4513}
4514
4515/**
4516 * __iw_get_name() - SIOCGIWNAME ioctl handler
4517 * @dev: device upon which the ioctl was received
4518 * @info: ioctl request information
4519 * @wrqu: ioctl request data
4520 * @extra: ioctl extra data
4521 *
4522 * Return: 0 on success, non-zero on error
4523 */
4524static int __iw_get_name(struct net_device *dev,
4525 struct iw_request_info *info, char *wrqu, char *extra)
4526{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004527 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004528 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529 int ret;
4530
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004531 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532
4533 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4534 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4535 ret = wlan_hdd_validate_context(hdd_ctx);
4536 if (0 != ret)
4537 return ret;
4538
Jeff Johnson441e1f72017-02-07 08:50:49 -08004539 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4540 if (0 != ret)
4541 return ret;
4542
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
4544 EXIT();
4545 return 0;
4546}
4547
4548/**
4549 * __iw_get_name() - SSR wrapper for __iw_get_name
4550 * @dev: pointer to net_device
4551 * @info: pointer to iw_request_info
4552 * @wrqu: pointer to iwreq_data
4553 * @extra: extra
4554 *
4555 * Return: 0 on success, error number otherwise
4556 */
4557static int iw_get_name(struct net_device *dev,
4558 struct iw_request_info *info,
4559 char *wrqu, char *extra)
4560{
4561 int ret;
4562
4563 cds_ssr_protect(__func__);
4564 ret = __iw_get_name(dev, info, wrqu, extra);
4565 cds_ssr_unprotect(__func__);
4566
4567 return ret;
4568}
4569
4570/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 * __iw_get_range() - SIOCGIWRANGE ioctl handler
4572 * @dev: device upon which the ioctl was received
4573 * @info: ioctl request information
4574 * @wrqu: ioctl request data
4575 * @extra: ioctl extra data
4576 *
4577 * Return: 0 on success, non-zero on error
4578 */
4579static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
4580 union iwreq_data *wrqu, char *extra)
4581{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004582 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4583 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 struct iw_range *range = (struct iw_range *)extra;
4585
4586 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4587
4588 uint32_t num_channels = sizeof(channels);
4589 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4590 uint32_t a_len;
4591 uint32_t b_len;
4592 uint32_t active_phy_mode = 0;
4593 uint8_t index = 0, i;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004594 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 int ret;
4596
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004597 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004599 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 ret = wlan_hdd_validate_context(hdd_ctx);
4601 if (0 != ret)
4602 return ret;
4603
Jeff Johnson441e1f72017-02-07 08:50:49 -08004604 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4605 if (0 != ret)
4606 return ret;
4607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 wrqu->data.length = sizeof(struct iw_range);
4609 memset(range, 0, sizeof(struct iw_range));
4610
4611
4612 /*Get the phy mode */
4613 if (sme_cfg_get_int(hHal,
4614 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304615 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004616 hdd_debug("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617
4618 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
4619 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
4620 /*Get the supported rates for 11G band */
4621 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4622 if (sme_cfg_get_str(hHal,
4623 WNI_CFG_SUPPORTED_RATES_11A,
4624 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304625 &a_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004626 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 for (i = 0; i < a_len; i++) {
4630 range->bitrate[i] =
4631 ((supp_rates[i] & 0x7F) / 2) *
4632 1000000;
4633 }
4634 range->num_bitrates = a_len;
4635 } else {
4636 return -EIO;
4637 }
4638 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
4639 /*Get the supported rates for 11B band */
4640 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4641 if (sme_cfg_get_str(hHal,
4642 WNI_CFG_SUPPORTED_RATES_11B,
4643 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304644 &b_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004645 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004647
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 for (i = 0; i < b_len; i++) {
4649 range->bitrate[i] =
4650 ((supp_rates[i] & 0x7F) / 2) *
4651 1000000;
4652 }
4653 range->num_bitrates = b_len;
4654 } else {
4655 return -EIO;
4656 }
4657 }
4658 }
4659
4660 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
4661 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
4662 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
4663
4664 range->encoding_size[0] = 5;
4665 range->encoding_size[1] = 13;
4666 range->num_encoding_sizes = 2;
4667 range->max_encoding_tokens = MAX_WEP_KEYS;
4668
4669 /* we support through Wireless Extensions 22 */
4670 range->we_version_compiled = WIRELESS_EXT;
4671 range->we_version_source = 22;
4672
4673 /*Supported Channels and Frequencies */
4674 if (sme_cfg_get_str
4675 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304676 &num_channels) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004677 hdd_err("Failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 return -EIO;
4679 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004680 if (num_channels > IW_MAX_FREQUENCIES)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 num_channels = IW_MAX_FREQUENCIES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682
4683 range->num_channels = num_channels;
4684 range->num_frequency = num_channels;
4685
4686 for (index = 0; index < num_channels; index++) {
4687 uint32_t frq_indx = 0;
4688
4689 range->freq[index].i = channels[index];
4690 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
4691 if (channels[index] == freq_chan_map[frq_indx].chan) {
4692 range->freq[index].m =
4693 freq_chan_map[frq_indx].freq * 100000;
4694 range->freq[index].e = 1;
4695 break;
4696 }
4697 frq_indx++;
4698 }
4699 }
4700
4701 /* Event capability (kernel + driver) */
4702 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
4703 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
4704 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
4705 range->event_capa[1] = IW_EVENT_CAPA_K_1;
4706
4707 /*Encryption capability */
4708 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
4709 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
4710
4711 /* Txpower capability */
4712 range->txpower_capa = IW_TXPOW_MWATT;
4713
4714 /*Scanning capability */
4715#if WIRELESS_EXT >= 22
4716 range->scan_capa =
4717 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
4718#endif
4719
4720 EXIT();
4721 return 0;
4722}
4723
4724/**
4725 * iw_get_range() - SSR wrapper for __iw_get_range()
4726 * @dev: pointer to net_device
4727 * @info: pointer to iw_request_info
4728 * @wrqu: pointer to iwreq_data
4729 * @extra: pointer to extra ioctl payload
4730 *
4731 * Return: 0 on success, error number otherwise
4732 */
4733static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
4734 union iwreq_data *wrqu, char *extra)
4735{
4736 int ret;
4737
4738 cds_ssr_protect(__func__);
4739 ret = __iw_get_range(dev, info, wrqu, extra);
4740 cds_ssr_unprotect(__func__);
4741
4742 return ret;
4743}
4744
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004745struct class_a_stats {
4746 tCsrGlobalClassAStatsInfo class_a_stats;
4747};
4748
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749/**
4750 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004751 * @stats: pointer to Class A stats
4752 * @context: user context originally registered with SME (always the
4753 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 *
4755 * Return: None
4756 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004757static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004759 struct hdd_request *request;
4760 struct class_a_stats *priv;
4761 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004763 ENTER();
4764 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07004765 hdd_err("Bad param, stats [%pK] context [%pK]",
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004766 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767 return;
4768 }
4769
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004770 request = hdd_request_get(context);
4771 if (!request) {
4772 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004773 return;
4774 }
4775
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004776 returned_stats = stats;
4777 priv = hdd_request_priv(request);
4778 priv->class_a_stats = *returned_stats;
4779 hdd_request_complete(request);
4780 hdd_request_put(request);
4781 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782}
4783
4784/**
4785 * wlan_hdd_get_class_astats() - Get Class A statistics
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004786 * @adapter: adapter for which statistics are desired
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304788 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004790QDF_STATUS wlan_hdd_get_class_astats(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004791{
Jeff Johnsond377dce2017-10-04 10:32:42 -07004792 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304793 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004794 int ret;
4795 void *cookie;
4796 struct hdd_request *request;
4797 struct class_a_stats *priv;
4798 static const struct hdd_request_params params = {
4799 .priv_size = sizeof(*priv),
4800 .timeout_ms = WLAN_WAIT_TIME_STATS,
4801 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004803 if (NULL == adapter) {
4804 hdd_err("adapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304805 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004806 }
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +05304807 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004808 hdd_debug("Recovery in Progress. State: 0x%x Ignore!!!",
Prashanth Bhatta9e143052015-12-04 11:56:47 -08004809 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304810 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811 }
4812
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004813 request = hdd_request_alloc(&params);
4814 if (!request) {
4815 hdd_err("Request allocation failure");
4816 return QDF_STATUS_E_NOMEM;
4817 }
4818 cookie = hdd_request_cookie(request);
4819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 /* query only for Class A statistics (which include link speed) */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004821 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
4823 hdd_get_class_a_statistics_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07004824 sta_ctx->conn_info.staId[0],
Jeff Johnson1b780e42017-10-31 14:11:45 -07004825 cookie, adapter->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304826 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07004827 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004828 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829 }
4830
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004831 /* request was sent -- wait for the response */
4832 ret = hdd_request_wait_for_response(request);
4833 if (ret) {
4834 hdd_warn("SME timed out while retrieving Class A statistics");
4835 goto return_cached_results;
4836 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004838 /* update the adapter with the fresh results */
4839 priv = hdd_request_priv(request);
Jeff Johnson861dd4f2017-10-24 10:10:40 -07004840 adapter->hdd_stats.class_a_stat = priv->class_a_stats;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08004841
4842return_cached_results:
4843 /*
4844 * either we never sent a request, we sent a request and
4845 * received a response or we sent a request and timed out.
4846 * regardless we are done with the request.
4847 */
4848 hdd_request_put(request);
4849
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304850 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851}
4852
Jeff Johnsondda167c2017-01-23 10:37:57 -08004853struct station_stats {
4854 tCsrSummaryStatsInfo summary_stats;
4855 tCsrGlobalClassAStatsInfo class_a_stats;
4856 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
4857};
4858
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859/**
4860 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08004861 * @stats: pointer to combined station stats
4862 * @context: user context originally registered with SME (always the
4863 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 *
4865 * Return: None
4866 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004867static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004868{
Jeff Johnsondda167c2017-01-23 10:37:57 -08004869 struct hdd_request *request;
4870 struct station_stats *priv;
4871 tCsrSummaryStatsInfo *summary_stats;
4872 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304873 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004874
Jeff Johnsondda167c2017-01-23 10:37:57 -08004875 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07004876 hdd_err("Bad param, pStats [%pK] pContext [%pK]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08004877 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878 return;
4879 }
4880
Jeff Johnsondda167c2017-01-23 10:37:57 -08004881 request = hdd_request_get(context);
4882 if (!request) {
4883 hdd_err("Obsolete request");
4884 return;
4885 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886
Jeff Johnsondda167c2017-01-23 10:37:57 -08004887 summary_stats = (tCsrSummaryStatsInfo *) stats;
4888 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05304889 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08004890 (class_a_stats + 1);
4891 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004892
4893 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004894 priv->summary_stats = *summary_stats;
4895 priv->class_a_stats = *class_a_stats;
4896 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004897
Jeff Johnsondda167c2017-01-23 10:37:57 -08004898 hdd_request_complete(request);
4899 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900}
4901
4902/**
4903 * wlan_hdd_get_station_stats() - Get station statistics
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004904 * @adapter: adapter for which statistics are desired
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304906 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004908QDF_STATUS wlan_hdd_get_station_stats(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909{
Jeff Johnsond377dce2017-10-04 10:32:42 -07004910 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dustin Brown0f5260d2017-06-12 16:17:38 -07004911 QDF_STATUS status;
4912 int errno;
Jeff Johnsondda167c2017-01-23 10:37:57 -08004913 void *cookie;
4914 struct hdd_request *request;
4915 struct station_stats *priv;
4916 static const struct hdd_request_params params = {
4917 .priv_size = sizeof(*priv),
4918 .timeout_ms = WLAN_WAIT_TIME_STATS,
4919 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004921 if (NULL == adapter) {
4922 hdd_err("adapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304923 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924 }
4925
Jeff Johnsondda167c2017-01-23 10:37:57 -08004926 request = hdd_request_alloc(&params);
4927 if (!request) {
4928 hdd_err("Request allocation failure");
4929 return QDF_STATUS_E_NOMEM;
4930 }
4931 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932
4933 /* query only for Summary & Class A statistics */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004934 status = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(adapter),
Dustin Brown0f5260d2017-06-12 16:17:38 -07004935 eCSR_HDD,
4936 SME_SUMMARY_STATS |
4937 SME_GLOBAL_CLASSA_STATS |
4938 SME_PER_CHAIN_RSSI_STATS,
4939 hdd_get_station_statistics_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07004940 sta_ctx->conn_info.staId[0],
Dustin Brown0f5260d2017-06-12 16:17:38 -07004941 cookie,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004942 adapter->session_id);
Dustin Brown0f5260d2017-06-12 16:17:38 -07004943 if (QDF_IS_STATUS_ERROR(status)) {
4944 hdd_err("Failed to retrieve statistics, status %d", status);
4945 goto put_request;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946 }
4947
Dustin Brown0f5260d2017-06-12 16:17:38 -07004948 /* request was sent -- wait for the response */
4949 errno = hdd_request_wait_for_response(request);
4950 if (errno) {
4951 hdd_err("Failed to wait for statistics, errno %d", errno);
4952 goto put_request;
4953 }
4954
4955 /* update the adapter with the fresh results */
4956 priv = hdd_request_priv(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004957 adapter->hdd_stats.summary_stat = priv->summary_stats;
Jeff Johnson861dd4f2017-10-24 10:10:40 -07004958 adapter->hdd_stats.class_a_stat = priv->class_a_stats;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004959 adapter->hdd_stats.per_chain_rssi_stats = priv->per_chain_rssi_stats;
Dustin Brown0f5260d2017-06-12 16:17:38 -07004960
4961put_request:
Jeff Johnsondda167c2017-01-23 10:37:57 -08004962 /*
4963 * either we never sent a request, we sent a request and
4964 * received a response or we sent a request and timed out.
4965 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004966 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08004967 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004968
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004969 /* either callback updated adapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304970 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971}
4972
4973/**
4974 * iw_get_linkspeed() - Get current link speed ioctl
4975 * @dev: device upon which the ioctl was received
4976 * @info: ioctl request information
4977 * @wrqu: ioctl request data
4978 * @extra: extra ioctl buffer
4979 *
4980 * Return: 0 on success, non-zero on error
4981 */
4982static int __iw_get_linkspeed(struct net_device *dev,
4983 struct iw_request_info *info,
4984 union iwreq_data *wrqu, char *extra)
4985{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004986 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987 char *pLinkSpeed = (char *)extra;
4988 int len = sizeof(uint32_t) + 1;
4989 uint32_t link_speed = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004990 struct hdd_context *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08004991 int ret;
4992 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08004994 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05304995
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004996 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08004997 ret = wlan_hdd_validate_context(hdd_ctx);
4998 if (0 != ret)
4999 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005000
Jeff Johnson441e1f72017-02-07 08:50:49 -08005001 ret = hdd_check_private_wext_control(hdd_ctx, info);
5002 if (0 != ret)
5003 return ret;
5004
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005005 ret = wlan_hdd_get_link_speed(adapter, &link_speed);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005006 if (0 != ret)
Jeff Johnson441e1f72017-02-07 08:50:49 -08005007 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005008
5009 wrqu->data.length = len;
5010 /* return the linkspeed as a string */
5011 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
5012 if ((rc < 0) || (rc >= len)) {
5013 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07005014 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015 return -EIO;
5016 }
5017
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305018 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019 /* a value is being successfully returned */
5020 return 0;
5021}
5022
5023static int iw_get_linkspeed(struct net_device *dev,
5024 struct iw_request_info *info,
5025 union iwreq_data *wrqu, char *extra)
5026{
5027 int ret;
5028
5029 cds_ssr_protect(__func__);
5030 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
5031 cds_ssr_unprotect(__func__);
5032
5033 return ret;
5034}
5035
5036/**
5037 * wlan_hdd_change_country_code_callback() - Change country code callback
5038 * @context: opaque context originally passed to SME. All functions
5039 * which use this callback pass the adapter upon which the country
5040 * code change is active
5041 *
5042 * This function is registered as the callback function when
5043 * sme_change_country_code() is invoked. Callers of
5044 * sme_change_country_code() subsequently wait for the adapter's
5045 * @change_country_code completion variable, so all this function
5046 * needs to do is set that completion variable so that execution can
5047 * continue.
5048 *
5049 * Return: none
5050 */
5051void wlan_hdd_change_country_code_callback(void *context)
5052{
5053
Jeff Johnson3d278b02017-08-29 14:17:47 -07005054 struct hdd_adapter *adapter = context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055
5056 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
5057 complete(&adapter->change_country_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005058}
5059
5060/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005061 * wlan_hdd_update_phymode() - handle change in PHY mode
5062 * @net: device upon which PHY mode change was received
5063 * @hal: umac handle for the driver
5064 * @new_phymode: new PHY mode for the device
5065 * @phddctx: pointer to the HDD context
5066 *
5067 * This function is called when the device is set to a new PHY mode.
5068 * It takes a holistic look at the desired PHY mode along with the
5069 * configured capabilities of the driver and the reported capabilities
5070 * of the hardware in order to correctly configure all PHY-related
5071 * parameters.
5072 *
5073 * Return: 0 on success, negative errno value on error
5074 */
5075int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005076 int new_phymode, struct hdd_context *phddctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077{
5078#ifdef QCA_HT_2040_COEX
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005079 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305080 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081#endif
5082 bool band_24 = false, band_5g = false;
5083 bool ch_bond24 = false, ch_bond5g = false;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305084 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087 eCsrPhyMode phymode = -EIO, old_phymode;
Srinivas Girigowda2fb677c2017-03-25 15:35:34 -07005088 enum hdd_dot11_mode hdd_dot11mode = phddctx->config->dot11Mode;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005089 enum band_info curr_band = BAND_ALL;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305090 int retval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091
5092 old_phymode = sme_get_phy_mode(hal);
5093
5094 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5095 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5096 nChannelBondingMode24GHz))
5097 ch_bond24 = true;
5098
5099 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5100 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
5101 nChannelBondingMode5GHz))
5102 ch_bond5g = true;
5103
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005104 if (phddctx->config->nBandCapability == BAND_ALL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105 band_24 = band_5g = true;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005106 else if (phddctx->config->nBandCapability == BAND_2G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005107 band_24 = true;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005108 else if (phddctx->config->nBandCapability == BAND_5G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 band_5g = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005110
5111 vhtchanwidth = phddctx->config->vhtChannelWidth;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005112 hdd_debug("ch_bond24=%d ch_bond5g=%d band_24=%d band_5g=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005113 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
5114
5115 switch (new_phymode) {
5116 case IEEE80211_MODE_AUTO:
5117 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005118 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119 phymode = eCSR_DOT11_MODE_AUTO;
5120 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5121 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005122 curr_band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5124 } else {
5125 sme_set_phy_mode(hal, old_phymode);
5126 return -EIO;
5127 }
5128 break;
5129 case IEEE80211_MODE_11A:
5130 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005131 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 phymode = eCSR_DOT11_MODE_11a;
5133 hdd_dot11mode = eHDD_DOT11_MODE_11a;
5134 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005135 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136 } else {
5137 sme_set_phy_mode(hal, old_phymode);
5138 return -EIO;
5139 }
5140 break;
5141 case IEEE80211_MODE_11B:
5142 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005143 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144 phymode = eCSR_DOT11_MODE_11b;
5145 hdd_dot11mode = eHDD_DOT11_MODE_11b;
5146 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005147 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 } else {
5149 sme_set_phy_mode(hal, old_phymode);
5150 return -EIO;
5151 }
5152 break;
5153 case IEEE80211_MODE_11G:
5154 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005155 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 phymode = eCSR_DOT11_MODE_11g;
5157 hdd_dot11mode = eHDD_DOT11_MODE_11g;
5158 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005159 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 } else {
5161 sme_set_phy_mode(hal, old_phymode);
5162 return -EIO;
5163 }
5164 break;
5165 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
5166 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
5167 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
5168 */
5169 case IEEE80211_MODE_11NA_HT20:
5170 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005171 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172 phymode = eCSR_DOT11_MODE_11n;
5173 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5174 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005175 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005176 } else {
5177 sme_set_phy_mode(hal, old_phymode);
5178 return -EIO;
5179 }
5180 break;
5181 case IEEE80211_MODE_11NA_HT40:
5182 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005183 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184 phymode = eCSR_DOT11_MODE_11n;
5185 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5186 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005187 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005188 } else {
5189 sme_set_phy_mode(hal, old_phymode);
5190 return -EIO;
5191 }
5192 break;
5193 case IEEE80211_MODE_11NG_HT20:
5194 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005195 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005196 phymode = eCSR_DOT11_MODE_11n;
5197 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5198 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005199 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 } else {
5201 sme_set_phy_mode(hal, old_phymode);
5202 return -EIO;
5203 }
5204 break;
5205 case IEEE80211_MODE_11NG_HT40:
5206 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005207 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208 phymode = eCSR_DOT11_MODE_11n;
5209 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5210 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005211 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005212 } else {
5213 sme_set_phy_mode(hal, old_phymode);
5214 return -EIO;
5215 }
5216 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217 case IEEE80211_MODE_11AC_VHT20:
5218 case IEEE80211_MODE_11AC_VHT40:
5219 case IEEE80211_MODE_11AC_VHT80:
5220 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005221 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222 phymode = eCSR_DOT11_MODE_11ac;
5223 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
5224 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005225 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 } else {
5227 sme_set_phy_mode(hal, old_phymode);
5228 return -EIO;
5229 }
5230 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005231 case IEEE80211_MODE_2G_AUTO:
5232 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005233 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234 phymode = eCSR_DOT11_MODE_AUTO;
5235 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5236 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005237 curr_band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005238 } else {
5239 sme_set_phy_mode(hal, old_phymode);
5240 return -EIO;
5241 }
5242 break;
5243 case IEEE80211_MODE_5G_AUTO:
5244 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005245 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246 phymode = eCSR_DOT11_MODE_AUTO;
5247 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
5248 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
5249 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005250 curr_band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 } else {
5252 sme_set_phy_mode(hal, old_phymode);
5253 return -EIO;
5254 }
5255 break;
5256 case IEEE80211_MODE_11AGN:
5257 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005258 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005259 phymode = eCSR_DOT11_MODE_11n;
5260 hdd_dot11mode = eHDD_DOT11_MODE_11n;
5261 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005262 curr_band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005263 } else {
5264 sme_set_phy_mode(hal, old_phymode);
5265 return -EIO;
5266 }
5267 break;
5268 default:
5269 return -EIO;
5270 }
5271
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005272 switch (new_phymode) {
5273 case IEEE80211_MODE_11AC_VHT20:
5274 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5275 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
5276 break;
5277 case IEEE80211_MODE_11AC_VHT40:
5278 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
5279 break;
5280 case IEEE80211_MODE_11AC_VHT80:
5281 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
5282 break;
5283 default:
5284 vhtchanwidth = phddctx->config->vhtChannelWidth;
5285 break;
5286 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005287
5288 if (phymode != -EIO) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305289 sme_config = qdf_mem_malloc(sizeof(*sme_config));
5290 if (!sme_config) {
5291 hdd_err("Failed to allocate memory for sme_config");
5292 return -ENOMEM;
5293 }
5294 qdf_mem_zero(sme_config, sizeof(*sme_config));
5295 sme_get_config_param(hal, sme_config);
5296 sme_config->csrConfig.phyMode = phymode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297#ifdef QCA_HT_2040_COEX
5298 if (phymode == eCSR_DOT11_MODE_11n &&
5299 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305300 sme_config->csrConfig.obssEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005301 halStatus = sme_set_ht2040_mode(hal,
Jeff Johnson1b780e42017-10-31 14:11:45 -07005302 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305304 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005305 hdd_err("Failed to disable OBSS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305306 retval = -EIO;
5307 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308 }
5309 } else if (phymode == eCSR_DOT11_MODE_11n &&
5310 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305311 sme_config->csrConfig.obssEnabled = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 halStatus = sme_set_ht2040_mode(hal,
Jeff Johnson1b780e42017-10-31 14:11:45 -07005313 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305315 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005316 hdd_err("Failed to enable OBSS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305317 retval = -EIO;
5318 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005319 }
5320 }
5321#endif
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305322 sme_config->csrConfig.eBand = curr_band;
5323 sme_config->csrConfig.bandCapability = curr_band;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005324 if (curr_band == BAND_2G)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305325 sme_config->csrConfig.Is11hSupportEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 else
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305327 sme_config->csrConfig.Is11hSupportEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328 phddctx->config->Is11hSupportEnabled;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005329 if (curr_band == BAND_2G)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305330 sme_config->csrConfig.channelBondingMode24GHz = chwidth;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005331 else if (curr_band == BAND_2G)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305332 sme_config->csrConfig.channelBondingMode5GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 else {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305334 sme_config->csrConfig.channelBondingMode24GHz = chwidth;
5335 sme_config->csrConfig.channelBondingMode5GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336 }
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305337 sme_config->csrConfig.nVhtChannelWidth = vhtchanwidth;
5338 sme_update_config(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005339
5340 phddctx->config->dot11Mode = hdd_dot11mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 phddctx->config->nChannelBondingMode24GHz =
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305342 sme_config->csrConfig.channelBondingMode24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343 phddctx->config->nChannelBondingMode5GHz =
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305344 sme_config->csrConfig.channelBondingMode5GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07005346 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005347 hdd_err("could not update config_dat");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305348 retval = -EIO;
5349 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005350 }
Rajeev Kumar Sirasanagandla4c9b6752017-07-25 20:35:20 +05305351
5352 if (band_5g) {
5353 struct ieee80211_supported_band *band;
5354
5355 band = phddctx->wiphy->bands[HDD_NL80211_BAND_5GHZ];
5356 if (phddctx->config->nChannelBondingMode5GHz)
5357 band->ht_cap.cap |=
5358 IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5359 else
5360 band->ht_cap.cap &=
5361 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5362 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005363
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005364 hdd_debug("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005365 phymode, chwidth, curr_band, vhtchanwidth);
5366 }
5367
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305368free:
5369 if (sme_config)
5370 qdf_mem_free(sme_config);
5371 return retval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005372}
5373
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005374struct temperature_priv {
5375 int temperature;
5376};
5377
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378/**
5379 * hdd_get_temperature_cb() - "Get Temperature" callback function
5380 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005381 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 *
5383 * This function is passed to sme_get_temperature() as the callback
5384 * function to be invoked when the temperature measurement is
5385 * available.
5386 *
5387 * Return: None
5388 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005389static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005391 struct hdd_request *request;
5392 struct temperature_priv *priv;
5393
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005395
5396 request = hdd_request_get(context);
5397 if (!request) {
5398 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 return;
5400 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005401
5402 priv = hdd_request_priv(request);
5403 priv->temperature = temperature;
5404 hdd_request_complete(request);
5405 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406 EXIT();
5407}
5408
5409/**
5410 * wlan_hdd_get_temperature() - get current device temperature
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005411 * @adapter: device upon which the request was made
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 * @temperature: pointer to where the temperature is to be returned
5413 *
5414 * Return: 0 if a temperature value (either current or cached) was
5415 * returned, otherwise a negative errno is returned.
5416 *
5417 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005418int wlan_hdd_get_temperature(struct hdd_adapter *adapter, int *temperature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305420 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005421 int ret;
5422 void *cookie;
5423 struct hdd_request *request;
5424 struct temperature_priv *priv;
5425 static const struct hdd_request_params params = {
5426 .priv_size = sizeof(*priv),
5427 .timeout_ms = WLAN_WAIT_TIME_STATS,
5428 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429
5430 ENTER();
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005431 if (NULL == adapter) {
5432 hdd_err("adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 return -EPERM;
5434 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005435
5436 request = hdd_request_alloc(&params);
5437 if (!request) {
5438 hdd_err("Request allocation failure");
5439 return -ENOMEM;
5440 }
5441 cookie = hdd_request_cookie(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005442 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005443 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305444 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005445 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005446 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005447 ret = hdd_request_wait_for_response(request);
5448 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005449 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005450 } else {
5451 /* update the adapter with the fresh results */
5452 priv = hdd_request_priv(request);
5453 if (priv->temperature)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005454 adapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455 }
5456 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08005457
5458 /*
5459 * either we never sent a request, we sent a request and
5460 * received a response or we sent a request and timed out.
5461 * regardless we are done with the request.
5462 */
5463 hdd_request_put(request);
5464
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005465 *temperature = adapter->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 EXIT();
5467 return 0;
5468}
5469
Jeff Johnson011c4502017-10-05 15:25:56 -07005470static int hdd_validate_pdev_reset(int value)
5471{
5472 if ((value < 1) || (value > 5)) {
5473 hdd_warn(" Invalid value %d: Use any one of the below values\n"
5474 " TX_FLUSH = 1\n"
5475 " WARM_RESET = 2\n"
5476 " COLD_RESET = 3\n"
5477 " WARM_RESET_RESTORE_CAL = 4\n"
5478 " COLD_RESET_RESTORE_CAL = 5", value);
5479
5480 return -EINVAL;
5481 }
5482
5483 return 0;
5484}
5485
5486static int hdd_handle_pdev_reset(struct hdd_adapter *adapter, int value)
5487{
5488 int ret;
5489
5490 hdd_debug("%d", value);
5491
5492 ret = hdd_validate_pdev_reset(value);
5493 if (ret)
5494 return ret;
5495
Jeff Johnson1b780e42017-10-31 14:11:45 -07005496 ret = wma_cli_set_command(adapter->session_id,
Jeff Johnson011c4502017-10-05 15:25:56 -07005497 WMI_PDEV_PARAM_PDEV_RESET,
5498 value, PDEV_CMD);
5499
5500 return ret;
5501}
5502
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503/**
5504 * iw_setint_getnone() - Generic "set integer" private ioctl handler
5505 * @dev: device upon which the ioctl was received
5506 * @info: ioctl request information
5507 * @wrqu: ioctl request data
5508 * @extra: ioctl extra data
5509 *
5510 * Return: 0 on success, non-zero on error
5511 */
5512static int __iw_setint_getnone(struct net_device *dev,
5513 struct iw_request_info *info,
5514 union iwreq_data *wrqu, char *extra)
5515{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005516 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5517 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005518 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005519 struct hdd_context *hdd_ctx;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305520 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 int *value = (int *)extra;
5522 int sub_cmd = value[0];
5523 int set_value = value[1];
5524 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305525 QDF_STATUS status;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08005526 void *soc = NULL;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08005527 struct cdp_pdev *pdev = NULL;
5528 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005529
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005530 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305531
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005532 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005533 ret = wlan_hdd_validate_context(hdd_ctx);
5534 if (0 != ret)
5535 return ret;
5536
Jeff Johnson441e1f72017-02-07 08:50:49 -08005537 ret = hdd_check_private_wext_control(hdd_ctx, info);
5538 if (0 != ret)
5539 return ret;
5540
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305541 sme_config = qdf_mem_malloc(sizeof(*sme_config));
5542 if (!sme_config) {
5543 hdd_err("failed to allocate memory for sme_config");
5544 return -ENOMEM;
5545 }
5546 qdf_mem_zero(sme_config, sizeof(*sme_config));
Jeff Johnson441e1f72017-02-07 08:50:49 -08005547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005548 switch (sub_cmd) {
5549 case WE_SET_11D_STATE:
5550 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305551 if (((ENABLE_11D == set_value)
5552 || (DISABLE_11D == set_value)) && hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305554 sme_get_config_param(hHal, sme_config);
5555 sme_config->csrConfig.Is11dSupportEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 (bool) set_value;
5557
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005558 hdd_debug("11D state=%d!!",
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305559 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560 Is11dSupportEnabled);
5561
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305562 sme_update_config(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005563 } else {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305564 ret = -EINVAL;
5565 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005566 }
5567 break;
5568 }
5569
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570 case WE_SET_POWER:
5571 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305572 if (!hHal)
5573 return -EINVAL;
5574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 switch (set_value) {
5576 case 1:
5577 /* Enable PowerSave */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005578 sme_ps_enable_disable(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005579 SME_PS_ENABLE);
5580 break;
5581 case 2:
5582 /* Disable PowerSave */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005583 sme_ps_enable_disable(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584 SME_PS_DISABLE);
5585 break;
5586 case 3: /* Enable UASPD */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005587 sme_ps_uapsd_enable(hHal, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 break;
5589 case 4: /* Disable UASPD */
Jeff Johnson1b780e42017-10-31 14:11:45 -07005590 sme_ps_uapsd_disable(hHal, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005591 break;
5592 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005593 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594 set_value);
5595 ret = -EINVAL;
5596 break;
5597 }
5598 break;
5599 }
5600
5601 case WE_SET_MAX_ASSOC:
5602 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305603 if (!hHal)
5604 return -EINVAL;
5605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
5607 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
5608 ret = -EINVAL;
5609 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
5610 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305611 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005612 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613 ret = -EIO;
5614 }
5615 break;
5616 }
5617
5618 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
5619 if (set_value == 0 || set_value == 1)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005620 (WLAN_HDD_GET_CTX(adapter))->config->force_sap_acs =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621 set_value;
5622 else
5623 ret = -EINVAL;
5624 break;
5625
5626 case WE_SET_DATA_INACTIVITY_TO:
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305627 if (!hHal)
5628 return -EINVAL;
5629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005630 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
5631 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005632 (sme_cfg_set_int((WLAN_HDD_GET_CTX(adapter))->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005633 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305634 set_value) == QDF_STATUS_E_FAILURE)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005635 hdd_err("WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636 ret = -EINVAL;
5637 }
5638 break;
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05305639 case WE_SET_WOW_DATA_INACTIVITY_TO:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305640 if (!hHal) {
5641 ret = -EINVAL;
5642 goto free;
5643 }
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05305644
5645 if ((set_value < CFG_WOW_DATA_INACTIVITY_TIMEOUT_MIN) ||
5646 (set_value > CFG_WOW_DATA_INACTIVITY_TIMEOUT_MAX) ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005647 (sme_cfg_set_int((WLAN_HDD_GET_CTX(adapter))->hHal,
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05305648 WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT,
5649 set_value) == QDF_STATUS_E_FAILURE)) {
5650 hdd_err("WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT fail");
5651 ret = -EINVAL;
5652 }
5653 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 case WE_SET_MC_RATE:
5655 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305656 if (!hHal)
5657 return -EINVAL;
5658
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005659 ret = wlan_hdd_set_mc_rate(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660 break;
5661 }
5662 case WE_SET_TX_POWER:
5663 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305664 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305666 if (!hHal)
5667 return -EINVAL;
5668
Jeff Johnsond377dce2017-10-04 10:32:42 -07005669 qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 if (sme_set_tx_power
Jeff Johnson1b780e42017-10-31 14:11:45 -07005671 (hHal, adapter->session_id, bssid,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005672 adapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305673 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005674 hdd_err("Setting tx power failed");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305675 ret = -EIO;
5676 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677 }
5678 break;
5679 }
5680 case WE_SET_MAX_TX_POWER:
5681 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305682 struct qdf_mac_addr bssid;
5683 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305685 if (!hHal)
5686 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005687
5688 hdd_debug("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005689 set_value);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005690 qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssId);
5691 qdf_copy_macaddr(&selfMac, &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692
5693 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305694 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005695 hdd_err("Setting maximum tx power failed");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305696 ret = -EIO;
5697 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005698 }
5699
5700 break;
5701 }
5702 case WE_SET_MAX_TX_POWER_2_4:
5703 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005704 hdd_debug("Setting maximum tx power %d dBm for 2.4 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07005705 set_value);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005706 if (sme_set_max_tx_power_per_band(BAND_2G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305707 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005708 hdd_err("Setting max tx power failed for 2.4 GHz band");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305709 ret = -EIO;
5710 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005711 }
5712
5713 break;
5714 }
5715 case WE_SET_MAX_TX_POWER_5_0:
5716 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005717 hdd_debug("Setting maximum tx power %d dBm for 5.0 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07005718 set_value);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005719 if (sme_set_max_tx_power_per_band(BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305720 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005721 hdd_err("Setting max tx power failed for 5.0 GHz band");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305722 ret = -EIO;
5723 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724 }
5725
5726 break;
5727 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005728
5729 case WE_SET_TM_LEVEL:
5730 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305731 if (!hHal)
5732 return -EINVAL;
5733
5734 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005735 (void)sme_set_thermal_level(hHal, set_value);
5736 break;
5737 }
5738
5739 case WE_SET_PHYMODE:
5740 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005741 struct hdd_context *phddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07005742
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305743 if (!hHal)
5744 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005745
5746 ret =
5747 wlan_hdd_update_phymode(dev, hHal, set_value,
5748 phddctx);
5749 break;
5750 }
5751
5752 case WE_SET_NSS:
5753 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305754 if (!hHal)
5755 return -EINVAL;
5756
5757 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005759 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005760 ret = -EINVAL;
5761 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305762 if (QDF_STATUS_SUCCESS !=
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -08005763 hdd_update_nss(adapter, set_value))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005764 ret = -EINVAL;
5765 }
5766 break;
5767 }
5768
5769 case WE_SET_GTX_HT_MCS:
5770 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005771 hdd_debug("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005772 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773 WMI_VDEV_PARAM_GTX_HT_MCS,
5774 set_value, GTX_CMD);
5775 break;
5776 }
5777
5778 case WE_SET_GTX_VHT_MCS:
5779 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005780 hdd_debug("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005782 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 WMI_VDEV_PARAM_GTX_VHT_MCS,
5784 set_value, GTX_CMD);
5785 break;
5786 }
5787
5788 case WE_SET_GTX_USRCFG:
5789 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005790 hdd_debug("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005792 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005793 WMI_VDEV_PARAM_GTX_USR_CFG,
5794 set_value, GTX_CMD);
5795 break;
5796 }
5797
5798 case WE_SET_GTX_THRE:
5799 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005800 hdd_debug("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005801 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 WMI_VDEV_PARAM_GTX_THRE,
5803 set_value, GTX_CMD);
5804 break;
5805 }
5806
5807 case WE_SET_GTX_MARGIN:
5808 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005809 hdd_debug("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005810 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811 WMI_VDEV_PARAM_GTX_MARGIN,
5812 set_value, GTX_CMD);
5813 break;
5814 }
5815
5816 case WE_SET_GTX_STEP:
5817 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005818 hdd_debug("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005819 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820 WMI_VDEV_PARAM_GTX_STEP,
5821 set_value, GTX_CMD);
5822 break;
5823 }
5824
5825 case WE_SET_GTX_MINTPC:
5826 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005827 hdd_debug("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005828 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005829 WMI_VDEV_PARAM_GTX_MINTPC,
5830 set_value, GTX_CMD);
5831 break;
5832 }
5833
5834 case WE_SET_GTX_BWMASK:
5835 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005836 hdd_debug("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005837 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005838 WMI_VDEV_PARAM_GTX_BW_MASK,
5839 set_value, GTX_CMD);
5840 break;
5841 }
5842
5843 case WE_SET_LDPC:
5844 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305845 if (!hHal)
5846 return -EINVAL;
5847
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005848 ret = hdd_set_ldpc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849 break;
5850 }
5851
5852 case WE_SET_TX_STBC:
5853 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305854 if (!hHal)
5855 return -EINVAL;
5856
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005857 ret = hdd_set_tx_stbc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 break;
5859 }
5860
5861 case WE_SET_RX_STBC:
5862 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305863 if (!hHal)
5864 return -EINVAL;
5865
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005866 ret = hdd_set_rx_stbc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 break;
5868 }
5869
5870 case WE_SET_SHORT_GI:
5871 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305872 if (!hHal)
5873 return -EINVAL;
5874
5875 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005876 ret = sme_update_ht_config(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005877 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
5878 set_value);
5879 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07005880 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005881 break;
5882 }
5883
5884 case WE_SET_RTSCTS:
5885 {
5886 uint32_t value;
5887
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305888 if (!hHal)
5889 return -EINVAL;
5890
5891 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005892 set_value);
5893
5894 if ((set_value & HDD_RTSCTS_EN_MASK) ==
5895 HDD_RTSCTS_ENABLE)
5896 value =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005897 (WLAN_HDD_GET_CTX(adapter))->config->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898 RTSThreshold;
5899 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
5900 || ((set_value & HDD_RTSCTS_EN_MASK) ==
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305901 HDD_CTS_ENABLE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305903 } else {
5904 ret = -EIO;
5905 goto free;
5906 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005907
Jeff Johnson1b780e42017-10-31 14:11:45 -07005908 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005909 WMI_VDEV_PARAM_ENABLE_RTSCTS,
5910 set_value, VDEV_CMD);
5911 if (!ret) {
5912 if (sme_cfg_set_int
5913 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305914 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005915 hdd_err("FAILED TO SET RTSCTS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305916 ret = -EIO;
5917 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005918 }
5919 }
5920
5921 break;
5922 }
5923
5924 case WE_SET_CHWIDTH:
5925 {
5926 bool chwidth = false;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005927 struct hdd_context *phddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07005928
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05305929 if (!hHal)
5930 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005931
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005932 /*updating channel bonding only on 5Ghz */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005933 hdd_debug("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005934 set_value);
5935 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005936 hdd_err("Invalid channel width 0->20 1->40 2->80");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305937 ret = -EINVAL;
5938 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939 }
5940
5941 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
5942 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
5943 nChannelBondingMode5GHz)))
5944 chwidth = true;
5945
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305946 sme_get_config_param(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005947 switch (set_value) {
5948 case eHT_CHANNEL_WIDTH_20MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305949 sme_config->csrConfig.channelBondingMode5GHz =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005950 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5951 break;
5952 case eHT_CHANNEL_WIDTH_40MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305953 if (chwidth) {
5954 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005955 channelBondingMode5GHz =
5956 phddctx->config->
5957 nChannelBondingMode5GHz;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305958 } else {
5959 ret = -EINVAL;
5960 goto free;
5961 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005962
5963 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964 case eHT_CHANNEL_WIDTH_80MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305965 if (chwidth) {
5966 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005967 channelBondingMode5GHz =
5968 phddctx->config->
5969 nChannelBondingMode5GHz;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305970 } else {
5971 ret = -EINVAL;
5972 goto free;
5973 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005974
5975 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005976
5977 default:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305978 ret = -EINVAL;
5979 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005980 }
5981
Jeff Johnson1b780e42017-10-31 14:11:45 -07005982 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983 WMI_VDEV_PARAM_CHWIDTH,
5984 set_value, VDEV_CMD);
5985 if (!ret)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05305986 sme_update_config(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005987
5988 break;
5989 }
5990
5991 case WE_SET_ANI_EN_DIS:
5992 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005993 hdd_debug("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07005995 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005996 WMI_PDEV_PARAM_ANI_ENABLE,
5997 set_value, PDEV_CMD);
5998 break;
5999 }
6000
6001 case WE_SET_ANI_POLL_PERIOD:
6002 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006003 hdd_debug("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006004 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006005 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006006 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
6007 set_value, PDEV_CMD);
6008 break;
6009 }
6010
6011 case WE_SET_ANI_LISTEN_PERIOD:
6012 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006013 hdd_debug("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006014 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006015 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
6017 set_value, PDEV_CMD);
6018 break;
6019 }
6020
6021 case WE_SET_ANI_OFDM_LEVEL:
6022 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006023 hdd_debug("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006024 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006025 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006026 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
6027 set_value, PDEV_CMD);
6028 break;
6029 }
6030
6031 case WE_SET_ANI_CCK_LEVEL:
6032 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006033 hdd_debug("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006034 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006035 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006036 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
6037 set_value, PDEV_CMD);
6038 break;
6039 }
6040
6041 case WE_SET_DYNAMIC_BW:
6042 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006043 hdd_debug("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006045 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 WMI_PDEV_PARAM_DYNAMIC_BW,
6047 set_value, PDEV_CMD);
6048 break;
6049 }
6050
6051 case WE_SET_CTS_CBW:
6052 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006053 hdd_debug("WE_SET_CTS_CBW val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006054 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055 WMI_PDEV_PARAM_CTS_CBW,
6056 set_value, PDEV_CMD);
6057 break;
6058 }
6059
6060 case WE_SET_11N_RATE:
6061 {
6062 uint8_t preamble = 0, nss = 0, rix = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006063
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006064 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006065 set_value);
6066
6067 if (set_value != 0xff) {
6068 rix = RC_2_RATE_IDX(set_value);
6069 if (set_value & 0x80) {
6070 preamble = WMI_RATE_PREAMBLE_HT;
6071 nss = HT_RC_2_STREAMS(set_value) - 1;
6072 } else {
6073 nss = 0;
6074 rix = RC_2_RATE_IDX(set_value);
6075 if (set_value & 0x10) {
6076 preamble =
6077 WMI_RATE_PREAMBLE_CCK;
6078 if (rix != 0x3)
6079 /* Enable Short
6080 * preamble always for
6081 * CCK except 1mbps
6082 */
6083 rix |= 0x4;
6084 } else {
6085 preamble =
6086 WMI_RATE_PREAMBLE_OFDM;
6087 }
6088 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006089 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006090 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006091 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 set_value, rix, preamble, nss);
6093
Jeff Johnson1b780e42017-10-31 14:11:45 -07006094 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006095 WMI_VDEV_PARAM_FIXED_RATE,
6096 set_value, VDEV_CMD);
6097 break;
6098 }
6099
6100 case WE_SET_VHT_RATE:
6101 {
6102 uint8_t preamble = 0, nss = 0, rix = 0;
6103
6104 if (set_value != 0xff) {
6105 rix = RC_2_RATE_IDX_11AC(set_value);
6106 preamble = WMI_RATE_PREAMBLE_VHT;
6107 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
6108
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006109 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006111 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006112 set_value, rix, preamble, nss);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006113 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006114 WMI_VDEV_PARAM_FIXED_RATE,
6115 set_value, VDEV_CMD);
6116 break;
6117 }
6118
6119 case WE_SET_AMPDU:
6120 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006121 hdd_debug("SET AMPDU val %d", 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 GEN_VDEV_PARAM_AMPDU,
6124 set_value, GEN_CMD);
6125 break;
6126 }
6127
6128 case WE_SET_AMSDU:
6129 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006130 hdd_debug("SET AMSDU 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 GEN_VDEV_PARAM_AMSDU,
6133 set_value, GEN_CMD);
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07006134 /* Update the stored ini value */
6135 if (!ret)
6136 hdd_ctx->config->max_amsdu_num = set_value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006137 break;
6138 }
6139
6140 case WE_SET_BURST_ENABLE:
6141 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006142 hdd_debug("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006143 if ((set_value == 0) || (set_value == 1)) {
Jeff Johnson1b780e42017-10-31 14:11:45 -07006144 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006145 WMI_PDEV_PARAM_BURST_ENABLE,
6146 set_value, PDEV_CMD);
6147 } else
6148 ret = -EINVAL;
6149 break;
6150 }
6151 case WE_SET_BURST_DUR:
6152 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006153 hdd_debug("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07006154 if ((set_value > 0) && (set_value <= 102400))
Jeff Johnson1b780e42017-10-31 14:11:45 -07006155 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006156 WMI_PDEV_PARAM_BURST_DUR,
6157 set_value, PDEV_CMD);
6158 else
6159 ret = -EINVAL;
6160 break;
6161 }
6162
6163 case WE_SET_TX_CHAINMASK:
6164 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006165 hdd_debug("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006166 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006167 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006168 WMI_PDEV_PARAM_TX_CHAIN_MASK,
6169 set_value, PDEV_CMD);
6170 break;
6171 }
6172
6173 case WE_SET_RX_CHAINMASK:
6174 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006175 hdd_debug("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006176 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006177 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006178 WMI_PDEV_PARAM_RX_CHAIN_MASK,
6179 set_value, PDEV_CMD);
6180 break;
6181 }
6182
6183 case WE_SET_TXPOW_2G:
6184 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006185 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006187 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006188 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
6189 set_value, PDEV_CMD);
6190 break;
6191 }
6192
6193 case WE_SET_TXPOW_5G:
6194 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006195 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006196 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006197 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
6199 set_value, PDEV_CMD);
6200 break;
6201 }
6202
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 /* Firmware debug log */
6204 case WE_DBGLOG_LOG_LEVEL:
6205 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006206 hdd_debug("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006207 hdd_ctx->fw_log_settings.dl_loglevel = 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 WMI_DBGLOG_LOG_LEVEL,
6210 set_value, DBG_CMD);
6211 break;
6212 }
6213
6214 case WE_DBGLOG_VAP_ENABLE:
6215 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006216 hdd_debug("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006217 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006218 WMI_DBGLOG_VAP_ENABLE,
6219 set_value, DBG_CMD);
6220 break;
6221 }
6222
6223 case WE_DBGLOG_VAP_DISABLE:
6224 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006225 hdd_debug("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006226 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006227 WMI_DBGLOG_VAP_DISABLE,
6228 set_value, DBG_CMD);
6229 break;
6230 }
6231
6232 case WE_DBGLOG_MODULE_ENABLE:
6233 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006234 hdd_debug("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006235 set_value);
6236 hdd_ctx->fw_log_settings.enable = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006237 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006238 WMI_DBGLOG_MODULE_ENABLE,
6239 set_value, DBG_CMD);
6240 break;
6241 }
6242
6243 case WE_DBGLOG_MODULE_DISABLE:
6244 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006245 hdd_debug("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006246 set_value);
6247 hdd_ctx->fw_log_settings.enable = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006248 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006249 WMI_DBGLOG_MODULE_DISABLE,
6250 set_value, DBG_CMD);
6251 break;
6252 }
6253 case WE_DBGLOG_MOD_LOG_LEVEL:
6254 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006255 hdd_debug("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006256 set_value);
6257
6258 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
6259 hdd_ctx->fw_log_settings.index = 0;
6260
6261 hdd_ctx->fw_log_settings.
6262 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
6263 set_value;
6264 hdd_ctx->fw_log_settings.index++;
6265
Jeff Johnson1b780e42017-10-31 14:11:45 -07006266 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006267 WMI_DBGLOG_MOD_LOG_LEVEL,
6268 set_value, DBG_CMD);
6269 break;
6270 }
6271
6272 case WE_DBGLOG_TYPE:
6273 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006274 hdd_debug("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006275 hdd_ctx->fw_log_settings.dl_type = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006276 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006277 WMI_DBGLOG_TYPE,
6278 set_value, DBG_CMD);
6279 break;
6280 }
6281 case WE_DBGLOG_REPORT_ENABLE:
6282 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006283 hdd_debug("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006284 set_value);
6285 hdd_ctx->fw_log_settings.dl_report = set_value;
Jeff Johnson1b780e42017-10-31 14:11:45 -07006286 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006287 WMI_DBGLOG_REPORT_ENABLE,
6288 set_value, DBG_CMD);
6289 break;
6290 }
6291
6292 case WE_SET_TXRX_FWSTATS:
6293 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006294 hdd_debug("WE_SET_TXRX_FWSTATS val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006295 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006296 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
6297 set_value, VDEV_CMD);
6298 break;
6299 }
6300
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006301 case WE_SET_TXRX_STATS:
6302 {
6303 hdd_notice("WE_SET_TXRX_STATS val %d", set_value);
6304 ret = cds_get_datapath_handles(&soc, &pdev, &vdev,
Jeff Johnson1b780e42017-10-31 14:11:45 -07006305 adapter->session_id);
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006306
Venkata Sharath Chandra Manchalabcdfdb12017-03-29 19:25:45 -07006307 if (ret != 0) {
6308 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
6309 "Invalid handles");
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006310 break;
Venkata Sharath Chandra Manchalabcdfdb12017-03-29 19:25:45 -07006311 }
6312 ret = cdp_txrx_stats(soc, vdev, set_value);
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08006313 break;
6314 }
6315
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006316 case WE_TXRX_FWSTATS_RESET:
6317 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006318 hdd_debug("WE_TXRX_FWSTATS_RESET val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006319 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006320 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
6321 set_value, VDEV_CMD);
6322 break;
6323 }
6324
6325 case WE_DUMP_STATS:
6326 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006327 hdd_debug("WE_DUMP_STATS val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006328 ret = hdd_wlan_dump_stats(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006329 break;
6330 }
6331
6332 case WE_CLEAR_STATS:
6333 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006334 hdd_debug("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006335 switch (set_value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006336 case CDP_HDD_STATS:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006337 memset(&adapter->stats, 0, sizeof(adapter->stats));
6338 memset(&adapter->hdd_stats, 0,
6339 sizeof(adapter->hdd_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006340 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006341 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006342 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
6343 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006344 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006345 wlan_hdd_clear_netif_queue_history(hdd_ctx);
6346 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07006347 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05306348 hdd_clear_hif_stats();
6349 break;
Yun Park1027e8c2017-10-13 15:17:37 -07006350 case CDP_NAPI_STATS:
6351 hdd_clear_napi_stats();
6352 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006353 default:
Leo Changfdb45c32016-10-28 11:09:23 -07006354 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
6355 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006356 }
6357 break;
6358 }
6359
6360 case WE_PPS_PAID_MATCH:
6361 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006362 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306363 ret = -EINVAL;
6364 goto free;
6365 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006366
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006367 hdd_debug("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006368 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006369 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006370 WMI_VDEV_PPS_PAID_MATCH,
6371 set_value, PPS_CMD);
6372 break;
6373 }
6374
6375 case WE_PPS_GID_MATCH:
6376 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006377 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306378 ret = -EINVAL;
6379 goto free;
6380 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006381 hdd_debug("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006382 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006383 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006384 WMI_VDEV_PPS_GID_MATCH,
6385 set_value, PPS_CMD);
6386 break;
6387 }
6388
6389 case WE_PPS_EARLY_TIM_CLEAR:
6390 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006391 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306392 ret = -EINVAL;
6393 goto free;
6394 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006395 hdd_debug(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006396 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006397 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006398 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
6399 set_value, PPS_CMD);
6400 break;
6401 }
6402
6403 case WE_PPS_EARLY_DTIM_CLEAR:
6404 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006405 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306406 ret = -EINVAL;
6407 goto free;
6408 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006409 hdd_debug("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006410 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006411 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006412 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
6413 set_value, PPS_CMD);
6414 break;
6415 }
6416
6417 case WE_PPS_EOF_PAD_DELIM:
6418 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006419 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306420 ret = -EINVAL;
6421 goto free;
6422 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006423 hdd_debug("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006424 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006425 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006426 WMI_VDEV_PPS_EOF_PAD_DELIM,
6427 set_value, PPS_CMD);
6428 break;
6429 }
6430
6431 case WE_PPS_MACADDR_MISMATCH:
6432 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006433 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306434 ret = -EINVAL;
6435 goto free;
6436 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006437 hdd_debug("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006438 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006439 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006440 WMI_VDEV_PPS_MACADDR_MISMATCH,
6441 set_value, PPS_CMD);
6442 break;
6443 }
6444
6445 case WE_PPS_DELIM_CRC_FAIL:
6446 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006447 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306448 ret = -EINVAL;
6449 goto free;
6450 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006451 hdd_debug("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006452 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006453 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006454 WMI_VDEV_PPS_DELIM_CRC_FAIL,
6455 set_value, PPS_CMD);
6456 break;
6457 }
6458
6459 case WE_PPS_GID_NSTS_ZERO:
6460 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006461 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306462 ret = -EINVAL;
6463 goto free;
6464 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006465 hdd_debug("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006466 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006467 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006468 WMI_VDEV_PPS_GID_NSTS_ZERO,
6469 set_value, PPS_CMD);
6470 break;
6471 }
6472
6473 case WE_PPS_RSSI_CHECK:
6474 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006475 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306476 ret = -EINVAL;
6477 goto free;
6478 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006479 hdd_debug("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006480 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006481 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006482 WMI_VDEV_PPS_RSSI_CHECK,
6483 set_value, PPS_CMD);
6484 break;
6485 }
6486
6487 case WE_PPS_5G_EBT:
6488 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006489 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306490 ret = -EINVAL;
6491 goto free;
6492 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006493
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006494 hdd_debug("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006495 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006496 WMI_VDEV_PPS_5G_EBT,
6497 set_value, PPS_CMD);
6498 break;
6499 }
6500
6501 case WE_SET_HTSMPS:
6502 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006503 hdd_debug("WE_SET_HTSMPS val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006504 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006505 WMI_STA_SMPS_FORCE_MODE_CMDID,
6506 set_value, VDEV_CMD);
6507 break;
6508 }
6509
6510 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
6511 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006512 hdd_debug("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006513 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006514 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006515 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
6516 set_value, QPOWER_CMD);
6517 break;
6518 }
6519
6520 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
6521 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006522 hdd_debug("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006523 set_value);
6524 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006525 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006526 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
6527 set_value, QPOWER_CMD);
6528 break;
6529 }
6530
6531 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
6532 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006533 hdd_debug("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006534 set_value);
6535 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006536 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006537 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
6538 set_value, QPOWER_CMD);
6539 break;
6540 }
6541
6542 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
6543 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006544 hdd_debug("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006545 set_value);
6546 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006547 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006548 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
6549 set_value, QPOWER_CMD);
6550 break;
6551 }
6552
6553 case WE_MCC_CONFIG_LATENCY:
6554 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006555 wlan_hdd_set_mcc_latency(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006556 break;
6557 }
6558
6559 case WE_MCC_CONFIG_QUOTA:
6560 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006561 hdd_debug("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006562 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006563 ret = wlan_hdd_set_mcc_p2p_quota(adapter,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08006564 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006565 break;
6566 }
6567 case WE_SET_DEBUG_LOG:
6568 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006569 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07006570
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05306571 if (!hHal)
6572 return -EINVAL;
6573
Nirav Shah1da77682016-05-03 20:16:39 +05306574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006575 hdd_ctx->config->gEnableDebugLog = set_value;
6576 sme_update_connect_debug(hdd_ctx->hHal, set_value);
6577 break;
6578 }
6579 case WE_SET_EARLY_RX_ADJUST_ENABLE:
6580 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006581 hdd_debug("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582 if ((set_value == 0) || (set_value == 1))
6583 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006584 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006585 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
6586 set_value, VDEV_CMD);
6587 else
6588 ret = -EINVAL;
6589 break;
6590 }
6591 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
6592 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006593 hdd_debug("SET early_rx bmiss val %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006594 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006595 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
6596 set_value, VDEV_CMD);
6597 break;
6598 }
6599 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
6600 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006601 hdd_debug("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006602 set_value);
6603 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006604 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006605 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
6606 set_value, VDEV_CMD);
6607 break;
6608 }
6609 case WE_SET_EARLY_RX_SLOP_STEP:
6610 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006611 hdd_debug("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006612 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006613 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006614 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
6615 set_value, VDEV_CMD);
6616 break;
6617 }
6618 case WE_SET_EARLY_RX_INIT_SLOP:
6619 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006620 hdd_debug("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006621 set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006622 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006623 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
6624 set_value, VDEV_CMD);
6625 break;
6626 }
6627 case WE_SET_EARLY_RX_ADJUST_PAUSE:
6628 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006629 hdd_debug("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006630 if ((set_value == 0) || (set_value == 1))
6631 ret = wma_cli_set_command(
Jeff Johnson1b780e42017-10-31 14:11:45 -07006632 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006633 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
6634 set_value, VDEV_CMD);
6635 else
6636 ret = -EINVAL;
6637 break;
6638 }
6639 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
6640 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006641 hdd_debug("SET early_rx drift sample %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006642 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006643 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
6644 set_value, VDEV_CMD);
6645 break;
6646 }
6647 case WE_SET_SCAN_DISABLE:
6648 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05306649 if (!hHal)
6650 return -EINVAL;
6651
6652 hdd_notice("SET SCAN DISABLE %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006653 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(adapter), set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006654 break;
6655 }
Govind Singha471e5e2015-10-12 17:11:14 +05306656 case WE_START_FW_PROFILE:
6657 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006658 hdd_debug("WE_START_FW_PROFILE %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006659 ret = wma_cli_set_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +05306660 WMI_WLAN_PROFILE_TRIGGER_CMDID,
6661 set_value, DBG_CMD);
6662 break;
6663 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306664 case WE_SET_CHANNEL:
6665 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006666 hdd_debug("Set Channel %d Session ID %d mode %d", set_value,
Jeff Johnson1b780e42017-10-31 14:11:45 -07006667 adapter->session_id, adapter->device_mode);
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05306668 if (!hHal)
6669 return -EINVAL;
6670
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306671
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006672 if ((QDF_STA_MODE == adapter->device_mode) ||
6673 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306674
6675 status = sme_ext_change_channel(hHal,
Jeff Johnson1b780e42017-10-31 14:11:45 -07006676 set_value, adapter->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306677 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006678 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306679 status);
6680 ret = -EINVAL;
6681 }
6682 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006683 hdd_err("change channel not supported for device mode %d",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006684 adapter->device_mode);
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306685 ret = -EINVAL;
6686 }
6687 break;
6688 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306689 case WE_SET_CONC_SYSTEM_PREF:
6690 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006691 hdd_debug("New preference: %d", set_value);
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306692 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
6693 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
6694 hdd_err("Invalid system preference %d", set_value);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306695 ret = -EINVAL;
6696 goto free;
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306697 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05306698
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05306699 /* hdd_ctx, hdd_ctx->config are already checked for null */
6700 hdd_ctx->config->conc_system_pref = set_value;
6701 break;
6702 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006703 case WE_SET_11AX_RATE:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006704 ret = hdd_set_11ax_rate(adapter, set_value, NULL);
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08006705 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07006706 case WE_SET_DCM:
6707 hdd_notice("Set WMI_VDEV_PARAM_HE_DCM: %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006708 ret = wma_cli_set_command(adapter->session_id,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07006709 WMI_VDEV_PARAM_HE_DCM, set_value,
6710 VDEV_CMD);
6711 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07006712 case WE_SET_RANGE_EXT:
6713 hdd_notice("Set WMI_VDEV_PARAM_HE_RANGE_EXT: %d", set_value);
Jeff Johnson1b780e42017-10-31 14:11:45 -07006714 ret = wma_cli_set_command(adapter->session_id,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07006715 WMI_VDEV_PARAM_HE_RANGE_EXT,
6716 set_value, VDEV_CMD);
6717 break;
Jeff Johnson011c4502017-10-05 15:25:56 -07006718 case WE_SET_PDEV_RESET:
6719 ret = hdd_handle_pdev_reset(adapter, set_value);
6720 break;
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05306721 case WE_SET_MODULATED_DTIM:
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05306722 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
6723 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
6724 hdd_err("Invalid gEnableModuleDTIM value %d",
6725 set_value);
6726 return -EINVAL;
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05306727 }
Jeff Johnsonc66d3102018-02-28 11:58:26 -08006728
6729 hdd_ctx->config->enableModulatedDTIM = set_value;
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05306730 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006731 default:
Rajeev Kumard0565362018-03-01 12:02:01 -08006732 hdd_debug("Invalid sub command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006733 ret = -EINVAL;
6734 break;
6735 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306736 EXIT();
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306737free:
6738 qdf_mem_free(sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006739 return ret;
6740}
6741
6742static int iw_setint_getnone(struct net_device *dev,
6743 struct iw_request_info *info,
6744 union iwreq_data *wrqu,
6745 char *extra)
6746{
6747 int ret;
6748
6749 cds_ssr_protect(__func__);
6750 ret = __iw_setint_getnone(dev, info, wrqu, extra);
6751 cds_ssr_unprotect(__func__);
6752
6753 return ret;
6754}
6755
6756/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006757 * __iw_setnone_get_threeint() - return three value to up layer.
6758 *
6759 * @dev: pointer of net_device of this wireless card
6760 * @info: meta data about Request sent
6761 * @wrqu: include request info
6762 * @extra: buf used for in/Output
6763 *
6764 * Return: execute result
6765 */
6766static int __iw_setnone_get_threeint(struct net_device *dev,
6767 struct iw_request_info *info,
6768 union iwreq_data *wrqu, char *extra)
6769{
6770 int ret = 0; /* success */
6771 uint32_t *value = (int *)extra;
Jeff Johnson3d278b02017-08-29 14:17:47 -07006772 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006773 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006774
6775 ENTER_DEV(dev);
6776 ret = wlan_hdd_validate_context(hdd_ctx);
6777 if (0 != ret)
6778 return ret;
6779
Jeff Johnson441e1f72017-02-07 08:50:49 -08006780 ret = hdd_check_private_wext_control(hdd_ctx, info);
6781 if (0 != ret)
6782 return ret;
6783
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006784 hdd_debug("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006785 switch (value[0]) {
6786 case WE_GET_TSF:
6787 ret = hdd_indicate_tsf(adapter, value, 3);
6788 break;
6789 default:
6790 hdd_err("Invalid IOCTL get_value command %d", value[0]);
6791 break;
6792 }
6793 return ret;
6794}
6795
6796/**
6797 * iw_setnone_get_threeint() - return three value to up layer.
6798 *
6799 * @dev: pointer of net_device of this wireless card
6800 * @info: meta data about Request sent
6801 * @wrqu: include request info
6802 * @extra: buf used for in/Output
6803 *
6804 * Return: execute result
6805 */
6806static int iw_setnone_get_threeint(struct net_device *dev,
6807 struct iw_request_info *info,
6808 union iwreq_data *wrqu, char *extra)
6809{
6810 int ret;
6811
6812 cds_ssr_protect(__func__);
6813 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
6814 cds_ssr_unprotect(__func__);
6815
6816 return ret;
6817}
6818
6819/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006820 * iw_setchar_getnone() - Generic "set string" private ioctl handler
6821 * @dev: device upon which the ioctl was received
6822 * @info: ioctl request information
6823 * @wrqu: ioctl request data
6824 * @extra: ioctl extra data
6825 *
6826 * Return: 0 on success, non-zero on error
6827 */
6828static int __iw_setchar_getnone(struct net_device *dev,
6829 struct iw_request_info *info,
6830 union iwreq_data *wrqu, char *extra)
6831{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306832 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006833 int sub_cmd;
6834 int ret;
6835 char *pBuffer = NULL;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006836 struct hdd_adapter *adapter = (netdev_priv(dev));
6837 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006838 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006839 struct iw_point s_priv_data;
6840
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006841 ENTER_DEV(dev);
6842
Mukul Sharma34777c62015-11-02 20:22:30 +05306843 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006844 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05306845 return -EPERM;
6846 }
6847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006848 ret = wlan_hdd_validate_context(hdd_ctx);
6849 if (0 != ret)
6850 return ret;
6851
Jeff Johnson441e1f72017-02-07 08:50:49 -08006852 ret = hdd_check_private_wext_control(hdd_ctx, info);
6853 if (0 != ret)
6854 return ret;
6855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006856 /* helper function to get iwreq_data with compat handling. */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006857 if (hdd_priv_get_data(&s_priv_data, wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006858 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006859
6860 /* make sure all params are correctly passed to function */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006861 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006862 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006863
6864 sub_cmd = s_priv_data.flags;
6865
6866 /* ODD number is used for set, copy data using copy_from_user */
6867 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
6868 s_priv_data.length);
6869 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006870 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006871 return -ENOMEM;
6872 }
6873
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006874 hdd_debug("Received length: %d data: %s",
6875 s_priv_data.length, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006876
6877 switch (sub_cmd) {
6878 case WE_WOWL_ADD_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006879 hdd_debug("ADD_PTRN");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006880 hdd_add_wowl_ptrn(adapter, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006881 break;
6882 case WE_WOWL_DEL_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006883 hdd_debug("DEL_PTRN");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006884 hdd_del_wowl_ptrn(adapter, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006885 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006886 case WE_NEIGHBOR_REPORT_REQUEST:
6887 {
6888 tRrmNeighborReq neighborReq;
6889 tRrmNeighborRspCallbackInfo callbackInfo;
6890
6891 if (pConfig->fRrmEnable) {
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306892 neighborReq.neighbor_report_offload = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006893 neighborReq.no_ssid =
6894 (s_priv_data.length - 1) ? false : true;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306895 hdd_debug("Neighbor Request ssid present %d",
6896 neighborReq.no_ssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006897 if (!neighborReq.no_ssid) {
6898 neighborReq.ssid.length =
6899 (s_priv_data.length - 1) >
6900 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306901 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006902 pBuffer,
6903 neighborReq.ssid.length);
6904 }
6905
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306906 /*
6907 * If 11k offload is supported by FW and enabled
6908 * in the ini, set the offload to true
6909 */
6910 if (hdd_ctx->config->is_11k_offload_supported &&
6911 (hdd_ctx->config->offload_11k_enable_bitmask &
6912 OFFLOAD_11K_BITMASK_NEIGHBOR_REPORT_REQUEST)) {
6913 hdd_debug("Neighbor report offloaded to FW");
6914 neighborReq.neighbor_report_offload = true;
6915 }
6916
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006917 callbackInfo.neighborRspCallback = NULL;
6918 callbackInfo.neighborRspCallbackContext = NULL;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05306919 callbackInfo.timeout = 5000; /* 5 seconds */
6920 sme_neighbor_report_request(
6921 WLAN_HDD_GET_HAL_CTX(adapter),
6922 adapter->session_id,
6923 &neighborReq,
6924 &callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006925 } else {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006926 hdd_err("Ignoring neighbor request as RRM not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006927 ret = -EINVAL;
6928 }
6929 }
6930 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006931 case WE_SET_AP_WPS_IE:
Wu Gao02bd75b2017-10-13 18:34:02 +08006932 hdd_debug("Received WE_SET_AP_WPS_IE, won't process");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006933 break;
6934 case WE_SET_CONFIG:
6935 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006936 if (QDF_STATUS_SUCCESS != vstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006937 ret = -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006938
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006939 break;
6940 default:
6941 {
Jeff Johnson99bac312016-06-28 10:38:18 -07006942 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006943 sub_cmd);
6944 ret = -EINVAL;
6945 break;
6946 }
6947 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07006948 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306949 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006950 return ret;
6951}
6952
6953static int iw_setchar_getnone(struct net_device *dev,
6954 struct iw_request_info *info,
6955 union iwreq_data *wrqu, char *extra)
6956{
6957 int ret;
6958
6959 cds_ssr_protect(__func__);
6960 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
6961 cds_ssr_unprotect(__func__);
6962
6963 return ret;
6964}
6965
6966/**
6967 * iw_setnone_getint() - Generic "get integer" private ioctl handler
6968 * @dev: device upon which the ioctl was received
6969 * @info: ioctl request information
6970 * @wrqu: ioctl request data
6971 * @extra: ioctl extra data
6972 *
6973 * Return: 0 on success, non-zero on error
6974 */
6975static int __iw_setnone_getint(struct net_device *dev,
6976 struct iw_request_info *info,
6977 union iwreq_data *wrqu, char *extra)
6978{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006979 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6980 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006981 int *value = (int *)extra;
6982 int ret;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05306983 tSmeConfigParams *sme_config;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006984 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006985
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006986 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306987
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006988 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006989 ret = wlan_hdd_validate_context(hdd_ctx);
6990 if (0 != ret)
6991 return ret;
6992
Jeff Johnson441e1f72017-02-07 08:50:49 -08006993 ret = hdd_check_private_wext_control(hdd_ctx, info);
6994 if (0 != ret)
6995 return ret;
6996
Rajeev Kumar1117fcf2018-02-15 16:25:19 -08006997 sme_config = qdf_mem_malloc(sizeof(*sme_config));
6998 if (!sme_config) {
6999 hdd_err("failed to allocate memory for sme_config");
7000 return -ENOMEM;
7001 }
7002
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007003 switch (value[0]) {
7004 case WE_GET_11D_STATE:
7005 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307006 sme_get_config_param(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007007
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307008 *value = sme_config->csrConfig.Is11dSupportEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007009
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007010 hdd_debug("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007011
7012 break;
7013 }
7014
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007015 case WE_GET_WLAN_DBG:
7016 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307017 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007018 *value = 0;
7019 break;
7020 }
7021 case WE_GET_MAX_ASSOC:
7022 {
7023 if (sme_cfg_get_int
7024 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307025 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007026 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007027 ret = -EIO;
7028 }
7029 break;
7030 }
7031 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
7032 *value = (WLAN_HDD_GET_CTX(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007033 adapter))->config->force_sap_acs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007034 break;
7035
7036 case WE_GET_CONCURRENCY_MODE:
7037 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08007038 *value = policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007039
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007040 hdd_debug("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007041 break;
7042 }
7043
7044 case WE_GET_NSS:
7045 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307046 sme_get_config_param(hHal, sme_config);
7047 *value = (sme_config->csrConfig.enable2x2 == 0) ? 1 : 2;
Srinivas Girigowda576b2352017-08-25 14:44:26 -07007048 if (policy_mgr_is_current_hwmode_dbs(hdd_ctx->hdd_psoc))
7049 *value = *value - 1;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007050 hdd_debug("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007051 break;
7052 }
7053
7054 case WE_GET_GTX_HT_MCS:
7055 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007056 hdd_debug("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007057 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007058 WMI_VDEV_PARAM_GTX_HT_MCS,
7059 GTX_CMD);
7060 break;
7061 }
7062
7063 case WE_GET_GTX_VHT_MCS:
7064 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007065 hdd_debug("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007066 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007067 WMI_VDEV_PARAM_GTX_VHT_MCS,
7068 GTX_CMD);
7069 break;
7070 }
7071
7072 case WE_GET_GTX_USRCFG:
7073 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007074 hdd_debug("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007075 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007076 WMI_VDEV_PARAM_GTX_USR_CFG,
7077 GTX_CMD);
7078 break;
7079 }
7080
7081 case WE_GET_GTX_THRE:
7082 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007083 hdd_debug("GET WMI_VDEV_PARAM_GTX_THRE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007084 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007085 WMI_VDEV_PARAM_GTX_THRE,
7086 GTX_CMD);
7087 break;
7088 }
7089
7090 case WE_GET_GTX_MARGIN:
7091 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007092 hdd_debug("GET WMI_VDEV_PARAM_GTX_MARGIN");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007093 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007094 WMI_VDEV_PARAM_GTX_MARGIN,
7095 GTX_CMD);
7096 break;
7097 }
7098
7099 case WE_GET_GTX_STEP:
7100 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007101 hdd_debug("GET WMI_VDEV_PARAM_GTX_STEP");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007102 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007103 WMI_VDEV_PARAM_GTX_STEP,
7104 GTX_CMD);
7105 break;
7106 }
7107
7108 case WE_GET_GTX_MINTPC:
7109 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007110 hdd_debug("GET WMI_VDEV_PARAM_GTX_MINTPC");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007111 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007112 WMI_VDEV_PARAM_GTX_MINTPC,
7113 GTX_CMD);
7114 break;
7115 }
7116
7117 case WE_GET_GTX_BWMASK:
7118 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007119 hdd_debug("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007120 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007121 WMI_VDEV_PARAM_GTX_BW_MASK,
7122 GTX_CMD);
7123 break;
7124 }
7125
7126 case WE_GET_LDPC:
7127 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007128 ret = hdd_get_ldpc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007129 break;
7130 }
7131
7132 case WE_GET_TX_STBC:
7133 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007134 ret = hdd_get_tx_stbc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007135 break;
7136 }
7137
7138 case WE_GET_RX_STBC:
7139 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007140 ret = hdd_get_rx_stbc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007141 break;
7142 }
7143
7144 case WE_GET_SHORT_GI:
7145 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007146 hdd_debug("GET WMI_VDEV_PARAM_SGI");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007147 *value = wma_cli_get_command(adapter->session_id,
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08007148 WMI_VDEV_PARAM_SGI,
7149 VDEV_CMD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007150 break;
7151 }
7152
7153 case WE_GET_RTSCTS:
7154 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007155 hdd_debug("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007156 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007157 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7158 VDEV_CMD);
7159 break;
7160 }
7161
7162 case WE_GET_CHWIDTH:
7163 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007164 hdd_debug("GET WMI_VDEV_PARAM_CHWIDTH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007165 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007166 WMI_VDEV_PARAM_CHWIDTH,
7167 VDEV_CMD);
7168 break;
7169 }
7170
7171 case WE_GET_ANI_EN_DIS:
7172 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007173 hdd_debug("GET WMI_PDEV_PARAM_ANI_ENABLE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007174 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007175 WMI_PDEV_PARAM_ANI_ENABLE,
7176 PDEV_CMD);
7177 break;
7178 }
7179
7180 case WE_GET_ANI_POLL_PERIOD:
7181 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007182 hdd_debug("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007183 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007184 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
7185 PDEV_CMD);
7186 break;
7187 }
7188
7189 case WE_GET_ANI_LISTEN_PERIOD:
7190 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007191 hdd_debug("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007192 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007193 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
7194 PDEV_CMD);
7195 break;
7196 }
7197
7198 case WE_GET_ANI_OFDM_LEVEL:
7199 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007200 hdd_debug("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007201 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007202 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
7203 PDEV_CMD);
7204 break;
7205 }
7206
7207 case WE_GET_ANI_CCK_LEVEL:
7208 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007209 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007210 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007211 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
7212 PDEV_CMD);
7213 break;
7214 }
7215
7216 case WE_GET_DYNAMIC_BW:
7217 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007218 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007219 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007220 WMI_PDEV_PARAM_DYNAMIC_BW,
7221 PDEV_CMD);
7222 break;
7223 }
7224
7225 case WE_GET_11N_RATE:
7226 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007227 hdd_debug("GET WMI_VDEV_PARAM_FIXED_RATE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007228 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007229 WMI_VDEV_PARAM_FIXED_RATE,
7230 VDEV_CMD);
7231 break;
7232 }
7233
7234 case WE_GET_AMPDU:
7235 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007236 hdd_debug("GET AMPDU");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007237 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007238 GEN_VDEV_PARAM_AMPDU,
7239 GEN_CMD);
7240 break;
7241 }
7242
7243 case WE_GET_AMSDU:
7244 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007245 hdd_debug("GET AMSDU");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007246 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007247 GEN_VDEV_PARAM_AMSDU,
7248 GEN_CMD);
7249 break;
7250 }
7251
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007252 case WE_GET_ROAM_SYNCH_DELAY:
7253 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007254 hdd_debug("GET ROAM SYNCH DELAY");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007255 *value = wma_cli_get_command(adapter->session_id,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07007256 GEN_VDEV_ROAM_SYNCH_DELAY,
7257 GEN_CMD);
7258 break;
7259 }
7260
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007261 case WE_GET_BURST_ENABLE:
7262 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007263 hdd_debug("GET Burst enable value");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007264 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007265 WMI_PDEV_PARAM_BURST_ENABLE,
7266 PDEV_CMD);
7267 break;
7268 }
7269 case WE_GET_BURST_DUR:
7270 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007271 hdd_debug("GET Burst Duration value");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007272 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007273 WMI_PDEV_PARAM_BURST_DUR,
7274 PDEV_CMD);
7275 break;
7276 }
7277
7278 case WE_GET_TX_CHAINMASK:
7279 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007280 hdd_debug("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007281 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007282 WMI_PDEV_PARAM_TX_CHAIN_MASK,
7283 PDEV_CMD);
7284 break;
7285 }
7286
7287 case WE_GET_RX_CHAINMASK:
7288 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007289 hdd_debug("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007290 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007291 WMI_PDEV_PARAM_RX_CHAIN_MASK,
7292 PDEV_CMD);
7293 break;
7294 }
7295
7296 case WE_GET_TXPOW_2G:
7297 {
7298 uint32_t txpow2g = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007299 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007300
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007301 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007302 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007303 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
7304 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307305 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007306 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7307 &txpow2g)) {
7308 return -EIO;
7309 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007310 hdd_debug("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007311 break;
7312 }
7313
7314 case WE_GET_TXPOW_5G:
7315 {
7316 uint32_t txpow5g = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007317 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007318
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007319 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007320 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007321 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
7322 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307323 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007324 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
7325 &txpow5g)) {
7326 return -EIO;
7327 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007328 hdd_debug("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007329 break;
7330 }
7331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007332 case WE_GET_PPS_PAID_MATCH:
7333 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007334 hdd_debug("GET WMI_VDEV_PPS_PAID_MATCH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007335 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007336 WMI_VDEV_PPS_PAID_MATCH,
7337 PPS_CMD);
7338 break;
7339 }
7340
7341 case WE_GET_PPS_GID_MATCH:
7342 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007343 hdd_debug("GET WMI_VDEV_PPS_GID_MATCH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007344 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007345 WMI_VDEV_PPS_GID_MATCH,
7346 PPS_CMD);
7347 break;
7348 }
7349
7350 case WE_GET_PPS_EARLY_TIM_CLEAR:
7351 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007352 hdd_debug("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007353 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007354 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
7355 PPS_CMD);
7356 break;
7357 }
7358
7359 case WE_GET_PPS_EARLY_DTIM_CLEAR:
7360 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007361 hdd_debug("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007362 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007363 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
7364 PPS_CMD);
7365 break;
7366 }
7367
7368 case WE_GET_PPS_EOF_PAD_DELIM:
7369 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007370 hdd_debug("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007371 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007372 WMI_VDEV_PPS_EOF_PAD_DELIM,
7373 PPS_CMD);
7374 break;
7375 }
7376
7377 case WE_GET_PPS_MACADDR_MISMATCH:
7378 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007379 hdd_debug("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007380 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007381 WMI_VDEV_PPS_MACADDR_MISMATCH,
7382 PPS_CMD);
7383 break;
7384 }
7385
7386 case WE_GET_PPS_DELIM_CRC_FAIL:
7387 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007388 hdd_debug("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007389 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007390 WMI_VDEV_PPS_DELIM_CRC_FAIL,
7391 PPS_CMD);
7392 break;
7393 }
7394
7395 case WE_GET_PPS_GID_NSTS_ZERO:
7396 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007397 hdd_debug("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007398 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007399 WMI_VDEV_PPS_GID_NSTS_ZERO,
7400 PPS_CMD);
7401 break;
7402 }
7403
7404 case WE_GET_PPS_RSSI_CHECK:
7405 {
7406
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007407 hdd_debug("GET WMI_VDEV_PPS_RSSI_CHECK");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007408 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007409 WMI_VDEV_PPS_RSSI_CHECK,
7410 PPS_CMD);
7411 break;
7412 }
7413
7414 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
7415 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007416 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007417 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007418 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
7419 QPOWER_CMD);
7420 break;
7421 }
7422
7423 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
7424 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007425 hdd_debug("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007426 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007427 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
7428 QPOWER_CMD);
7429 break;
7430 }
7431
7432 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
7433 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007434 hdd_debug("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007435 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007436 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
7437 QPOWER_CMD);
7438 break;
7439 }
7440
7441 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
7442 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007443 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007444 *value = wma_cli_get_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007445 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
7446 QPOWER_CMD);
7447 break;
7448 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07007449 case WE_CAP_TSF:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007450 ret = hdd_capture_tsf(adapter, (uint32_t *)value, 1);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07007451 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007452 case WE_GET_TEMPERATURE:
7453 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007454 hdd_debug("WE_GET_TEMPERATURE");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007455 ret = wlan_hdd_get_temperature(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007456 break;
7457 }
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07007458 case WE_GET_DCM:
7459 hdd_notice("GET WMI_VDEV_PARAM_HE_DCM");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007460 *value = wma_cli_get_command(adapter->session_id,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07007461 WMI_VDEV_PARAM_HE_DCM,
7462 VDEV_CMD);
7463 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07007464 case WE_GET_RANGE_EXT:
7465 hdd_notice("GET WMI_VDEV_PARAM_HE_RANGE_EXT");
Jeff Johnson1b780e42017-10-31 14:11:45 -07007466 *value = wma_cli_get_command(adapter->session_id,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07007467 WMI_VDEV_PARAM_HE_RANGE_EXT,
7468 VDEV_CMD);
7469 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007470 default:
7471 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007472 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007473 value[0]);
7474 break;
7475 }
7476 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307477 EXIT();
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307478 qdf_mem_free(sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007479 return ret;
7480}
7481
7482static int iw_setnone_getint(struct net_device *dev,
7483 struct iw_request_info *info,
7484 union iwreq_data *wrqu, char *extra)
7485{
7486 int ret;
7487
7488 cds_ssr_protect(__func__);
7489 ret = __iw_setnone_getint(dev, info, wrqu, extra);
7490 cds_ssr_unprotect(__func__);
7491
7492 return ret;
7493}
7494
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307495static int hdd_set_fwtest(int argc, int cmd, int value)
7496{
7497 struct set_fwtest_params *fw_test;
7498
7499 /* check for max number of arguments */
7500 if (argc > (WMA_MAX_NUM_ARGS) ||
7501 argc != HDD_FWTEST_PARAMS) {
7502 hdd_err("Too Many args %d", argc);
7503 return -EINVAL;
7504 }
7505 /*
7506 * check if number of arguments are 3 then, check
7507 * then set the default value for sounding interval.
7508 */
7509 if (HDD_FWTEST_PARAMS == argc) {
7510 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
7511 value = HDD_FWTEST_SU_DEFAULT_VALUE;
7512 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
7513 value = HDD_FWTEST_MU_DEFAULT_VALUE;
7514 }
7515 /* check sounding interval value should not exceed to max */
7516 if (value > HDD_FWTEST_MAX_VALUE) {
7517 hdd_err("Invalid arguments value should not exceed max: %d",
7518 value);
7519 return -EINVAL;
7520 }
7521 fw_test = qdf_mem_malloc(sizeof(*fw_test));
7522 if (NULL == fw_test) {
7523 hdd_err("qdf_mem_malloc failed for fw_test");
7524 return -ENOMEM;
7525 }
7526 fw_test->arg = cmd;
7527 fw_test->value = value;
7528 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
7529 qdf_mem_free(fw_test);
7530 hdd_err("Not able to post FW_TEST_CMD message to WMA");
7531 return -EINVAL;
7532 }
7533 return 0;
7534}
7535
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007536/**
7537 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
7538 * @dev: device upon which the ioctl was received
7539 * @info: ioctl request information
7540 * @wrqu: ioctl request data
7541 * @extra: ioctl extra data
7542 *
7543 * Return: 0 on success, non-zero on error
7544 */
7545static int __iw_set_three_ints_getnone(struct net_device *dev,
7546 struct iw_request_info *info,
7547 union iwreq_data *wrqu, char *extra)
7548{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007549 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007550 int *value = (int *)extra;
7551 int sub_cmd = value[0];
7552 int ret;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007553 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007554
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007555 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307556
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007557 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007558 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07007559 return -EPERM;
7560 }
7561
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007562 ret = wlan_hdd_validate_context(hdd_ctx);
7563 if (0 != ret)
7564 return ret;
7565
Jeff Johnson441e1f72017-02-07 08:50:49 -08007566 ret = hdd_check_private_wext_control(hdd_ctx, info);
7567 if (0 != ret)
7568 return ret;
7569
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007570 switch (sub_cmd) {
7571
7572 case WE_SET_WLAN_DBG:
Dustin Brown36e2e5c2017-05-16 15:41:37 -07007573 qdf_print_set_category_verbose(qdf_get_pidx(), value[1],
7574 value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007575 break;
7576 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307577 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007578 break;
7579
7580 /* value[3] the acs band is not required as start and end channels are
7581 * enough but this cmd is maintained under set three ints for historic
7582 * reasons.
7583 */
7584 case WE_SET_SAP_CHANNELS:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007585 if (wlan_hdd_validate_operation_channel(adapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307586 QDF_STATUS_SUCCESS ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007587 wlan_hdd_validate_operation_channel(adapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307588 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007589 ret = -EINVAL;
7590 } else {
7591 hdd_ctx->config->force_sap_acs_st_ch = value[1];
7592 hdd_ctx->config->force_sap_acs_end_ch = value[2];
7593 }
7594 break;
7595 case WE_SET_DUAL_MAC_SCAN_CONFIG:
7596 hdd_debug("Ioctl to set dual mac scan config");
Tushnim Bhattacharyya49ed8ab2017-05-26 18:20:10 -07007597 if (hdd_ctx->config->dual_mac_feature_disable ==
7598 DISABLE_DBS_CXN_AND_SCAN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007599 hdd_err("Dual mac feature is disabled from INI");
7600 return -EPERM;
7601 }
7602 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08007603 policy_mgr_set_dual_mac_scan_config(hdd_ctx->hdd_psoc,
7604 value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007605 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05307606 case WE_SET_FW_TEST:
7607 {
7608 ret = hdd_set_fwtest(value[1], value[2], value[3]);
7609 if (ret) {
7610 hdd_err("Not able to set fwtest %d", ret);
7611 return ret;
7612 }
7613 }
7614 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007615 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007616 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007617 break;
7618
7619 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307620 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007621 return ret;
7622}
7623
7624int iw_set_three_ints_getnone(struct net_device *dev,
7625 struct iw_request_info *info,
7626 union iwreq_data *wrqu, char *extra)
7627{
7628 int ret;
7629
7630 cds_ssr_protect(__func__);
7631 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
7632 cds_ssr_unprotect(__func__);
7633
7634 return ret;
7635}
7636
7637/**
7638 * hdd_connection_state_string() - Get connection state string
7639 * @connection_state: enum to be converted to a string
7640 *
7641 * Return: the string equivalent of @connection_state
7642 */
7643static const char *
7644hdd_connection_state_string(eConnectionState connection_state)
7645{
7646 switch (connection_state) {
7647 CASE_RETURN_STRING(eConnectionState_NotConnected);
7648 CASE_RETURN_STRING(eConnectionState_Connecting);
7649 CASE_RETURN_STRING(eConnectionState_Associated);
7650 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
7651 CASE_RETURN_STRING(eConnectionState_IbssConnected);
7652 CASE_RETURN_STRING(eConnectionState_Disconnecting);
7653 default:
7654 return "UNKNOWN";
7655 }
7656}
7657
Naveen Rawat910726a2017-03-06 11:42:51 -08007658#if defined(FEATURE_OEM_DATA_SUPPORT)
7659/**
7660 * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
7661 * wifi_pos api to get oem data caps
7662 * @dev: net device upon which the request was received
7663 * @info: ioctl request information
7664 * @wrqu: ioctl request data
7665 * @extra: ioctl data payload
7666 *
7667 * Return: 0 for success, negative errno value on failure
7668 */
7669static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
7670 struct iw_request_info *info,
7671 union iwreq_data *wrqu, char *extra)
7672{
7673 return iw_get_oem_data_cap(dev, info, wrqu, extra);
7674}
7675#elif defined(WIFI_POS_CONVERGED)
7676static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
7677 struct iw_request_info *info,
7678 union iwreq_data *wrqu, char *extra)
7679{
Jeff Johnson3d278b02017-08-29 14:17:47 -07007680 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007681 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Naveen Rawat910726a2017-03-06 11:42:51 -08007682
7683 return os_if_wifi_pos_populate_caps(hdd_ctx->hdd_psoc,
7684 (struct wifi_pos_driver_caps *)extra);
7685}
7686#else
7687static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
7688 struct iw_request_info *info,
7689 union iwreq_data *wrqu, char *extra)
7690{
7691 return -ENOTSUPP;
7692}
7693#endif
7694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007695/**
7696 * iw_get_char_setnone() - Generic "get string" private ioctl handler
7697 * @dev: device upon which the ioctl was received
7698 * @info: ioctl request information
7699 * @wrqu: ioctl request data
7700 * @extra: ioctl extra data
7701 *
7702 * Return: 0 on success, non-zero on error
7703 */
7704static int __iw_get_char_setnone(struct net_device *dev,
7705 struct iw_request_info *info,
7706 union iwreq_data *wrqu, char *extra)
7707{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007708 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007709 int sub_cmd = wrqu->data.flags;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007710 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007711 int ret;
7712#ifdef WLAN_FEATURE_11W
Jeff Johnson2a722002017-09-30 20:02:35 -07007713 struct hdd_wext_state *pWextState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007714#endif
7715
7716#ifdef WLAN_FEATURE_11W
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007717 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007718#endif
7719
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007720 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307721
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007722 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007723 ret = wlan_hdd_validate_context(hdd_ctx);
7724 if (0 != ret)
7725 return ret;
7726
Jeff Johnson441e1f72017-02-07 08:50:49 -08007727 ret = hdd_check_private_wext_control(hdd_ctx, info);
7728 if (0 != ret)
7729 return ret;
7730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007731 switch (sub_cmd) {
7732 case WE_WLAN_VERSION:
7733 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05307734 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007735 break;
7736 }
7737
7738 case WE_GET_STATS:
7739 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007740 hdd_wlan_get_stats(adapter, &(wrqu->data.length),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007741 extra, WE_MAX_STR_LEN);
7742 break;
7743 }
7744
Dustin Brownd9322482017-01-09 12:46:03 -08007745 case WE_GET_SUSPEND_RESUME_STATS:
7746 {
7747 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
7748 WE_MAX_STR_LEN);
7749 if (ret >= 0) {
7750 wrqu->data.length = ret;
7751 ret = 0;
7752 }
7753
7754 break;
7755 }
7756
Govind Singha471e5e2015-10-12 17:11:14 +05307757 case WE_LIST_FW_PROFILE:
7758 hdd_wlan_list_fw_profile(&(wrqu->data.length),
7759 extra, WE_MAX_STR_LEN);
7760 break;
7761
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007762 /* The case prints the current state of the HDD, SME, CSR, PE,
7763 * TL it can be extended for WDI Global State as well. And
7764 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
7765 * and P2P_GO have not been added as of now.
7766 */
7767 case WE_GET_STATES:
7768 {
7769 int buf = 0, len = 0;
7770 int adapter_num = 0;
7771 int count = 0, check = 1;
7772
7773 tHalHandle hHal = NULL;
7774 tpAniSirGlobal pMac = NULL;
Jeff Johnsond377dce2017-10-04 10:32:42 -07007775 struct hdd_station_ctx *sta_ctx = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007776
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007777 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson3d278b02017-08-29 14:17:47 -07007778 struct hdd_adapter *useAdapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007779
7780 /* Print wlan0 or p2p0 states based on the adapter_num
7781 * by using the correct adapter
7782 */
7783 while (adapter_num < 2) {
7784 if (WLAN_ADAPTER == adapter_num) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007785 useAdapter = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007786 buf =
7787 scnprintf(extra + len,
7788 WE_MAX_STR_LEN - len,
7789 "\n\n wlan0 States:-");
7790 len += buf;
7791 } else if (P2P_ADAPTER == adapter_num) {
7792 buf =
7793 scnprintf(extra + len,
7794 WE_MAX_STR_LEN - len,
7795 "\n\n p2p0 States:-");
7796 len += buf;
7797
Jeff Johnsonce2ee982017-09-03 09:27:35 -07007798 if (!hdd_ctx) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007799 buf =
7800 scnprintf(extra + len,
7801 WE_MAX_STR_LEN -
7802 len,
Jeff Johnsonce2ee982017-09-03 09:27:35 -07007803 "\n hdd_ctx is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007804 len += buf;
7805 break;
7806 }
7807
7808 /* Printing p2p0 states only in the
7809 * case when the device is configured
7810 * as a p2p_client
7811 */
7812 useAdapter =
Jeff Johnsonce2ee982017-09-03 09:27:35 -07007813 hdd_get_adapter(hdd_ctx,
Krunal Sonif07bb382016-03-10 13:02:11 -08007814 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007815 if (!useAdapter) {
7816 buf =
7817 scnprintf(extra + len,
7818 WE_MAX_STR_LEN -
7819 len,
7820 "\n Device not configured as P2P_CLIENT.");
7821 len += buf;
7822 break;
7823 }
7824 }
7825
7826 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
7827 if (!hHal) {
7828 buf =
7829 scnprintf(extra + len,
7830 WE_MAX_STR_LEN - len,
7831 "\n pMac is NULL");
7832 len += buf;
7833 break;
7834 }
7835 pMac = PMAC_STRUCT(hHal);
7836 if (!pMac) {
7837 buf =
7838 scnprintf(extra + len,
7839 WE_MAX_STR_LEN - len,
7840 "\n pMac is NULL");
7841 len += buf;
7842 break;
7843 }
Jeff Johnsond377dce2017-10-04 10:32:42 -07007844 sta_ctx =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007845 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
7846
7847
7848 buf =
7849 scnprintf(extra + len, WE_MAX_STR_LEN - len,
7850 "\n HDD Conn State - %s "
Srinivas Girigowdab9086af2017-10-14 14:41:13 -07007851 "\n\n SME State:"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007852 "\n Neighbour Roam State - %s"
7853 "\n CSR State - %s"
7854 "\n CSR Substate - %s",
7855 hdd_connection_state_string
Jeff Johnsond377dce2017-10-04 10:32:42 -07007856 (sta_ctx->conn_info.connState),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007857 mac_trace_get_neighbour_roam_state
7858 (sme_get_neighbor_roam_state
Jeff Johnson1b780e42017-10-31 14:11:45 -07007859 (hHal, useAdapter->session_id)),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007860 mac_trace_getcsr_roam_state
7861 (sme_get_current_roam_state
Jeff Johnson1b780e42017-10-31 14:11:45 -07007862 (hHal, useAdapter->session_id)),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007863 mac_trace_getcsr_roam_sub_state
7864 (sme_get_current_roam_sub_state
Jeff Johnson1b780e42017-10-31 14:11:45 -07007865 (hHal, useAdapter->session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007866 );
7867 len += buf;
7868 adapter_num++;
7869 }
7870
Mukul Sharma81661ae2015-10-30 20:26:02 +05307871 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007872 /* Printing Lim State starting with global lim states */
7873 buf =
7874 scnprintf(extra + len, WE_MAX_STR_LEN - len,
Srinivas Girigowdab9086af2017-10-14 14:41:13 -07007875 "\n\n LIM STATES:-"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007876 "\n Global Sme State - %s "
7877 "\n Global mlm State - %s " "\n",
7878 mac_trace_get_lim_sme_state
7879 (sme_get_lim_sme_state(hHal)),
7880 mac_trace_get_lim_mlm_state
7881 (sme_get_lim_sme_state(hHal))
7882 );
7883 len += buf;
7884
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007885 while (check < 3 && count < 255) {
7886 if (sme_is_lim_session_valid(hHal, count)) {
7887 buf =
7888 scnprintf(extra + len,
7889 WE_MAX_STR_LEN -
7890 len,
7891 "\n Lim Valid Session %d:-"
7892 "\n PE Sme State - %s "
7893 "\n PE Mlm State - %s "
7894 "\n", check,
7895 mac_trace_get_lim_sme_state
7896 (sme_get_lim_sme_session_state
7897 (hHal, count)),
7898 mac_trace_get_lim_mlm_state
7899 (sme_get_lim_mlm_session_state
7900 (hHal, count))
7901 );
7902
7903 len += buf;
7904 check++;
7905 }
7906 count++;
7907 }
7908 }
7909
7910 wrqu->data.length = strlen(extra) + 1;
7911 break;
7912 }
7913
7914 case WE_GET_CFG:
7915 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007916 hdd_debug("Printing CLD global INI Config");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007917 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007918 extra,
7919 QCSAP_IOCTL_MAX_STR_LEN);
7920 wrqu->data.length = strlen(extra) + 1;
7921 break;
7922 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007923 case WE_GET_RSSI:
7924 {
7925 int8_t s7Rssi = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007926
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007927 wlan_hdd_get_rssi(adapter, &s7Rssi);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007928 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
7929 wrqu->data.length = strlen(extra) + 1;
7930 break;
7931 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007932
7933 case WE_GET_WMM_STATUS:
7934 {
7935 snprintf(extra, WE_MAX_STR_LEN,
7936 "\nDir: 0=up, 1=down, 3=both\n"
7937 "|------------------------|\n"
7938 "|AC | ACM |Admitted| Dir |\n"
7939 "|------------------------|\n"
7940 "|VO | %d | %3s | %d |\n"
7941 "|VI | %d | %3s | %d |\n"
7942 "|BE | %d | %3s | %d |\n"
7943 "|BK | %d | %3s | %d |\n"
7944 "|------------------------|\n",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007945 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007946 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007947 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007948 wmmAcStatus[SME_AC_VO].
7949 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007950 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007951 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
7952 ts_info.direction,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007953 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007954 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007955 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956 wmmAcStatus[SME_AC_VI].
7957 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007958 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007959 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
7960 ts_info.direction,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007961 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007962 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007963 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007964 wmmAcStatus[SME_AC_BE].
7965 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007966 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007967 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
7968 ts_info.direction,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007969 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007970 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007971 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007972 wmmAcStatus[SME_AC_BK].
7973 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnson02d14ce2017-10-31 09:08:30 -07007974 adapter->hdd_wmm_status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007975 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
7976 ts_info.direction);
7977
7978 wrqu->data.length = strlen(extra) + 1;
7979 break;
7980 }
7981 case WE_GET_CHANNEL_LIST:
7982 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307983 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007984 uint8_t i, len;
7985 char *buf;
7986 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
7987 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007988 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007989
Srinivas Girigowdac231df62017-03-24 18:27:57 -07007990 struct channel_list_info channel_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007991
7992 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05307993 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007994 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307995 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007996 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007997 return -EINVAL;
7998 }
7999 buf = extra;
8000 /*
8001 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
8002 * Maximum buffer needed = 5 * number of channels.
8003 * Check ifsufficient buffer is available and then
8004 * proceed to fill the buffer.
8005 */
8006 if (WE_MAX_STR_LEN <
8007 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008008 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008009 return -EINVAL;
8010 }
8011 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
8012 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308013 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008014 ubuf, &ubuf_len)) {
8015 /* Printing Country code in getChannelList */
8016 for (i = 0; i < (ubuf_len - 1); i++)
8017 len += scnprintf(buf + len,
8018 WE_MAX_STR_LEN - len,
8019 "%c", ubuf[i]);
8020 }
8021 for (i = 0; i < channel_list.num_channels; i++) {
8022 len +=
8023 scnprintf(buf + len, WE_MAX_STR_LEN - len,
8024 " %u", channel_list.channels[i]);
8025 }
8026 wrqu->data.length = strlen(extra) + 1;
8027
8028 break;
8029 }
8030#ifdef FEATURE_WLAN_TDLS
8031 case WE_GET_TDLS_PEERS:
8032 {
8033 wrqu->data.length =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008034 wlan_hdd_tdls_get_all_peers(adapter, extra,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008035 WE_MAX_STR_LEN) + 1;
8036 break;
8037 }
8038#endif
8039#ifdef WLAN_FEATURE_11W
8040 case WE_GET_11W_INFO:
8041 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008042 hdd_debug("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008043 pWextState->roamProfile.MFPEnabled);
8044
8045 snprintf(extra, WE_MAX_STR_LEN,
8046 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
8047 "\n Number of Unprotected Disassocs %d"
8048 "\n Number of Unprotected Deauths %d",
8049 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
8050 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
8051 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
8052 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
8053 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
8054 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
8055 pWextState->roamProfile.MFPEnabled,
Jeff Johnsondc179f42017-10-21 11:27:26 -07008056 adapter->hdd_stats.hdd_pmf_stats.
8057 num_unprot_disassoc_rx,
8058 adapter->hdd_stats.hdd_pmf_stats.
8059 num_unprot_deauth_rx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008060
8061 wrqu->data.length = strlen(extra) + 1;
8062 break;
8063 }
8064#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008065 case WE_GET_IBSS_STA_INFO:
8066 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07008067 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008068 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008069 int idx = 0;
8070 int length = 0, buf = 0;
8071
Naveen Rawatc45d1622016-07-05 12:20:09 -07008072 for (idx = 0; idx < MAX_PEERS; idx++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07008073 if (HDD_WLAN_INVALID_STA_ID !=
Jeff Johnsond377dce2017-10-04 10:32:42 -07008074 sta_ctx->conn_info.staId[idx]) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008075 buf = snprintf
8076 ((extra + length),
8077 WE_MAX_STR_LEN - length,
8078 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Jeff Johnsond377dce2017-10-04 10:32:42 -07008079 sta_ctx->conn_info.staId[idx],
8080 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008081 peerMacAddress[idx].bytes[0],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008082 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008083 peerMacAddress[idx].bytes[1],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008084 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008085 peerMacAddress[idx].bytes[2],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008086 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008087 peerMacAddress[idx].bytes[3],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008088 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008089 peerMacAddress[idx].bytes[4],
Jeff Johnsond377dce2017-10-04 10:32:42 -07008090 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008091 peerMacAddress[idx].bytes[5]
8092 );
8093 length += buf;
8094 }
8095 }
8096 wrqu->data.length = strlen(extra) + 1;
8097 break;
8098 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008099 case WE_GET_PHYMODE:
8100 {
8101 bool ch_bond24 = false, ch_bond5g = false;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008102 struct hdd_context *hddctx = WLAN_HDD_GET_CTX(adapter);
8103 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008104 eCsrPhyMode phymode;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008105 enum band_info currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008106 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008107
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008108 sme_config = qdf_mem_malloc(sizeof(*sme_config));
8109 if (!sme_config) {
8110 hdd_err("Out of memory");
8111 ret = -ENOMEM;
8112 break;
8113 }
8114
8115 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008116 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008117 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008118 ch_bond24 = true;
8119
8120 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008121 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008122 ch_bond5g = true;
8123
Dustin Browne9c6b3a2017-01-23 17:17:32 -08008124 qdf_mem_free(sme_config);
8125
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008126 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308127 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008128 sme_get_freq_band(hal, &currBand))) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008129 hdd_err("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008130 return -EIO;
8131 }
8132
8133 switch (phymode) {
8134 case eCSR_DOT11_MODE_AUTO:
8135 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
8136 break;
8137 case eCSR_DOT11_MODE_11n:
8138 case eCSR_DOT11_MODE_11n_ONLY:
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008139 if (currBand == BAND_2G) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008140 if (ch_bond24)
8141 snprintf(extra, WE_MAX_STR_LEN,
8142 "11NGHT40");
8143 else
8144 snprintf(extra, WE_MAX_STR_LEN,
8145 "11NGHT20");
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08008146 } else if (currBand == BAND_5G) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008147 if (ch_bond5g)
8148 snprintf(extra, WE_MAX_STR_LEN,
8149 "11NAHT40");
8150 else
8151 snprintf(extra, WE_MAX_STR_LEN,
8152 "11NAHT20");
8153 } else {
8154 snprintf(extra, WE_MAX_STR_LEN, "11N");
8155 }
8156 break;
8157 case eCSR_DOT11_MODE_abg:
8158 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
8159 break;
8160 case eCSR_DOT11_MODE_11a:
8161 snprintf(extra, WE_MAX_STR_LEN, "11A");
8162 break;
8163 case eCSR_DOT11_MODE_11b:
8164 case eCSR_DOT11_MODE_11b_ONLY:
8165 snprintf(extra, WE_MAX_STR_LEN, "11B");
8166 break;
8167 case eCSR_DOT11_MODE_11g:
8168 case eCSR_DOT11_MODE_11g_ONLY:
8169 snprintf(extra, WE_MAX_STR_LEN, "11G");
8170 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008171 case eCSR_DOT11_MODE_11ac:
8172 case eCSR_DOT11_MODE_11ac_ONLY:
8173 if (hddctx->config->vhtChannelWidth ==
8174 eHT_CHANNEL_WIDTH_20MHZ)
8175 snprintf(extra, WE_MAX_STR_LEN,
8176 "11ACVHT20");
8177 else if (hddctx->config->vhtChannelWidth ==
8178 eHT_CHANNEL_WIDTH_40MHZ)
8179 snprintf(extra, WE_MAX_STR_LEN,
8180 "11ACVHT40");
8181 else if (hddctx->config->vhtChannelWidth ==
8182 eHT_CHANNEL_WIDTH_80MHZ)
8183 snprintf(extra, WE_MAX_STR_LEN,
8184 "11ACVHT80");
8185 else if (hddctx->config->vhtChannelWidth ==
8186 eHT_CHANNEL_WIDTH_160MHZ)
8187 snprintf(extra, WE_MAX_STR_LEN,
8188 "11ACVHT160");
8189 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08008190 case eCSR_DOT11_MODE_11ax:
8191 case eCSR_DOT11_MODE_11ax_ONLY:
8192 /* currently using vhtChannelWidth */
8193 if (hddctx->config->vhtChannelWidth ==
8194 eHT_CHANNEL_WIDTH_20MHZ)
8195 snprintf(extra, WE_MAX_STR_LEN,
8196 "11AX_HE_20");
8197 else if (hddctx->config->vhtChannelWidth ==
8198 eHT_CHANNEL_WIDTH_40MHZ)
8199 snprintf(extra, WE_MAX_STR_LEN,
8200 "11AX_HE_40");
8201 else if (hddctx->config->vhtChannelWidth ==
8202 eHT_CHANNEL_WIDTH_80MHZ)
8203 snprintf(extra, WE_MAX_STR_LEN,
8204 "11AX_HE_80");
8205 else if (hddctx->config->vhtChannelWidth ==
8206 eHT_CHANNEL_WIDTH_160MHZ)
8207 snprintf(extra, WE_MAX_STR_LEN,
8208 "11AX_HE_160");
8209 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008210 }
8211
8212 wrqu->data.length = strlen(extra) + 1;
8213 break;
8214 }
8215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008216 case WE_GET_OEM_DATA_CAP:
Naveen Rawat910726a2017-03-06 11:42:51 -08008217 return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008218 case WE_GET_SNR:
8219 {
8220 int8_t s7snr = 0;
8221 int status = 0;
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008222 struct hdd_context *hdd_ctx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07008223 struct hdd_station_ctx *sta_ctx;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008224
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008225 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008226 status = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308227 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008228 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05308229
Jeff Johnsond377dce2017-10-04 10:32:42 -07008230 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008231 if (0 == hdd_ctx->config->fEnableSNRMonitoring ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008232 eConnectionState_Associated !=
Jeff Johnsond377dce2017-10-04 10:32:42 -07008233 sta_ctx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008234 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Jeff Johnsonce2ee982017-09-03 09:27:35 -07008235 hdd_ctx->config->fEnableSNRMonitoring,
Jeff Johnsond377dce2017-10-04 10:32:42 -07008236 sta_ctx->conn_info.connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008237 return -ENONET;
8238 }
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008239 wlan_hdd_get_snr(adapter, &s7snr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008240 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
8241 wrqu->data.length = strlen(extra) + 1;
8242 break;
8243 }
8244 default:
8245 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008246 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008247 sub_cmd);
8248 break;
8249 }
8250 }
Dustin Brownd9322482017-01-09 12:46:03 -08008251
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308252 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -08008253 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008254}
8255
8256static int iw_get_char_setnone(struct net_device *dev,
8257 struct iw_request_info *info,
8258 union iwreq_data *wrqu, char *extra)
8259{
8260 int ret;
8261
8262 cds_ssr_protect(__func__);
8263 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
8264 cds_ssr_unprotect(__func__);
8265
8266 return ret;
8267}
8268
8269/**
8270 * iw_setnone_getnone() - Generic "action" private ioctl handler
8271 * @dev: device upon which the ioctl was received
8272 * @info: ioctl request information
8273 * @wrqu: ioctl request data
8274 * @extra: ioctl extra data
8275 *
8276 * Return: 0 on success, non-zero on error
8277 */
8278static int __iw_setnone_getnone(struct net_device *dev,
8279 struct iw_request_info *info,
8280 union iwreq_data *wrqu, char *extra)
8281{
Jeff Johnson3d278b02017-08-29 14:17:47 -07008282 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008283 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008284 int ret;
8285 int sub_cmd;
8286
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008287 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308288
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008289 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008290 ret = wlan_hdd_validate_context(hdd_ctx);
8291 if (0 != ret)
8292 return ret;
8293
Jeff Johnson441e1f72017-02-07 08:50:49 -08008294 ret = hdd_check_private_wext_control(hdd_ctx, info);
8295 if (0 != ret)
8296 return ret;
8297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008298#ifdef CONFIG_COMPAT
8299 /* this ioctl is a special case where a sub-ioctl is used and both
8300 * the number of get and set args is 0. in this specific case the
8301 * logic in iwpriv places the sub_cmd in the data.flags portion of
8302 * the iwreq. unfortunately the location of this field will be
8303 * different between 32-bit and 64-bit userspace, and the standard
8304 * compat support in the kernel does not handle this case. so we
8305 * need to explicitly handle it here.
8306 */
8307 if (is_compat_task()) {
8308 struct compat_iw_point *compat_iw_point =
8309 (struct compat_iw_point *)&wrqu->data;
8310 sub_cmd = compat_iw_point->flags;
8311 } else {
8312 sub_cmd = wrqu->data.flags;
8313 }
8314#else
8315 sub_cmd = wrqu->data.flags;
8316#endif
8317
8318 switch (sub_cmd) {
8319 case WE_GET_RECOVERY_STAT:
8320 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008321 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008323 sme_get_recovery_stats(hal);
8324 break;
8325 }
8326
Govind Singha471e5e2015-10-12 17:11:14 +05308327 case WE_GET_FW_PROFILE_DATA:
Jeff Johnson1b780e42017-10-31 14:11:45 -07008328 ret = wma_cli_set_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +05308329 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
8330 0, DBG_CMD);
8331 break;
8332
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008333 case WE_IBSS_GET_PEER_INFO_ALL:
8334 {
8335 hdd_wlan_get_ibss_peer_info_all(adapter);
8336 break;
8337 }
8338
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008339 case WE_SET_REASSOC_TRIGGER:
8340 {
Jeff Johnson3d278b02017-08-29 14:17:47 -07008341 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008342
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008343 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308344 tSirMacAddr bssid;
Krunal Sonibfd05492017-10-03 15:48:37 -07008345 uint32_t roamId = INVALID_ROAM_ID;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308346 uint8_t operating_ch =
Jeff Johnsonb9424862017-10-30 08:49:35 -07008347 adapter->session.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008348 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008349
Jeff Johnson1b780e42017-10-31 14:11:45 -07008350 sme_get_modify_profile_fields(hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008351 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308352 if (roaming_offload_enabled(hdd_ctx)) {
8353 qdf_mem_copy(bssid,
Jeff Johnsonb9424862017-10-30 08:49:35 -07008354 &adapter->session.station.conn_info.bssId,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308355 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -08008356 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308357 bssid, operating_ch);
8358 } else {
Jeff Johnson1b780e42017-10-31 14:11:45 -07008359 sme_roam_reassoc(hdd_ctx->hHal, adapter->session_id,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05308360 NULL, modProfileFields, &roamId, 1);
8361 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008362 return 0;
8363 }
8364
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008365 case WE_STOP_OBSS_SCAN:
8366 {
8367 /*
8368 * 1.OBSS Scan is mandatory while operating in 2.4GHz
8369 * 2.OBSS scan is stopped by Firmware during the disassociation
8370 * 3.OBSS stop comamnd is added for debugging purpose
8371 */
8372 tHalHandle hal;
8373
8374 hal = WLAN_HDD_GET_HAL_CTX(adapter);
8375 if (hal == NULL) {
8376 hdd_err("hal context is NULL");
8377 return -EINVAL;
8378 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07008379 sme_ht40_stop_obss_scan(hal, adapter->session_id);
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08008380 }
8381 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008382 default:
8383 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008384 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008385 break;
8386 }
8387 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308388 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008389 return ret;
8390}
8391
8392static int iw_setnone_getnone(struct net_device *dev,
8393 struct iw_request_info *info,
8394 union iwreq_data *wrqu, char *extra)
8395{
8396 int ret;
8397
8398 cds_ssr_protect(__func__);
8399 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
8400 cds_ssr_unprotect(__func__);
8401
8402 return ret;
8403}
8404
Krunal Sonia6e505b2017-01-12 12:25:18 -08008405#ifdef MPC_UT_FRAMEWORK
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008406static int iw_get_policy_manager_ut_ops(struct hdd_context *hdd_ctx,
Jeff Johnson3d278b02017-08-29 14:17:47 -07008407 struct hdd_adapter *adapter, int sub_cmd, int *apps_args)
Krunal Sonia6e505b2017-01-12 12:25:18 -08008408{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -08008409 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08008410 case WE_POLICY_MANAGER_CLIST_CMD:
8411 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008412 hdd_debug("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008413 policy_mgr_incr_connection_count_utfw(hdd_ctx->hdd_psoc,
8414 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
8415 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008416 }
8417 break;
8418
8419 case WE_POLICY_MANAGER_DLIST_CMD:
8420 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008421 hdd_debug("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008422 policy_mgr_decr_connection_count_utfw(hdd_ctx->hdd_psoc,
8423 apps_args[0], apps_args[1]);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008424 }
8425 break;
8426
8427 case WE_POLICY_MANAGER_ULIST_CMD:
8428 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008429 hdd_debug("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008430 policy_mgr_update_connection_info_utfw(hdd_ctx->hdd_psoc,
8431 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
8432 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008433 }
8434 break;
8435
8436 case WE_POLICY_MANAGER_DBS_CMD:
8437 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008438 hdd_debug("<iwpriv wlan0 pm_dbs> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -08008439 if (apps_args[0] == 0)
8440 wma_set_dbs_capability_ut(0);
8441 else
8442 wma_set_dbs_capability_ut(1);
8443
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008444 if (apps_args[1] >= PM_THROUGHPUT &&
8445 apps_args[1] <= PM_LATENCY) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08008446 pr_info("setting system pref to [%d]\n", apps_args[1]);
8447 hdd_ctx->config->conc_system_pref = apps_args[1];
8448 }
8449 }
8450 break;
8451
8452 case WE_POLICY_MANAGER_PCL_CMD:
8453 {
8454 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
8455 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
8456 uint32_t pcl_len = 0, i = 0;
8457
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07008458 hdd_debug("<iwpriv wlan0 pm_pcl> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -08008459
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008460 policy_mgr_get_pcl(hdd_ctx->hdd_psoc, apps_args[0],
Krunal Sonia6e505b2017-01-12 12:25:18 -08008461 pcl, &pcl_len,
8462 weight_list, QDF_ARRAY_SIZE(weight_list));
8463 pr_info("PCL list for role[%d] is {", apps_args[0]);
8464 for (i = 0 ; i < pcl_len; i++)
8465 pr_info(" %d, ", pcl[i]);
8466 pr_info("}--------->\n");
8467 }
8468 break;
8469
8470 case WE_POLICY_SET_HW_MODE_CMD:
8471 {
8472 if (apps_args[0] == 0) {
8473 hdd_err("set hw mode for single mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008474 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07008475 adapter->session_id,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008476 HW_MODE_SS_2x2,
8477 HW_MODE_80_MHZ,
8478 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
8479 HW_MODE_DBS_NONE,
8480 HW_MODE_AGILE_DFS_NONE,
8481 HW_MODE_SBS_NONE,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08008482 SIR_UPDATE_REASON_UT, PM_NOP);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008483 } else if (apps_args[0] == 1) {
8484 hdd_err("set hw mode for dual mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008485 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07008486 adapter->session_id,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008487 HW_MODE_SS_1x1,
8488 HW_MODE_80_MHZ,
8489 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
8490 HW_MODE_DBS,
8491 HW_MODE_AGILE_DFS_NONE,
8492 HW_MODE_SBS_NONE,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08008493 SIR_UPDATE_REASON_UT, PM_NOP);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008494 }
8495 }
8496 break;
8497
8498 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8499 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008500 enum policy_mgr_conc_next_action action;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008501
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07008502 hdd_debug("<iwpriv wlan0 pm_query_action> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008503 action = policy_mgr_current_connections_update(
8504 hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07008505 adapter->session_id, apps_args[0],
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008506 SIR_UPDATE_REASON_UT);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008507 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
8508 }
8509 break;
8510
8511 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8512 {
8513 bool allow;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008514
8515 hdd_notice("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008516 allow = policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008517 apps_args[0], apps_args[1], apps_args[2]);
8518 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
8519 }
8520 break;
8521
8522 case WE_POLICY_MANAGER_SCENARIO_CMD:
8523 {
8524 clean_report(hdd_ctx);
8525 if (apps_args[0] == 1) {
8526 wlan_hdd_one_connection_scenario(hdd_ctx);
8527 } else if (apps_args[0] == 2) {
8528 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008529 6, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008530 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008531 36, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008532 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008533 6, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008534 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008535 36, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008536 } else if (apps_args[0] == 3) {
8537 /* MCC on same band with 2x2 same mac*/
8538 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008539 6, 11, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008540 /* MCC on diff band with 2x2 same mac*/
8541 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008542 6, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008543 /* MCC on diff band with 1x1 diff mac */
8544 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008545 36, 6, POLICY_MGR_ONE_ONE, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008546 /* MCC on diff band with 1x1 same mac */
8547 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008548 36, 6, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008549 /* SCC on same band with 2x2 same mac */
8550 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008551 36, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008552 /* SCC on same band with 1x1 same mac */
8553 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008554 36, 36, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008555 /* MCC on same band with 2x2 same mac */
8556 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008557 36, 149, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008558 /* MCC on same band with 1x1 same mac */
8559 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008560 36, 149, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008561 }
8562 print_report(hdd_ctx);
8563 }
8564 break;
8565 }
8566 return 0;
8567}
8568#else
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008569static int iw_get_policy_manager_ut_ops(struct hdd_context *hdd_ctx,
Jeff Johnson3d278b02017-08-29 14:17:47 -07008570 struct hdd_adapter *adapter, int sub_cmd, int *apps_args)
Krunal Sonia6e505b2017-01-12 12:25:18 -08008571{
8572 return 0;
8573}
8574#endif
8575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008576/**
Liangwei Dong2a7f2912018-02-07 17:08:17 +08008577 * hdd_ch_avoid_unit_cmd - unit test ch avoidance
8578 * @hdd_ctx: hdd_context
8579 * @num_args: input args number
8580 * @apps_args: args data ptr
8581 *
8582 * This is to inject a ch avoid event to do unit test SAP chan avoidance.
8583 *
8584 * Return: void
8585 */
8586#if WLAN_DEBUG
8587static void hdd_ch_avoid_unit_cmd(struct hdd_context *hdd_ctx,
8588 int num_args, int *apps_args)
8589{
8590 struct ch_avoid_ind_type ch_avoid;
8591 int cnt = 0, i;
8592
8593 if (num_args < 2 || num_args > CH_AVOID_MAX_RANGE * 2 ||
8594 num_args % 2 != 0)
8595 return;
8596 hdd_info("simulate ch avoid num_args %d", num_args);
8597 for (i = 0; i < num_args && i < CH_AVOID_MAX_RANGE * 2; i++) {
8598 ch_avoid.avoid_freq_range[cnt].start_freq =
8599 apps_args[i];
8600 ch_avoid.avoid_freq_range[cnt].end_freq =
8601 apps_args[++i];
8602
8603 hdd_info("simulate ch avoid [%d %d]",
8604 ch_avoid.avoid_freq_range[cnt].start_freq,
8605 ch_avoid.avoid_freq_range[cnt].end_freq);
8606 cnt++;
8607 }
8608 ch_avoid.ch_avoid_range_cnt = cnt;
8609 ucfg_reg_unit_simulate_ch_avoid(hdd_ctx->hdd_psoc, &ch_avoid);
8610}
8611#else
8612static void hdd_ch_avoid_unit_cmd(struct hdd_context *hdd_ctx,
8613 int num_args, int *apps_args)
8614{
8615}
8616#endif
8617/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008618 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8619 * @dev: device upon which the ioctl was received
8620 * @info: ioctl request information
8621 * @wrqu: ioctl request data
8622 * @extra: ioctl extra data
8623 *
8624 * This is an SSR-protected generic handler for private ioctls which
8625 * take multiple arguments. Note that this implementation is also
8626 * somewhat unique in that it is shared by both STA-mode and SAP-mode
8627 * interfaces.
8628 *
8629 * Return: 0 on success, non-zero on error
8630 */
8631static int __iw_set_var_ints_getnone(struct net_device *dev,
8632 struct iw_request_info *info,
8633 union iwreq_data *wrqu, char *extra)
8634{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008635 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8636 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008637 int sub_cmd;
8638 int *apps_args = (int *) extra;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008639 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008640 int ret, num_args;
8641
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008642 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308643
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008644 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008645 ret = wlan_hdd_validate_context(hdd_ctx);
8646 if (0 != ret)
8647 return ret;
8648
Jeff Johnson441e1f72017-02-07 08:50:49 -08008649 ret = hdd_check_private_wext_control(hdd_ctx, info);
8650 if (0 != ret)
8651 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008652
8653 sub_cmd = wrqu->data.flags;
8654 num_args = wrqu->data.length;
8655
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008656 hdd_debug("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008657
8658 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008659 case WE_IBSS_GET_PEER_INFO:
8660 {
8661 pr_info("Station ID = %d\n", apps_args[0]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008662 hdd_wlan_get_ibss_peer_info(adapter, apps_args[0]);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008663 }
8664 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008665
8666 case WE_P2P_NOA_CMD:
8667 {
Srinivas Girigowda5d5fdc52017-03-24 22:30:57 -07008668 struct p2p_app_set_ps p2pNoA;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008669
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008670 if (adapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -08008671 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
8672 hdd_device_mode_to_string(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008673 adapter->device_mode),
8674 adapter->device_mode);
Rajeev Kumar274034c2015-11-23 11:28:58 -08008675 return -EINVAL;
8676 }
8677
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008678 p2pNoA.opp_ps = apps_args[0];
8679 p2pNoA.ctWindow = apps_args[1];
8680 p2pNoA.duration = apps_args[2];
8681 p2pNoA.interval = apps_args[3];
8682 p2pNoA.count = apps_args[4];
8683 p2pNoA.single_noa_duration = apps_args[5];
8684 p2pNoA.psSelection = apps_args[6];
8685
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008686 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 -07008687 apps_args[0], apps_args[1], apps_args[2],
8688 apps_args[3], apps_args[4],
8689 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008690
8691 hdd_set_p2p_ps(dev, &p2pNoA);
8692
8693 }
8694 break;
8695
8696 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
8697 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008698 hdd_debug("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
Jeff Johnson99bac312016-06-28 10:38:18 -07008699 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308700 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008701 }
8702 break;
8703
8704 case WE_MTRACE_DUMP_CMD:
8705 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008706 hdd_debug("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
Jeff Johnson99bac312016-06-28 10:38:18 -07008707 apps_args[0], apps_args[1],
8708 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308709 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008710 apps_args[1], apps_args[2],
8711 apps_args[3]);
8712
8713 }
8714 break;
8715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008716 case WE_POLICY_MANAGER_CINFO_CMD:
8717 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008718 struct policy_mgr_conc_connection_info *conn_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008719 uint32_t i = 0, len = 0;
8720
Krunal Sonia6e505b2017-01-12 12:25:18 -08008721 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008722 conn_info = policy_mgr_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -08008723 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008724 for (i = 0; i < len; i++) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07008725 pr_info("|table_index[%d]\t\t\n", i);
8726 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
8727 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
8728 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
8729 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
8730 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
8731 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
8732 pr_info("+--------------------------+\n");
8733 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008734 }
8735 }
8736 break;
8737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008738 case WE_UNIT_TEST_CMD:
8739 {
Krunal Soniaadaa272017-10-04 16:42:55 -07008740 QDF_STATUS status;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008741
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008742 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
8743 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Krunal Soniaadaa272017-10-04 16:42:55 -07008744 hdd_err("Invalid MODULE ID %d", apps_args[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008745 return -EINVAL;
8746 }
Krunal Soniaadaa272017-10-04 16:42:55 -07008747 if ((apps_args[1] >= (WMA_MAX_NUM_ARGS)) ||
Anurag Chouhan77564182016-09-03 16:38:01 +05308748 (apps_args[1] < 0)) {
Krunal Soniaadaa272017-10-04 16:42:55 -07008749 hdd_err("Too Many/Few args %d", apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008750 return -EINVAL;
8751 }
Jeff Johnson1b780e42017-10-31 14:11:45 -07008752 status = sme_send_unit_test_cmd(adapter->session_id,
Krunal Soniaadaa272017-10-04 16:42:55 -07008753 apps_args[0],
8754 apps_args[1],
8755 &apps_args[2]);
8756 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson21d63bb2017-10-07 17:45:33 -07008757 hdd_err("sme_send_unit_test_cmd returned %d", status);
8758 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008759 }
8760 }
8761 break;
8762#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
8763 case WE_LED_FLASHING_PARAM:
8764 {
8765 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008766
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008767 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008768 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008769 return -EINVAL;
8770 }
8771 for (i = 0; i < num_args; i++) {
8772 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008773 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008774 return -EINVAL;
8775 }
8776 }
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008777 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008778 0, apps_args[0], apps_args[1]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008779 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008780 1, apps_args[2], apps_args[3]);
8781 }
8782 break;
8783#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +05308784 case WE_SET_PKTLOG:
8785 {
8786 int ret;
8787
8788 if (num_args < 1 || num_args > 2) {
8789 hdd_err("pktlog: either 1 or 2 parameters are required");
8790 return -EINVAL;
8791 }
8792
8793 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
8794 apps_args[1]);
8795 if (ret)
8796 return ret;
8797 break;
8798 }
8799
Manjeet Singhf82ed072016-07-08 11:40:00 +05308800 case WE_MAC_PWR_DEBUG_CMD:
8801 {
8802 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008803 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Manjeet Singhf82ed072016-07-08 11:40:00 +05308804 int i, j;
8805
8806 if (num_args < 3) {
8807 hdd_err("number of arguments can't be null %d",
8808 num_args);
8809 return -EINVAL;
8810 }
8811 if (num_args - 3 != apps_args[2]) {
8812 hdd_err("arg list of size %d doesn't match num_args %d",
8813 num_args-3, apps_args[2]);
8814 return -EINVAL;
8815 }
8816 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
8817 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
8818 hdd_err("Invalid MODULE ID %d", apps_args[1]);
8819 return -EINVAL;
8820 }
8821 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
8822 hdd_err("Too Many args %d", apps_args[2]);
8823 return -EINVAL;
8824 }
8825 mac_pwr_dbg_args.pdev_id = apps_args[0];
8826 mac_pwr_dbg_args.module_id = apps_args[1];
8827 mac_pwr_dbg_args.num_args = apps_args[2];
8828
8829 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
8830 mac_pwr_dbg_args.args[i] = apps_args[j];
8831
8832 if (QDF_STATUS_SUCCESS !=
Jeff Johnson1b780e42017-10-31 14:11:45 -07008833 sme_process_mac_pwr_dbg_cmd(hal, adapter->session_id,
Manjeet Singhf82ed072016-07-08 11:40:00 +05308834 &mac_pwr_dbg_args)) {
8835 return -EINVAL;
8836 }
8837 }
8838 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -08008839 case WE_POLICY_MANAGER_CLIST_CMD:
8840 case WE_POLICY_MANAGER_DLIST_CMD:
8841 case WE_POLICY_MANAGER_ULIST_CMD:
8842 case WE_POLICY_MANAGER_DBS_CMD:
8843 case WE_POLICY_MANAGER_PCL_CMD:
8844 case WE_POLICY_SET_HW_MODE_CMD:
8845 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
8846 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
8847 case WE_POLICY_MANAGER_SCENARIO_CMD:
8848 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008849 iw_get_policy_manager_ut_ops(hdd_ctx, adapter,
Krunal Sonia6e505b2017-01-12 12:25:18 -08008850 sub_cmd, apps_args);
8851 }
8852 break;
Liangwei Dong2a7f2912018-02-07 17:08:17 +08008853 case WE_SET_CHAN_AVOID:
8854 {
8855 hdd_ch_avoid_unit_cmd(hdd_ctx, num_args, apps_args);
8856 }
8857 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008858 default:
8859 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008860 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008861 }
8862 break;
8863 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308864 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008865 return 0;
8866}
8867
8868/**
8869 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
8870 * @dev: pointer to net_device structure
8871 * @info: pointer to iw_request_info structure
8872 * @wrqu: pointer to iwreq_data
8873 * @extra; extra
8874 *
8875 * Return: 0 on success, error number otherwise
8876 *
8877 */
8878static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
8879 struct iw_request_info *info,
8880 union iwreq_data *wrqu, char *extra)
8881{
8882 union iwreq_data u_priv_wrqu;
8883 int apps_args[MAX_VAR_ARGS] = {0};
8884 int ret, num_args;
8885
Mukul Sharma64a70e82015-11-02 20:05:09 +05308886 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008887 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +05308888 return -EPERM;
8889 }
8890
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008891 /* Helper function to get iwreq_data with compat handling. */
8892 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
8893 return -EINVAL;
8894
8895 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008896 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008897 return -EINVAL;
8898 }
8899
8900 num_args = u_priv_wrqu.data.length;
8901 if (num_args > MAX_VAR_ARGS)
8902 num_args = MAX_VAR_ARGS;
8903
8904 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
8905 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008906 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008907 return -EFAULT;
8908 }
8909
8910 cds_ssr_protect(__func__);
8911 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
8912 (char *)&apps_args);
8913 cds_ssr_unprotect(__func__);
8914 return ret;
8915}
8916
8917/**
8918 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
8919 * @dev: device upon which the ioctl was received
8920 * @info: ioctl request information
8921 * @wrqu: ioctl request data
8922 * @extra: ioctl extra data
8923 *
8924 * This is a generic handler for private ioctls which take multiple
8925 * arguments. Note that this implementation is also somewhat unique
8926 * in that it is shared by both STA-mode and SAP-mode interfaces.
8927 *
8928 * Return: 0 on success, non-zero on error
8929 */
8930int iw_set_var_ints_getnone(struct net_device *dev,
8931 struct iw_request_info *info,
8932 union iwreq_data *wrqu, char *extra)
8933{
8934 int ret;
8935
8936 cds_ssr_protect(__func__);
8937 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
8938 cds_ssr_unprotect(__func__);
8939 return ret;
8940}
8941
8942/**
8943 * iw_add_tspec - Add TSpec private ioctl handler
8944 * @dev: device upon which the ioctl was received
8945 * @info: ioctl request information
8946 * @wrqu: ioctl request data
8947 * @extra: ioctl extra data
8948 *
8949 * Return: 0 on success, non-zero on error
8950 */
8951static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
8952 union iwreq_data *wrqu, char *extra)
8953{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008954 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -07008955 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008956 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
8957 int params[HDD_WLAN_WMM_PARAM_COUNT];
Abhishek Singh12be60f2017-08-11 13:52:42 +05308958 struct sme_qos_wmmtspecinfo tSpec;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008959 uint32_t handle;
8960 struct iw_point s_priv_data;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008961 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008962 int ret;
8963
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008964 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308965
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008966 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008967 ret = wlan_hdd_validate_context(hdd_ctx);
8968 if (0 != ret)
8969 return ret;
8970
Jeff Johnson441e1f72017-02-07 08:50:49 -08008971 ret = hdd_check_private_wext_control(hdd_ctx, info);
8972 if (0 != ret)
8973 return ret;
8974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008975 /* make sure the application is sufficiently priviledged */
8976 /* note that the kernel will do this for "set" ioctls, but since */
8977 /* this ioctl wants to return status to user space it must be */
8978 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008979 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008980 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008981
8982 /* we must be associated in order to add a tspec */
Jeff Johnsond377dce2017-10-04 10:32:42 -07008983 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008984 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8985 return 0;
8986 }
8987 /* since we are defined to be a "get" ioctl, and since the number */
8988 /* of params exceeds the number of params that wireless extensions */
8989 /* will pass down in the iwreq_data, we must copy the "set" params. */
8990 /* We must handle the compat for iwreq_data in 32U/64K environment. */
8991
8992 /* helper function to get iwreq_data with compat handling. */
8993 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8994 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
8995 return 0;
8996 }
8997 /* make sure all params are correctly passed to function */
8998 if ((NULL == s_priv_data.pointer) ||
8999 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
9000 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9001 return 0;
9002 }
9003 /* from user space ourselves */
9004 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
9005 /* hmmm, can't get them */
9006 return -EIO;
9007 }
9008 /* clear the tspec */
9009 memset(&tSpec, 0, sizeof(tSpec));
9010
9011 /* validate the handle */
9012 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9013 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9014 /* that one is reserved */
9015 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9016 return 0;
9017 }
9018 /* validate the TID */
9019 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
9020 /* out of range */
9021 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9022 return 0;
9023 }
9024 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
9025
9026 /* validate the direction */
9027 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
9028 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
9029 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
9030 break;
9031
9032 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
9033 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
9034 break;
9035
9036 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
9037 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
9038 break;
9039
9040 default:
9041 /* unknown */
9042 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9043 return 0;
9044 }
9045
9046 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
9047
9048 /* validate the user priority */
9049 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
9050 /* out of range */
9051 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9052 return 0;
9053 }
9054 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
9055 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009056 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009057 return 0;
9058 }
9059
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009060 hdd_debug("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009061 tSpec.ts_info.psb, tSpec.ts_info.up);
9062
9063 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
9064 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
9065 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
9066 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
9067 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
9068 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
9069 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
9070 tSpec.surplus_bw_allowance =
9071 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
9072 tSpec.min_service_interval =
9073 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
9074 tSpec.max_service_interval =
9075 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
9076 tSpec.suspension_interval =
9077 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
9078 tSpec.inactivity_interval =
9079 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
9080
9081 tSpec.ts_info.burst_size_defn =
9082 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
9083
9084 /* validate the ts info ack policy */
9085 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
9086 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
9087 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
9088 break;
9089
9090 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
9091 tSpec.ts_info.ack_policy =
9092 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
9093 break;
9094
9095 default:
9096 /* unknown */
9097 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9098 return 0;
9099 }
9100
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009101 *pStatus = hdd_wmm_addts(adapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309102 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009103 return 0;
9104}
9105
9106static int iw_add_tspec(struct net_device *dev,
9107 struct iw_request_info *info,
9108 union iwreq_data *wrqu, char *extra)
9109{
9110 int ret;
9111
9112 cds_ssr_protect(__func__);
9113 ret = __iw_add_tspec(dev, info, wrqu, extra);
9114 cds_ssr_unprotect(__func__);
9115
9116 return ret;
9117}
9118
9119/**
9120 * iw_del_tspec - Delete TSpec private ioctl handler
9121 * @dev: device upon which the ioctl was received
9122 * @info: ioctl request information
9123 * @wrqu: ioctl request data
9124 * @extra: ioctl extra data
9125 *
9126 * Return: 0 on success, non-zero on error
9127 */
9128static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
9129 union iwreq_data *wrqu, char *extra)
9130{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009131 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009132 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009133 int *params = (int *)extra;
9134 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9135 uint32_t handle;
9136 int ret;
9137
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009138 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309139
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009140 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009141 ret = wlan_hdd_validate_context(hdd_ctx);
9142 if (0 != ret)
9143 return ret;
9144
Jeff Johnson441e1f72017-02-07 08:50:49 -08009145 ret = hdd_check_private_wext_control(hdd_ctx, info);
9146 if (0 != ret)
9147 return ret;
9148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009149 /* make sure the application is sufficiently priviledged */
9150 /* note that the kernel will do this for "set" ioctls, but since */
9151 /* this ioctl wants to return status to user space it must be */
9152 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009153 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009154 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009155
9156 /* although we are defined to be a "get" ioctl, the params we require */
9157 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9158 /* is no need to copy the params from user space */
9159
9160 /* validate the handle */
9161 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9162 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9163 /* that one is reserved */
9164 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9165 return 0;
9166 }
9167
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009168 *pStatus = hdd_wmm_delts(adapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309169 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009170 return 0;
9171}
9172
9173static int iw_del_tspec(struct net_device *dev,
9174 struct iw_request_info *info,
9175 union iwreq_data *wrqu, char *extra)
9176{
9177 int ret;
9178
9179 cds_ssr_protect(__func__);
9180 ret = __iw_del_tspec(dev, info, wrqu, extra);
9181 cds_ssr_unprotect(__func__);
9182
9183 return ret;
9184}
9185
9186/**
9187 * iw_get_tspec - Get TSpec private ioctl handler
9188 * @dev: device upon which the ioctl was received
9189 * @info: ioctl request information
9190 * @wrqu: ioctl request data
9191 * @extra: ioctl extra data
9192 *
9193 * Return: 0 on success, non-zero on error
9194 */
9195static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
9196 union iwreq_data *wrqu, char *extra)
9197{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009198 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009199 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009200 int *params = (int *)extra;
9201 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
9202 uint32_t handle;
9203 int ret;
9204
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009205 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309206
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009207 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009208 ret = wlan_hdd_validate_context(hdd_ctx);
9209 if (0 != ret)
9210 return ret;
9211
Jeff Johnson441e1f72017-02-07 08:50:49 -08009212 ret = hdd_check_private_wext_control(hdd_ctx, info);
9213 if (0 != ret)
9214 return ret;
9215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009216 /* although we are defined to be a "get" ioctl, the params we require */
9217 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
9218 /* is no need to copy the params from user space */
9219
9220 /* validate the handle */
9221 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
9222 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
9223 /* that one is reserved */
9224 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
9225 return 0;
9226 }
9227
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009228 *pStatus = hdd_wmm_checkts(adapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309229 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009230 return 0;
9231}
9232
9233static int iw_get_tspec(struct net_device *dev,
9234 struct iw_request_info *info,
9235 union iwreq_data *wrqu, char *extra)
9236{
9237 int ret;
9238
9239 cds_ssr_protect(__func__);
9240 ret = __iw_get_tspec(dev, info, wrqu, extra);
9241 cds_ssr_unprotect(__func__);
9242
9243 return ret;
9244}
9245
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009246/**
9247 * iw_set_fties - Set FT IEs private ioctl handler
9248 * @dev: device upon which the ioctl was received
9249 * @info: ioctl request information
9250 * @wrqu: ioctl request data
9251 * @extra: ioctl extra data
9252 *
9253 * Each time the supplicant has the auth_request or reassoc request
9254 * IEs ready they are pushed to the driver. The driver will in turn
9255 * use it to send out the auth req and reassoc req for 11r FT Assoc.
9256 *
9257 * Return: 0 on success, non-zero on error
9258 */
9259static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
9260 union iwreq_data *wrqu, char *extra)
9261{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009262 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -07009263 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009264 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009265 int ret;
9266
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009267 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309268
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009269 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009270 ret = wlan_hdd_validate_context(hdd_ctx);
9271 if (0 != ret)
9272 return ret;
9273
Jeff Johnson441e1f72017-02-07 08:50:49 -08009274 ret = hdd_check_private_wext_control(hdd_ctx, info);
9275 if (0 != ret)
9276 return ret;
9277
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009278 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009279 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009280 return -EINVAL;
9281 }
9282 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009283 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009284 return -EINVAL;
9285 }
9286 /* Added for debug on reception of Re-assoc Req. */
Jeff Johnsond377dce2017-10-04 10:32:42 -07009287 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009288 hdd_debug("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009289 wrqu->data.length);
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009290 hdd_debug("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009291 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009292 hdd_debug("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009293
9294 /* Pass the received FT IEs to SME */
Jeff Johnson1b780e42017-10-31 14:11:45 -07009295 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(adapter), adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009296 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309297 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009298 return 0;
9299}
9300
9301static int iw_set_fties(struct net_device *dev,
9302 struct iw_request_info *info,
9303 union iwreq_data *wrqu, char *extra)
9304{
9305 int ret;
9306
9307 cds_ssr_protect(__func__);
9308 ret = __iw_set_fties(dev, info, wrqu, extra);
9309 cds_ssr_unprotect(__func__);
9310
9311 return ret;
9312}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009313
Dustin Brown0cbc7572016-12-16 13:54:40 -08009314/**
9315 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
9316 * @dev: device upon which the ioctl was received
9317 * @info: ioctl request information
9318 * @wrqu: ioctl request data
9319 * @extra: ioctl extra data
9320 *
Dustin Brown860566f2017-01-31 15:24:43 -08009321 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
9322 * time being to provide guidance in migrating to standard APIs.
9323 *
Dustin Brown0cbc7572016-12-16 13:54:40 -08009324 * Return: 0 on success, non-zero on error
9325 */
9326static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
9327 struct iw_request_info *info,
9328 union iwreq_data *wrqu,
9329 char *extra)
9330{
Dustin Brown860566f2017-01-31 15:24:43 -08009331 hdd_err("\n"
9332 "setMCBCFilter is obsolete. Use the following instead:\n"
9333 "Configure multicast filtering via the ‘ip’ command.\n"
9334 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
9335 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
9336 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
9337 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
9338 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07009339 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -08009340}
9341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009342/**
9343 * iw_set_host_offload - Set host offload ioctl handler
9344 * @dev: device upon which the ioctl was received
9345 * @info: ioctl request information
9346 * @wrqu: ioctl request data
9347 * @extra: ioctl extra data
9348 *
9349 * Return: 0 on success, non-zero on error
9350 */
9351static int __iw_set_host_offload(struct net_device *dev,
9352 struct iw_request_info *info,
9353 union iwreq_data *wrqu, char *extra)
9354{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009355 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowda077143e2017-03-25 10:47:27 -07009356 struct host_offload_req *pRequest = (struct host_offload_req *) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009357 tSirHostOffloadReq offloadRequest;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009358 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009359 int ret;
9360
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009361 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309362
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009363 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009364 ret = wlan_hdd_validate_context(hdd_ctx);
9365 if (0 != ret)
9366 return ret;
9367
Jeff Johnson441e1f72017-02-07 08:50:49 -08009368 ret = hdd_check_private_wext_control(hdd_ctx, info);
9369 if (0 != ret)
9370 return ret;
9371
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009372 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009373 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009374 return -EINVAL;
9375 }
9376
9377 /* Debug display of request components. */
9378 switch (pRequest->offloadType) {
9379 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009380 hdd_debug("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009381 switch (pRequest->enableOrDisable) {
9382 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009383 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009384 break;
9385 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009386 hdd_debug(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009387 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009388 hdd_debug(" ARP offload enable");
9389 hdd_debug(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009390 pRequest->params.hostIpv4Addr[0],
9391 pRequest->params.hostIpv4Addr[1],
9392 pRequest->params.hostIpv4Addr[2],
9393 pRequest->params.hostIpv4Addr[3]);
9394 }
9395 break;
9396
9397 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009398 hdd_debug("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009399 switch (pRequest->enableOrDisable) {
9400 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009401 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009402 break;
9403 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009404 hdd_debug(" enable");
9405 hdd_debug(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009406 *(uint16_t *) (pRequest->params.hostIpv6Addr),
9407 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9408 2),
9409 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9410 4),
9411 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9412 6),
9413 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9414 8),
9415 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9416 10),
9417 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9418 12),
9419 *(uint16_t *) (pRequest->params.hostIpv6Addr +
9420 14));
9421 }
9422 }
9423
Hanumanth Reddy Pothula8fcade52017-12-01 13:49:40 +05309424 qdf_mem_zero(&offloadRequest, sizeof(offloadRequest));
9425 offloadRequest.offloadType = pRequest->offloadType;
9426 offloadRequest.enableOrDisable = pRequest->enableOrDisable;
9427 qdf_mem_copy(&offloadRequest.params, &pRequest->params,
9428 sizeof(pRequest->params));
9429 qdf_mem_copy(&offloadRequest.bssid, &pRequest->bssId.bytes,
9430 QDF_MAC_ADDR_SIZE);
9431
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309432 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009433 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07009434 adapter->session_id, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009435 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009436 return -EINVAL;
9437 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309438 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009439 return 0;
9440}
9441
9442static int iw_set_host_offload(struct net_device *dev,
9443 struct iw_request_info *info,
9444 union iwreq_data *wrqu, char *extra)
9445{
9446 int ret;
9447
9448 cds_ssr_protect(__func__);
9449 ret = __iw_set_host_offload(dev, info, wrqu, extra);
9450 cds_ssr_unprotect(__func__);
9451
9452 return ret;
9453}
9454
9455/**
9456 * iw_set_keepalive_params - Set keepalive params ioctl handler
9457 * @dev: device upon which the ioctl was received
9458 * @info: ioctl request information
9459 * @wrqu: ioctl request data
9460 * @extra: ioctl extra data
9461 *
9462 * Return: 0 on success, non-zero on error
9463 */
9464static int __iw_set_keepalive_params(struct net_device *dev,
9465 struct iw_request_info *info,
9466 union iwreq_data *wrqu, char *extra)
9467{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009468 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009469 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009470 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009471 int ret;
9472
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009473 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309474
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009475 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009476 ret = wlan_hdd_validate_context(hdd_ctx);
9477 if (0 != ret)
9478 return ret;
9479
Jeff Johnson441e1f72017-02-07 08:50:49 -08009480 ret = hdd_check_private_wext_control(hdd_ctx, info);
9481 if (0 != ret)
9482 return ret;
9483
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009484 if (wrqu->data.length != sizeof(*request)) {
9485 hdd_err("Invalid length %d", wrqu->data.length);
9486 return -EINVAL;
9487 }
9488
9489 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
9490 hdd_err("Value of timePeriod %d exceed Max limit %d",
9491 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009492 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
9493 return -EINVAL;
9494 }
9495
9496 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009497 hdd_debug("Set Keep Alive Request : TimePeriod %d size %zu",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009498 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009499
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009500 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009501 case WLAN_KEEP_ALIVE_NULL_PKT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009502 hdd_debug("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009503 break;
9504
9505 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009506 hdd_debug("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009507
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009508 hdd_debug("Host IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009509 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
9510 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009511
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009512 hdd_debug("Dest IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009513 request->destIpv4Addr[0], request->destIpv4Addr[1],
9514 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009515
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009516 hdd_debug("Dest MAC address: "MAC_ADDRESS_STR,
Srinivas Girigowda9c330a92015-11-24 12:28:25 -08009517 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009518 break;
9519 }
9520
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009521 hdd_debug("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009522
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309523 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009524 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07009525 adapter->session_id, request)) {
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -08009526 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009527 return -EINVAL;
9528 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309529 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009530 return 0;
9531}
9532
9533static int iw_set_keepalive_params(struct net_device *dev,
9534 struct iw_request_info *info,
9535 union iwreq_data *wrqu,
9536 char *extra)
9537{
9538 int ret;
9539
9540 cds_ssr_protect(__func__);
9541 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
9542 cds_ssr_unprotect(__func__);
9543
9544 return ret;
9545}
9546
9547#ifdef WLAN_FEATURE_PACKET_FILTERING
9548/**
9549 * wlan_hdd_set_filter() - Set packet filter
9550 * @hdd_ctx: Global HDD context
9551 * @request: Packet filter request struct
9552 * @sessionId: Target session for the request
9553 *
9554 * Return: 0 on success, non-zero on error
9555 */
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +05309556int wlan_hdd_set_filter(struct hdd_context *hdd_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009557 struct pkt_filter_cfg *request,
9558 uint8_t sessionId)
9559{
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309560 struct pmo_rcv_pkt_fltr_cfg *pmo_set_pkt_fltr_req = NULL;
9561 struct pmo_rcv_pkt_fltr_clear_param *pmo_clr_pkt_fltr_param = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009562 int i = 0;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309563 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009564
9565 if (hdd_ctx->config->disablePacketFilter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009566 hdd_warn("Packet filtering disabled in ini");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009567 return 0;
9568 }
9569
9570 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009571 hdd_debug("Packet Filter Request : FA %d params %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009572 request->filter_action, request->num_params);
9573
9574 switch (request->filter_action) {
9575 case HDD_RCV_FILTER_SET:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009576 hdd_debug("Set Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009577 request->filter_id);
9578
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309579 pmo_set_pkt_fltr_req =
9580 qdf_mem_malloc(sizeof(*pmo_set_pkt_fltr_req));
9581 if (!pmo_set_pkt_fltr_req) {
Mukul Sharmad75a6672017-06-22 15:40:53 +05309582 hdd_err("unable to allocate pmo_set_pkt_fltr_req");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309583 return QDF_STATUS_E_NOMEM;
9584 }
9585
9586 pmo_set_pkt_fltr_req->filter_id = request->filter_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009587 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
9588 hdd_err("Number of Params exceed Max limit %d",
9589 request->num_params);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309590 status = QDF_STATUS_E_INVAL;
9591 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009592 }
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309593 pmo_set_pkt_fltr_req->num_params = request->num_params;
9594 pmo_set_pkt_fltr_req->coalesce_time = 0;
Srinivas Girigowdabbbecad2017-06-28 16:01:48 -07009595 pmo_set_pkt_fltr_req->filter_type = PMO_RCV_FILTER_TYPE_FILTER_PKT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009596 for (i = 0; i < request->num_params; i++) {
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309597 pmo_set_pkt_fltr_req->params_data[i].protocol_layer =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009598 request->params_data[i].protocol_layer;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309599 pmo_set_pkt_fltr_req->params_data[i].compare_flag =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009600 request->params_data[i].compare_flag;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309601 pmo_set_pkt_fltr_req->params_data[i].data_offset =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009602 request->params_data[i].data_offset;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309603 pmo_set_pkt_fltr_req->params_data[i].data_length =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009604 request->params_data[i].data_length;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309605 pmo_set_pkt_fltr_req->params_data[i].reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009606
Dustin Brown4d1e8462016-12-14 12:12:24 -08009607 if (request->params_data[i].data_offset >
9608 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
9609 hdd_err("Invalid data offset %u for param %d (max = %d)",
9610 request->params_data[i].data_offset,
9611 i,
9612 SIR_MAX_FILTER_TEST_DATA_OFFSET);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309613 status = QDF_STATUS_E_INVAL;
9614 goto out;
Dustin Brown4d1e8462016-12-14 12:12:24 -08009615 }
9616
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009617 if (request->params_data[i].data_length >
9618 SIR_MAX_FILTER_TEST_DATA_LEN) {
9619 hdd_err("Error invalid data length %d",
9620 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309621 status = QDF_STATUS_E_INVAL;
9622 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009623 }
9624
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009625 hdd_debug("Proto %d Comp Flag %d Filter Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009626 request->params_data[i].protocol_layer,
9627 request->params_data[i].compare_flag,
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309628 pmo_set_pkt_fltr_req->filter_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009629
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009630 hdd_debug("Data Offset %d Data Len %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009631 request->params_data[i].data_offset,
9632 request->params_data[i].data_length);
9633
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309634 if (sizeof(
9635 pmo_set_pkt_fltr_req->params_data[i].compare_data)
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07009636 < (request->params_data[i].data_length)) {
9637 hdd_err("Error invalid data length %d",
9638 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309639 status = QDF_STATUS_E_INVAL;
9640 goto out;
Rajeev Kumarf5b6da22016-04-15 13:24:03 -07009641 }
9642
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309643 memcpy(
9644 &pmo_set_pkt_fltr_req->params_data[i].compare_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009645 request->params_data[i].compare_data,
9646 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309647 memcpy(&pmo_set_pkt_fltr_req->params_data[i].data_mask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009648 request->params_data[i].data_mask,
9649 request->params_data[i].data_length);
9650
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009651 hdd_debug("CData %d CData %d CData %d CData %d CData %d CData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009652 request->params_data[i].compare_data[0],
9653 request->params_data[i].compare_data[1],
9654 request->params_data[i].compare_data[2],
9655 request->params_data[i].compare_data[3],
9656 request->params_data[i].compare_data[4],
9657 request->params_data[i].compare_data[5]);
9658
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009659 hdd_debug("MData %d MData %d MData %d MData %d MData %d MData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009660 request->params_data[i].data_mask[0],
9661 request->params_data[i].data_mask[1],
9662 request->params_data[i].data_mask[2],
9663 request->params_data[i].data_mask[3],
9664 request->params_data[i].data_mask[4],
9665 request->params_data[i].data_mask[5]);
9666 }
9667
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309668 if (QDF_STATUS_SUCCESS !=
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309669 pmo_ucfg_set_pkt_filter(hdd_ctx->hdd_psoc,
9670 pmo_set_pkt_fltr_req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009671 sessionId)) {
9672 hdd_err("Failure to execute Set Filter");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309673 status = QDF_STATUS_E_INVAL;
9674 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009675 }
9676
9677 break;
9678
9679 case HDD_RCV_FILTER_CLEAR:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009680 hdd_debug("Clear Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009681 request->filter_id);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309682
9683 pmo_clr_pkt_fltr_param = qdf_mem_malloc(
9684 sizeof(*pmo_clr_pkt_fltr_param));
9685 if (!pmo_clr_pkt_fltr_param) {
9686 hdd_err("unable to allocate pmo_clr_pkt_fltr_param");
9687 return QDF_STATUS_E_NOMEM;
9688 }
9689
9690 pmo_clr_pkt_fltr_param->filter_id = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309691 if (QDF_STATUS_SUCCESS !=
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309692 pmo_ucfg_clear_pkt_filter(hdd_ctx->hdd_psoc,
9693 pmo_clr_pkt_fltr_param,
9694 sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009695 hdd_err("Failure to execute Clear Filter");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309696 status = QDF_STATUS_E_INVAL;
9697 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009698 }
9699 break;
9700
9701 default:
9702 hdd_err("Packet Filter Request: Invalid %d",
9703 request->filter_action);
9704 return -EINVAL;
9705 }
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +05309706
9707out:
9708 if (pmo_set_pkt_fltr_req)
9709 qdf_mem_free(pmo_set_pkt_fltr_req);
9710 if (pmo_clr_pkt_fltr_param)
9711 qdf_mem_free(pmo_clr_pkt_fltr_param);
9712
9713 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009714}
9715
9716/**
9717 * __iw_set_packet_filter_params() - set packet filter parameters in target
9718 * @dev: Pointer to netdev
9719 * @info: Pointer to iw request info
9720 * @wrqu: Pointer to data
9721 * @extra: Pointer to extra data
9722 *
9723 * Return: 0 on success, non-zero on error
9724 */
9725static int __iw_set_packet_filter_params(struct net_device *dev,
9726 struct iw_request_info *info,
9727 union iwreq_data *wrqu, char *extra)
9728{
9729 int ret;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009730 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009731 struct iw_point priv_data;
Jeff Johnson3d278b02017-08-29 14:17:47 -07009732 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009733 struct pkt_filter_cfg *request = NULL;
9734
Mukul Sharma472382f2015-11-02 20:16:31 +05309735 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009736 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +05309737 return -EPERM;
9738 }
9739
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009740 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309741
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009742 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9743 ret = wlan_hdd_validate_context(hdd_ctx);
9744 if (0 != ret)
9745 return ret;
9746
Jeff Johnson441e1f72017-02-07 08:50:49 -08009747 ret = hdd_check_private_wext_control(hdd_ctx, info);
9748 if (0 != ret)
9749 return ret;
9750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009751 if (hdd_priv_get_data(&priv_data, wrqu)) {
9752 hdd_err("failed to get priv data");
9753 return -EINVAL;
9754 }
9755
9756 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07009757 hdd_err("invalid priv data %pK or invalid priv data length %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009758 priv_data.pointer, priv_data.length);
9759 return -EINVAL;
9760 }
9761
Arun Khandavalli75d246b2017-08-07 19:46:06 +05309762 if (adapter->device_mode != QDF_STA_MODE) {
9763 hdd_err("Packet filter not supported for this mode :%d",
9764 adapter->device_mode);
9765 return -ENOTSUPP;
9766 }
9767
Mukul Sharmabe846bb2017-05-09 17:41:52 +05309768 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) {
9769 hdd_err("Packet filter not supported in disconnected state");
9770 return -ENOTSUPP;
9771 }
9772
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009773 /* copy data using copy_from_user */
9774 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
9775 priv_data.length);
9776 if (NULL == request) {
9777 hdd_err("mem_alloc_copy_from_user_helper fail");
9778 return -ENOMEM;
9779 }
9780
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +05309781 if (request->filter_action == HDD_RCV_FILTER_SET)
9782 hdd_ctx->user_configured_pkt_filter_rules |=
9783 1 << request->filter_id;
9784 else if (request->filter_action == HDD_RCV_FILTER_CLEAR)
9785 hdd_ctx->user_configured_pkt_filter_rules &=
9786 ~(1 << request->filter_id);
9787
Jeff Johnson1b780e42017-10-31 14:11:45 -07009788 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009789
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07009790 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309791 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009792 return ret;
9793}
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;
9809
9810 cds_ssr_protect(__func__);
9811 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
9812 cds_ssr_unprotect(__func__);
9813
9814 return ret;
9815}
9816#endif
9817
Jeff Johnsonced658b2018-03-08 09:54:01 -08009818struct hdd_statistics_priv {
9819 tCsrSummaryStatsInfo summary_stats;
9820 tCsrGlobalClassAStatsInfo class_a_stats;
9821 tCsrGlobalClassDStatsInfo class_d_stats;
9822};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009823
Jeff Johnsond37833f2018-03-07 14:22:44 -08009824/**
9825 * hdd_statistics_cb() - "Get statistics" callback function
Jeff Johnsonced658b2018-03-08 09:54:01 -08009826 * @stats: statistics payload
9827 * @context: opaque context originally passed to SME. HDD always passes
9828 * a cookie for the request context
Jeff Johnsond37833f2018-03-07 14:22:44 -08009829 *
9830 * Return: None
9831 */
Jeff Johnsonced658b2018-03-08 09:54:01 -08009832static void hdd_statistics_cb(void *stats, void *context)
Jeff Johnsond37833f2018-03-07 14:22:44 -08009833{
Jeff Johnsonced658b2018-03-08 09:54:01 -08009834 struct hdd_request *request;
9835 struct hdd_statistics_priv *priv;
9836 tCsrSummaryStatsInfo *summary_stats;
9837 tCsrGlobalClassAStatsInfo *class_a_stats;
9838 tCsrGlobalClassDStatsInfo *class_d_stats;
Jeff Johnsond37833f2018-03-07 14:22:44 -08009839
Jeff Johnsonced658b2018-03-08 09:54:01 -08009840 request = hdd_request_get(context);
9841 if (!request) {
9842 hdd_err("Obsolete request");
9843 return;
Jeff Johnsond37833f2018-03-07 14:22:44 -08009844 }
9845
Jeff Johnsonced658b2018-03-08 09:54:01 -08009846 priv = hdd_request_priv(request);
9847
9848 summary_stats = (tCsrSummaryStatsInfo *)stats;
9849 priv->summary_stats = *summary_stats;
9850
9851 class_a_stats = (tCsrGlobalClassAStatsInfo *)(summary_stats + 1);
9852 priv->class_a_stats = *class_a_stats;
9853
9854 class_d_stats = (tCsrGlobalClassDStatsInfo *)(class_a_stats + 1);
9855 priv->class_d_stats = *class_d_stats;
9856
9857 hdd_request_complete(request);
9858 hdd_request_put(request);
Jeff Johnsond37833f2018-03-07 14:22:44 -08009859}
9860
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009861static int __iw_get_statistics(struct net_device *dev,
9862 struct iw_request_info *info,
9863 union iwreq_data *wrqu, char *extra)
9864{
9865
Jeff Johnsonced658b2018-03-08 09:54:01 -08009866 QDF_STATUS status;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009867 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9868 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsonced658b2018-03-08 09:54:01 -08009869 struct hdd_station_ctx *sta_ctx;
9870 char *p;
9871 int tlen;
9872 tCsrSummaryStatsInfo *summary_stats =
9873 &(adapter->hdd_stats.summary_stat);
9874 tCsrGlobalClassAStatsInfo *class_a_stats =
9875 &(adapter->hdd_stats.class_a_stat);
9876 tCsrGlobalClassDStatsInfo *class_d_stats =
9877 &(adapter->hdd_stats.class_d_stat);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009878 int ret;
Jeff Johnsonced658b2018-03-08 09:54:01 -08009879 void *cookie;
9880 struct hdd_request *request;
9881 struct hdd_statistics_priv *priv;
9882 static const struct hdd_request_params params = {
9883 .priv_size = sizeof(*priv),
9884 .timeout_ms = WLAN_WAIT_TIME_STATS,
9885 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009886
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009887 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009888
9889 ret = wlan_hdd_validate_context(hdd_ctx);
9890 if (0 != ret)
9891 return ret;
9892
Jeff Johnson441e1f72017-02-07 08:50:49 -08009893 ret = hdd_check_private_wext_control(hdd_ctx, info);
9894 if (0 != ret)
9895 return ret;
9896
Jeff Johnsonced658b2018-03-08 09:54:01 -08009897 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
9898 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
9899 wrqu->data.length = 0;
9900 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009901 }
9902
Jeff Johnsonced658b2018-03-08 09:54:01 -08009903 request = hdd_request_alloc(&params);
9904 if (!request) {
9905 hdd_warn("request allocation failed");
9906 goto return_cached_stats;
9907 }
9908
9909 cookie = hdd_request_cookie(request);
9910
9911 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
9912 SME_SUMMARY_STATS |
9913 SME_GLOBAL_CLASSA_STATS |
9914 SME_GLOBAL_CLASSD_STATS,
9915 hdd_statistics_cb,
9916 sta_ctx->conn_info.staId[0],
9917 cookie, adapter->session_id);
9918
9919 if (QDF_STATUS_SUCCESS != status) {
9920 hdd_warn("Unable to retrieve SME statistics");
9921 goto put_request;
9922 }
9923
9924 /* request was sent -- wait for the response */
9925 ret = hdd_request_wait_for_response(request);
9926 if (ret) {
9927 hdd_err("Failed to wait for statistics, errno %d", ret);
9928 goto put_request;
9929 }
9930
9931 /* update the adapter cache with the fresh results */
9932 priv = hdd_request_priv(request);
9933 *summary_stats = priv->summary_stats;
9934 *class_a_stats = priv->class_a_stats;
9935 *class_d_stats = priv->class_d_stats;
9936
9937put_request:
9938 /*
9939 * either we never sent a request, we sent a request and
9940 * received a response or we sent a request and timed out.
9941 * regardless we are done with the request.
9942 */
9943 hdd_request_put(request);
9944
9945return_cached_stats:
9946 p = extra;
9947 tlen = 0;
9948
9949 FILL_TLV(p, WLAN_STATS_RETRY_CNT,
9950 sizeof(summary_stats->retry_cnt),
9951 &(summary_stats->retry_cnt[0]), tlen);
9952
9953 FILL_TLV(p, WLAN_STATS_MUL_RETRY_CNT,
9954 sizeof(summary_stats->multiple_retry_cnt),
9955 &(summary_stats->multiple_retry_cnt[0]), tlen);
9956
9957 FILL_TLV(p, WLAN_STATS_TX_FRM_CNT,
9958 sizeof(summary_stats->tx_frm_cnt),
9959 &(summary_stats->tx_frm_cnt[0]), tlen);
9960
9961 FILL_TLV(p, WLAN_STATS_RX_FRM_CNT,
9962 sizeof(summary_stats->rx_frm_cnt),
9963 &(summary_stats->rx_frm_cnt), tlen);
9964
9965 FILL_TLV(p, WLAN_STATS_FRM_DUP_CNT,
9966 sizeof(summary_stats->frm_dup_cnt),
9967 &(summary_stats->frm_dup_cnt), tlen);
9968
9969 FILL_TLV(p, WLAN_STATS_FAIL_CNT,
9970 sizeof(summary_stats->fail_cnt),
9971 &(summary_stats->fail_cnt[0]), tlen);
9972
9973 FILL_TLV(p, WLAN_STATS_RTS_FAIL_CNT,
9974 sizeof(summary_stats->rts_fail_cnt),
9975 &(summary_stats->rts_fail_cnt), tlen);
9976
9977 FILL_TLV(p, WLAN_STATS_ACK_FAIL_CNT,
9978 sizeof(summary_stats->ack_fail_cnt),
9979 &(summary_stats->ack_fail_cnt), tlen);
9980
9981 FILL_TLV(p, WLAN_STATS_RTS_SUC_CNT,
9982 sizeof(summary_stats->rts_succ_cnt),
9983 &(summary_stats->rts_succ_cnt), tlen);
9984
9985 FILL_TLV(p, WLAN_STATS_RX_DISCARD_CNT,
9986 sizeof(summary_stats->rx_discard_cnt),
9987 &(summary_stats->rx_discard_cnt), tlen);
9988
9989 FILL_TLV(p, WLAN_STATS_RX_ERROR_CNT,
9990 sizeof(summary_stats->rx_error_cnt),
9991 &(summary_stats->rx_error_cnt), tlen);
9992
9993 FILL_TLV(p, WLAN_STATS_TX_BYTE_CNT,
9994 sizeof(class_d_stats->tx_uc_byte_cnt[0]),
9995 &(class_d_stats->tx_uc_byte_cnt[0]), tlen);
9996
9997 FILL_TLV(p, WLAN_STATS_RX_BYTE_CNT,
9998 sizeof(class_d_stats->rx_byte_cnt),
9999 &(class_d_stats->rx_byte_cnt), tlen);
10000
10001 FILL_TLV(p, WLAN_STATS_RX_RATE,
10002 sizeof(class_d_stats->rx_rate),
10003 &(class_d_stats->rx_rate), tlen);
10004
10005 /* Transmit rate, in units of 500 kbit/sec */
10006 FILL_TLV(p, WLAN_STATS_TX_RATE,
10007 sizeof(class_a_stats->tx_rate),
10008 &(class_a_stats->tx_rate), tlen);
10009
10010 FILL_TLV(p, WLAN_STATS_RX_UC_BYTE_CNT,
10011 sizeof(class_d_stats->rx_uc_byte_cnt[0]),
10012 &(class_d_stats->rx_uc_byte_cnt[0]), tlen);
10013 FILL_TLV(p, WLAN_STATS_RX_MC_BYTE_CNT,
10014 sizeof(class_d_stats->rx_mc_byte_cnt),
10015 &(class_d_stats->rx_mc_byte_cnt), tlen);
10016 FILL_TLV(p, WLAN_STATS_RX_BC_BYTE_CNT,
10017 sizeof(class_d_stats->rx_bc_byte_cnt),
10018 &(class_d_stats->rx_bc_byte_cnt), tlen);
10019 FILL_TLV(p, WLAN_STATS_TX_UC_BYTE_CNT,
10020 sizeof(class_d_stats->tx_uc_byte_cnt[0]),
10021 &(class_d_stats->tx_uc_byte_cnt[0]), tlen);
10022 FILL_TLV(p, WLAN_STATS_TX_MC_BYTE_CNT,
10023 sizeof(class_d_stats->tx_mc_byte_cnt),
10024 &(class_d_stats->tx_mc_byte_cnt), tlen);
10025 FILL_TLV(p, WLAN_STATS_TX_BC_BYTE_CNT,
10026 sizeof(class_d_stats->tx_bc_byte_cnt),
10027 &(class_d_stats->tx_bc_byte_cnt), tlen);
10028
10029 wrqu->data.length = tlen;
10030
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010031 EXIT();
10032
10033 return 0;
10034}
10035
10036static int iw_get_statistics(struct net_device *dev,
10037 struct iw_request_info *info,
10038 union iwreq_data *wrqu, char *extra)
10039{
10040 int ret;
10041
10042 cds_ssr_protect(__func__);
10043 ret = __iw_get_statistics(dev, info, wrqu, extra);
10044 cds_ssr_unprotect(__func__);
10045
10046 return ret;
10047}
10048
10049#ifdef FEATURE_WLAN_SCAN_PNO
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010050/*Max Len for PNO notification*/
10051#define MAX_PNO_NOTIFY_LEN 100
Abhishek Singh0481d662017-04-11 18:20:11 +053010052static void found_pref_network_cb(struct wlan_objmgr_vdev *vdev,
10053 struct scan_event *event, void *args)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010054{
Abhishek Singh0481d662017-04-11 18:20:11 +053010055 struct vdev_osif_priv *osif_priv;
10056 struct wireless_dev *wdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010057 union iwreq_data wrqu;
10058 char buf[MAX_PNO_NOTIFY_LEN + 1];
10059
Abhishek Singh0481d662017-04-11 18:20:11 +053010060 wlan_vdev_obj_lock(vdev);
10061 osif_priv = wlan_vdev_get_ospriv(vdev);
10062 wlan_vdev_obj_unlock(vdev);
10063 if (!osif_priv) {
10064 hdd_err("osif_priv is null");
10065 return;
10066 }
10067
10068 wdev = osif_priv->wdev;
10069 if (!wdev) {
10070 hdd_err("wdev is null");
10071 return;
10072 }
10073
10074 hdd_debug("A preferred network was found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010075
10076 /* create the event */
Abhishek Singh0481d662017-04-11 18:20:11 +053010077 qdf_mem_zero(&wrqu, sizeof(wrqu));
10078 qdf_mem_zero(buf, sizeof(buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010079
10080 snprintf(buf, MAX_PNO_NOTIFY_LEN,
Abhishek Singh0481d662017-04-11 18:20:11 +053010081 "QCOM: Found preferred network:");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010082
10083 wrqu.data.pointer = buf;
10084 wrqu.data.length = strlen(buf);
10085
10086 /* send the event */
10087
Abhishek Singh0481d662017-04-11 18:20:11 +053010088 wireless_send_event(wdev->netdev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010089}
10090
10091/**
10092 * __iw_set_pno() - Preferred Network Offload ioctl handler
10093 * @dev: device upon which the ioctl was received
10094 * @info: ioctl request information
10095 * @wrqu: ioctl request data
10096 * @extra: ioctl extra data
10097 *
10098 * This function parses a Preferred Network Offload command
10099 * Input is string based and expected to be of the form:
10100 *
10101 * <enable(1) | disable(0)>
10102 * when enabling:
10103 * <number of networks>
10104 * for each network:
10105 * <ssid_len> <ssid> <authentication> <encryption>
10106 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070010107 * <scan_time (seconds)>
10108 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010109 * <suspend mode>
10110 *
10111 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070010112 * 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 -080010113 *
10114 * this translates into:
10115 * -----------------------------
10116 * enable PNO
10117 * 2 networks
10118 * Network 1:
10119 * test - with authentication type 0 and encryption type 0,
10120 * search on 3 channels: 1 6 and 11,
10121 * SSID bcast type is unknown (directed probe will be sent if
10122 * AP not found) and must meet -40dBm RSSI
10123 * Network 2:
10124 * test2 - with authentication type 4 and encryption type 4,
10125 * search on 6 channels 1, 2, 3, 4, 5 and 6
10126 * bcast type is non-bcast (directed probe will be sent)
10127 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010128 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070010129 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010130 */
10131static int __iw_set_pno(struct net_device *dev,
10132 struct iw_request_info *info,
10133 union iwreq_data *wrqu, char *extra)
10134{
Jeff Johnson3d278b02017-08-29 14:17:47 -070010135 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010136 struct hdd_context *hdd_ctx;
Abhishek Singh0481d662017-04-11 18:20:11 +053010137 uint8_t value;
10138 struct wlan_objmgr_vdev *vdev;
10139 struct wlan_objmgr_psoc *psoc;
10140 int ret = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010141 int offset;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010142 char *ptr, *data;
Abhishek Singh0481d662017-04-11 18:20:11 +053010143 uint8_t i, j, params;
10144 QDF_STATUS status;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010145 size_t len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010146
10147 /* request is a large struct, so we make it static to avoid
10148 * stack overflow. This API is only invoked via ioctl, so it
10149 * is serialized by the kernel rtnl_lock and hence does not
10150 * need to be reentrant
10151 */
Abhishek Singh0481d662017-04-11 18:20:11 +053010152 static struct pno_scan_req_params req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010153
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010154 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010155
10156 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10157 ret = wlan_hdd_validate_context(hdd_ctx);
10158 if (ret)
10159 return ret;
10160
Jeff Johnson441e1f72017-02-07 08:50:49 -080010161 ret = hdd_check_private_wext_control(hdd_ctx, info);
10162 if (0 != ret)
10163 return ret;
10164
Abhishek Singh0481d662017-04-11 18:20:11 +053010165 vdev = wlan_objmgr_get_vdev_by_macaddr_from_pdev(hdd_ctx->hdd_pdev,
10166 dev->dev_addr, WLAN_LEGACY_MAC_ID);
10167 if (!vdev) {
10168 hdd_err("vdev object is NULL");
10169 return -EIO;
10170 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010171
Abhishek Singh0481d662017-04-11 18:20:11 +053010172 hdd_debug("PNO data len %d data %s", wrqu->data.length, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010173
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010174 /* making sure argument string ends with '\0' */
10175 len = (wrqu->data.length + 1);
10176 data = qdf_mem_malloc(len);
10177 if (!data) {
10178 hdd_err("fail to allocate memory %zu", len);
10179 return -EINVAL;
10180 }
10181 qdf_mem_copy(data, extra, (len-1));
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010182 ptr = data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010183
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010184 if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010185 hdd_err("PNO enable input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010186 ret = -EINVAL;
10187 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010188 }
10189
Abhishek Singh0481d662017-04-11 18:20:11 +053010190 if (!value) {
10191 status = ucfg_scan_pno_stop(vdev);
10192 if (QDF_IS_STATUS_ERROR(status)) {
10193 hdd_err("Failed to disabled PNO");
10194 ret = -EINVAL;
10195 } else {
10196 hdd_debug("PNO scan disabled");
10197 }
10198 goto exit;
10199 }
10200
10201 if (ucfg_scan_get_pno_in_progress(vdev)) {
10202 hdd_debug("pno is already in progress");
10203 ret = -EBUSY;
10204 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010205 }
10206
10207 ptr += offset;
10208
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010209 if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010210 hdd_err("PNO count input not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010211 ret = -EINVAL;
10212 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010213 }
Abhishek Singh0481d662017-04-11 18:20:11 +053010214 req.networks_cnt = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010215
Abhishek Singh0481d662017-04-11 18:20:11 +053010216 hdd_debug("PNO enable networks count %d offset %d",
10217 req.networks_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010218
Abhishek Singh0481d662017-04-11 18:20:11 +053010219 if ((0 == req.networks_cnt) ||
10220 (req.networks_cnt > SCAN_PNO_MAX_SUPP_NETWORKS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010221 hdd_err("Network count %d invalid",
Abhishek Singh0481d662017-04-11 18:20:11 +053010222 req.networks_cnt);
10223 ret = -EINVAL;
10224 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010225 }
10226
10227 ptr += offset;
10228
Abhishek Singh0481d662017-04-11 18:20:11 +053010229 for (i = 0; i < req.networks_cnt; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010230
Abhishek Singh0481d662017-04-11 18:20:11 +053010231 req.networks_list[i].ssid.length = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010232
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010233 params = sscanf(ptr, " %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010234 &(req.networks_list[i].ssid.length),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010235 &offset);
10236
10237 if (1 != params) {
10238 hdd_err("PNO ssid length input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010239 ret = -EINVAL;
10240 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010241 }
10242
Abhishek Singh0481d662017-04-11 18:20:11 +053010243 if ((0 == req.networks_list[i].ssid.length) ||
10244 (req.networks_list[i].ssid.length > 32)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010245 hdd_err("SSID Len %d is not correct for network %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010246 req.networks_list[i].ssid.length, i);
10247 ret = -EINVAL;
10248 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010249 }
10250
10251 /* Advance to SSID */
10252 ptr += offset;
10253
Abhishek Singh0481d662017-04-11 18:20:11 +053010254 memcpy(req.networks_list[i].ssid.ssid, ptr,
10255 req.networks_list[i].ssid.length);
10256 ptr += req.networks_list[i].ssid.length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010257
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010258 params = sscanf(ptr, " %u %u %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010259 &(req.networks_list[i].authentication),
10260 &(req.networks_list[i].encryption),
10261 &(req.networks_list[i].channel_cnt),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010262 &offset);
10263
10264 if (3 != params) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010265 hdd_err("Incorrect cmd %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010266 ret = -EINVAL;
10267 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010268 }
10269
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010270 hdd_debug("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010271 req.networks_list[i].ssid.length,
10272 req.networks_list[i].ssid.length,
10273 req.networks_list[i].ssid.ssid,
10274 req.networks_list[i].authentication,
10275 req.networks_list[i].encryption,
10276 req.networks_list[i].channel_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010277
10278 /* Advance to channel list */
10279 ptr += offset;
10280
Abhishek Singh0481d662017-04-11 18:20:11 +053010281 if (SCAN_PNO_MAX_NETW_CHANNELS_EX <
10282 req.networks_list[i].channel_cnt) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010283 hdd_err("Incorrect number of channels");
Abhishek Singh0481d662017-04-11 18:20:11 +053010284 ret = -EINVAL;
10285 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010286 }
10287
Abhishek Singh0481d662017-04-11 18:20:11 +053010288 if (0 != req.networks_list[i].channel_cnt) {
10289 for (j = 0; j < req.networks_list[i].channel_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010290 j++) {
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010291 if (1 != sscanf(ptr, " %hhu %n", &value,
Abhishek Singh0481d662017-04-11 18:20:11 +053010292 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010293 hdd_err("PNO network channel is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010294 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010295 ret = -EINVAL;
10296 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010297 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010298 if (!IS_CHANNEL_VALID(value)) {
10299 hdd_err("invalid channel: %hhu", value);
10300 ret = -EINVAL;
10301 goto exit;
10302 }
Abhishek Singh0481d662017-04-11 18:20:11 +053010303 req.networks_list[i].channels[j] =
10304 cds_chan_to_freq(value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010305 /* Advance to next channel number */
10306 ptr += offset;
10307 }
10308 }
10309
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010310 if (1 != sscanf(ptr, " %u %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010311 &(req.networks_list[i].bc_new_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010312 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010313 hdd_err("PNO broadcast network type 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 (req.networks_list[i].bc_new_type > 2) {
10319 hdd_err("invalid bcast nw type: %u",
10320 req.networks_list[i].bc_new_type);
10321 ret = -EINVAL;
10322 goto exit;
10323 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010324
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010325 hdd_debug("PNO bcastNetwType %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010326 req.networks_list[i].bc_new_type, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010327
10328 /* Advance to rssi Threshold */
10329 ptr += offset;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010330 if (1 != sscanf(ptr, " %d %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053010331 &(req.networks_list[i].rssi_thresh),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010332 &offset)) {
10333 hdd_err("PNO rssi threshold input is not valid %s",
10334 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053010335 ret = -EINVAL;
10336 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010337 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010338 hdd_debug("PNO rssi %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053010339 req.networks_list[i].rssi_thresh, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010340 /* Advance to next network */
10341 ptr += offset;
10342 } /* For ucNetworkCount */
10343
Abhishek Singh0481d662017-04-11 18:20:11 +053010344 req.fast_scan_period = 0;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010345 if (sscanf(ptr, " %u %n", &(req.fast_scan_period), &offset) > 0) {
Abhishek Singh0481d662017-04-11 18:20:11 +053010346 req.fast_scan_period *= MSEC_PER_SEC;
Dustin Brown43e87292016-10-10 10:38:25 -070010347 ptr += offset;
10348 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010349 if (req.fast_scan_period == 0) {
10350 hdd_err("invalid fast scan period %u",
10351 req.fast_scan_period);
10352 ret = -EINVAL;
10353 goto exit;
10354 }
Dustin Brown43e87292016-10-10 10:38:25 -070010355
Abhishek Singh0481d662017-04-11 18:20:11 +053010356 req.fast_scan_max_cycles = 0;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010357 if (sscanf(ptr, " %hhu %n", &value,
Dustin Brown43e87292016-10-10 10:38:25 -070010358 &offset) > 0)
10359 ptr += offset;
Abhishek Singh0481d662017-04-11 18:20:11 +053010360 req.fast_scan_max_cycles = value;
Dustin Brown43e87292016-10-10 10:38:25 -070010361
Abhishek Singh0481d662017-04-11 18:20:11 +053010362 wlan_pdev_obj_lock(hdd_ctx->hdd_pdev);
10363 psoc = wlan_pdev_get_psoc(hdd_ctx->hdd_pdev);
10364 wlan_pdev_obj_unlock(hdd_ctx->hdd_pdev);
10365 ucfg_scan_register_pno_cb(psoc,
10366 found_pref_network_cb, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010367
Abhishek Singh0481d662017-04-11 18:20:11 +053010368 ucfg_scan_get_pno_def_params(vdev, &req);
10369 status = ucfg_scan_pno_start(vdev, &req);
10370 if (QDF_IS_STATUS_ERROR(status)) {
10371 hdd_err("Failed to enable PNO");
10372 ret = -EINVAL;
10373 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010374
Abhishek Singh0481d662017-04-11 18:20:11 +053010375exit:
10376 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010377
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053010378 qdf_mem_free(data);
Abhishek Singh0481d662017-04-11 18:20:11 +053010379 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010380}
10381
10382static int iw_set_pno(struct net_device *dev,
10383 struct iw_request_info *info,
10384 union iwreq_data *wrqu, char *extra)
10385{
10386 int ret;
10387
10388 cds_ssr_protect(__func__);
10389 ret = __iw_set_pno(dev, info, wrqu, extra);
10390 cds_ssr_unprotect(__func__);
10391
10392 return ret;
10393}
10394#endif /* FEATURE_WLAN_SCAN_PNO */
10395
10396/* Common function to SetBand */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010397int hdd_reg_set_band(struct net_device *dev, u8 ui_band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010398{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010399 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
10400 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010401 enum band_info band;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010402 QDF_STATUS status;
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010403 struct hdd_context *hdd_ctx;
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010404 enum band_info currBand;
10405 enum band_info connectedBand;
10406 long lrc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010407
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010408 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010409
10410 switch (ui_band) {
10411 case WLAN_HDD_UI_BAND_AUTO:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010412 band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010413 break;
10414 case WLAN_HDD_UI_BAND_5_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010415 band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010416 break;
10417 case WLAN_HDD_UI_BAND_2_4_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010418 band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010419 break;
10420 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070010421 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010422 return -EINVAL;
10423 }
10424
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010425 hdd_debug("change band to %u", band);
10426
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010427 if ((band == BAND_2G && hdd_ctx->config->nBandCapability == 2) ||
Rajeev Kumar Sirasanagandla4c9b6752017-07-25 20:35:20 +053010428 (band == BAND_5G && hdd_ctx->config->nBandCapability == 1) ||
10429 (band == BAND_ALL && hdd_ctx->config->nBandCapability != 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010430 hdd_err("band value %u violate INI settings %u",
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010431 band, hdd_ctx->config->nBandCapability);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010432 return -EIO;
10433 }
10434
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010435 if (band == BAND_ALL) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010436 hdd_debug("Auto band received. Setting band same as ini value %d",
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010437 hdd_ctx->config->nBandCapability);
10438 band = hdd_ctx->config->nBandCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010439 }
10440
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010441 if (QDF_STATUS_SUCCESS != ucfg_reg_get_curr_band(hdd_ctx->hdd_pdev,
Amar Singhal58b45ef2017-08-01 13:43:54 -070010442 &currBand)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010443 hdd_debug("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010444 return -EIO;
10445 }
10446
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010447 if (currBand == band)
10448 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010449
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010450 hdd_ctx->curr_band = band;
Amar Singhal58b45ef2017-08-01 13:43:54 -070010451
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010452 /* Change band request received.
10453 * Abort pending scan requests, flush the existing scan results,
10454 * and change the band capability
10455 */
10456 hdd_debug("Current band value = %u, new setting %u ",
10457 currBand, band);
10458
Dustin Brown920397d2017-12-13 16:27:50 -080010459 hdd_for_each_adapter(hdd_ctx, adapter) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010460 hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010461 wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID,
Jeff Johnson1b780e42017-10-31 14:11:45 -070010462 adapter->session_id, INVALID_SCAN_ID, false);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010463 connectedBand = hdd_conn_get_connected_band(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010464 WLAN_HDD_GET_STATION_CTX_PTR(adapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010465
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010466 /* Handling is done only for STA and P2P */
10467 if (band != BAND_ALL &&
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010468 ((adapter->device_mode == QDF_STA_MODE) ||
10469 (adapter->device_mode == QDF_P2P_CLIENT_MODE)) &&
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010470 (hdd_conn_is_connected(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010471 WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010472 && (connectedBand != band)) {
10473 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010474
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010475 /* STA already connected on current
10476 * band, So issue disconnect first,
10477 * then change the band
10478 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010479
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010480 hdd_debug("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010481 hdd_device_mode_to_string(adapter->device_mode),
10482 adapter->device_mode, currBand, band);
10483 INIT_COMPLETION(adapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010484
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010485 status = sme_roam_disconnect(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010486 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -070010487 adapter->session_id,
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010488 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010489
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010490 if (QDF_STATUS_SUCCESS != status) {
10491 hdd_err("sme_roam_disconnect failure, status: %d",
Jeff Johnson99bac312016-06-28 10:38:18 -070010492 (int)status);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010493 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010494 }
10495
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010496 lrc = wait_for_completion_timeout(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010497 &adapter->disconnect_comp_var,
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010498 msecs_to_jiffies(
10499 WLAN_WAIT_TIME_DISCONNECT));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010500
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010501 if (lrc == 0) {
10502 hdd_err("Timeout while waiting for csr_roam_disconnect");
10503 return -ETIMEDOUT;
10504 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010505 }
10506
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010507 sme_scan_flush_result(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010508 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010509
Dustin Brown920397d2017-12-13 16:27:50 -080010510 if (QDF_IS_STATUS_ERROR(ucfg_reg_set_band(hdd_ctx->hdd_pdev, band))) {
10511 hdd_err("Failed to set the band value to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010512 return -EINVAL;
10513 }
10514
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010515 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010516}
10517
10518static int __iw_set_band_config(struct net_device *dev,
10519 struct iw_request_info *info,
10520 union iwreq_data *wrqu, char *extra)
10521{
Jeff Johnson3d278b02017-08-29 14:17:47 -070010522 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010523 struct hdd_context *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -080010524 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010525 int *value = (int *)extra;
10526
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010527 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010528
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010529 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010530 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053010531 return -EPERM;
10532 }
10533
Jeff Johnson441e1f72017-02-07 08:50:49 -080010534 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
10535 ret = hdd_check_private_wext_control(hdd_ctx, info);
10536 if (0 != ret)
10537 return ret;
10538
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070010539 return hdd_reg_set_band(dev, value[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010540}
10541
10542static int iw_set_band_config(struct net_device *dev,
10543 struct iw_request_info *info,
10544 union iwreq_data *wrqu, char *extra)
10545{
10546 int ret;
10547
10548 cds_ssr_protect(__func__);
10549 ret = __iw_set_band_config(dev, info, wrqu, extra);
10550 cds_ssr_unprotect(__func__);
10551
10552 return ret;
10553}
10554
Arunk Khandavalli062fb032017-10-04 12:18:15 +053010555int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010556 uint32_t bandwidth)
10557{
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010558 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -070010559 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010560 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
10561 QDF_STATUS status;
10562 tHalHandle hal_hdl = hdd_ctx->hHal;
10563 struct qdf_mac_addr bssid;
10564 tCsrRoamProfile roam_profile;
Amar Singhal5cccafe2017-02-15 12:42:58 -080010565 struct ch_params ch_params;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010566
10567 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
10568 hdd_err("Not supported, device is not in monitor mode");
10569 return -EINVAL;
10570 }
10571
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010572 hdd_debug("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080010573 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010574 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
10575 roam_profile.ChannelInfo.numOfChannels = 1;
10576 roam_profile.phyMode = ch_info->phy_mode;
10577 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070010578 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010579
Jeff Johnson1e851a12017-10-28 14:36:12 -070010580 qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010581 QDF_MAC_ADDR_SIZE);
10582
10583 ch_params.ch_width = bandwidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070010584 wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params);
Manjunathappa Prakashc4dc9382017-03-07 18:50:33 -080010585 if (ch_params.ch_width == CH_WIDTH_INVALID) {
10586 hdd_err("Invalid capture channel or bandwidth for a country");
10587 return -EINVAL;
10588 }
Krunal Sonied3bc8e2018-01-26 12:13:34 -080010589 if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan,
10590 POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) {
10591 hdd_err("Failed to change hw mode");
10592 return -EINVAL;
10593 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070010594
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010595 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
10596 &roam_profile);
10597 if (status) {
10598 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
10599 status);
10600 }
10601
Arunk Khandavalli062fb032017-10-04 12:18:15 +053010602 adapter->mon_chan = chan;
10603 adapter->mon_bandwidth = bandwidth;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010604 return qdf_status_to_os_return(status);
10605}
10606
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010607static int printk_adapter(void *priv, const char *fmt, ...)
10608{
10609 int ret;
10610 va_list args;
10611
10612 va_start(args, fmt);
10613 ret = vprintk(fmt, args);
10614 ret += printk("\n");
10615 va_end(args);
10616
10617 return ret;
10618}
10619
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010620static void hdd_ioctl_log_buffer(int log_id, uint32_t count)
10621{
10622 qdf_abstract_print *print = &printk_adapter;
10623
10624 switch (log_id) {
10625 case HTC_CREDIT_HISTORY_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010626 cds_print_htc_credit_history(count, print, NULL);
10627 break;
10628 case COMMAND_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010629 wma_print_wmi_cmd_log(count, print, NULL);
10630 break;
10631 case COMMAND_TX_CMP_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010632 wma_print_wmi_cmd_tx_cmp_log(count, print, NULL);
10633 break;
10634 case MGMT_COMMAND_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010635 wma_print_wmi_mgmt_cmd_log(count, print, NULL);
10636 break;
10637 case MGMT_COMMAND_TX_CMP_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010638 wma_print_wmi_mgmt_cmd_tx_cmp_log(count, print, NULL);
10639 break;
10640 case EVENT_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010641 wma_print_wmi_event_log(count, print, NULL);
10642 break;
10643 case RX_EVENT_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010644 wma_print_wmi_rx_event_log(count, print, NULL);
10645 break;
10646 case MGMT_EVENT_LOG:
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010647 wma_print_wmi_mgmt_event_log(count, print, NULL);
10648 break;
10649 default:
10650 print(NULL, "Invalid Log Id %d", log_id);
10651 break;
10652 }
10653}
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010654
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010655static int __iw_set_two_ints_getnone(struct net_device *dev,
10656 struct iw_request_info *info,
10657 union iwreq_data *wrqu, char *extra)
10658{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010659 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010660 int *value = (int *)extra;
10661 int sub_cmd = value[0];
10662 int ret;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010663 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010664
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010665 ENTER_DEV(dev);
10666
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010667 ret = wlan_hdd_validate_context(hdd_ctx);
10668 if (0 != ret)
10669 return ret;
10670
Jeff Johnson441e1f72017-02-07 08:50:49 -080010671 ret = hdd_check_private_wext_control(hdd_ctx, info);
10672 if (0 != ret)
10673 return ret;
10674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010675 switch (sub_cmd) {
10676 case WE_SET_SMPS_PARAM:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010677 hdd_debug("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Jeff Johnson1b780e42017-10-31 14:11:45 -070010678 ret = wma_cli_set_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010679 WMI_STA_SMPS_PARAM_CMDID,
10680 value[1] << WMA_SMPS_PARAM_VALUE_S
10681 | value[2],
10682 VDEV_CMD);
10683 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070010684#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010685 case WE_SET_FW_CRASH_INJECT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010686 hdd_debug("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053010688 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
10689 value[1], value[2]);
SaidiReddy Yenugacc733af2016-11-09 17:45:42 +053010690 if (!hdd_ctx->config->crash_inject_enabled) {
10691 hdd_err("Crash Inject ini disabled, Ignore Crash Inject");
10692 return 0;
10693 }
Yue Ma06152352017-06-20 18:08:58 -070010694 if (value[1] == 3) {
Anurag Chouhan4085ff72017-10-05 18:09:56 +053010695 cds_trigger_recovery(QDF_REASON_UNSPECIFIED);
Yue Ma06152352017-06-20 18:08:58 -070010696 return 0;
10697 }
Jeff Johnson1b780e42017-10-31 14:11:45 -070010698 ret = wma_cli_set2_command(adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010699 GEN_PARAM_CRASH_INJECT,
10700 value[1], value[2], GEN_CMD);
10701 break;
10702#endif
Govind Singha471e5e2015-10-12 17:11:14 +053010703 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010704 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010705 value[1], value[2]);
Jeff Johnson1b780e42017-10-31 14:11:45 -070010706 ret = wma_cli_set2_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +053010707 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
10708 value[1], value[2], DBG_CMD);
10709 break;
10710 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070010711 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053010712 value[1], value[2]);
Jeff Johnson1b780e42017-10-31 14:11:45 -070010713 ret = wma_cli_set2_command(adapter->session_id,
Govind Singha471e5e2015-10-12 17:11:14 +053010714 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
10715 value[1], value[2], DBG_CMD);
10716 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010717 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
10718 hdd_debug("Ioctl to set dual fw mode config");
Tushnim Bhattacharyya49ed8ab2017-05-26 18:20:10 -070010719 if (hdd_ctx->config->dual_mac_feature_disable ==
10720 DISABLE_DBS_CXN_AND_SCAN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010721 hdd_err("Dual mac feature is disabled from INI");
10722 return -EPERM;
10723 }
10724 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010725 policy_mgr_set_dual_mac_fw_mode_config(hdd_ctx->hdd_psoc,
10726 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010727 break;
10728 case WE_DUMP_DP_TRACE_LEVEL:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010729 hdd_debug("WE_DUMP_DP_TRACE_LEVEL: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010730 value[1], value[2]);
10731 if (value[1] == DUMP_DP_TRACE)
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -070010732 qdf_dp_trace_dump_all(value[2],
10733 QDF_TRACE_DEFAULT_PDEV_ID);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053010734 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
10735 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053010736 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
10737 qdf_dp_trace_clear_buffer();
Mohit Khannaf8f96822017-05-17 17:11:59 -070010738 else if (value[1] == DISABLE_DP_TRACE_LIVE_MODE)
10739 qdf_dp_trace_disable_live_mode();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010740 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010741 case WE_SET_MON_MODE_CHAN:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010742 ret = wlan_hdd_set_mon_chan(adapter, value[1], value[2]);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070010743 break;
Dustin Brown54096432017-02-23 13:00:44 -080010744 case WE_SET_WLAN_SUSPEND: {
Dustin Brown3ed3e9b2017-03-23 12:57:58 -070010745 hdd_info("STA unit-test suspend(%d, %d)", value[1], value[2]);
Dustin Brown54096432017-02-23 13:00:44 -080010746 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
10747 value[1], value[2]);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010748 break;
Dustin Brown54096432017-02-23 13:00:44 -080010749 }
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010750 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070010751 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070010752 break;
Dustin Brown8d2d0f52017-04-03 17:02:08 -070010753 case WE_LOG_BUFFER: {
10754 int log_id = value[1];
10755 uint32_t count = value[2] < 0 ? 0 : value[2];
10756
10757 hdd_ioctl_log_buffer(log_id, count);
10758
10759 break;
10760 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010761 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070010762 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010763 break;
10764 }
10765
10766 return ret;
10767}
10768
10769static int iw_set_two_ints_getnone(struct net_device *dev,
10770 struct iw_request_info *info,
10771 union iwreq_data *wrqu, char *extra)
10772{
10773 int ret;
10774
10775 cds_ssr_protect(__func__);
10776 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
10777 cds_ssr_unprotect(__func__);
10778
10779 return ret;
10780}
10781
10782/* Define the Wireless Extensions to the Linux Network Device structure */
10783/* A number of these routines are NULL (meaning they are not implemented.) */
10784
10785static const iw_handler we_handler[] = {
10786 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
10787 (iw_handler) iw_get_name, /* SIOCGIWNAME */
10788 (iw_handler) NULL, /* SIOCSIWNWID */
10789 (iw_handler) NULL, /* SIOCGIWNWID */
Jeff Johnson7b0f3a22017-10-15 21:25:28 -070010790 (iw_handler) NULL, /* SIOCSIWFREQ */
Jeff Johnson52002c02017-10-15 21:18:52 -070010791 (iw_handler) NULL, /* SIOCGIWFREQ */
Jeff Johnson31fd71a2017-10-15 21:13:09 -070010792 (iw_handler) NULL, /* SIOCSIWMODE */
Jeff Johnson88aa1a22017-10-15 21:06:34 -070010793 (iw_handler) NULL, /* SIOCGIWMODE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010794 (iw_handler) NULL, /* SIOCSIWSENS */
10795 (iw_handler) NULL, /* SIOCGIWSENS */
10796 (iw_handler) NULL, /* SIOCSIWRANGE */
10797 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
10798 (iw_handler) NULL, /* SIOCSIWPRIV */
10799 (iw_handler) NULL, /* SIOCGIWPRIV */
10800 (iw_handler) NULL, /* SIOCSIWSTATS */
10801 (iw_handler) NULL, /* SIOCGIWSTATS */
10802 (iw_handler) NULL, /* SIOCSIWSPY */
10803 (iw_handler) NULL, /* SIOCGIWSPY */
10804 (iw_handler) NULL, /* SIOCSIWTHRSPY */
10805 (iw_handler) NULL, /* SIOCGIWTHRSPY */
Jeff Johnson5ff10172017-10-15 18:45:27 -070010806 (iw_handler) NULL, /* SIOCSIWAP */
Jeff Johnsonb07d3ff2017-10-15 18:38:53 -070010807 (iw_handler) NULL, /* SIOCGIWAP */
Jeff Johnson2165afc2017-10-15 18:33:12 -070010808 (iw_handler) NULL, /* SIOCSIWMLME */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010809 (iw_handler) NULL, /* SIOCGIWAPLIST */
Jeff Johnsond73a5432017-10-15 18:12:52 -070010810 (iw_handler) NULL, /* SIOCSIWSCAN */
10811 (iw_handler) NULL, /* SIOCGIWSCAN */
10812 (iw_handler) NULL, /* SIOCSIWESSID */
Jeff Johnson3c6c0ef2017-10-15 17:59:14 -070010813 (iw_handler) NULL, /* SIOCGIWESSID */
Jeff Johnson90448a82017-10-15 16:35:25 -070010814 (iw_handler) NULL, /* SIOCSIWNICKN */
Jeff Johnson22ba2a42017-10-15 15:53:39 -070010815 (iw_handler) NULL, /* SIOCGIWNICKN */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010816 (iw_handler) NULL, /* -- hole -- */
10817 (iw_handler) NULL, /* -- hole -- */
Jeff Johnson64b26982017-10-15 15:48:38 -070010818 (iw_handler) NULL, /* SIOCSIWRATE */
Jeff Johnson7b5b8e72017-10-15 15:41:00 -070010819 (iw_handler) NULL, /* SIOCGIWRATE */
Jeff Johnsonf2316482017-10-15 14:57:02 -070010820 (iw_handler) NULL, /* SIOCSIWRTS */
Jeff Johnsona95d5ca2017-10-15 14:49:45 -070010821 (iw_handler) NULL, /* SIOCGIWRTS */
Jeff Johnson40d70102017-10-15 14:39:01 -070010822 (iw_handler) NULL, /* SIOCSIWFRAG */
Jeff Johnson75956d32017-10-15 13:53:36 -070010823 (iw_handler) NULL, /* SIOCGIWFRAG */
Jeff Johnson744676f2017-10-15 12:56:16 -070010824 (iw_handler) NULL, /* SIOCSIWTXPOW */
Jeff Johnson918d35e2017-10-15 12:50:26 -070010825 (iw_handler) NULL, /* SIOCGIWTXPOW */
Jeff Johnsond8995042017-10-15 12:45:45 -070010826 (iw_handler) NULL, /* SIOCSIWRETRY */
Jeff Johnson00367e22017-10-15 12:40:15 -070010827 (iw_handler) NULL, /* SIOCGIWRETRY */
Jeff Johnson140e07a2017-10-15 12:32:29 -070010828 (iw_handler) NULL, /* SIOCSIWENCODE */
Jeff Johnsone84e8d02017-10-15 12:22:58 -070010829 (iw_handler) NULL, /* SIOCGIWENCODE */
Jeff Johnson955e0582017-10-15 11:56:52 -070010830 (iw_handler) NULL, /* SIOCSIWPOWER */
Jeff Johnson330d8dc2017-10-15 11:43:13 -070010831 (iw_handler) NULL, /* SIOCGIWPOWER */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010832 (iw_handler) NULL, /* -- hole -- */
10833 (iw_handler) NULL, /* -- hole -- */
Jeff Johnson4bcdafa2017-10-15 11:33:42 -070010834 (iw_handler) NULL, /* SIOCSIWGENIE */
Jeff Johnsonf6562c62017-10-15 11:24:05 -070010835 (iw_handler) NULL, /* SIOCGIWGENIE */
Jeff Johnson079f7de2017-10-15 11:04:08 -070010836 (iw_handler) NULL, /* SIOCSIWAUTH */
Jeff Johnson4139b822017-10-15 10:55:03 -070010837 (iw_handler) NULL, /* SIOCGIWAUTH */
Jeff Johnson5b300822017-10-15 10:44:40 -070010838 (iw_handler) NULL, /* SIOCSIWENCODEEXT */
Jeff Johnson6b747052017-10-15 10:29:04 -070010839 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010840 (iw_handler) NULL, /* SIOCSIWPMKSA */
10841};
10842
10843static const iw_handler we_private[] = {
10844
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010845 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone,
10846 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint,
10847 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010848 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10849 iw_set_three_ints_getnone,
10850 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010851 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010852 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10853 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070010854 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
10855 iw_setnone_get_threeint,
Nirav Shaheb017be2018-02-15 11:20:58 +053010856#ifdef WLAN_FEATURE_FIPS
Jeff Johnson6fa1e012017-04-05 06:40:53 -070010857 [WLAN_PRIV_FIPS_TEST - SIOCIWFIRSTPRIV] = hdd_fips_test,
Nirav Shaheb017be2018-02-15 11:20:58 +053010858#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010859 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
10860 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
10861 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010862 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010863 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
10864 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
10865 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
10866 iw_set_keepalive_params,
10867#ifdef WLAN_FEATURE_PACKET_FILTERING
10868 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
10869 iw_set_packet_filter_params,
10870#endif
10871#ifdef FEATURE_WLAN_SCAN_PNO
10872 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
10873#endif
10874 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080010875 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
10876 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010877 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
10878 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
10879 iw_set_two_ints_getnone,
10880 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
10881 iw_set_dot11p_channel_sched,
10882};
10883
10884/*Maximum command length can be only 15 */
10885static const struct iw_priv_args we_private_args[] = {
10886
10887 /* handlers for main ioctl */
10888 {WLAN_PRIV_SET_INT_GET_NONE,
10889 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10890 0,
10891 ""},
10892
10893 /* handlers for sub-ioctl */
10894 {WE_SET_11D_STATE,
10895 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10896 0,
10897 "set11Dstate"},
10898
10899 {WE_WOWL,
10900 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10901 0,
10902 "wowl"},
10903
10904 {WE_SET_POWER,
10905 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10906 0,
10907 "setPower"},
10908
10909 {WE_SET_MAX_ASSOC,
10910 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10911 0,
10912 "setMaxAssoc"},
10913
10914 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
10915 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
10916 "setAutoChannel" },
10917
10918 {WE_SET_SCAN_DISABLE,
10919 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10920 0,
10921 "scan_disable"},
10922
10923 {WE_SET_DATA_INACTIVITY_TO,
10924 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10925 0,
10926 "inactivityTO"},
10927
Mukul Sharmaed92f2f2017-04-20 00:06:28 +053010928 {WE_SET_WOW_DATA_INACTIVITY_TO,
10929 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10930 0,
10931 "wow_ito"},
10932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010933 {WE_SET_MAX_TX_POWER,
10934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10935 0,
10936 "setMaxTxPower"},
10937
10938 {WE_SET_TX_POWER,
10939 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10940 0,
10941 "setTxPower"},
10942
10943 {WE_SET_MC_RATE,
10944 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10945 0,
10946 "setMcRate"},
10947
10948 {WE_SET_MAX_TX_POWER_2_4,
10949 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10950 0,
10951 "setTxMaxPower2G"},
10952
10953 {WE_SET_MAX_TX_POWER_5_0,
10954 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10955 0,
10956 "setTxMaxPower5G"},
10957
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010958 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010959 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080010960 0,
10961 "pktlog"},
10962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010963 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
10964 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080010965 * will support both
10966 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010967 {WE_SET_MAX_TX_POWER,
10968 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10969 0,
10970 "setTxMaxPower"},
10971
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010972 {WE_SET_TM_LEVEL,
10973 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10974 0,
10975 "setTmLevel"},
10976
10977 {WE_SET_PHYMODE,
10978 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10979 0,
10980 "setphymode"},
10981
10982 {WE_SET_NSS,
10983 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10984 0,
10985 "nss"},
10986
10987 {WE_SET_LDPC,
10988 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10989 0,
10990 "ldpc"},
10991
10992 {WE_SET_TX_STBC,
10993 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10994 0,
10995 "tx_stbc"},
10996
10997 {WE_SET_RX_STBC,
10998 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
10999 0,
11000 "rx_stbc"},
11001
11002 {WE_SET_SHORT_GI,
11003 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11004 0,
11005 "shortgi"},
11006
11007 {WE_SET_RTSCTS,
11008 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11009 0,
11010 "enablertscts"},
11011
11012 {WE_SET_CHWIDTH,
11013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11014 0,
11015 "chwidth"},
11016
11017 {WE_SET_ANI_EN_DIS,
11018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11019 0,
11020 "anienable"},
11021
11022 {WE_SET_ANI_POLL_PERIOD,
11023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11024 0,
11025 "aniplen"},
11026
11027 {WE_SET_ANI_LISTEN_PERIOD,
11028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11029 0,
11030 "anilislen"},
11031
11032 {WE_SET_ANI_OFDM_LEVEL,
11033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11034 0,
11035 "aniofdmlvl"},
11036
11037 {WE_SET_ANI_CCK_LEVEL,
11038 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11039 0,
11040 "aniccklvl"},
11041
11042 {WE_SET_DYNAMIC_BW,
11043 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11044 0,
11045 "cwmenable"},
11046
11047 {WE_SET_CTS_CBW,
11048 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11049 0,
11050 "cts_cbw" },
11051
11052 {WE_SET_GTX_HT_MCS,
11053 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11054 0,
11055 "gtxHTMcs"},
11056
11057 {WE_SET_GTX_VHT_MCS,
11058 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11059 0,
11060 "gtxVHTMcs"},
11061
11062 {WE_SET_GTX_USRCFG,
11063 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11064 0,
11065 "gtxUsrCfg"},
11066
11067 {WE_SET_GTX_THRE,
11068 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11069 0,
11070 "gtxThre"},
11071
11072 {WE_SET_GTX_MARGIN,
11073 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11074 0,
11075 "gtxMargin"},
11076
11077 {WE_SET_GTX_STEP,
11078 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11079 0,
11080 "gtxStep"},
11081
11082 {WE_SET_GTX_MINTPC,
11083 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11084 0,
11085 "gtxMinTpc"},
11086
11087 {WE_SET_GTX_BWMASK,
11088 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11089 0,
11090 "gtxBWMask"},
11091
11092 {WE_SET_TX_CHAINMASK,
11093 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11094 0,
11095 "txchainmask"},
11096
11097 {WE_SET_RX_CHAINMASK,
11098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11099 0,
11100 "rxchainmask"},
11101
11102 {WE_SET_11N_RATE,
11103 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11104 0,
11105 "set11NRates"},
11106
11107 {WE_SET_VHT_RATE,
11108 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11109 0,
11110 "set11ACRates"},
11111
11112 {WE_SET_AMPDU,
11113 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11114 0,
11115 "ampdu"},
11116
11117 {WE_SET_AMSDU,
11118 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11119 0,
11120 "amsdu"},
11121
11122 {WE_SET_BURST_ENABLE,
11123 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11124 0,
11125 "burst_enable"},
11126
11127 {WE_SET_BURST_DUR,
11128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11129 0,
11130 "burst_dur"},
11131
11132 {WE_SET_TXPOW_2G,
11133 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11134 0,
11135 "txpow2g"},
11136
11137 {WE_SET_TXPOW_5G,
11138 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11139 0,
11140 "txpow5g"},
11141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011142 /* Sub-cmds DBGLOG specific commands */
11143 {WE_DBGLOG_LOG_LEVEL,
11144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11145 0,
11146 "dl_loglevel"},
11147
11148 {WE_DBGLOG_VAP_ENABLE,
11149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11150 0,
11151 "dl_vapon"},
11152
11153 {WE_DBGLOG_VAP_DISABLE,
11154 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11155 0,
11156 "dl_vapoff"},
11157
11158 {WE_DBGLOG_MODULE_ENABLE,
11159 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11160 0,
11161 "dl_modon"},
11162
11163 {WE_DBGLOG_MODULE_DISABLE,
11164 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11165 0,
11166 "dl_modoff"},
11167
11168 {WE_DBGLOG_MOD_LOG_LEVEL,
11169 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11170 0,
11171 "dl_mod_loglevel"},
11172
11173 {WE_DBGLOG_TYPE,
11174 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11175 0,
11176 "dl_type"},
11177 {WE_DBGLOG_REPORT_ENABLE,
11178 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11179 0,
11180 "dl_report"},
11181
11182 {WE_SET_TXRX_FWSTATS,
11183 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11184 0,
11185 "txrx_fw_stats"},
11186
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080011187 {WE_SET_TXRX_STATS,
11188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11189 0,
11190 "txrx_stats"},
11191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011192 {WE_TXRX_FWSTATS_RESET,
11193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11194 0,
11195 "txrx_fw_st_rst"},
11196
11197 {WE_PPS_PAID_MATCH,
11198 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11199 0, "paid_match"},
11200
11201 {WE_PPS_GID_MATCH,
11202 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11203 0, "gid_match"},
11204
11205 {WE_PPS_EARLY_TIM_CLEAR,
11206 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11207 0, "tim_clear"},
11208
11209 {WE_PPS_EARLY_DTIM_CLEAR,
11210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11211 0, "dtim_clear"},
11212
11213 {WE_PPS_EOF_PAD_DELIM,
11214 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11215 0, "eof_delim"},
11216
11217 {WE_PPS_MACADDR_MISMATCH,
11218 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11219 0, "mac_match"},
11220
11221 {WE_PPS_DELIM_CRC_FAIL,
11222 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11223 0, "delim_fail"},
11224
11225 {WE_PPS_GID_NSTS_ZERO,
11226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11227 0, "nsts_zero"},
11228
11229 {WE_PPS_RSSI_CHECK,
11230 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11231 0, "rssi_chk"},
11232
11233 {WE_PPS_5G_EBT,
11234 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11235 0, "5g_ebt"},
11236
11237 {WE_SET_HTSMPS,
11238 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11239 0, "htsmps"},
11240
11241 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
11242 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11243 0, "set_qpspollcnt"},
11244
11245 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
11246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11247 0, "set_qtxwake"},
11248
11249 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
11250 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11251 0, "set_qwakeintv"},
11252
11253 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
11254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11255 0, "set_qnodatapoll"},
11256
11257 /* handlers for MCC time quota and latency sub ioctls */
11258 {WE_MCC_CONFIG_LATENCY,
11259 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11260 0, "setMccLatency"},
11261
11262 {WE_MCC_CONFIG_QUOTA,
11263 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11264 0, "setMccQuota"},
11265
11266 {WE_SET_DEBUG_LOG,
11267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11268 0, "setDbgLvl"},
11269
11270 /* handlers for early_rx power save */
11271 {WE_SET_EARLY_RX_ADJUST_ENABLE,
11272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11273 0, "erx_enable"},
11274
11275 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
11276 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11277 0, "erx_bmiss_val"},
11278
11279 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
11280 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11281 0, "erx_bmiss_smpl"},
11282
11283 {WE_SET_EARLY_RX_SLOP_STEP,
11284 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11285 0, "erx_slop_step"},
11286
11287 {WE_SET_EARLY_RX_INIT_SLOP,
11288 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11289 0, "erx_init_slop"},
11290
11291 {WE_SET_EARLY_RX_ADJUST_PAUSE,
11292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11293 0, "erx_adj_pause"},
11294
11295 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
11296 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11297 0, "erx_dri_sample"},
11298
11299 {WE_DUMP_STATS,
11300 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11301 0, "dumpStats"},
11302
11303 {WE_CLEAR_STATS,
11304 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11305 0, "clearStats"},
11306
Govind Singha471e5e2015-10-12 17:11:14 +053011307 {WE_START_FW_PROFILE,
11308 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11309 0, "startProfile"},
11310
Abhishek Singh1bdb1572015-10-16 16:24:19 +053011311 {WE_SET_CHANNEL,
11312 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11313 0, "setChanChange" },
11314
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053011315 {WE_SET_CONC_SYSTEM_PREF,
11316 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11317 0, "setConcSysPref" },
11318
Jeff Johnson011c4502017-10-05 15:25:56 -070011319 {WE_SET_PDEV_RESET,
11320 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11321 0, "pdev_reset" },
11322
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +053011323 {WE_SET_MODULATED_DTIM,
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -080011324 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11325 0, "setModDTIM" },
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +053011326
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011327 {WLAN_PRIV_SET_NONE_GET_INT,
11328 0,
11329 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11330 ""},
11331
11332 /* handlers for sub-ioctl */
11333 {WE_GET_11D_STATE,
11334 0,
11335 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11336 "get11Dstate"},
11337
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011338 {WE_GET_WLAN_DBG,
11339 0,
11340 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11341 "getwlandbg"},
11342
11343 {WE_GET_MAX_ASSOC,
11344 0,
11345 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11346 "getMaxAssoc"},
11347
11348 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
11349 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11350 "getAutoChannel" },
11351
11352 {WE_GET_CONCURRENCY_MODE,
11353 0,
11354 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11355 "getconcurrency"},
11356
11357 {WE_GET_NSS,
11358 0,
11359 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11360 "get_nss"},
11361
11362 {WE_GET_LDPC,
11363 0,
11364 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11365 "get_ldpc"},
11366
11367 {WE_GET_TX_STBC,
11368 0,
11369 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11370 "get_tx_stbc"},
11371
11372 {WE_GET_RX_STBC,
11373 0,
11374 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11375 "get_rx_stbc"},
11376
11377 {WE_GET_SHORT_GI,
11378 0,
11379 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11380 "get_shortgi"},
11381
11382 {WE_GET_RTSCTS,
11383 0,
11384 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11385 "get_rtscts"},
11386
11387 {WE_GET_CHWIDTH,
11388 0,
11389 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11390 "get_chwidth"},
11391
11392 {WE_GET_ANI_EN_DIS,
11393 0,
11394 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11395 "get_anienable"},
11396
11397 {WE_GET_ANI_POLL_PERIOD,
11398 0,
11399 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11400 "get_aniplen"},
11401
11402 {WE_GET_ANI_LISTEN_PERIOD,
11403 0,
11404 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11405 "get_anilislen"},
11406
11407 {WE_GET_ANI_OFDM_LEVEL,
11408 0,
11409 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11410 "get_aniofdmlvl"},
11411
11412 {WE_GET_ANI_CCK_LEVEL,
11413 0,
11414 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11415 "get_aniccklvl"},
11416
11417 {WE_GET_DYNAMIC_BW,
11418 0,
11419 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11420 "get_cwmenable"},
11421
11422 {WE_GET_GTX_HT_MCS,
11423 0,
11424 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11425 "get_gtxHTMcs"},
11426
11427 {WE_GET_GTX_VHT_MCS,
11428 0,
11429 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11430 "get_gtxVHTMcs"},
11431
11432 {WE_GET_GTX_USRCFG,
11433 0,
11434 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11435 "get_gtxUsrCfg"},
11436
11437 {WE_GET_GTX_THRE,
11438 0,
11439 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11440 "get_gtxThre"},
11441
11442 {WE_GET_GTX_MARGIN,
11443 0,
11444 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11445 "get_gtxMargin"},
11446
11447 {WE_GET_GTX_STEP,
11448 0,
11449 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11450 "get_gtxStep"},
11451
11452 {WE_GET_GTX_MINTPC,
11453 0,
11454 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11455 "get_gtxMinTpc"},
11456
11457 {WE_GET_GTX_BWMASK,
11458 0,
11459 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11460 "get_gtxBWMask"},
11461
11462 {WE_GET_TX_CHAINMASK,
11463 0,
11464 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11465 "get_txchainmask"},
11466
11467 {WE_GET_RX_CHAINMASK,
11468 0,
11469 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11470 "get_rxchainmask"},
11471
11472 {WE_GET_11N_RATE,
11473 0,
11474 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11475 "get_11nrate"},
11476
11477 {WE_GET_AMPDU,
11478 0,
11479 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11480 "get_ampdu"},
11481
11482 {WE_GET_AMSDU,
11483 0,
11484 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11485 "get_amsdu"},
11486
11487 {WE_GET_BURST_ENABLE,
11488 0,
11489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11490 "get_burst_en"},
11491
11492 {WE_GET_BURST_DUR,
11493 0,
11494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11495 "get_burst_dur"},
11496
11497 {WE_GET_TXPOW_2G,
11498 0,
11499 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11500 "get_txpow2g"},
11501
11502 {WE_GET_TXPOW_5G,
11503 0,
11504 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11505 "get_txpow5g"},
11506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011507 {WE_GET_PPS_PAID_MATCH,
11508 0,
11509 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11510 "get_paid_match"},
11511
11512 {WE_GET_PPS_GID_MATCH,
11513 0,
11514 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11515 "get_gid_match"},
11516
11517 {WE_GET_PPS_EARLY_TIM_CLEAR,
11518 0,
11519 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11520 "get_tim_clear"},
11521
11522 {WE_GET_PPS_EARLY_DTIM_CLEAR,
11523 0,
11524 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11525 "get_dtim_clear"},
11526
11527 {WE_GET_PPS_EOF_PAD_DELIM,
11528 0,
11529 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11530 "get_eof_delim"},
11531
11532 {WE_GET_PPS_MACADDR_MISMATCH,
11533 0,
11534 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11535 "get_mac_match"},
11536
11537 {WE_GET_PPS_DELIM_CRC_FAIL,
11538 0,
11539 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11540 "get_delim_fail"},
11541
11542 {WE_GET_PPS_GID_NSTS_ZERO,
11543 0,
11544 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11545 "get_nsts_zero"},
11546
11547 {WE_GET_PPS_RSSI_CHECK,
11548 0,
11549 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11550 "get_rssi_chk"},
11551
11552 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
11553 0,
11554 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11555 "get_qpspollcnt"},
11556
11557 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
11558 0,
11559 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11560 "get_qtxwake"},
11561
11562 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
11563 0,
11564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11565 "get_qwakeintv"},
11566
11567 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
11568 0,
11569 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11570 "get_qnodatapoll"},
11571
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011572 {WE_CAP_TSF,
11573 0,
11574 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11575 "cap_tsf"},
11576
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011577 {WE_GET_TEMPERATURE,
11578 0,
11579 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11580 "get_temp"},
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070011581 {WE_GET_DCM,
11582 0,
11583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11584 "get_dcm"},
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070011585 {WE_GET_RANGE_EXT,
11586 0,
11587 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11588 "get_range_ext"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011589 /* handlers for main ioctl */
11590 {WLAN_PRIV_SET_CHAR_GET_NONE,
11591 IW_PRIV_TYPE_CHAR | 512,
11592 0,
11593 ""},
11594
11595 /* handlers for sub-ioctl */
11596 {WE_WOWL_ADD_PTRN,
11597 IW_PRIV_TYPE_CHAR | 512,
11598 0,
11599 "wowlAddPtrn"},
11600
11601 {WE_WOWL_DEL_PTRN,
11602 IW_PRIV_TYPE_CHAR | 512,
11603 0,
11604 "wowlDelPtrn"},
11605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011606 /* handlers for sub-ioctl */
11607 {WE_NEIGHBOR_REPORT_REQUEST,
11608 IW_PRIV_TYPE_CHAR | 512,
11609 0,
11610 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080011611
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011612 {WE_SET_AP_WPS_IE,
11613 IW_PRIV_TYPE_CHAR | 512,
11614 0,
11615 "set_ap_wps_ie"},
11616
11617 {WE_SET_CONFIG,
11618 IW_PRIV_TYPE_CHAR | 512,
11619 0,
11620 "setConfig"},
11621
11622 /* handlers for main ioctl */
11623 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
11624 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11625 0,
11626 ""},
11627
11628 /* handlers for sub-ioctl */
11629 {WE_SET_WLAN_DBG,
11630 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11631 0,
11632 "setwlandbg"},
11633
11634 /* handlers for sub-ioctl */
11635 {WE_SET_DP_TRACE,
11636 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11637 0,
11638 "set_dp_trace"},
11639
11640 {WE_SET_SAP_CHANNELS,
11641 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11642 0,
11643 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053011644
11645 {WE_SET_FW_TEST,
11646 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11647 0, "fw_test"},
11648
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070011649 /* handlers for main ioctl */
11650 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
11651 0,
11652 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11653 "" },
11654 {WE_GET_TSF,
11655 0,
11656 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11657 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011658
11659 {WE_SET_DUAL_MAC_SCAN_CONFIG,
11660 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
11661 0,
11662 "set_scan_cfg"},
11663
11664 /* handlers for main ioctl */
11665 {WLAN_PRIV_GET_CHAR_SET_NONE,
11666 0,
11667 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11668 ""},
11669
11670 /* handlers for sub-ioctl */
11671 {WE_WLAN_VERSION,
11672 0,
11673 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11674 "version"},
11675 {WE_GET_STATS,
11676 0,
11677 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11678 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080011679 {WE_GET_SUSPEND_RESUME_STATS,
11680 0,
11681 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11682 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053011683 {WE_LIST_FW_PROFILE,
11684 0,
11685 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11686 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011687 {WE_GET_STATES,
11688 0,
11689 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11690 "getHostStates"},
11691 {WE_GET_CFG,
11692 0,
11693 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11694 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011695 {WE_GET_RSSI,
11696 0,
11697 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11698 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011699 {WE_GET_WMM_STATUS,
11700 0,
11701 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11702 "getWmmStatus"},
11703 {
11704 WE_GET_CHANNEL_LIST,
11705 0,
11706 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11707 "getChannelList"
11708 },
11709#ifdef FEATURE_WLAN_TDLS
11710 {
11711 WE_GET_TDLS_PEERS,
11712 0,
11713 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11714 "getTdlsPeers"
11715 },
11716#endif
11717#ifdef WLAN_FEATURE_11W
11718 {
11719 WE_GET_11W_INFO,
11720 0,
11721 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11722 "getPMFInfo"
11723 },
11724#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011725 {
11726 WE_GET_IBSS_STA_INFO,
11727 0,
11728 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11729 "getIbssSTAs"
11730 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011731 {WE_GET_PHYMODE,
11732 0,
11733 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11734 "getphymode"},
Naveen Rawat910726a2017-03-06 11:42:51 -080011735#if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011736 {WE_GET_OEM_DATA_CAP,
11737 0,
11738 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11739 "getOemDataCap"},
Naveen Rawat910726a2017-03-06 11:42:51 -080011740#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011741 {WE_GET_SNR,
11742 0,
11743 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11744 "getSNR"},
11745
11746 /* handlers for main ioctl */
11747 {WLAN_PRIV_SET_NONE_GET_NONE,
11748 0,
11749 0,
11750 ""},
11751
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011752 /* handlers for sub-ioctl */
11753 {
11754 WE_IBSS_GET_PEER_INFO_ALL,
11755 0,
11756 0,
11757 "ibssPeerInfoAll"
11758 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011759 {WE_GET_RECOVERY_STAT,
11760 0,
11761 0,
11762 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053011763
11764 {WE_GET_FW_PROFILE_DATA,
11765 0,
11766 0,
11767 "getProfileData"},
11768
11769 {WE_SET_REASSOC_TRIGGER,
11770 0,
11771 0,
11772 "reassoc"},
11773
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080011774 {WE_STOP_OBSS_SCAN,
11775 0,
11776 0,
11777 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011778 /* handlers for main ioctl */
11779 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
11780 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11781 0,
11782 ""},
11783
11784 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011785 {WE_IBSS_GET_PEER_INFO,
11786 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11787 0,
11788 "ibssPeerInfo"},
11789
11790 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011791 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
11792 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11793 0,
11794 "setdumplog"},
11795
11796 {WE_MTRACE_DUMP_CMD,
11797 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11798 0,
11799 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080011800
11801 {WE_POLICY_MANAGER_CINFO_CMD,
11802 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11803 0,
11804 "pm_cinfo"},
11805
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011806#ifdef MPC_UT_FRAMEWORK
11807 {WE_POLICY_MANAGER_CLIST_CMD,
11808 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11809 0,
11810 "pm_clist"},
11811
11812 {WE_POLICY_MANAGER_DLIST_CMD,
11813 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11814 0,
11815 "pm_dlist"},
11816
11817 {WE_POLICY_MANAGER_DBS_CMD,
11818 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11819 0,
11820 "pm_dbs"},
11821
11822 {WE_POLICY_MANAGER_PCL_CMD,
11823 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11824 0,
11825 "pm_pcl"},
11826
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011827 {WE_POLICY_MANAGER_ULIST_CMD,
11828 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11829 0,
11830 "pm_ulist"},
11831
11832 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
11833 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11834 0,
11835 "pm_query_action"},
11836
11837 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
11838 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11839 0,
11840 "pm_query_allow"},
11841
11842 {WE_POLICY_MANAGER_SCENARIO_CMD,
11843 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11844 0,
11845 "pm_run_scenario"},
11846
11847 {WE_POLICY_SET_HW_MODE_CMD,
11848 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11849 0,
11850 "pm_set_hw_mode"},
11851#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011852 {
11853 WE_UNIT_TEST_CMD,
11854 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11855 0,
11856 "setUnitTestCmd"
11857 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053011858 {
11859 WE_MAC_PWR_DEBUG_CMD,
11860 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11861 0,
11862 "halPwrDebug"
11863 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011864
11865#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11866 {WE_LED_FLASHING_PARAM,
11867 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11868 0,
11869 "gpio_control"},
11870#endif
Liangwei Dong2a7f2912018-02-07 17:08:17 +080011871#ifdef WLAN_DEBUG
11872 {WE_SET_CHAN_AVOID,
11873 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
11874 0,
11875 "ch_avoid"},
11876#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011877 /* handlers for main ioctl */
Jeff Johnson6fa1e012017-04-05 06:40:53 -070011878 {WLAN_PRIV_FIPS_TEST,
11879 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11880 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11881 "fips_test"},
11882
11883 /* handlers for main ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011884 {WLAN_PRIV_ADD_TSPEC,
11885 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
11886 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11887 "addTspec"},
11888
11889 /* handlers for main ioctl */
11890 {WLAN_PRIV_DEL_TSPEC,
11891 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11892 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11893 "delTspec"},
11894
11895 /* handlers for main ioctl */
11896 {WLAN_PRIV_GET_TSPEC,
11897 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11898 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11899 "getTspec"},
11900
11901 /* handlers for main ioctl - host offload */
11902 {
11903 WLAN_PRIV_SET_HOST_OFFLOAD,
Srinivas Girigowda077143e2017-03-25 10:47:27 -070011904 IW_PRIV_TYPE_BYTE | sizeof(struct host_offload_req),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011905 0,
11906 "setHostOffload"
11907 }
11908 ,
11909
11910 {
11911 WLAN_GET_WLAN_STATISTICS,
11912 0,
11913 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
11914 "getWlanStats"
11915 }
11916 ,
11917
11918 {
11919 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053011920 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
11921 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011922 0,
11923 "setKeepAlive"
11924 }
11925 ,
11926#ifdef WLAN_FEATURE_PACKET_FILTERING
11927 {
11928 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053011929 IW_PRIV_TYPE_BYTE |
11930 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011931 0,
11932 "setPktFilter"
11933 }
11934 ,
11935#endif
11936#ifdef FEATURE_WLAN_SCAN_PNO
11937 {
11938 WLAN_SET_PNO,
11939 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
11940 0,
11941 "setpno"
11942 }
11943 ,
11944#endif
11945 {
11946 WLAN_SET_BAND_CONFIG,
11947 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
11948 0,
11949 "SETBAND"
11950 }
11951 ,
11952 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080011953 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080011954 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011955 0,
11956 "setMCBCFilter"
11957 }
11958 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080011959
11960 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011961 WLAN_GET_LINK_SPEED,
11962 IW_PRIV_TYPE_CHAR | 18,
11963 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
11964 }
11965 ,
11966
11967 /* handlers for main ioctl */
11968 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
11969 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11970 0,
11971 ""}
11972 ,
11973 {WE_SET_SMPS_PARAM,
11974 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11975 0, "set_smps_param"}
11976 ,
11977 {WLAN_SET_DOT11P_CHANNEL_SCHED,
11978 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
11979 0, "set_dot11p" }
11980 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070011981#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011982 {WE_SET_FW_CRASH_INJECT,
11983 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11984 0, "crash_inject"}
11985 ,
Rachit Kankaneb1035622018-01-24 18:41:35 +053011986#if defined(WMI_INTERFACE_EVENT_LOGGING) || defined(FEATURE_HTC_CREDIT_HISTORY)
Dustin Brown8d2d0f52017-04-03 17:02:08 -070011987 {WE_LOG_BUFFER,
11988 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11989 0, "log_buffer"}
11990 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011991#endif
Rachit Kankaneb1035622018-01-24 18:41:35 +053011992#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070011993#ifdef WLAN_SUSPEND_RESUME_TEST
11994 {WE_SET_WLAN_SUSPEND,
11995 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
11996 0, "wlan_suspend"}
11997 ,
11998 {WE_SET_WLAN_RESUME,
11999 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12000 0, "wlan_resume"}
12001 ,
12002#endif
Govind Singha471e5e2015-10-12 17:11:14 +053012003 {WE_ENABLE_FW_PROFILE,
12004 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12005 0, "enableProfile"}
12006 ,
12007 {WE_SET_FW_PROFILE_HIST_INTVL,
12008 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12009 0, "set_hist_intvl"}
12010 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012011 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
12012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12013 0, "set_fw_mode_cfg"}
12014 ,
12015 {WE_DUMP_DP_TRACE_LEVEL,
12016 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12017 0, "dump_dp_trace"}
12018 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012019 {WE_SET_MON_MODE_CHAN,
12020 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
12021 0, "setMonChan"}
12022 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070012023
12024 {WE_GET_ROAM_SYNCH_DELAY,
12025 0,
12026 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12027 "hostroamdelay"}
12028 ,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -080012029 {WE_SET_11AX_RATE,
12030 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12031 0,
12032 "set_11ax_rate"}
12033 ,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070012034 {WE_SET_DCM,
12035 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12036 0,
12037 "enable_dcm"}
12038 ,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070012039 {WE_SET_RANGE_EXT,
12040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12041 0,
Naveen Rawat53448ea2017-11-27 11:43:18 -080012042 "range_ext"}
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070012043 ,
Naveen Rawatc921c7b2017-06-13 17:29:51 -070012044
12045 {WLAN_PRIV_SET_FTIES,
12046 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
12047 0,
12048 "set_ft_ies"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012049};
12050
12051const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053012052 .num_standard = QDF_ARRAY_SIZE(we_handler),
12053 .num_private = QDF_ARRAY_SIZE(we_private),
12054 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012055
12056 .standard = (iw_handler *) we_handler,
12057 .private = (iw_handler *) we_private,
12058 .private_args = we_private_args,
12059 .get_wireless_stats = NULL,
12060};
12061
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012062/* hdd_set_wext() - configures bss parameters
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012063 * @adapter: handle to adapter context
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012064 *
12065 * Returns: none
12066 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012067static int hdd_set_wext(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012068{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012069 struct hdd_wext_state *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -070012070 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012071
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012072 ENTER();
12073
12074 if (!pwextBuf) {
12075 hdd_err("ERROR: pwextBuf is NULL");
12076 return QDF_STATUS_E_FAILURE;
12077 }
12078
Jeff Johnsond377dce2017-10-04 10:32:42 -070012079 if (!sta_ctx) {
12080 hdd_err("ERROR: sta_ctx is NULL");
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012081 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070012082 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012083
12084 /* Now configure the roaming profile links. To SSID and bssid. */
12085 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -070012086 pwextBuf->roamProfile.SSIDs.SSIDList = &sta_ctx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012087
12088 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -070012089 pwextBuf->roamProfile.BSSIDs.bssid = &sta_ctx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012090
12091 /*Set the numOfChannels to zero to scan all the channels */
12092 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
12093 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
12094
12095 /* Default is no encryption */
12096 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
12097 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
12098 eCSR_ENCRYPT_TYPE_NONE;
12099
12100 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
12101 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
12102 eCSR_ENCRYPT_TYPE_NONE;
12103
12104 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
12105
12106 /* Default is no authentication */
12107 pwextBuf->roamProfile.AuthType.numEntries = 1;
12108 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
12109
12110 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnsonce4a8342017-10-14 13:12:22 -070012111 sta_ctx->wpa_versions = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012112
12113 /*Set the default scan mode */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012114 adapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012115
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012116 hdd_clear_roam_profile_ie(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012117
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012118 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012119 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012120
12121}
12122
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012123#ifdef WLAN_FEATURE_FILS_SK
Jeff Johnson2a722002017-09-30 20:02:35 -070012124static void hdd_initialize_fils_info(struct hdd_wext_state *pwextBuf)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012125{
12126 pwextBuf->roamProfile.fils_con_info = NULL;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053012127 pwextBuf->roamProfile.hlp_ie = NULL;
12128 pwextBuf->roamProfile.hlp_ie_len = 0;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012129}
12130#else
Jeff Johnson2a722002017-09-30 20:02:35 -070012131static void hdd_initialize_fils_info(struct hdd_wext_state *pwextBuf)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012132{ }
12133#endif
12134
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070012135/**
12136 * hdd_register_wext() - register wext context
12137 * @dev: net device handle
12138 *
12139 * Registers wext interface context for a given net device
12140 *
12141 * Returns: 0 on success, errno on failure
12142 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012143int hdd_register_wext(struct net_device *dev)
12144{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012145 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12146 struct hdd_wext_state *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053012147 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012148
12149 ENTER();
12150
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070012151 if (!pwextBuf) {
12152 hdd_err(FL("ERROR: pwextBuf is NULL"));
12153 return QDF_STATUS_E_FAILURE;
12154 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070012155
12156 /* Zero the memory. This zeros the profile structure */
Jeff Johnson2a722002017-09-30 20:02:35 -070012157 memset(pwextBuf, 0, sizeof(struct hdd_wext_state));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012158
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012159 status = hdd_set_wext(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012160
Anurag Chouhance0dc992016-02-16 18:18:03 +053012161 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012162 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012163 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012164 }
12165
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053012166 hdd_initialize_fils_info(pwextBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012167 /* Register as a wireless device */
12168 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
12169
12170 EXIT();
12171 return 0;
12172}
12173
12174int hdd_unregister_wext(struct net_device *dev)
12175{
Jeff Johnson36e74c42017-09-18 08:15:42 -070012176 hdd_debug("dev(%pK)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012177
12178 if (dev != NULL) {
12179 rtnl_lock();
12180 dev->wireless_handlers = NULL;
12181 rtnl_unlock();
12182 }
12183
12184 return 0;
12185}