blob: e7815493e197a95b36d1ddfc42d7859a9546cbc9 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Dustin Brownd9322482017-01-09 12:46:03 -08002 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_wext.c
30 *
31 * Linux Wireless Extensions Implementation
32 */
33
34#include <linux/version.h>
35#include <linux/module.h>
36#include <linux/kernel.h>
37#include <linux/init.h>
38#include <linux/wireless.h>
39#include <mac_trace.h>
40#include <wlan_hdd_includes.h>
41#include <cds_api.h>
Rajeev Kumarea95edd2017-01-11 20:49:36 -080042#include "scheduler_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043#include <net/arp.h>
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080044#include <cdp_txrx_cmn.h>
Manjunathappa Prakash3454fd62016-04-01 08:52:06 -070045#include <cdp_txrx_stats.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "sir_params.h"
47#include "csr_api.h"
48#include "csr_inside_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include "sme_rrm_internal.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include <ani_global.h>
51#include "dot11f.h"
52#include <wlan_hdd_wowl.h>
53#include <wlan_hdd_cfg.h>
54#include <wlan_hdd_wmm.h>
55#include "utils_api.h"
56#include "wlan_hdd_p2p.h"
57#ifdef FEATURE_WLAN_TDLS
58#include "wlan_hdd_tdls.h"
59#endif
60
61#include "cds_ieee80211_common.h"
62#include "ol_if_athvar.h"
63#include "dbglog_host.h"
64#include "wma.h"
65
66#include "wlan_hdd_power.h"
67#include "qwlan_version.h"
68#include "wlan_hdd_host_offload.h"
69
70#include <linux/wireless.h>
71#include <net/cfg80211.h>
72
73#include "wlan_hdd_misc.h"
74
75#include "qc_sap_ioctl.h"
76#include "sme_api.h"
77#include "wma_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053078#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079#include "wlan_hdd_assoc.h"
80#include "wlan_hdd_ioctl.h"
81#include "wlan_hdd_scan.h"
82#include "sme_power_save_api.h"
83#include "cds_concurrency.h"
84#include "wlan_hdd_conc_ut.h"
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070085#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086#include "wlan_hdd_ocb.h"
87#include "wlan_hdd_napi.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080088#include "cdp_txrx_flow_ctrl_legacy.h"
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070089#include "wlan_hdd_nan_datapath.h"
Nirav Shahbf1b0332016-05-25 14:27:39 +053090#include "wlan_hdd_stats.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070091#ifdef WLAN_SUSPEND_RESUME_TEST
92#include "wlan_hdd_driver_ops.h"
93#include "hif.h"
Rajeev Kumar9bb2e852016-09-24 12:29:25 -070094#include "pld_common.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070095#endif
Dhanashri Atree7d442a2016-07-14 18:20:29 -070096#include "wlan_hdd_lro.h"
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053097#include "cds_utils.h"
Jeff Johnsona6ace5b2017-01-23 07:11:02 -080098#include "wlan_hdd_request_manager.h"
Naveen Rawat910726a2017-03-06 11:42:51 -080099#include "os_if_wifi_pos.h"
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -0800100#include <cdp_txrx_stats.h>
101#include <cds_api.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102#define HDD_FINISH_ULA_TIME_OUT 800
103#define HDD_SET_MCBC_FILTERS_TO_FW 1
104#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106/* To Validate Channel against the Frequency and Vice-Versa */
107static const hdd_freq_chan_map_t freq_chan_map[] = {
108 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
109 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
110 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
111 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
112 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
113 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
114 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
115 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
116 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
117 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
118 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
119 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
120
121#define FREQ_CHAN_MAP_TABLE_SIZE \
122 (sizeof(freq_chan_map) / sizeof(freq_chan_map[0]))
123
124/* Private ioctls and their sub-ioctls */
125#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
126#define WE_SET_11D_STATE 1
127#define WE_WOWL 2
128#define WE_SET_POWER 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530129/*
130 * <ioctl>
131 * setMaxAssoc - Sets the maximum number of associated stations
132 *
133 * @INPUT: 1 to 32
134 *
135 * @OUTPUT: None
136 *
137 * This IOTCL sets the maximum number of associated stations
138 *
139 * @E.g: iwpriv wlan0 setMaxAssoc <value>
140 *
141 * Supported Feature: STA
142 *
143 * Usage: Internal/External
144 *
145 * </ioctl>
146 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147#define WE_SET_MAX_ASSOC 4
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +0530148/*
149 * <ioctl>
150 * scan_diable - Disable scan
151 *
152 * @INPUT: set_value
153 *
154 * @OUTPUT: None
155 *
156 * This IOCTL is used to set disable scan
157 *
158 * @E.g: iwpriv wlan0 scan_disable 1
159 *
160 * Supported Feature: Scan
161 *
162 * Usage: Internal/External
163 *
164 * </ioctl>
165 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166#define WE_SET_SCAN_DISABLE 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530167/*
168 * <ioctl>
169 * inactivityTO - sets the timeout value for inactivity data while
170 * in power save mode
171 *
172 * @INPUT: int1…..int255
173 *
174 * @OUTPUT: None
175 *
176 * This IOCTL set the timeout value for inactivity data in power save mode
177 *
178 * @E.g: iwpriv wlan0 inactivityTO 20
179 *
180 * Supported Feature: STA
181 *
182 * Usage: Internal/External
183 *
184 * </ioctl>
185 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186#define WE_SET_DATA_INACTIVITY_TO 6
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530187/*
188 * <ioctl>
189 * setMaxTxPower - Dynamically sets the maximum transmission power
190 *
191 * @INPUT: Transmission power in dBm
192 *
193 * @OUTPUT: None
194 *
195 * This IOCTL dynamically sets the maximum transmission power
196 * This setting does not persist over reboots
197 *
198 * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
199 *
200 * Supported Feature: STA
201 *
202 * Usage: Internal/External
203 *
204 * </ioctl>
205 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206#define WE_SET_MAX_TX_POWER 7
207#define WE_SET_HIGHER_DTIM_TRANSITION 8
208#define WE_SET_TM_LEVEL 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530209/*
210 * <ioctl>
211 * setphymode - Set the phymode dynamically
212 *
213 * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
214 *
215 * @OUTPUT: None
216 *
217 * This IOCTL sets the phymode dynamically
218 *
219 * @E.g: iwpriv wlan0 setphymode 10
220 *
221 * Supported Feature: STA
222 *
223 * Usage: Internal/External
224 *
225 * </ioctl>
226 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227#define WE_SET_PHYMODE 10
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530228/*
229 * <ioctl>
230 * nss - Set the number of spatial streams
231 *
232 * @INPUT: int1…..int3
233 *
234 * @OUTPUT: None
235 *
236 * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
237 *
238 * @E.g: iwpriv wlan0 nss 2
239 *
240 * Supported Feature: STA
241 *
242 * Usage: Internal/External
243 *
244 * </ioctl>
245 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246#define WE_SET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530247/*
248 * <ioctl>
249 * ldpc - Enables or disables LDPC
250 *
251 * @INPUT: 0 – Disable, 1 - Enable
252 *
253 * @OUTPUT: None
254 *
255 * This IOCTL enables or disables LDPC
256 *
257 * @E.g: iwpriv wlan0 ldpc 1
258 *
259 * Supported Feature: STA
260 *
261 * Usage: Internal/External
262 *
263 * </ioctl>
264 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265#define WE_SET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530266/*
267 * <ioctl>
268 * tx_stbc - Enables or disables tx_stbc
269 *
270 * @INPUT: Int 0 – Disable, 1 - Enable
271 *
272 * @OUTPUT: None
273 *
274 * This IOTCL used to enables or disables tx_stbc
275 *
276 * @E.g: iwpriv wlan0 tx_stbc <value>
277 *
278 * Supported Feature: STA
279 *
280 * Usage: Internal/External
281 *
282 * </ioctl>
283 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284#define WE_SET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530285/*
286 * <ioctl>
287 * rx_stbc - Set the rx_stbc parameter
288 *
289 * @INPUT: Int 0 – Disable, 1 - Enable
290 *
291 * @OUTPUT: None
292 *
293 * This IOTCL used to set rx_stbc parameter
294 *
295 * @E.g: iwpriv wlan0 rx_stbc <value>
296 *
297 * Supported Feature: STA
298 *
299 * Usage: Internal/External
300 *
301 * </ioctl>
302 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303#define WE_SET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530304/*
305 * <ioctl>
306 * shortgi - Enables or disables a short-guard interval
307 *
308 * @INPUT: Int 0 – Disable, 1 - Enable
309 *
310 * @OUTPUT: None
311 *
312 * This IOCTL enables or disables a short-guard interval.
313 *
314 * @E.g: iwpriv wlan0 shortgi <value>
315 *
316 * Supported Feature: STA
317 *
318 * Usage: Internal/External
319 *
320 * </ioctl>
321 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322#define WE_SET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530323/*
324 * <ioctl>
325 * enablertscts - enables or disables rts/cts.
326 *
327 * @INPUT: 1-Enable , 0-Disable
328 *
329 * @OUTPUT: None
330 *
331 * This IOCTL enables or disables rts/cts.
332 *
333 * @E.g: iwpriv wlan0 enablertscts <value>
334 *
335 * Supported Feature: STA
336 *
337 * Usage: Internal/External
338 *
339 * </ioctl>
340 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341#define WE_SET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530342/*
343 * <ioctl>
344 * chwidth - Set the channel bandwidth
345 *
346 * @INPUT: 0-20mhz to 3-160mhz
347 *
348 * @OUTPUT: None
349 *
350 * This IOTCL used to set the channel bandwidth
351 *
352 * @E.g: iwpriv wlan0 chwidth 1
353 *
354 * Supported Feature: STA
355 *
356 * Usage: Internal/External
357 *
358 * </ioctl>
359 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360#define WE_SET_CHWIDTH 17
361#define WE_SET_ANI_EN_DIS 18
362#define WE_SET_ANI_POLL_PERIOD 19
363#define WE_SET_ANI_LISTEN_PERIOD 20
364#define WE_SET_ANI_OFDM_LEVEL 21
365#define WE_SET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530366/*
367 * <ioctl>
368 * cwmenable - Enables or disables the dynamic channel bandwidth
369 *
370 * @INPUT: 0-Disable, 1-Enable
371 *
372 * @OUTPUT: None
373 *
374 * This IOTCL used to enables or disables the dynamic channel bandwidth
375 *
376 * @E.g: iwpriv wlan0 cwmenable <value>
377 *
378 * Supported Feature: STA
379 *
380 * Usage: Internal/External
381 *
382 * </ioctl>
383 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384#define WE_SET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530385/*
386 * <ioctl>
387 * txchainmask - This IOCTL sets the current Tx chain mask
388 *
389 * @INPUT: Mask Value
390 *
391 * @OUTPUT: None
392 *
393 * This IOCTL sets the current Tx chain mask
394 *
395 * @E.g: iwpriv wlan0 txchainmask 1
396 *
397 * Supported Feature: STA
398 *
399 * Usage: Internal/External
400 *
401 * </ioctl>
402 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403#define WE_SET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530404/*
405 * <ioctl>
406 * rxchainmask - Sets the current Rx chain mask
407 *
408 * @INPUT: Mask Value
409 *
410 * @OUTPUT: None
411 *
412 * This IOCTL sets the current Rx chain mask. This command is the
413 * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
414 *
415 * @E.g: iwpriv wlan0 rxchainmask <value>
416 *
417 * Supported Feature: STA
418 *
419 * Usage: Internal/External
420 *
421 * </ioctl>
422 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423#define WE_SET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530424/*
425 * <ioctl>
426 * set11NRates - Fixes the Tx data rate of the 11N mode.
427 *
428 * @INPUT: 0x1b to 0x8f
429 *
430 * @OUTPUT: None
431 *
432 * This IOCTL fixes the Tx data rate of the 11N mode.
433 *
434 * @E.g: iwpriv wlan0 set11NRates 0x85
435 *
436 * Supported Feature: STA
437 *
438 * Usage: Internal/External
439 *
440 * </ioctl>
441 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442#define WE_SET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530443/*
444 * <ioctl>
445 * ampdu - Set the the maximum subframe of ampdu
446 *
447 * @INPUT: int 1 to int 63
448 *
449 * @OUTPUT: None
450 *
451 * This IOCTL sets the maximum subframe of ampdu.
452 *
453 * @E.g: iwpriv wlan0 ampdu 9
454 *
455 * Supported Feature: STA
456 *
457 * Usage: Internal/External
458 *
459 * </ioctl>
460 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461#define WE_SET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530462/*
463 * <ioctl>
464 * amsdu - Sets the maximum subframe of amsdu.
465 *
466 * @INPUT: int 1 to int 31
467 *
468 * @OUTPUT: None
469 *
470 * This IOCTL sets the maximum subframe of amsdu.
471 *
472 * @E.g: iwpriv wlan0 amsdu 9
473 *
474 * Supported Feature: STA
475 *
476 * Usage: Internal/External
477 *
478 * </ioctl>
479 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480#define WE_SET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530481/*
482 * <ioctl>
483 * txpow2g - current 2 GHz Tx power setting
484 *
485 * @INPUT: Tx power in dBm
486 *
487 * @OUTPUT: None
488 *
489 * This IOTCL used to set 2 ghz tx power
490 *
491 * @E.g: iwpriv wlan0 txpow2g
492 *
493 * Supported Feature: STA
494 *
495 * Usage: Internal/External
496 *
497 * </ioctl>
498 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800499#define WE_SET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530500/*
501 * <ioctl>
502 * txpow5g - Current 5 GHz tx power setting
503 *
504 * @INPUT: Tx power in dBm
505 *
506 * @OUTPUT: None
507 *
508 * This IOTCL used to set the 5 ghz txpower
509 *
510 * @E.g: iwpriv wlan0 txpow5g
511 *
512 * Supported Feature: STA
513 *
514 * Usage: Internal/External
515 *
516 * </ioctl>
517 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800518#define WE_SET_TXPOW_5G 30
519/* Private ioctl for firmware debug log */
520#define WE_DBGLOG_LOG_LEVEL 31
521#define WE_DBGLOG_VAP_ENABLE 32
522#define WE_DBGLOG_VAP_DISABLE 33
523#define WE_DBGLOG_MODULE_ENABLE 34
524#define WE_DBGLOG_MODULE_DISABLE 35
525#define WE_DBGLOG_MOD_LOG_LEVEL 36
526#define WE_DBGLOG_TYPE 37
527#define WE_SET_TXRX_FWSTATS 38
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530528/*
529 * <ioctl>
530 * set11ACRates - Fixes the Tx data rate of 11AC
531 *
532 * @INPUT: 0x1 to 0x9
533 *
534 * @OUTPUT: None
535 *
536 * This IOCTL fixes the Tx data rate of 11AC.
537 *
538 * @E.g: iwpriv wlan0 set11ACRates 0x9
539 *
540 * Supported Feature: STA
541 *
542 * Usage: Internal/External
543 *
544 * </ioctl>
545 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546#define WE_SET_VHT_RATE 39
547#define WE_DBGLOG_REPORT_ENABLE 40
548#define WE_TXRX_FWSTATS_RESET 41
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530549/*
550 * <ioctl>
551 * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
552 *
553 * @INPUT: Transmission power in dBm
554 *
555 * @OUTPUT: None
556 *
557 * This IOCTL sets the maximum transmit power for the 2.4-GHz band
558 * This setting does not persist over reboots
559 *
560 * @E.g: iwpriv wlan0 setTxMaxPower2G 10
561 *
562 * Supported Feature: STA
563 *
564 * Usage: Internal/External
565 *
566 * </ioctl>
567 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568#define WE_SET_MAX_TX_POWER_2_4 42
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530569/*
570 * <ioctl>
571 * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
572 *
573 * @INPUT: Transmission power in dBm
574 *
575 * @OUTPUT: None
576 *
577 * This IOCTL sets the maximum transmit power for the 5-GHz band
578 * This setting does not persist over reboots
579 *
580 * @E.g: iwpriv wlan0 setTxMaxPower5G 10
581 *
582 * Supported Feature: STA
583 *
584 * Usage: Internal/External
585 *
586 * </ioctl>
587 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800589#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590/* Private ioctl for packet powe save */
591#define WE_PPS_PAID_MATCH 45
592#define WE_PPS_GID_MATCH 46
593#define WE_PPS_EARLY_TIM_CLEAR 47
594#define WE_PPS_EARLY_DTIM_CLEAR 48
595#define WE_PPS_EOF_PAD_DELIM 49
596#define WE_PPS_MACADDR_MISMATCH 50
597#define WE_PPS_DELIM_CRC_FAIL 51
598#define WE_PPS_GID_NSTS_ZERO 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530599/*
600 * <ioctl>
601 * rssi_chk - Chek the rssi
602 *
603 * @INPUT: One argument as input
604 *
605 * @OUTPUT: rssi
606 * wlan0 rssi_chk:56
607 *
608 * This IOTCL used to chek rssi
609 *
610 * @E.g: iwpriv wlan0 rssi_chk <value>
611 *
612 * Supported Feature: STA
613 *
614 * Usage: Internal/External
615 *
616 * </ioctl>
617 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618#define WE_PPS_RSSI_CHECK 53
619#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530620/*
621 * <ioctl>
622 * htsmps - Sets the htsmps
623 *
624 * @INPUT: Atleast one int argument
625 *
626 * @OUTPUT: None
627 *
628 * This IOTCL used to set htsmps
629 *
630 * @E.g: iwpriv wlan0 htsmps <value>
631 *
632 * Supported Feature: STA
633 *
634 * Usage: Internal/External
635 *
636 * </ioctl>
637 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638#define WE_SET_HTSMPS 55
639/* Private ioctl for QPower */
640#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
641#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
642#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
643#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530644/*
645 * <ioctl>
646 * burst_enable - Enables or disables the burst feature
647 *
648 * @INPUT: 0-Disable, 1-Enable
649 *
650 * @OUTPUT: None
651 *
652 * This IOCTL enables or disables the burst feature.
653 *
654 * @E.g: iwpriv wlan0 burst_enable 0
655 *
656 * Supported Feature: STA
657 *
658 * Usage: Internal/External
659 *
660 * </ioctl>
661 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662#define WE_SET_BURST_ENABLE 60
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530663/*
664 * <ioctl>
665 * burst_dur - Enables or disables the burst feature
666 *
667 * @INPUT: int 1…..int 8191 in microseconds
668 *
669 * @OUTPUT: None
670 *
671 * This IOCTL sets the burst duration.
672 *
673 * @E.g: iwpriv wlan0 burst_dur <value>
674 *
675 * Supported Feature: STA
676 *
677 * Usage: Internal/External
678 *
679 * </ioctl>
680 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681#define WE_SET_BURST_DUR 61
682/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530683/*
684 * <ioctl>
685 * gtxHTMcs - Set the tx HTM value
686 *
687 * @INPUT: Atleast one int orgument
688 *
689 * @OUTPUT: None
690 *
691 * This IOTCL sets htm tx value
692 *
693 * @E.g: iwpriv wlan0 gtxHTMcs <value>
694 *
695 * Supported Feature: STA
696 *
697 * Usage: Internal/External
698 *
699 * </ioctl>
700 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701#define WE_SET_GTX_HT_MCS 62
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530702/*
703 * <ioctl>
704 * gtxVHTMcs - Set gtxVHTMcs value
705 *
706 * @INPUT: Atleast one int argument
707 *
708 * @OUTPUT: None
709 *
710 * This IOTCL used to set gtxVHTMcs value
711 *
712 * @E.g: iwpriv wlan0 gtxVHTMcs <value>
713 *
714 * Supported Feature: STA
715 *
716 * Usage: Internal/External
717 *
718 * </ioctl>
719 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720#define WE_SET_GTX_VHT_MCS 63
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530721/*
722 * <ioctl>
723 * gtxUsrCfg - Host request for GTX mask
724 *
725 * @INPUT: Atleast one int orgument
726 *
727 * @OUTPUT: None
728 *
729 * This IOTCL used send the host request for GTX mask
730 *
731 * @E.g: iwpriv wlan0 gtxUsrCfg <value>
732 *
733 * Supported Feature: STA
734 *
735 * Usage: Internal/External
736 *
737 * </ioctl>
738 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739#define WE_SET_GTX_USRCFG 64
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530740/*
741 * <ioctl>
742 * gtxThre - Set the tx threshold
743 *
744 * @INPUT: Atleast one int argument
745 *
746 * @OUTPUT: None
747 *
748 * This IOTCL used to set tx threshold
749 *
750 * @E.g: iwpriv wlan0 gtxThre <value>
751 *
752 * Supported Feature: STA
753 *
754 * Usage: Internal/External
755 *
756 * </ioctl>
757 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758#define WE_SET_GTX_THRE 65
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530759/*
760 * <ioctl>
761 * gtxMargin - Set the gtxMargin
762 *
763 * @INPUT: 1 to 32
764 *
765 * @OUTPUT: None
766 *
767 * This IOTCL use dto set gtxMargin
768 *
769 * @E.g: iwpriv wlan0 gtxMargini <value>
770 *
771 * Supported Feature: STA
772 *
773 * Usage: Internal/External
774 *
775 * </ioctl>
776 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777#define WE_SET_GTX_MARGIN 66
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530778/*
779 * <ioctl>
780 * gtxStep - Set the gtxStep
781 *
782 * @INPUT: None
783 *
784 * @OUTPUT: None
785 *
786 * This IOTCL used to sets gtxStep
787 *
788 * @E.g: iwpriv wlan0 gtxStep <value>
789 *
790 * Supported Feature: STA
791 *
792 * Usage: Internal/External
793 *
794 * </ioctl>
795 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796#define WE_SET_GTX_STEP 67
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530797/*
798 * <ioctl>
799 * gtxMinTpc - Sets the gtxMinTpc
800 *
801 * @INPUT: Atleast one int argument
802 *
803 * @OUTPUT: None
804 *
805 * This IOTCL sets the tx MinTpc
806 *
807 * @E.g: iwpriv wlan0 gtxMinTpc <value>
808 *
809 * Supported Feature: STA
810 *
811 * Usage: Internal/External
812 *
813 * </ioctl>
814 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815#define WE_SET_GTX_MINTPC 68
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530816/*
817 * <ioctl>
818 * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
819 *
820 * @INPUT: Mask value
821 *
822 * @OUTPUT: None
823 *
824 * This IOTCL used to set gtxBWMask
825 *
826 * @E.g: iwpriv wlan0 gtxBWMask <value>
827 *
828 * Supported Feature: STA
829 *
830 * Usage: Internal/External
831 *
832 * </ioctl>
833 */
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530834
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530835#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530836/*
837 * <ioctl>
838 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
839 *
840 * @INPUT: set_value
841 *
842 * @OUTPUT: None
843 *
844 * This IOCTL is used to set the MCC latency value in milliseconds
845 * during STA-P2P concurrency.
846 *
847 * If 0ms latency is provided, then FW will set to a default.
848 * Otherwise, latency must be at least 30ms.
849 *
850 * @E.g: iwpriv wlan0 setMccLatency 40
851 *
852 *
853 * Supported Feature: Concurrency
854 *
855 * Usage: Internal/External
856 *
857 * </ioctl>
858 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530860
861/*
862 * <ioctl>
863 * setMccQuota- Set the quota for P2P cases
864 *
865 * @INPUT: set_value [0,100]
866 *
867 * @OUTPUT: None
868 *
869 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
870 *
871 * Currently used to set time quota for 2 MCC vdevs/adapters using
872 * (operating channel, quota) for each mode.
873 * The info is provided run time using iwpriv command:
874 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
875 * Note: the quota provided in command is for the same mode in cmd.
876 * HDD checks if MCC mode is active, gets the second mode and its
877 * operating chan.
878 * Quota for the 2nd role is calculated as 100 - quota of first mode.
879 *
880 * @E.g: iwpriv wlan0 setMccQuota 50
881 * iwpriv p2p0 setMccQuota 50
882 *
883 * Supported Feature: Concurrency
884 *
885 * Usage: Internal/External
886 *
887 * </ioctl>
888 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889#define WE_MCC_CONFIG_QUOTA 71
890/* Private IOCTL for debug connection issues */
891#define WE_SET_DEBUG_LOG 72
892#ifdef WE_SET_TX_POWER
893#undef WE_SET_TX_POWER
894#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530895/*
896 * <ioctl>
897 * setTxPower - Set the current transmit power
898 *
899 * @INPUT: Transmission power in dBm
900 *
901 * @OUTPUT: None
902 *
903 * This IOCTL sets the current transmit power.
904 * This setting does not persist over reboots.
905 *
906 * @E.g: iwpriv wlan0 setTxPower 10
907 *
908 * Supported Feature: STA
909 *
910 * Usage: Internal/External
911 *
912 * </ioctl>
913 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914#define WE_SET_TX_POWER 74
915/* Private ioctl for earlyrx power save feature */
916#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
917#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
918#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
919#define WE_SET_EARLY_RX_SLOP_STEP 78
920#define WE_SET_EARLY_RX_INIT_SLOP 79
921#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530922/*
923 * <ioctl>
924 * setMcRate - Set the data rate for multicast data
925 *
926 * @INPUT: 1 to 32
927 *
928 * @OUTPUT: None
929 *
930 * This IOCTL sets the data rate for multicast data. Note that this command
931 * is allowed only in STA, IBSS, or QCMobileAP mode
932 *
933 * @E.g: iwpriv wlan0 setMcRate <value>
934 *
935 * Supported Feature: STA
936 *
937 * Usage: Internal/External
938 *
939 * </ioctl>
940 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941#define WE_SET_MC_RATE 81
942#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
943/* Private ioctl for packet power save */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530944/*
945 * <ioctl>
946 * 5g_ebt - Sets the 5g_ebt
947 *
948 * @INPUT: <value>
949 *
950 * @OUTPUT: None
951 *
952 * This IOTCL used to set 5g_ebt
953 *
954 * @E.g: iwpriv wlan0 5g_ebt <value>
955 *
956 * Supported Feature: STA
957 *
958 * Usage: Internal/External
959 *
960 * </ioctl>
961 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962#define WE_PPS_5G_EBT 83
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530963/*
964 * <ioctl>
965 * cts_cbw - Set CTS channel BW for dynamic BW adjustment
966 *
967 * @INPUT: 20 t0 160
968 *
969 * @OUTPUT: None
970 *
971 * This IOTCL used to set CTS channel BW for dynamic BW adjustment
972 *
973 * @E.g: iwpriv wlan0 cts_cbw <value>
974 *
975 * Supported Feature: STA
976 *
977 * Usage: Internal/External
978 *
979 * </ioctl>
980 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981#define WE_SET_CTS_CBW 84
982#define WE_DUMP_STATS 85
983#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530984/* Private sub ioctl for starting/stopping the profiling */
985#define WE_START_FW_PROFILE 87
Abhishek Singh3c507012016-12-01 11:15:42 +0530986/*
987 * <ioctl>
988 * setChanChange - Initiate channel change
989 *
990 * @INPUT: channel number to switch to.
991 *
992 * @OUTPUT: None
993 *
994 * This IOCTL is used to initiate a channel change.
995 * If called on STA/CLI interface it will send the
996 * ECSA action frame to the connected SAP/GO asking to
997 * initiate the ECSA, if supported.
998 * If called on SAP/GO interface it will initiate
999 * ECSA and ask connected peers to move to new channel.
1000 *
1001 * @E.g: iwpriv wlan0 setChanChange <channel>
1002 * iwpriv wlan0 setChanChange 1
1003 *
1004 * Supported Feature: ECSA
1005 *
1006 * Usage: Internal/External
1007 *
1008 * </ioctl>
1009 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +05301010#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05301011#define WE_SET_CONC_SYSTEM_PREF 89
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08001012#define WE_SET_TXRX_STATS 90
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08001014/*
1015 * <ioctl>
1016 * set_11ax_rate - set 11ax rates to FW
1017 *
1018 * @INPUT: rate code
1019 *
1020 * @OUTPUT: None
1021 *
1022 * This IOCTL fixes the Tx data rate of 11AX.
1023 *
1024 * @E.g: iwpriv wlan0 set_11ax_rate <rate code>
1025 *
1026 * Supported Feature: STA/SAP
1027 *
1028 * Usage: Internal
1029 *
1030 * </ioctl>
1031 */
1032#define WE_SET_11AX_RATE 91
1033
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001034/*
1035 * <ioctl>
1036 * enable_dcm - enable Dual Carrier Modulation(DCM)
1037 *
1038 * @INPUT: 0/1
1039 *
1040 * @OUTPUT: None
1041 *
1042 * This IOCTL enables/disables DCM.
1043 *
1044 * @E.g: iwpriv wlan0 enable_dcm <0/1>
1045 *
1046 * Supported Feature: STA/SAP
1047 *
1048 * Usage: Internal
1049 *
1050 * </ioctl>
1051 */
1052#define WE_SET_DCM 92
1053
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001054/*
1055 * <ioctl>
1056 * enable_range_ext - enable Range extension
1057 *
1058 * @INPUT: 0/1
1059 *
1060 * @OUTPUT: None
1061 *
1062 * This IOCTL enables/disables Range extension.
1063 *
1064 * @E.g: iwpriv wlan0 enable_range_ext <0/1>
1065 *
1066 * Supported Feature: STA/SAP
1067 *
1068 * Usage: Internal
1069 *
1070 * </ioctl>
1071 */
1072#define WE_SET_RANGE_EXT 93
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001073
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074/* Private ioctls and their sub-ioctls */
1075#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
1076#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077#define WE_SET_SAP_CHANNELS 3
1078#define WE_GET_WLAN_DBG 4
1079#define WE_GET_MAX_ASSOC 6
1080/* 7 is unused */
1081#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +05301082
1083/*
1084 * <ioctl>
1085 * getconcurrency - Get concurrency mode
1086 *
1087 * @INPUT: None
1088 *
1089 * @OUTPUT: It shows concurrency value
1090 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
1091 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
1092 * 8:OCB 9:EPPING 10:QVIT 11:NDI
1093 *
1094 * This IOCTL is used to retrieve concurrency mode.
1095 *
1096 * @E.g: iwpriv wlan0 getconcurrency
1097 * wlan0 getconcurrency:5
1098 * Above value shows STA+P2P_Client
1099 *
1100 * Supported Feature: Concurrency
1101 *
1102 * Usage: Internal/External
1103 *
1104 * </ioctl>
1105 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106#define WE_GET_CONCURRENCY_MODE 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301107/*
1108 * <ioctl>
1109 * get_nss - Get the number of spatial STBC streams (NSS)
1110 *
1111 * @INPUT: None
1112 *
1113 * @OUTPUT: NSS
1114 * wlan0 get_nss:2
1115 *
1116 * This IOTCL used to get the number of spatial STBC streams
1117 *
1118 * @E.g: iwpriv wlan0 get_nss
1119 *
1120 * Supported Feature: STA
1121 *
1122 * Usage: Internal/External
1123 *
1124 * </ioctl>
1125 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126#define WE_GET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301127/*
1128 * <ioctl>
1129 * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1130 *
1131 * @INPUT: None
1132 *
1133 * @OUTPUT: ldpc
1134 * wlan0 get_ldpc:1
1135 *
1136 * This IOTCL used to gets the low density parity check (LDPC)
1137 *
1138 * @E.g: iwpriv wlan0 get_ldpc
1139 *
1140 * Supported Feature: STA
1141 *
1142 * Usage: Internal/External
1143 *
1144 * </ioctl>
1145 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146#define WE_GET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301147/*
1148 * <ioctl>
1149 * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1150 *
1151 * @INPUT: None
1152 *
1153 * @OUTPUT: TXSTBC
1154 * wlan0 get_tx_stbc:1
1155 *
1156 * This IOTCL get the value of the current Tx space time block code (STBC)
1157 *
1158 * @E.g: iwpriv wlan0 get_tx_stbc
1159 *
1160 * Supported Feature: STA
1161 *
1162 * Usage: Internal/External
1163 *
1164 * </ioctl>
1165 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166#define WE_GET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301167/*
1168 * <ioctl>
1169 * get_rx_stbc - Gets the value of the current Rx STBC
1170 *
1171 * @INPUT: None
1172 *
1173 * @OUTPUT: Rx STBC
1174 * wlan0 get_rx_stbc:1
1175 *
1176 * This IOTCL used to get the value of the current Rx STBC
1177 *
1178 * @E.g: iwpriv wlan0 get_rx_stbc
1179 *
1180 * Supported Feature: STA
1181 *
1182 * Usage: Internal/External
1183 *
1184 * </ioctl>
1185 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186#define WE_GET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301187/*
1188 * <ioctl>
1189 * get_shortgi - Get the value of the current short GI setting
1190 *
1191 * @INPUT: None
1192 *
1193 * @OUTPUT: Enable/disable of shortgi
1194 * wlan0 get_shortgi:1
1195 *
1196 * This IOCTL gets the value of the current short GI setting
1197 *
1198 * @E.g: iwpriv wlan0 get_shortgi
1199 *
1200 * Supported Feature: STA
1201 *
1202 * Usage: Internal/External
1203 *
1204 * </ioctl>
1205 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206#define WE_GET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301207/*
1208 * <ioctl>
1209 * get_rtscts - Get the value of the current RTS/CTS setting.
1210 *
1211 * @INPUT: None
1212 *
1213 * @OUTPUT: Enable/disable of RTS/CTS
1214 * wlan0 get_rtscts:33
1215 *
1216 * This IOTCL get the value of the current RTS/CTS setting.
1217 *
1218 * @E.g: iwpriv wlan0 get_rtscts
1219 *
1220 * Supported Feature: STA
1221 *
1222 * Usage: Internal/External
1223 *
1224 * </ioctl>
1225 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226#define WE_GET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301227/*
1228 * <ioctl>
1229 * get_chwidth - Get the current channel width setting
1230 *
1231 * @INPUT: None
1232 *
1233 * @OUTPUT: channel width
1234 * wlan0 get_chwidth:0
1235 *
1236 * This IOTCL get the current channel width setting.
1237 *
1238 * @E.g: iwpriv wlan0 get_chwidth
1239 *
1240 * Supported Feature: STA
1241 *
1242 * Usage: Internal/External
1243 *
1244 * </ioctl>
1245 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246#define WE_GET_CHWIDTH 17
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301247/*
1248 * <ioctl>
1249 * get_anienable - Get the anienable
1250 *
1251 * @INPUT: None
1252 *
1253 * @OUTPUT:
1254 * wlan0 get_anienable:0
1255 *
1256 * This IOTCL get the anienable
1257 *
1258 * @E.g: iwpriv wlan0 get_anienable
1259 *
1260 * Supported Feature: STA
1261 *
1262 * Usage: Internal/External
1263 *
1264 * </ioctl>
1265 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266#define WE_GET_ANI_EN_DIS 18
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301267/*
1268 * <ioctl>
1269 * get_aniplen - Get the aniplen
1270 *
1271 * @INPUT: None
1272 *
1273 * @OUTPUT:
1274 * wlan0 get_aniplen:0
1275 *
1276 * This IOTCL get the aniplen
1277 *
1278 * @E.g: iwpriv wlan0 get_aniplen
1279 *
1280 * Supported Feature: STA
1281 *
1282 * Usage: Internal/External
1283 *
1284 * </ioctl>
1285 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286#define WE_GET_ANI_POLL_PERIOD 19
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301287/*
1288 * <ioctl>
1289 * get_anilislen- Get the anilislen
1290 *
1291 * @INPUT: None
1292 *
1293 * @OUTPUT:
1294 * wlan0 get_anilislen:0
1295 *
1296 * This IOTCL used to get anilislen
1297 *
1298 * @E.g: iwpriv wlan0 get_anilislen
1299 *
1300 * Supported Feature: STA
1301 *
1302 * Usage: Internal/External
1303 *
1304 * </ioctl>
1305 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306#define WE_GET_ANI_LISTEN_PERIOD 20
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301307/*
1308 * <ioctl>
1309 * get_aniofdmlvl - Get the OFDM level
1310 *
1311 * @INPUT: None
1312 *
1313 * @OUTPUT: OFDM
1314 * wlan0 get_aniofdmlvl:0
1315 *
1316 * This IOTCL used to get ofdm level
1317 *
1318 * @E.g: iwpriv wlan0 get_aniofdmlvl
1319 *
1320 * Supported Feature: STA
1321 *
1322 * Usage: Internal/External
1323 *
1324 * </ioctl>
1325 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326#define WE_GET_ANI_OFDM_LEVEL 21
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301327/*
1328 * <ioctl>
1329 * get_aniccklvl - Get the cck level
1330 *
1331 * @INPUT: None
1332 *
1333 * @OUTPUT:
1334 * wlan0 get_aniccklvl:0
1335 *
1336 * This IOTCL used to get cck level
1337 *
1338 * @E.g: iwpriv wlan0 get_aniccklvl
1339 *
1340 * Supported Feature: STA
1341 *
1342 * Usage: Internal/External
1343 *
1344 * </ioctl>
1345 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346#define WE_GET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301347/*
1348 * <ioctl>
1349 * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1350 *
1351 * @INPUT: None
1352 *
1353 * @OUTPUT: Enable/disable dynamic channel bandwidth
1354 * wlan0 get_cwmenable:0
1355 *
1356 * This IOTCL get the value of the dynamic channel bandwidth setting
1357 *
1358 * @E.g: iwpriv wlan0 get_cwmenable
1359 *
1360 * Supported Feature: STA
1361 *
1362 * Usage: Internal/External
1363 *
1364 * </ioctl>
1365 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366#define WE_GET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301367/*
1368 * <ioctl>
1369 * get_txchainmask - Get the txchainmask that was set
1370 *
1371 * @INPUT: None
1372 *
1373 * @OUTPUT: txchainmask
1374 * wlan0 get_txchainmask:1
1375 *
1376 * This IOCTL gets the txchainmask that was set
1377 * This command is useful if it was previously set
1378 *
1379 * @E.g: iwpriv wlan0 get_txchainmask
1380 *
1381 * Supported Feature: STA
1382 *
1383 * Usage: Internal/External
1384 *
1385 * </ioctl>
1386 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387#define WE_GET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301388/*
1389 * <ioctl>
1390 * get_rxchainmask - Get the rxchainmask that was set
1391 *
1392 * @INPUT: None
1393 *
1394 * @OUTPUT: rxchainmask
1395 * wlan0 get_rxchainmask:1
1396 *
1397 * This IOCTL gets the rxchainmask that was set
1398 * This command is useful only if it was previously set.
1399 *
1400 * @E.g: iwpriv wlan0 get_rxchainmask
1401 *
1402 * Supported Feature: STA
1403 *
1404 * Usage: Internal/External
1405 *
1406 * </ioctl>
1407 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408#define WE_GET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301409/*
1410 * <ioctl>
1411 * get_11nrate - Get the fixed Tx data rate
1412 *
1413 * @INPUT: None
1414 *
1415 * @OUTPUT: Using this command does not return the same value as set
1416 * wlan0 get_11nrate:0
1417 *
1418 * This IOCTL gets the fixed Tx data rate
1419 * This command is useful only if setting the fixed Tx rate.
1420 *
1421 * @E.g: iwpriv wlan0 get_11nrate
1422 *
1423 * Supported Feature: STA
1424 *
1425 * Usage: Internal/External
1426 *
1427 * </ioctl>
1428 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429#define WE_GET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301430/*
1431 * <ioctl>
1432 * get_ampdu - Get the maximum subframe of ampdu
1433 *
1434 * @INPUT: None
1435 *
1436 * @OUTPUT: Maximum subframe of ampdu
1437 * wlan0 get_ampdu:1
1438 *
1439 * This IOCTL gets the maximum subframe of ampdu
1440 * This command is useful only if setting ampdu.
1441 *
1442 * @E.g: iwpriv wlan0 get_ampdu
1443 *
1444 * Supported Feature: STA
1445 *
1446 * Usage: Internal/External
1447 *
1448 * </ioctl>
1449 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450#define WE_GET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301451/*
1452 * <ioctl>
1453 * get_amsdu - Get the maximum subframe of amsdu
1454 *
1455 * @INPUT: None
1456 *
1457 * @OUTPUT: Maximum subframe of amsdu
1458 * wlan0 get_amsdu:1
1459 *
1460 * This IOCTL gets the maximum subframe of amsdu.
1461 * This command is useful only if setting amsdu
1462 *
1463 * @E.g: iwpriv wlan0 get_amsdu
1464 *
1465 * Supported Feature: STA
1466 *
1467 * Usage: Internal/External
1468 *
1469 * </ioctl>
1470 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471#define WE_GET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301472/*
1473 * <ioctl>
1474 * get_txpow2g - Get the current 2 GHz Tx power setting
1475 *
1476 * @INPUT: None
1477 *
1478 * @OUTPUT: Tx Power in dbm
1479 * wlan0 get_txpow2g:0
1480 *
1481 * This IOCTL gets the current 2 GHz Tx power setting
1482 * This command is useful if setting Tx power
1483 *
1484 * @E.g: iwpriv wlan0 get_txpow2g
1485 *
1486 * Supported Feature: STA
1487 *
1488 * Usage: Internal/External
1489 *
1490 * </ioctl>
1491 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492#define WE_GET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301493/*
1494 * <ioctl>
1495 * get_txpow5g - Get the current 5 GHz Tx power setting
1496 *
1497 * @INPUT: None
1498 *
1499 * @OUTPUT: Tx Power in dbm
1500 * wlan0 get_txpow5g:0
1501 *
1502 * This IOCTL gets the current 5 GHz Tx power setting
1503 * This command is useful if setting Tx power
1504 *
1505 * @E.g: iwpriv wlan0 get_txpow5g
1506 *
1507 * Supported Feature: STA
1508 *
1509 * Usage: Internal/External
1510 *
1511 * </ioctl>
1512 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -08001514/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515#define WE_GET_PPS_PAID_MATCH 32
1516#define WE_GET_PPS_GID_MATCH 33
1517#define WE_GET_PPS_EARLY_TIM_CLEAR 34
1518#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
1519#define WE_GET_PPS_EOF_PAD_DELIM 36
1520#define WE_GET_PPS_MACADDR_MISMATCH 37
1521#define WE_GET_PPS_DELIM_CRC_FAIL 38
1522#define WE_GET_PPS_GID_NSTS_ZERO 39
1523#define WE_GET_PPS_RSSI_CHECK 40
1524/* Private ioctl for QPower */
1525#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
1526#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
1527#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
1528#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301529/*
1530 * <ioctl>
1531 * get_burst_en - Enables or disables the burst feature
1532 *
1533 * @INPUT: None
1534 *
1535 * @OUTPUT: Enable/disable of burst feature
1536 * wlan0 get_burst_en:1
1537 *
1538 * This IOCTL enables or disables the burst feature
1539 *
1540 * @E.g: iwpriv wlan0 get_burst_en
1541 *
1542 * Supported Feature:STA
1543 *
1544 * Usage: Internal/External
1545 *
1546 * </ioctl>
1547 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548#define WE_GET_BURST_ENABLE 45
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301549/*
1550 * <ioctl>
1551 * get_burst_dur - Get the burst duration
1552 *
1553 * @INPUT: None
1554 *
1555 * @OUTPUT: Duration in microseconds
1556 * wlan0 get_burst_dur:8160
1557 *
1558 * This IOCTL gets the burst duration
1559 * This command is useful if setting burst enable
1560 *
1561 * @E.g: iwpriv wlan0 get_burst_dur
1562 *
1563 * Supported Feature: STA
1564 *
1565 * Usage: Internal/External
1566 *
1567 * </ioctl>
1568 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569#define WE_GET_BURST_DUR 46
1570/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301571/*
1572 * <ioctl>
1573 * get_gtxHTMcs - Get the tx HTM
1574 *
1575 * @INPUT: None
1576 *
1577 * @OUTPUT: HTM
1578 * wlan0 get_gtxHTMcs:32896
1579 *
1580 * This IOTCL used to get HTM
1581 *
1582 * @E.g: iwpriv wlan0 get_gtxHTMcs
1583 *
1584 * Supported Feature: STA
1585 *
1586 * Usage: Internal/External
1587 *
1588 * </ioctl>
1589 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590#define WE_GET_GTX_HT_MCS 47
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301591/*
1592 * <ioctl>
1593 * get_gtxVHTMcs - Get the VHTM
1594 *
1595 * @INPUT: None
1596 *
1597 * @OUTPUT: VHTM
1598 * wlan0 get_gtxVHTMcs:524800
1599 *
1600 * This IOTCL used to get the VHTM
1601 *
1602 * @E.g: iwpriv wlan0 get_gtxVHTMcs
1603 *
1604 * Supported Feature: STA
1605 *
1606 * Usage: Internal/External
1607 *
1608 * </ioctl>
1609 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610#define WE_GET_GTX_VHT_MCS 48
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301611/*
1612 * <ioctl>
1613 * get_gtxUsrCfg - Get the tx cfg
1614 *
1615 * @INPUT: None
1616 *
1617 * @OUTPUT: TXCFG
1618 * wlan0 get_gtxUsrCfg:32
1619 *
1620 * This IOTCL used to get the tx cfg
1621 *
1622 * @E.g: iwpriv wlan0 get_gtxUsrCfg
1623 *
1624 * Supported Feature: STA
1625 *
1626 * Usage: Internal/External
1627 *
1628 * </ioctl>
1629 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630#define WE_GET_GTX_USRCFG 49
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301631/*
1632 * <ioctl>
1633 * get_gtxThre - Get the tx threshold
1634 *
1635 * @INPUT: None
1636 *
1637 * @OUTPUT: Threshold
1638 * wlan0 get_gtxThre:3
1639 *
1640 * This IOCTL is used to get tx threshold
1641 *
1642 * @E.g: iwpriv wlan0 get_gtxThre
1643 *
1644 * Supported Feature: STA
1645 *
1646 * Usage: Internal/External
1647 *
1648 * </ioctl>
1649 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650#define WE_GET_GTX_THRE 50
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301651/*
1652 * <ioctl>
1653 * get_gtxMargin - Get the tx margin
1654 *
1655 * @INPUT: None
1656 *
1657 * @OUTPUT: GTXMARGIN
1658 * wlan0 get_gtxMargin:2
1659 *
1660 * This IOCTL is used to set tx margin
1661 *
1662 * @E.g: iwpriv wlan0 get_gtxMargin
1663 *
1664 * Supported Feature: STA
1665 *
1666 * Usage: Internal/External
1667 *
1668 * </ioctl>
1669 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670#define WE_GET_GTX_MARGIN 51
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301671/*
1672 * <ioctl>
1673 * get_gtxStep - Get the tx step
1674 *
1675 * @INPUT: None
1676 *
1677 * @OUTPUT: GTXSTEP
1678 * wlan0 get_gtxStep:0
1679 *
1680 * This IOCTL is used to get the gtx step
1681 *
1682 * @E.g: iwpriv wlan0 get_gtxStep
1683 *
1684 * Supported Feature: STA
1685 *
1686 * Usage: Internal/External
1687 *
1688 * </ioctl>
1689 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690#define WE_GET_GTX_STEP 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301691/*
1692 * <ioctl>
1693 * get_gtxMinTpc - Get the tx miminum tpc
1694 *
1695 * @INPUT: None
1696 *
1697 * @OUTPUT: TPC
1698 * wlan0 get_gtxMinTpc:0
1699 *
1700 * This IOCTL is used to get tx miminum tpc
1701 *
1702 * @E.g: iwpriv wlan0 get_gtxMinTpc
1703 *
1704 * Supported Feature: STA
1705 *
1706 * Usage: Internal/External
1707 *
1708 * </ioctl>
1709 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710#define WE_GET_GTX_MINTPC 53
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301711/*
1712 * <ioctl>
1713 * get_gtxBWMask - Get the tx BW MASK
1714 *
1715 * @INPUT: None
1716 *
1717 * @OUTPUT: MASK
1718 * wlan0 get_gtxBWMask:15
1719 *
1720 * This IOCTL is used get gtx bw mask
1721 *
1722 * @E.g: iwpriv wlan0 get_gtxBWMask
1723 *
1724 * Supported Feature: STA
1725 *
1726 * Usage: Internal/External
1727 *
1728 * </ioctl>
1729 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730#define WE_GET_GTX_BWMASK 54
1731#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001732#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07001733#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001735/*
1736 * <ioctl>
1737 * get_dcm - Get dcm enablement value
1738 *
1739 * @INPUT: None
1740 *
1741 * @OUTPUT: 0/1
1742 * wlan0 get_dcm
1743 *
1744 * This IOCTL is used get dcm value
1745 *
1746 * Supported Feature: STA/SAP
1747 *
1748 * Usage: Internal
1749 *
1750 * </ioctl>
1751 */
1752#define WE_GET_DCM 60
1753
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001754/*
1755 * <ioctl>
1756 * get_dcm - Get range extension enablement value
1757 *
1758 * @INPUT: None
1759 *
1760 * @OUTPUT: 0/1
1761 * wlan0 get_range_ext
1762 *
1763 * This IOCTL is used get range_extension value
1764 *
1765 * Supported Feature: STA/SAP
1766 *
1767 * Usage: Internal
1768 *
1769 * </ioctl>
1770 */
1771#define WE_GET_RANGE_EXT 61
1772
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773/* Private ioctls and their sub-ioctls */
1774#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
1775
1776/* Private ioctls and their sub-ioctls */
1777#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
1778#define WE_WOWL_ADD_PTRN 1
1779#define WE_WOWL_DEL_PTRN 2
Sreelakshmi Konamkided64d72017-02-23 10:39:26 +05301780/*
1781 * <ioctl>
1782 * neighbor - Send neighbor report request
1783 *
1784 * @INPUT: string
1785 *
1786 * @OUTPUT: None
1787 *
1788 * This IOCTL create a Neighbor report request and send it to peer
1789 *
1790 * @E.g: iwpriv wlan0 neighbor "SSID"
1791 *
1792 * Supported Feature: 11k
1793 *
1794 * Usage: Internal/External
1795 *
1796 * </ioctl>
1797 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798#define WE_NEIGHBOR_REPORT_REQUEST 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301799/*
1800 * <ioctl>
1801 * set_ap_wps_ie - Set the P2P IE of the probe response
1802 *
1803 * @INPUT: string
1804 *
1805 * @OUTPUT: None
1806 *
1807 * This IOCTL sets the P2P IE of the probe response
1808 *
1809 * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1810 *
1811 * Supported Feature: STA
1812 *
1813 * Usage: Internal/External
1814 *
1815 * </ioctl>
1816 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817#define WE_SET_AP_WPS_IE 4 /* This is called in station mode to set probe rsp ie. */
1818#define WE_SET_CONFIG 5
1819
1820/* Private ioctls and their sub-ioctls */
1821#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
1822#define WE_SET_WLAN_DBG 1
1823#define WE_SET_DP_TRACE 2
1824#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05301825#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826
1827/* Private ioctls and their sub-ioctls */
1828#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
1829#define WE_WLAN_VERSION 1
1830#define WE_GET_STATS 2
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301831/*
1832 * <ioctl>
1833 * getConfig - gets the values of all configurations listed in WCNSS
1834 *
1835 * @INPUT: None
1836 *
1837 * @OUTPUT: Current configuration to the sys log
1838 * wlan0 getConfig: WLAN configuration written to system log
1839 *
1840 * This IOCTL gets the values of all configurations listed in WCNSS
1841 *
1842 * @E.g: iwpriv wlan0 getConfig
1843 *
1844 * Supported Feature: STA
1845 *
1846 * Usage: Internal/External
1847 *
1848 * </ioctl>
1849 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850#define WE_GET_CFG 3
1851#define WE_GET_WMM_STATUS 4
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301852/*
1853 * <ioctl>
1854 * getChannelList - Get the available channel list while in QCMobileAP
1855 *
1856 * @INPUT: None
1857 *
1858 * @OUTPUT: Channel list
1859 * wlan0 getChannelList:36 US 1..165
1860 *
1861 * This IOCTL gets the available channel list while in QCMobileAP
1862 *
1863 * @E.g: iwpriv wlan0 getChannelList
1864 *
1865 * Supported Feature: STA
1866 *
1867 * Usage: Internal/External
1868 *
1869 * </ioctl>
1870 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871#define WE_GET_CHANNEL_LIST 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301872/*
1873 * <ioctl>
1874 * getRSSI - Get the Received Signal Strength Indicator
1875 *
1876 * @INPUT: None
1877 *
1878 * @OUTPUT: RSSI
1879 * wlan0 getRSSI:rsssi=-32
1880 *
1881 * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1882 *
1883 * @E.g: iwpriv wlan0 getRSSI
1884 *
1885 * Supported Feature: STA
1886 *
1887 * Usage: Internal/External
1888 *
1889 * </ioctl>
1890 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -08001892
1893/*
1894 * <ioctl>
1895 * getSuspendStats - Get suspend/resume stats
1896 *
1897 * @INPUT: None
1898 *
1899 * @OUTPUT: character string containing formatted suspend/resume stats
1900 *
1901 * This ioctl is used to get suspend/resume stats formatted for display.
1902 * Currently it includes suspend/resume counts, wow wake up reasons, and
1903 * suspend fail reasons.
1904 *
1905 * @E.g: iwpriv wlan0 getSuspendStats
1906 * iwpriv wlan0 getSuspendStats
1907 *
1908 * Supported Feature: suspend/resume
1909 *
1910 * Usage: Internal
1911 *
1912 * </ioctl>
1913 */
1914#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05301916/*
1917 * <ioctl>
1918 * getTdlsPeers - Get all TDLS peers.
1919 *
1920 * @INPUT: None
1921 *
1922 * @OUTPUT: Returns the MAC address of all the TDLS peers
1923 * wlan0 getTdlsPeers:
1924 * MAC Id cap up RSSI
1925 * ---------------------------------
1926 * 00:0a:f5:0e:bd:18 2 Y Y -44
1927 * 00:0a:f5:bf:0e:12 0 N N 0
1928 *
1929 * This IOCTL is used to get all TDLS peers.
1930 *
1931 * @E.g: iwpriv wlan0 getTdlsPeers
1932 *
1933 * Supported Feature: TDLS
1934 *
1935 * Usage: Internal/External
1936 *
1937 * </ioctl>
1938 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939#define WE_GET_TDLS_PEERS 8
1940#endif
1941#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +05301942/*
1943 * <ioctl>
1944 * getPMFInfo - get the PMF info of the connected session
1945 *
1946 * @INPUT: None
1947 *
1948 * @OUTPUT:
1949 * wlan0 getPMFInfo:
1950 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
1951 * Number of Unprotected Disassocs 0
1952 * Number of Unprotected Deauths 0
1953 *
1954 * This IOCTL is used to get the PMF stats/status of the current
1955 * connection.
1956 *
1957 * @e.g:iwpriv wlan0 getPMFInfo
1958 *
1959 * Supported Feature: PMF
1960 *
1961 * Usage: Internal/External
1962 *
1963 * </ioctl>
1964 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965#define WE_GET_11W_INFO 9
1966#endif
1967#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +05301968/*
1969 * <ioctl>
1970 * getIbssSTAs - get ibss sta info
1971 *
1972 * @INPUT: None
1973 *
1974 * @OUTPUT: Give the MAC of the IBSS STA
1975 * wlan0 getIbssSTAs:
1976 * 1 .8c:fd:f0:01:9c:bf
1977 *
1978 * This IOCTL is used to get ibss sta info
1979 *
1980 * @E.g: iwpriv wlan0 getIbssSTAs
1981 *
1982 * Supported Feature: IBSS
1983 *
1984 * Usage: Internal/External
1985 *
1986 * </ioctl>
1987 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001988#define WE_GET_IBSS_STA_INFO 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301989/*
1990 * <ioctl>
1991 * getphymode - Get the current phymode.
1992 *
1993 * @INPUT: None
1994 *
1995 * @OUTPUT: In phymode
1996 * wlan0 getphymode:AUTO MODE
1997 *
1998 * This IOCTL used to gets the current phymode.
1999 *
2000 * @E.g: iwpriv wlan0 getphymode
2001 *
2002 * Supported Feature: STA
2003 *
2004 * Usage: Internal/External
2005 *
2006 * </ioctl>
2007 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008#define WE_GET_PHYMODE 12
Naveen Rawat910726a2017-03-06 11:42:51 -08002009
2010/*
2011 * <ioctl>
2012 * getOemDataCap - Get the oem data caps.
2013 *
2014 * @INPUT: None
2015 *
2016 * @OUTPUT: oem data capability
2017 *
2018 * This IOCTL used to gets the current oem data cap.
2019 *
2020 * @E.g: iwpriv wlan0 getOemDataCap
2021 *
2022 * Usage: Internal/External
2023 *
2024 * </ioctl>
2025 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026#define WE_GET_OEM_DATA_CAP 13
Naveen Rawat910726a2017-03-06 11:42:51 -08002027
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302028/*
2029 * <ioctl>
2030 * getSNR - Enable SNR Monitoring
2031 *
2032 * @INPUT: None
2033 *
2034 * @OUTPUT: Signal strength/ratio
2035 * wlan0 getSNR:1
2036 *
2037 * This IOCTL is used to get ibss sta info
2038 *
2039 * @E.g: iwpriv wlan0 getSNR
2040 *
2041 * Supported Feature: STA
2042 *
2043 * Usage: Internal/External
2044 *
2045 * </ioctl>
2046 */
Naveen Rawat910726a2017-03-06 11:42:51 -08002047
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +05302049#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050
2051/* Private ioctls and their sub-ioctls */
2052#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
2053#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +05302054/*
2055 * <ioctl>
2056 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
2057 *
2058 * @INPUT: None
2059 *
2060 * @OUTPUT: print ibss peer in info logs
2061 * pPeerInfo->numIBSSPeers = 1
2062 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2063 *
2064 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
2065 * in info logs
2066 *
2067 * @E.g: iwpriv wlan0 ibssPeerInfoAll
2068 *
2069 * Supported Feature: IBSS
2070 *
2071 * Usage: Internal/External
2072 *
2073 * </ioctl>
2074 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002075#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -08002076/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002077#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002078#define WE_GET_FW_PROFILE_DATA 18
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +05302079/*
2080 * <ioctl>
2081 * stop_obss_scan - Stop obss scan
2082 *
2083 * @INPUT: None
2084 *
2085 * @OUTPUT: None
2086 *
2087 * This IOCTL is used to stop obss scan
2088 *
2089 * @E.g: iwpriv wlan0 stop_obss_scan
2090 *
2091 * Supported Feature: Scan
2092 *
2093 * Usage: Internal/External
2094 *
2095 * </ioctl>
2096 */
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002097#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098
2099/* Private ioctls and their sub-ioctls */
2100#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
2101
2102#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +05302103/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104
Manjeet Singhf82ed072016-07-08 11:40:00 +05302105#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106
2107#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302108/*
2109 * <ioctl>
2110 * setTdlsConfig - Set TDLS configuration parameters.
2111 *
2112 * @INPUT: 11 TDLS configuration parameters
2113 * @args[0]: tdls: [0..2]
2114 * @args[1]: tx_period_t: [1000..4294967295UL]
2115 * @args[2]: tx_packet_n: [0..4294967295UL]
2116 * @args[3]: [discovery_period is not used anymore]
2117 * @args[4]: discovery_tries_n: [1..100]
2118 * @args[5]: [idle_timeout is not used anymore]
2119 * @args[6]: idle_packet_n: [0..40000]
2120 * @args[7]: [rssi_hysteresis is not used anymore]
2121 * @args[8]: rssi_trigger_threshold: [-120..0]
2122 * @args[9]: rssi_teardown_threshold: [-120..0]
2123 * @args[10]: rssi_delta: [-30..0]
2124 *
2125 * @OUTPUT: None
2126 *
2127 * This IOCTL is used to set the TDLS configuration parameters.
2128 *
2129 * @E.g: iwpriv wlan0 setTdlsConfig tdls tx_period_t tx_packet_n
2130 * discovery_period discovery_tries_n idle_timeout
2131 * idle_packet_n rssi_hysteresis rssi_trigger_threshold
2132 * rssi_teardown_threshold rssi_delta
2133 * iwpriv wlan0 setTdlsConfig 1 1500 40 1 5 1 5 0 -70 -70 -10
2134 *
2135 * Supported Feature: TDLS
2136 *
2137 * Usage: Internal/External
2138 *
2139 * </ioctl>
2140 */
2141
2142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143#define WE_TDLS_CONFIG_PARAMS 5
2144#endif
Abhishek Singh49b654e2016-12-01 16:11:17 +05302145/*
2146 * <ioctl>
2147 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
2148 *
2149 * @INPUT: staid
2150 *
2151 * @OUTPUT: print ibss peer corresponding to staid in info logs
2152 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2153 *
2154 * This IOCTL is used to print the specific ibss peers's MAC,
2155 * rate and RSSI in info logs
2156 *
2157 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
2158 * iwpriv wlan0 ibssPeerInfo 0
2159 *
2160 * Supported Feature: IBSS
2161 *
2162 * Usage: Internal/External
2163 *
2164 * </ioctl>
2165 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002166#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167#define WE_UNIT_TEST_CMD 7
2168
2169#define WE_MTRACE_DUMP_CMD 8
2170#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
2171
2172
2173#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2174#define WE_LED_FLASHING_PARAM 10
2175#endif
2176
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302177/*
2178 * <ioctl>
2179 * pm_clist - Increments the index value of the concurrent connection list
2180 * and update with the input parameters provided.
2181 *
2182 * @INPUT: Following 8 arguments:
2183 * @vdev_id: vdev id
2184 * @tx_streams: TX streams
2185 * @rx_streams: RX streams
2186 * @chain_mask: Chain mask
2187 * @type: vdev_type
2188 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2189 * @sub_type: vdev_subtype
2190 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2191 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2192 * @channel: Channel
2193 * @mac: Mac id
2194 *
2195 * @OUTPUT: None
2196 *
2197 * This IOCTL is used to increments the index value of the concurrent connection
2198 * list and update with the input parameters provided.
2199 *
2200 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
2201 * sub_type channel mac
2202 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
2203 *
2204 * Supported Feature: DBS
2205 *
2206 * Usage: Internal/External
2207 *
2208 * </ioctl>
2209 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302211
2212/*
2213 * <ioctl>
2214 * pm_dlist - Delete the index from the concurrent connection list that is
2215 * present in the given vdev_id.
2216 *
2217 * @INPUT: delete_all, vdev_id
2218 * @delete_all: delete all indices
2219 * @vdev_id: vdev id
2220 *
2221 * @OUTPUT: None
2222 *
2223 * This IOCTL is used to delete the index from the concurrent connection list
2224 * that is present in the given vdev_id.
2225 *
2226 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
2227 * iwpriv wlan0 pm_dlist 0 1
2228 *
2229 * Supported Feature: DBS
2230 *
2231 * Usage: Internal/External
2232 *
2233 * </ioctl>
2234 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302236
2237/*
2238 * <ioctl>
2239 * pm_dbs - Set dbs capability and system preference
2240 *
2241 * @INPUT: dbs, system_pref
2242 * @dbs: Value of DBS capability to be set
2243 * @system_pref: System preference
2244 * 0:CDS_THROUGHPUT 1: CDS_POWERSAVE 2: CDS_LATENCY
2245 *
2246 * @OUTPUT: None
2247 *
2248 * This IOCTL is used to set dbs capability and system preference.
2249 *
2250 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
2251 * iwpriv wlan0 pm_dbs 1 0
2252 *
2253 * Supported Feature: DBS
2254 *
2255 * Usage: Internal/External
2256 *
2257 * </ioctl>
2258 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302260
2261/*
2262 * <ioctl>
2263 * pm_pcl - Set pcl for concurrency mode.
2264 *
2265 * @INPUT: cds_con_mode
2266 * @cds_con_mode: concurrency mode for PCL table
2267 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2268 *
2269 * @OUTPUT: None
2270 *
2271 * This IOCTL is used to set pcl for concurrency mode.
2272 *
2273 * @E.g: iwpriv wlan0 pm_pcl cds_con_mode
2274 * iwpriv wlan0 pm_pcl 0
2275 *
2276 * Supported Feature: DBS
2277 *
2278 * Usage: Internal/External
2279 *
2280 * </ioctl>
2281 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302283
2284/*
2285 * <ioctl>
2286 * pm_cinfo - Shows the concurrent connection list.
2287 *
2288 * @INPUT: None
2289 *
2290 * @OUTPUT: None
2291 *
2292 * This IOCTL is used to show the concurrent connection list.
2293 *
2294 * @E.g: iwpriv wlan0 pm_cinfo
2295 *
2296 * Supported Feature: DBS
2297 *
2298 * Usage: Internal/External
2299 *
2300 * </ioctl>
2301 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302303
2304/*
2305 * <ioctl>
2306 * pm_ulist - Updates the index value of the concurrent connection list
2307 * with the input parameters provided.
2308 *
2309 * @INPUT: Following 8 arguments:
2310 * @vdev_id: vdev id
2311 * @tx_streams: TX streams
2312 * @rx_streams: RX streams
2313 * @chain_mask: Chain mask
2314 * @type: vdev_type
2315 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2316 * @sub_type: vdev_subtype
2317 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2318 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2319 * @channel: Channel
2320 * @mac: Mac id
2321 *
2322 * @OUTPUT: None
2323 *
2324 * This IOCTL is used to updates the index value of the concurrent
2325 * connection list with the input parameters provided.
2326 *
2327 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
2328 * sub_type channel mac
2329 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
2330 *
2331 * Supported Feature: DBS
2332 *
2333 * Usage: Internal/External
2334 *
2335 * </ioctl>
2336 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302338
2339/*
2340 * <ioctl>
2341 * pm_query_action - Initiate actions needed on current connections as
2342 * per the channel provided.
2343 *
2344 * @INPUT: channel
2345 * @channel: Channel on which new connection will be.
2346 *
2347 * @OUTPUT: None
2348 *
2349 * This IOCTL is used to initiate actions needed on current connections
2350 * as per the channel provided.
2351 *
2352 * @E.g: iwpriv wlan0 pm_query_action channel
2353 * iwpriv wlan0 pm_query_action 6
2354 *
2355 * Supported Feature: DBS
2356 *
2357 * Usage: Internal/External
2358 *
2359 * </ioctl>
2360 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302362
2363/*
2364 * <ioctl>
2365 * pm_query_allow - Checks for allowed concurrency combination
2366 *
2367 * @INPUT: mode, channel, bandwidth
2368 * @mode: new connection mode
2369 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2370 * @channel: channel on which new connection is coming up
2371 * @bandwidth: Bandwidth requested by the connection
2372 * 0:None 1:5MHz 2:10MHz 3:20MHz
2373 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
2374 *
2375 * @OUTPUT: None
2376 *
2377 * This IOCTL is used to checks for allowed concurrency combination.
2378 *
2379 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
2380 * iwpriv wlan0 pm_query_allow 0 6 4
2381 *
2382 * Supported Feature: DBS
2383 *
2384 * Usage: Internal/External
2385 *
2386 * </ioctl>
2387 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302389
2390/*
2391 * <ioctl>
2392 * pm_run_scenario - Create scenario with number of connections provided.
2393 *
2394 * @INPUT: num_of_conn
2395 * @num_of_conn: the number of connections (values: 1~3)
2396 *
2397 * @OUTPUT: None
2398 *
2399 * This IOCTL is used to create scenario with the number of connections
2400 * provided.
2401 *
2402 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
2403 * iwpriv wlan0 pm_run_scenario 1
2404 *
2405 * Supported Feature: DBS
2406 *
2407 * Usage: Internal/External
2408 *
2409 * </ioctl>
2410 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302412
2413/*
2414 * <ioctl>
2415 * pm_set_hw_mode - Set hardware for single/dual mac.
2416 *
2417 * @INPUT: hw_mode
2418 * 0:single mac 1:dual mac
2419 *
2420 * @OUTPUT: None
2421 *
2422 * This IOCTL is used to set hardware for single/dual mac.
2423 *
2424 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
2425 * iwpriv wlan0 pm_set_hw_mode 1
2426 *
2427 * Supported Feature: DBS
2428 *
2429 * Usage: Internal/External
2430 *
2431 * </ioctl>
2432 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433#define WE_POLICY_SET_HW_MODE_CMD 20
2434
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302435/*
2436 * <ioctl>
2437 * set_scan_cfg - Set dual MAC scan config parameters.
2438 *
2439 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2440 * @dbs: Value of DBS bit
2441 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2442 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2443 *
2444 * @OUTPUT: None
2445 *
2446 * This IOCTL is used to set the dual MAC scan config.
2447 *
2448 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2449 * single_mac_scan_with_dbs
2450 * iwpriv wlan0 set_scan_cfg 1 0 1
2451 *
2452 * Supported Feature: DBS
2453 *
2454 * Usage: Internal/External
2455 *
2456 * </ioctl>
2457 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302459
2460/*
2461 * <ioctl>
2462 * set_fw_mode_cfg - Sets the dual mac FW mode config
2463 *
2464 * @INPUT: dbs, dfs
2465 * @dbs: DBS bit
2466 * @dfs: Agile DFS bit
2467 *
2468 * @OUTPUT: None
2469 *
2470 * This IOCTL is used to set the dual mac FW mode config.
2471 *
2472 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2473 * iwpriv wlan0 set_fw_mode_cfg 1 1
2474 *
2475 * Supported Feature: DBS
2476 *
2477 * Usage: Internal/External
2478 *
2479 * </ioctl>
2480 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07002482#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483
2484#ifdef FEATURE_WLAN_TDLS
2485#undef MAX_VAR_ARGS
2486#define MAX_VAR_ARGS 11
2487#else
2488#undef MAX_VAR_ARGS
2489#define MAX_VAR_ARGS 9
2490#endif
2491
2492/* Private ioctls (with no sub-ioctls) */
2493/* note that they must be odd so that they have "get" semantics */
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302494/*
2495 * <ioctl>
2496 * addTspec - Add TSPEC for each AC
2497 *
2498 * @INPUT: 19 TSPEC params
2499 * @[arg0]: handle
2500 * @[arg1]: tid
2501 * @[arg2]: dir
2502 * @[arg3]: psb
2503 * @[arg4]: up
2504 * @[arg5]: nomMsduSize
2505 * @[arg6]: maxMsduSize
2506 * @[arg7]: minDataRate
2507 * @[arg8]: meanDataRate
2508 * @[arg9]: peakDataRate
2509 * @[arg10]: maxBurstSize
2510 * @[arg11]: minPhyRate
2511 * @[arg12]: sba
2512 * @[arg13]: minServiceIntv
2513 * @[arg14]: suspendIntv
2514 * @[arg15]: burstSizeDefn
2515 * @[arg16]: ackPolicy
2516 * @[arg17]: inactivityPeriod
2517 * @[arg18]: maxServiceIntv
2518 *
2519 * @OUTPUT: Success/Failure
2520 *
2521 * This IOCTL is used to add TSPEC for each AC.
2522 *
2523 * @E.g: iwpriv wlan0 addTspec <handle> <tid> <dir> <psb> <up> <nomMsduSize>
2524 * <maxMsduSize> <minDataRate> <meanDataRate>
2525 * <peakDataRate> <maxBurstSize> <minPhyRate>
2526 * <sba> <minServiceIntv> <suspendIntv>
2527 * <burstSizeDefn> <ackPolicy> <inactivityPeriod>
2528 * <maxServiceIntv>
2529 * iwpriv wlan0 addTspec 7001 6 2 1 6 0x80D0 0x80D0 0x14500 0x14500 0x14500
2530 * 0 0x5B8D80 0x2001 20 2000 0 0 0 2000
2531 * wlan0 addTspec:3
2532 *
2533 * Supported Feature: WMM
2534 *
2535 * Usage: Internal/External
2536 *
2537 * </ioctl>
2538 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302540/*
2541 * <ioctl>
2542 * delTspec - Delete TSPEC entry for each AC
2543 *
2544 * @INPUT: 1 TSPEC param
2545 * @[arg0]: handle
2546 *
2547 * @OUTPUT: Success/Failure
2548 *
2549 * This IOCTL is used to delete TSPEC entry for each AC.
2550 *
2551 * @E.g: iwpriv wlan0 delTspec <handle>
2552 * iwpriv wlan0 delTspec 7001
2553 * wlan0 delTspec:16
2554 *
2555 * Supported Feature: WMM
2556 *
2557 * Usage: Internal/External
2558 *
2559 * </ioctl>
2560 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302562/*
2563 * <ioctl>
2564 * getTspec - Get TSPEC entry for each AC
2565 *
2566 * @INPUT: 1 TSPEC param
2567 * @[arg0]: handle
2568 *
2569 * @OUTPUT: Success/Failure
2570 *
2571 * This IOCTL is used to get TSPEC entry for each AC.
2572 *
2573 * @E.g: iwpriv wlan0 getTspec <handle>
2574 * iwpriv wlan0 getTspec 7001
2575 * wlan0 delTspec:18
2576 *
2577 * Supported Feature: WMM
2578 *
2579 * Usage: Internal/External
2580 *
2581 * </ioctl>
2582 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2584
2585/* (SIOCIWFIRSTPRIV + 8) is currently unused */
2586/* (SIOCIWFIRSTPRIV + 10) is currently unused */
2587/* (SIOCIWFIRSTPRIV + 12) is currently unused */
2588/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002589#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
2590#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591/* (SIOCIWFIRSTPRIV + 16) is currently unused */
2592/* (SIOCIWFIRSTPRIV + 17) is currently unused */
2593/* (SIOCIWFIRSTPRIV + 19) is currently unused */
2594
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596
2597/* Private ioctl for setting the host offload feature */
2598#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2599
2600/* Private ioctl to get the statistics */
2601#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2602
2603/* Private ioctl to set the Keep Alive Params */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302604/*
2605 * <ioctl>
2606 * setKeepAlive - Set the keep alive feature
2607 *
2608 * @INPUT: 28 bytes of information in the order of packet type, time period
2609 * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2610 *
2611 * @OUTPUT: None
2612 *
2613 * This IOCTL sets the keep alive feature to send either NULL
2614 * or unsolicited ARP response packets
2615 *
2616 * @E.g: iwpriv wlan0 setKeepAlive
2617 *
2618 * Supported Feature: STA
2619 *
2620 * Usage: Internal/External
2621 *
2622 * </ioctl>
2623 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2625
2626#ifdef WLAN_FEATURE_PACKET_FILTERING
2627/* Private ioctl to set the packet filtering params */
2628#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2629#endif
2630
2631
2632#ifdef FEATURE_WLAN_SCAN_PNO
2633/* Private ioctl to get the statistics */
2634#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2635#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302636/*
2637 * <ioctl>
2638 * SETBAND - Set the operational band
2639 *
2640 * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2641 *
2642 * @OUTPUT: None
2643 *
2644 * This IOCTL Set the operational band If the new band is different from the
2645 * current operational band, it aborts the pending scan requests, flushes
2646 * the existing scan results, and then change * the band capability
2647 *
2648 * @E.g: iwpriv wlan0 SETBAND <value>
2649 *
2650 * Supported Feature: STA
2651 *
2652 * Usage: Internal/External
2653 *
2654 * </ioctl>
2655 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
2657
Dustin Brown0cbc7572016-12-16 13:54:40 -08002658#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -08002659/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660
2661/* Private ioctls and their sub-ioctls */
2662#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
2663#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -07002664#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665#define WE_SET_FW_CRASH_INJECT 2
2666#endif
2667#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +05302668/* Private sub ioctl for enabling and setting histogram interval of profiling */
2669#define WE_ENABLE_FW_PROFILE 4
2670#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07002672/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002673#define WE_SET_WLAN_SUSPEND 6
2674#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002675
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676/* (SIOCIWFIRSTPRIV + 29) is currently unused */
2677
2678/* 802.11p IOCTL */
2679#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
2680
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302681/*
2682 * <ioctl>
2683 * getLinkSpeed - Gets the current link speed in Mbps
2684 *
2685 * @INPUT: None
2686 *
2687 * @OUTPUT: linkspeed in mbps
2688 * wlan0 getLinkSpeed:7
2689 *
2690 * This IOCTL is used get the current link speed in Mbps
2691 *
2692 * @E.g: iwpriv wlan0 getLinkSpeed
2693 *
2694 * Supported Feature: STA
2695 *
2696 * Usage: Internal/External
2697 *
2698 * </ioctl>
2699 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
2701
2702#define WLAN_STATS_INVALID 0
2703#define WLAN_STATS_RETRY_CNT 1
2704#define WLAN_STATS_MUL_RETRY_CNT 2
2705#define WLAN_STATS_TX_FRM_CNT 3
2706#define WLAN_STATS_RX_FRM_CNT 4
2707#define WLAN_STATS_FRM_DUP_CNT 5
2708#define WLAN_STATS_FAIL_CNT 6
2709#define WLAN_STATS_RTS_FAIL_CNT 7
2710#define WLAN_STATS_ACK_FAIL_CNT 8
2711#define WLAN_STATS_RTS_SUC_CNT 9
2712#define WLAN_STATS_RX_DISCARD_CNT 10
2713#define WLAN_STATS_RX_ERROR_CNT 11
2714#define WLAN_STATS_TX_BYTE_CNT 12
2715
2716#define WLAN_STATS_RX_BYTE_CNT 13
2717#define WLAN_STATS_RX_RATE 14
2718#define WLAN_STATS_TX_RATE 15
2719
2720#define WLAN_STATS_RX_UC_BYTE_CNT 16
2721#define WLAN_STATS_RX_MC_BYTE_CNT 17
2722#define WLAN_STATS_RX_BC_BYTE_CNT 18
2723#define WLAN_STATS_TX_UC_BYTE_CNT 19
2724#define WLAN_STATS_TX_MC_BYTE_CNT 20
2725#define WLAN_STATS_TX_BC_BYTE_CNT 21
2726
2727#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
2728 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
2729 *__p++ = __type; \
2730 *__p++ = __size; \
2731 memcpy(__p, __val, __size); \
2732 __p += __size; \
2733 __tlen += __size + 2; \
2734 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07002735 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736 } \
2737 } while (0)
2738
2739#define VERSION_VALUE_MAX_LEN 32
2740
2741#define TX_PER_TRACKING_DEFAULT_RATIO 5
2742#define TX_PER_TRACKING_MAX_RATIO 10
2743#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
2744
2745#define WLAN_ADAPTER 0
2746#define P2P_ADAPTER 1
2747
2748/**
2749 * mem_alloc_copy_from_user_helper - copy from user helper
2750 * @wrqu_data: wireless extensions request data
2751 * @len: length of @wrqu_data
2752 *
2753 * Helper function to allocate buffer and copy user data.
2754 *
2755 * Return: On success return a pointer to a kernel buffer containing a
2756 * copy of the userspace data (with an additional NUL character
2757 * appended for safety). On failure return %NULL.
2758 */
2759void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2760{
2761 u8 *ptr = NULL;
2762
2763 /* in order to protect the code, an extra byte is post
2764 * appended to the buffer and the null termination is added.
2765 * However, when allocating (len+1) byte of memory, we need to
2766 * make sure that there is no uint overflow when doing
2767 * addition. In theory check len < UINT_MAX protects the uint
2768 * overflow. For wlan private ioctl, the buffer size is much
2769 * less than UINT_MAX, as a good guess, now, it is assumed
2770 * that the private command buffer size is no greater than 4K
2771 * (4096 bytes). So we use 4096 as the upper boundary for now.
2772 */
2773 if (len > MAX_USER_COMMAND_SIZE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002774 hdd_err("Invalid length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 return NULL;
2776 }
2777
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002778 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002780 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 return NULL;
2782 }
2783
2784 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002785 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002786 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 return NULL;
2788 }
2789 ptr[len] = '\0';
2790 return ptr;
2791}
2792
2793/**
2794 * hdd_priv_get_data() - Get pointer to ioctl private data
2795 * @p_priv_data: pointer to iw_point struct to be filled
2796 * @wrqu: Pointer to IOCTL Data received from userspace
2797 *
2798 * Helper function to get compatible struct iw_point passed to ioctl
2799 *
2800 * Return - 0 if p_priv_data successfully filled, error otherwise
2801 */
2802int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2803{
2804 if ((NULL == p_priv_data) || (NULL == wrqu)) {
2805 return -EINVAL;
2806 }
2807#ifdef CONFIG_COMPAT
2808 if (is_compat_task()) {
2809 struct compat_iw_point *p_compat_priv_data;
2810
2811 /* Compat task:
2812 * typecast to compat structure and copy the members.
2813 */
2814 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2815
2816 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2817 p_priv_data->length = p_compat_priv_data->length;
2818 p_priv_data->flags = p_compat_priv_data->flags;
2819 } else {
2820#endif /* #ifdef CONFIG_COMPAT */
2821
2822 /* Non compat task: directly copy the structure. */
2823 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
2824
2825#ifdef CONFIG_COMPAT
2826 }
2827#endif /* #ifdef CONFIG_COMPAT */
2828
2829 return 0;
2830}
2831
Jeff Johnson441e1f72017-02-07 08:50:49 -08002832static int hdd_check_wext_control(enum hdd_wext_control wext_control,
2833 struct iw_request_info *info)
2834{
2835 switch (wext_control) {
2836 default:
2837 case hdd_wext_disabled:
2838 hdd_err("Rejecting disabled ioctl %x", info->cmd);
2839 return -ENOTSUPP;
2840 case hdd_wext_deprecated:
2841 hdd_warn("Using deprecated ioctl %x", info->cmd);
2842 return 0;
2843 case hdd_wext_enabled:
2844 return 0;
2845 }
2846}
2847
2848int hdd_check_standard_wext_control(struct hdd_context_s *hdd_ctx,
2849 struct iw_request_info *info)
2850{
2851 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
2852 info);
2853}
2854
2855int hdd_check_private_wext_control(struct hdd_context_s *hdd_ctx,
2856 struct iw_request_info *info)
2857{
2858 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
2859 info);
2860}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861
2862/**
2863 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
2864 * @pAdapter: Pointer to the hdd adapter.
2865 * @length: Size of the data copied
2866 * @buffer: Pointer to char buffer.
2867 * @buf_len: Length of the char buffer.
2868 *
2869 * This function called when the "iwpriv wlan0 get_stats" command is given.
2870 * It used to collect the txrx stats when the device is configured in SAP mode.
2871 *
2872 * Return - none
2873 */
2874void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
2875 char *buffer, uint16_t buf_len)
2876{
2877 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
2878 uint32_t len = 0;
2879 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
2880 uint32_t total_rx_delv = 0, total_rx_refused = 0;
2881 int i = 0;
2882
2883 for (; i < NUM_CPUS; i++) {
2884 total_rx_pkt += pStats->rxPackets[i];
2885 total_rx_dropped += pStats->rxDropped[i];
2886 total_rx_delv += pStats->rxDelivered[i];
2887 total_rx_refused += pStats->rxRefused[i];
2888 }
2889
2890 len = scnprintf(buffer, buf_len,
2891 "\nTransmit"
2892 "\ncalled %u, dropped %u,"
2893 "\n dropped BK %u, BE %u, VI %u, VO %u"
2894 "\n classified BK %u, BE %u, VI %u, VO %u"
2895 "\ncompleted %u,"
2896 "\n\nReceive Total"
2897 "\n packets %u, dropped %u, delivered %u, refused %u"
2898 "\n",
2899 pStats->txXmitCalled,
2900 pStats->txXmitDropped,
2901
2902 pStats->txXmitDroppedAC[SME_AC_BK],
2903 pStats->txXmitDroppedAC[SME_AC_BE],
2904 pStats->txXmitDroppedAC[SME_AC_VI],
2905 pStats->txXmitDroppedAC[SME_AC_VO],
2906
2907 pStats->txXmitClassifiedAC[SME_AC_BK],
2908 pStats->txXmitClassifiedAC[SME_AC_BE],
2909 pStats->txXmitClassifiedAC[SME_AC_VI],
2910 pStats->txXmitClassifiedAC[SME_AC_VO],
2911
2912 pStats->txCompleted,
2913 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
2914 );
2915
2916 for (i = 0; i < NUM_CPUS; i++) {
2917 len += scnprintf(buffer + len, buf_len - len,
2918 "\nReceive CPU: %d"
2919 "\n packets %u, dropped %u, delivered %u, refused %u",
2920 i, pStats->rxPackets[i], pStats->rxDropped[i],
2921 pStats->rxDelivered[i], pStats->rxRefused[i]);
2922 }
2923
2924 len += scnprintf(buffer + len, buf_len - len,
2925 "\n\nTX_FLOW"
2926 "\nCurrent status: %s"
2927 "\ntx-flow timer start count %u"
2928 "\npause count %u, unpause count %u",
2929 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
2930 pStats->txflow_timer_cnt,
2931 pStats->txflow_pause_cnt,
2932 pStats->txflow_unpause_cnt);
2933
Leo Changfdb45c32016-10-28 11:09:23 -07002934 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
2935 pAdapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936
2937 len += hdd_napi_stats(buffer + len, buf_len - len,
2938 NULL, hdd_napi_get_all());
2939
2940 *length = len + 1;
2941}
2942
2943/**
Dustin Brownd9322482017-01-09 12:46:03 -08002944 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
2945 * @hdd_ctx: The Hdd context owning the stats to be written
2946 * @buffer: The char buffer to write to
2947 * @max_len: The maximum number of chars to write
2948 *
2949 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
2950 *
2951 * Return - length of written content, negative number on error
2952 */
2953static int wlan_hdd_write_suspend_resume_stats(hdd_context_t *hdd_ctx,
2954 char *buffer, uint16_t max_len)
2955{
2956 QDF_STATUS status;
2957 struct suspend_resume_stats *sr_stats;
2958 struct sir_wake_lock_stats wow_stats;
2959
2960 sr_stats = &hdd_ctx->suspend_resume_stats;
2961
2962 status = wma_get_wakelock_stats(&wow_stats);
2963 if (QDF_IS_STATUS_ERROR(status)) {
2964 hdd_err("Failed to get WoW stats");
2965 return qdf_status_to_os_return(status);
2966 }
2967
2968 return scnprintf(buffer, max_len,
2969 "\n"
2970 "Suspends: %u\n"
2971 "Resumes: %u\n"
2972 "\n"
2973 "Suspend Fail Reasons\n"
2974 "\tIPA: %u\n"
2975 "\tRadar: %u\n"
2976 "\tRoam: %u\n"
2977 "\tScan: %u\n"
2978 "\tInitial Wakeup: %u\n"
2979 "\n"
2980 "WoW Wake Reasons\n"
2981 "\tunicast: %u\n"
2982 "\tbroadcast: %u\n"
2983 "\tIPv4 multicast: %u\n"
2984 "\tIPv6 multicast: %u\n"
2985 "\tIPv6 multicast RA: %u\n"
2986 "\tIPv6 multicast NS: %u\n"
2987 "\tIPv6 multicast NA: %u\n"
2988 "\tICMPv4: %u\n"
2989 "\tICMPv6: %u\n"
2990 "\tRSSI Breach: %u\n"
2991 "\tLow RSSI: %u\n"
2992 "\tG-Scan: %u\n"
2993 "\tPNO Complete: %u\n"
2994 "\tPNO Match: %u\n",
2995 sr_stats->suspends,
2996 sr_stats->resumes,
2997 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
2998 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
2999 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
3000 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
3001 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
3002 wow_stats.wow_ucast_wake_up_count,
3003 wow_stats.wow_bcast_wake_up_count,
3004 wow_stats.wow_ipv4_mcast_wake_up_count,
3005 wow_stats.wow_ipv6_mcast_wake_up_count,
3006 wow_stats.wow_ipv6_mcast_ra_stats,
3007 wow_stats.wow_ipv6_mcast_ns_stats,
3008 wow_stats.wow_ipv6_mcast_na_stats,
3009 wow_stats.wow_icmpv4_count,
3010 wow_stats.wow_icmpv6_count,
3011 wow_stats.wow_rssi_breach_wake_up_count,
3012 wow_stats.wow_low_rssi_wake_up_count,
3013 wow_stats.wow_gscan_wake_up_count,
3014 wow_stats.wow_pno_complete_wake_up_count,
3015 wow_stats.wow_pno_match_wake_up_count);
3016}
3017
3018/**
Govind Singha471e5e2015-10-12 17:11:14 +05303019 * hdd_wlan_list_fw_profile() - Get fw profiling points
3020 * @length: Size of the data copied
3021 * @buffer: Pointer to char buffer.
3022 * @buf_len: Length of the char buffer.
3023 *
3024 * This function called when the "iwpriv wlan0 listProfile" command is given.
3025 * It is used to get the supported profiling points in FW.
3026 *
3027 * Return - none
3028 */
3029void hdd_wlan_list_fw_profile(uint16_t *length,
3030 char *buffer, uint16_t buf_len)
3031{
3032 uint32_t len = 0;
3033
3034 len = scnprintf(buffer, buf_len,
3035 "PROF_CPU_IDLE: %u\n"
3036 "PROF_PPDU_PROC: %u\n"
3037 "PROF_PPDU_POST: %u\n"
3038 "PROF_HTT_TX_INPUT: %u\n"
3039 "PROF_MSDU_ENQ: %u\n"
3040 "PROF_PPDU_POST_HAL: %u\n"
3041 "PROF_COMPUTE_TX_TIME: %u\n",
3042 PROF_CPU_IDLE,
3043 PROF_PPDU_PROC,
3044 PROF_PPDU_POST,
3045 PROF_HTT_TX_INPUT,
3046 PROF_MSDU_ENQ,
3047 PROF_PPDU_POST_HAL,
3048 PROF_COMPUTE_TX_TIME);
3049
3050 *length = len + 1;
3051}
3052
3053/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 * hdd_wlan_dump_stats() - display dump Stats
3055 * @adapter: adapter handle
3056 * @value: value from user
3057 *
3058 * Return: none
3059 */
3060void hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value)
3061{
3062 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3063
3064 switch (value) {
3065
3066 case WLAN_TXRX_HIST_STATS:
3067 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
3068 break;
3069 case WLAN_HDD_NETIF_OPER_HISTORY:
3070 wlan_hdd_display_netif_queue_history(hdd_ctx);
3071 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05303072 case WLAN_HIF_STATS:
3073 hdd_display_hif_stats();
3074 break;
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003075 case WLAN_LRO_STATS:
3076 hdd_lro_display_stats(hdd_ctx);
3077 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 default:
Leo Changfdb45c32016-10-28 11:09:23 -07003079 cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080 break;
3081 }
3082}
3083
3084/**
3085 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303086 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 * @wrqu: Pointer to IOCTL REQUEST Data.
3088 * @extra: Pointer to destination buffer
3089 *
3090 * This function is used to get Wlan Driver, Firmware, & Hardware
3091 * Version information. If @wrqu and @extra are specified, then the
3092 * version string is returned. Otherwise it is simply printed to the
3093 * kernel log.
3094 *
3095 * Return: none
3096 */
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303097void hdd_wlan_get_version(hdd_context_t *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 char *extra)
3099{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303100 tSirVersionString wcnss_sw_version;
3101 const char *swversion;
3102 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003103 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303105 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003106 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 goto error;
3108 }
3109
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303110 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
3111 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303113 swversion = wcnss_sw_version;
3114 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
3115 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
3116 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
3117 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003118 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303120 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121
3122 if (wrqu && extra) {
3123 wrqu->data.length =
3124 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003125 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003127 msp_id, mspid, siid, crmid,
3128 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003130 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003132 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 }
3134error:
3135 return;
3136}
3137
3138/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003139 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
3140 * @pAdapter: Adapter upon which the IBSS client is active
3141 * @staIdx: Station index of the IBSS peer
3142 *
3143 * Return: a pointer to the MAC address of the IBSS peer if the peer is
3144 * found, otherwise %NULL.
3145 */
3146struct qdf_mac_addr *
3147hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
3148 uint8_t staIdx)
3149{
3150 uint8_t idx;
3151 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3152
Naveen Rawatc45d1622016-07-05 12:20:09 -07003153 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003154 if (0 != pHddStaCtx->conn_info.staId[idx] &&
3155 staIdx == pHddStaCtx->conn_info.staId[idx]) {
3156 return &pHddStaCtx->conn_info.peerMacAddress[idx];
3157 }
3158 }
3159 return NULL;
3160}
3161
3162/**
3163 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
3164 * @pAdapter: Adapter upon which the IBSS client is active
3165 * @staIdx: Station index of the IBSS peer
3166 *
3167 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
3168 * otherwise an appropriate QDF_STATUS_E_* failure code.
3169 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003170static QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter,
3171 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003172{
3173 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3174 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3175 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003176 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003177
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003178 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003179 status = sme_request_ibss_peer_info(hHal, pAdapter,
3180 hdd_get_ibss_peer_info_cb,
3181 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003182
3183 if (QDF_STATUS_SUCCESS == status) {
3184 unsigned long rc;
3185 rc = wait_for_completion_timeout
3186 (&pAdapter->ibss_peer_info_comp,
3187 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3188 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003189 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003190 return QDF_STATUS_E_FAILURE;
3191 }
3192
3193 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003194 hdd_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003195 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003196 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3197 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003198
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003199 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
3200 mac_addr, sizeof(mac_addr));
3201 hdd_info("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
3202 mac_addr, (int)tx_rate,
3203 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003204 }
3205 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003206 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003207 }
3208
3209 return status;
3210}
3211
3212/**
3213 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
3214 * @pAdapter: Adapter upon which the IBSS clients are active
3215 *
3216 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
3217 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
3218 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003219static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003220{
3221 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3222 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3223 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003224 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003225 int i;
3226
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003227 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003228 status = sme_request_ibss_peer_info(hHal, pAdapter,
3229 hdd_get_ibss_peer_info_cb,
3230 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003231
3232 if (QDF_STATUS_SUCCESS == status) {
3233 unsigned long rc;
3234 rc = wait_for_completion_timeout
3235 (&pAdapter->ibss_peer_info_comp,
3236 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3237 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003238 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003239 return QDF_STATUS_E_FAILURE;
3240 }
3241
3242 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003243 hdd_info("pPeerInfo->numIBSSPeers = %d ",
3244 (int)pPeerInfo->numPeers);
3245 for (i = 0; i < pPeerInfo->numPeers; i++) {
3246 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3247 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003248
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003249 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
3250 qdf_mem_copy(mac_addr,
3251 pPeerInfo->peerInfoParams[i].mac_addr,
3252 sizeof(mac_addr));
3253
3254 hdd_info(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
3255 mac_addr, (int)tx_rate,
3256 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003257 }
3258 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003259 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003260 }
3261
3262 return status;
3263}
3264
3265/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 * hdd_wlan_get_freq() - Convert channel to frequency
3267 * @channel: channel to be converted
3268 * @pfreq: where to store the frequency
3269 *
3270 * Return: 1 on success, otherwise a negative errno
3271 */
3272int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
3273{
3274 int i;
3275 if (channel > 0) {
3276 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
3277 if (channel == freq_chan_map[i].chan) {
3278 *pfreq = freq_chan_map[i].freq;
3279 return 1;
3280 }
3281 }
3282 }
Jeff Johnson99bac312016-06-28 10:38:18 -07003283 hdd_notice("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 return -EINVAL;
3285}
3286
3287/**
3288 * hdd_is_auth_type_rsn() - RSN authentication type check
3289 * @authType: authentication type to be checked
3290 *
3291 * Return: true if @authType is an RSN authentication type,
3292 * false if it is not
3293 */
3294static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
3295{
3296 bool rsnType = false;
3297 /* is the authType supported? */
3298 switch (authType) {
3299 case eCSR_AUTH_TYPE_NONE: /* never used */
3300 rsnType = false;
3301 break;
3302 /* MAC layer authentication types */
3303 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3304 rsnType = false;
3305 break;
3306 case eCSR_AUTH_TYPE_SHARED_KEY:
3307 rsnType = false;
3308 break;
3309 case eCSR_AUTH_TYPE_AUTOSWITCH:
3310 rsnType = false;
3311 break;
3312
3313 /* Upper layer authentication types */
3314 case eCSR_AUTH_TYPE_WPA:
3315 rsnType = true;
3316 break;
3317 case eCSR_AUTH_TYPE_WPA_PSK:
3318 rsnType = true;
3319 break;
3320 case eCSR_AUTH_TYPE_WPA_NONE:
3321 rsnType = true;
3322 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 case eCSR_AUTH_TYPE_RSN:
3325 rsnType = true;
3326 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 case eCSR_AUTH_TYPE_RSN_PSK:
3329#ifdef WLAN_FEATURE_11W
3330 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3331 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
3332#endif
3333 rsnType = true;
3334 break;
3335 /* case eCSR_AUTH_TYPE_FAILED: */
3336 case eCSR_AUTH_TYPE_UNKNOWN:
3337 rsnType = false;
3338 break;
3339 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003340 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341 authType);
3342 rsnType = false;
3343 break;
3344 }
Jeff Johnson99bac312016-06-28 10:38:18 -07003345 hdd_notice("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346 authType, rsnType);
3347 return rsnType;
3348}
3349
Jeff Johnsona5444942017-01-23 13:11:08 -08003350struct rssi_priv {
3351 int8_t rssi;
3352};
3353
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354/**
3355 * hdd_get_rssi_cb() - "Get RSSI" callback function
3356 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08003357 * @sta_id: ID of the station
3358 * @context: opaque context originally passed to SME. HDD always passes
3359 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 *
3361 * Return: None
3362 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003363static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364{
Jeff Johnsona5444942017-01-23 13:11:08 -08003365 struct hdd_request *request;
3366 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367
Jeff Johnsona5444942017-01-23 13:11:08 -08003368 request = hdd_request_get(context);
3369 if (!request) {
3370 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 return;
3372 }
3373
Jeff Johnsona5444942017-01-23 13:11:08 -08003374 priv = hdd_request_priv(request);
3375 priv->rssi = rssi;
3376 hdd_request_complete(request);
3377 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378}
3379
3380/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 * wlan_hdd_get_rssi() - Get the current RSSI
3382 * @pAdapter: adapter upon which the measurement is requested
3383 * @rssi_value: pointer to where the RSSI should be returned
3384 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303385 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303387QDF_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 hdd_context_t *pHddCtx;
3390 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303391 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08003392 int ret;
3393 void *cookie;
3394 struct hdd_request *request;
3395 struct rssi_priv *priv;
3396 static const struct hdd_request_params params = {
3397 .priv_size = sizeof(*priv),
3398 .timeout_ms = WLAN_WAIT_TIME_STATS,
3399 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400
3401 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003402 hdd_warn("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303403 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003405 if (cds_is_driver_recovering()) {
3406 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3407 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 /* return a cached value */
3409 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303410 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 }
3412
3413 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3414 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3415
3416 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05303417 hdd_err("Not associated!, rssi on disconnect %d",
3418 pAdapter->rssi_on_disconnect);
3419 *rssi_value = pAdapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303420 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 }
3422
3423 if (pHddStaCtx->hdd_ReassocScenario) {
3424 hdd_info("Roaming in progress, return cached RSSI");
3425 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303426 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 }
3428
Jeff Johnsona5444942017-01-23 13:11:08 -08003429 request = hdd_request_alloc(&params);
3430 if (!request) {
3431 hdd_err("Request allocation failure, return cached RSSI");
3432 *rssi_value = pAdapter->rssi;
3433 return QDF_STATUS_SUCCESS;
3434 }
3435 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436
3437 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
3438 pHddStaCtx->conn_info.staId[0],
3439 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
Jeff Johnsona5444942017-01-23 13:11:08 -08003440 cookie, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303441 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003442 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 /* we'll returned a cached value below */
3444 } else {
3445 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08003446 ret = hdd_request_wait_for_response(request);
3447 if (ret) {
3448 hdd_warn("SME timed out while retrieving RSSI");
3449 /* we'll returned a cached value below */
3450 } else {
3451 /* update the adapter with the fresh results */
3452 priv = hdd_request_priv(request);
3453 pAdapter->rssi = priv->rssi;
3454 if (pAdapter->rssi > 0)
3455 pAdapter->rssi = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456 }
3457 }
3458
Jeff Johnsona5444942017-01-23 13:11:08 -08003459 /*
3460 * either we never sent a request, we sent a request and
3461 * received a response or we sent a request and timed out.
3462 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003464 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465
3466 *rssi_value = pAdapter->rssi;
3467
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303468 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469}
3470
Jeff Johnson002cb972017-01-23 14:59:07 -08003471struct snr_priv {
3472 int8_t snr;
3473};
3474
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08003476 * hdd_get_snr_cb() - "Get SNR" callback function
3477 * @snr: Current SNR of the station
Jeff Johnson002cb972017-01-23 14:59:07 -08003478 * @sta_id: ID of the station
3479 * @context: opaque context originally passed to SME. HDD always passes
3480 * a cookie for the request context
Jeff Johnson8eaff302017-01-23 11:03:31 -08003481 *
3482 * Return: None
3483 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003484static void hdd_get_snr_cb(int8_t snr, uint32_t sta_id, void *context)
Jeff Johnson8eaff302017-01-23 11:03:31 -08003485{
Jeff Johnson002cb972017-01-23 14:59:07 -08003486 struct hdd_request *request;
3487 struct snr_priv *priv;
Jeff Johnson8eaff302017-01-23 11:03:31 -08003488
Jeff Johnson002cb972017-01-23 14:59:07 -08003489 request = hdd_request_get(context);
3490 if (!request) {
3491 hdd_err("Obsolete request");
Jeff Johnson8eaff302017-01-23 11:03:31 -08003492 return;
3493 }
3494
Jeff Johnson002cb972017-01-23 14:59:07 -08003495 /* propagate response back to requesting thread */
3496 priv = hdd_request_priv(request);
3497 priv->snr = snr;
3498 hdd_request_complete(request);
3499 hdd_request_put(request);
Jeff Johnson8eaff302017-01-23 11:03:31 -08003500}
3501
3502/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 * wlan_hdd_get_snr() - Get the current SNR
3504 * @pAdapter: adapter upon which the measurement is requested
3505 * @snr: pointer to where the SNR should be returned
3506 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303507 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303509QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 hdd_context_t *pHddCtx;
3512 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303513 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 int valid;
Jeff Johnson002cb972017-01-23 14:59:07 -08003515 int ret;
3516 void *cookie;
3517 struct hdd_request *request;
3518 struct snr_priv *priv;
3519 static const struct hdd_request_params params = {
3520 .priv_size = sizeof(*priv),
3521 .timeout_ms = WLAN_WAIT_TIME_STATS,
3522 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303524 ENTER();
3525
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003527 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303528 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 }
3530
3531 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3532
3533 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303534 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303535 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536
3537 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3538
Jeff Johnson002cb972017-01-23 14:59:07 -08003539 request = hdd_request_alloc(&params);
3540 if (!request) {
3541 hdd_err("Request allocation failure");
3542 return QDF_STATUS_E_FAULT;
3543 }
3544 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545
3546 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
3547 pHddStaCtx->conn_info.staId[0],
Jeff Johnson002cb972017-01-23 14:59:07 -08003548 pHddStaCtx->conn_info.bssId, cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303549 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003550 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 /* we'll returned a cached value below */
3552 } else {
3553 /* request was sent -- wait for the response */
Jeff Johnson002cb972017-01-23 14:59:07 -08003554 ret = hdd_request_wait_for_response(request);
3555 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003556 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557 /* we'll now returned a cached value below */
Jeff Johnson002cb972017-01-23 14:59:07 -08003558 } else {
3559 /* update the adapter with the fresh results */
3560 priv = hdd_request_priv(request);
3561 pAdapter->snr = priv->snr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 }
3563 }
3564
Jeff Johnson002cb972017-01-23 14:59:07 -08003565 /*
3566 * either we never sent a request, we sent a request and
3567 * received a response or we sent a request and timed out.
3568 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003570 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571
3572 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303573 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303574 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575}
3576
Jeff Johnsone50427c2017-01-26 10:54:49 -08003577struct linkspeed_priv {
3578 tSirLinkSpeedInfo linkspeed_info;
3579};
3580
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581static void
Jeff Johnsone50427c2017-01-26 10:54:49 -08003582hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583{
Jeff Johnsone50427c2017-01-26 10:54:49 -08003584 struct hdd_request *request;
3585 struct linkspeed_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586
Jeff Johnsone50427c2017-01-26 10:54:49 -08003587 if (!linkspeed_info) {
3588 hdd_err("NULL linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 return;
3590 }
3591
Jeff Johnsone50427c2017-01-26 10:54:49 -08003592 request = hdd_request_get(context);
3593 if (!request) {
3594 hdd_err("Obsolete request");
3595 return;
3596 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597
Jeff Johnsone50427c2017-01-26 10:54:49 -08003598 priv = hdd_request_priv(request);
3599 priv->linkspeed_info = *linkspeed_info;
3600 hdd_request_complete(request);
3601 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602}
3603
Jeff Johnsone50427c2017-01-26 10:54:49 -08003604int wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *adapter,
3605 struct qdf_mac_addr *mac_address,
3606 uint32_t *linkspeed)
3607{
3608 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303609 QDF_STATUS status;
Jeff Johnsone50427c2017-01-26 10:54:49 -08003610 void *cookie;
3611 tSirLinkSpeedInfo *linkspeed_info;
3612 struct hdd_request *request;
3613 struct linkspeed_priv *priv;
3614 static const struct hdd_request_params params = {
3615 .priv_size = sizeof(*priv),
3616 .timeout_ms = WLAN_WAIT_TIME_STATS,
3617 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618
Jeff Johnsone50427c2017-01-26 10:54:49 -08003619 if ((!adapter) || (!linkspeed)) {
3620 hdd_err("NULL argument");
3621 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623
Jeff Johnsone50427c2017-01-26 10:54:49 -08003624 request = hdd_request_alloc(&params);
3625 if (!request) {
3626 hdd_err("Request allocation failure");
3627 ret = -ENOMEM;
3628 goto return_cached_value;
3629 }
3630
3631 cookie = hdd_request_cookie(request);
3632 priv = hdd_request_priv(request);
3633
3634 linkspeed_info = &priv->linkspeed_info;
3635 qdf_copy_macaddr(&linkspeed_info->peer_macaddr, mac_address);
3636 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(adapter),
3637 linkspeed_info,
3638 cookie, hdd_get_link_speed_cb);
3639 if (QDF_IS_STATUS_ERROR(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003640 hdd_err("Unable to retrieve statistics for link speed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003641 ret = qdf_status_to_os_return(status);
3642 goto cleanup;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 }
Jeff Johnsone50427c2017-01-26 10:54:49 -08003644 ret = hdd_request_wait_for_response(request);
3645 if (ret) {
3646 hdd_err("SME timed out while retrieving link speed");
3647 goto cleanup;
3648 }
3649 adapter->estimated_linkspeed = linkspeed_info->estLinkSpeed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650
Jeff Johnsone50427c2017-01-26 10:54:49 -08003651cleanup:
3652 /*
3653 * either we never sent a request, we sent a request and
3654 * received a response or we sent a request and timed out.
3655 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 */
Jeff Johnsone50427c2017-01-26 10:54:49 -08003657 hdd_request_put(request);
3658
3659return_cached_value:
3660 *linkspeed = adapter->estimated_linkspeed;
3661
3662 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663}
3664
3665/**
3666 * wlan_hdd_get_link_speed() - get link speed
3667 * @pAdapter: pointer to the adapter
3668 * @link_speed: pointer to link speed
3669 *
3670 * This function fetches per bssid link speed.
3671 *
3672 * Return: if associated, link speed shall be returned.
3673 * if not associated, link speed of 0 is returned.
3674 * On error, error number will be returned.
3675 */
3676int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
3677{
3678 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
3679 hdd_station_ctx_t *hdd_stactx =
3680 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
3681 int ret;
3682
3683 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05303684 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303687 /* Linkspeed is allowed only for P2P mode */
3688 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
3689 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
3690 hdd_device_mode_to_string(sta_adapter->device_mode),
3691 sta_adapter->device_mode);
3692 return -ENOTSUPP;
3693 }
3694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
3696 /* we are not connected so we don't have a classAstats */
3697 *link_speed = 0;
3698 } else {
Anurag Chouhan6d760662016-02-20 16:05:43 +05303699 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700
Anurag Chouhanc5548422016-02-24 18:33:27 +05303701 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702
Jeff Johnsone50427c2017-01-26 10:54:49 -08003703 ret = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, &bssid,
3704 link_speed);
3705 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003706 hdd_err("Unable to retrieve SME linkspeed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003707 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709 /* linkspeed in units of 500 kbps */
3710 *link_speed = (*link_speed) / 500;
3711 }
3712 return 0;
3713}
3714
3715/**
3716 * hdd_statistics_cb() - "Get statistics" callback function
3717 * @pStats: statistics payload
3718 * @pContext: opaque context originally passed to SME. HDD always passes
3719 * a pointer to an adapter
3720 *
3721 * Return: None
3722 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003723static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724{
3725 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
3726 hdd_stats_t *pStatsCache = NULL;
3727 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05303728 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003729
3730 tCsrSummaryStatsInfo *pSummaryStats = NULL;
3731 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733
3734 if (pAdapter != NULL)
3735 pStatsCache = &pAdapter->hdd_stats;
3736
3737 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3738 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Jeff Johnsonf2dac4f2017-03-16 11:41:31 -07003739 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003740
3741 if (pStatsCache != NULL) {
3742 /* copy the stats into the cache we keep in the
3743 * adapter instance structure
3744 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303745 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003746 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303747 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303749 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003750 sizeof(pStatsCache->ClassD_stat));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003751 }
3752
3753 if (pAdapter) {
3754 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303755 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05303756 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003757 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758 return;
3759 }
3760 }
3761}
3762
3763/**
3764 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
3765 * @pAdapter: adapter who's IEs are to be cleared
3766 *
3767 * Return: None
3768 */
3769void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
3770{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003771 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07003772
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003773 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774
3775 /* clear WPA/RSN/WSC IE information in the profile */
3776 pWextState->roamProfile.nWPAReqIELength = 0;
3777 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
3778 pWextState->roamProfile.nRSNReqIELength = 0;
3779 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
3780
3781#ifdef FEATURE_WLAN_WAPI
3782 pWextState->roamProfile.nWAPIReqIELength = 0;
3783 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
3784#endif
3785
3786 pWextState->roamProfile.bWPSAssociation = false;
3787 pWextState->roamProfile.bOSENAssociation = false;
3788 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
3789 pWextState->roamProfile.nAddIEScanLength = 0;
3790 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
3791 pWextState->roamProfile.nAddIEAssocLength = 0;
3792
3793 pWextState->roamProfile.EncryptionType.numEntries = 1;
3794 pWextState->roamProfile.EncryptionType.encryptionType[0]
3795 = eCSR_ENCRYPT_TYPE_NONE;
3796
3797 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3798 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
3799 = eCSR_ENCRYPT_TYPE_NONE;
3800
3801 pWextState->roamProfile.AuthType.numEntries = 1;
3802 pWextState->roamProfile.AuthType.authType[0] =
3803 eCSR_AUTH_TYPE_OPEN_SYSTEM;
3804
Abhishek Singh3c9910e2017-01-06 17:56:47 +05303805 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
3806 QDF_MAC_ADDR_SIZE);
3807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808#ifdef WLAN_FEATURE_11W
3809 pWextState->roamProfile.MFPEnabled = false;
3810 pWextState->roamProfile.MFPRequired = 0;
3811 pWextState->roamProfile.MFPCapable = 0;
3812#endif
3813
3814 pWextState->authKeyMgmt = 0;
3815
Yingying Tang3cc6b792016-10-20 17:00:37 +08003816 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
3817
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003818#ifdef FEATURE_WLAN_WAPI
3819 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
3820 pAdapter->wapi_info.nWapiMode = 0;
3821#endif
3822
Anurag Chouhanc5548422016-02-24 18:33:27 +05303823 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003824 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825}
3826
3827/**
3828 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
3829 * @oui: The OUI that is being searched for
3830 * @oui_size: The length of @oui
3831 * @ie: The set of IEs within which we're trying to find @oui
3832 * @ie_len: The length of @ie
3833 *
3834 * This function will scan the IEs contained within @ie looking for @oui.
3835 *
3836 * Return: Pointer to @oui embedded within @ie if it is present, NULL
3837 * if @oui is not present within @ie.
3838 */
3839uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
3840 uint8_t *ie, int ie_len)
3841{
3842 int left = ie_len;
3843 uint8_t *ptr = ie;
3844 uint8_t elem_id, elem_len;
3845 uint8_t eid = 0xDD;
3846
3847 if (NULL == ie || 0 == ie_len)
3848 return NULL;
3849
3850 while (left >= 2) {
3851 elem_id = ptr[0];
3852 elem_len = ptr[1];
3853 left -= 2;
3854 if (elem_len > left) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003855 hdd_alert("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 eid, elem_len, left);
3857 return NULL;
3858 }
3859 if (elem_id == eid) {
3860 if (memcmp(&ptr[2], oui, oui_size) == 0)
3861 return ptr;
3862 }
3863
3864 left -= elem_len;
3865 ptr += (elem_len + 2);
3866 }
3867 return NULL;
3868}
3869
3870/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303871 * hdd_get_ldpc() - Get adapter LDPC
3872 * @adapter: adapter being queried
3873 * @value: where to store the value
3874 *
3875 * Return: 0 on success, negative errno on failure
3876 */
3877int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
3878{
3879 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3880 int ret;
3881
3882 ENTER();
3883 ret = sme_get_ht_config(hal, adapter->sessionId,
3884 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
3885 if (ret < 0) {
3886 hdd_alert("Failed to get LDPC value");
3887 } else {
3888 *value = ret;
3889 ret = 0;
3890 }
3891 return ret;
3892}
3893
3894/**
3895 * hdd_set_ldpc() - Set adapter LDPC
3896 * @adapter: adapter being modified
3897 * @value: new LDPC value
3898 *
3899 * Return: 0 on success, negative errno on failure
3900 */
3901int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
3902{
3903 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3904 int ret;
3905
3906 hdd_alert("%d", value);
3907 if (value) {
3908 /* make sure HT capabilities allow this */
3909 QDF_STATUS status;
3910 uint32_t cfg_value;
3911 union {
3912 uint16_t cfg_value16;
3913 tSirMacHTCapabilityInfo ht_cap_info;
3914 } u;
3915
3916 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
3917 if (QDF_STATUS_SUCCESS != status) {
3918 hdd_alert("Failed to get HT capability info");
3919 return -EIO;
3920 }
3921 u.cfg_value16 = cfg_value & 0xFFFF;
3922 if (!u.ht_cap_info.advCodingCap) {
3923 hdd_alert("LDCP not supported");
3924 return -EINVAL;
3925 }
3926 }
3927
3928 ret = sme_update_ht_config(hal, adapter->sessionId,
3929 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
3930 value);
3931 if (ret)
3932 hdd_alert("Failed to set LDPC value");
3933
3934 return ret;
3935}
3936
3937/**
3938 * hdd_get_tx_stbc() - Get adapter TX STBC
3939 * @adapter: adapter being queried
3940 * @value: where to store the value
3941 *
3942 * Return: 0 on success, negative errno on failure
3943 */
3944int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
3945{
3946 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3947 int ret;
3948
3949 ENTER();
3950 ret = sme_get_ht_config(hal, adapter->sessionId,
3951 WNI_CFG_HT_CAP_INFO_TX_STBC);
3952 if (ret < 0) {
3953 hdd_alert("Failed to get TX STBC value");
3954 } else {
3955 *value = ret;
3956 ret = 0;
3957 }
3958
3959 return ret;
3960}
3961
3962/**
3963 * hdd_set_tx_stbc() - Set adapter TX STBC
3964 * @adapter: adapter being modified
3965 * @value: new TX STBC value
3966 *
3967 * Return: 0 on success, negative errno on failure
3968 */
3969int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
3970{
3971 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3972 int ret;
3973
3974 hdd_alert("%d", value);
3975 if (value) {
3976 /* make sure HT capabilities allow this */
3977 QDF_STATUS status;
3978 uint32_t cfg_value;
3979 union {
3980 uint16_t cfg_value16;
3981 tSirMacHTCapabilityInfo ht_cap_info;
3982 } u;
3983
3984 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
3985 if (QDF_STATUS_SUCCESS != status) {
3986 hdd_alert("Failed to get HT capability info");
3987 return -EIO;
3988 }
3989 u.cfg_value16 = cfg_value & 0xFFFF;
3990 if (!u.ht_cap_info.txSTBC) {
3991 hdd_alert("TX STBC not supported");
3992 return -EINVAL;
3993 }
3994 }
3995 ret = sme_update_ht_config(hal, adapter->sessionId,
3996 WNI_CFG_HT_CAP_INFO_TX_STBC,
3997 value);
3998 if (ret)
3999 hdd_alert("Failed to set TX STBC value");
4000
4001 return ret;
4002}
4003
4004/**
4005 * hdd_get_rx_stbc() - Get adapter RX STBC
4006 * @adapter: adapter being queried
4007 * @value: where to store the value
4008 *
4009 * Return: 0 on success, negative errno on failure
4010 */
4011int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
4012{
4013 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4014 int ret;
4015
4016 ENTER();
4017 ret = sme_get_ht_config(hal, adapter->sessionId,
4018 WNI_CFG_HT_CAP_INFO_RX_STBC);
4019 if (ret < 0) {
4020 hdd_alert("Failed to get RX STBC value");
4021 } else {
4022 *value = ret;
4023 ret = 0;
4024 }
4025
4026 return ret;
4027}
4028
4029/**
4030 * hdd_set_rx_stbc() - Set adapter RX STBC
4031 * @adapter: adapter being modified
4032 * @value: new RX STBC value
4033 *
4034 * Return: 0 on success, negative errno on failure
4035 */
4036int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
4037{
4038 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4039 int ret;
4040
4041 hdd_alert("%d", value);
4042 if (value) {
4043 /* make sure HT capabilities allow this */
4044 QDF_STATUS status;
4045 uint32_t cfg_value;
4046 union {
4047 uint16_t cfg_value16;
4048 tSirMacHTCapabilityInfo ht_cap_info;
4049 } u;
4050
4051 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4052 if (QDF_STATUS_SUCCESS != status) {
4053 hdd_alert("Failed to get HT capability info");
4054 return -EIO;
4055 }
4056 u.cfg_value16 = cfg_value & 0xFFFF;
4057 if (!u.ht_cap_info.rxSTBC) {
4058 hdd_alert("RX STBC not supported");
4059 return -EINVAL;
4060 }
4061 }
4062 ret = sme_update_ht_config(hal, adapter->sessionId,
4063 WNI_CFG_HT_CAP_INFO_RX_STBC,
4064 value);
4065 if (ret)
4066 hdd_alert("Failed to set RX STBC value");
4067
4068 return ret;
4069}
4070
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004071int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate)
4072{
4073 int set_value;
4074
4075 if (sme_is_feature_supported_by_fw(DOT11AX))
4076 set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble);
4077 else
4078 set_value = (preamble << 6) | (nss << 4) | rate;
4079
4080 return set_value;
4081}
4082
4083int hdd_set_11ax_rate(hdd_adapter_t *adapter, int set_value,
4084 struct sap_Config *sap_config)
4085{
4086 uint8_t preamble = 0, nss = 0, rix = 0;
4087 int ret;
4088
4089 if (!sap_config) {
4090 if (!sme_is_feature_supported_by_fw(DOT11AX)) {
4091 hdd_err("Target does not support 11ax");
4092 return -EIO;
4093 }
4094 } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax &&
4095 sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) {
4096 hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d",
4097 sap_config->SapHw_mode, sap_config->channel);
4098 return -EIO;
4099 }
4100
4101 if (set_value != 0xff) {
4102 rix = RC_2_RATE_IDX_11AX(set_value);
4103 preamble = WMI_RATE_PREAMBLE_HE;
4104 nss = HT_RC_2_STREAMS_11AX(set_value);
4105
4106 set_value = hdd_assemble_rate_code(preamble, nss, rix);
4107 }
4108
4109 hdd_notice("SET_11AX_RATE val %d rix %d preamble %x nss %d",
4110 set_value, rix, preamble, nss);
4111
4112 ret = wma_cli_set_command(adapter->sessionId,
4113 WMI_VDEV_PARAM_FIXED_RATE,
4114 set_value, VDEV_CMD);
4115
4116 return ret;
4117}
4118
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304119/**
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004120 * hdd_get_aid_rc() - Get AID and rate code passed from user
4121 * @aid: pointer to AID
4122 * @rc: pointer to rate code
4123 * @set_value: value passed from user
4124 *
4125 * If target is 11ax capable, set_value will have AID left shifted 16 bits
4126 * and 16 bits for rate code. If the target is not 11ax capable, rate code
4127 * will only be 8 bits.
4128 *
4129 * Return: None
4130 */
4131static void hdd_get_aid_rc(uint8_t *aid, uint16_t *rc, int set_value)
4132{
4133 uint8_t rc_bits;
4134
4135 if (sme_is_feature_supported_by_fw(DOT11AX))
4136 rc_bits = 16;
4137 else
4138 rc_bits = 8;
4139
4140 *aid = set_value >> rc_bits;
4141 *rc = set_value & ((1 << (rc_bits + 1)) - 1);
4142}
4143
4144int hdd_set_peer_rate(hdd_adapter_t *adapter, int set_value)
4145{
4146 uint8_t aid, *peer_mac;
4147 uint16_t rc;
4148 QDF_STATUS status;
4149
4150 if (adapter->device_mode != QDF_SAP_MODE) {
4151 hdd_err("Invalid devicde mode - %d", adapter->device_mode);
4152 return -EINVAL;
4153 }
4154
4155 hdd_get_aid_rc(&aid, &rc, set_value);
4156
4157 if ((adapter->aStaInfo[aid].isUsed) &&
4158 (OL_TXRX_PEER_STATE_CONN == adapter->aStaInfo[aid].tlSTAState)) {
4159 peer_mac =
4160 (uint8_t *)&(adapter->aStaInfo[aid].macAddrSTA.bytes[0]);
4161 hdd_info("Peer AID: %d MAC_ADDR: "MAC_ADDRESS_STR,
4162 aid, MAC_ADDR_ARRAY(peer_mac));
4163 } else {
4164 hdd_err("No matching peer found for AID: %d", aid);
4165 return -EINVAL;
4166 }
4167
4168 status = sme_set_peer_param(peer_mac, WMI_PEER_PARAM_FIXED_RATE,
4169 rc, adapter->sessionId);
4170 if (status != QDF_STATUS_SUCCESS) {
4171 hdd_err("Failed to set peer fixed rate - status: %d", status);
4172 return -EIO;
4173 }
4174
4175 return 0;
4176}
4177
4178/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
4180 * @dev: device upon which the ioctl was received
4181 * @info: ioctl request information
4182 * @wrqu: ioctl request data
4183 * @extra: ioctl extra data
4184 *
4185 * Return: 0 on success, non-zero on error
4186 */
4187static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
4188 union iwreq_data *wrqu, char *extra)
4189{
4190 hdd_adapter_t *adapter;
4191 hdd_context_t *hdd_ctx;
4192 int ret;
4193
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004194 ENTER_DEV(dev);
4195
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4197 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4198 ret = wlan_hdd_validate_context(hdd_ctx);
4199 if (0 != ret)
4200 return ret;
4201
Jeff Johnson441e1f72017-02-07 08:50:49 -08004202 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4203 if (0 != ret)
4204 return ret;
4205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 /* Do nothing for now */
4207 return 0;
4208}
4209
4210/**
4211 * iw_set_commit() - SSR wrapper function for __iw_set_commit
4212 * @dev: pointer to net_device
4213 * @info: pointer to iw_request_info
4214 * @wrqu: pointer to iwreq_data
4215 * @extra: extra
4216 *
4217 * Return: 0 on success, error number otherwise
4218 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004219static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 union iwreq_data *wrqu, char *extra)
4221{
4222 int ret;
4223
4224 cds_ssr_protect(__func__);
4225 ret = __iw_set_commit(dev, info, wrqu, extra);
4226 cds_ssr_unprotect(__func__);
4227
4228 return ret;
4229}
4230
4231/**
4232 * __iw_get_name() - SIOCGIWNAME ioctl handler
4233 * @dev: device upon which the ioctl was received
4234 * @info: ioctl request information
4235 * @wrqu: ioctl request data
4236 * @extra: ioctl extra data
4237 *
4238 * Return: 0 on success, non-zero on error
4239 */
4240static int __iw_get_name(struct net_device *dev,
4241 struct iw_request_info *info, char *wrqu, char *extra)
4242{
4243 hdd_adapter_t *adapter;
4244 hdd_context_t *hdd_ctx;
4245 int ret;
4246
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004247 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248
4249 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4250 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4251 ret = wlan_hdd_validate_context(hdd_ctx);
4252 if (0 != ret)
4253 return ret;
4254
Jeff Johnson441e1f72017-02-07 08:50:49 -08004255 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4256 if (0 != ret)
4257 return ret;
4258
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
4260 EXIT();
4261 return 0;
4262}
4263
4264/**
4265 * __iw_get_name() - SSR wrapper for __iw_get_name
4266 * @dev: pointer to net_device
4267 * @info: pointer to iw_request_info
4268 * @wrqu: pointer to iwreq_data
4269 * @extra: extra
4270 *
4271 * Return: 0 on success, error number otherwise
4272 */
4273static int iw_get_name(struct net_device *dev,
4274 struct iw_request_info *info,
4275 char *wrqu, char *extra)
4276{
4277 int ret;
4278
4279 cds_ssr_protect(__func__);
4280 ret = __iw_get_name(dev, info, wrqu, extra);
4281 cds_ssr_unprotect(__func__);
4282
4283 return ret;
4284}
4285
4286/**
4287 * __iw_set_mode() - ioctl handler
4288 * @dev: device upon which the ioctl was received
4289 * @info: ioctl request information
4290 * @wrqu: ioctl request data
4291 * @extra: ioctl extra data
4292 *
4293 * Return: 0 on success, non-zero on error
4294 */
4295static int __iw_set_mode(struct net_device *dev,
4296 struct iw_request_info *info,
4297 union iwreq_data *wrqu, char *extra)
4298{
4299 hdd_wext_state_t *pWextState;
4300 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4301 hdd_context_t *hdd_ctx;
4302 tCsrRoamProfile *pRoamProfile;
4303 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004304 struct hdd_config *pConfig;
4305 struct wireless_dev *wdev;
4306 int ret;
4307
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004308 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309
4310 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4311 ret = wlan_hdd_validate_context(hdd_ctx);
4312 if (0 != ret)
4313 return ret;
4314
Jeff Johnson441e1f72017-02-07 08:50:49 -08004315 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4316 if (0 != ret)
4317 return ret;
4318
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4320 wdev = dev->ieee80211_ptr;
4321 pRoamProfile = &pWextState->roamProfile;
4322 LastBSSType = pRoamProfile->BSSType;
4323
Jeff Johnson99bac312016-06-28 10:38:18 -07004324 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325
4326 switch (wrqu->mode) {
4327 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07004328 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
4330 /* Set the phymode correctly for IBSS. */
4331 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
4332 pWextState->roamProfile.phyMode =
4333 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08004334 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 wdev->iftype = NL80211_IFTYPE_ADHOC;
4336 break;
4337 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07004338 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
4340 wdev->iftype = NL80211_IFTYPE_STATION;
4341 break;
4342 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07004343 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
4345 break;
4346 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004347 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348 return -EOPNOTSUPP;
4349 }
4350
4351 if (LastBSSType != pRoamProfile->BSSType) {
4352 /* the BSS mode changed. We need to issue disconnect
4353 * if connected or in IBSS disconnect state
4354 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07004355 if (hdd_conn_is_connected
4356 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004357 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304358 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359 /* need to issue a disconnect to CSR. */
4360 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304361 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4363 pAdapter->sessionId,
4364 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304365 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366 unsigned long rc;
4367 rc = wait_for_completion_timeout(&pAdapter->
4368 disconnect_comp_var,
4369 msecs_to_jiffies
4370 (WLAN_WAIT_TIME_DISCONNECT));
4371 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004372 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373 }
4374 }
4375 }
4376
4377 EXIT();
4378 return 0;
4379}
4380
4381/**
4382 * iw_set_mode() - SSR wrapper for __iw_set_mode()
4383 * @dev: pointer to net_device
4384 * @info: pointer to iw_request_info
4385 * @wrqu: pointer to iwreq_data
4386 * @extra: pointer to extra ioctl payload
4387 *
4388 * Return: 0 on success, error number otherwise
4389 */
4390static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
4391 union iwreq_data *wrqu, char *extra)
4392{
4393 int ret;
4394
4395 cds_ssr_protect(__func__);
4396 ret = __iw_set_mode(dev, info, wrqu, extra);
4397 cds_ssr_unprotect(__func__);
4398
4399 return ret;
4400}
4401
4402/**
4403 * __iw_get_mode() - SIOCGIWMODE ioctl handler
4404 * @dev: device upon which the ioctl was received
4405 * @info: ioctl request information
4406 * @wrqu: ioctl request data
4407 * @extra: ioctl extra data
4408 *
4409 * Return: 0 on success, non-zero on error
4410 */
4411static int
4412__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4413 union iwreq_data *wrqu, char *extra)
4414{
4415 hdd_wext_state_t *pWextState;
4416 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4417 hdd_context_t *hdd_ctx;
4418 int ret;
4419
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004420 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421
4422 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4423 ret = wlan_hdd_validate_context(hdd_ctx);
4424 if (0 != ret)
4425 return ret;
4426
Jeff Johnson441e1f72017-02-07 08:50:49 -08004427 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4428 if (0 != ret)
4429 return ret;
4430
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4432
4433 switch (pWextState->roamProfile.BSSType) {
4434 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07004435 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 wrqu->mode = IW_MODE_INFRA;
4437 break;
4438 case eCSR_BSS_TYPE_IBSS:
4439 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07004440 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 wrqu->mode = IW_MODE_ADHOC;
4442 break;
4443 case eCSR_BSS_TYPE_ANY:
4444 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004445 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446 wrqu->mode = IW_MODE_AUTO;
4447 break;
4448 }
4449
4450 EXIT();
4451 return 0;
4452}
4453
4454/**
4455 * iw_get_mode() - SSR wrapper for __iw_get_mode()
4456 * @dev: pointer to net_device
4457 * @info: pointer to iw_request_info
4458 * @wrqu: pointer to iwreq_data
4459 * @extra: pointer to extra ioctl payload
4460 *
4461 * Return: 0 on success, error number otherwise
4462 */
4463static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4464 union iwreq_data *wrqu, char *extra)
4465{
4466 int ret;
4467
4468 cds_ssr_protect(__func__);
4469 ret = __iw_get_mode(dev, info, wrqu, extra);
4470 cds_ssr_unprotect(__func__);
4471
4472 return ret;
4473}
4474
4475/**
4476 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
4477 * @dev: device upon which the ioctl was received
4478 * @info: ioctl request information
4479 * @wrqu: ioctl request data
4480 * @extra: ioctl extra data
4481 *
4482 * Return: 0 on success, non-zero on error
4483 */
4484static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4485 union iwreq_data *wrqu, char *extra)
4486{
4487 uint32_t numChans = 0;
4488 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4489 uint32_t indx = 0;
4490 int ret;
4491 hdd_wext_state_t *pWextState;
4492 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4493 hdd_context_t *hdd_ctx;
4494 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4495 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4496 tCsrRoamProfile *pRoamProfile;
4497
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004498 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499
4500 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4501 ret = wlan_hdd_validate_context(hdd_ctx);
4502 if (0 != ret)
4503 return ret;
4504
Jeff Johnson441e1f72017-02-07 08:50:49 -08004505 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4506 if (0 != ret)
4507 return ret;
4508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4510
4511 pRoamProfile = &pWextState->roamProfile;
4512
Jeff Johnson99bac312016-06-28 10:38:18 -07004513 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514
4515 /* Link is up then return cant set channel */
4516 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
4517 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004518 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 return -EOPNOTSUPP;
4520 }
4521
4522 /* Settings by Frequency as input */
4523 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
4524 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
4525 uint32_t freq = wrqu->freq.m / 100000;
4526
4527 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
4528 && (freq != freq_chan_map[indx].freq))
4529 indx++;
4530 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
4531 return -EINVAL;
4532 }
4533 wrqu->freq.e = 0;
4534 wrqu->freq.m = freq_chan_map[indx].chan;
4535
4536 }
4537
4538 if (wrqu->freq.e == 0) {
4539 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
4540 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004541 hdd_notice("Channel %d is outside valid range from %d to %d",
4542 wrqu->freq.m,
4543 WNI_CFG_CURRENT_CHANNEL_STAMIN,
4544 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 return -EINVAL;
4546 }
4547
4548 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4549
4550 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
4551 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304552 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004553 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 return -EIO;
4555 }
4556
4557 for (indx = 0; indx < numChans; indx++) {
4558 if (wrqu->freq.m == validChan[indx]) {
4559 break;
4560 }
4561 }
4562 } else {
4563
4564 return -EINVAL;
4565 }
4566
4567 if (indx >= numChans) {
4568 return -EINVAL;
4569 }
4570
4571 /* Set the Operational Channel */
4572 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
4573 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
4574 pRoamProfile->ChannelInfo.ChannelList =
4575 &pHddStaCtx->conn_info.operationChannel;
4576
Jeff Johnson99bac312016-06-28 10:38:18 -07004577 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578
4579 EXIT();
4580
4581 return ret;
4582}
4583
4584/**
4585 * iw_set_freq() - SSR wrapper for __iw_set_freq()
4586 * @dev: pointer to net_device
4587 * @info: pointer to iw_request_info
4588 * @wrqu: pointer to iwreq_data
4589 * @extra: pointer to extra ioctl payload
4590 *
4591 * Return: 0 on success, error number otherwise
4592 */
4593static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4594 union iwreq_data *wrqu, char *extra)
4595{
4596 int ret;
4597
4598 cds_ssr_protect(__func__);
4599 ret = __iw_set_freq(dev, info, wrqu, extra);
4600 cds_ssr_unprotect(__func__);
4601
4602 return ret;
4603}
4604
4605/**
4606 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
4607 * @dev: device upon which the ioctl was received
4608 * @info: ioctl request information
4609 * @wrqu: ioctl request data
4610 * @extra: ioctl extra data
4611 *
4612 * Return: 0 on success, non-zero on error
4613 */
4614static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4615 struct iw_freq *fwrq, char *extra)
4616{
4617 uint32_t status = false, channel = 0, freq = 0;
4618 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4619 tHalHandle hHal;
4620 hdd_wext_state_t *pWextState;
4621 tCsrRoamProfile *pRoamProfile;
4622 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4623 hdd_context_t *hdd_ctx;
4624 int ret;
4625
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004626 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627
4628 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4629 ret = wlan_hdd_validate_context(hdd_ctx);
4630 if (0 != ret)
4631 return ret;
4632
Jeff Johnson441e1f72017-02-07 08:50:49 -08004633 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4634 if (0 != ret)
4635 return ret;
4636
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4638 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4639
4640 pRoamProfile = &pWextState->roamProfile;
4641
4642 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
4643 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304644 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004645 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 pAdapter->sessionId);
4647 return -EIO;
Jeff Johnson68755312017-02-10 11:46:55 -08004648 }
4649
4650 status = hdd_wlan_get_freq(channel, &freq);
4651 if (true == status) {
4652 /* Set Exponent parameter as 6 (MHZ)
4653 * in struct iw_freq iwlist & iwconfig
4654 * command shows frequency into proper
4655 * format (2.412 GHz instead of 246.2
4656 * MHz)
4657 */
4658 fwrq->m = freq;
4659 fwrq->e = MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 }
4661 } else {
4662 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4663 * iwlist & iwconfig command shows frequency into proper
4664 * format (2.412 GHz instead of 246.2 MHz)
4665 */
4666 fwrq->m = 0;
4667 fwrq->e = MHZ;
4668 }
4669 return 0;
4670}
4671
4672/**
4673 * iw_get_freq() - SSR wrapper for __iw_get_freq()
4674 * @dev: pointer to net_device
4675 * @info: pointer to iw_request_info
4676 * @fwrq: pointer to frequency data
4677 * @extra: pointer to extra ioctl payload
4678 *
4679 * Return: 0 on success, error number otherwise
4680 */
4681static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4682 struct iw_freq *fwrq, char *extra)
4683{
4684 int ret;
4685
4686 cds_ssr_protect(__func__);
4687 ret = __iw_get_freq(dev, info, fwrq, extra);
4688 cds_ssr_unprotect(__func__);
4689
4690 return ret;
4691}
4692
4693/**
4694 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
4695 * @dev: device upon which the ioctl was received
4696 * @info: ioctl request information
4697 * @wrqu: ioctl request data
4698 * @extra: ioctl extra data
4699 *
4700 * Return: 0 on success, non-zero on error
4701 */
4702static int __iw_get_tx_power(struct net_device *dev,
4703 struct iw_request_info *info,
4704 union iwreq_data *wrqu, char *extra)
4705{
4706
4707 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4708 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4709 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4710 int ret;
4711
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004712 ENTER_DEV(dev);
4713
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 ret = wlan_hdd_validate_context(hdd_ctx);
4715 if (0 != ret)
4716 return ret;
4717
Jeff Johnson441e1f72017-02-07 08:50:49 -08004718 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4719 if (0 != ret)
4720 return ret;
4721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4723 wrqu->txpower.value = 0;
4724 return 0;
4725 }
4726 wlan_hdd_get_class_astats(pAdapter);
4727 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
4728
4729 return 0;
4730}
4731
4732/**
4733 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
4734 * @dev: pointer to net_device
4735 * @info: pointer to iw_request_info
4736 * @wrqu: pointer to iwreq_data
4737 * @extra: pointer to extra ioctl payload
4738 *
4739 * Return: 0 on success, error number otherwise
4740 */
4741static int iw_get_tx_power(struct net_device *dev,
4742 struct iw_request_info *info,
4743 union iwreq_data *wrqu, char *extra)
4744{
4745 int ret;
4746
4747 cds_ssr_protect(__func__);
4748 ret = __iw_get_tx_power(dev, info, wrqu, extra);
4749 cds_ssr_unprotect(__func__);
4750
4751 return ret;
4752}
4753
4754/**
4755 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
4756 * @dev: device upon which the ioctl was received
4757 * @info: ioctl request information
4758 * @wrqu: ioctl request data
4759 * @extra: ioctl extra data
4760 *
4761 * Return: 0 on success, non-zero on error
4762 */
4763static int __iw_set_tx_power(struct net_device *dev,
4764 struct iw_request_info *info,
4765 union iwreq_data *wrqu, char *extra)
4766{
4767 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4768 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4769 hdd_context_t *hdd_ctx;
4770 int ret;
4771
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004772 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004773
4774 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4775 ret = wlan_hdd_validate_context(hdd_ctx);
4776 if (0 != ret)
4777 return ret;
4778
Jeff Johnson441e1f72017-02-07 08:50:49 -08004779 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4780 if (0 != ret)
4781 return ret;
4782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304784 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004785 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786 return -EIO;
4787 }
4788
4789 EXIT();
4790
4791 return 0;
4792}
4793
4794/**
4795 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
4796 * @dev: pointer to net_device
4797 * @info: pointer to iw_request_info
4798 * @wrqu: pointer to iwreq_data
4799 * @extra: pointer to extra ioctl payload
4800 *
4801 * Return: 0 on success, error number otherwise
4802 */
4803static int iw_set_tx_power(struct net_device *dev,
4804 struct iw_request_info *info,
4805 union iwreq_data *wrqu, char *extra)
4806{
4807 int ret;
4808
4809 cds_ssr_protect(__func__);
4810 ret = __iw_set_tx_power(dev, info, wrqu, extra);
4811 cds_ssr_unprotect(__func__);
4812
4813 return ret;
4814}
4815
4816/**
4817 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
4818 * @dev: device upon which the ioctl was received
4819 * @info: ioctl request information
4820 * @wrqu: ioctl request data
4821 * @extra: ioctl extra data
4822 *
4823 * Return: 0 on success, non-zero on error
4824 */
4825static int __iw_get_bitrate(struct net_device *dev,
4826 struct iw_request_info *info,
4827 union iwreq_data *wrqu, char *extra)
4828{
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004829 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830 hdd_wext_state_t *pWextState;
4831 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4832 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4833 hdd_context_t *hdd_ctx;
4834 int ret;
4835
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004836 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837
4838 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4839 ret = wlan_hdd_validate_context(hdd_ctx);
4840 if (0 != ret)
4841 return ret;
4842
Jeff Johnson441e1f72017-02-07 08:50:49 -08004843 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4844 if (0 != ret)
4845 return ret;
4846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4848 wrqu->bitrate.value = 0;
4849 } else {
4850 status =
4851 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4852 eCSR_HDD,
4853 SME_SUMMARY_STATS |
4854 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -08004855 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856 hdd_statistics_cb, 0,
4857 false,
4858 pHddStaCtx->conn_info.staId[0],
4859 pAdapter, pAdapter->sessionId);
4860
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304861 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004862 hdd_err("Unable to retrieve statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004863 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 }
4865
4866 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4867
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004868 status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304869 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870 WLAN_WAIT_TIME_STATS);
4871
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004872 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004873 hdd_err("SME timeout while retrieving statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004874 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004875 }
4876
4877 wrqu->bitrate.value =
4878 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
4879 }
4880
4881 EXIT();
4882
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004883 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884}
4885
4886/**
4887 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
4888 * @dev: pointer to net_device
4889 * @info: pointer to iw_request_info
4890 * @wrqu: pointer to iwreq_data
4891 * @extra: pointer to extra ioctl payload
4892 *
4893 * Return: 0 on success, error number otherwise
4894 */
4895static int iw_get_bitrate(struct net_device *dev,
4896 struct iw_request_info *info,
4897 union iwreq_data *wrqu, char *extra)
4898{
4899 int ret;
4900
4901 cds_ssr_protect(__func__);
4902 ret = __iw_get_bitrate(dev, info, wrqu, extra);
4903 cds_ssr_unprotect(__func__);
4904
4905 return ret;
4906}
4907
4908/**
4909 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
4910 * @dev: device upon which the ioctl was received
4911 * @info: ioctl request information
4912 * @wrqu: ioctl request data
4913 * @extra: ioctl extra data
4914 *
4915 * Return: 0 on success, non-zero on error
4916 */
4917static int __iw_set_bitrate(struct net_device *dev,
4918 struct iw_request_info *info,
4919 union iwreq_data *wrqu, char *extra)
4920{
4921 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4922 hdd_wext_state_t *pWextState;
4923 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4924 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4925 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4926 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4927 uint32_t i, rate;
4928 uint32_t valid_rate = false, active_phy_mode = 0;
4929 hdd_context_t *hdd_ctx;
4930 int ret;
4931
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004932 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933
4934 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4935 ret = wlan_hdd_validate_context(hdd_ctx);
4936 if (0 != ret)
4937 return ret;
4938
Jeff Johnson441e1f72017-02-07 08:50:49 -08004939 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4940 if (0 != ret)
4941 return ret;
4942
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004943 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4944
4945 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4946 return -ENXIO;
4947 }
4948
4949 rate = wrqu->bitrate.value;
4950
4951 if (rate == -1) {
4952 rate = WNI_CFG_FIXED_RATE_AUTO;
4953 valid_rate = true;
4954 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
4955 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304956 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
4958 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
4959 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
4960 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
4961 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304962 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004963 &&
4964 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
4965 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304966 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004967 for (i = 0; i < (b_len + a_len); ++i) {
4968 /* supported rates returned is double
4969 * the actual rate so we divide it by 2
4970 */
4971 if ((supp_rates[i] & 0x7F) / 2 ==
4972 rate) {
4973 valid_rate = true;
4974 rate = i +
4975 WNI_CFG_FIXED_RATE_1MBPS;
4976 break;
4977 }
4978 }
4979 }
4980 }
4981 }
4982 if (valid_rate != true) {
4983 return -EINVAL;
4984 }
4985 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304986 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004987 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988 return -EIO;
4989 }
4990 return 0;
4991}
4992
4993/**
4994 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
4995 * @dev: pointer to net_device
4996 * @info: pointer to iw_request_info
4997 * @wrqu: pointer to iwreq_data
4998 * @extra: pointer to extra ioctl payload
4999 *
5000 * Return: 0 on success, error number otherwise
5001 */
5002static int iw_set_bitrate(struct net_device *dev,
5003 struct iw_request_info *info,
5004 union iwreq_data *wrqu, char *extra)
5005{
5006 int ret;
5007
5008 cds_ssr_protect(__func__);
5009 ret = __iw_set_bitrate(dev, info, wrqu, extra);
5010 cds_ssr_unprotect(__func__);
5011
5012 return ret;
5013}
5014
5015/**
5016 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
5017 * @dev: device upon which the ioctl was received
5018 * @info: ioctl request information
5019 * @wrqu: ioctl request data
5020 * @extra: ioctl extra data
5021 *
5022 * Return: 0 on success, non-zero on error
5023 */
5024static int __iw_set_genie(struct net_device *dev,
5025 struct iw_request_info *info,
5026 union iwreq_data *wrqu, char *extra)
5027{
5028 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5029 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5030 uint8_t *genie = NULL;
5031 uint8_t *base_genie = NULL;
5032 uint16_t remLen;
5033 hdd_context_t *hdd_ctx;
5034 int ret;
5035
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005036 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005037
5038 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5039 ret = wlan_hdd_validate_context(hdd_ctx);
5040 if (0 != ret)
5041 return ret;
5042
Jeff Johnson441e1f72017-02-07 08:50:49 -08005043 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5044 if (0 != ret)
5045 return ret;
5046
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005047 if (!wrqu->data.length) {
5048 hdd_clear_roam_profile_ie(pAdapter);
5049 EXIT();
5050 return 0;
5051 }
5052
5053 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
5054 wrqu->data.length);
5055 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005056 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005057 return -ENOMEM;
5058 }
5059
5060 genie = base_genie;
5061
5062 remLen = wrqu->data.length;
5063
Jeff Johnson99bac312016-06-28 10:38:18 -07005064 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005065 genie[1]);
5066
5067 /* clear any previous genIE before this call */
5068 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5069
5070 while (remLen >= 2) {
5071 uint16_t eLen = 0;
5072 uint8_t elementId;
5073 elementId = *genie++;
5074 eLen = *genie++;
5075 remLen -= 2;
5076
Jeff Johnson99bac312016-06-28 10:38:18 -07005077 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078
5079 switch (elementId) {
5080 case IE_EID_VENDOR:
5081 if ((IE_LEN_SIZE + IE_EID_SIZE + IE_VENDOR_OUI_SIZE) > eLen) { /* should have at least OUI */
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305082 ret = -EINVAL;
5083 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 }
5085
5086 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
5087 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07005088 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
5089 genie[0], genie[1], genie[2],
5090 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091
5092 if (SIR_MAC_MAX_IE_LENGTH <
5093 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005094 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305095 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305096 ret = -ENOMEM;
5097 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098 }
5099 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
5100 memcpy(pWextState->genIE.addIEdata +
5101 curGenIELen, genie - 2, eLen + 2);
5102 pWextState->genIE.length += eLen + 2;
5103 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005104 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305105 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
5106 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
5107 ret = -EINVAL;
5108 QDF_ASSERT(0);
5109 goto exit;
5110 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005111 memset(pWextState->WPARSNIE, 0,
5112 MAX_WPA_RSN_IE_LEN);
5113 memcpy(pWextState->WPARSNIE, genie - 2,
5114 (eLen + 2));
5115 pWextState->roamProfile.pWPAReqIE =
5116 pWextState->WPARSNIE;
5117 pWextState->roamProfile.nWPAReqIELength =
5118 eLen + 2;
5119 } else { /* any vendorId except WPA IE should be accumulated to genIE */
5120
5121 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07005122 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
5123 genie[0], genie[1], genie[2],
5124 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005125
5126 if (SIR_MAC_MAX_IE_LENGTH <
5127 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005128 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305129 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305130 ret = -ENOMEM;
5131 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 }
5133 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
5134 memcpy(pWextState->genIE.addIEdata +
5135 curGenIELen, genie - 2, eLen + 2);
5136 pWextState->genIE.length += eLen + 2;
5137 }
5138 break;
5139 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07005140 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305141 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
5142 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
5143 ret = -EINVAL;
5144 QDF_ASSERT(0);
5145 goto exit;
5146 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
5148 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
5149 pWextState->roamProfile.pRSNReqIE =
5150 pWextState->WPARSNIE;
5151 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
5152 break;
5153
5154 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005155 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305156 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005157 }
5158 genie += eLen;
5159 remLen -= eLen;
5160 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305161exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07005163 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305164 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165}
5166
5167/**
5168 * iw_set_genie() - SSR wrapper for __iw_set_genie()
5169 * @dev: pointer to net_device
5170 * @info: pointer to iw_request_info
5171 * @wrqu: pointer to iwreq_data
5172 * @extra: pointer to extra ioctl payload
5173 *
5174 * Return: 0 on success, error number otherwise
5175 */
5176static int iw_set_genie(struct net_device *dev,
5177 struct iw_request_info *info,
5178 union iwreq_data *wrqu, char *extra)
5179{
5180 int ret;
5181
5182 cds_ssr_protect(__func__);
5183 ret = __iw_set_genie(dev, info, wrqu, extra);
5184 cds_ssr_unprotect(__func__);
5185
5186 return ret;
5187}
5188
5189/**
5190 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
5191 * @dev: device upon which the ioctl was received
5192 * @info: ioctl request information
5193 * @wrqu: ioctl request data
5194 * @extra: ioctl extra data
5195 *
5196 * Return: 0 on success, non-zero on error
5197 */
5198static int __iw_get_genie(struct net_device *dev,
5199 struct iw_request_info *info,
5200 union iwreq_data *wrqu, char *extra)
5201{
5202 hdd_wext_state_t *pWextState;
5203 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5204 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305205 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
5207 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
5208 hdd_context_t *hdd_ctx;
5209 int ret;
5210
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005211 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005212
5213 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5214 ret = wlan_hdd_validate_context(hdd_ctx);
5215 if (0 != ret)
5216 return ret;
5217
Jeff Johnson441e1f72017-02-07 08:50:49 -08005218 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5219 if (0 != ret)
5220 return ret;
5221
Jeff Johnson99bac312016-06-28 10:38:18 -07005222 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005223
5224 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5225
5226 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
5227 return -ENXIO;
5228 }
5229
5230 /* Return something ONLY if we are associated with an RSN or
5231 * WPA network
5232 */
5233 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
5234 return -ENXIO;
5235 }
5236
5237 /* Actually retrieve the RSN IE from CSR. (We previously sent
5238 * it down in the CSR Roam Profile.)
5239 */
5240 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
5241 pAdapter->sessionId,
5242 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305243 if (QDF_STATUS_SUCCESS != status) {
5244 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005245 return -EFAULT;
5246 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05305248 if (length > DOT11F_IE_RSN_MAX_LEN) {
5249 hdd_notice("invalid buffer length length:%d", length);
5250 return -E2BIG;
5251 }
5252 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005253
Jeff Johnson99bac312016-06-28 10:38:18 -07005254 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 wrqu->data.length);
5256
5257 EXIT();
5258
5259 return 0;
5260}
5261
5262/**
5263 * iw_get_genie() - SSR wrapper for __iw_get_genie()
5264 * @dev: pointer to net_device
5265 * @info: pointer to iw_request_info
5266 * @wrqu: pointer to iwreq_data
5267 * @extra: pointer to extra ioctl payload
5268 *
5269 * Return: 0 on success, error number otherwise
5270 */
5271static int iw_get_genie(struct net_device *dev,
5272 struct iw_request_info *info,
5273 union iwreq_data *wrqu, char *extra)
5274{
5275 int ret;
5276
5277 cds_ssr_protect(__func__);
5278 ret = __iw_get_genie(dev, info, wrqu, extra);
5279 cds_ssr_unprotect(__func__);
5280
5281 return ret;
5282}
5283
5284/**
5285 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
5286 * @dev: device upon which the ioctl was received
5287 * @info: ioctl request information
5288 * @wrqu: ioctl request data
5289 * @extra: ioctl extra data
5290 *
5291 * Return: 0 on success, non-zero on error
5292 */
5293static int __iw_get_encode(struct net_device *dev,
5294 struct iw_request_info *info,
5295 struct iw_point *dwrq, char *extra)
5296{
5297 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5298 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5299 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5300 int keyId;
5301 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
5302 int i;
5303 hdd_context_t *hdd_ctx;
5304 int ret;
5305
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005306 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307
5308 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5309 ret = wlan_hdd_validate_context(hdd_ctx);
5310 if (0 != ret)
5311 return ret;
5312
Jeff Johnson441e1f72017-02-07 08:50:49 -08005313 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5314 if (0 != ret)
5315 return ret;
5316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 keyId = pRoamProfile->Keys.defaultIndex;
5318
5319 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005320 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 return -EINVAL;
5322 }
5323
5324 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
5325 dwrq->flags |= IW_ENCODE_ENABLED;
5326 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305327 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328 pRoamProfile->Keys.KeyLength[keyId]);
5329
5330 dwrq->flags |= (keyId + 1);
5331
5332 } else {
5333 dwrq->flags |= IW_ENCODE_DISABLED;
5334 }
5335
5336 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08005337 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338 continue;
5339 } else {
5340 break;
5341 }
5342 }
5343
5344 if (MAX_WEP_KEYS == i) {
5345 dwrq->flags |= IW_ENCODE_NOKEY;
5346 }
5347
5348 authType =
5349 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
5350 conn_info.authType;
5351
5352 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
5353 dwrq->flags |= IW_ENCODE_OPEN;
5354 } else {
5355 dwrq->flags |= IW_ENCODE_RESTRICTED;
5356 }
5357 EXIT();
5358 return 0;
5359}
5360
5361/**
5362 * iw_get_encode() - SSR wrapper for __iw_get_encode()
5363 * @dev: pointer to net_device
5364 * @info: pointer to iw_request_info
5365 * @dwrq: pointer to encoding information
5366 * @extra: pointer to extra ioctl payload
5367 *
5368 * Return: 0 on success, error number otherwise
5369 */
5370static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
5371 struct iw_point *dwrq, char *extra)
5372{
5373 int ret;
5374
5375 cds_ssr_protect(__func__);
5376 ret = __iw_get_encode(dev, info, dwrq, extra);
5377 cds_ssr_unprotect(__func__);
5378
5379 return ret;
5380}
5381
5382/**
5383 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
5384 * @dev: device upon which the ioctl was received
5385 * @info: ioctl request information
5386 * @wrqu: ioctl request data
5387 * @extra: ioctl extra data
5388 *
5389 * Return: 0 on success, non-zero on error
5390 */
5391static int __iw_get_rts_threshold(struct net_device *dev,
5392 struct iw_request_info *info,
5393 union iwreq_data *wrqu, char *extra)
5394{
Jeff Johnson5b907622017-02-07 10:00:37 -08005395 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5396 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5397 uint32_t threshold = 0;
5398 hdd_context_t *hdd_ctx;
5399 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005401 ENTER_DEV(dev);
5402
Jeff Johnson5b907622017-02-07 10:00:37 -08005403 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5404 ret = wlan_hdd_validate_context(hdd_ctx);
5405 if (0 != ret)
5406 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407
Jeff Johnson441e1f72017-02-07 08:50:49 -08005408 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5409 if (0 != ret)
5410 return ret;
5411
Jeff Johnson5b907622017-02-07 10:00:37 -08005412 if (QDF_STATUS_SUCCESS !=
5413 sme_cfg_get_int(hal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
5414 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
5415 return -EIO;
5416 }
5417 wrqu->rts.value = threshold;
5418
5419 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
5420
5421 EXIT();
5422
5423 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424}
5425
5426/**
5427 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
5428 * @dev: device upon which the ioctl was received
5429 * @info: ioctl request information
5430 * @wrqu: ioctl request data
5431 * @extra: ioctl extra data
5432 *
5433 * Return: 0 on success, non-zero on error
5434 */
5435static int __iw_set_rts_threshold(struct net_device *dev,
5436 struct iw_request_info *info,
5437 union iwreq_data *wrqu, char *extra)
5438{
5439 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5440 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5441 hdd_context_t *hdd_ctx;
5442 int ret;
5443
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005444 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445
5446 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5447 ret = wlan_hdd_validate_context(hdd_ctx);
5448 if (0 != ret)
5449 return ret;
5450
Jeff Johnson441e1f72017-02-07 08:50:49 -08005451 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5452 if (0 != ret)
5453 return ret;
5454
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
5456 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
5457 return -EINVAL;
5458 }
5459
5460 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305461 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005462 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463 return -EIO;
5464 }
5465
5466 EXIT();
5467
5468 return 0;
5469}
5470
5471/**
5472 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
5473 * @dev: pointer to net_device
5474 * @info: pointer to iw_request_info
5475 * @wrqu: pointer to iwreq_data
5476 * @extra: pointer to extra ioctl payload
5477 *
5478 * Return: 0 on success, error number otherwise
5479 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005480int iw_get_rts_threshold(struct net_device *dev,
5481 struct iw_request_info *info,
5482 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483{
5484 int ret;
5485
5486 cds_ssr_protect(__func__);
5487 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
5488 cds_ssr_unprotect(__func__);
5489
5490 return ret;
5491}
5492
5493/**
5494 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
5495 * @dev: pointer to net_device
5496 * @info: pointer to iw_request_info
5497 * @wrqu: pointer to iwreq_data
5498 * @extra: pointer to extra ioctl payload
5499 *
5500 * Return: 0 on success, error number otherwise
5501 */
5502static int iw_set_rts_threshold(struct net_device *dev,
5503 struct iw_request_info *info,
5504 union iwreq_data *wrqu, char *extra)
5505{
5506 int ret;
5507
5508 cds_ssr_protect(__func__);
5509 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
5510 cds_ssr_unprotect(__func__);
5511
5512 return ret;
5513}
5514
5515/**
5516 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
5517 * @dev: device upon which the ioctl was received
5518 * @info: ioctl request information
5519 * @wrqu: ioctl request data
5520 * @extra: ioctl extra data
5521 *
5522 * Return: 0 on success, non-zero on error
5523 */
5524static int __iw_get_frag_threshold(struct net_device *dev,
5525 struct iw_request_info *info,
5526 union iwreq_data *wrqu, char *extra)
5527{
Jeff Johnson5b907622017-02-07 10:00:37 -08005528 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5529 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5530 uint32_t threshold = 0;
5531 hdd_context_t *hdd_ctx;
5532 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005533
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005534 ENTER_DEV(dev);
5535
Jeff Johnson5b907622017-02-07 10:00:37 -08005536 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5537 ret = wlan_hdd_validate_context(hdd_ctx);
5538 if (0 != ret)
5539 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005540
Jeff Johnson441e1f72017-02-07 08:50:49 -08005541 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5542 if (0 != ret)
5543 return ret;
5544
Jeff Johnson5b907622017-02-07 10:00:37 -08005545 if (sme_cfg_get_int(hal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
5546 != QDF_STATUS_SUCCESS) {
5547 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
5548 return -EIO;
5549 }
5550 wrqu->frag.value = threshold;
5551
5552 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
5553
5554 EXIT();
5555
5556 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557}
5558
5559/**
5560 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
5561 * @dev: pointer to net_device
5562 * @info: pointer to iw_request_info
5563 * @wrqu: pointer to iwreq_data
5564 * @extra: pointer to extra ioctl payload
5565 *
5566 * Return: 0 on success, error number otherwise
5567 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005568int iw_get_frag_threshold(struct net_device *dev,
5569 struct iw_request_info *info,
5570 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005571{
5572 int ret;
5573
5574 cds_ssr_protect(__func__);
5575 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
5576 cds_ssr_unprotect(__func__);
5577
5578 return ret;
5579}
5580
5581/**
5582 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
5583 * @dev: device upon which the ioctl was received
5584 * @info: ioctl request information
5585 * @wrqu: ioctl request data
5586 * @extra: ioctl extra data
5587 *
5588 * Return: 0 on success, non-zero on error
5589 */
5590static int __iw_set_frag_threshold(struct net_device *dev,
5591 struct iw_request_info *info,
5592 union iwreq_data *wrqu, char *extra)
5593{
5594 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5595 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5596 hdd_context_t *hdd_ctx;
5597 int ret;
5598
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005599 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005600
5601 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5602 ret = wlan_hdd_validate_context(hdd_ctx);
5603 if (0 != ret)
5604 return ret;
5605
Jeff Johnson441e1f72017-02-07 08:50:49 -08005606 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5607 if (0 != ret)
5608 return ret;
5609
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
5611 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
5612 return -EINVAL;
5613 }
5614
5615 if (sme_cfg_set_int
5616 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305617 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005618 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 return -EIO;
5620 }
5621
5622 EXIT();
5623
5624 return 0;
5625}
5626
5627/**
5628 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
5629 * @dev: pointer to net_device
5630 * @info: pointer to iw_request_info
5631 * @wrqu: pointer to iwreq_data
5632 * @extra: pointer to extra ioctl payload
5633 *
5634 * Return: 0 on success, error number otherwise
5635 */
5636static int iw_set_frag_threshold(struct net_device *dev,
5637 struct iw_request_info *info,
5638 union iwreq_data *wrqu, char *extra)
5639{
5640 int ret;
5641
5642 cds_ssr_protect(__func__);
5643 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
5644 cds_ssr_unprotect(__func__);
5645
5646 return ret;
5647}
5648
5649/**
5650 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
5651 * @dev: device upon which the ioctl was received
5652 * @info: ioctl request information
5653 * @wrqu: ioctl request data
5654 * @extra: ioctl extra data
5655 *
5656 * Return: 0 on success, non-zero on error
5657 */
5658static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005659 struct iw_request_info *info,
5660 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661{
5662 hdd_adapter_t *adapter;
5663 hdd_context_t *hdd_ctx;
5664 int ret;
5665
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005666 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667
5668 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5669 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5670 ret = wlan_hdd_validate_context(hdd_ctx);
5671 if (0 != ret)
5672 return ret;
5673
Jeff Johnson441e1f72017-02-07 08:50:49 -08005674 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5675 if (0 != ret)
5676 return ret;
5677
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 return -EOPNOTSUPP;
5679}
5680
5681/**
5682 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
5683 * @dev: pointer to net_device
5684 * @info: pointer to iw_request_info
5685 * @wrqu: pointer to iwreq_data
5686 * @extra: extra
5687 *
5688 * Return: 0 on success, error number otherwise
5689 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005690static int iw_get_power_mode(struct net_device *dev,
5691 struct iw_request_info *info,
5692 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693{
5694 int ret;
5695
5696 cds_ssr_protect(__func__);
5697 ret = __iw_get_power_mode(dev, info, wrqu, extra);
5698 cds_ssr_unprotect(__func__);
5699
5700 return ret;
5701}
5702
5703/**
5704 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
5705 * @dev: device upon which the ioctl was received
5706 * @info: ioctl request information
5707 * @wrqu: ioctl request data
5708 * @extra: ioctl extra data
5709 *
5710 * Return: 0 on success, non-zero on error
5711 */
5712static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005713 struct iw_request_info *info,
5714 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005715{
5716 hdd_adapter_t *adapter;
5717 hdd_context_t *hdd_ctx;
5718 int ret;
5719
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005720 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721
5722 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5723 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5724 ret = wlan_hdd_validate_context(hdd_ctx);
5725 if (0 != ret)
5726 return ret;
5727
Jeff Johnson441e1f72017-02-07 08:50:49 -08005728 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5729 if (0 != ret)
5730 return ret;
5731
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005732 return -EOPNOTSUPP;
5733}
5734
5735/**
5736 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
5737 * @dev: pointer to net_device
5738 * @info: pointer to iw_request_info
5739 * @wrqu: pointer to iwreq_data
5740 * @extra: extra
5741 *
5742 * Return: 0 on success, error number otherwise
5743 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005744static int iw_set_power_mode(struct net_device *dev,
5745 struct iw_request_info *info,
5746 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747{
5748 int ret;
5749
5750 cds_ssr_protect(__func__);
5751 ret = __iw_set_power_mode(dev, info, wrqu, extra);
5752 cds_ssr_unprotect(__func__);
5753
5754 return ret;
5755}
5756
5757/**
5758 * __iw_get_range() - SIOCGIWRANGE ioctl handler
5759 * @dev: device upon which the ioctl was received
5760 * @info: ioctl request information
5761 * @wrqu: ioctl request data
5762 * @extra: ioctl extra data
5763 *
5764 * Return: 0 on success, non-zero on error
5765 */
5766static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
5767 union iwreq_data *wrqu, char *extra)
5768{
5769 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5770 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5771 struct iw_range *range = (struct iw_range *)extra;
5772
5773 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5774
5775 uint32_t num_channels = sizeof(channels);
5776 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
5777 uint32_t a_len;
5778 uint32_t b_len;
5779 uint32_t active_phy_mode = 0;
5780 uint8_t index = 0, i;
5781 hdd_context_t *hdd_ctx;
5782 int ret;
5783
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005784 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005785
5786 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5787 ret = wlan_hdd_validate_context(hdd_ctx);
5788 if (0 != ret)
5789 return ret;
5790
Jeff Johnson441e1f72017-02-07 08:50:49 -08005791 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5792 if (0 != ret)
5793 return ret;
5794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005795 wrqu->data.length = sizeof(struct iw_range);
5796 memset(range, 0, sizeof(struct iw_range));
5797
5798
5799 /*Get the phy mode */
5800 if (sme_cfg_get_int(hHal,
5801 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305802 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005803 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804
5805 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5806 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
5807 /*Get the supported rates for 11G band */
5808 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5809 if (sme_cfg_get_str(hHal,
5810 WNI_CFG_SUPPORTED_RATES_11A,
5811 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305812 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
5814 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5815 }
5816 for (i = 0; i < a_len; i++) {
5817 range->bitrate[i] =
5818 ((supp_rates[i] & 0x7F) / 2) *
5819 1000000;
5820 }
5821 range->num_bitrates = a_len;
5822 } else {
5823 return -EIO;
5824 }
5825 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
5826 /*Get the supported rates for 11B band */
5827 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5828 if (sme_cfg_get_str(hHal,
5829 WNI_CFG_SUPPORTED_RATES_11B,
5830 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305831 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005832 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
5833 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5834 }
5835 for (i = 0; i < b_len; i++) {
5836 range->bitrate[i] =
5837 ((supp_rates[i] & 0x7F) / 2) *
5838 1000000;
5839 }
5840 range->num_bitrates = b_len;
5841 } else {
5842 return -EIO;
5843 }
5844 }
5845 }
5846
5847 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
5848 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
5849 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
5850
5851 range->encoding_size[0] = 5;
5852 range->encoding_size[1] = 13;
5853 range->num_encoding_sizes = 2;
5854 range->max_encoding_tokens = MAX_WEP_KEYS;
5855
5856 /* we support through Wireless Extensions 22 */
5857 range->we_version_compiled = WIRELESS_EXT;
5858 range->we_version_source = 22;
5859
5860 /*Supported Channels and Frequencies */
5861 if (sme_cfg_get_str
5862 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305863 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005864 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005865 return -EIO;
5866 }
5867 if (num_channels > IW_MAX_FREQUENCIES) {
5868 num_channels = IW_MAX_FREQUENCIES;
5869 }
5870
5871 range->num_channels = num_channels;
5872 range->num_frequency = num_channels;
5873
5874 for (index = 0; index < num_channels; index++) {
5875 uint32_t frq_indx = 0;
5876
5877 range->freq[index].i = channels[index];
5878 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
5879 if (channels[index] == freq_chan_map[frq_indx].chan) {
5880 range->freq[index].m =
5881 freq_chan_map[frq_indx].freq * 100000;
5882 range->freq[index].e = 1;
5883 break;
5884 }
5885 frq_indx++;
5886 }
5887 }
5888
5889 /* Event capability (kernel + driver) */
5890 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
5891 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
5892 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
5893 range->event_capa[1] = IW_EVENT_CAPA_K_1;
5894
5895 /*Encryption capability */
5896 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
5897 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
5898
5899 /* Txpower capability */
5900 range->txpower_capa = IW_TXPOW_MWATT;
5901
5902 /*Scanning capability */
5903#if WIRELESS_EXT >= 22
5904 range->scan_capa =
5905 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
5906#endif
5907
5908 EXIT();
5909 return 0;
5910}
5911
5912/**
5913 * iw_get_range() - SSR wrapper for __iw_get_range()
5914 * @dev: pointer to net_device
5915 * @info: pointer to iw_request_info
5916 * @wrqu: pointer to iwreq_data
5917 * @extra: pointer to extra ioctl payload
5918 *
5919 * Return: 0 on success, error number otherwise
5920 */
5921static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
5922 union iwreq_data *wrqu, char *extra)
5923{
5924 int ret;
5925
5926 cds_ssr_protect(__func__);
5927 ret = __iw_get_range(dev, info, wrqu, extra);
5928 cds_ssr_unprotect(__func__);
5929
5930 return ret;
5931}
5932
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005933struct class_a_stats {
5934 tCsrGlobalClassAStatsInfo class_a_stats;
5935};
5936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005937/**
5938 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005939 * @stats: pointer to Class A stats
5940 * @context: user context originally registered with SME (always the
5941 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942 *
5943 * Return: None
5944 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005945static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005946{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005947 struct hdd_request *request;
5948 struct class_a_stats *priv;
5949 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005950
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005951 ENTER();
5952 if ((NULL == stats) || (NULL == context)) {
5953 hdd_err("Bad param, stats [%p] context [%p]",
5954 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005955 return;
5956 }
5957
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005958 request = hdd_request_get(context);
5959 if (!request) {
5960 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 return;
5962 }
5963
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005964 returned_stats = stats;
5965 priv = hdd_request_priv(request);
5966 priv->class_a_stats = *returned_stats;
5967 hdd_request_complete(request);
5968 hdd_request_put(request);
5969 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005970}
5971
5972/**
5973 * wlan_hdd_get_class_astats() - Get Class A statistics
5974 * @pAdapter: adapter for which statistics are desired
5975 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305976 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005977 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305978QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005979{
5980 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305981 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005982 int ret;
5983 void *cookie;
5984 struct hdd_request *request;
5985 struct class_a_stats *priv;
5986 static const struct hdd_request_params params = {
5987 .priv_size = sizeof(*priv),
5988 .timeout_ms = WLAN_WAIT_TIME_STATS,
5989 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990
5991 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005992 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305993 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08005995 if (cds_is_driver_recovering()) {
5996 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
5997 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305998 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 }
6000
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006001 request = hdd_request_alloc(&params);
6002 if (!request) {
6003 hdd_err("Request allocation failure");
6004 return QDF_STATUS_E_NOMEM;
6005 }
6006 cookie = hdd_request_cookie(request);
6007
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006008 /* query only for Class A statistics (which include link speed) */
6009 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
6010 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
6011 hdd_get_class_a_statistics_cb,
6012 0, /* not periodic */
6013 false, /* non-cached results */
6014 pHddStaCtx->conn_info.staId[0],
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006015 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306016 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07006017 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006018 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006019 }
6020
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006021 /* request was sent -- wait for the response */
6022 ret = hdd_request_wait_for_response(request);
6023 if (ret) {
6024 hdd_warn("SME timed out while retrieving Class A statistics");
6025 goto return_cached_results;
6026 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006028 /* update the adapter with the fresh results */
6029 priv = hdd_request_priv(request);
6030 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6031
6032return_cached_results:
6033 /*
6034 * either we never sent a request, we sent a request and
6035 * received a response or we sent a request and timed out.
6036 * regardless we are done with the request.
6037 */
6038 hdd_request_put(request);
6039
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306040 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006041}
6042
Jeff Johnsondda167c2017-01-23 10:37:57 -08006043struct station_stats {
6044 tCsrSummaryStatsInfo summary_stats;
6045 tCsrGlobalClassAStatsInfo class_a_stats;
6046 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
6047};
6048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006049/**
6050 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08006051 * @stats: pointer to combined station stats
6052 * @context: user context originally registered with SME (always the
6053 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006054 *
6055 * Return: None
6056 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006057static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006058{
Jeff Johnsondda167c2017-01-23 10:37:57 -08006059 struct hdd_request *request;
6060 struct station_stats *priv;
6061 tCsrSummaryStatsInfo *summary_stats;
6062 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306063 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006064
Jeff Johnsondda167c2017-01-23 10:37:57 -08006065 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006066 hdd_err("Bad param, pStats [%p] pContext [%p]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08006067 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006068 return;
6069 }
6070
Jeff Johnsondda167c2017-01-23 10:37:57 -08006071 request = hdd_request_get(context);
6072 if (!request) {
6073 hdd_err("Obsolete request");
6074 return;
6075 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006076
Jeff Johnsondda167c2017-01-23 10:37:57 -08006077 summary_stats = (tCsrSummaryStatsInfo *) stats;
6078 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306079 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08006080 (class_a_stats + 1);
6081 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082
6083 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006084 priv->summary_stats = *summary_stats;
6085 priv->class_a_stats = *class_a_stats;
6086 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006087
Jeff Johnsondda167c2017-01-23 10:37:57 -08006088 hdd_request_complete(request);
6089 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006090}
6091
6092/**
6093 * wlan_hdd_get_station_stats() - Get station statistics
6094 * @pAdapter: adapter for which statistics are desired
6095 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306096 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306098QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099{
6100 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306101 QDF_STATUS hstatus;
Jeff Johnsondda167c2017-01-23 10:37:57 -08006102 int ret;
6103 void *cookie;
6104 struct hdd_request *request;
6105 struct station_stats *priv;
6106 static const struct hdd_request_params params = {
6107 .priv_size = sizeof(*priv),
6108 .timeout_ms = WLAN_WAIT_TIME_STATS,
6109 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110
6111 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006112 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306113 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006114 }
6115
Jeff Johnsondda167c2017-01-23 10:37:57 -08006116 request = hdd_request_alloc(&params);
6117 if (!request) {
6118 hdd_err("Request allocation failure");
6119 return QDF_STATUS_E_NOMEM;
6120 }
6121 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006122
6123 /* query only for Summary & Class A statistics */
6124 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
6125 eCSR_HDD,
6126 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306127 SME_GLOBAL_CLASSA_STATS |
6128 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006129 hdd_get_station_statistics_cb,
6130 0, /* not periodic */
6131 false, /* non-cached results */
6132 pHddStaCtx->conn_info.staId[0],
Jeff Johnsondda167c2017-01-23 10:37:57 -08006133 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306134 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006135 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006136 /* we'll return with cached values */
6137 } else {
6138 /* request was sent -- wait for the response */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006139 ret = hdd_request_wait_for_response(request);
6140 if (ret) {
6141 hdd_warn("SME timed out while retrieving statistics");
6142 /* we'll returned a cached value below */
6143 } else {
6144 /* update the adapter with the fresh results */
6145 priv = hdd_request_priv(request);
6146 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
6147 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6148 pAdapter->hdd_stats.per_chain_rssi_stats =
6149 priv->per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006150 }
6151 }
6152
Jeff Johnsondda167c2017-01-23 10:37:57 -08006153 /*
6154 * either we never sent a request, we sent a request and
6155 * received a response or we sent a request and timed out.
6156 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006158 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006159
6160 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306161 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006162}
6163
6164/**
6165 * iw_get_linkspeed() - Get current link speed ioctl
6166 * @dev: device upon which the ioctl was received
6167 * @info: ioctl request information
6168 * @wrqu: ioctl request data
6169 * @extra: extra ioctl buffer
6170 *
6171 * Return: 0 on success, non-zero on error
6172 */
6173static int __iw_get_linkspeed(struct net_device *dev,
6174 struct iw_request_info *info,
6175 union iwreq_data *wrqu, char *extra)
6176{
6177 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6178 char *pLinkSpeed = (char *)extra;
6179 int len = sizeof(uint32_t) + 1;
6180 uint32_t link_speed = 0;
6181 hdd_context_t *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08006182 int ret;
6183 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006185 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006187 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08006188 ret = wlan_hdd_validate_context(hdd_ctx);
6189 if (0 != ret)
6190 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006191
Jeff Johnson441e1f72017-02-07 08:50:49 -08006192 ret = hdd_check_private_wext_control(hdd_ctx, info);
6193 if (0 != ret)
6194 return ret;
6195
6196 ret = wlan_hdd_get_link_speed(pAdapter, &link_speed);
6197 if (0 != ret) {
6198 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199 }
6200
6201 wrqu->data.length = len;
6202 /* return the linkspeed as a string */
6203 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
6204 if ((rc < 0) || (rc >= len)) {
6205 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07006206 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006207 return -EIO;
6208 }
6209
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306210 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006211 /* a value is being successfully returned */
6212 return 0;
6213}
6214
6215static int iw_get_linkspeed(struct net_device *dev,
6216 struct iw_request_info *info,
6217 union iwreq_data *wrqu, char *extra)
6218{
6219 int ret;
6220
6221 cds_ssr_protect(__func__);
6222 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
6223 cds_ssr_unprotect(__func__);
6224
6225 return ret;
6226}
6227
6228/**
6229 * wlan_hdd_change_country_code_callback() - Change country code callback
6230 * @context: opaque context originally passed to SME. All functions
6231 * which use this callback pass the adapter upon which the country
6232 * code change is active
6233 *
6234 * This function is registered as the callback function when
6235 * sme_change_country_code() is invoked. Callers of
6236 * sme_change_country_code() subsequently wait for the adapter's
6237 * @change_country_code completion variable, so all this function
6238 * needs to do is set that completion variable so that execution can
6239 * continue.
6240 *
6241 * Return: none
6242 */
6243void wlan_hdd_change_country_code_callback(void *context)
6244{
6245
6246 hdd_adapter_t *adapter = context;
6247
6248 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
6249 complete(&adapter->change_country_code);
6250
6251 return;
6252}
6253
6254/**
6255 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
6256 * @dev: device upon which the ioctl was received
6257 * @info: ioctl request information
6258 * @wrqu: ioctl request data
6259 * @extra: ioctl extra data
6260 *
6261 * Return: 0 on success, non-zero on error
6262 */
6263static int __iw_set_nick(struct net_device *dev,
6264 struct iw_request_info *info,
6265 union iwreq_data *wrqu, char *extra)
6266{
6267 hdd_adapter_t *adapter;
6268 hdd_context_t *hdd_ctx;
6269 int ret;
6270
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006271 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006272
6273 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6274 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6275 ret = wlan_hdd_validate_context(hdd_ctx);
6276 if (0 != ret)
6277 return ret;
6278
Jeff Johnson441e1f72017-02-07 08:50:49 -08006279 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6280 if (0 != ret)
6281 return ret;
6282
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006283 return 0;
6284}
6285
6286/**
6287 * iw_set_nick() - SSR wrapper for __iw_set_nick
6288 * @dev: pointer to net_device
6289 * @info: pointer to iw_request_info
6290 * @wrqu: pointer to iwreq_data
6291 * @extra: extra
6292 *
6293 * Return: 0 on success, error number otherwise
6294 */
6295static int iw_set_nick(struct net_device *dev,
6296 struct iw_request_info *info,
6297 union iwreq_data *wrqu, char *extra)
6298{
6299 int ret;
6300
6301 cds_ssr_protect(__func__);
6302 ret = __iw_set_nick(dev, info, wrqu, extra);
6303 cds_ssr_unprotect(__func__);
6304
6305 return ret;
6306}
6307
6308/**
6309 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
6310 * @dev: device upon which the ioctl was received
6311 * @info: ioctl request information
6312 * @wrqu: ioctl request data
6313 * @extra: ioctl extra data
6314 *
6315 * Return: 0 on success, non-zero on error
6316 */
6317static int __iw_get_nick(struct net_device *dev,
6318 struct iw_request_info *info,
6319 union iwreq_data *wrqu, char *extra)
6320{
6321 hdd_adapter_t *adapter;
6322 hdd_context_t *hdd_ctx;
6323 int ret;
6324
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006325 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006326
6327 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6328 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6329 ret = wlan_hdd_validate_context(hdd_ctx);
6330 if (0 != ret)
6331 return ret;
6332
Jeff Johnson441e1f72017-02-07 08:50:49 -08006333 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6334 if (0 != ret)
6335 return ret;
6336
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006337 return 0;
6338}
6339
6340/**
6341 * iw_get_nick() - SSR wrapper for __iw_get_nick
6342 * @dev: pointer to net_device
6343 * @info: pointer to iw_request_info
6344 * @wrqu: pointer to iwreq_data
6345 * @extra: extra
6346 *
6347 * Return: 0 on success, error number otherwise
6348 */
6349static int iw_get_nick(struct net_device *dev,
6350 struct iw_request_info *info,
6351 union iwreq_data *wrqu, char *extra)
6352{
6353 int ret;
6354
6355 cds_ssr_protect(__func__);
6356 ret = __iw_get_nick(dev, info, wrqu, extra);
6357 cds_ssr_unprotect(__func__);
6358
6359 return ret;
6360}
6361
6362/**
6363 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
6364 * @dev: device upon which the ioctl was received
6365 * @info: ioctl request information
6366 * @wrqu: ioctl request data
6367 * @extra: ioctl extra data
6368 *
6369 * Return: 0 on success, non-zero on error
6370 */
6371static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6372 union iwreq_data *wrqu, char *extra)
6373{
6374 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6375 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6376 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6377 hdd_context_t *hdd_ctx;
6378 struct iw_point *encoderq = &(wrqu->encoding);
6379 uint32_t keyId;
6380 uint8_t key_length;
6381 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6382 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306383 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006384 int ret;
6385
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006386 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006387
6388 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6389 ret = wlan_hdd_validate_context(hdd_ctx);
6390 if (0 != ret)
6391 return ret;
6392
Jeff Johnson441e1f72017-02-07 08:50:49 -08006393 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6394 if (0 != ret)
6395 return ret;
6396
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006397 keyId = encoderq->flags & IW_ENCODE_INDEX;
6398
6399 if (keyId) {
6400 if (keyId > MAX_WEP_KEYS) {
6401 return -EINVAL;
6402 }
6403
6404 fKeyPresent = 1;
6405 keyId--;
6406 } else {
6407 fKeyPresent = 0;
6408 }
6409
6410 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006411 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006412 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006413 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
6414 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006415 }
6416 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6417 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6418 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6419 eCSR_ENCRYPT_TYPE_NONE;
6420 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6421 eCSR_ENCRYPT_TYPE_NONE;
6422
6423 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6424 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6425
6426 if (eConnectionState_Associated ==
6427 pHddStaCtx->conn_info.connState) {
6428 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6429 status =
6430 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
6431 pAdapter->sessionId,
6432 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306433 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006434 unsigned long rc;
6435 rc = wait_for_completion_timeout(&pAdapter->
6436 disconnect_comp_var,
6437 msecs_to_jiffies
6438 (WLAN_WAIT_TIME_DISCONNECT));
6439 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07006440 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006441 }
6442 }
6443
6444 return status;
6445
6446 }
6447
6448 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006449 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006450
6451 pHddStaCtx->conn_info.authType =
6452 (encoderq->
6453 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
6454 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6455
6456 }
6457
6458 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006459 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006460
6461 key_length = wrqu->data.length;
6462
6463 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
6464
6465 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006466 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006467 key_length);
6468
6469 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6470 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6471 pHddStaCtx->conn_info.authType)) {
6472 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
6473 } else {
6474 encryptionType =
6475 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6476 }
6477 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006478 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006479 key_length);
6480
6481 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6482 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6483 pHddStaCtx->conn_info.authType)) {
6484 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
6485 } else {
6486 encryptionType =
6487 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6488 }
6489 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006490 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006491 key_length);
6492 return -EINVAL;
6493 }
6494
6495 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6496 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
6497 pWextState->roamProfile.EncryptionType.numEntries = 1;
6498 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6499 encryptionType;
6500 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
6501 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6502 encryptionType;
6503
6504 if ((eConnectionState_NotConnected ==
6505 pHddStaCtx->conn_info.connState)
6506 &&
6507 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6508 pHddStaCtx->conn_info.authType)
6509 || (eCSR_AUTH_TYPE_SHARED_KEY ==
6510 pHddStaCtx->conn_info.authType))) {
6511
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306512 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006513 KeyMaterial[keyId][0], extra, key_length);
6514
6515 pWextState->roamProfile.Keys.KeyLength[keyId] =
6516 (uint8_t) key_length;
6517 pWextState->roamProfile.Keys.defaultIndex =
6518 (uint8_t) keyId;
6519
6520 return status;
6521 }
6522 }
6523
6524 return 0;
6525}
6526
6527/**
6528 * iw_set_encode() - SSR wrapper for __iw_set_encode()
6529 * @dev: pointer to net_device
6530 * @info: pointer to iw_request_info
6531 * @wrqu: pointer to iwreq_data
6532 * @extra: pointer to extra ioctl payload
6533 *
6534 * Return: 0 on success, error number otherwise
6535 */
6536static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6537 union iwreq_data *wrqu, char *extra)
6538{
6539 int ret;
6540
6541 cds_ssr_protect(__func__);
6542 ret = __iw_set_encode(dev, info, wrqu, extra);
6543 cds_ssr_unprotect(__func__);
6544
6545 return ret;
6546}
6547
6548/**
6549 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
6550 * @dev: device upon which the ioctl was received
6551 * @info: ioctl request information
6552 * @wrqu: ioctl request data
6553 * @extra: ioctl extra data
6554 *
6555 * Return: 0 on success, non-zero on error
6556 */
6557static int __iw_get_encodeext(struct net_device *dev,
6558 struct iw_request_info *info,
6559 struct iw_point *dwrq, char *extra)
6560{
6561 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6562 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6563 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
6564 int keyId;
6565 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6566 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
6567 int i, ret;
6568 hdd_context_t *hdd_ctx;
6569
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006570 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006571
6572 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6573 ret = wlan_hdd_validate_context(hdd_ctx);
6574 if (0 != ret)
6575 return ret;
6576
Jeff Johnson441e1f72017-02-07 08:50:49 -08006577 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6578 if (0 != ret)
6579 return ret;
6580
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006581 keyId = pRoamProfile->Keys.defaultIndex;
6582
6583 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006584 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006585 return -EINVAL;
6586 }
6587
6588 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
6589 dwrq->flags |= IW_ENCODE_ENABLED;
6590 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306591 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006592 pRoamProfile->Keys.KeyLength[keyId]);
6593 } else {
6594 dwrq->flags |= IW_ENCODE_DISABLED;
6595 }
6596
6597 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006598 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006599 continue;
6600 } else {
6601 break;
6602 }
6603 }
6604
6605 if (MAX_WEP_KEYS == i) {
6606 dwrq->flags |= IW_ENCODE_NOKEY;
6607 } else {
6608 dwrq->flags |= IW_ENCODE_ENABLED;
6609 }
6610
6611 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
6612
6613 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
6614 dwrq->flags |= IW_ENCODE_DISABLED;
6615 }
6616
6617 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
6618
6619 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
6620 dwrq->flags |= IW_ENCODE_OPEN;
6621 } else {
6622 dwrq->flags |= IW_ENCODE_RESTRICTED;
6623 }
6624 EXIT();
6625 return 0;
6626
6627}
6628
6629/**
6630 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
6631 * @dev: pointer to net_device
6632 * @info: pointer to iw_request_info
6633 * @dwrq: pointer to encoding information
6634 * @extra: pointer to extra ioctl payload
6635 *
6636 * Return: 0 on success, error number otherwise
6637 */
6638static int iw_get_encodeext(struct net_device *dev,
6639 struct iw_request_info *info,
6640 struct iw_point *dwrq, char *extra)
6641{
6642 int ret;
6643
6644 cds_ssr_protect(__func__);
6645 ret = __iw_get_encodeext(dev, info, dwrq, extra);
6646 cds_ssr_unprotect(__func__);
6647
6648 return ret;
6649}
6650
6651/**
6652 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
6653 * @dev: device upon which the ioctl was received
6654 * @info: ioctl request information
6655 * @wrqu: ioctl request data
6656 * @extra: ioctl extra data
6657 *
6658 * Return: 0 on success, non-zero on error
6659 */
6660static int __iw_set_encodeext(struct net_device *dev,
6661 struct iw_request_info *info,
6662 union iwreq_data *wrqu, char *extra)
6663{
6664 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6665 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6666 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6667 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306668 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006669 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6670 int ret;
6671 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6672 int key_index;
6673 struct iw_point *encoding = &wrqu->encoding;
6674 tCsrRoamSetKey setKey;
6675 uint32_t roamId = 0xFF;
6676
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006677 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006678
6679 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6680 ret = wlan_hdd_validate_context(hdd_ctx);
6681 if (0 != ret)
6682 return ret;
6683
Jeff Johnson441e1f72017-02-07 08:50:49 -08006684 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6685 if (0 != ret)
6686 return ret;
6687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006688 key_index = encoding->flags & IW_ENCODE_INDEX;
6689
6690 if (key_index > 0) {
6691
6692 /*Convert from 1-based to 0-based keying */
6693 key_index--;
6694 }
6695 if (!ext->key_len) {
6696
6697 /*Set the encrytion type to NONE */
6698 pRoamProfile->EncryptionType.encryptionType[0] =
6699 eCSR_ENCRYPT_TYPE_NONE;
6700 return ret;
6701 }
6702
6703 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
6704 (IW_ENCODE_ALG_WEP == ext->alg)) {
6705 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
6706
Jeff Johnson99bac312016-06-28 10:38:18 -07006707 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006708 return -EINVAL;
Jeff Johnson68755312017-02-10 11:46:55 -08006709 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006710
Jeff Johnson68755312017-02-10 11:46:55 -08006711 /*Static wep, update the roam profile with the keys */
6712 if (ext->key_len &&
6713 (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
6714 key_index < CSR_MAX_NUM_KEY) {
6715 qdf_mem_copy(&pRoamProfile->Keys.
6716 KeyMaterial[key_index][0],
6717 ext->key, ext->key_len);
6718 pRoamProfile->Keys.KeyLength[key_index] =
6719 (uint8_t) ext->key_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006720
Jeff Johnson68755312017-02-10 11:46:55 -08006721 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
6722 pRoamProfile->Keys.defaultIndex =
6723 (uint8_t) key_index;
6724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006725 }
6726 return ret;
6727 }
6728
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306729 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006730
6731 setKey.keyId = key_index;
6732 setKey.keyLength = ext->key_len;
6733
6734 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306735 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006736 }
6737
6738 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
6739 /*Key direction for group is RX only */
6740 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05306741 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006742 } else {
6743
6744 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306745 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306746 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006747 }
6748
6749 /*For supplicant pae role is zero */
6750 setKey.paeRole = 0;
6751
6752 switch (ext->alg) {
6753 case IW_ENCODE_ALG_NONE:
6754 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6755 break;
6756
6757 case IW_ENCODE_ALG_WEP:
6758 setKey.encType =
6759 (ext->key_len ==
6760 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
6761 break;
6762
6763 case IW_ENCODE_ALG_TKIP:
6764 {
6765 uint8_t *pKey = &setKey.Key[0];
6766
6767 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
6768
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306769 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006770
6771 /* Supplicant sends the 32bytes key in this order
6772 * |--------------|----------|----------|
6773 * | Tk1 | TX MIC | RX MIC |
6774 * |--------------|----------|----------|
6775 * <---16bytes---><--8bytes--><--8bytes-->
6776 *
6777 *
6778 * Sme expects the 32 bytes key to be in the below order
6779 * |--------------|----------|----------|
6780 * | Tk1 | RX MIC | TX MIC |
6781 * |--------------|----------|----------|
6782 * <---16bytes---><--8bytes--><--8bytes-->
6783 */
6784
6785 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306786 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006787
6788 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306789 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006790
6791 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306792 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006793
6794 }
6795 break;
6796
6797 case IW_ENCODE_ALG_CCMP:
6798 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
6799 break;
6800
6801#ifdef FEATURE_WLAN_ESE
6802#define IW_ENCODE_ALG_KRK 6
6803 case IW_ENCODE_ALG_KRK:
6804 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
6805 break;
6806#endif /* FEATURE_WLAN_ESE */
6807
6808 default:
6809 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6810 break;
6811 }
6812
Jeff Johnson99bac312016-06-28 10:38:18 -07006813 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
6814 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006815
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006816 /* The supplicant may attempt to set the PTK once
6817 * pre-authentication is done. Save the key in the UMAC and
6818 * include it in the ADD BSS request
6819 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306820 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006821 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306822 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006823 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006824 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306825 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006826 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006827 return -EINVAL;
6828 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006829
6830 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6831
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306832 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006833 pAdapter->sessionId,
6834 &setKey, &roamId);
6835
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306836 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006837 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306838 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006839
6840 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6841 }
6842
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306843 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006844}
6845
6846/**
6847 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
6848 * @dev: pointer to net_device
6849 * @info: pointer to iw_request_info
6850 * @wrqu: pointer to iwreq_data
6851 * @extra: pointer to extra ioctl payload
6852 *
6853 * Return: 0 on success, error number otherwise
6854 */
6855static int iw_set_encodeext(struct net_device *dev,
6856 struct iw_request_info *info,
6857 union iwreq_data *wrqu, char *extra)
6858{
6859 int ret;
6860
6861 cds_ssr_protect(__func__);
6862 ret = __iw_set_encodeext(dev, info, wrqu, extra);
6863 cds_ssr_unprotect(__func__);
6864
6865 return ret;
6866}
6867
6868/**
6869 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
6870 * @dev: device upon which the ioctl was received
6871 * @info: ioctl request information
6872 * @wrqu: ioctl request data
6873 * @extra: ioctl extra data
6874 *
6875 * Return: 0 on success, non-zero on error
6876 */
6877static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
6878 union iwreq_data *wrqu, char *extra)
6879{
6880 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6881 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6882 hdd_context_t *hdd_ctx;
6883 int ret;
6884
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006885 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006886
6887 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6888 ret = wlan_hdd_validate_context(hdd_ctx);
6889 if (0 != ret)
6890 return ret;
6891
Jeff Johnson441e1f72017-02-07 08:50:49 -08006892 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6893 if (0 != ret)
6894 return ret;
6895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006896 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
6897 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
6898
Jeff Johnson99bac312016-06-28 10:38:18 -07006899 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006900
6901 return -EINVAL;
6902 }
6903
6904 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
6905
6906 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
6907 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
6908 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306909 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006910 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006911 return -EIO;
6912 }
6913 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
6914 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6915 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306916 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05306917 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006918 return -EIO;
6919 }
6920 }
6921 } else {
6922 return -EOPNOTSUPP;
6923 }
6924
Jeff Johnson99bac312016-06-28 10:38:18 -07006925 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006926
6927 EXIT();
6928
6929 return 0;
6930
6931}
6932
6933/**
6934 * iw_set_retry() - SSR wrapper for __iw_set_retry()
6935 * @dev: pointer to net_device
6936 * @info: pointer to iw_request_info
6937 * @wrqu: pointer to iwreq_data
6938 * @extra: pointer to extra ioctl payload
6939 *
6940 * Return: 0 on success, error number otherwise
6941 */
6942static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
6943 union iwreq_data *wrqu, char *extra)
6944{
6945 int ret;
6946
6947 cds_ssr_protect(__func__);
6948 ret = __iw_set_retry(dev, info, wrqu, extra);
6949 cds_ssr_unprotect(__func__);
6950
6951 return ret;
6952}
6953
6954/**
6955 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
6956 * @dev: device upon which the ioctl was received
6957 * @info: ioctl request information
6958 * @wrqu: ioctl request data
6959 * @extra: ioctl extra data
6960 *
6961 * Return: 0 on success, non-zero on error
6962 */
6963static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
6964 union iwreq_data *wrqu, char *extra)
6965{
6966 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6967 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6968 uint32_t retry = 0;
6969 hdd_context_t *hdd_ctx;
6970 int ret;
6971
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006972 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006973
6974 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6975 ret = wlan_hdd_validate_context(hdd_ctx);
6976 if (0 != ret)
6977 return ret;
6978
Jeff Johnson441e1f72017-02-07 08:50:49 -08006979 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6980 if (0 != ret)
6981 return ret;
6982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006983 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
6984 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
6985
6986 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306987 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006988 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006989 return -EIO;
6990 }
6991
6992 wrqu->retry.value = retry;
6993 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
6994 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
6995
6996 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306997 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05306998 hdd_warn("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006999 return -EIO;
7000 }
7001
7002 wrqu->retry.value = retry;
7003 } else {
7004 return -EOPNOTSUPP;
7005 }
7006
Jeff Johnson99bac312016-06-28 10:38:18 -07007007 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007008
7009 EXIT();
7010
7011 return 0;
7012}
7013
7014/**
7015 * iw_get_retry() - SSR wrapper for __iw_get_retry()
7016 * @dev: pointer to net_device
7017 * @info: pointer to iw_request_info
7018 * @wrqu: pointer to iwreq_data
7019 * @extra: pointer to extra ioctl payload
7020 *
7021 * Return: 0 on success, error number otherwise
7022 */
7023static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7024 union iwreq_data *wrqu, char *extra)
7025{
7026 int ret;
7027
7028 cds_ssr_protect(__func__);
7029 ret = __iw_get_retry(dev, info, wrqu, extra);
7030 cds_ssr_unprotect(__func__);
7031
7032 return ret;
7033}
7034
7035/**
7036 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
7037 * @dev: device upon which the ioctl was received
7038 * @info: ioctl request information
7039 * @wrqu: ioctl request data
7040 * @extra: ioctl extra data
7041 *
7042 * Return: 0 on success, non-zero on error
7043 */
7044static int __iw_set_mlme(struct net_device *dev,
7045 struct iw_request_info *info,
7046 union iwreq_data *wrqu, char *extra)
7047{
7048 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7049 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7050 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307051 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007052 hdd_context_t *hdd_ctx;
7053 int ret;
7054
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007055 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007056
7057 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7058 ret = wlan_hdd_validate_context(hdd_ctx);
7059 if (0 != ret)
7060 return ret;
7061
Jeff Johnson441e1f72017-02-07 08:50:49 -08007062 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7063 if (0 != ret)
7064 return ret;
7065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007066 /* reason_code is unused. By default it is set to
7067 * eCSR_DISCONNECT_REASON_UNSPECIFIED
7068 */
7069 switch (mlme->cmd) {
7070 case IW_MLME_DISASSOC:
7071 case IW_MLME_DEAUTH:
7072
7073 if (pHddStaCtx->conn_info.connState ==
7074 eConnectionState_Associated) {
7075 eCsrRoamDisconnectReason reason =
7076 eCSR_DISCONNECT_REASON_UNSPECIFIED;
7077
7078 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
7079 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
7080
7081 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7082 status =
7083 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
7084 pAdapter->sessionId, reason);
7085
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307086 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007087 unsigned long rc;
7088 rc = wait_for_completion_timeout(&pAdapter->
7089 disconnect_comp_var,
7090 msecs_to_jiffies
7091 (WLAN_WAIT_TIME_DISCONNECT));
7092 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07007093 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007094 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07007095 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
7096 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007097
7098 /* Resetting authKeyMgmt */
7099 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
7100 0;
7101
Jeff Johnson99bac312016-06-28 10:38:18 -07007102 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007103 wlan_hdd_netif_queue_control(pAdapter,
7104 WLAN_NETIF_TX_DISABLE_N_CARRIER,
7105 WLAN_CONTROL_PATH);
7106
7107 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07007108 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
7109 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007110 }
7111 break;
7112 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007113 hdd_err("%d Command should be Disassociate/Deauthenticate",
7114 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007115 return -EINVAL;
7116 } /* end of switch */
7117
7118 EXIT();
7119
7120 return status;
7121
7122}
7123
7124/**
7125 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
7126 * @dev: pointer to net_device
7127 * @info: pointer to iw_request_info
7128 * @wrqu: pointer to iwreq_data
7129 * @extra: pointer to extra ioctl payload
7130 *
7131 * Return: 0 on success, error number otherwise
7132 */
7133static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
7134 union iwreq_data *wrqu, char *extra)
7135{
7136 int ret;
7137
7138 cds_ssr_protect(__func__);
7139 ret = __iw_set_mlme(dev, info, wrqu, extra);
7140 cds_ssr_unprotect(__func__);
7141
7142 return ret;
7143}
7144
7145/**
7146 * wlan_hdd_update_phymode() - handle change in PHY mode
7147 * @net: device upon which PHY mode change was received
7148 * @hal: umac handle for the driver
7149 * @new_phymode: new PHY mode for the device
7150 * @phddctx: pointer to the HDD context
7151 *
7152 * This function is called when the device is set to a new PHY mode.
7153 * It takes a holistic look at the desired PHY mode along with the
7154 * configured capabilities of the driver and the reported capabilities
7155 * of the hardware in order to correctly configure all PHY-related
7156 * parameters.
7157 *
7158 * Return: 0 on success, negative errno value on error
7159 */
7160int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
7161 int new_phymode, hdd_context_t *phddctx)
7162{
7163#ifdef QCA_HT_2040_COEX
7164 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307165 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007166#endif
7167 bool band_24 = false, band_5g = false;
7168 bool ch_bond24 = false, ch_bond5g = false;
7169 tSmeConfigParams smeconfig;
7170 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007171 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007172 eCsrPhyMode phymode = -EIO, old_phymode;
7173 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
7174 eCsrBand curr_band = eCSR_BAND_ALL;
7175
7176 old_phymode = sme_get_phy_mode(hal);
7177
7178 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7179 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7180 nChannelBondingMode24GHz))
7181 ch_bond24 = true;
7182
7183 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7184 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7185 nChannelBondingMode5GHz))
7186 ch_bond5g = true;
7187
7188 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
7189 band_24 = band_5g = true;
7190 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
7191 band_24 = true;
7192 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
7193 band_5g = true;
7194 }
7195
7196 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07007197 hdd_warn("ch_bond24=%d ch_bond5g=%d band_24=%d band_5g=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007198 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
7199
7200 switch (new_phymode) {
7201 case IEEE80211_MODE_AUTO:
7202 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7203 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
7204 phymode = eCSR_DOT11_MODE_AUTO;
7205 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7206 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7207 curr_band = eCSR_BAND_ALL;
7208 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7209 } else {
7210 sme_set_phy_mode(hal, old_phymode);
7211 return -EIO;
7212 }
7213 break;
7214 case IEEE80211_MODE_11A:
7215 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
7216 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7217 phymode = eCSR_DOT11_MODE_11a;
7218 hdd_dot11mode = eHDD_DOT11_MODE_11a;
7219 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7220 curr_band = eCSR_BAND_5G;
7221 } else {
7222 sme_set_phy_mode(hal, old_phymode);
7223 return -EIO;
7224 }
7225 break;
7226 case IEEE80211_MODE_11B:
7227 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
7228 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7229 phymode = eCSR_DOT11_MODE_11b;
7230 hdd_dot11mode = eHDD_DOT11_MODE_11b;
7231 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7232 curr_band = eCSR_BAND_24;
7233 } else {
7234 sme_set_phy_mode(hal, old_phymode);
7235 return -EIO;
7236 }
7237 break;
7238 case IEEE80211_MODE_11G:
7239 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
7240 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7241 phymode = eCSR_DOT11_MODE_11g;
7242 hdd_dot11mode = eHDD_DOT11_MODE_11g;
7243 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7244 curr_band = eCSR_BAND_24;
7245 } else {
7246 sme_set_phy_mode(hal, old_phymode);
7247 return -EIO;
7248 }
7249 break;
7250 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
7251 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
7252 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
7253 */
7254 case IEEE80211_MODE_11NA_HT20:
7255 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7256 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7257 phymode = eCSR_DOT11_MODE_11n;
7258 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7259 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7260 curr_band = eCSR_BAND_5G;
7261 } else {
7262 sme_set_phy_mode(hal, old_phymode);
7263 return -EIO;
7264 }
7265 break;
7266 case IEEE80211_MODE_11NA_HT40:
7267 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7268 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7269 phymode = eCSR_DOT11_MODE_11n;
7270 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7271 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7272 curr_band = eCSR_BAND_5G;
7273 } else {
7274 sme_set_phy_mode(hal, old_phymode);
7275 return -EIO;
7276 }
7277 break;
7278 case IEEE80211_MODE_11NG_HT20:
7279 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7280 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7281 phymode = eCSR_DOT11_MODE_11n;
7282 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7283 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7284 curr_band = eCSR_BAND_24;
7285 } else {
7286 sme_set_phy_mode(hal, old_phymode);
7287 return -EIO;
7288 }
7289 break;
7290 case IEEE80211_MODE_11NG_HT40:
7291 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7292 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7293 phymode = eCSR_DOT11_MODE_11n;
7294 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7295 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7296 curr_band = eCSR_BAND_24;
7297 } else {
7298 sme_set_phy_mode(hal, old_phymode);
7299 return -EIO;
7300 }
7301 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007302 case IEEE80211_MODE_11AC_VHT20:
7303 case IEEE80211_MODE_11AC_VHT40:
7304 case IEEE80211_MODE_11AC_VHT80:
7305 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
7306 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7307 phymode = eCSR_DOT11_MODE_11ac;
7308 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
7309 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7310 curr_band = eCSR_BAND_5G;
7311 } else {
7312 sme_set_phy_mode(hal, old_phymode);
7313 return -EIO;
7314 }
7315 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007316 case IEEE80211_MODE_2G_AUTO:
7317 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7318 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7319 phymode = eCSR_DOT11_MODE_AUTO;
7320 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7321 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7322 curr_band = eCSR_BAND_24;
7323 } else {
7324 sme_set_phy_mode(hal, old_phymode);
7325 return -EIO;
7326 }
7327 break;
7328 case IEEE80211_MODE_5G_AUTO:
7329 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7330 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7331 phymode = eCSR_DOT11_MODE_AUTO;
7332 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7333 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7334 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7335 curr_band = eCSR_BAND_5G;
7336 } else {
7337 sme_set_phy_mode(hal, old_phymode);
7338 return -EIO;
7339 }
7340 break;
7341 case IEEE80211_MODE_11AGN:
7342 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7343 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
7344 phymode = eCSR_DOT11_MODE_11n;
7345 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7346 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7347 curr_band = eCSR_BAND_ALL;
7348 } else {
7349 sme_set_phy_mode(hal, old_phymode);
7350 return -EIO;
7351 }
7352 break;
7353 default:
7354 return -EIO;
7355 }
7356
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007357 switch (new_phymode) {
7358 case IEEE80211_MODE_11AC_VHT20:
7359 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7360 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
7361 break;
7362 case IEEE80211_MODE_11AC_VHT40:
7363 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
7364 break;
7365 case IEEE80211_MODE_11AC_VHT80:
7366 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7367 break;
7368 default:
7369 vhtchanwidth = phddctx->config->vhtChannelWidth;
7370 break;
7371 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007372
7373 if (phymode != -EIO) {
7374 sme_get_config_param(hal, &smeconfig);
7375 smeconfig.csrConfig.phyMode = phymode;
7376#ifdef QCA_HT_2040_COEX
7377 if (phymode == eCSR_DOT11_MODE_11n &&
7378 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
7379 smeconfig.csrConfig.obssEnabled = false;
7380 halStatus = sme_set_ht2040_mode(hal,
7381 pAdapter->sessionId,
7382 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307383 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007384 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007385 return -EIO;
7386 }
7387 } else if (phymode == eCSR_DOT11_MODE_11n &&
7388 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
7389 smeconfig.csrConfig.obssEnabled = true;
7390 halStatus = sme_set_ht2040_mode(hal,
7391 pAdapter->sessionId,
7392 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307393 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007394 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007395 return -EIO;
7396 }
7397 }
7398#endif
7399 smeconfig.csrConfig.eBand = curr_band;
7400 smeconfig.csrConfig.bandCapability = curr_band;
7401 if (curr_band == eCSR_BAND_24)
7402 smeconfig.csrConfig.Is11hSupportEnabled = 0;
7403 else
7404 smeconfig.csrConfig.Is11hSupportEnabled =
7405 phddctx->config->Is11hSupportEnabled;
7406 if (curr_band == eCSR_BAND_24)
7407 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7408 else if (curr_band == eCSR_BAND_24)
7409 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7410 else {
7411 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7412 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7413 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007414 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007415 sme_update_config(hal, &smeconfig);
7416
7417 phddctx->config->dot11Mode = hdd_dot11mode;
7418 phddctx->config->nBandCapability = curr_band;
7419 phddctx->config->nChannelBondingMode24GHz =
7420 smeconfig.csrConfig.channelBondingMode24GHz;
7421 phddctx->config->nChannelBondingMode5GHz =
7422 smeconfig.csrConfig.channelBondingMode5GHz;
7423 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07007424 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007425 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007426 return -EIO;
7427 }
7428 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07007429 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007430 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7431 else
Dustin Browna30892e2016-10-12 17:28:36 -07007432 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007433 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7434
Jeff Johnson99bac312016-06-28 10:38:18 -07007435 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007436 phymode, chwidth, curr_band, vhtchanwidth);
7437 }
7438
7439 return 0;
7440}
7441
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007442struct temperature_priv {
7443 int temperature;
7444};
7445
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007446/**
7447 * hdd_get_temperature_cb() - "Get Temperature" callback function
7448 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007449 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007450 *
7451 * This function is passed to sme_get_temperature() as the callback
7452 * function to be invoked when the temperature measurement is
7453 * available.
7454 *
7455 * Return: None
7456 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007457static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007458{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007459 struct hdd_request *request;
7460 struct temperature_priv *priv;
7461
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007462 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007463
7464 request = hdd_request_get(context);
7465 if (!request) {
7466 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007467 return;
7468 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007469
7470 priv = hdd_request_priv(request);
7471 priv->temperature = temperature;
7472 hdd_request_complete(request);
7473 hdd_request_put(request);
7474
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007475 EXIT();
7476}
7477
7478/**
7479 * wlan_hdd_get_temperature() - get current device temperature
7480 * @pAdapter: device upon which the request was made
7481 * @temperature: pointer to where the temperature is to be returned
7482 *
7483 * Return: 0 if a temperature value (either current or cached) was
7484 * returned, otherwise a negative errno is returned.
7485 *
7486 */
7487int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
7488{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307489 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007490 int ret;
7491 void *cookie;
7492 struct hdd_request *request;
7493 struct temperature_priv *priv;
7494 static const struct hdd_request_params params = {
7495 .priv_size = sizeof(*priv),
7496 .timeout_ms = WLAN_WAIT_TIME_STATS,
7497 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007498
7499 ENTER();
7500 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007501 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007502 return -EPERM;
7503 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007504
7505 request = hdd_request_alloc(&params);
7506 if (!request) {
7507 hdd_err("Request allocation failure");
7508 return -ENOMEM;
7509 }
7510 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007511 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007512 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307513 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007514 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007515 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007516 ret = hdd_request_wait_for_response(request);
7517 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007518 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007519 } else {
7520 /* update the adapter with the fresh results */
7521 priv = hdd_request_priv(request);
7522 if (priv->temperature)
7523 pAdapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007524 }
7525 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007526
7527 /*
7528 * either we never sent a request, we sent a request and
7529 * received a response or we sent a request and timed out.
7530 * regardless we are done with the request.
7531 */
7532 hdd_request_put(request);
7533
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007534 *temperature = pAdapter->temperature;
7535 EXIT();
7536 return 0;
7537}
7538
7539/**
7540 * iw_setint_getnone() - Generic "set integer" private ioctl handler
7541 * @dev: device upon which the ioctl was received
7542 * @info: ioctl request information
7543 * @wrqu: ioctl request data
7544 * @extra: ioctl extra data
7545 *
7546 * Return: 0 on success, non-zero on error
7547 */
7548static int __iw_setint_getnone(struct net_device *dev,
7549 struct iw_request_info *info,
7550 union iwreq_data *wrqu, char *extra)
7551{
7552 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7553 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7554 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007555 hdd_context_t *hdd_ctx;
7556 tSmeConfigParams smeConfig;
7557 int *value = (int *)extra;
7558 int sub_cmd = value[0];
7559 int set_value = value[1];
7560 int ret;
7561 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307562 QDF_STATUS status;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08007563 void *soc = NULL;
7564 struct ol_txrx_stats_req req;
7565 struct cdp_pdev *pdev = NULL;
7566 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007567
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007568 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307569
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007570 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7571 ret = wlan_hdd_validate_context(hdd_ctx);
7572 if (0 != ret)
7573 return ret;
7574
Jeff Johnson441e1f72017-02-07 08:50:49 -08007575 ret = hdd_check_private_wext_control(hdd_ctx, info);
7576 if (0 != ret)
7577 return ret;
7578
Jeff Johnson441e1f72017-02-07 08:50:49 -08007579 memset(&smeConfig, 0x00, sizeof(smeConfig));
7580
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007581 switch (sub_cmd) {
7582 case WE_SET_11D_STATE:
7583 {
7584 if ((ENABLE_11D == set_value)
7585 || (DISABLE_11D == set_value)) {
7586
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007587 sme_get_config_param(hHal, &smeConfig);
7588 smeConfig.csrConfig.Is11dSupportEnabled =
7589 (bool) set_value;
7590
Jeff Johnson99bac312016-06-28 10:38:18 -07007591 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007592 smeConfig.csrConfig.
7593 Is11dSupportEnabled);
7594
7595 sme_update_config(hHal, &smeConfig);
7596 } else {
7597 return -EINVAL;
7598 }
7599 break;
7600 }
7601
7602 case WE_WOWL:
7603 {
7604 switch (set_value) {
7605 case 0x00:
7606 hdd_exit_wowl(pAdapter);
7607 break;
7608 case 0x01:
7609 case 0x02:
7610 case 0x03:
7611 enable_mp = (set_value & 0x01) ? 1 : 0;
7612 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07007613 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007614 (enable_mp ? "YES" : "NO"),
7615 (enable_pbm ? "YES" : "NO"));
7616 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
7617 break;
7618 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007619 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007620 set_value);
7621 ret = -EINVAL;
7622 break;
7623 }
7624
7625 break;
7626 }
7627 case WE_SET_POWER:
7628 {
7629 switch (set_value) {
7630 case 1:
7631 /* Enable PowerSave */
7632 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7633 SME_PS_ENABLE);
7634 break;
7635 case 2:
7636 /* Disable PowerSave */
7637 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7638 SME_PS_DISABLE);
7639 break;
7640 case 3: /* Enable UASPD */
7641 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
7642 break;
7643 case 4: /* Disable UASPD */
7644 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
7645 break;
7646 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007647 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007648 set_value);
7649 ret = -EINVAL;
7650 break;
7651 }
7652 break;
7653 }
7654
7655 case WE_SET_MAX_ASSOC:
7656 {
7657 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
7658 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
7659 ret = -EINVAL;
7660 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
7661 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307662 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007663 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007664 ret = -EIO;
7665 }
7666 break;
7667 }
7668
7669 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
7670 if (set_value == 0 || set_value == 1)
7671 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
7672 set_value;
7673 else
7674 ret = -EINVAL;
7675 break;
7676
7677 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007678 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
7679 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
7680 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7681 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307682 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007683 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007684 ret = -EINVAL;
7685 }
7686 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007687 case WE_SET_MC_RATE:
7688 {
7689 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
7690 break;
7691 }
7692 case WE_SET_TX_POWER:
7693 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307694 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007695
Anurag Chouhanc5548422016-02-24 18:33:27 +05307696 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007697 if (sme_set_tx_power
7698 (hHal, pAdapter->sessionId, bssid,
7699 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307700 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007701 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007702 return -EIO;
7703 }
7704 break;
7705 }
7706 case WE_SET_MAX_TX_POWER:
7707 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307708 struct qdf_mac_addr bssid;
7709 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007710
Jeff Johnson99bac312016-06-28 10:38:18 -07007711 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007712 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05307713 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
7714 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007715
7716 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307717 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007718 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007719 return -EIO;
7720 }
7721
7722 break;
7723 }
7724 case WE_SET_MAX_TX_POWER_2_4:
7725 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007726 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
7727 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007728 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307729 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007730 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007731 return -EIO;
7732 }
7733
7734 break;
7735 }
7736 case WE_SET_MAX_TX_POWER_5_0:
7737 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007738 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
7739 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007740 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307741 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007742 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007743 return -EIO;
7744 }
7745
7746 break;
7747 }
7748 case WE_SET_HIGHER_DTIM_TRANSITION:
7749 {
7750 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007751 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007752 set_value);
7753 ret = -EINVAL;
7754 } else {
7755 if (pAdapter->higherDtimTransition != set_value) {
7756 pAdapter->higherDtimTransition =
7757 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07007758 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007759 pAdapter->higherDtimTransition);
7760 }
7761 }
7762
7763 break;
7764 }
7765
7766 case WE_SET_TM_LEVEL:
7767 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007768 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007769 (void)sme_set_thermal_level(hHal, set_value);
7770 break;
7771 }
7772
7773 case WE_SET_PHYMODE:
7774 {
7775 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
7776
7777 ret =
7778 wlan_hdd_update_phymode(dev, hHal, set_value,
7779 phddctx);
7780 break;
7781 }
7782
7783 case WE_SET_NSS:
7784 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007785 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007786 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007787 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007788 ret = -EINVAL;
7789 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307790 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007791 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
7792 set_value))
7793 ret = -EINVAL;
7794 }
7795 break;
7796 }
7797
7798 case WE_SET_GTX_HT_MCS:
7799 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007800 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007801 ret = wma_cli_set_command(pAdapter->sessionId,
7802 WMI_VDEV_PARAM_GTX_HT_MCS,
7803 set_value, GTX_CMD);
7804 break;
7805 }
7806
7807 case WE_SET_GTX_VHT_MCS:
7808 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007809 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007810 set_value);
7811 ret = wma_cli_set_command(pAdapter->sessionId,
7812 WMI_VDEV_PARAM_GTX_VHT_MCS,
7813 set_value, GTX_CMD);
7814 break;
7815 }
7816
7817 case WE_SET_GTX_USRCFG:
7818 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007819 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007820 set_value);
7821 ret = wma_cli_set_command(pAdapter->sessionId,
7822 WMI_VDEV_PARAM_GTX_USR_CFG,
7823 set_value, GTX_CMD);
7824 break;
7825 }
7826
7827 case WE_SET_GTX_THRE:
7828 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007829 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007830 ret = wma_cli_set_command(pAdapter->sessionId,
7831 WMI_VDEV_PARAM_GTX_THRE,
7832 set_value, GTX_CMD);
7833 break;
7834 }
7835
7836 case WE_SET_GTX_MARGIN:
7837 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007838 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007839 ret = wma_cli_set_command(pAdapter->sessionId,
7840 WMI_VDEV_PARAM_GTX_MARGIN,
7841 set_value, GTX_CMD);
7842 break;
7843 }
7844
7845 case WE_SET_GTX_STEP:
7846 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007847 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007848 ret = wma_cli_set_command(pAdapter->sessionId,
7849 WMI_VDEV_PARAM_GTX_STEP,
7850 set_value, GTX_CMD);
7851 break;
7852 }
7853
7854 case WE_SET_GTX_MINTPC:
7855 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007856 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007857 ret = wma_cli_set_command(pAdapter->sessionId,
7858 WMI_VDEV_PARAM_GTX_MINTPC,
7859 set_value, GTX_CMD);
7860 break;
7861 }
7862
7863 case WE_SET_GTX_BWMASK:
7864 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007865 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007866 ret = wma_cli_set_command(pAdapter->sessionId,
7867 WMI_VDEV_PARAM_GTX_BW_MASK,
7868 set_value, GTX_CMD);
7869 break;
7870 }
7871
7872 case WE_SET_LDPC:
7873 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307874 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007875 break;
7876 }
7877
7878 case WE_SET_TX_STBC:
7879 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307880 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007881 break;
7882 }
7883
7884 case WE_SET_RX_STBC:
7885 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307886 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007887 break;
7888 }
7889
7890 case WE_SET_SHORT_GI:
7891 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007892 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08007893 /*
7894 * wma_cli_set_command should be called instead of
7895 * sme_update_ht_config since SGI is used for HT/HE.
7896 * This should be refactored.
7897 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007898 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
7899 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
7900 set_value);
7901 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07007902 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007903 break;
7904 }
7905
7906 case WE_SET_RTSCTS:
7907 {
7908 uint32_t value;
7909
Jeff Johnson99bac312016-06-28 10:38:18 -07007910 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007911 set_value);
7912
7913 if ((set_value & HDD_RTSCTS_EN_MASK) ==
7914 HDD_RTSCTS_ENABLE)
7915 value =
7916 (WLAN_HDD_GET_CTX(pAdapter))->config->
7917 RTSThreshold;
7918 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
7919 || ((set_value & HDD_RTSCTS_EN_MASK) ==
7920 HDD_CTS_ENABLE))
7921 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
7922 else
7923 return -EIO;
7924
7925 ret = wma_cli_set_command(pAdapter->sessionId,
7926 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7927 set_value, VDEV_CMD);
7928 if (!ret) {
7929 if (sme_cfg_set_int
7930 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307931 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007932 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007933 return -EIO;
7934 }
7935 }
7936
7937 break;
7938 }
7939
7940 case WE_SET_CHWIDTH:
7941 {
7942 bool chwidth = false;
7943 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
7944 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07007945 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007946 set_value);
7947 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007948 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007949 return -EINVAL;
7950 }
7951
7952 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7953 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
7954 nChannelBondingMode5GHz)))
7955 chwidth = true;
7956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007957 sme_get_config_param(hHal, &smeConfig);
7958 switch (set_value) {
7959 case eHT_CHANNEL_WIDTH_20MHZ:
7960 smeConfig.csrConfig.channelBondingMode5GHz =
7961 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7962 break;
7963 case eHT_CHANNEL_WIDTH_40MHZ:
7964 if (chwidth)
7965 smeConfig.csrConfig.
7966 channelBondingMode5GHz =
7967 phddctx->config->
7968 nChannelBondingMode5GHz;
7969 else
7970 return -EINVAL;
7971
7972 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007973 case eHT_CHANNEL_WIDTH_80MHZ:
7974 if (chwidth)
7975 smeConfig.csrConfig.
7976 channelBondingMode5GHz =
7977 phddctx->config->
7978 nChannelBondingMode5GHz;
7979 else
7980 return -EINVAL;
7981
7982 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007983
7984 default:
7985 return -EINVAL;
7986 }
7987
7988 ret = wma_cli_set_command(pAdapter->sessionId,
7989 WMI_VDEV_PARAM_CHWIDTH,
7990 set_value, VDEV_CMD);
7991 if (!ret)
7992 sme_update_config(hHal, &smeConfig);
7993
7994 break;
7995 }
7996
7997 case WE_SET_ANI_EN_DIS:
7998 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007999 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008000 set_value);
8001 ret = wma_cli_set_command(pAdapter->sessionId,
8002 WMI_PDEV_PARAM_ANI_ENABLE,
8003 set_value, PDEV_CMD);
8004 break;
8005 }
8006
8007 case WE_SET_ANI_POLL_PERIOD:
8008 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008009 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008010 set_value);
8011 ret = wma_cli_set_command(pAdapter->sessionId,
8012 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
8013 set_value, PDEV_CMD);
8014 break;
8015 }
8016
8017 case WE_SET_ANI_LISTEN_PERIOD:
8018 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008019 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008020 set_value);
8021 ret = wma_cli_set_command(pAdapter->sessionId,
8022 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
8023 set_value, PDEV_CMD);
8024 break;
8025 }
8026
8027 case WE_SET_ANI_OFDM_LEVEL:
8028 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008029 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008030 set_value);
8031 ret = wma_cli_set_command(pAdapter->sessionId,
8032 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
8033 set_value, PDEV_CMD);
8034 break;
8035 }
8036
8037 case WE_SET_ANI_CCK_LEVEL:
8038 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008039 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008040 set_value);
8041 ret = wma_cli_set_command(pAdapter->sessionId,
8042 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
8043 set_value, PDEV_CMD);
8044 break;
8045 }
8046
8047 case WE_SET_DYNAMIC_BW:
8048 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008049 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008050 set_value);
8051 ret = wma_cli_set_command(pAdapter->sessionId,
8052 WMI_PDEV_PARAM_DYNAMIC_BW,
8053 set_value, PDEV_CMD);
8054 break;
8055 }
8056
8057 case WE_SET_CTS_CBW:
8058 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008059 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008060 ret = wma_cli_set_command(pAdapter->sessionId,
8061 WMI_PDEV_PARAM_CTS_CBW,
8062 set_value, PDEV_CMD);
8063 break;
8064 }
8065
8066 case WE_SET_11N_RATE:
8067 {
8068 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07008069 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008070 set_value);
8071
8072 if (set_value != 0xff) {
8073 rix = RC_2_RATE_IDX(set_value);
8074 if (set_value & 0x80) {
8075 preamble = WMI_RATE_PREAMBLE_HT;
8076 nss = HT_RC_2_STREAMS(set_value) - 1;
8077 } else {
8078 nss = 0;
8079 rix = RC_2_RATE_IDX(set_value);
8080 if (set_value & 0x10) {
8081 preamble =
8082 WMI_RATE_PREAMBLE_CCK;
8083 if (rix != 0x3)
8084 /* Enable Short
8085 * preamble always for
8086 * CCK except 1mbps
8087 */
8088 rix |= 0x4;
8089 } else {
8090 preamble =
8091 WMI_RATE_PREAMBLE_OFDM;
8092 }
8093 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008094 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008095 }
8096 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
8097 set_value, rix, preamble, nss);
8098
8099 ret = wma_cli_set_command(pAdapter->sessionId,
8100 WMI_VDEV_PARAM_FIXED_RATE,
8101 set_value, VDEV_CMD);
8102 break;
8103 }
8104
8105 case WE_SET_VHT_RATE:
8106 {
8107 uint8_t preamble = 0, nss = 0, rix = 0;
8108
8109 if (set_value != 0xff) {
8110 rix = RC_2_RATE_IDX_11AC(set_value);
8111 preamble = WMI_RATE_PREAMBLE_VHT;
8112 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
8113
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008114 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008115 }
8116 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
8117 set_value, rix, preamble, nss);
8118 ret = wma_cli_set_command(pAdapter->sessionId,
8119 WMI_VDEV_PARAM_FIXED_RATE,
8120 set_value, VDEV_CMD);
8121 break;
8122 }
8123
8124 case WE_SET_AMPDU:
8125 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008126 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008127 ret = wma_cli_set_command(pAdapter->sessionId,
8128 GEN_VDEV_PARAM_AMPDU,
8129 set_value, GEN_CMD);
8130 break;
8131 }
8132
8133 case WE_SET_AMSDU:
8134 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008135 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008136 ret = wma_cli_set_command(pAdapter->sessionId,
8137 GEN_VDEV_PARAM_AMSDU,
8138 set_value, GEN_CMD);
8139 break;
8140 }
8141
8142 case WE_SET_BURST_ENABLE:
8143 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008144 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008145 if ((set_value == 0) || (set_value == 1)) {
8146 ret = wma_cli_set_command(pAdapter->sessionId,
8147 WMI_PDEV_PARAM_BURST_ENABLE,
8148 set_value, PDEV_CMD);
8149 } else
8150 ret = -EINVAL;
8151 break;
8152 }
8153 case WE_SET_BURST_DUR:
8154 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008155 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07008156 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008157 ret = wma_cli_set_command(pAdapter->sessionId,
8158 WMI_PDEV_PARAM_BURST_DUR,
8159 set_value, PDEV_CMD);
8160 else
8161 ret = -EINVAL;
8162 break;
8163 }
8164
8165 case WE_SET_TX_CHAINMASK:
8166 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008167 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008168 set_value);
8169 ret = wma_cli_set_command(pAdapter->sessionId,
8170 WMI_PDEV_PARAM_TX_CHAIN_MASK,
8171 set_value, PDEV_CMD);
8172 break;
8173 }
8174
8175 case WE_SET_RX_CHAINMASK:
8176 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008177 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008178 set_value);
8179 ret = wma_cli_set_command(pAdapter->sessionId,
8180 WMI_PDEV_PARAM_RX_CHAIN_MASK,
8181 set_value, PDEV_CMD);
8182 break;
8183 }
8184
8185 case WE_SET_TXPOW_2G:
8186 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008187 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008188 set_value);
8189 ret = wma_cli_set_command(pAdapter->sessionId,
8190 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
8191 set_value, PDEV_CMD);
8192 break;
8193 }
8194
8195 case WE_SET_TXPOW_5G:
8196 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008197 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008198 set_value);
8199 ret = wma_cli_set_command(pAdapter->sessionId,
8200 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
8201 set_value, PDEV_CMD);
8202 break;
8203 }
8204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008205 /* Firmware debug log */
8206 case WE_DBGLOG_LOG_LEVEL:
8207 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008208 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008209 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
8210 ret = wma_cli_set_command(pAdapter->sessionId,
8211 WMI_DBGLOG_LOG_LEVEL,
8212 set_value, DBG_CMD);
8213 break;
8214 }
8215
8216 case WE_DBGLOG_VAP_ENABLE:
8217 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008218 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008219 ret = wma_cli_set_command(pAdapter->sessionId,
8220 WMI_DBGLOG_VAP_ENABLE,
8221 set_value, DBG_CMD);
8222 break;
8223 }
8224
8225 case WE_DBGLOG_VAP_DISABLE:
8226 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008227 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008228 ret = wma_cli_set_command(pAdapter->sessionId,
8229 WMI_DBGLOG_VAP_DISABLE,
8230 set_value, DBG_CMD);
8231 break;
8232 }
8233
8234 case WE_DBGLOG_MODULE_ENABLE:
8235 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008236 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008237 set_value);
8238 hdd_ctx->fw_log_settings.enable = set_value;
8239 ret = wma_cli_set_command(pAdapter->sessionId,
8240 WMI_DBGLOG_MODULE_ENABLE,
8241 set_value, DBG_CMD);
8242 break;
8243 }
8244
8245 case WE_DBGLOG_MODULE_DISABLE:
8246 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008247 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008248 set_value);
8249 hdd_ctx->fw_log_settings.enable = set_value;
8250 ret = wma_cli_set_command(pAdapter->sessionId,
8251 WMI_DBGLOG_MODULE_DISABLE,
8252 set_value, DBG_CMD);
8253 break;
8254 }
8255 case WE_DBGLOG_MOD_LOG_LEVEL:
8256 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008257 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008258 set_value);
8259
8260 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
8261 hdd_ctx->fw_log_settings.index = 0;
8262
8263 hdd_ctx->fw_log_settings.
8264 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
8265 set_value;
8266 hdd_ctx->fw_log_settings.index++;
8267
8268 ret = wma_cli_set_command(pAdapter->sessionId,
8269 WMI_DBGLOG_MOD_LOG_LEVEL,
8270 set_value, DBG_CMD);
8271 break;
8272 }
8273
8274 case WE_DBGLOG_TYPE:
8275 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008276 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008277 hdd_ctx->fw_log_settings.dl_type = set_value;
8278 ret = wma_cli_set_command(pAdapter->sessionId,
8279 WMI_DBGLOG_TYPE,
8280 set_value, DBG_CMD);
8281 break;
8282 }
8283 case WE_DBGLOG_REPORT_ENABLE:
8284 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008285 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008286 set_value);
8287 hdd_ctx->fw_log_settings.dl_report = set_value;
8288 ret = wma_cli_set_command(pAdapter->sessionId,
8289 WMI_DBGLOG_REPORT_ENABLE,
8290 set_value, DBG_CMD);
8291 break;
8292 }
8293
8294 case WE_SET_TXRX_FWSTATS:
8295 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008296 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008297 ret = wma_cli_set_command(pAdapter->sessionId,
8298 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
8299 set_value, VDEV_CMD);
8300 break;
8301 }
8302
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008303 case WE_SET_TXRX_STATS:
8304 {
8305 hdd_notice("WE_SET_TXRX_STATS val %d", set_value);
8306 ret = cds_get_datapath_handles(&soc, &pdev, &vdev,
8307 pAdapter->sessionId);
8308
8309 if (ret != 0)
8310 break;
8311
8312 qdf_mem_zero(&req, sizeof(req));
8313 ret = cdp_txrx_stats(soc, vdev, &req, set_value);
8314 break;
8315 }
8316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008317 case WE_TXRX_FWSTATS_RESET:
8318 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008319 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008320 ret = wma_cli_set_command(pAdapter->sessionId,
8321 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
8322 set_value, VDEV_CMD);
8323 break;
8324 }
8325
8326 case WE_DUMP_STATS:
8327 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008328 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008329 hdd_wlan_dump_stats(pAdapter, set_value);
8330 break;
8331 }
8332
8333 case WE_CLEAR_STATS:
8334 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008335 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008336 switch (set_value) {
8337 case WLAN_HDD_STATS:
8338 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
8339 memset(&pAdapter->hdd_stats, 0,
8340 sizeof(pAdapter->hdd_stats));
8341 break;
8342 case WLAN_TXRX_HIST_STATS:
8343 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
8344 break;
8345 case WLAN_HDD_NETIF_OPER_HISTORY:
8346 wlan_hdd_clear_netif_queue_history(hdd_ctx);
8347 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05308348 case WLAN_HIF_STATS:
8349 hdd_clear_hif_stats();
8350 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008351 default:
Leo Changfdb45c32016-10-28 11:09:23 -07008352 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
8353 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008354 }
8355 break;
8356 }
8357
8358 case WE_PPS_PAID_MATCH:
8359 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008360 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008361 return EINVAL;
8362
Jeff Johnson99bac312016-06-28 10:38:18 -07008363 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008364 set_value);
8365 ret = wma_cli_set_command(pAdapter->sessionId,
8366 WMI_VDEV_PPS_PAID_MATCH,
8367 set_value, PPS_CMD);
8368 break;
8369 }
8370
8371 case WE_PPS_GID_MATCH:
8372 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008373 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008374 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008375 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008376 set_value);
8377 ret = wma_cli_set_command(pAdapter->sessionId,
8378 WMI_VDEV_PPS_GID_MATCH,
8379 set_value, PPS_CMD);
8380 break;
8381 }
8382
8383 case WE_PPS_EARLY_TIM_CLEAR:
8384 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008385 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008386 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008387 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008388 set_value);
8389 ret = wma_cli_set_command(pAdapter->sessionId,
8390 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
8391 set_value, PPS_CMD);
8392 break;
8393 }
8394
8395 case WE_PPS_EARLY_DTIM_CLEAR:
8396 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008397 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008398 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008399 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008400 set_value);
8401 ret = wma_cli_set_command(pAdapter->sessionId,
8402 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
8403 set_value, PPS_CMD);
8404 break;
8405 }
8406
8407 case WE_PPS_EOF_PAD_DELIM:
8408 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008409 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008410 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008411 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008412 set_value);
8413 ret = wma_cli_set_command(pAdapter->sessionId,
8414 WMI_VDEV_PPS_EOF_PAD_DELIM,
8415 set_value, PPS_CMD);
8416 break;
8417 }
8418
8419 case WE_PPS_MACADDR_MISMATCH:
8420 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008421 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008422 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008423 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008424 set_value);
8425 ret = wma_cli_set_command(pAdapter->sessionId,
8426 WMI_VDEV_PPS_MACADDR_MISMATCH,
8427 set_value, PPS_CMD);
8428 break;
8429 }
8430
8431 case WE_PPS_DELIM_CRC_FAIL:
8432 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008433 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008434 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008435 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008436 set_value);
8437 ret = wma_cli_set_command(pAdapter->sessionId,
8438 WMI_VDEV_PPS_DELIM_CRC_FAIL,
8439 set_value, PPS_CMD);
8440 break;
8441 }
8442
8443 case WE_PPS_GID_NSTS_ZERO:
8444 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008445 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008447 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008448 set_value);
8449 ret = wma_cli_set_command(pAdapter->sessionId,
8450 WMI_VDEV_PPS_GID_NSTS_ZERO,
8451 set_value, PPS_CMD);
8452 break;
8453 }
8454
8455 case WE_PPS_RSSI_CHECK:
8456 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008457 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008458 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008459 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008460 set_value);
8461 ret = wma_cli_set_command(pAdapter->sessionId,
8462 WMI_VDEV_PPS_RSSI_CHECK,
8463 set_value, PPS_CMD);
8464 break;
8465 }
8466
8467 case WE_PPS_5G_EBT:
8468 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008469 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008470 return -EINVAL;
8471
Jeff Johnson99bac312016-06-28 10:38:18 -07008472 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008473 ret = wma_cli_set_command(pAdapter->sessionId,
8474 WMI_VDEV_PPS_5G_EBT,
8475 set_value, PPS_CMD);
8476 break;
8477 }
8478
8479 case WE_SET_HTSMPS:
8480 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008481 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008482 ret = wma_cli_set_command(pAdapter->sessionId,
8483 WMI_STA_SMPS_FORCE_MODE_CMDID,
8484 set_value, VDEV_CMD);
8485 break;
8486 }
8487
8488 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
8489 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008490 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008491 set_value);
8492 ret = wma_cli_set_command(pAdapter->sessionId,
8493 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
8494 set_value, QPOWER_CMD);
8495 break;
8496 }
8497
8498 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
8499 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008500 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008501 set_value);
8502 ret = wma_cli_set_command(
8503 pAdapter->sessionId,
8504 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
8505 set_value, QPOWER_CMD);
8506 break;
8507 }
8508
8509 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
8510 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008511 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008512 set_value);
8513 ret = wma_cli_set_command(
8514 pAdapter->sessionId,
8515 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
8516 set_value, QPOWER_CMD);
8517 break;
8518 }
8519
8520 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
8521 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008522 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008523 set_value);
8524 ret = wma_cli_set_command(
8525 pAdapter->sessionId,
8526 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
8527 set_value, QPOWER_CMD);
8528 break;
8529 }
8530
8531 case WE_MCC_CONFIG_LATENCY:
8532 {
8533 cds_set_mcc_latency(pAdapter, set_value);
8534 break;
8535 }
8536
8537 case WE_MCC_CONFIG_QUOTA:
8538 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008539 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008540 set_value);
8541 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
8542 break;
8543 }
8544 case WE_SET_DEBUG_LOG:
8545 {
8546 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05308547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008548 hdd_ctx->config->gEnableDebugLog = set_value;
8549 sme_update_connect_debug(hdd_ctx->hHal, set_value);
8550 break;
8551 }
8552 case WE_SET_EARLY_RX_ADJUST_ENABLE:
8553 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008554 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008555 if ((set_value == 0) || (set_value == 1))
8556 ret = wma_cli_set_command(
8557 pAdapter->sessionId,
8558 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
8559 set_value, VDEV_CMD);
8560 else
8561 ret = -EINVAL;
8562 break;
8563 }
8564 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
8565 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008566 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008567 ret = wma_cli_set_command(pAdapter->sessionId,
8568 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
8569 set_value, VDEV_CMD);
8570 break;
8571 }
8572 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
8573 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008574 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008575 set_value);
8576 ret = wma_cli_set_command(
8577 pAdapter->sessionId,
8578 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
8579 set_value, VDEV_CMD);
8580 break;
8581 }
8582 case WE_SET_EARLY_RX_SLOP_STEP:
8583 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008584 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008585 set_value);
8586 ret = wma_cli_set_command(pAdapter->sessionId,
8587 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
8588 set_value, VDEV_CMD);
8589 break;
8590 }
8591 case WE_SET_EARLY_RX_INIT_SLOP:
8592 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008593 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008594 set_value);
8595 ret = wma_cli_set_command(pAdapter->sessionId,
8596 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
8597 set_value, VDEV_CMD);
8598 break;
8599 }
8600 case WE_SET_EARLY_RX_ADJUST_PAUSE:
8601 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008602 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008603 if ((set_value == 0) || (set_value == 1))
8604 ret = wma_cli_set_command(
8605 pAdapter->sessionId,
8606 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
8607 set_value, VDEV_CMD);
8608 else
8609 ret = -EINVAL;
8610 break;
8611 }
8612 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
8613 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008614 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008615 ret = wma_cli_set_command(pAdapter->sessionId,
8616 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
8617 set_value, VDEV_CMD);
8618 break;
8619 }
8620 case WE_SET_SCAN_DISABLE:
8621 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008622 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008623 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
8624 break;
8625 }
Govind Singha471e5e2015-10-12 17:11:14 +05308626 case WE_START_FW_PROFILE:
8627 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008628 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05308629 ret = wma_cli_set_command(pAdapter->sessionId,
8630 WMI_WLAN_PROFILE_TRIGGER_CMDID,
8631 set_value, DBG_CMD);
8632 break;
8633 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308634 case WE_SET_CHANNEL:
8635 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008636 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308637 pAdapter->sessionId, pAdapter->device_mode);
8638
Krunal Sonif07bb382016-03-10 13:02:11 -08008639 if ((QDF_STA_MODE == pAdapter->device_mode) ||
8640 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308641
8642 status = sme_ext_change_channel(hHal,
8643 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308644 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008645 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308646 status);
8647 ret = -EINVAL;
8648 }
8649 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008650 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308651 pAdapter->device_mode);
8652 ret = -EINVAL;
8653 }
8654 break;
8655 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308656 case WE_SET_CONC_SYSTEM_PREF:
8657 {
8658 hdd_info("New preference: %d", set_value);
8659 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
8660 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
8661 hdd_err("Invalid system preference %d", set_value);
8662 return -EINVAL;
8663 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308664
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308665 /* hdd_ctx, hdd_ctx->config are already checked for null */
8666 hdd_ctx->config->conc_system_pref = set_value;
8667 break;
8668 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008669 case WE_SET_11AX_RATE:
8670 ret = hdd_set_11ax_rate(pAdapter, set_value, NULL);
8671 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07008672 case WE_SET_DCM:
8673 hdd_notice("Set WMI_VDEV_PARAM_HE_DCM: %d", set_value);
8674 ret = wma_cli_set_command(pAdapter->sessionId,
8675 WMI_VDEV_PARAM_HE_DCM, set_value,
8676 VDEV_CMD);
8677 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07008678 case WE_SET_RANGE_EXT:
8679 hdd_notice("Set WMI_VDEV_PARAM_HE_RANGE_EXT: %d", set_value);
8680 ret = wma_cli_set_command(pAdapter->sessionId,
8681 WMI_VDEV_PARAM_HE_RANGE_EXT,
8682 set_value, VDEV_CMD);
8683 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008684 default:
8685 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008686 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008687 sub_cmd);
8688 ret = -EINVAL;
8689 break;
8690 }
8691 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308692 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008693 return ret;
8694}
8695
8696static int iw_setint_getnone(struct net_device *dev,
8697 struct iw_request_info *info,
8698 union iwreq_data *wrqu,
8699 char *extra)
8700{
8701 int ret;
8702
8703 cds_ssr_protect(__func__);
8704 ret = __iw_setint_getnone(dev, info, wrqu, extra);
8705 cds_ssr_unprotect(__func__);
8706
8707 return ret;
8708}
8709
8710/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008711 * __iw_setnone_get_threeint() - return three value to up layer.
8712 *
8713 * @dev: pointer of net_device of this wireless card
8714 * @info: meta data about Request sent
8715 * @wrqu: include request info
8716 * @extra: buf used for in/Output
8717 *
8718 * Return: execute result
8719 */
8720static int __iw_setnone_get_threeint(struct net_device *dev,
8721 struct iw_request_info *info,
8722 union iwreq_data *wrqu, char *extra)
8723{
8724 int ret = 0; /* success */
8725 uint32_t *value = (int *)extra;
8726 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8727 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8728
8729 ENTER_DEV(dev);
8730 ret = wlan_hdd_validate_context(hdd_ctx);
8731 if (0 != ret)
8732 return ret;
8733
Jeff Johnson441e1f72017-02-07 08:50:49 -08008734 ret = hdd_check_private_wext_control(hdd_ctx, info);
8735 if (0 != ret)
8736 return ret;
8737
Jeff Johnson99bac312016-06-28 10:38:18 -07008738 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008739 switch (value[0]) {
8740 case WE_GET_TSF:
8741 ret = hdd_indicate_tsf(adapter, value, 3);
8742 break;
8743 default:
8744 hdd_err("Invalid IOCTL get_value command %d", value[0]);
8745 break;
8746 }
8747 return ret;
8748}
8749
8750/**
8751 * iw_setnone_get_threeint() - return three value to up layer.
8752 *
8753 * @dev: pointer of net_device of this wireless card
8754 * @info: meta data about Request sent
8755 * @wrqu: include request info
8756 * @extra: buf used for in/Output
8757 *
8758 * Return: execute result
8759 */
8760static int iw_setnone_get_threeint(struct net_device *dev,
8761 struct iw_request_info *info,
8762 union iwreq_data *wrqu, char *extra)
8763{
8764 int ret;
8765
8766 cds_ssr_protect(__func__);
8767 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8768 cds_ssr_unprotect(__func__);
8769
8770 return ret;
8771}
8772
8773/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008774 * iw_setchar_getnone() - Generic "set string" private ioctl handler
8775 * @dev: device upon which the ioctl was received
8776 * @info: ioctl request information
8777 * @wrqu: ioctl request data
8778 * @extra: ioctl extra data
8779 *
8780 * Return: 0 on success, non-zero on error
8781 */
8782static int __iw_setchar_getnone(struct net_device *dev,
8783 struct iw_request_info *info,
8784 union iwreq_data *wrqu, char *extra)
8785{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308786 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008787 int sub_cmd;
8788 int ret;
8789 char *pBuffer = NULL;
8790 hdd_adapter_t *pAdapter = (netdev_priv(dev));
8791 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008792 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008793 struct iw_point s_priv_data;
8794
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008795 ENTER_DEV(dev);
8796
Mukul Sharma34777c62015-11-02 20:22:30 +05308797 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008798 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05308799 return -EPERM;
8800 }
8801
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008802 ret = wlan_hdd_validate_context(hdd_ctx);
8803 if (0 != ret)
8804 return ret;
8805
Jeff Johnson441e1f72017-02-07 08:50:49 -08008806 ret = hdd_check_private_wext_control(hdd_ctx, info);
8807 if (0 != ret)
8808 return ret;
8809
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008810 /* helper function to get iwreq_data with compat handling. */
8811 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8812 return -EINVAL;
8813 }
8814
8815 /* make sure all params are correctly passed to function */
8816 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
8817 return -EINVAL;
8818 }
8819
8820 sub_cmd = s_priv_data.flags;
8821
8822 /* ODD number is used for set, copy data using copy_from_user */
8823 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8824 s_priv_data.length);
8825 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008826 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008827 return -ENOMEM;
8828 }
8829
Jeff Johnson99bac312016-06-28 10:38:18 -07008830 hdd_notice("Received length %d", s_priv_data.length);
8831 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008832
8833 switch (sub_cmd) {
8834 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07008835 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008836 hdd_add_wowl_ptrn(pAdapter, pBuffer);
8837 break;
8838 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07008839 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008840 hdd_del_wowl_ptrn(pAdapter, pBuffer);
8841 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008842 case WE_NEIGHBOR_REPORT_REQUEST:
8843 {
8844 tRrmNeighborReq neighborReq;
8845 tRrmNeighborRspCallbackInfo callbackInfo;
8846
8847 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008848 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008849 neighborReq.no_ssid =
8850 (s_priv_data.length - 1) ? false : true;
8851 if (!neighborReq.no_ssid) {
8852 neighborReq.ssid.length =
8853 (s_priv_data.length - 1) >
8854 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308855 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008856 pBuffer,
8857 neighborReq.ssid.length);
8858 }
8859
8860 callbackInfo.neighborRspCallback = NULL;
8861 callbackInfo.neighborRspCallbackContext = NULL;
8862 callbackInfo.timeout = 5000; /* 5 seconds */
8863 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
8864 (pAdapter),
8865 pAdapter->sessionId,
8866 &neighborReq,
8867 &callbackInfo);
8868 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008869 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870 ret = -EINVAL;
8871 }
8872 }
8873 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008874 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008875 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008876 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
8877 s_priv_data.length);
8878 break;
8879 case WE_SET_CONFIG:
8880 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308881 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008882 ret = -EINVAL;
8883 }
8884 break;
8885 default:
8886 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008887 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008888 sub_cmd);
8889 ret = -EINVAL;
8890 break;
8891 }
8892 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07008893 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308894 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008895 return ret;
8896}
8897
8898static int iw_setchar_getnone(struct net_device *dev,
8899 struct iw_request_info *info,
8900 union iwreq_data *wrqu, char *extra)
8901{
8902 int ret;
8903
8904 cds_ssr_protect(__func__);
8905 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
8906 cds_ssr_unprotect(__func__);
8907
8908 return ret;
8909}
8910
8911/**
8912 * iw_setnone_getint() - Generic "get integer" private ioctl handler
8913 * @dev: device upon which the ioctl was received
8914 * @info: ioctl request information
8915 * @wrqu: ioctl request data
8916 * @extra: ioctl extra data
8917 *
8918 * Return: 0 on success, non-zero on error
8919 */
8920static int __iw_setnone_getint(struct net_device *dev,
8921 struct iw_request_info *info,
8922 union iwreq_data *wrqu, char *extra)
8923{
8924 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8925 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8926 int *value = (int *)extra;
8927 int ret;
8928 tSmeConfigParams smeConfig;
8929 hdd_context_t *hdd_ctx;
8930
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008931 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008933 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8934 ret = wlan_hdd_validate_context(hdd_ctx);
8935 if (0 != ret)
8936 return ret;
8937
Jeff Johnson441e1f72017-02-07 08:50:49 -08008938 ret = hdd_check_private_wext_control(hdd_ctx, info);
8939 if (0 != ret)
8940 return ret;
8941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008942 switch (value[0]) {
8943 case WE_GET_11D_STATE:
8944 {
8945 sme_get_config_param(hHal, &smeConfig);
8946
8947 *value = smeConfig.csrConfig.Is11dSupportEnabled;
8948
Jeff Johnson99bac312016-06-28 10:38:18 -07008949 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008950
8951 break;
8952 }
8953
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008954 case WE_GET_WLAN_DBG:
8955 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308956 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008957 *value = 0;
8958 break;
8959 }
8960 case WE_GET_MAX_ASSOC:
8961 {
8962 if (sme_cfg_get_int
8963 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308964 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008965 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008966 ret = -EIO;
8967 }
8968 break;
8969 }
8970 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
8971 *value = (WLAN_HDD_GET_CTX(
8972 pAdapter))->config->force_sap_acs;
8973 break;
8974
8975 case WE_GET_CONCURRENCY_MODE:
8976 {
8977 *value = cds_get_concurrency_mode();
8978
Jeff Johnson99bac312016-06-28 10:38:18 -07008979 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008980 break;
8981 }
8982
8983 case WE_GET_NSS:
8984 {
8985 sme_get_config_param(hHal, &smeConfig);
8986 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07008987 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008988 break;
8989 }
8990
8991 case WE_GET_GTX_HT_MCS:
8992 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008993 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008994 *value = wma_cli_get_command(pAdapter->sessionId,
8995 WMI_VDEV_PARAM_GTX_HT_MCS,
8996 GTX_CMD);
8997 break;
8998 }
8999
9000 case WE_GET_GTX_VHT_MCS:
9001 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009002 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009003 *value = wma_cli_get_command(pAdapter->sessionId,
9004 WMI_VDEV_PARAM_GTX_VHT_MCS,
9005 GTX_CMD);
9006 break;
9007 }
9008
9009 case WE_GET_GTX_USRCFG:
9010 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009011 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009012 *value = wma_cli_get_command(pAdapter->sessionId,
9013 WMI_VDEV_PARAM_GTX_USR_CFG,
9014 GTX_CMD);
9015 break;
9016 }
9017
9018 case WE_GET_GTX_THRE:
9019 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009020 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009021 *value = wma_cli_get_command(pAdapter->sessionId,
9022 WMI_VDEV_PARAM_GTX_THRE,
9023 GTX_CMD);
9024 break;
9025 }
9026
9027 case WE_GET_GTX_MARGIN:
9028 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009029 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009030 *value = wma_cli_get_command(pAdapter->sessionId,
9031 WMI_VDEV_PARAM_GTX_MARGIN,
9032 GTX_CMD);
9033 break;
9034 }
9035
9036 case WE_GET_GTX_STEP:
9037 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009038 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009039 *value = wma_cli_get_command(pAdapter->sessionId,
9040 WMI_VDEV_PARAM_GTX_STEP,
9041 GTX_CMD);
9042 break;
9043 }
9044
9045 case WE_GET_GTX_MINTPC:
9046 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009047 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009048 *value = wma_cli_get_command(pAdapter->sessionId,
9049 WMI_VDEV_PARAM_GTX_MINTPC,
9050 GTX_CMD);
9051 break;
9052 }
9053
9054 case WE_GET_GTX_BWMASK:
9055 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009056 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009057 *value = wma_cli_get_command(pAdapter->sessionId,
9058 WMI_VDEV_PARAM_GTX_BW_MASK,
9059 GTX_CMD);
9060 break;
9061 }
9062
9063 case WE_GET_LDPC:
9064 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309065 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009066 break;
9067 }
9068
9069 case WE_GET_TX_STBC:
9070 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309071 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009072 break;
9073 }
9074
9075 case WE_GET_RX_STBC:
9076 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309077 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009078 break;
9079 }
9080
9081 case WE_GET_SHORT_GI:
9082 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009083 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009084 *value = wma_cli_get_command(pAdapter->sessionId,
9085 WMI_VDEV_PARAM_SGI,
9086 VDEV_CMD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009087 break;
9088 }
9089
9090 case WE_GET_RTSCTS:
9091 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009092 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009093 *value = wma_cli_get_command(pAdapter->sessionId,
9094 WMI_VDEV_PARAM_ENABLE_RTSCTS,
9095 VDEV_CMD);
9096 break;
9097 }
9098
9099 case WE_GET_CHWIDTH:
9100 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009101 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009102 *value = wma_cli_get_command(pAdapter->sessionId,
9103 WMI_VDEV_PARAM_CHWIDTH,
9104 VDEV_CMD);
9105 break;
9106 }
9107
9108 case WE_GET_ANI_EN_DIS:
9109 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009110 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009111 *value = wma_cli_get_command(pAdapter->sessionId,
9112 WMI_PDEV_PARAM_ANI_ENABLE,
9113 PDEV_CMD);
9114 break;
9115 }
9116
9117 case WE_GET_ANI_POLL_PERIOD:
9118 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009119 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009120 *value = wma_cli_get_command(pAdapter->sessionId,
9121 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
9122 PDEV_CMD);
9123 break;
9124 }
9125
9126 case WE_GET_ANI_LISTEN_PERIOD:
9127 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009128 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009129 *value = wma_cli_get_command(pAdapter->sessionId,
9130 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
9131 PDEV_CMD);
9132 break;
9133 }
9134
9135 case WE_GET_ANI_OFDM_LEVEL:
9136 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009137 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009138 *value = wma_cli_get_command(pAdapter->sessionId,
9139 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
9140 PDEV_CMD);
9141 break;
9142 }
9143
9144 case WE_GET_ANI_CCK_LEVEL:
9145 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009146 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009147 *value = wma_cli_get_command(pAdapter->sessionId,
9148 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
9149 PDEV_CMD);
9150 break;
9151 }
9152
9153 case WE_GET_DYNAMIC_BW:
9154 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009155 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009156 *value = wma_cli_get_command(pAdapter->sessionId,
9157 WMI_PDEV_PARAM_DYNAMIC_BW,
9158 PDEV_CMD);
9159 break;
9160 }
9161
9162 case WE_GET_11N_RATE:
9163 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009164 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009165 *value = wma_cli_get_command(pAdapter->sessionId,
9166 WMI_VDEV_PARAM_FIXED_RATE,
9167 VDEV_CMD);
9168 break;
9169 }
9170
9171 case WE_GET_AMPDU:
9172 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009173 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009174 *value = wma_cli_get_command(pAdapter->sessionId,
9175 GEN_VDEV_PARAM_AMPDU,
9176 GEN_CMD);
9177 break;
9178 }
9179
9180 case WE_GET_AMSDU:
9181 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009182 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009183 *value = wma_cli_get_command(pAdapter->sessionId,
9184 GEN_VDEV_PARAM_AMSDU,
9185 GEN_CMD);
9186 break;
9187 }
9188
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009189 case WE_GET_ROAM_SYNCH_DELAY:
9190 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009191 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009192 *value = wma_cli_get_command(pAdapter->sessionId,
9193 GEN_VDEV_ROAM_SYNCH_DELAY,
9194 GEN_CMD);
9195 break;
9196 }
9197
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009198 case WE_GET_BURST_ENABLE:
9199 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009200 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009201 *value = wma_cli_get_command(pAdapter->sessionId,
9202 WMI_PDEV_PARAM_BURST_ENABLE,
9203 PDEV_CMD);
9204 break;
9205 }
9206 case WE_GET_BURST_DUR:
9207 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009208 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009209 *value = wma_cli_get_command(pAdapter->sessionId,
9210 WMI_PDEV_PARAM_BURST_DUR,
9211 PDEV_CMD);
9212 break;
9213 }
9214
9215 case WE_GET_TX_CHAINMASK:
9216 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009217 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009218 *value = wma_cli_get_command(pAdapter->sessionId,
9219 WMI_PDEV_PARAM_TX_CHAIN_MASK,
9220 PDEV_CMD);
9221 break;
9222 }
9223
9224 case WE_GET_RX_CHAINMASK:
9225 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009226 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009227 *value = wma_cli_get_command(pAdapter->sessionId,
9228 WMI_PDEV_PARAM_RX_CHAIN_MASK,
9229 PDEV_CMD);
9230 break;
9231 }
9232
9233 case WE_GET_TXPOW_2G:
9234 {
9235 uint32_t txpow2g = 0;
9236 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07009237 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009238 *value = wma_cli_get_command(pAdapter->sessionId,
9239 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
9240 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309241 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009242 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9243 &txpow2g)) {
9244 return -EIO;
9245 }
Jeff Johnson99bac312016-06-28 10:38:18 -07009246 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009247 break;
9248 }
9249
9250 case WE_GET_TXPOW_5G:
9251 {
9252 uint32_t txpow5g = 0;
9253 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07009254 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009255 *value = wma_cli_get_command(pAdapter->sessionId,
9256 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
9257 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309258 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009259 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9260 &txpow5g)) {
9261 return -EIO;
9262 }
Jeff Johnson99bac312016-06-28 10:38:18 -07009263 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009264 break;
9265 }
9266
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009267 case WE_GET_PPS_PAID_MATCH:
9268 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009269 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009270 *value = wma_cli_get_command(pAdapter->sessionId,
9271 WMI_VDEV_PPS_PAID_MATCH,
9272 PPS_CMD);
9273 break;
9274 }
9275
9276 case WE_GET_PPS_GID_MATCH:
9277 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009278 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009279 *value = wma_cli_get_command(pAdapter->sessionId,
9280 WMI_VDEV_PPS_GID_MATCH,
9281 PPS_CMD);
9282 break;
9283 }
9284
9285 case WE_GET_PPS_EARLY_TIM_CLEAR:
9286 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009287 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009288 *value = wma_cli_get_command(pAdapter->sessionId,
9289 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
9290 PPS_CMD);
9291 break;
9292 }
9293
9294 case WE_GET_PPS_EARLY_DTIM_CLEAR:
9295 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009296 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009297 *value = wma_cli_get_command(pAdapter->sessionId,
9298 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
9299 PPS_CMD);
9300 break;
9301 }
9302
9303 case WE_GET_PPS_EOF_PAD_DELIM:
9304 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009305 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009306 *value = wma_cli_get_command(pAdapter->sessionId,
9307 WMI_VDEV_PPS_EOF_PAD_DELIM,
9308 PPS_CMD);
9309 break;
9310 }
9311
9312 case WE_GET_PPS_MACADDR_MISMATCH:
9313 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009314 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009315 *value = wma_cli_get_command(pAdapter->sessionId,
9316 WMI_VDEV_PPS_MACADDR_MISMATCH,
9317 PPS_CMD);
9318 break;
9319 }
9320
9321 case WE_GET_PPS_DELIM_CRC_FAIL:
9322 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009323 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009324 *value = wma_cli_get_command(pAdapter->sessionId,
9325 WMI_VDEV_PPS_DELIM_CRC_FAIL,
9326 PPS_CMD);
9327 break;
9328 }
9329
9330 case WE_GET_PPS_GID_NSTS_ZERO:
9331 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009332 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009333 *value = wma_cli_get_command(pAdapter->sessionId,
9334 WMI_VDEV_PPS_GID_NSTS_ZERO,
9335 PPS_CMD);
9336 break;
9337 }
9338
9339 case WE_GET_PPS_RSSI_CHECK:
9340 {
9341
Jeff Johnson99bac312016-06-28 10:38:18 -07009342 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009343 *value = wma_cli_get_command(pAdapter->sessionId,
9344 WMI_VDEV_PPS_RSSI_CHECK,
9345 PPS_CMD);
9346 break;
9347 }
9348
9349 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
9350 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009351 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009352 *value = wma_cli_get_command(pAdapter->sessionId,
9353 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
9354 QPOWER_CMD);
9355 break;
9356 }
9357
9358 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
9359 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009360 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009361 *value = wma_cli_get_command(pAdapter->sessionId,
9362 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
9363 QPOWER_CMD);
9364 break;
9365 }
9366
9367 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
9368 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009369 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009370 *value = wma_cli_get_command(pAdapter->sessionId,
9371 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
9372 QPOWER_CMD);
9373 break;
9374 }
9375
9376 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
9377 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009378 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009379 *value = wma_cli_get_command(pAdapter->sessionId,
9380 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
9381 QPOWER_CMD);
9382 break;
9383 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009384 case WE_CAP_TSF:
9385 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
9386 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009387 case WE_GET_TEMPERATURE:
9388 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009389 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009390 ret = wlan_hdd_get_temperature(pAdapter, value);
9391 break;
9392 }
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07009393 case WE_GET_DCM:
9394 hdd_notice("GET WMI_VDEV_PARAM_HE_DCM");
9395 *value = wma_cli_get_command(pAdapter->sessionId,
9396 WMI_VDEV_PARAM_HE_DCM,
9397 VDEV_CMD);
9398 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07009399 case WE_GET_RANGE_EXT:
9400 hdd_notice("GET WMI_VDEV_PARAM_HE_RANGE_EXT");
9401 *value = wma_cli_get_command(pAdapter->sessionId,
9402 WMI_VDEV_PARAM_HE_RANGE_EXT,
9403 VDEV_CMD);
9404 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009405 default:
9406 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009407 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009408 value[0]);
9409 break;
9410 }
9411 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309412 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009413 return ret;
9414}
9415
9416static int iw_setnone_getint(struct net_device *dev,
9417 struct iw_request_info *info,
9418 union iwreq_data *wrqu, char *extra)
9419{
9420 int ret;
9421
9422 cds_ssr_protect(__func__);
9423 ret = __iw_setnone_getint(dev, info, wrqu, extra);
9424 cds_ssr_unprotect(__func__);
9425
9426 return ret;
9427}
9428
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309429static int hdd_set_fwtest(int argc, int cmd, int value)
9430{
9431 struct set_fwtest_params *fw_test;
9432
9433 /* check for max number of arguments */
9434 if (argc > (WMA_MAX_NUM_ARGS) ||
9435 argc != HDD_FWTEST_PARAMS) {
9436 hdd_err("Too Many args %d", argc);
9437 return -EINVAL;
9438 }
9439 /*
9440 * check if number of arguments are 3 then, check
9441 * then set the default value for sounding interval.
9442 */
9443 if (HDD_FWTEST_PARAMS == argc) {
9444 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
9445 value = HDD_FWTEST_SU_DEFAULT_VALUE;
9446 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
9447 value = HDD_FWTEST_MU_DEFAULT_VALUE;
9448 }
9449 /* check sounding interval value should not exceed to max */
9450 if (value > HDD_FWTEST_MAX_VALUE) {
9451 hdd_err("Invalid arguments value should not exceed max: %d",
9452 value);
9453 return -EINVAL;
9454 }
9455 fw_test = qdf_mem_malloc(sizeof(*fw_test));
9456 if (NULL == fw_test) {
9457 hdd_err("qdf_mem_malloc failed for fw_test");
9458 return -ENOMEM;
9459 }
9460 fw_test->arg = cmd;
9461 fw_test->value = value;
9462 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
9463 qdf_mem_free(fw_test);
9464 hdd_err("Not able to post FW_TEST_CMD message to WMA");
9465 return -EINVAL;
9466 }
9467 return 0;
9468}
9469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009470/**
9471 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
9472 * @dev: device upon which the ioctl was received
9473 * @info: ioctl request information
9474 * @wrqu: ioctl request data
9475 * @extra: ioctl extra data
9476 *
9477 * Return: 0 on success, non-zero on error
9478 */
9479static int __iw_set_three_ints_getnone(struct net_device *dev,
9480 struct iw_request_info *info,
9481 union iwreq_data *wrqu, char *extra)
9482{
9483 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9484 int *value = (int *)extra;
9485 int sub_cmd = value[0];
9486 int ret;
9487 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9488
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009489 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309490
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009491 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009492 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009493 return -EPERM;
9494 }
9495
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009496 ret = wlan_hdd_validate_context(hdd_ctx);
9497 if (0 != ret)
9498 return ret;
9499
Jeff Johnson441e1f72017-02-07 08:50:49 -08009500 ret = hdd_check_private_wext_control(hdd_ctx, info);
9501 if (0 != ret)
9502 return ret;
9503
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009504 switch (sub_cmd) {
9505
9506 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309507 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009508 break;
9509 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309510 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009511 break;
9512
9513 /* value[3] the acs band is not required as start and end channels are
9514 * enough but this cmd is maintained under set three ints for historic
9515 * reasons.
9516 */
9517 case WE_SET_SAP_CHANNELS:
9518 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309519 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009520 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309521 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009522 ret = -EINVAL;
9523 } else {
9524 hdd_ctx->config->force_sap_acs_st_ch = value[1];
9525 hdd_ctx->config->force_sap_acs_end_ch = value[2];
9526 }
9527 break;
9528 case WE_SET_DUAL_MAC_SCAN_CONFIG:
9529 hdd_debug("Ioctl to set dual mac scan config");
9530 if (hdd_ctx->config->dual_mac_feature_disable) {
9531 hdd_err("Dual mac feature is disabled from INI");
9532 return -EPERM;
9533 }
9534 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08009535 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009536 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309537 case WE_SET_FW_TEST:
9538 {
9539 ret = hdd_set_fwtest(value[1], value[2], value[3]);
9540 if (ret) {
9541 hdd_err("Not able to set fwtest %d", ret);
9542 return ret;
9543 }
9544 }
9545 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009546 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009547 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009548 break;
9549
9550 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309551 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009552 return ret;
9553}
9554
9555int iw_set_three_ints_getnone(struct net_device *dev,
9556 struct iw_request_info *info,
9557 union iwreq_data *wrqu, char *extra)
9558{
9559 int ret;
9560
9561 cds_ssr_protect(__func__);
9562 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
9563 cds_ssr_unprotect(__func__);
9564
9565 return ret;
9566}
9567
9568/**
9569 * hdd_connection_state_string() - Get connection state string
9570 * @connection_state: enum to be converted to a string
9571 *
9572 * Return: the string equivalent of @connection_state
9573 */
9574static const char *
9575hdd_connection_state_string(eConnectionState connection_state)
9576{
9577 switch (connection_state) {
9578 CASE_RETURN_STRING(eConnectionState_NotConnected);
9579 CASE_RETURN_STRING(eConnectionState_Connecting);
9580 CASE_RETURN_STRING(eConnectionState_Associated);
9581 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
9582 CASE_RETURN_STRING(eConnectionState_IbssConnected);
9583 CASE_RETURN_STRING(eConnectionState_Disconnecting);
9584 default:
9585 return "UNKNOWN";
9586 }
9587}
9588
Naveen Rawat910726a2017-03-06 11:42:51 -08009589#if defined(FEATURE_OEM_DATA_SUPPORT)
9590/**
9591 * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
9592 * wifi_pos api to get oem data caps
9593 * @dev: net device upon which the request was received
9594 * @info: ioctl request information
9595 * @wrqu: ioctl request data
9596 * @extra: ioctl data payload
9597 *
9598 * Return: 0 for success, negative errno value on failure
9599 */
9600static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9601 struct iw_request_info *info,
9602 union iwreq_data *wrqu, char *extra)
9603{
9604 return iw_get_oem_data_cap(dev, info, wrqu, extra);
9605}
9606#elif defined(WIFI_POS_CONVERGED)
9607static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9608 struct iw_request_info *info,
9609 union iwreq_data *wrqu, char *extra)
9610{
9611 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9612 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9613
9614 return os_if_wifi_pos_populate_caps(hdd_ctx->hdd_psoc,
9615 (struct wifi_pos_driver_caps *)extra);
9616}
9617#else
9618static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9619 struct iw_request_info *info,
9620 union iwreq_data *wrqu, char *extra)
9621{
9622 return -ENOTSUPP;
9623}
9624#endif
9625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009626/**
9627 * iw_get_char_setnone() - Generic "get string" private ioctl handler
9628 * @dev: device upon which the ioctl was received
9629 * @info: ioctl request information
9630 * @wrqu: ioctl request data
9631 * @extra: ioctl extra data
9632 *
9633 * Return: 0 on success, non-zero on error
9634 */
9635static int __iw_get_char_setnone(struct net_device *dev,
9636 struct iw_request_info *info,
9637 union iwreq_data *wrqu, char *extra)
9638{
9639 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9640 int sub_cmd = wrqu->data.flags;
9641 hdd_context_t *hdd_ctx;
9642 int ret;
9643#ifdef WLAN_FEATURE_11W
9644 hdd_wext_state_t *pWextState;
9645#endif
9646
9647#ifdef WLAN_FEATURE_11W
9648 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9649#endif
9650
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009651 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309652
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009653 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9654 ret = wlan_hdd_validate_context(hdd_ctx);
9655 if (0 != ret)
9656 return ret;
9657
Jeff Johnson441e1f72017-02-07 08:50:49 -08009658 ret = hdd_check_private_wext_control(hdd_ctx, info);
9659 if (0 != ret)
9660 return ret;
9661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009662 switch (sub_cmd) {
9663 case WE_WLAN_VERSION:
9664 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05309665 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009666 break;
9667 }
9668
9669 case WE_GET_STATS:
9670 {
9671 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
9672 extra, WE_MAX_STR_LEN);
9673 break;
9674 }
9675
Dustin Brownd9322482017-01-09 12:46:03 -08009676 case WE_GET_SUSPEND_RESUME_STATS:
9677 {
9678 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
9679 WE_MAX_STR_LEN);
9680 if (ret >= 0) {
9681 wrqu->data.length = ret;
9682 ret = 0;
9683 }
9684
9685 break;
9686 }
9687
Govind Singha471e5e2015-10-12 17:11:14 +05309688 case WE_LIST_FW_PROFILE:
9689 hdd_wlan_list_fw_profile(&(wrqu->data.length),
9690 extra, WE_MAX_STR_LEN);
9691 break;
9692
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009693 /* The case prints the current state of the HDD, SME, CSR, PE,
9694 * TL it can be extended for WDI Global State as well. And
9695 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
9696 * and P2P_GO have not been added as of now.
9697 */
9698 case WE_GET_STATES:
9699 {
9700 int buf = 0, len = 0;
9701 int adapter_num = 0;
9702 int count = 0, check = 1;
9703
9704 tHalHandle hHal = NULL;
9705 tpAniSirGlobal pMac = NULL;
9706 hdd_station_ctx_t *pHddStaCtx = NULL;
9707
9708 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9709 hdd_adapter_t *useAdapter = NULL;
9710
9711 /* Print wlan0 or p2p0 states based on the adapter_num
9712 * by using the correct adapter
9713 */
9714 while (adapter_num < 2) {
9715 if (WLAN_ADAPTER == adapter_num) {
9716 useAdapter = pAdapter;
9717 buf =
9718 scnprintf(extra + len,
9719 WE_MAX_STR_LEN - len,
9720 "\n\n wlan0 States:-");
9721 len += buf;
9722 } else if (P2P_ADAPTER == adapter_num) {
9723 buf =
9724 scnprintf(extra + len,
9725 WE_MAX_STR_LEN - len,
9726 "\n\n p2p0 States:-");
9727 len += buf;
9728
9729 if (!pHddCtx) {
9730 buf =
9731 scnprintf(extra + len,
9732 WE_MAX_STR_LEN -
9733 len,
9734 "\n pHddCtx is NULL");
9735 len += buf;
9736 break;
9737 }
9738
9739 /* Printing p2p0 states only in the
9740 * case when the device is configured
9741 * as a p2p_client
9742 */
9743 useAdapter =
9744 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08009745 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009746 if (!useAdapter) {
9747 buf =
9748 scnprintf(extra + len,
9749 WE_MAX_STR_LEN -
9750 len,
9751 "\n Device not configured as P2P_CLIENT.");
9752 len += buf;
9753 break;
9754 }
9755 }
9756
9757 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
9758 if (!hHal) {
9759 buf =
9760 scnprintf(extra + len,
9761 WE_MAX_STR_LEN - len,
9762 "\n pMac is NULL");
9763 len += buf;
9764 break;
9765 }
9766 pMac = PMAC_STRUCT(hHal);
9767 if (!pMac) {
9768 buf =
9769 scnprintf(extra + len,
9770 WE_MAX_STR_LEN - len,
9771 "\n pMac is NULL");
9772 len += buf;
9773 break;
9774 }
9775 pHddStaCtx =
9776 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
9777
9778
9779 buf =
9780 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9781 "\n HDD Conn State - %s "
9782 "\n \n SME State:"
9783 "\n Neighbour Roam State - %s"
9784 "\n CSR State - %s"
9785 "\n CSR Substate - %s",
9786 hdd_connection_state_string
9787 (pHddStaCtx->conn_info.connState),
9788 mac_trace_get_neighbour_roam_state
9789 (sme_get_neighbor_roam_state
9790 (hHal, useAdapter->sessionId)),
9791 mac_trace_getcsr_roam_state
9792 (sme_get_current_roam_state
9793 (hHal, useAdapter->sessionId)),
9794 mac_trace_getcsr_roam_sub_state
9795 (sme_get_current_roam_sub_state
9796 (hHal, useAdapter->sessionId))
9797 );
9798 len += buf;
9799 adapter_num++;
9800 }
9801
Mukul Sharma81661ae2015-10-30 20:26:02 +05309802 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009803 /* Printing Lim State starting with global lim states */
9804 buf =
9805 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9806 "\n \n LIM STATES:-"
9807 "\n Global Sme State - %s "
9808 "\n Global mlm State - %s " "\n",
9809 mac_trace_get_lim_sme_state
9810 (sme_get_lim_sme_state(hHal)),
9811 mac_trace_get_lim_mlm_state
9812 (sme_get_lim_sme_state(hHal))
9813 );
9814 len += buf;
9815
9816 /* Printing the PE Sme and Mlm states for valid lim sessions */
9817 while (check < 3 && count < 255) {
9818 if (sme_is_lim_session_valid(hHal, count)) {
9819 buf =
9820 scnprintf(extra + len,
9821 WE_MAX_STR_LEN -
9822 len,
9823 "\n Lim Valid Session %d:-"
9824 "\n PE Sme State - %s "
9825 "\n PE Mlm State - %s "
9826 "\n", check,
9827 mac_trace_get_lim_sme_state
9828 (sme_get_lim_sme_session_state
9829 (hHal, count)),
9830 mac_trace_get_lim_mlm_state
9831 (sme_get_lim_mlm_session_state
9832 (hHal, count))
9833 );
9834
9835 len += buf;
9836 check++;
9837 }
9838 count++;
9839 }
9840 }
9841
9842 wrqu->data.length = strlen(extra) + 1;
9843 break;
9844 }
9845
9846 case WE_GET_CFG:
9847 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009848 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009849 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
9850 extra,
9851 QCSAP_IOCTL_MAX_STR_LEN);
9852 wrqu->data.length = strlen(extra) + 1;
9853 break;
9854 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009855 case WE_GET_RSSI:
9856 {
9857 int8_t s7Rssi = 0;
9858 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
9859 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
9860 wrqu->data.length = strlen(extra) + 1;
9861 break;
9862 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009863
9864 case WE_GET_WMM_STATUS:
9865 {
9866 snprintf(extra, WE_MAX_STR_LEN,
9867 "\nDir: 0=up, 1=down, 3=both\n"
9868 "|------------------------|\n"
9869 "|AC | ACM |Admitted| Dir |\n"
9870 "|------------------------|\n"
9871 "|VO | %d | %3s | %d |\n"
9872 "|VI | %d | %3s | %d |\n"
9873 "|BE | %d | %3s | %d |\n"
9874 "|BK | %d | %3s | %d |\n"
9875 "|------------------------|\n",
9876 pAdapter->hddWmmStatus.
9877 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
9878 pAdapter->hddWmmStatus.
9879 wmmAcStatus[SME_AC_VO].
9880 wmmAcAccessAllowed ? "YES" : "NO",
9881 pAdapter->hddWmmStatus.
9882 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
9883 ts_info.direction,
9884 pAdapter->hddWmmStatus.
9885 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
9886 pAdapter->hddWmmStatus.
9887 wmmAcStatus[SME_AC_VI].
9888 wmmAcAccessAllowed ? "YES" : "NO",
9889 pAdapter->hddWmmStatus.
9890 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
9891 ts_info.direction,
9892 pAdapter->hddWmmStatus.
9893 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
9894 pAdapter->hddWmmStatus.
9895 wmmAcStatus[SME_AC_BE].
9896 wmmAcAccessAllowed ? "YES" : "NO",
9897 pAdapter->hddWmmStatus.
9898 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
9899 ts_info.direction,
9900 pAdapter->hddWmmStatus.
9901 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
9902 pAdapter->hddWmmStatus.
9903 wmmAcStatus[SME_AC_BK].
9904 wmmAcAccessAllowed ? "YES" : "NO",
9905 pAdapter->hddWmmStatus.
9906 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
9907 ts_info.direction);
9908
9909 wrqu->data.length = strlen(extra) + 1;
9910 break;
9911 }
9912 case WE_GET_CHANNEL_LIST:
9913 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309914 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009915 uint8_t i, len;
9916 char *buf;
9917 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
9918 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
9919 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9920
9921 tChannelListInfo channel_list;
9922
9923 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05309924 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009925 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309926 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009927 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009928 return -EINVAL;
9929 }
9930 buf = extra;
9931 /*
9932 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
9933 * Maximum buffer needed = 5 * number of channels.
9934 * Check ifsufficient buffer is available and then
9935 * proceed to fill the buffer.
9936 */
9937 if (WE_MAX_STR_LEN <
9938 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009939 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009940 return -EINVAL;
9941 }
9942 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
9943 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309944 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009945 ubuf, &ubuf_len)) {
9946 /* Printing Country code in getChannelList */
9947 for (i = 0; i < (ubuf_len - 1); i++)
9948 len += scnprintf(buf + len,
9949 WE_MAX_STR_LEN - len,
9950 "%c", ubuf[i]);
9951 }
9952 for (i = 0; i < channel_list.num_channels; i++) {
9953 len +=
9954 scnprintf(buf + len, WE_MAX_STR_LEN - len,
9955 " %u", channel_list.channels[i]);
9956 }
9957 wrqu->data.length = strlen(extra) + 1;
9958
9959 break;
9960 }
9961#ifdef FEATURE_WLAN_TDLS
9962 case WE_GET_TDLS_PEERS:
9963 {
9964 wrqu->data.length =
9965 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
9966 WE_MAX_STR_LEN) + 1;
9967 break;
9968 }
9969#endif
9970#ifdef WLAN_FEATURE_11W
9971 case WE_GET_11W_INFO:
9972 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009973 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009974 pWextState->roamProfile.MFPEnabled);
9975
9976 snprintf(extra, WE_MAX_STR_LEN,
9977 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
9978 "\n Number of Unprotected Disassocs %d"
9979 "\n Number of Unprotected Deauths %d",
9980 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
9981 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
9982 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
9983 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
9984 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
9985 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
9986 pWextState->roamProfile.MFPEnabled,
9987 pAdapter->hdd_stats.hddPmfStats.
9988 numUnprotDisassocRx,
9989 pAdapter->hdd_stats.hddPmfStats.
9990 numUnprotDeauthRx);
9991
9992 wrqu->data.length = strlen(extra) + 1;
9993 break;
9994 }
9995#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009996 case WE_GET_IBSS_STA_INFO:
9997 {
9998 hdd_station_ctx_t *pHddStaCtx =
9999 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10000 int idx = 0;
10001 int length = 0, buf = 0;
10002
Naveen Rawatc45d1622016-07-05 12:20:09 -070010003 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010004 if (0 != pHddStaCtx->conn_info.staId[idx]) {
10005 buf = snprintf
10006 ((extra + length),
10007 WE_MAX_STR_LEN - length,
10008 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
10009 pHddStaCtx->conn_info.staId[idx],
10010 pHddStaCtx->conn_info.
10011 peerMacAddress[idx].bytes[0],
10012 pHddStaCtx->conn_info.
10013 peerMacAddress[idx].bytes[1],
10014 pHddStaCtx->conn_info.
10015 peerMacAddress[idx].bytes[2],
10016 pHddStaCtx->conn_info.
10017 peerMacAddress[idx].bytes[3],
10018 pHddStaCtx->conn_info.
10019 peerMacAddress[idx].bytes[4],
10020 pHddStaCtx->conn_info.
10021 peerMacAddress[idx].bytes[5]
10022 );
10023 length += buf;
10024 }
10025 }
10026 wrqu->data.length = strlen(extra) + 1;
10027 break;
10028 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010029 case WE_GET_PHYMODE:
10030 {
10031 bool ch_bond24 = false, ch_bond5g = false;
10032 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
10033 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10034 eCsrPhyMode phymode;
10035 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010036 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010037
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010038 sme_config = qdf_mem_malloc(sizeof(*sme_config));
10039 if (!sme_config) {
10040 hdd_err("Out of memory");
10041 ret = -ENOMEM;
10042 break;
10043 }
10044
10045 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010046 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010047 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010048 ch_bond24 = true;
10049
10050 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010051 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010052 ch_bond5g = true;
10053
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010054 qdf_mem_free(sme_config);
10055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010056 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010057 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010058 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010059 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010060 return -EIO;
10061 }
10062
10063 switch (phymode) {
10064 case eCSR_DOT11_MODE_AUTO:
10065 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
10066 break;
10067 case eCSR_DOT11_MODE_11n:
10068 case eCSR_DOT11_MODE_11n_ONLY:
10069 if (currBand == eCSR_BAND_24) {
10070 if (ch_bond24)
10071 snprintf(extra, WE_MAX_STR_LEN,
10072 "11NGHT40");
10073 else
10074 snprintf(extra, WE_MAX_STR_LEN,
10075 "11NGHT20");
10076 } else if (currBand == eCSR_BAND_5G) {
10077 if (ch_bond5g)
10078 snprintf(extra, WE_MAX_STR_LEN,
10079 "11NAHT40");
10080 else
10081 snprintf(extra, WE_MAX_STR_LEN,
10082 "11NAHT20");
10083 } else {
10084 snprintf(extra, WE_MAX_STR_LEN, "11N");
10085 }
10086 break;
10087 case eCSR_DOT11_MODE_abg:
10088 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
10089 break;
10090 case eCSR_DOT11_MODE_11a:
10091 snprintf(extra, WE_MAX_STR_LEN, "11A");
10092 break;
10093 case eCSR_DOT11_MODE_11b:
10094 case eCSR_DOT11_MODE_11b_ONLY:
10095 snprintf(extra, WE_MAX_STR_LEN, "11B");
10096 break;
10097 case eCSR_DOT11_MODE_11g:
10098 case eCSR_DOT11_MODE_11g_ONLY:
10099 snprintf(extra, WE_MAX_STR_LEN, "11G");
10100 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010101 case eCSR_DOT11_MODE_11ac:
10102 case eCSR_DOT11_MODE_11ac_ONLY:
10103 if (hddctx->config->vhtChannelWidth ==
10104 eHT_CHANNEL_WIDTH_20MHZ)
10105 snprintf(extra, WE_MAX_STR_LEN,
10106 "11ACVHT20");
10107 else if (hddctx->config->vhtChannelWidth ==
10108 eHT_CHANNEL_WIDTH_40MHZ)
10109 snprintf(extra, WE_MAX_STR_LEN,
10110 "11ACVHT40");
10111 else if (hddctx->config->vhtChannelWidth ==
10112 eHT_CHANNEL_WIDTH_80MHZ)
10113 snprintf(extra, WE_MAX_STR_LEN,
10114 "11ACVHT80");
10115 else if (hddctx->config->vhtChannelWidth ==
10116 eHT_CHANNEL_WIDTH_160MHZ)
10117 snprintf(extra, WE_MAX_STR_LEN,
10118 "11ACVHT160");
10119 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080010120 case eCSR_DOT11_MODE_11ax:
10121 case eCSR_DOT11_MODE_11ax_ONLY:
10122 /* currently using vhtChannelWidth */
10123 if (hddctx->config->vhtChannelWidth ==
10124 eHT_CHANNEL_WIDTH_20MHZ)
10125 snprintf(extra, WE_MAX_STR_LEN,
10126 "11AX_HE_20");
10127 else if (hddctx->config->vhtChannelWidth ==
10128 eHT_CHANNEL_WIDTH_40MHZ)
10129 snprintf(extra, WE_MAX_STR_LEN,
10130 "11AX_HE_40");
10131 else if (hddctx->config->vhtChannelWidth ==
10132 eHT_CHANNEL_WIDTH_80MHZ)
10133 snprintf(extra, WE_MAX_STR_LEN,
10134 "11AX_HE_80");
10135 else if (hddctx->config->vhtChannelWidth ==
10136 eHT_CHANNEL_WIDTH_160MHZ)
10137 snprintf(extra, WE_MAX_STR_LEN,
10138 "11AX_HE_160");
10139 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010140 }
10141
10142 wrqu->data.length = strlen(extra) + 1;
10143 break;
10144 }
10145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010146 case WE_GET_OEM_DATA_CAP:
Naveen Rawat910726a2017-03-06 11:42:51 -080010147 return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010148 case WE_GET_SNR:
10149 {
10150 int8_t s7snr = 0;
10151 int status = 0;
10152 hdd_context_t *pHddCtx;
10153 hdd_station_ctx_t *pHddStaCtx;
10154 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10155 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010156 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010157 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010159 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10160 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
10161 eConnectionState_Associated !=
10162 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010163 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010164 pHddCtx->config->fEnableSNRMonitoring,
10165 pHddStaCtx->conn_info.connState);
10166 return -ENONET;
10167 }
10168 wlan_hdd_get_snr(pAdapter, &s7snr);
10169 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
10170 wrqu->data.length = strlen(extra) + 1;
10171 break;
10172 }
10173 default:
10174 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010175 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010176 sub_cmd);
10177 break;
10178 }
10179 }
Dustin Brownd9322482017-01-09 12:46:03 -080010180
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010181 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -080010182 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010183}
10184
10185static int iw_get_char_setnone(struct net_device *dev,
10186 struct iw_request_info *info,
10187 union iwreq_data *wrqu, char *extra)
10188{
10189 int ret;
10190
10191 cds_ssr_protect(__func__);
10192 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
10193 cds_ssr_unprotect(__func__);
10194
10195 return ret;
10196}
10197
10198/**
10199 * iw_setnone_getnone() - Generic "action" private ioctl handler
10200 * @dev: device upon which the ioctl was received
10201 * @info: ioctl request information
10202 * @wrqu: ioctl request data
10203 * @extra: ioctl extra data
10204 *
10205 * Return: 0 on success, non-zero on error
10206 */
10207static int __iw_setnone_getnone(struct net_device *dev,
10208 struct iw_request_info *info,
10209 union iwreq_data *wrqu, char *extra)
10210{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010211 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010212 hdd_context_t *hdd_ctx;
10213 int ret;
10214 int sub_cmd;
10215
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010216 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010217
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010218 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010219 ret = wlan_hdd_validate_context(hdd_ctx);
10220 if (0 != ret)
10221 return ret;
10222
Jeff Johnson441e1f72017-02-07 08:50:49 -080010223 ret = hdd_check_private_wext_control(hdd_ctx, info);
10224 if (0 != ret)
10225 return ret;
10226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010227#ifdef CONFIG_COMPAT
10228 /* this ioctl is a special case where a sub-ioctl is used and both
10229 * the number of get and set args is 0. in this specific case the
10230 * logic in iwpriv places the sub_cmd in the data.flags portion of
10231 * the iwreq. unfortunately the location of this field will be
10232 * different between 32-bit and 64-bit userspace, and the standard
10233 * compat support in the kernel does not handle this case. so we
10234 * need to explicitly handle it here.
10235 */
10236 if (is_compat_task()) {
10237 struct compat_iw_point *compat_iw_point =
10238 (struct compat_iw_point *)&wrqu->data;
10239 sub_cmd = compat_iw_point->flags;
10240 } else {
10241 sub_cmd = wrqu->data.flags;
10242 }
10243#else
10244 sub_cmd = wrqu->data.flags;
10245#endif
10246
10247 switch (sub_cmd) {
10248 case WE_GET_RECOVERY_STAT:
10249 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010250 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010251 sme_get_recovery_stats(hal);
10252 break;
10253 }
10254
Govind Singha471e5e2015-10-12 17:11:14 +053010255 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010256 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +053010257 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
10258 0, DBG_CMD);
10259 break;
10260
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010261 case WE_IBSS_GET_PEER_INFO_ALL:
10262 {
10263 hdd_wlan_get_ibss_peer_info_all(adapter);
10264 break;
10265 }
10266
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010267 case WE_SET_REASSOC_TRIGGER:
10268 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010269 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
10270 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010271 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010272 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010273 uint8_t operating_ch =
10274 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010275 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010276
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010277 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010278 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010279 if (roaming_offload_enabled(hdd_ctx)) {
10280 qdf_mem_copy(bssid,
10281 &adapter->sessionCtx.station.conn_info.bssId,
10282 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -080010283 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010284 bssid, operating_ch);
10285 } else {
10286 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
10287 NULL, modProfileFields, &roamId, 1);
10288 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010289 return 0;
10290 }
10291
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010292 case WE_STOP_OBSS_SCAN:
10293 {
10294 /*
10295 * 1.OBSS Scan is mandatory while operating in 2.4GHz
10296 * 2.OBSS scan is stopped by Firmware during the disassociation
10297 * 3.OBSS stop comamnd is added for debugging purpose
10298 */
10299 tHalHandle hal;
10300
10301 hal = WLAN_HDD_GET_HAL_CTX(adapter);
10302 if (hal == NULL) {
10303 hdd_err("hal context is NULL");
10304 return -EINVAL;
10305 }
10306 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
10307 }
10308 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010309 default:
10310 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010311 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010312 break;
10313 }
10314 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010315 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010316 return ret;
10317}
10318
10319static int iw_setnone_getnone(struct net_device *dev,
10320 struct iw_request_info *info,
10321 union iwreq_data *wrqu, char *extra)
10322{
10323 int ret;
10324
10325 cds_ssr_protect(__func__);
10326 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
10327 cds_ssr_unprotect(__func__);
10328
10329 return ret;
10330}
10331
Krunal Sonia6e505b2017-01-12 12:25:18 -080010332#ifdef MPC_UT_FRAMEWORK
10333static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10334 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10335{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -080010336 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010337 case WE_POLICY_MANAGER_CLIST_CMD:
10338 {
10339 hdd_err("<iwpriv wlan0 pm_clist> is called");
10340 cds_incr_connection_count_utfw(apps_args[0],
10341 apps_args[1], apps_args[2], apps_args[3],
10342 apps_args[4], apps_args[5], apps_args[6],
10343 apps_args[7]);
10344 }
10345 break;
10346
10347 case WE_POLICY_MANAGER_DLIST_CMD:
10348 {
10349 hdd_err("<iwpriv wlan0 pm_dlist> is called");
10350 cds_decr_connection_count_utfw(apps_args[0],
10351 apps_args[1]);
10352 }
10353 break;
10354
10355 case WE_POLICY_MANAGER_ULIST_CMD:
10356 {
10357 hdd_err("<iwpriv wlan0 pm_ulist> is called");
10358 cds_update_connection_info_utfw(apps_args[0],
10359 apps_args[1], apps_args[2], apps_args[3],
10360 apps_args[4], apps_args[5], apps_args[6],
10361 apps_args[7]);
10362 }
10363 break;
10364
10365 case WE_POLICY_MANAGER_DBS_CMD:
10366 {
10367 hdd_err("<iwpriv wlan0 pm_dbs> is called");
10368 if (apps_args[0] == 0)
10369 wma_set_dbs_capability_ut(0);
10370 else
10371 wma_set_dbs_capability_ut(1);
10372
10373 if (apps_args[1] >= CDS_THROUGHPUT &&
10374 apps_args[1] <= CDS_LATENCY) {
10375 pr_info("setting system pref to [%d]\n", apps_args[1]);
10376 hdd_ctx->config->conc_system_pref = apps_args[1];
10377 }
10378 }
10379 break;
10380
10381 case WE_POLICY_MANAGER_PCL_CMD:
10382 {
10383 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
10384 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
10385 uint32_t pcl_len = 0, i = 0;
10386
10387 hdd_err("<iwpriv wlan0 pm_pcl> is called");
10388
10389 cds_get_pcl(apps_args[0],
10390 pcl, &pcl_len,
10391 weight_list, QDF_ARRAY_SIZE(weight_list));
10392 pr_info("PCL list for role[%d] is {", apps_args[0]);
10393 for (i = 0 ; i < pcl_len; i++)
10394 pr_info(" %d, ", pcl[i]);
10395 pr_info("}--------->\n");
10396 }
10397 break;
10398
10399 case WE_POLICY_SET_HW_MODE_CMD:
10400 {
10401 if (apps_args[0] == 0) {
10402 hdd_err("set hw mode for single mac");
10403 cds_pdev_set_hw_mode(
10404 adapter->sessionId,
10405 HW_MODE_SS_2x2,
10406 HW_MODE_80_MHZ,
10407 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
10408 HW_MODE_DBS_NONE,
10409 HW_MODE_AGILE_DFS_NONE,
10410 HW_MODE_SBS_NONE,
10411 SIR_UPDATE_REASON_UT);
10412 } else if (apps_args[0] == 1) {
10413 hdd_err("set hw mode for dual mac");
10414 cds_pdev_set_hw_mode(
10415 adapter->sessionId,
10416 HW_MODE_SS_1x1,
10417 HW_MODE_80_MHZ,
10418 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
10419 HW_MODE_DBS,
10420 HW_MODE_AGILE_DFS_NONE,
10421 HW_MODE_SBS_NONE,
10422 SIR_UPDATE_REASON_UT);
10423 }
10424 }
10425 break;
10426
10427 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10428 {
10429 enum cds_conc_next_action action;
10430 hdd_notice("<iwpriv wlan0 pm_query_action> is called");
10431 action = cds_current_connections_update(adapter->sessionId,
10432 apps_args[0],
10433 SIR_UPDATE_REASON_UT);
10434 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
10435 }
10436 break;
10437
10438 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10439 {
10440 bool allow;
10441 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
10442 allow = cds_allow_concurrency(
10443 apps_args[0], apps_args[1], apps_args[2]);
10444 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
10445 }
10446 break;
10447
10448 case WE_POLICY_MANAGER_SCENARIO_CMD:
10449 {
10450 clean_report(hdd_ctx);
10451 if (apps_args[0] == 1) {
10452 wlan_hdd_one_connection_scenario(hdd_ctx);
10453 } else if (apps_args[0] == 2) {
10454 wlan_hdd_two_connections_scenario(hdd_ctx,
10455 6, CDS_TWO_TWO);
10456 wlan_hdd_two_connections_scenario(hdd_ctx,
10457 36, CDS_TWO_TWO);
10458 wlan_hdd_two_connections_scenario(hdd_ctx,
10459 6, CDS_ONE_ONE);
10460 wlan_hdd_two_connections_scenario(hdd_ctx,
10461 36, CDS_ONE_ONE);
10462 } else if (apps_args[0] == 3) {
10463 /* MCC on same band with 2x2 same mac*/
10464 wlan_hdd_three_connections_scenario(hdd_ctx,
10465 6, 11, CDS_TWO_TWO, 0);
10466 /* MCC on diff band with 2x2 same mac*/
10467 wlan_hdd_three_connections_scenario(hdd_ctx,
10468 6, 36, CDS_TWO_TWO, 0);
10469 /* MCC on diff band with 1x1 diff mac */
10470 wlan_hdd_three_connections_scenario(hdd_ctx,
10471 36, 6, CDS_ONE_ONE, 0);
10472 /* MCC on diff band with 1x1 same mac */
10473 wlan_hdd_three_connections_scenario(hdd_ctx,
10474 36, 6, CDS_ONE_ONE, 1);
10475 /* SCC on same band with 2x2 same mac */
10476 wlan_hdd_three_connections_scenario(hdd_ctx,
10477 36, 36, CDS_TWO_TWO, 0);
10478 /* SCC on same band with 1x1 same mac */
10479 wlan_hdd_three_connections_scenario(hdd_ctx,
10480 36, 36, CDS_ONE_ONE, 1);
10481 /* MCC on same band with 2x2 same mac */
10482 wlan_hdd_three_connections_scenario(hdd_ctx,
10483 36, 149, CDS_TWO_TWO, 0);
10484 /* MCC on same band with 1x1 same mac */
10485 wlan_hdd_three_connections_scenario(hdd_ctx,
10486 36, 149, CDS_ONE_ONE, 1);
10487 }
10488 print_report(hdd_ctx);
10489 }
10490 break;
10491 }
10492 return 0;
10493}
10494#else
10495static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10496 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10497{
10498 return 0;
10499}
10500#endif
10501
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010502/**
10503 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10504 * @dev: device upon which the ioctl was received
10505 * @info: ioctl request information
10506 * @wrqu: ioctl request data
10507 * @extra: ioctl extra data
10508 *
10509 * This is an SSR-protected generic handler for private ioctls which
10510 * take multiple arguments. Note that this implementation is also
10511 * somewhat unique in that it is shared by both STA-mode and SAP-mode
10512 * interfaces.
10513 *
10514 * Return: 0 on success, non-zero on error
10515 */
10516static int __iw_set_var_ints_getnone(struct net_device *dev,
10517 struct iw_request_info *info,
10518 union iwreq_data *wrqu, char *extra)
10519{
10520 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10521 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10522 int sub_cmd;
10523 int *apps_args = (int *) extra;
10524 hdd_context_t *hdd_ctx;
10525 int ret, num_args;
10526
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010527 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010529 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10530 ret = wlan_hdd_validate_context(hdd_ctx);
10531 if (0 != ret)
10532 return ret;
10533
Jeff Johnson441e1f72017-02-07 08:50:49 -080010534 ret = hdd_check_private_wext_control(hdd_ctx, info);
10535 if (0 != ret)
10536 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010537
10538 sub_cmd = wrqu->data.flags;
10539 num_args = wrqu->data.length;
10540
Jeff Johnson99bac312016-06-28 10:38:18 -070010541 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010542
10543 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010544 case WE_IBSS_GET_PEER_INFO:
10545 {
10546 pr_info("Station ID = %d\n", apps_args[0]);
10547 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
10548 }
10549 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010550
10551 case WE_P2P_NOA_CMD:
10552 {
10553 p2p_app_setP2pPs_t p2pNoA;
10554
Krunal Sonif07bb382016-03-10 13:02:11 -080010555 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -080010556 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
10557 hdd_device_mode_to_string(
10558 pAdapter->device_mode),
10559 pAdapter->device_mode);
10560 return -EINVAL;
10561 }
10562
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010563 p2pNoA.opp_ps = apps_args[0];
10564 p2pNoA.ctWindow = apps_args[1];
10565 p2pNoA.duration = apps_args[2];
10566 p2pNoA.interval = apps_args[3];
10567 p2pNoA.count = apps_args[4];
10568 p2pNoA.single_noa_duration = apps_args[5];
10569 p2pNoA.psSelection = apps_args[6];
10570
Jeff Johnson99bac312016-06-28 10:38:18 -070010571 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
10572 apps_args[0], apps_args[1], apps_args[2],
10573 apps_args[3], apps_args[4],
10574 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010575
10576 hdd_set_p2p_ps(dev, &p2pNoA);
10577
10578 }
10579 break;
10580
10581 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
10582 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010583 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
10584 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010585 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010586 }
10587 break;
10588
10589 case WE_MTRACE_DUMP_CMD:
10590 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010591 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
10592 apps_args[0], apps_args[1],
10593 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010594 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010595 apps_args[1], apps_args[2],
10596 apps_args[3]);
10597
10598 }
10599 break;
10600
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010601 case WE_POLICY_MANAGER_CINFO_CMD:
10602 {
10603 struct cds_conc_connection_info *conn_info;
10604 uint32_t i = 0, len = 0;
10605
Krunal Sonia6e505b2017-01-12 12:25:18 -080010606 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -080010607 conn_info = cds_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010608 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010609 for (i = 0; i < len; i++) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010610 pr_info("|table_index[%d]\t\t\n", i);
10611 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
10612 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
10613 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
10614 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
10615 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
10616 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
10617 pr_info("+--------------------------+\n");
10618 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010619 }
10620 }
10621 break;
10622
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010623
10624#ifdef FEATURE_WLAN_TDLS
10625 case WE_TDLS_CONFIG_PARAMS:
10626 {
10627 tdls_config_params_t tdlsParams;
10628
10629 tdlsParams.tdls = apps_args[0];
10630 tdlsParams.tx_period_t = apps_args[1];
10631 tdlsParams.tx_packet_n = apps_args[2];
10632 /* ignore args[3] as discovery_period is not used anymore */
10633 tdlsParams.discovery_tries_n = apps_args[4];
10634 /* ignore args[5] as idle_timeout is not used anymore */
10635 tdlsParams.idle_packet_n = apps_args[6];
10636 /* ignore args[7] as rssi_hysteresis is not used anymore */
10637 tdlsParams.rssi_trigger_threshold = apps_args[8];
10638 tdlsParams.rssi_teardown_threshold = apps_args[9];
10639 tdlsParams.rssi_delta = apps_args[10];
10640
10641 wlan_hdd_tdls_set_params(dev, &tdlsParams);
10642 }
10643 break;
10644#endif
10645 case WE_UNIT_TEST_CMD:
10646 {
10647 t_wma_unit_test_cmd *unitTestArgs;
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010648 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010649 int i, j;
10650 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
10651 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010652 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010653 apps_args[0]);
10654 return -EINVAL;
10655 }
Anurag Chouhan77564182016-09-03 16:38:01 +053010656 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
10657 (apps_args[1] < 0)) {
10658 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010659 apps_args[1]);
10660 return -EINVAL;
10661 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010662 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010663 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010664 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010665 return -ENOMEM;
10666 }
10667 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
10668 unitTestArgs->module_id = apps_args[0];
10669 unitTestArgs->num_args = apps_args[1];
10670 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
10671 unitTestArgs->args[i] = apps_args[j];
10672 }
10673 msg.type = SIR_HAL_UNIT_TEST_CMD;
10674 msg.reserved = 0;
10675 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010676 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010677 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010678 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -070010679 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010680 return -EINVAL;
10681 }
10682 }
10683 break;
10684#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
10685 case WE_LED_FLASHING_PARAM:
10686 {
10687 int i;
10688 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010689 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010690 return -EINVAL;
10691 }
10692 for (i = 0; i < num_args; i++) {
10693 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010694 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010695 return -EINVAL;
10696 }
10697 }
10698 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10699 0, apps_args[0], apps_args[1]);
10700 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10701 1, apps_args[2], apps_args[3]);
10702 }
10703 break;
10704#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010705 case WE_SET_PKTLOG:
10706 {
10707 int ret;
10708
10709 if (num_args < 1 || num_args > 2) {
10710 hdd_err("pktlog: either 1 or 2 parameters are required");
10711 return -EINVAL;
10712 }
10713
10714 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
10715 apps_args[1]);
10716 if (ret)
10717 return ret;
10718 break;
10719 }
10720
Manjeet Singhf82ed072016-07-08 11:40:00 +053010721 case WE_MAC_PWR_DEBUG_CMD:
10722 {
10723 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
10724 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10725 int i, j;
10726
10727 if (num_args < 3) {
10728 hdd_err("number of arguments can't be null %d",
10729 num_args);
10730 return -EINVAL;
10731 }
10732 if (num_args - 3 != apps_args[2]) {
10733 hdd_err("arg list of size %d doesn't match num_args %d",
10734 num_args-3, apps_args[2]);
10735 return -EINVAL;
10736 }
10737 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
10738 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
10739 hdd_err("Invalid MODULE ID %d", apps_args[1]);
10740 return -EINVAL;
10741 }
10742 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
10743 hdd_err("Too Many args %d", apps_args[2]);
10744 return -EINVAL;
10745 }
10746 mac_pwr_dbg_args.pdev_id = apps_args[0];
10747 mac_pwr_dbg_args.module_id = apps_args[1];
10748 mac_pwr_dbg_args.num_args = apps_args[2];
10749
10750 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
10751 mac_pwr_dbg_args.args[i] = apps_args[j];
10752
10753 if (QDF_STATUS_SUCCESS !=
10754 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
10755 &mac_pwr_dbg_args)) {
10756 return -EINVAL;
10757 }
10758 }
10759 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -080010760 case WE_POLICY_MANAGER_CLIST_CMD:
10761 case WE_POLICY_MANAGER_DLIST_CMD:
10762 case WE_POLICY_MANAGER_ULIST_CMD:
10763 case WE_POLICY_MANAGER_DBS_CMD:
10764 case WE_POLICY_MANAGER_PCL_CMD:
10765 case WE_POLICY_SET_HW_MODE_CMD:
10766 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10767 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10768 case WE_POLICY_MANAGER_SCENARIO_CMD:
10769 {
10770 iw_get_policy_manager_ut_ops(hdd_ctx, pAdapter,
10771 sub_cmd, apps_args);
10772 }
10773 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010774 default:
10775 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010776 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010777 }
10778 break;
10779 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010780 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010781 return 0;
10782}
10783
10784/**
10785 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
10786 * @dev: pointer to net_device structure
10787 * @info: pointer to iw_request_info structure
10788 * @wrqu: pointer to iwreq_data
10789 * @extra; extra
10790 *
10791 * Return: 0 on success, error number otherwise
10792 *
10793 */
10794static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
10795 struct iw_request_info *info,
10796 union iwreq_data *wrqu, char *extra)
10797{
10798 union iwreq_data u_priv_wrqu;
10799 int apps_args[MAX_VAR_ARGS] = {0};
10800 int ret, num_args;
10801
Mukul Sharma64a70e82015-11-02 20:05:09 +053010802 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010803 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +053010804 return -EPERM;
10805 }
10806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010807 /* Helper function to get iwreq_data with compat handling. */
10808 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
10809 return -EINVAL;
10810
10811 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010812 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010813 return -EINVAL;
10814 }
10815
10816 num_args = u_priv_wrqu.data.length;
10817 if (num_args > MAX_VAR_ARGS)
10818 num_args = MAX_VAR_ARGS;
10819
10820 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
10821 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010822 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010823 return -EFAULT;
10824 }
10825
10826 cds_ssr_protect(__func__);
10827 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
10828 (char *)&apps_args);
10829 cds_ssr_unprotect(__func__);
10830 return ret;
10831}
10832
10833/**
10834 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10835 * @dev: device upon which the ioctl was received
10836 * @info: ioctl request information
10837 * @wrqu: ioctl request data
10838 * @extra: ioctl extra data
10839 *
10840 * This is a generic handler for private ioctls which take multiple
10841 * arguments. Note that this implementation is also somewhat unique
10842 * in that it is shared by both STA-mode and SAP-mode interfaces.
10843 *
10844 * Return: 0 on success, non-zero on error
10845 */
10846int iw_set_var_ints_getnone(struct net_device *dev,
10847 struct iw_request_info *info,
10848 union iwreq_data *wrqu, char *extra)
10849{
10850 int ret;
10851
10852 cds_ssr_protect(__func__);
10853 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
10854 cds_ssr_unprotect(__func__);
10855 return ret;
10856}
10857
10858/**
10859 * iw_add_tspec - Add TSpec private ioctl handler
10860 * @dev: device upon which the ioctl was received
10861 * @info: ioctl request information
10862 * @wrqu: ioctl request data
10863 * @extra: ioctl extra data
10864 *
10865 * Return: 0 on success, non-zero on error
10866 */
10867static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
10868 union iwreq_data *wrqu, char *extra)
10869{
10870 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10871 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10872 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
10873 int params[HDD_WLAN_WMM_PARAM_COUNT];
10874 sme_QosWmmTspecInfo tSpec;
10875 uint32_t handle;
10876 struct iw_point s_priv_data;
10877 hdd_context_t *hdd_ctx;
10878 int ret;
10879
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010880 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010882 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10883 ret = wlan_hdd_validate_context(hdd_ctx);
10884 if (0 != ret)
10885 return ret;
10886
Jeff Johnson441e1f72017-02-07 08:50:49 -080010887 ret = hdd_check_private_wext_control(hdd_ctx, info);
10888 if (0 != ret)
10889 return ret;
10890
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010891 /* make sure the application is sufficiently priviledged */
10892 /* note that the kernel will do this for "set" ioctls, but since */
10893 /* this ioctl wants to return status to user space it must be */
10894 /* defined as a "get" ioctl */
10895 if (!capable(CAP_NET_ADMIN)) {
10896 return -EPERM;
10897 }
10898
10899 /* we must be associated in order to add a tspec */
10900 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
10901 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10902 return 0;
10903 }
10904 /* since we are defined to be a "get" ioctl, and since the number */
10905 /* of params exceeds the number of params that wireless extensions */
10906 /* will pass down in the iwreq_data, we must copy the "set" params. */
10907 /* We must handle the compat for iwreq_data in 32U/64K environment. */
10908
10909 /* helper function to get iwreq_data with compat handling. */
10910 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
10911 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10912 return 0;
10913 }
10914 /* make sure all params are correctly passed to function */
10915 if ((NULL == s_priv_data.pointer) ||
10916 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
10917 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10918 return 0;
10919 }
10920 /* from user space ourselves */
10921 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
10922 /* hmmm, can't get them */
10923 return -EIO;
10924 }
10925 /* clear the tspec */
10926 memset(&tSpec, 0, sizeof(tSpec));
10927
10928 /* validate the handle */
10929 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
10930 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
10931 /* that one is reserved */
10932 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10933 return 0;
10934 }
10935 /* validate the TID */
10936 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
10937 /* out of range */
10938 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10939 return 0;
10940 }
10941 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
10942
10943 /* validate the direction */
10944 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
10945 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
10946 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
10947 break;
10948
10949 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
10950 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
10951 break;
10952
10953 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
10954 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
10955 break;
10956
10957 default:
10958 /* unknown */
10959 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10960 return 0;
10961 }
10962
10963 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
10964
10965 /* validate the user priority */
10966 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
10967 /* out of range */
10968 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10969 return 0;
10970 }
10971 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
10972 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010973 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010974 return 0;
10975 }
10976
Jeff Johnson99bac312016-06-28 10:38:18 -070010977 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010978 tSpec.ts_info.psb, tSpec.ts_info.up);
10979
10980 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
10981 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
10982 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
10983 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
10984 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
10985 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
10986 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
10987 tSpec.surplus_bw_allowance =
10988 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
10989 tSpec.min_service_interval =
10990 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
10991 tSpec.max_service_interval =
10992 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
10993 tSpec.suspension_interval =
10994 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
10995 tSpec.inactivity_interval =
10996 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
10997
10998 tSpec.ts_info.burst_size_defn =
10999 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
11000
11001 /* validate the ts info ack policy */
11002 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
11003 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
11004 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
11005 break;
11006
11007 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
11008 tSpec.ts_info.ack_policy =
11009 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
11010 break;
11011
11012 default:
11013 /* unknown */
11014 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11015 return 0;
11016 }
11017
11018 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011019 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011020 return 0;
11021}
11022
11023static int iw_add_tspec(struct net_device *dev,
11024 struct iw_request_info *info,
11025 union iwreq_data *wrqu, char *extra)
11026{
11027 int ret;
11028
11029 cds_ssr_protect(__func__);
11030 ret = __iw_add_tspec(dev, info, wrqu, extra);
11031 cds_ssr_unprotect(__func__);
11032
11033 return ret;
11034}
11035
11036/**
11037 * iw_del_tspec - Delete TSpec private ioctl handler
11038 * @dev: device upon which the ioctl was received
11039 * @info: ioctl request information
11040 * @wrqu: ioctl request data
11041 * @extra: ioctl extra data
11042 *
11043 * Return: 0 on success, non-zero on error
11044 */
11045static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
11046 union iwreq_data *wrqu, char *extra)
11047{
11048 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11049 hdd_context_t *hdd_ctx;
11050 int *params = (int *)extra;
11051 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11052 uint32_t handle;
11053 int ret;
11054
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011055 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011056
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011057 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11058 ret = wlan_hdd_validate_context(hdd_ctx);
11059 if (0 != ret)
11060 return ret;
11061
Jeff Johnson441e1f72017-02-07 08:50:49 -080011062 ret = hdd_check_private_wext_control(hdd_ctx, info);
11063 if (0 != ret)
11064 return ret;
11065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011066 /* make sure the application is sufficiently priviledged */
11067 /* note that the kernel will do this for "set" ioctls, but since */
11068 /* this ioctl wants to return status to user space it must be */
11069 /* defined as a "get" ioctl */
11070 if (!capable(CAP_NET_ADMIN)) {
11071 return -EPERM;
11072 }
11073
11074 /* although we are defined to be a "get" ioctl, the params we require */
11075 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11076 /* is no need to copy the params from user space */
11077
11078 /* validate the handle */
11079 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11080 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11081 /* that one is reserved */
11082 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11083 return 0;
11084 }
11085
11086 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011087 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011088 return 0;
11089}
11090
11091static int iw_del_tspec(struct net_device *dev,
11092 struct iw_request_info *info,
11093 union iwreq_data *wrqu, char *extra)
11094{
11095 int ret;
11096
11097 cds_ssr_protect(__func__);
11098 ret = __iw_del_tspec(dev, info, wrqu, extra);
11099 cds_ssr_unprotect(__func__);
11100
11101 return ret;
11102}
11103
11104/**
11105 * iw_get_tspec - Get TSpec private ioctl handler
11106 * @dev: device upon which the ioctl was received
11107 * @info: ioctl request information
11108 * @wrqu: ioctl request data
11109 * @extra: ioctl extra data
11110 *
11111 * Return: 0 on success, non-zero on error
11112 */
11113static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
11114 union iwreq_data *wrqu, char *extra)
11115{
11116 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11117 hdd_context_t *hdd_ctx;
11118 int *params = (int *)extra;
11119 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11120 uint32_t handle;
11121 int ret;
11122
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011123 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011125 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11126 ret = wlan_hdd_validate_context(hdd_ctx);
11127 if (0 != ret)
11128 return ret;
11129
Jeff Johnson441e1f72017-02-07 08:50:49 -080011130 ret = hdd_check_private_wext_control(hdd_ctx, info);
11131 if (0 != ret)
11132 return ret;
11133
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011134 /* although we are defined to be a "get" ioctl, the params we require */
11135 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11136 /* is no need to copy the params from user space */
11137
11138 /* validate the handle */
11139 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11140 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11141 /* that one is reserved */
11142 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11143 return 0;
11144 }
11145
11146 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011147 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011148 return 0;
11149}
11150
11151static int iw_get_tspec(struct net_device *dev,
11152 struct iw_request_info *info,
11153 union iwreq_data *wrqu, char *extra)
11154{
11155 int ret;
11156
11157 cds_ssr_protect(__func__);
11158 ret = __iw_get_tspec(dev, info, wrqu, extra);
11159 cds_ssr_unprotect(__func__);
11160
11161 return ret;
11162}
11163
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011164/**
11165 * iw_set_fties - Set FT IEs private ioctl handler
11166 * @dev: device upon which the ioctl was received
11167 * @info: ioctl request information
11168 * @wrqu: ioctl request data
11169 * @extra: ioctl extra data
11170 *
11171 * Each time the supplicant has the auth_request or reassoc request
11172 * IEs ready they are pushed to the driver. The driver will in turn
11173 * use it to send out the auth req and reassoc req for 11r FT Assoc.
11174 *
11175 * Return: 0 on success, non-zero on error
11176 */
11177static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
11178 union iwreq_data *wrqu, char *extra)
11179{
11180 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11181 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11182 hdd_context_t *hdd_ctx;
11183 int ret;
11184
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011185 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011187 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11188 ret = wlan_hdd_validate_context(hdd_ctx);
11189 if (0 != ret)
11190 return ret;
11191
Jeff Johnson441e1f72017-02-07 08:50:49 -080011192 ret = hdd_check_private_wext_control(hdd_ctx, info);
11193 if (0 != ret)
11194 return ret;
11195
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011196 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011197 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011198 return -EINVAL;
11199 }
11200 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011201 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011202 return -EINVAL;
11203 }
11204 /* Added for debug on reception of Re-assoc Req. */
11205 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011206 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011207 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -070011208 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011209 }
Jeff Johnson99bac312016-06-28 10:38:18 -070011210 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011211
11212 /* Pass the received FT IEs to SME */
11213 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
11214 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011215 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011216 return 0;
11217}
11218
11219static int iw_set_fties(struct net_device *dev,
11220 struct iw_request_info *info,
11221 union iwreq_data *wrqu, char *extra)
11222{
11223 int ret;
11224
11225 cds_ssr_protect(__func__);
11226 ret = __iw_set_fties(dev, info, wrqu, extra);
11227 cds_ssr_unprotect(__func__);
11228
11229 return ret;
11230}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011231
Dustin Brown0cbc7572016-12-16 13:54:40 -080011232/**
11233 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
11234 * @dev: device upon which the ioctl was received
11235 * @info: ioctl request information
11236 * @wrqu: ioctl request data
11237 * @extra: ioctl extra data
11238 *
Dustin Brown860566f2017-01-31 15:24:43 -080011239 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
11240 * time being to provide guidance in migrating to standard APIs.
11241 *
Dustin Brown0cbc7572016-12-16 13:54:40 -080011242 * Return: 0 on success, non-zero on error
11243 */
11244static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
11245 struct iw_request_info *info,
11246 union iwreq_data *wrqu,
11247 char *extra)
11248{
Dustin Brown860566f2017-01-31 15:24:43 -080011249 hdd_err("\n"
11250 "setMCBCFilter is obsolete. Use the following instead:\n"
11251 "Configure multicast filtering via the ‘ip’ command.\n"
11252 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
11253 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
11254 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
11255 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
11256 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Mukul Sharma3ba26b82017-01-12 21:59:41 +053011257 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -080011258}
11259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011260/**
11261 * iw_set_host_offload - Set host offload ioctl handler
11262 * @dev: device upon which the ioctl was received
11263 * @info: ioctl request information
11264 * @wrqu: ioctl request data
11265 * @extra: ioctl extra data
11266 *
11267 * Return: 0 on success, non-zero on error
11268 */
11269static int __iw_set_host_offload(struct net_device *dev,
11270 struct iw_request_info *info,
11271 union iwreq_data *wrqu, char *extra)
11272{
11273 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11274 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
11275 tSirHostOffloadReq offloadRequest;
11276 hdd_context_t *hdd_ctx;
11277 int ret;
11278
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011279 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011280
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011281 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11282 ret = wlan_hdd_validate_context(hdd_ctx);
11283 if (0 != ret)
11284 return ret;
11285
Jeff Johnson441e1f72017-02-07 08:50:49 -080011286 ret = hdd_check_private_wext_control(hdd_ctx, info);
11287 if (0 != ret)
11288 return ret;
11289
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011290 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011291 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011292 return -EINVAL;
11293 }
11294
11295 /* Debug display of request components. */
11296 switch (pRequest->offloadType) {
11297 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -070011298 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011299 switch (pRequest->enableOrDisable) {
11300 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070011301 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011302 break;
11303 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070011304 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011305 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070011306 hdd_warn(" ARP offload enable");
11307 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011308 pRequest->params.hostIpv4Addr[0],
11309 pRequest->params.hostIpv4Addr[1],
11310 pRequest->params.hostIpv4Addr[2],
11311 pRequest->params.hostIpv4Addr[3]);
11312 }
11313 break;
11314
11315 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -070011316 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011317 switch (pRequest->enableOrDisable) {
11318 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070011319 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011320 break;
11321 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070011322 hdd_info(" enable");
11323 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011324 *(uint16_t *) (pRequest->params.hostIpv6Addr),
11325 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11326 2),
11327 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11328 4),
11329 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11330 6),
11331 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11332 8),
11333 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11334 10),
11335 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11336 12),
11337 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11338 14));
11339 }
11340 }
11341
11342 /* Execute offload request. The reason that we can copy the
11343 * request information from the ioctl structure to the SME
11344 * structure is that they are laid out exactly the same.
11345 * Otherwise, each piece of information would have to be
11346 * copied individually.
11347 */
11348 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011349 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011350 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
11351 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011352 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011353 return -EINVAL;
11354 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011355 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011356 return 0;
11357}
11358
11359static int iw_set_host_offload(struct net_device *dev,
11360 struct iw_request_info *info,
11361 union iwreq_data *wrqu, char *extra)
11362{
11363 int ret;
11364
11365 cds_ssr_protect(__func__);
11366 ret = __iw_set_host_offload(dev, info, wrqu, extra);
11367 cds_ssr_unprotect(__func__);
11368
11369 return ret;
11370}
11371
11372/**
11373 * iw_set_keepalive_params - Set keepalive params ioctl handler
11374 * @dev: device upon which the ioctl was received
11375 * @info: ioctl request information
11376 * @wrqu: ioctl request data
11377 * @extra: ioctl extra data
11378 *
11379 * Return: 0 on success, non-zero on error
11380 */
11381static int __iw_set_keepalive_params(struct net_device *dev,
11382 struct iw_request_info *info,
11383 union iwreq_data *wrqu, char *extra)
11384{
11385 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011386 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011387 hdd_context_t *hdd_ctx;
11388 int ret;
11389
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011390 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011392 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11393 ret = wlan_hdd_validate_context(hdd_ctx);
11394 if (0 != ret)
11395 return ret;
11396
Jeff Johnson441e1f72017-02-07 08:50:49 -080011397 ret = hdd_check_private_wext_control(hdd_ctx, info);
11398 if (0 != ret)
11399 return ret;
11400
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011401 if (wrqu->data.length != sizeof(*request)) {
11402 hdd_err("Invalid length %d", wrqu->data.length);
11403 return -EINVAL;
11404 }
11405
11406 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
11407 hdd_err("Value of timePeriod %d exceed Max limit %d",
11408 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011409 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
11410 return -EINVAL;
11411 }
11412
11413 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011414 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
11415 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011416
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011417 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011418 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011419 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011420 break;
11421
11422 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011423 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011424
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011425 hdd_info("Host IP address: %d.%d.%d.%d",
11426 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
11427 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011428
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011429 hdd_info("Dest IP address: %d.%d.%d.%d",
11430 request->destIpv4Addr[0], request->destIpv4Addr[1],
11431 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011432
Srinivas Girigowda9c330a92015-11-24 12:28:25 -080011433 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
11434 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011435 break;
11436 }
11437
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011438 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011439
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011440 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011441 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011442 pAdapter->sessionId, request)) {
11443 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011444 return -EINVAL;
11445 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011446 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011447 return 0;
11448}
11449
11450static int iw_set_keepalive_params(struct net_device *dev,
11451 struct iw_request_info *info,
11452 union iwreq_data *wrqu,
11453 char *extra)
11454{
11455 int ret;
11456
11457 cds_ssr_protect(__func__);
11458 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
11459 cds_ssr_unprotect(__func__);
11460
11461 return ret;
11462}
11463
11464#ifdef WLAN_FEATURE_PACKET_FILTERING
11465/**
11466 * wlan_hdd_set_filter() - Set packet filter
11467 * @hdd_ctx: Global HDD context
11468 * @request: Packet filter request struct
11469 * @sessionId: Target session for the request
11470 *
11471 * Return: 0 on success, non-zero on error
11472 */
11473static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
11474 struct pkt_filter_cfg *request,
11475 uint8_t sessionId)
11476{
11477 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
11478 tSirRcvFltPktClearParam packetFilterClrReq = {0};
11479 int i = 0;
11480
11481 if (hdd_ctx->config->disablePacketFilter) {
11482 hdd_err("packet filtering disabled in ini returning");
11483 return 0;
11484 }
11485
11486 /* Debug display of request components. */
11487 hdd_info("Packet Filter Request : FA %d params %d",
11488 request->filter_action, request->num_params);
11489
11490 switch (request->filter_action) {
11491 case HDD_RCV_FILTER_SET:
11492 hdd_info("Set Packet Filter Request for Id: %d",
11493 request->filter_id);
11494
11495 packetFilterSetReq.filterId = request->filter_id;
11496 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
11497 hdd_err("Number of Params exceed Max limit %d",
11498 request->num_params);
11499 return -EINVAL;
11500 }
11501 packetFilterSetReq.numFieldParams = request->num_params;
11502 packetFilterSetReq.coalesceTime = 0;
11503 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
11504 for (i = 0; i < request->num_params; i++) {
11505 packetFilterSetReq.paramsData[i].protocolLayer =
11506 request->params_data[i].protocol_layer;
11507 packetFilterSetReq.paramsData[i].cmpFlag =
11508 request->params_data[i].compare_flag;
11509 packetFilterSetReq.paramsData[i].dataOffset =
11510 request->params_data[i].data_offset;
11511 packetFilterSetReq.paramsData[i].dataLength =
11512 request->params_data[i].data_length;
11513 packetFilterSetReq.paramsData[i].reserved = 0;
11514
Dustin Brown4d1e8462016-12-14 12:12:24 -080011515 if (request->params_data[i].data_offset >
11516 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
11517 hdd_err("Invalid data offset %u for param %d (max = %d)",
11518 request->params_data[i].data_offset,
11519 i,
11520 SIR_MAX_FILTER_TEST_DATA_OFFSET);
11521 return -EINVAL;
11522 }
11523
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011524 if (request->params_data[i].data_length >
11525 SIR_MAX_FILTER_TEST_DATA_LEN) {
11526 hdd_err("Error invalid data length %d",
11527 request->params_data[i].data_length);
11528 return -EINVAL;
11529 }
11530
11531 hdd_info("Proto %d Comp Flag %d Filter Type %d",
11532 request->params_data[i].protocol_layer,
11533 request->params_data[i].compare_flag,
11534 packetFilterSetReq.filterType);
11535
11536 hdd_info("Data Offset %d Data Len %d",
11537 request->params_data[i].data_offset,
11538 request->params_data[i].data_length);
11539
Rajeev Kumarf5b6da22016-04-15 13:24:03 -070011540 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
11541 < (request->params_data[i].data_length)) {
11542 hdd_err("Error invalid data length %d",
11543 request->params_data[i].data_length);
11544 return -EINVAL;
11545 }
11546
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011547 memcpy(&packetFilterSetReq.paramsData[i].compareData,
11548 request->params_data[i].compare_data,
11549 request->params_data[i].data_length);
11550 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
11551 request->params_data[i].data_mask,
11552 request->params_data[i].data_length);
11553
11554 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
11555 request->params_data[i].compare_data[0],
11556 request->params_data[i].compare_data[1],
11557 request->params_data[i].compare_data[2],
11558 request->params_data[i].compare_data[3],
11559 request->params_data[i].compare_data[4],
11560 request->params_data[i].compare_data[5]);
11561
11562 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
11563 request->params_data[i].data_mask[0],
11564 request->params_data[i].data_mask[1],
11565 request->params_data[i].data_mask[2],
11566 request->params_data[i].data_mask[3],
11567 request->params_data[i].data_mask[4],
11568 request->params_data[i].data_mask[5]);
11569 }
11570
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011571 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011572 sme_receive_filter_set_filter(hdd_ctx->hHal,
11573 &packetFilterSetReq,
11574 sessionId)) {
11575 hdd_err("Failure to execute Set Filter");
11576 return -EINVAL;
11577 }
11578
11579 break;
11580
11581 case HDD_RCV_FILTER_CLEAR:
11582
11583 hdd_info("Clear Packet Filter Request for Id: %d",
11584 request->filter_id);
11585 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011586 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011587 sme_receive_filter_clear_filter(hdd_ctx->hHal,
11588 &packetFilterClrReq,
11589 sessionId)) {
11590 hdd_err("Failure to execute Clear Filter");
11591 return -EINVAL;
11592 }
11593 break;
11594
11595 default:
11596 hdd_err("Packet Filter Request: Invalid %d",
11597 request->filter_action);
11598 return -EINVAL;
11599 }
11600 return 0;
11601}
11602
11603/**
11604 * __iw_set_packet_filter_params() - set packet filter parameters in target
11605 * @dev: Pointer to netdev
11606 * @info: Pointer to iw request info
11607 * @wrqu: Pointer to data
11608 * @extra: Pointer to extra data
11609 *
11610 * Return: 0 on success, non-zero on error
11611 */
11612static int __iw_set_packet_filter_params(struct net_device *dev,
11613 struct iw_request_info *info,
11614 union iwreq_data *wrqu, char *extra)
11615{
11616 int ret;
11617 hdd_context_t *hdd_ctx;
11618 struct iw_point priv_data;
11619 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
11620 struct pkt_filter_cfg *request = NULL;
11621
Mukul Sharma472382f2015-11-02 20:16:31 +053011622 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011623 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +053011624 return -EPERM;
11625 }
11626
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011627 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011629 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11630 ret = wlan_hdd_validate_context(hdd_ctx);
11631 if (0 != ret)
11632 return ret;
11633
Jeff Johnson441e1f72017-02-07 08:50:49 -080011634 ret = hdd_check_private_wext_control(hdd_ctx, info);
11635 if (0 != ret)
11636 return ret;
11637
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011638 if (hdd_priv_get_data(&priv_data, wrqu)) {
11639 hdd_err("failed to get priv data");
11640 return -EINVAL;
11641 }
11642
11643 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
11644 hdd_err("invalid priv data %p or invalid priv data length %d",
11645 priv_data.pointer, priv_data.length);
11646 return -EINVAL;
11647 }
11648
11649 /* copy data using copy_from_user */
11650 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
11651 priv_data.length);
11652 if (NULL == request) {
11653 hdd_err("mem_alloc_copy_from_user_helper fail");
11654 return -ENOMEM;
11655 }
11656
11657 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
11658
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -070011659 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011660 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011661 return ret;
11662}
11663
11664/**
11665 * iw_set_packet_filter_params() - set packet filter parameters in target
11666 * @dev: Pointer to netdev
11667 * @info: Pointer to iw request info
11668 * @wrqu: Pointer to data
11669 * @extra: Pointer to extra data
11670 *
11671 * Return: 0 on success, non-zero on error
11672 */
11673static int iw_set_packet_filter_params(struct net_device *dev,
11674 struct iw_request_info *info,
11675 union iwreq_data *wrqu, char *extra)
11676{
11677 int ret;
11678
11679 cds_ssr_protect(__func__);
11680 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
11681 cds_ssr_unprotect(__func__);
11682
11683 return ret;
11684}
11685#endif
11686
11687
11688static int __iw_get_statistics(struct net_device *dev,
11689 struct iw_request_info *info,
11690 union iwreq_data *wrqu, char *extra)
11691{
11692
Anurag Chouhance0dc992016-02-16 18:18:03 +053011693 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011694 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011695 hdd_wext_state_t *pWextState;
11696 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11697 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11698 char *p = extra;
11699 int tlen = 0;
11700 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
11701 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
11702 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
11703 int ret;
11704
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011705 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011706
11707 ret = wlan_hdd_validate_context(hdd_ctx);
11708 if (0 != ret)
11709 return ret;
11710
Jeff Johnson441e1f72017-02-07 08:50:49 -080011711 ret = hdd_check_private_wext_control(hdd_ctx, info);
11712 if (0 != ret)
11713 return ret;
11714
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011715 if (eConnectionState_Associated !=
11716 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
11717
11718 wrqu->txpower.value = 0;
11719 } else {
11720 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11721 SME_SUMMARY_STATS |
11722 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080011723 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011724 hdd_statistics_cb, 0, false,
11725 (WLAN_HDD_GET_STATION_CTX_PTR
11726 (pAdapter))->conn_info.staId[0],
11727 pAdapter, pAdapter->sessionId);
11728
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011729 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011730 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011731 return -EINVAL;
11732 }
11733
11734 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11735
Anurag Chouhance0dc992016-02-16 18:18:03 +053011736 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011737 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011738 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011739 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011740 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011741 /*Remove the SME statistics list by passing NULL in callback argument */
11742 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11743 SME_SUMMARY_STATS |
11744 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080011745 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011746 NULL, 0, false,
11747 (WLAN_HDD_GET_STATION_CTX_PTR
11748 (pAdapter))->conn_info.
11749 staId[0], pAdapter,
11750 pAdapter->sessionId);
11751
11752 return -EINVAL;
11753 }
11754 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
11755 (uint8_t) sizeof(pStats->retry_cnt),
11756 (char *)&(pStats->retry_cnt[0]), tlen);
11757
11758 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
11759 (uint8_t) sizeof(pStats->multiple_retry_cnt),
11760 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
11761
11762 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
11763 (uint8_t) sizeof(pStats->tx_frm_cnt),
11764 (char *)&(pStats->tx_frm_cnt[0]), tlen);
11765
11766 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
11767 (uint8_t) sizeof(pStats->rx_frm_cnt),
11768 (char *)&(pStats->rx_frm_cnt), tlen);
11769
11770 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
11771 (uint8_t) sizeof(pStats->frm_dup_cnt),
11772 (char *)&(pStats->frm_dup_cnt), tlen);
11773
11774 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
11775 (uint8_t) sizeof(pStats->fail_cnt),
11776 (char *)&(pStats->fail_cnt[0]), tlen);
11777
11778 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
11779 (uint8_t) sizeof(pStats->rts_fail_cnt),
11780 (char *)&(pStats->rts_fail_cnt), tlen);
11781
11782 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
11783 (uint8_t) sizeof(pStats->ack_fail_cnt),
11784 (char *)&(pStats->ack_fail_cnt), tlen);
11785
11786 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
11787 (uint8_t) sizeof(pStats->rts_succ_cnt),
11788 (char *)&(pStats->rts_succ_cnt), tlen);
11789
11790 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
11791 (uint8_t) sizeof(pStats->rx_discard_cnt),
11792 (char *)&(pStats->rx_discard_cnt), tlen);
11793
11794 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
11795 (uint8_t) sizeof(pStats->rx_error_cnt),
11796 (char *)&(pStats->rx_error_cnt), tlen);
11797
11798 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
11799 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11800 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11801
11802 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
11803 (uint8_t) sizeof(dStats->rx_byte_cnt),
11804 (char *)&(dStats->rx_byte_cnt), tlen);
11805
11806 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
11807 (uint8_t) sizeof(dStats->rx_rate),
11808 (char *)&(dStats->rx_rate), tlen);
11809
11810 /* Transmit rate, in units of 500 kbit/sec */
11811 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
11812 (uint8_t) sizeof(aStats->tx_rate),
11813 (char *)&(aStats->tx_rate), tlen);
11814
11815 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
11816 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
11817 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
11818 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
11819 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
11820 (char *)&(dStats->rx_mc_byte_cnt), tlen);
11821 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
11822 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
11823 (char *)&(dStats->rx_bc_byte_cnt), tlen);
11824 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
11825 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11826 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11827 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
11828 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
11829 (char *)&(dStats->tx_mc_byte_cnt), tlen);
11830 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
11831 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
11832 (char *)&(dStats->tx_bc_byte_cnt), tlen);
11833
11834 wrqu->data.length = tlen;
11835
11836 }
11837
11838 EXIT();
11839
11840 return 0;
11841}
11842
11843static int iw_get_statistics(struct net_device *dev,
11844 struct iw_request_info *info,
11845 union iwreq_data *wrqu, char *extra)
11846{
11847 int ret;
11848
11849 cds_ssr_protect(__func__);
11850 ret = __iw_get_statistics(dev, info, wrqu, extra);
11851 cds_ssr_unprotect(__func__);
11852
11853 return ret;
11854}
11855
11856#ifdef FEATURE_WLAN_SCAN_PNO
11857
11858/*Max Len for PNO notification*/
11859#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011860static void found_pref_network_cb(void *callbackContext,
11861 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011862{
11863 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
11864 union iwreq_data wrqu;
11865 char buf[MAX_PNO_NOTIFY_LEN + 1];
11866
Jeff Johnson99bac312016-06-28 10:38:18 -070011867 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011868 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
11869
11870 /* create the event */
11871 memset(&wrqu, 0, sizeof(wrqu));
11872 memset(buf, 0, sizeof(buf));
11873
11874 snprintf(buf, MAX_PNO_NOTIFY_LEN,
11875 "QCOM: Found preferred network: %s with RSSI of -%u",
11876 pPrefNetworkFoundInd->ssId.ssId,
11877 (unsigned int)pPrefNetworkFoundInd->rssi);
11878
11879 wrqu.data.pointer = buf;
11880 wrqu.data.length = strlen(buf);
11881
11882 /* send the event */
11883
11884 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
11885
11886}
11887
11888/**
11889 * __iw_set_pno() - Preferred Network Offload ioctl handler
11890 * @dev: device upon which the ioctl was received
11891 * @info: ioctl request information
11892 * @wrqu: ioctl request data
11893 * @extra: ioctl extra data
11894 *
11895 * This function parses a Preferred Network Offload command
11896 * Input is string based and expected to be of the form:
11897 *
11898 * <enable(1) | disable(0)>
11899 * when enabling:
11900 * <number of networks>
11901 * for each network:
11902 * <ssid_len> <ssid> <authentication> <encryption>
11903 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070011904 * <scan_time (seconds)>
11905 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011906 * <suspend mode>
11907 *
11908 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070011909 * 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 -080011910 *
11911 * this translates into:
11912 * -----------------------------
11913 * enable PNO
11914 * 2 networks
11915 * Network 1:
11916 * test - with authentication type 0 and encryption type 0,
11917 * search on 3 channels: 1 6 and 11,
11918 * SSID bcast type is unknown (directed probe will be sent if
11919 * AP not found) and must meet -40dBm RSSI
11920 * Network 2:
11921 * test2 - with authentication type 4 and encryption type 4,
11922 * search on 6 channels 1, 2, 3, 4, 5 and 6
11923 * bcast type is non-bcast (directed probe will be sent)
11924 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011925 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070011926 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011927 */
11928static int __iw_set_pno(struct net_device *dev,
11929 struct iw_request_info *info,
11930 union iwreq_data *wrqu, char *extra)
11931{
11932 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
11933 hdd_context_t *hdd_ctx;
11934 int ret;
11935 int offset;
11936 char *ptr;
11937 uint8_t i, j, params, mode;
11938
11939 /* request is a large struct, so we make it static to avoid
11940 * stack overflow. This API is only invoked via ioctl, so it
11941 * is serialized by the kernel rtnl_lock and hence does not
11942 * need to be reentrant
11943 */
11944 static tSirPNOScanReq request;
11945
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011946 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011947
11948 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11949 ret = wlan_hdd_validate_context(hdd_ctx);
11950 if (ret)
11951 return ret;
11952
Jeff Johnson441e1f72017-02-07 08:50:49 -080011953 ret = hdd_check_private_wext_control(hdd_ctx, info);
11954 if (0 != ret)
11955 return ret;
11956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011957 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
11958
11959 request.enable = 0;
11960 request.ucNetworksCount = 0;
11961
11962 ptr = extra;
11963
11964 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
11965 hdd_err("PNO enable input is not valid %s", ptr);
11966 return -EINVAL;
11967 }
11968
11969 if (0 == request.enable) {
11970 /* Disable PNO, ignore any other params */
11971 memset(&request, 0, sizeof(request));
11972 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
11973 &request, adapter->sessionId,
11974 found_pref_network_cb, adapter);
11975 return 0;
11976 }
11977
11978 ptr += offset;
11979
11980 if (1 !=
11981 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
11982 hdd_err("PNO count input not valid %s", ptr);
11983 return -EINVAL;
11984
11985 }
11986
11987 hdd_info("PNO enable %d networks count %d offset %d",
11988 request.enable, request.ucNetworksCount, offset);
11989
11990 if ((0 == request.ucNetworksCount) ||
11991 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
11992 hdd_err("Network count %d invalid",
11993 request.ucNetworksCount);
11994 return -EINVAL;
11995 }
11996
11997 ptr += offset;
11998
11999 for (i = 0; i < request.ucNetworksCount; i++) {
12000
12001 request.aNetworks[i].ssId.length = 0;
12002
12003 params = sscanf(ptr, "%hhu %n",
12004 &(request.aNetworks[i].ssId.length),
12005 &offset);
12006
12007 if (1 != params) {
12008 hdd_err("PNO ssid length input is not valid %s", ptr);
12009 return -EINVAL;
12010 }
12011
12012 if ((0 == request.aNetworks[i].ssId.length) ||
12013 (request.aNetworks[i].ssId.length > 32)) {
12014 hdd_err("SSID Len %d is not correct for network %d",
12015 request.aNetworks[i].ssId.length, i);
12016 return -EINVAL;
12017 }
12018
12019 /* Advance to SSID */
12020 ptr += offset;
12021
12022 memcpy(request.aNetworks[i].ssId.ssId, ptr,
12023 request.aNetworks[i].ssId.length);
12024 ptr += request.aNetworks[i].ssId.length;
12025
12026 params = sscanf(ptr, "%u %u %hhu %n",
12027 &(request.aNetworks[i].authentication),
12028 &(request.aNetworks[i].encryption),
12029 &(request.aNetworks[i].ucChannelCount),
12030 &offset);
12031
12032 if (3 != params) {
12033 hdd_warn("Incorrect cmd %s", ptr);
12034 return -EINVAL;
12035 }
12036
12037 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
12038 request.aNetworks[i].ssId.length,
12039 request.aNetworks[i].ssId.length,
12040 request.aNetworks[i].ssId.ssId,
12041 request.aNetworks[i].authentication,
12042 request.aNetworks[i].encryption,
12043 request.aNetworks[i].ucChannelCount, offset);
12044
12045 /* Advance to channel list */
12046 ptr += offset;
12047
12048 if (SIR_PNO_MAX_NETW_CHANNELS <
12049 request.aNetworks[i].ucChannelCount) {
12050 hdd_warn("Incorrect number of channels");
12051 return -EINVAL;
12052 }
12053
12054 if (0 != request.aNetworks[i].ucChannelCount) {
12055 for (j = 0; j < request.aNetworks[i].ucChannelCount;
12056 j++) {
12057 if (1 !=
12058 sscanf(ptr, "%hhu %n",
12059 &(request.aNetworks[i].
12060 aChannels[j]), &offset)) {
12061 hdd_err("PNO network channel input is not valid %s",
12062 ptr);
12063 return -EINVAL;
12064 }
12065 /* Advance to next channel number */
12066 ptr += offset;
12067 }
12068 }
12069
12070 if (1 != sscanf(ptr, "%u %n",
12071 &(request.aNetworks[i].bcastNetwType),
12072 &offset)) {
12073 hdd_err("PNO broadcast network type input is not valid %s",
12074 ptr);
12075 return -EINVAL;
12076 }
12077
12078 hdd_notice("PNO bcastNetwType %d offset %d",
12079 request.aNetworks[i].bcastNetwType, offset);
12080
12081 /* Advance to rssi Threshold */
12082 ptr += offset;
12083 if (1 != sscanf(ptr, "%d %n",
12084 &(request.aNetworks[i].rssiThreshold),
12085 &offset)) {
12086 hdd_err("PNO rssi threshold input is not valid %s",
12087 ptr);
12088 return -EINVAL;
12089 }
12090 hdd_notice("PNO rssi %d offset %d",
12091 request.aNetworks[i].rssiThreshold, offset);
12092 /* Advance to next network */
12093 ptr += offset;
12094 } /* For ucNetworkCount */
12095
Dustin Brown43e87292016-10-10 10:38:25 -070012096 request.fast_scan_period = 0;
12097 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
12098 request.fast_scan_period *= MSEC_PER_SEC;
12099 ptr += offset;
12100 }
12101
12102 request.fast_scan_max_cycles = 0;
12103 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
12104 &offset) > 0)
12105 ptr += offset;
12106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012107 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
12108
12109 request.modePNO = mode;
12110 /* for LA we just expose suspend option */
12111 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
12112 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
12113 }
12114
12115 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
12116 &request,
12117 adapter->sessionId,
12118 found_pref_network_cb, adapter);
12119
12120 return 0;
12121}
12122
12123static int iw_set_pno(struct net_device *dev,
12124 struct iw_request_info *info,
12125 union iwreq_data *wrqu, char *extra)
12126{
12127 int ret;
12128
12129 cds_ssr_protect(__func__);
12130 ret = __iw_set_pno(dev, info, wrqu, extra);
12131 cds_ssr_unprotect(__func__);
12132
12133 return ret;
12134}
12135#endif /* FEATURE_WLAN_SCAN_PNO */
12136
12137/* Common function to SetBand */
12138int hdd_set_band(struct net_device *dev, u8 ui_band)
12139{
12140 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12141 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12142 eCsrBand band;
12143
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012144 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012145 hdd_context_t *pHddCtx;
12146 hdd_adapter_list_node_t *pAdapterNode, *pNext;
12147 eCsrBand currBand = eCSR_BAND_MAX;
12148 eCsrBand connectedBand;
12149
12150 pAdapterNode = NULL;
12151 pNext = NULL;
12152 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12153
12154 switch (ui_band) {
12155 case WLAN_HDD_UI_BAND_AUTO:
12156 band = eCSR_BAND_ALL;
12157 break;
12158 case WLAN_HDD_UI_BAND_5_GHZ:
12159 band = eCSR_BAND_5G;
12160 break;
12161 case WLAN_HDD_UI_BAND_2_4_GHZ:
12162 band = eCSR_BAND_24;
12163 break;
12164 default:
12165 band = eCSR_BAND_MAX;
12166 }
12167
Jeff Johnson99bac312016-06-28 10:38:18 -070012168 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012169
12170 if (band == eCSR_BAND_MAX) {
12171 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -070012172 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012173 return -EINVAL;
12174 }
12175
12176 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
12177 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012178 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012179 band, pHddCtx->config->nBandCapability);
12180 return -EIO;
12181 }
12182
12183 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012184 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012185 pHddCtx->config->nBandCapability);
12186 band = pHddCtx->config->nBandCapability;
12187 }
12188
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012189 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012190 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012191 return -EIO;
12192 }
12193
12194 if (currBand != band) {
12195 /* Change band request received.
12196 * Abort pending scan requests, flush the existing scan results,
12197 * and change the band capability
12198 */
Jeff Johnson99bac312016-06-28 10:38:18 -070012199 hdd_notice("Current band value = %u, new setting %u ",
12200 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012201
12202 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012203 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012204 pAdapter = pAdapterNode->pAdapter;
12205 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12206 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053012207 INVALID_SCAN_ID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012208 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
12209 connectedBand =
12210 hdd_conn_get_connected_band
12211 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
12212
12213 /* Handling is done only for STA and P2P */
12214 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -080012215 ((pAdapter->device_mode == QDF_STA_MODE)
12216 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012217 &&
12218 (hdd_conn_is_connected
12219 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
12220 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012221 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012222 long lrc;
12223
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012224 /* STA already connected on current
12225 * band, So issue disconnect first,
12226 * then change the band
12227 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012228
Jeff Johnson99bac312016-06-28 10:38:18 -070012229 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012230 hdd_device_mode_to_string(pAdapter->device_mode),
12231 pAdapter->device_mode, currBand, band);
12232 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12233
12234 status =
12235 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
12236 (pAdapter),
12237 pAdapter->sessionId,
12238 eCSR_DISCONNECT_REASON_UNSPECIFIED);
12239
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012240 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012241 hdd_err("csr_roam_disconnect failure, returned %d",
12242 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012243 return -EINVAL;
12244 }
12245
12246 lrc =
12247 wait_for_completion_timeout(&pAdapter->
12248 disconnect_comp_var,
12249 msecs_to_jiffies
12250 (WLAN_WAIT_TIME_DISCONNECT));
12251
12252 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012253 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012254 return -ETIMEDOUT;
12255 }
12256 }
12257
12258 sme_scan_flush_result(hHal);
12259
12260 status =
12261 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
12262 pAdapterNode = pNext;
12263 }
12264
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012265 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012266 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012267 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012268 band);
12269 return -EINVAL;
12270 }
12271 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
12272 }
12273 return 0;
12274}
12275
12276int hdd_set_band_helper(struct net_device *dev, const char *command)
12277{
12278 uint8_t band;
12279 int ret;
12280
12281 /* Convert the band value from ascii to integer */
12282 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
12283 ret = kstrtou8(command, 10, &band);
12284 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012285 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012286 return -EINVAL;
12287 }
12288
12289 return hdd_set_band(dev, band);
12290}
12291
12292static int __iw_set_band_config(struct net_device *dev,
12293 struct iw_request_info *info,
12294 union iwreq_data *wrqu, char *extra)
12295{
Jeff Johnson441e1f72017-02-07 08:50:49 -080012296 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12297 hdd_context_t *hdd_ctx;
12298 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012299 int *value = (int *)extra;
12300
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012301 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012302
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012303 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012304 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012305 return -EPERM;
12306 }
12307
Jeff Johnson441e1f72017-02-07 08:50:49 -080012308 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12309 ret = hdd_check_private_wext_control(hdd_ctx, info);
12310 if (0 != ret)
12311 return ret;
12312
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012313 return hdd_set_band(dev, value[0]);
12314}
12315
12316static int iw_set_band_config(struct net_device *dev,
12317 struct iw_request_info *info,
12318 union iwreq_data *wrqu, char *extra)
12319{
12320 int ret;
12321
12322 cds_ssr_protect(__func__);
12323 ret = __iw_set_band_config(dev, info, wrqu, extra);
12324 cds_ssr_unprotect(__func__);
12325
12326 return ret;
12327}
12328
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012329/**
12330 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
12331 * @adapter: Handle to adapter
12332 * @chan: Monitor mode channel
12333 * @bandwidth: Capture channel bandwidth
12334 *
12335 * Return: 0 on success else error code.
12336 */
12337static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
12338 uint32_t bandwidth)
12339{
12340 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12341 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
12342 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
12343 QDF_STATUS status;
12344 tHalHandle hal_hdl = hdd_ctx->hHal;
12345 struct qdf_mac_addr bssid;
12346 tCsrRoamProfile roam_profile;
12347 struct ch_params_s ch_params;
12348
12349 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
12350 hdd_err("Not supported, device is not in monitor mode");
12351 return -EINVAL;
12352 }
12353
12354 hdd_info("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080012355 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012356 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
12357 roam_profile.ChannelInfo.numOfChannels = 1;
12358 roam_profile.phyMode = ch_info->phy_mode;
12359 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070012360 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012361
12362 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
12363 QDF_MAC_ADDR_SIZE);
12364
12365 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -070012366 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012367 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
12368 &roam_profile);
12369 if (status) {
12370 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
12371 status);
12372 }
12373
12374 return qdf_status_to_os_return(status);
12375}
12376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012377static int __iw_set_two_ints_getnone(struct net_device *dev,
12378 struct iw_request_info *info,
12379 union iwreq_data *wrqu, char *extra)
12380{
12381 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12382 int *value = (int *)extra;
12383 int sub_cmd = value[0];
12384 int ret;
12385 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
12386
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012387 ENTER_DEV(dev);
12388
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012389 ret = wlan_hdd_validate_context(hdd_ctx);
12390 if (0 != ret)
12391 return ret;
12392
Jeff Johnson441e1f72017-02-07 08:50:49 -080012393 ret = hdd_check_private_wext_control(hdd_ctx, info);
12394 if (0 != ret)
12395 return ret;
12396
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012397 switch (sub_cmd) {
12398 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -070012399 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012400 ret = wma_cli_set_command(pAdapter->sessionId,
12401 WMI_STA_SMPS_PARAM_CMDID,
12402 value[1] << WMA_SMPS_PARAM_VALUE_S
12403 | value[2],
12404 VDEV_CMD);
12405 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070012406#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012407 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -070012408 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012409 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053012410 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
12411 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012412 ret = wma_cli_set2_command(pAdapter->sessionId,
12413 GEN_PARAM_CRASH_INJECT,
12414 value[1], value[2], GEN_CMD);
12415 break;
12416#endif
Govind Singha471e5e2015-10-12 17:11:14 +053012417 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070012418 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012419 value[1], value[2]);
12420 ret = wma_cli_set2_command(pAdapter->sessionId,
12421 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
12422 value[1], value[2], DBG_CMD);
12423 break;
12424 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070012425 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012426 value[1], value[2]);
12427 ret = wma_cli_set2_command(pAdapter->sessionId,
12428 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
12429 value[1], value[2], DBG_CMD);
12430 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012431 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
12432 hdd_debug("Ioctl to set dual fw mode config");
12433 if (hdd_ctx->config->dual_mac_feature_disable) {
12434 hdd_err("Dual mac feature is disabled from INI");
12435 return -EPERM;
12436 }
12437 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -080012438 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012439 break;
12440 case WE_DUMP_DP_TRACE_LEVEL:
12441 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
12442 value[1], value[2]);
12443 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012444 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053012445 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
12446 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053012447 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
12448 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012449 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012450 case WE_SET_MON_MODE_CHAN:
12451 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
12452 break;
Dustin Brown54096432017-02-23 13:00:44 -080012453 case WE_SET_WLAN_SUSPEND: {
Dustin Brown3ed3e9b2017-03-23 12:57:58 -070012454 hdd_info("STA unit-test suspend(%d, %d)", value[1], value[2]);
Dustin Brown54096432017-02-23 13:00:44 -080012455 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
12456 value[1], value[2]);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012457 break;
Dustin Brown54096432017-02-23 13:00:44 -080012458 }
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012459 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070012460 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012461 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012462 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070012463 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012464 break;
12465 }
12466
12467 return ret;
12468}
12469
12470static int iw_set_two_ints_getnone(struct net_device *dev,
12471 struct iw_request_info *info,
12472 union iwreq_data *wrqu, char *extra)
12473{
12474 int ret;
12475
12476 cds_ssr_protect(__func__);
12477 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
12478 cds_ssr_unprotect(__func__);
12479
12480 return ret;
12481}
12482
12483/* Define the Wireless Extensions to the Linux Network Device structure */
12484/* A number of these routines are NULL (meaning they are not implemented.) */
12485
12486static const iw_handler we_handler[] = {
12487 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
12488 (iw_handler) iw_get_name, /* SIOCGIWNAME */
12489 (iw_handler) NULL, /* SIOCSIWNWID */
12490 (iw_handler) NULL, /* SIOCGIWNWID */
12491 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
12492 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
12493 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
12494 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
12495 (iw_handler) NULL, /* SIOCSIWSENS */
12496 (iw_handler) NULL, /* SIOCGIWSENS */
12497 (iw_handler) NULL, /* SIOCSIWRANGE */
12498 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
12499 (iw_handler) NULL, /* SIOCSIWPRIV */
12500 (iw_handler) NULL, /* SIOCGIWPRIV */
12501 (iw_handler) NULL, /* SIOCSIWSTATS */
12502 (iw_handler) NULL, /* SIOCGIWSTATS */
12503 (iw_handler) NULL, /* SIOCSIWSPY */
12504 (iw_handler) NULL, /* SIOCGIWSPY */
12505 (iw_handler) NULL, /* SIOCSIWTHRSPY */
12506 (iw_handler) NULL, /* SIOCGIWTHRSPY */
12507 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
12508 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
12509 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
12510 (iw_handler) NULL, /* SIOCGIWAPLIST */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012511#ifndef NAPIER_SCAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012512 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
12513 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012514#else
12515 (iw_handler) NULL, /* SIOCSIWSCAN */
12516 (iw_handler) NULL, /* SIOCGIWSCAN */
12517#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012518 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
12519 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
12520 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
12521 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
12522 (iw_handler) NULL, /* -- hole -- */
12523 (iw_handler) NULL, /* -- hole -- */
12524 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
12525 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
12526 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
12527 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
12528 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
12529 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
12530 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
12531 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
12532 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
12533 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
12534 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
12535 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
12536 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
12537 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
12538 (iw_handler) NULL, /* -- hole -- */
12539 (iw_handler) NULL, /* -- hole -- */
12540 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
12541 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
12542 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
12543 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
12544 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
12545 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
12546 (iw_handler) NULL, /* SIOCSIWPMKSA */
12547};
12548
12549static const iw_handler we_private[] = {
12550
12551 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
12552 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
12553 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
12554 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12555 iw_set_three_ints_getnone,
12556 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
12557 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
12558 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12559 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070012560 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
12561 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012562 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
12563 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
12564 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012565 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012566 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
12567 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
12568 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
12569 iw_set_keepalive_params,
12570#ifdef WLAN_FEATURE_PACKET_FILTERING
12571 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
12572 iw_set_packet_filter_params,
12573#endif
12574#ifdef FEATURE_WLAN_SCAN_PNO
12575 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
12576#endif
12577 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080012578 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
12579 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012580 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
12581 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12582 iw_set_two_ints_getnone,
12583 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
12584 iw_set_dot11p_channel_sched,
12585};
12586
12587/*Maximum command length can be only 15 */
12588static const struct iw_priv_args we_private_args[] = {
12589
12590 /* handlers for main ioctl */
12591 {WLAN_PRIV_SET_INT_GET_NONE,
12592 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12593 0,
12594 ""},
12595
12596 /* handlers for sub-ioctl */
12597 {WE_SET_11D_STATE,
12598 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12599 0,
12600 "set11Dstate"},
12601
12602 {WE_WOWL,
12603 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12604 0,
12605 "wowl"},
12606
12607 {WE_SET_POWER,
12608 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12609 0,
12610 "setPower"},
12611
12612 {WE_SET_MAX_ASSOC,
12613 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12614 0,
12615 "setMaxAssoc"},
12616
12617 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
12618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
12619 "setAutoChannel" },
12620
12621 {WE_SET_SCAN_DISABLE,
12622 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12623 0,
12624 "scan_disable"},
12625
12626 {WE_SET_DATA_INACTIVITY_TO,
12627 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12628 0,
12629 "inactivityTO"},
12630
12631 {WE_SET_MAX_TX_POWER,
12632 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12633 0,
12634 "setMaxTxPower"},
12635
12636 {WE_SET_TX_POWER,
12637 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12638 0,
12639 "setTxPower"},
12640
12641 {WE_SET_MC_RATE,
12642 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12643 0,
12644 "setMcRate"},
12645
12646 {WE_SET_MAX_TX_POWER_2_4,
12647 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12648 0,
12649 "setTxMaxPower2G"},
12650
12651 {WE_SET_MAX_TX_POWER_5_0,
12652 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12653 0,
12654 "setTxMaxPower5G"},
12655
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012656 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012657 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012658 0,
12659 "pktlog"},
12660
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012661 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
12662 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012663 * will support both
12664 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012665 {WE_SET_MAX_TX_POWER,
12666 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12667 0,
12668 "setTxMaxPower"},
12669
12670 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012671 * 1 = enable and 0 = disable
12672 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012673 {
12674 WE_SET_HIGHER_DTIM_TRANSITION,
12675 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12676 0,
12677 "setHDtimTransn"
12678 },
12679
12680 {WE_SET_TM_LEVEL,
12681 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12682 0,
12683 "setTmLevel"},
12684
12685 {WE_SET_PHYMODE,
12686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12687 0,
12688 "setphymode"},
12689
12690 {WE_SET_NSS,
12691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12692 0,
12693 "nss"},
12694
12695 {WE_SET_LDPC,
12696 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12697 0,
12698 "ldpc"},
12699
12700 {WE_SET_TX_STBC,
12701 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12702 0,
12703 "tx_stbc"},
12704
12705 {WE_SET_RX_STBC,
12706 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12707 0,
12708 "rx_stbc"},
12709
12710 {WE_SET_SHORT_GI,
12711 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12712 0,
12713 "shortgi"},
12714
12715 {WE_SET_RTSCTS,
12716 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12717 0,
12718 "enablertscts"},
12719
12720 {WE_SET_CHWIDTH,
12721 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12722 0,
12723 "chwidth"},
12724
12725 {WE_SET_ANI_EN_DIS,
12726 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12727 0,
12728 "anienable"},
12729
12730 {WE_SET_ANI_POLL_PERIOD,
12731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12732 0,
12733 "aniplen"},
12734
12735 {WE_SET_ANI_LISTEN_PERIOD,
12736 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12737 0,
12738 "anilislen"},
12739
12740 {WE_SET_ANI_OFDM_LEVEL,
12741 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12742 0,
12743 "aniofdmlvl"},
12744
12745 {WE_SET_ANI_CCK_LEVEL,
12746 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12747 0,
12748 "aniccklvl"},
12749
12750 {WE_SET_DYNAMIC_BW,
12751 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12752 0,
12753 "cwmenable"},
12754
12755 {WE_SET_CTS_CBW,
12756 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12757 0,
12758 "cts_cbw" },
12759
12760 {WE_SET_GTX_HT_MCS,
12761 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12762 0,
12763 "gtxHTMcs"},
12764
12765 {WE_SET_GTX_VHT_MCS,
12766 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12767 0,
12768 "gtxVHTMcs"},
12769
12770 {WE_SET_GTX_USRCFG,
12771 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12772 0,
12773 "gtxUsrCfg"},
12774
12775 {WE_SET_GTX_THRE,
12776 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12777 0,
12778 "gtxThre"},
12779
12780 {WE_SET_GTX_MARGIN,
12781 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12782 0,
12783 "gtxMargin"},
12784
12785 {WE_SET_GTX_STEP,
12786 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12787 0,
12788 "gtxStep"},
12789
12790 {WE_SET_GTX_MINTPC,
12791 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12792 0,
12793 "gtxMinTpc"},
12794
12795 {WE_SET_GTX_BWMASK,
12796 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12797 0,
12798 "gtxBWMask"},
12799
12800 {WE_SET_TX_CHAINMASK,
12801 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12802 0,
12803 "txchainmask"},
12804
12805 {WE_SET_RX_CHAINMASK,
12806 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12807 0,
12808 "rxchainmask"},
12809
12810 {WE_SET_11N_RATE,
12811 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12812 0,
12813 "set11NRates"},
12814
12815 {WE_SET_VHT_RATE,
12816 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12817 0,
12818 "set11ACRates"},
12819
12820 {WE_SET_AMPDU,
12821 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12822 0,
12823 "ampdu"},
12824
12825 {WE_SET_AMSDU,
12826 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12827 0,
12828 "amsdu"},
12829
12830 {WE_SET_BURST_ENABLE,
12831 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12832 0,
12833 "burst_enable"},
12834
12835 {WE_SET_BURST_DUR,
12836 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12837 0,
12838 "burst_dur"},
12839
12840 {WE_SET_TXPOW_2G,
12841 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12842 0,
12843 "txpow2g"},
12844
12845 {WE_SET_TXPOW_5G,
12846 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12847 0,
12848 "txpow5g"},
12849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012850 /* Sub-cmds DBGLOG specific commands */
12851 {WE_DBGLOG_LOG_LEVEL,
12852 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12853 0,
12854 "dl_loglevel"},
12855
12856 {WE_DBGLOG_VAP_ENABLE,
12857 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12858 0,
12859 "dl_vapon"},
12860
12861 {WE_DBGLOG_VAP_DISABLE,
12862 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12863 0,
12864 "dl_vapoff"},
12865
12866 {WE_DBGLOG_MODULE_ENABLE,
12867 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12868 0,
12869 "dl_modon"},
12870
12871 {WE_DBGLOG_MODULE_DISABLE,
12872 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12873 0,
12874 "dl_modoff"},
12875
12876 {WE_DBGLOG_MOD_LOG_LEVEL,
12877 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12878 0,
12879 "dl_mod_loglevel"},
12880
12881 {WE_DBGLOG_TYPE,
12882 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12883 0,
12884 "dl_type"},
12885 {WE_DBGLOG_REPORT_ENABLE,
12886 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12887 0,
12888 "dl_report"},
12889
12890 {WE_SET_TXRX_FWSTATS,
12891 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12892 0,
12893 "txrx_fw_stats"},
12894
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080012895 {WE_SET_TXRX_STATS,
12896 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12897 0,
12898 "txrx_stats"},
12899
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012900 {WE_TXRX_FWSTATS_RESET,
12901 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12902 0,
12903 "txrx_fw_st_rst"},
12904
12905 {WE_PPS_PAID_MATCH,
12906 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12907 0, "paid_match"},
12908
12909 {WE_PPS_GID_MATCH,
12910 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12911 0, "gid_match"},
12912
12913 {WE_PPS_EARLY_TIM_CLEAR,
12914 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12915 0, "tim_clear"},
12916
12917 {WE_PPS_EARLY_DTIM_CLEAR,
12918 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12919 0, "dtim_clear"},
12920
12921 {WE_PPS_EOF_PAD_DELIM,
12922 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12923 0, "eof_delim"},
12924
12925 {WE_PPS_MACADDR_MISMATCH,
12926 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12927 0, "mac_match"},
12928
12929 {WE_PPS_DELIM_CRC_FAIL,
12930 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12931 0, "delim_fail"},
12932
12933 {WE_PPS_GID_NSTS_ZERO,
12934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12935 0, "nsts_zero"},
12936
12937 {WE_PPS_RSSI_CHECK,
12938 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12939 0, "rssi_chk"},
12940
12941 {WE_PPS_5G_EBT,
12942 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12943 0, "5g_ebt"},
12944
12945 {WE_SET_HTSMPS,
12946 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12947 0, "htsmps"},
12948
12949 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
12950 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12951 0, "set_qpspollcnt"},
12952
12953 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
12954 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12955 0, "set_qtxwake"},
12956
12957 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
12958 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12959 0, "set_qwakeintv"},
12960
12961 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
12962 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12963 0, "set_qnodatapoll"},
12964
12965 /* handlers for MCC time quota and latency sub ioctls */
12966 {WE_MCC_CONFIG_LATENCY,
12967 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12968 0, "setMccLatency"},
12969
12970 {WE_MCC_CONFIG_QUOTA,
12971 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12972 0, "setMccQuota"},
12973
12974 {WE_SET_DEBUG_LOG,
12975 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12976 0, "setDbgLvl"},
12977
12978 /* handlers for early_rx power save */
12979 {WE_SET_EARLY_RX_ADJUST_ENABLE,
12980 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12981 0, "erx_enable"},
12982
12983 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
12984 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12985 0, "erx_bmiss_val"},
12986
12987 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
12988 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12989 0, "erx_bmiss_smpl"},
12990
12991 {WE_SET_EARLY_RX_SLOP_STEP,
12992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12993 0, "erx_slop_step"},
12994
12995 {WE_SET_EARLY_RX_INIT_SLOP,
12996 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12997 0, "erx_init_slop"},
12998
12999 {WE_SET_EARLY_RX_ADJUST_PAUSE,
13000 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13001 0, "erx_adj_pause"},
13002
13003 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
13004 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13005 0, "erx_dri_sample"},
13006
13007 {WE_DUMP_STATS,
13008 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13009 0, "dumpStats"},
13010
13011 {WE_CLEAR_STATS,
13012 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13013 0, "clearStats"},
13014
Govind Singha471e5e2015-10-12 17:11:14 +053013015 {WE_START_FW_PROFILE,
13016 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13017 0, "startProfile"},
13018
Abhishek Singh1bdb1572015-10-16 16:24:19 +053013019 {WE_SET_CHANNEL,
13020 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13021 0, "setChanChange" },
13022
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053013023 {WE_SET_CONC_SYSTEM_PREF,
13024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13025 0, "setConcSysPref" },
13026
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013027 {WLAN_PRIV_SET_NONE_GET_INT,
13028 0,
13029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13030 ""},
13031
13032 /* handlers for sub-ioctl */
13033 {WE_GET_11D_STATE,
13034 0,
13035 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13036 "get11Dstate"},
13037
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013038 {WE_GET_WLAN_DBG,
13039 0,
13040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13041 "getwlandbg"},
13042
13043 {WE_GET_MAX_ASSOC,
13044 0,
13045 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13046 "getMaxAssoc"},
13047
13048 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
13049 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13050 "getAutoChannel" },
13051
13052 {WE_GET_CONCURRENCY_MODE,
13053 0,
13054 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13055 "getconcurrency"},
13056
13057 {WE_GET_NSS,
13058 0,
13059 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13060 "get_nss"},
13061
13062 {WE_GET_LDPC,
13063 0,
13064 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13065 "get_ldpc"},
13066
13067 {WE_GET_TX_STBC,
13068 0,
13069 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13070 "get_tx_stbc"},
13071
13072 {WE_GET_RX_STBC,
13073 0,
13074 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13075 "get_rx_stbc"},
13076
13077 {WE_GET_SHORT_GI,
13078 0,
13079 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13080 "get_shortgi"},
13081
13082 {WE_GET_RTSCTS,
13083 0,
13084 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13085 "get_rtscts"},
13086
13087 {WE_GET_CHWIDTH,
13088 0,
13089 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13090 "get_chwidth"},
13091
13092 {WE_GET_ANI_EN_DIS,
13093 0,
13094 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13095 "get_anienable"},
13096
13097 {WE_GET_ANI_POLL_PERIOD,
13098 0,
13099 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13100 "get_aniplen"},
13101
13102 {WE_GET_ANI_LISTEN_PERIOD,
13103 0,
13104 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13105 "get_anilislen"},
13106
13107 {WE_GET_ANI_OFDM_LEVEL,
13108 0,
13109 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13110 "get_aniofdmlvl"},
13111
13112 {WE_GET_ANI_CCK_LEVEL,
13113 0,
13114 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13115 "get_aniccklvl"},
13116
13117 {WE_GET_DYNAMIC_BW,
13118 0,
13119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13120 "get_cwmenable"},
13121
13122 {WE_GET_GTX_HT_MCS,
13123 0,
13124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13125 "get_gtxHTMcs"},
13126
13127 {WE_GET_GTX_VHT_MCS,
13128 0,
13129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13130 "get_gtxVHTMcs"},
13131
13132 {WE_GET_GTX_USRCFG,
13133 0,
13134 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13135 "get_gtxUsrCfg"},
13136
13137 {WE_GET_GTX_THRE,
13138 0,
13139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13140 "get_gtxThre"},
13141
13142 {WE_GET_GTX_MARGIN,
13143 0,
13144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13145 "get_gtxMargin"},
13146
13147 {WE_GET_GTX_STEP,
13148 0,
13149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13150 "get_gtxStep"},
13151
13152 {WE_GET_GTX_MINTPC,
13153 0,
13154 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13155 "get_gtxMinTpc"},
13156
13157 {WE_GET_GTX_BWMASK,
13158 0,
13159 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13160 "get_gtxBWMask"},
13161
13162 {WE_GET_TX_CHAINMASK,
13163 0,
13164 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13165 "get_txchainmask"},
13166
13167 {WE_GET_RX_CHAINMASK,
13168 0,
13169 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13170 "get_rxchainmask"},
13171
13172 {WE_GET_11N_RATE,
13173 0,
13174 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13175 "get_11nrate"},
13176
13177 {WE_GET_AMPDU,
13178 0,
13179 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13180 "get_ampdu"},
13181
13182 {WE_GET_AMSDU,
13183 0,
13184 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13185 "get_amsdu"},
13186
13187 {WE_GET_BURST_ENABLE,
13188 0,
13189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13190 "get_burst_en"},
13191
13192 {WE_GET_BURST_DUR,
13193 0,
13194 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13195 "get_burst_dur"},
13196
13197 {WE_GET_TXPOW_2G,
13198 0,
13199 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13200 "get_txpow2g"},
13201
13202 {WE_GET_TXPOW_5G,
13203 0,
13204 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13205 "get_txpow5g"},
13206
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013207 {WE_GET_PPS_PAID_MATCH,
13208 0,
13209 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13210 "get_paid_match"},
13211
13212 {WE_GET_PPS_GID_MATCH,
13213 0,
13214 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13215 "get_gid_match"},
13216
13217 {WE_GET_PPS_EARLY_TIM_CLEAR,
13218 0,
13219 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13220 "get_tim_clear"},
13221
13222 {WE_GET_PPS_EARLY_DTIM_CLEAR,
13223 0,
13224 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13225 "get_dtim_clear"},
13226
13227 {WE_GET_PPS_EOF_PAD_DELIM,
13228 0,
13229 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13230 "get_eof_delim"},
13231
13232 {WE_GET_PPS_MACADDR_MISMATCH,
13233 0,
13234 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13235 "get_mac_match"},
13236
13237 {WE_GET_PPS_DELIM_CRC_FAIL,
13238 0,
13239 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13240 "get_delim_fail"},
13241
13242 {WE_GET_PPS_GID_NSTS_ZERO,
13243 0,
13244 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13245 "get_nsts_zero"},
13246
13247 {WE_GET_PPS_RSSI_CHECK,
13248 0,
13249 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13250 "get_rssi_chk"},
13251
13252 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
13253 0,
13254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13255 "get_qpspollcnt"},
13256
13257 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
13258 0,
13259 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13260 "get_qtxwake"},
13261
13262 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13263 0,
13264 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13265 "get_qwakeintv"},
13266
13267 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13268 0,
13269 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13270 "get_qnodatapoll"},
13271
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013272 {WE_CAP_TSF,
13273 0,
13274 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13275 "cap_tsf"},
13276
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013277 {WE_GET_TEMPERATURE,
13278 0,
13279 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13280 "get_temp"},
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070013281 {WE_GET_DCM,
13282 0,
13283 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13284 "get_dcm"},
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070013285 {WE_GET_RANGE_EXT,
13286 0,
13287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13288 "get_range_ext"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013289 /* handlers for main ioctl */
13290 {WLAN_PRIV_SET_CHAR_GET_NONE,
13291 IW_PRIV_TYPE_CHAR | 512,
13292 0,
13293 ""},
13294
13295 /* handlers for sub-ioctl */
13296 {WE_WOWL_ADD_PTRN,
13297 IW_PRIV_TYPE_CHAR | 512,
13298 0,
13299 "wowlAddPtrn"},
13300
13301 {WE_WOWL_DEL_PTRN,
13302 IW_PRIV_TYPE_CHAR | 512,
13303 0,
13304 "wowlDelPtrn"},
13305
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013306 /* handlers for sub-ioctl */
13307 {WE_NEIGHBOR_REPORT_REQUEST,
13308 IW_PRIV_TYPE_CHAR | 512,
13309 0,
13310 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080013311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013312 {WE_SET_AP_WPS_IE,
13313 IW_PRIV_TYPE_CHAR | 512,
13314 0,
13315 "set_ap_wps_ie"},
13316
13317 {WE_SET_CONFIG,
13318 IW_PRIV_TYPE_CHAR | 512,
13319 0,
13320 "setConfig"},
13321
13322 /* handlers for main ioctl */
13323 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
13324 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13325 0,
13326 ""},
13327
13328 /* handlers for sub-ioctl */
13329 {WE_SET_WLAN_DBG,
13330 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13331 0,
13332 "setwlandbg"},
13333
13334 /* handlers for sub-ioctl */
13335 {WE_SET_DP_TRACE,
13336 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13337 0,
13338 "set_dp_trace"},
13339
13340 {WE_SET_SAP_CHANNELS,
13341 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13342 0,
13343 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013344
13345 {WE_SET_FW_TEST,
13346 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13347 0, "fw_test"},
13348
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013349 /* handlers for main ioctl */
13350 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
13351 0,
13352 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13353 "" },
13354 {WE_GET_TSF,
13355 0,
13356 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13357 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013358
13359 {WE_SET_DUAL_MAC_SCAN_CONFIG,
13360 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13361 0,
13362 "set_scan_cfg"},
13363
13364 /* handlers for main ioctl */
13365 {WLAN_PRIV_GET_CHAR_SET_NONE,
13366 0,
13367 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13368 ""},
13369
13370 /* handlers for sub-ioctl */
13371 {WE_WLAN_VERSION,
13372 0,
13373 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13374 "version"},
13375 {WE_GET_STATS,
13376 0,
13377 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13378 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080013379 {WE_GET_SUSPEND_RESUME_STATS,
13380 0,
13381 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13382 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053013383 {WE_LIST_FW_PROFILE,
13384 0,
13385 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13386 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013387 {WE_GET_STATES,
13388 0,
13389 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13390 "getHostStates"},
13391 {WE_GET_CFG,
13392 0,
13393 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13394 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013395 {WE_GET_RSSI,
13396 0,
13397 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13398 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013399 {WE_GET_WMM_STATUS,
13400 0,
13401 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13402 "getWmmStatus"},
13403 {
13404 WE_GET_CHANNEL_LIST,
13405 0,
13406 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13407 "getChannelList"
13408 },
13409#ifdef FEATURE_WLAN_TDLS
13410 {
13411 WE_GET_TDLS_PEERS,
13412 0,
13413 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13414 "getTdlsPeers"
13415 },
13416#endif
13417#ifdef WLAN_FEATURE_11W
13418 {
13419 WE_GET_11W_INFO,
13420 0,
13421 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13422 "getPMFInfo"
13423 },
13424#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013425 {
13426 WE_GET_IBSS_STA_INFO,
13427 0,
13428 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13429 "getIbssSTAs"
13430 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013431 {WE_GET_PHYMODE,
13432 0,
13433 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13434 "getphymode"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013435#if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013436 {WE_GET_OEM_DATA_CAP,
13437 0,
13438 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13439 "getOemDataCap"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013440#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013441 {WE_GET_SNR,
13442 0,
13443 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13444 "getSNR"},
13445
13446 /* handlers for main ioctl */
13447 {WLAN_PRIV_SET_NONE_GET_NONE,
13448 0,
13449 0,
13450 ""},
13451
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013452 /* handlers for sub-ioctl */
13453 {
13454 WE_IBSS_GET_PEER_INFO_ALL,
13455 0,
13456 0,
13457 "ibssPeerInfoAll"
13458 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013459 {WE_GET_RECOVERY_STAT,
13460 0,
13461 0,
13462 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053013463
13464 {WE_GET_FW_PROFILE_DATA,
13465 0,
13466 0,
13467 "getProfileData"},
13468
13469 {WE_SET_REASSOC_TRIGGER,
13470 0,
13471 0,
13472 "reassoc"},
13473
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080013474 {WE_STOP_OBSS_SCAN,
13475 0,
13476 0,
13477 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013478 /* handlers for main ioctl */
13479 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
13480 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13481 0,
13482 ""},
13483
13484 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013485 {WE_IBSS_GET_PEER_INFO,
13486 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13487 0,
13488 "ibssPeerInfo"},
13489
13490 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013491 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
13492 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13493 0,
13494 "setdumplog"},
13495
13496 {WE_MTRACE_DUMP_CMD,
13497 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13498 0,
13499 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080013500
13501 {WE_POLICY_MANAGER_CINFO_CMD,
13502 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13503 0,
13504 "pm_cinfo"},
13505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013506#ifdef MPC_UT_FRAMEWORK
13507 {WE_POLICY_MANAGER_CLIST_CMD,
13508 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13509 0,
13510 "pm_clist"},
13511
13512 {WE_POLICY_MANAGER_DLIST_CMD,
13513 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13514 0,
13515 "pm_dlist"},
13516
13517 {WE_POLICY_MANAGER_DBS_CMD,
13518 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13519 0,
13520 "pm_dbs"},
13521
13522 {WE_POLICY_MANAGER_PCL_CMD,
13523 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13524 0,
13525 "pm_pcl"},
13526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013527 {WE_POLICY_MANAGER_ULIST_CMD,
13528 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13529 0,
13530 "pm_ulist"},
13531
13532 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
13533 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13534 0,
13535 "pm_query_action"},
13536
13537 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
13538 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13539 0,
13540 "pm_query_allow"},
13541
13542 {WE_POLICY_MANAGER_SCENARIO_CMD,
13543 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13544 0,
13545 "pm_run_scenario"},
13546
13547 {WE_POLICY_SET_HW_MODE_CMD,
13548 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13549 0,
13550 "pm_set_hw_mode"},
13551#endif
13552#ifdef FEATURE_WLAN_TDLS
13553 /* handlers for sub ioctl */
13554 {
13555 WE_TDLS_CONFIG_PARAMS,
13556 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13557 0,
13558 "setTdlsConfig"
13559 },
13560#endif
13561 {
13562 WE_UNIT_TEST_CMD,
13563 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13564 0,
13565 "setUnitTestCmd"
13566 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053013567 {
13568 WE_MAC_PWR_DEBUG_CMD,
13569 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13570 0,
13571 "halPwrDebug"
13572 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013573
13574#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
13575 {WE_LED_FLASHING_PARAM,
13576 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13577 0,
13578 "gpio_control"},
13579#endif
13580 /* handlers for main ioctl */
13581 {WLAN_PRIV_ADD_TSPEC,
13582 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
13583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13584 "addTspec"},
13585
13586 /* handlers for main ioctl */
13587 {WLAN_PRIV_DEL_TSPEC,
13588 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13589 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13590 "delTspec"},
13591
13592 /* handlers for main ioctl */
13593 {WLAN_PRIV_GET_TSPEC,
13594 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13595 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13596 "getTspec"},
13597
13598 /* handlers for main ioctl - host offload */
13599 {
13600 WLAN_PRIV_SET_HOST_OFFLOAD,
13601 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
13602 0,
13603 "setHostOffload"
13604 }
13605 ,
13606
13607 {
13608 WLAN_GET_WLAN_STATISTICS,
13609 0,
13610 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
13611 "getWlanStats"
13612 }
13613 ,
13614
13615 {
13616 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053013617 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
13618 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013619 0,
13620 "setKeepAlive"
13621 }
13622 ,
13623#ifdef WLAN_FEATURE_PACKET_FILTERING
13624 {
13625 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053013626 IW_PRIV_TYPE_BYTE |
13627 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013628 0,
13629 "setPktFilter"
13630 }
13631 ,
13632#endif
13633#ifdef FEATURE_WLAN_SCAN_PNO
13634 {
13635 WLAN_SET_PNO,
13636 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13637 0,
13638 "setpno"
13639 }
13640 ,
13641#endif
13642 {
13643 WLAN_SET_BAND_CONFIG,
13644 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13645 0,
13646 "SETBAND"
13647 }
13648 ,
13649 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080013650 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080013651 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013652 0,
13653 "setMCBCFilter"
13654 }
13655 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013656
13657 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013658 WLAN_GET_LINK_SPEED,
13659 IW_PRIV_TYPE_CHAR | 18,
13660 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
13661 }
13662 ,
13663
13664 /* handlers for main ioctl */
13665 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
13666 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13667 0,
13668 ""}
13669 ,
13670 {WE_SET_SMPS_PARAM,
13671 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13672 0, "set_smps_param"}
13673 ,
13674 {WLAN_SET_DOT11P_CHANNEL_SCHED,
13675 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
13676 0, "set_dot11p" }
13677 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070013678#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013679 {WE_SET_FW_CRASH_INJECT,
13680 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13681 0, "crash_inject"}
13682 ,
13683#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070013684#ifdef WLAN_SUSPEND_RESUME_TEST
13685 {WE_SET_WLAN_SUSPEND,
13686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13687 0, "wlan_suspend"}
13688 ,
13689 {WE_SET_WLAN_RESUME,
13690 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13691 0, "wlan_resume"}
13692 ,
13693#endif
Govind Singha471e5e2015-10-12 17:11:14 +053013694 {WE_ENABLE_FW_PROFILE,
13695 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13696 0, "enableProfile"}
13697 ,
13698 {WE_SET_FW_PROFILE_HIST_INTVL,
13699 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13700 0, "set_hist_intvl"}
13701 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013702 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
13703 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13704 0, "set_fw_mode_cfg"}
13705 ,
13706 {WE_DUMP_DP_TRACE_LEVEL,
13707 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13708 0, "dump_dp_trace"}
13709 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070013710 {WE_SET_MON_MODE_CHAN,
13711 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13712 0, "setMonChan"}
13713 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070013714
13715 {WE_GET_ROAM_SYNCH_DELAY,
13716 0,
13717 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13718 "hostroamdelay"}
13719 ,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -080013720 {WE_SET_11AX_RATE,
13721 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13722 0,
13723 "set_11ax_rate"}
13724 ,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070013725 {WE_SET_DCM,
13726 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13727 0,
13728 "enable_dcm"}
13729 ,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070013730 {WE_SET_RANGE_EXT,
13731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13732 0,
13733 "enable_range_ext"}
13734 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013735};
13736
13737const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053013738 .num_standard = QDF_ARRAY_SIZE(we_handler),
13739 .num_private = QDF_ARRAY_SIZE(we_private),
13740 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013741
13742 .standard = (iw_handler *) we_handler,
13743 .private = (iw_handler *) we_private,
13744 .private_args = we_private_args,
13745 .get_wireless_stats = NULL,
13746};
13747
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013748/* hdd_set_wext() - configures bss parameters
13749 * @pAdapter: handle to adapter context
13750 *
13751 * Returns: none
13752 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070013753static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013754{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013755 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13756 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013757
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013758 ENTER();
13759
13760 if (!pwextBuf) {
13761 hdd_err("ERROR: pwextBuf is NULL");
13762 return QDF_STATUS_E_FAILURE;
13763 }
13764
13765 if (!pHddStaCtx) {
13766 hdd_err("ERROR: pHddStaCtx is NULL");
13767 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013768 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013769
13770 /* Now configure the roaming profile links. To SSID and bssid. */
13771 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013772 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013773
13774 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013775 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013776
13777 /*Set the numOfChannels to zero to scan all the channels */
13778 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
13779 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
13780
13781 /* Default is no encryption */
13782 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
13783 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
13784 eCSR_ENCRYPT_TYPE_NONE;
13785
13786 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
13787 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
13788 eCSR_ENCRYPT_TYPE_NONE;
13789
13790 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
13791
13792 /* Default is no authentication */
13793 pwextBuf->roamProfile.AuthType.numEntries = 1;
13794 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13795
13796 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
13797 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
13798
13799 /*Set the default scan mode */
13800 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
13801
13802 hdd_clear_roam_profile_ie(pAdapter);
13803
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013804 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013805 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013806
13807}
13808
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013809/**
13810 * hdd_register_wext() - register wext context
13811 * @dev: net device handle
13812 *
13813 * Registers wext interface context for a given net device
13814 *
13815 * Returns: 0 on success, errno on failure
13816 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013817int hdd_register_wext(struct net_device *dev)
13818{
13819 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013820 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053013821 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013822
13823 ENTER();
13824
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013825 if (!pwextBuf) {
13826 hdd_err(FL("ERROR: pwextBuf is NULL"));
13827 return QDF_STATUS_E_FAILURE;
13828 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013829
13830 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013831 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
13832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013833 status = hdd_set_wext(pAdapter);
13834
Anurag Chouhance0dc992016-02-16 18:18:03 +053013835 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013836
Jeff Johnson99bac312016-06-28 10:38:18 -070013837 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013838 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013839 }
13840
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013841 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070013842 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013843 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013844 }
13845
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013846 /* Register as a wireless device */
13847 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
13848
13849 EXIT();
13850 return 0;
13851}
13852
13853int hdd_unregister_wext(struct net_device *dev)
13854{
Jeff Johnson99bac312016-06-28 10:38:18 -070013855 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013856
13857 if (dev != NULL) {
13858 rtnl_lock();
13859 dev->wireless_handlers = NULL;
13860 rtnl_unlock();
13861 }
13862
13863 return 0;
13864}