blob: 9b3bd989b3f2a0babeea52f24f671944c1055606 [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"
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080083#include "wlan_policy_mgr_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084#include "wlan_hdd_conc_ut.h"
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
Srinivas Girigowdafba82a02017-03-24 21:26:35 -0700121#define FREQ_CHAN_MAP_TABLE_SIZE QDF_ARRAY_SIZE(freq_chan_map)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122
123/* Private ioctls and their sub-ioctls */
124#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
125#define WE_SET_11D_STATE 1
126#define WE_WOWL 2
127#define WE_SET_POWER 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530128/*
129 * <ioctl>
130 * setMaxAssoc - Sets the maximum number of associated stations
131 *
132 * @INPUT: 1 to 32
133 *
134 * @OUTPUT: None
135 *
136 * This IOTCL sets the maximum number of associated stations
137 *
138 * @E.g: iwpriv wlan0 setMaxAssoc <value>
139 *
140 * Supported Feature: STA
141 *
142 * Usage: Internal/External
143 *
144 * </ioctl>
145 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146#define WE_SET_MAX_ASSOC 4
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +0530147/*
148 * <ioctl>
149 * scan_diable - Disable scan
150 *
151 * @INPUT: set_value
152 *
153 * @OUTPUT: None
154 *
155 * This IOCTL is used to set disable scan
156 *
157 * @E.g: iwpriv wlan0 scan_disable 1
158 *
159 * Supported Feature: Scan
160 *
161 * Usage: Internal/External
162 *
163 * </ioctl>
164 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165#define WE_SET_SCAN_DISABLE 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530166/*
167 * <ioctl>
168 * inactivityTO - sets the timeout value for inactivity data while
169 * in power save mode
170 *
171 * @INPUT: int1…..int255
172 *
173 * @OUTPUT: None
174 *
175 * This IOCTL set the timeout value for inactivity data in power save mode
176 *
177 * @E.g: iwpriv wlan0 inactivityTO 20
178 *
179 * Supported Feature: STA
180 *
181 * Usage: Internal/External
182 *
183 * </ioctl>
184 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185#define WE_SET_DATA_INACTIVITY_TO 6
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530186/*
187 * <ioctl>
188 * setMaxTxPower - Dynamically sets the maximum transmission power
189 *
190 * @INPUT: Transmission power in dBm
191 *
192 * @OUTPUT: None
193 *
194 * This IOCTL dynamically sets the maximum transmission power
195 * This setting does not persist over reboots
196 *
197 * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
198 *
199 * Supported Feature: STA
200 *
201 * Usage: Internal/External
202 *
203 * </ioctl>
204 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205#define WE_SET_MAX_TX_POWER 7
206#define WE_SET_HIGHER_DTIM_TRANSITION 8
207#define WE_SET_TM_LEVEL 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530208/*
209 * <ioctl>
210 * setphymode - Set the phymode dynamically
211 *
212 * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
213 *
214 * @OUTPUT: None
215 *
216 * This IOCTL sets the phymode dynamically
217 *
218 * @E.g: iwpriv wlan0 setphymode 10
219 *
220 * Supported Feature: STA
221 *
222 * Usage: Internal/External
223 *
224 * </ioctl>
225 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226#define WE_SET_PHYMODE 10
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530227/*
228 * <ioctl>
229 * nss - Set the number of spatial streams
230 *
231 * @INPUT: int1…..int3
232 *
233 * @OUTPUT: None
234 *
235 * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
236 *
237 * @E.g: iwpriv wlan0 nss 2
238 *
239 * Supported Feature: STA
240 *
241 * Usage: Internal/External
242 *
243 * </ioctl>
244 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245#define WE_SET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530246/*
247 * <ioctl>
248 * ldpc - Enables or disables LDPC
249 *
250 * @INPUT: 0 – Disable, 1 - Enable
251 *
252 * @OUTPUT: None
253 *
254 * This IOCTL enables or disables LDPC
255 *
256 * @E.g: iwpriv wlan0 ldpc 1
257 *
258 * Supported Feature: STA
259 *
260 * Usage: Internal/External
261 *
262 * </ioctl>
263 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264#define WE_SET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530265/*
266 * <ioctl>
267 * tx_stbc - Enables or disables tx_stbc
268 *
269 * @INPUT: Int 0 – Disable, 1 - Enable
270 *
271 * @OUTPUT: None
272 *
273 * This IOTCL used to enables or disables tx_stbc
274 *
275 * @E.g: iwpriv wlan0 tx_stbc <value>
276 *
277 * Supported Feature: STA
278 *
279 * Usage: Internal/External
280 *
281 * </ioctl>
282 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283#define WE_SET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530284/*
285 * <ioctl>
286 * rx_stbc - Set the rx_stbc parameter
287 *
288 * @INPUT: Int 0 – Disable, 1 - Enable
289 *
290 * @OUTPUT: None
291 *
292 * This IOTCL used to set rx_stbc parameter
293 *
294 * @E.g: iwpriv wlan0 rx_stbc <value>
295 *
296 * Supported Feature: STA
297 *
298 * Usage: Internal/External
299 *
300 * </ioctl>
301 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302#define WE_SET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530303/*
304 * <ioctl>
305 * shortgi - Enables or disables a short-guard interval
306 *
307 * @INPUT: Int 0 – Disable, 1 - Enable
308 *
309 * @OUTPUT: None
310 *
311 * This IOCTL enables or disables a short-guard interval.
312 *
313 * @E.g: iwpriv wlan0 shortgi <value>
314 *
315 * Supported Feature: STA
316 *
317 * Usage: Internal/External
318 *
319 * </ioctl>
320 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321#define WE_SET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530322/*
323 * <ioctl>
324 * enablertscts - enables or disables rts/cts.
325 *
326 * @INPUT: 1-Enable , 0-Disable
327 *
328 * @OUTPUT: None
329 *
330 * This IOCTL enables or disables rts/cts.
331 *
332 * @E.g: iwpriv wlan0 enablertscts <value>
333 *
334 * Supported Feature: STA
335 *
336 * Usage: Internal/External
337 *
338 * </ioctl>
339 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340#define WE_SET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530341/*
342 * <ioctl>
343 * chwidth - Set the channel bandwidth
344 *
345 * @INPUT: 0-20mhz to 3-160mhz
346 *
347 * @OUTPUT: None
348 *
349 * This IOTCL used to set the channel bandwidth
350 *
351 * @E.g: iwpriv wlan0 chwidth 1
352 *
353 * Supported Feature: STA
354 *
355 * Usage: Internal/External
356 *
357 * </ioctl>
358 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359#define WE_SET_CHWIDTH 17
360#define WE_SET_ANI_EN_DIS 18
361#define WE_SET_ANI_POLL_PERIOD 19
362#define WE_SET_ANI_LISTEN_PERIOD 20
363#define WE_SET_ANI_OFDM_LEVEL 21
364#define WE_SET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530365/*
366 * <ioctl>
367 * cwmenable - Enables or disables the dynamic channel bandwidth
368 *
369 * @INPUT: 0-Disable, 1-Enable
370 *
371 * @OUTPUT: None
372 *
373 * This IOTCL used to enables or disables the dynamic channel bandwidth
374 *
375 * @E.g: iwpriv wlan0 cwmenable <value>
376 *
377 * Supported Feature: STA
378 *
379 * Usage: Internal/External
380 *
381 * </ioctl>
382 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383#define WE_SET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530384/*
385 * <ioctl>
386 * txchainmask - This IOCTL sets the current Tx chain mask
387 *
388 * @INPUT: Mask Value
389 *
390 * @OUTPUT: None
391 *
392 * This IOCTL sets the current Tx chain mask
393 *
394 * @E.g: iwpriv wlan0 txchainmask 1
395 *
396 * Supported Feature: STA
397 *
398 * Usage: Internal/External
399 *
400 * </ioctl>
401 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402#define WE_SET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530403/*
404 * <ioctl>
405 * rxchainmask - Sets the current Rx chain mask
406 *
407 * @INPUT: Mask Value
408 *
409 * @OUTPUT: None
410 *
411 * This IOCTL sets the current Rx chain mask. This command is the
412 * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
413 *
414 * @E.g: iwpriv wlan0 rxchainmask <value>
415 *
416 * Supported Feature: STA
417 *
418 * Usage: Internal/External
419 *
420 * </ioctl>
421 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422#define WE_SET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530423/*
424 * <ioctl>
425 * set11NRates - Fixes the Tx data rate of the 11N mode.
426 *
427 * @INPUT: 0x1b to 0x8f
428 *
429 * @OUTPUT: None
430 *
431 * This IOCTL fixes the Tx data rate of the 11N mode.
432 *
433 * @E.g: iwpriv wlan0 set11NRates 0x85
434 *
435 * Supported Feature: STA
436 *
437 * Usage: Internal/External
438 *
439 * </ioctl>
440 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441#define WE_SET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530442/*
443 * <ioctl>
444 * ampdu - Set the the maximum subframe of ampdu
445 *
446 * @INPUT: int 1 to int 63
447 *
448 * @OUTPUT: None
449 *
450 * This IOCTL sets the maximum subframe of ampdu.
451 *
452 * @E.g: iwpriv wlan0 ampdu 9
453 *
454 * Supported Feature: STA
455 *
456 * Usage: Internal/External
457 *
458 * </ioctl>
459 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460#define WE_SET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530461/*
462 * <ioctl>
463 * amsdu - Sets the maximum subframe of amsdu.
464 *
465 * @INPUT: int 1 to int 31
466 *
467 * @OUTPUT: None
468 *
469 * This IOCTL sets the maximum subframe of amsdu.
470 *
471 * @E.g: iwpriv wlan0 amsdu 9
472 *
473 * Supported Feature: STA
474 *
475 * Usage: Internal/External
476 *
477 * </ioctl>
478 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479#define WE_SET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530480/*
481 * <ioctl>
482 * txpow2g - current 2 GHz Tx power setting
483 *
484 * @INPUT: Tx power in dBm
485 *
486 * @OUTPUT: None
487 *
488 * This IOTCL used to set 2 ghz tx power
489 *
490 * @E.g: iwpriv wlan0 txpow2g
491 *
492 * Supported Feature: STA
493 *
494 * Usage: Internal/External
495 *
496 * </ioctl>
497 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498#define WE_SET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530499/*
500 * <ioctl>
501 * txpow5g - Current 5 GHz tx power setting
502 *
503 * @INPUT: Tx power in dBm
504 *
505 * @OUTPUT: None
506 *
507 * This IOTCL used to set the 5 ghz txpower
508 *
509 * @E.g: iwpriv wlan0 txpow5g
510 *
511 * Supported Feature: STA
512 *
513 * Usage: Internal/External
514 *
515 * </ioctl>
516 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517#define WE_SET_TXPOW_5G 30
518/* Private ioctl for firmware debug log */
519#define WE_DBGLOG_LOG_LEVEL 31
520#define WE_DBGLOG_VAP_ENABLE 32
521#define WE_DBGLOG_VAP_DISABLE 33
522#define WE_DBGLOG_MODULE_ENABLE 34
523#define WE_DBGLOG_MODULE_DISABLE 35
524#define WE_DBGLOG_MOD_LOG_LEVEL 36
525#define WE_DBGLOG_TYPE 37
526#define WE_SET_TXRX_FWSTATS 38
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530527/*
528 * <ioctl>
529 * set11ACRates - Fixes the Tx data rate of 11AC
530 *
531 * @INPUT: 0x1 to 0x9
532 *
533 * @OUTPUT: None
534 *
535 * This IOCTL fixes the Tx data rate of 11AC.
536 *
537 * @E.g: iwpriv wlan0 set11ACRates 0x9
538 *
539 * Supported Feature: STA
540 *
541 * Usage: Internal/External
542 *
543 * </ioctl>
544 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545#define WE_SET_VHT_RATE 39
546#define WE_DBGLOG_REPORT_ENABLE 40
547#define WE_TXRX_FWSTATS_RESET 41
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530548/*
549 * <ioctl>
550 * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
551 *
552 * @INPUT: Transmission power in dBm
553 *
554 * @OUTPUT: None
555 *
556 * This IOCTL sets the maximum transmit power for the 2.4-GHz band
557 * This setting does not persist over reboots
558 *
559 * @E.g: iwpriv wlan0 setTxMaxPower2G 10
560 *
561 * Supported Feature: STA
562 *
563 * Usage: Internal/External
564 *
565 * </ioctl>
566 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800567#define WE_SET_MAX_TX_POWER_2_4 42
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530568/*
569 * <ioctl>
570 * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
571 *
572 * @INPUT: Transmission power in dBm
573 *
574 * @OUTPUT: None
575 *
576 * This IOCTL sets the maximum transmit power for the 5-GHz band
577 * This setting does not persist over reboots
578 *
579 * @E.g: iwpriv wlan0 setTxMaxPower5G 10
580 *
581 * Supported Feature: STA
582 *
583 * Usage: Internal/External
584 *
585 * </ioctl>
586 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800587#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800588#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589/* Private ioctl for packet powe save */
590#define WE_PPS_PAID_MATCH 45
591#define WE_PPS_GID_MATCH 46
592#define WE_PPS_EARLY_TIM_CLEAR 47
593#define WE_PPS_EARLY_DTIM_CLEAR 48
594#define WE_PPS_EOF_PAD_DELIM 49
595#define WE_PPS_MACADDR_MISMATCH 50
596#define WE_PPS_DELIM_CRC_FAIL 51
597#define WE_PPS_GID_NSTS_ZERO 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530598/*
599 * <ioctl>
600 * rssi_chk - Chek the rssi
601 *
602 * @INPUT: One argument as input
603 *
604 * @OUTPUT: rssi
605 * wlan0 rssi_chk:56
606 *
607 * This IOTCL used to chek rssi
608 *
609 * @E.g: iwpriv wlan0 rssi_chk <value>
610 *
611 * Supported Feature: STA
612 *
613 * Usage: Internal/External
614 *
615 * </ioctl>
616 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617#define WE_PPS_RSSI_CHECK 53
618#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530619/*
620 * <ioctl>
621 * htsmps - Sets the htsmps
622 *
623 * @INPUT: Atleast one int argument
624 *
625 * @OUTPUT: None
626 *
627 * This IOTCL used to set htsmps
628 *
629 * @E.g: iwpriv wlan0 htsmps <value>
630 *
631 * Supported Feature: STA
632 *
633 * Usage: Internal/External
634 *
635 * </ioctl>
636 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637#define WE_SET_HTSMPS 55
638/* Private ioctl for QPower */
639#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
640#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
641#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
642#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530643/*
644 * <ioctl>
645 * burst_enable - Enables or disables the burst feature
646 *
647 * @INPUT: 0-Disable, 1-Enable
648 *
649 * @OUTPUT: None
650 *
651 * This IOCTL enables or disables the burst feature.
652 *
653 * @E.g: iwpriv wlan0 burst_enable 0
654 *
655 * Supported Feature: STA
656 *
657 * Usage: Internal/External
658 *
659 * </ioctl>
660 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661#define WE_SET_BURST_ENABLE 60
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530662/*
663 * <ioctl>
664 * burst_dur - Enables or disables the burst feature
665 *
666 * @INPUT: int 1…..int 8191 in microseconds
667 *
668 * @OUTPUT: None
669 *
670 * This IOCTL sets the burst duration.
671 *
672 * @E.g: iwpriv wlan0 burst_dur <value>
673 *
674 * Supported Feature: STA
675 *
676 * Usage: Internal/External
677 *
678 * </ioctl>
679 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680#define WE_SET_BURST_DUR 61
681/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530682/*
683 * <ioctl>
684 * gtxHTMcs - Set the tx HTM value
685 *
686 * @INPUT: Atleast one int orgument
687 *
688 * @OUTPUT: None
689 *
690 * This IOTCL sets htm tx value
691 *
692 * @E.g: iwpriv wlan0 gtxHTMcs <value>
693 *
694 * Supported Feature: STA
695 *
696 * Usage: Internal/External
697 *
698 * </ioctl>
699 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700#define WE_SET_GTX_HT_MCS 62
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530701/*
702 * <ioctl>
703 * gtxVHTMcs - Set gtxVHTMcs value
704 *
705 * @INPUT: Atleast one int argument
706 *
707 * @OUTPUT: None
708 *
709 * This IOTCL used to set gtxVHTMcs value
710 *
711 * @E.g: iwpriv wlan0 gtxVHTMcs <value>
712 *
713 * Supported Feature: STA
714 *
715 * Usage: Internal/External
716 *
717 * </ioctl>
718 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719#define WE_SET_GTX_VHT_MCS 63
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530720/*
721 * <ioctl>
722 * gtxUsrCfg - Host request for GTX mask
723 *
724 * @INPUT: Atleast one int orgument
725 *
726 * @OUTPUT: None
727 *
728 * This IOTCL used send the host request for GTX mask
729 *
730 * @E.g: iwpriv wlan0 gtxUsrCfg <value>
731 *
732 * Supported Feature: STA
733 *
734 * Usage: Internal/External
735 *
736 * </ioctl>
737 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738#define WE_SET_GTX_USRCFG 64
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530739/*
740 * <ioctl>
741 * gtxThre - Set the tx threshold
742 *
743 * @INPUT: Atleast one int argument
744 *
745 * @OUTPUT: None
746 *
747 * This IOTCL used to set tx threshold
748 *
749 * @E.g: iwpriv wlan0 gtxThre <value>
750 *
751 * Supported Feature: STA
752 *
753 * Usage: Internal/External
754 *
755 * </ioctl>
756 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757#define WE_SET_GTX_THRE 65
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530758/*
759 * <ioctl>
760 * gtxMargin - Set the gtxMargin
761 *
762 * @INPUT: 1 to 32
763 *
764 * @OUTPUT: None
765 *
766 * This IOTCL use dto set gtxMargin
767 *
768 * @E.g: iwpriv wlan0 gtxMargini <value>
769 *
770 * Supported Feature: STA
771 *
772 * Usage: Internal/External
773 *
774 * </ioctl>
775 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776#define WE_SET_GTX_MARGIN 66
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530777/*
778 * <ioctl>
779 * gtxStep - Set the gtxStep
780 *
781 * @INPUT: None
782 *
783 * @OUTPUT: None
784 *
785 * This IOTCL used to sets gtxStep
786 *
787 * @E.g: iwpriv wlan0 gtxStep <value>
788 *
789 * Supported Feature: STA
790 *
791 * Usage: Internal/External
792 *
793 * </ioctl>
794 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795#define WE_SET_GTX_STEP 67
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530796/*
797 * <ioctl>
798 * gtxMinTpc - Sets the gtxMinTpc
799 *
800 * @INPUT: Atleast one int argument
801 *
802 * @OUTPUT: None
803 *
804 * This IOTCL sets the tx MinTpc
805 *
806 * @E.g: iwpriv wlan0 gtxMinTpc <value>
807 *
808 * Supported Feature: STA
809 *
810 * Usage: Internal/External
811 *
812 * </ioctl>
813 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814#define WE_SET_GTX_MINTPC 68
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530815/*
816 * <ioctl>
817 * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
818 *
819 * @INPUT: Mask value
820 *
821 * @OUTPUT: None
822 *
823 * This IOTCL used to set gtxBWMask
824 *
825 * @E.g: iwpriv wlan0 gtxBWMask <value>
826 *
827 * Supported Feature: STA
828 *
829 * Usage: Internal/External
830 *
831 * </ioctl>
832 */
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530833
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530834#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530835/*
836 * <ioctl>
837 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
838 *
839 * @INPUT: set_value
840 *
841 * @OUTPUT: None
842 *
843 * This IOCTL is used to set the MCC latency value in milliseconds
844 * during STA-P2P concurrency.
845 *
846 * If 0ms latency is provided, then FW will set to a default.
847 * Otherwise, latency must be at least 30ms.
848 *
849 * @E.g: iwpriv wlan0 setMccLatency 40
850 *
851 *
852 * Supported Feature: Concurrency
853 *
854 * Usage: Internal/External
855 *
856 * </ioctl>
857 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530859
860/*
861 * <ioctl>
862 * setMccQuota- Set the quota for P2P cases
863 *
864 * @INPUT: set_value [0,100]
865 *
866 * @OUTPUT: None
867 *
868 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
869 *
870 * Currently used to set time quota for 2 MCC vdevs/adapters using
871 * (operating channel, quota) for each mode.
872 * The info is provided run time using iwpriv command:
873 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
874 * Note: the quota provided in command is for the same mode in cmd.
875 * HDD checks if MCC mode is active, gets the second mode and its
876 * operating chan.
877 * Quota for the 2nd role is calculated as 100 - quota of first mode.
878 *
879 * @E.g: iwpriv wlan0 setMccQuota 50
880 * iwpriv p2p0 setMccQuota 50
881 *
882 * Supported Feature: Concurrency
883 *
884 * Usage: Internal/External
885 *
886 * </ioctl>
887 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888#define WE_MCC_CONFIG_QUOTA 71
889/* Private IOCTL for debug connection issues */
890#define WE_SET_DEBUG_LOG 72
891#ifdef WE_SET_TX_POWER
892#undef WE_SET_TX_POWER
893#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530894/*
895 * <ioctl>
896 * setTxPower - Set the current transmit power
897 *
898 * @INPUT: Transmission power in dBm
899 *
900 * @OUTPUT: None
901 *
902 * This IOCTL sets the current transmit power.
903 * This setting does not persist over reboots.
904 *
905 * @E.g: iwpriv wlan0 setTxPower 10
906 *
907 * Supported Feature: STA
908 *
909 * Usage: Internal/External
910 *
911 * </ioctl>
912 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913#define WE_SET_TX_POWER 74
914/* Private ioctl for earlyrx power save feature */
915#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
916#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
917#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
918#define WE_SET_EARLY_RX_SLOP_STEP 78
919#define WE_SET_EARLY_RX_INIT_SLOP 79
920#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530921/*
922 * <ioctl>
923 * setMcRate - Set the data rate for multicast data
924 *
925 * @INPUT: 1 to 32
926 *
927 * @OUTPUT: None
928 *
929 * This IOCTL sets the data rate for multicast data. Note that this command
930 * is allowed only in STA, IBSS, or QCMobileAP mode
931 *
932 * @E.g: iwpriv wlan0 setMcRate <value>
933 *
934 * Supported Feature: STA
935 *
936 * Usage: Internal/External
937 *
938 * </ioctl>
939 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940#define WE_SET_MC_RATE 81
941#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
942/* Private ioctl for packet power save */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530943/*
944 * <ioctl>
945 * 5g_ebt - Sets the 5g_ebt
946 *
947 * @INPUT: <value>
948 *
949 * @OUTPUT: None
950 *
951 * This IOTCL used to set 5g_ebt
952 *
953 * @E.g: iwpriv wlan0 5g_ebt <value>
954 *
955 * Supported Feature: STA
956 *
957 * Usage: Internal/External
958 *
959 * </ioctl>
960 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961#define WE_PPS_5G_EBT 83
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530962/*
963 * <ioctl>
964 * cts_cbw - Set CTS channel BW for dynamic BW adjustment
965 *
966 * @INPUT: 20 t0 160
967 *
968 * @OUTPUT: None
969 *
970 * This IOTCL used to set CTS channel BW for dynamic BW adjustment
971 *
972 * @E.g: iwpriv wlan0 cts_cbw <value>
973 *
974 * Supported Feature: STA
975 *
976 * Usage: Internal/External
977 *
978 * </ioctl>
979 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980#define WE_SET_CTS_CBW 84
981#define WE_DUMP_STATS 85
982#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530983/* Private sub ioctl for starting/stopping the profiling */
984#define WE_START_FW_PROFILE 87
Abhishek Singh3c507012016-12-01 11:15:42 +0530985/*
986 * <ioctl>
987 * setChanChange - Initiate channel change
988 *
989 * @INPUT: channel number to switch to.
990 *
991 * @OUTPUT: None
992 *
993 * This IOCTL is used to initiate a channel change.
994 * If called on STA/CLI interface it will send the
995 * ECSA action frame to the connected SAP/GO asking to
996 * initiate the ECSA, if supported.
997 * If called on SAP/GO interface it will initiate
998 * ECSA and ask connected peers to move to new channel.
999 *
1000 * @E.g: iwpriv wlan0 setChanChange <channel>
1001 * iwpriv wlan0 setChanChange 1
1002 *
1003 * Supported Feature: ECSA
1004 *
1005 * Usage: Internal/External
1006 *
1007 * </ioctl>
1008 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +05301009#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05301010#define WE_SET_CONC_SYSTEM_PREF 89
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08001011#define WE_SET_TXRX_STATS 90
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08001013/*
1014 * <ioctl>
1015 * set_11ax_rate - set 11ax rates to FW
1016 *
1017 * @INPUT: rate code
1018 *
1019 * @OUTPUT: None
1020 *
1021 * This IOCTL fixes the Tx data rate of 11AX.
1022 *
1023 * @E.g: iwpriv wlan0 set_11ax_rate <rate code>
1024 *
1025 * Supported Feature: STA/SAP
1026 *
1027 * Usage: Internal
1028 *
1029 * </ioctl>
1030 */
1031#define WE_SET_11AX_RATE 91
1032
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001033/*
1034 * <ioctl>
1035 * enable_dcm - enable Dual Carrier Modulation(DCM)
1036 *
1037 * @INPUT: 0/1
1038 *
1039 * @OUTPUT: None
1040 *
1041 * This IOCTL enables/disables DCM.
1042 *
1043 * @E.g: iwpriv wlan0 enable_dcm <0/1>
1044 *
1045 * Supported Feature: STA/SAP
1046 *
1047 * Usage: Internal
1048 *
1049 * </ioctl>
1050 */
1051#define WE_SET_DCM 92
1052
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001053/*
1054 * <ioctl>
1055 * enable_range_ext - enable Range extension
1056 *
1057 * @INPUT: 0/1
1058 *
1059 * @OUTPUT: None
1060 *
1061 * This IOCTL enables/disables Range extension.
1062 *
1063 * @E.g: iwpriv wlan0 enable_range_ext <0/1>
1064 *
1065 * Supported Feature: STA/SAP
1066 *
1067 * Usage: Internal
1068 *
1069 * </ioctl>
1070 */
1071#define WE_SET_RANGE_EXT 93
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073/* Private ioctls and their sub-ioctls */
1074#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
1075#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076#define WE_SET_SAP_CHANNELS 3
1077#define WE_GET_WLAN_DBG 4
1078#define WE_GET_MAX_ASSOC 6
1079/* 7 is unused */
1080#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +05301081
1082/*
1083 * <ioctl>
1084 * getconcurrency - Get concurrency mode
1085 *
1086 * @INPUT: None
1087 *
1088 * @OUTPUT: It shows concurrency value
1089 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
1090 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
1091 * 8:OCB 9:EPPING 10:QVIT 11:NDI
1092 *
1093 * This IOCTL is used to retrieve concurrency mode.
1094 *
1095 * @E.g: iwpriv wlan0 getconcurrency
1096 * wlan0 getconcurrency:5
1097 * Above value shows STA+P2P_Client
1098 *
1099 * Supported Feature: Concurrency
1100 *
1101 * Usage: Internal/External
1102 *
1103 * </ioctl>
1104 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105#define WE_GET_CONCURRENCY_MODE 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301106/*
1107 * <ioctl>
1108 * get_nss - Get the number of spatial STBC streams (NSS)
1109 *
1110 * @INPUT: None
1111 *
1112 * @OUTPUT: NSS
1113 * wlan0 get_nss:2
1114 *
1115 * This IOTCL used to get the number of spatial STBC streams
1116 *
1117 * @E.g: iwpriv wlan0 get_nss
1118 *
1119 * Supported Feature: STA
1120 *
1121 * Usage: Internal/External
1122 *
1123 * </ioctl>
1124 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001125#define WE_GET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301126/*
1127 * <ioctl>
1128 * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1129 *
1130 * @INPUT: None
1131 *
1132 * @OUTPUT: ldpc
1133 * wlan0 get_ldpc:1
1134 *
1135 * This IOTCL used to gets the low density parity check (LDPC)
1136 *
1137 * @E.g: iwpriv wlan0 get_ldpc
1138 *
1139 * Supported Feature: STA
1140 *
1141 * Usage: Internal/External
1142 *
1143 * </ioctl>
1144 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145#define WE_GET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301146/*
1147 * <ioctl>
1148 * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1149 *
1150 * @INPUT: None
1151 *
1152 * @OUTPUT: TXSTBC
1153 * wlan0 get_tx_stbc:1
1154 *
1155 * This IOTCL get the value of the current Tx space time block code (STBC)
1156 *
1157 * @E.g: iwpriv wlan0 get_tx_stbc
1158 *
1159 * Supported Feature: STA
1160 *
1161 * Usage: Internal/External
1162 *
1163 * </ioctl>
1164 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001165#define WE_GET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301166/*
1167 * <ioctl>
1168 * get_rx_stbc - Gets the value of the current Rx STBC
1169 *
1170 * @INPUT: None
1171 *
1172 * @OUTPUT: Rx STBC
1173 * wlan0 get_rx_stbc:1
1174 *
1175 * This IOTCL used to get the value of the current Rx STBC
1176 *
1177 * @E.g: iwpriv wlan0 get_rx_stbc
1178 *
1179 * Supported Feature: STA
1180 *
1181 * Usage: Internal/External
1182 *
1183 * </ioctl>
1184 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001185#define WE_GET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301186/*
1187 * <ioctl>
1188 * get_shortgi - Get the value of the current short GI setting
1189 *
1190 * @INPUT: None
1191 *
1192 * @OUTPUT: Enable/disable of shortgi
1193 * wlan0 get_shortgi:1
1194 *
1195 * This IOCTL gets the value of the current short GI setting
1196 *
1197 * @E.g: iwpriv wlan0 get_shortgi
1198 *
1199 * Supported Feature: STA
1200 *
1201 * Usage: Internal/External
1202 *
1203 * </ioctl>
1204 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205#define WE_GET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301206/*
1207 * <ioctl>
1208 * get_rtscts - Get the value of the current RTS/CTS setting.
1209 *
1210 * @INPUT: None
1211 *
1212 * @OUTPUT: Enable/disable of RTS/CTS
1213 * wlan0 get_rtscts:33
1214 *
1215 * This IOTCL get the value of the current RTS/CTS setting.
1216 *
1217 * @E.g: iwpriv wlan0 get_rtscts
1218 *
1219 * Supported Feature: STA
1220 *
1221 * Usage: Internal/External
1222 *
1223 * </ioctl>
1224 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225#define WE_GET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301226/*
1227 * <ioctl>
1228 * get_chwidth - Get the current channel width setting
1229 *
1230 * @INPUT: None
1231 *
1232 * @OUTPUT: channel width
1233 * wlan0 get_chwidth:0
1234 *
1235 * This IOTCL get the current channel width setting.
1236 *
1237 * @E.g: iwpriv wlan0 get_chwidth
1238 *
1239 * Supported Feature: STA
1240 *
1241 * Usage: Internal/External
1242 *
1243 * </ioctl>
1244 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245#define WE_GET_CHWIDTH 17
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301246/*
1247 * <ioctl>
1248 * get_anienable - Get the anienable
1249 *
1250 * @INPUT: None
1251 *
1252 * @OUTPUT:
1253 * wlan0 get_anienable:0
1254 *
1255 * This IOTCL get the anienable
1256 *
1257 * @E.g: iwpriv wlan0 get_anienable
1258 *
1259 * Supported Feature: STA
1260 *
1261 * Usage: Internal/External
1262 *
1263 * </ioctl>
1264 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265#define WE_GET_ANI_EN_DIS 18
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301266/*
1267 * <ioctl>
1268 * get_aniplen - Get the aniplen
1269 *
1270 * @INPUT: None
1271 *
1272 * @OUTPUT:
1273 * wlan0 get_aniplen:0
1274 *
1275 * This IOTCL get the aniplen
1276 *
1277 * @E.g: iwpriv wlan0 get_aniplen
1278 *
1279 * Supported Feature: STA
1280 *
1281 * Usage: Internal/External
1282 *
1283 * </ioctl>
1284 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285#define WE_GET_ANI_POLL_PERIOD 19
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301286/*
1287 * <ioctl>
1288 * get_anilislen- Get the anilislen
1289 *
1290 * @INPUT: None
1291 *
1292 * @OUTPUT:
1293 * wlan0 get_anilislen:0
1294 *
1295 * This IOTCL used to get anilislen
1296 *
1297 * @E.g: iwpriv wlan0 get_anilislen
1298 *
1299 * Supported Feature: STA
1300 *
1301 * Usage: Internal/External
1302 *
1303 * </ioctl>
1304 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305#define WE_GET_ANI_LISTEN_PERIOD 20
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301306/*
1307 * <ioctl>
1308 * get_aniofdmlvl - Get the OFDM level
1309 *
1310 * @INPUT: None
1311 *
1312 * @OUTPUT: OFDM
1313 * wlan0 get_aniofdmlvl:0
1314 *
1315 * This IOTCL used to get ofdm level
1316 *
1317 * @E.g: iwpriv wlan0 get_aniofdmlvl
1318 *
1319 * Supported Feature: STA
1320 *
1321 * Usage: Internal/External
1322 *
1323 * </ioctl>
1324 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325#define WE_GET_ANI_OFDM_LEVEL 21
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301326/*
1327 * <ioctl>
1328 * get_aniccklvl - Get the cck level
1329 *
1330 * @INPUT: None
1331 *
1332 * @OUTPUT:
1333 * wlan0 get_aniccklvl:0
1334 *
1335 * This IOTCL used to get cck level
1336 *
1337 * @E.g: iwpriv wlan0 get_aniccklvl
1338 *
1339 * Supported Feature: STA
1340 *
1341 * Usage: Internal/External
1342 *
1343 * </ioctl>
1344 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345#define WE_GET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301346/*
1347 * <ioctl>
1348 * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1349 *
1350 * @INPUT: None
1351 *
1352 * @OUTPUT: Enable/disable dynamic channel bandwidth
1353 * wlan0 get_cwmenable:0
1354 *
1355 * This IOTCL get the value of the dynamic channel bandwidth setting
1356 *
1357 * @E.g: iwpriv wlan0 get_cwmenable
1358 *
1359 * Supported Feature: STA
1360 *
1361 * Usage: Internal/External
1362 *
1363 * </ioctl>
1364 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365#define WE_GET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301366/*
1367 * <ioctl>
1368 * get_txchainmask - Get the txchainmask that was set
1369 *
1370 * @INPUT: None
1371 *
1372 * @OUTPUT: txchainmask
1373 * wlan0 get_txchainmask:1
1374 *
1375 * This IOCTL gets the txchainmask that was set
1376 * This command is useful if it was previously set
1377 *
1378 * @E.g: iwpriv wlan0 get_txchainmask
1379 *
1380 * Supported Feature: STA
1381 *
1382 * Usage: Internal/External
1383 *
1384 * </ioctl>
1385 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386#define WE_GET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301387/*
1388 * <ioctl>
1389 * get_rxchainmask - Get the rxchainmask that was set
1390 *
1391 * @INPUT: None
1392 *
1393 * @OUTPUT: rxchainmask
1394 * wlan0 get_rxchainmask:1
1395 *
1396 * This IOCTL gets the rxchainmask that was set
1397 * This command is useful only if it was previously set.
1398 *
1399 * @E.g: iwpriv wlan0 get_rxchainmask
1400 *
1401 * Supported Feature: STA
1402 *
1403 * Usage: Internal/External
1404 *
1405 * </ioctl>
1406 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407#define WE_GET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301408/*
1409 * <ioctl>
1410 * get_11nrate - Get the fixed Tx data rate
1411 *
1412 * @INPUT: None
1413 *
1414 * @OUTPUT: Using this command does not return the same value as set
1415 * wlan0 get_11nrate:0
1416 *
1417 * This IOCTL gets the fixed Tx data rate
1418 * This command is useful only if setting the fixed Tx rate.
1419 *
1420 * @E.g: iwpriv wlan0 get_11nrate
1421 *
1422 * Supported Feature: STA
1423 *
1424 * Usage: Internal/External
1425 *
1426 * </ioctl>
1427 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428#define WE_GET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301429/*
1430 * <ioctl>
1431 * get_ampdu - Get the maximum subframe of ampdu
1432 *
1433 * @INPUT: None
1434 *
1435 * @OUTPUT: Maximum subframe of ampdu
1436 * wlan0 get_ampdu:1
1437 *
1438 * This IOCTL gets the maximum subframe of ampdu
1439 * This command is useful only if setting ampdu.
1440 *
1441 * @E.g: iwpriv wlan0 get_ampdu
1442 *
1443 * Supported Feature: STA
1444 *
1445 * Usage: Internal/External
1446 *
1447 * </ioctl>
1448 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449#define WE_GET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301450/*
1451 * <ioctl>
1452 * get_amsdu - Get the maximum subframe of amsdu
1453 *
1454 * @INPUT: None
1455 *
1456 * @OUTPUT: Maximum subframe of amsdu
1457 * wlan0 get_amsdu:1
1458 *
1459 * This IOCTL gets the maximum subframe of amsdu.
1460 * This command is useful only if setting amsdu
1461 *
1462 * @E.g: iwpriv wlan0 get_amsdu
1463 *
1464 * Supported Feature: STA
1465 *
1466 * Usage: Internal/External
1467 *
1468 * </ioctl>
1469 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470#define WE_GET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301471/*
1472 * <ioctl>
1473 * get_txpow2g - Get the current 2 GHz Tx power setting
1474 *
1475 * @INPUT: None
1476 *
1477 * @OUTPUT: Tx Power in dbm
1478 * wlan0 get_txpow2g:0
1479 *
1480 * This IOCTL gets the current 2 GHz Tx power setting
1481 * This command is useful if setting Tx power
1482 *
1483 * @E.g: iwpriv wlan0 get_txpow2g
1484 *
1485 * Supported Feature: STA
1486 *
1487 * Usage: Internal/External
1488 *
1489 * </ioctl>
1490 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491#define WE_GET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301492/*
1493 * <ioctl>
1494 * get_txpow5g - Get the current 5 GHz Tx power setting
1495 *
1496 * @INPUT: None
1497 *
1498 * @OUTPUT: Tx Power in dbm
1499 * wlan0 get_txpow5g:0
1500 *
1501 * This IOCTL gets the current 5 GHz Tx power setting
1502 * This command is useful if setting Tx power
1503 *
1504 * @E.g: iwpriv wlan0 get_txpow5g
1505 *
1506 * Supported Feature: STA
1507 *
1508 * Usage: Internal/External
1509 *
1510 * </ioctl>
1511 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -08001513/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514#define WE_GET_PPS_PAID_MATCH 32
1515#define WE_GET_PPS_GID_MATCH 33
1516#define WE_GET_PPS_EARLY_TIM_CLEAR 34
1517#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
1518#define WE_GET_PPS_EOF_PAD_DELIM 36
1519#define WE_GET_PPS_MACADDR_MISMATCH 37
1520#define WE_GET_PPS_DELIM_CRC_FAIL 38
1521#define WE_GET_PPS_GID_NSTS_ZERO 39
1522#define WE_GET_PPS_RSSI_CHECK 40
1523/* Private ioctl for QPower */
1524#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
1525#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
1526#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
1527#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301528/*
1529 * <ioctl>
1530 * get_burst_en - Enables or disables the burst feature
1531 *
1532 * @INPUT: None
1533 *
1534 * @OUTPUT: Enable/disable of burst feature
1535 * wlan0 get_burst_en:1
1536 *
1537 * This IOCTL enables or disables the burst feature
1538 *
1539 * @E.g: iwpriv wlan0 get_burst_en
1540 *
1541 * Supported Feature:STA
1542 *
1543 * Usage: Internal/External
1544 *
1545 * </ioctl>
1546 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547#define WE_GET_BURST_ENABLE 45
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301548/*
1549 * <ioctl>
1550 * get_burst_dur - Get the burst duration
1551 *
1552 * @INPUT: None
1553 *
1554 * @OUTPUT: Duration in microseconds
1555 * wlan0 get_burst_dur:8160
1556 *
1557 * This IOCTL gets the burst duration
1558 * This command is useful if setting burst enable
1559 *
1560 * @E.g: iwpriv wlan0 get_burst_dur
1561 *
1562 * Supported Feature: STA
1563 *
1564 * Usage: Internal/External
1565 *
1566 * </ioctl>
1567 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568#define WE_GET_BURST_DUR 46
1569/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301570/*
1571 * <ioctl>
1572 * get_gtxHTMcs - Get the tx HTM
1573 *
1574 * @INPUT: None
1575 *
1576 * @OUTPUT: HTM
1577 * wlan0 get_gtxHTMcs:32896
1578 *
1579 * This IOTCL used to get HTM
1580 *
1581 * @E.g: iwpriv wlan0 get_gtxHTMcs
1582 *
1583 * Supported Feature: STA
1584 *
1585 * Usage: Internal/External
1586 *
1587 * </ioctl>
1588 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589#define WE_GET_GTX_HT_MCS 47
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301590/*
1591 * <ioctl>
1592 * get_gtxVHTMcs - Get the VHTM
1593 *
1594 * @INPUT: None
1595 *
1596 * @OUTPUT: VHTM
1597 * wlan0 get_gtxVHTMcs:524800
1598 *
1599 * This IOTCL used to get the VHTM
1600 *
1601 * @E.g: iwpriv wlan0 get_gtxVHTMcs
1602 *
1603 * Supported Feature: STA
1604 *
1605 * Usage: Internal/External
1606 *
1607 * </ioctl>
1608 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609#define WE_GET_GTX_VHT_MCS 48
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301610/*
1611 * <ioctl>
1612 * get_gtxUsrCfg - Get the tx cfg
1613 *
1614 * @INPUT: None
1615 *
1616 * @OUTPUT: TXCFG
1617 * wlan0 get_gtxUsrCfg:32
1618 *
1619 * This IOTCL used to get the tx cfg
1620 *
1621 * @E.g: iwpriv wlan0 get_gtxUsrCfg
1622 *
1623 * Supported Feature: STA
1624 *
1625 * Usage: Internal/External
1626 *
1627 * </ioctl>
1628 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629#define WE_GET_GTX_USRCFG 49
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301630/*
1631 * <ioctl>
1632 * get_gtxThre - Get the tx threshold
1633 *
1634 * @INPUT: None
1635 *
1636 * @OUTPUT: Threshold
1637 * wlan0 get_gtxThre:3
1638 *
1639 * This IOCTL is used to get tx threshold
1640 *
1641 * @E.g: iwpriv wlan0 get_gtxThre
1642 *
1643 * Supported Feature: STA
1644 *
1645 * Usage: Internal/External
1646 *
1647 * </ioctl>
1648 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649#define WE_GET_GTX_THRE 50
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301650/*
1651 * <ioctl>
1652 * get_gtxMargin - Get the tx margin
1653 *
1654 * @INPUT: None
1655 *
1656 * @OUTPUT: GTXMARGIN
1657 * wlan0 get_gtxMargin:2
1658 *
1659 * This IOCTL is used to set tx margin
1660 *
1661 * @E.g: iwpriv wlan0 get_gtxMargin
1662 *
1663 * Supported Feature: STA
1664 *
1665 * Usage: Internal/External
1666 *
1667 * </ioctl>
1668 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669#define WE_GET_GTX_MARGIN 51
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301670/*
1671 * <ioctl>
1672 * get_gtxStep - Get the tx step
1673 *
1674 * @INPUT: None
1675 *
1676 * @OUTPUT: GTXSTEP
1677 * wlan0 get_gtxStep:0
1678 *
1679 * This IOCTL is used to get the gtx step
1680 *
1681 * @E.g: iwpriv wlan0 get_gtxStep
1682 *
1683 * Supported Feature: STA
1684 *
1685 * Usage: Internal/External
1686 *
1687 * </ioctl>
1688 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689#define WE_GET_GTX_STEP 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301690/*
1691 * <ioctl>
1692 * get_gtxMinTpc - Get the tx miminum tpc
1693 *
1694 * @INPUT: None
1695 *
1696 * @OUTPUT: TPC
1697 * wlan0 get_gtxMinTpc:0
1698 *
1699 * This IOCTL is used to get tx miminum tpc
1700 *
1701 * @E.g: iwpriv wlan0 get_gtxMinTpc
1702 *
1703 * Supported Feature: STA
1704 *
1705 * Usage: Internal/External
1706 *
1707 * </ioctl>
1708 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709#define WE_GET_GTX_MINTPC 53
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301710/*
1711 * <ioctl>
1712 * get_gtxBWMask - Get the tx BW MASK
1713 *
1714 * @INPUT: None
1715 *
1716 * @OUTPUT: MASK
1717 * wlan0 get_gtxBWMask:15
1718 *
1719 * This IOCTL is used get gtx bw mask
1720 *
1721 * @E.g: iwpriv wlan0 get_gtxBWMask
1722 *
1723 * Supported Feature: STA
1724 *
1725 * Usage: Internal/External
1726 *
1727 * </ioctl>
1728 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729#define WE_GET_GTX_BWMASK 54
1730#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001731#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07001732#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001734/*
1735 * <ioctl>
1736 * get_dcm - Get dcm enablement value
1737 *
1738 * @INPUT: None
1739 *
1740 * @OUTPUT: 0/1
1741 * wlan0 get_dcm
1742 *
1743 * This IOCTL is used get dcm value
1744 *
1745 * Supported Feature: STA/SAP
1746 *
1747 * Usage: Internal
1748 *
1749 * </ioctl>
1750 */
1751#define WE_GET_DCM 60
1752
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001753/*
1754 * <ioctl>
1755 * get_dcm - Get range extension enablement value
1756 *
1757 * @INPUT: None
1758 *
1759 * @OUTPUT: 0/1
1760 * wlan0 get_range_ext
1761 *
1762 * This IOCTL is used get range_extension value
1763 *
1764 * Supported Feature: STA/SAP
1765 *
1766 * Usage: Internal
1767 *
1768 * </ioctl>
1769 */
1770#define WE_GET_RANGE_EXT 61
1771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772/* Private ioctls and their sub-ioctls */
1773#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
1774
1775/* Private ioctls and their sub-ioctls */
1776#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
1777#define WE_WOWL_ADD_PTRN 1
1778#define WE_WOWL_DEL_PTRN 2
Sreelakshmi Konamkided64d72017-02-23 10:39:26 +05301779/*
1780 * <ioctl>
1781 * neighbor - Send neighbor report request
1782 *
1783 * @INPUT: string
1784 *
1785 * @OUTPUT: None
1786 *
1787 * This IOCTL create a Neighbor report request and send it to peer
1788 *
1789 * @E.g: iwpriv wlan0 neighbor "SSID"
1790 *
1791 * Supported Feature: 11k
1792 *
1793 * Usage: Internal/External
1794 *
1795 * </ioctl>
1796 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797#define WE_NEIGHBOR_REPORT_REQUEST 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301798/*
1799 * <ioctl>
1800 * set_ap_wps_ie - Set the P2P IE of the probe response
1801 *
1802 * @INPUT: string
1803 *
1804 * @OUTPUT: None
1805 *
1806 * This IOCTL sets the P2P IE of the probe response
1807 *
1808 * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1809 *
1810 * Supported Feature: STA
1811 *
1812 * Usage: Internal/External
1813 *
1814 * </ioctl>
1815 */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07001816#define WE_SET_AP_WPS_IE 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817#define WE_SET_CONFIG 5
1818
1819/* Private ioctls and their sub-ioctls */
1820#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
1821#define WE_SET_WLAN_DBG 1
1822#define WE_SET_DP_TRACE 2
1823#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05301824#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825
1826/* Private ioctls and their sub-ioctls */
1827#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
1828#define WE_WLAN_VERSION 1
1829#define WE_GET_STATS 2
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301830/*
1831 * <ioctl>
1832 * getConfig - gets the values of all configurations listed in WCNSS
1833 *
1834 * @INPUT: None
1835 *
1836 * @OUTPUT: Current configuration to the sys log
1837 * wlan0 getConfig: WLAN configuration written to system log
1838 *
1839 * This IOCTL gets the values of all configurations listed in WCNSS
1840 *
1841 * @E.g: iwpriv wlan0 getConfig
1842 *
1843 * Supported Feature: STA
1844 *
1845 * Usage: Internal/External
1846 *
1847 * </ioctl>
1848 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849#define WE_GET_CFG 3
1850#define WE_GET_WMM_STATUS 4
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301851/*
1852 * <ioctl>
1853 * getChannelList - Get the available channel list while in QCMobileAP
1854 *
1855 * @INPUT: None
1856 *
1857 * @OUTPUT: Channel list
1858 * wlan0 getChannelList:36 US 1..165
1859 *
1860 * This IOCTL gets the available channel list while in QCMobileAP
1861 *
1862 * @E.g: iwpriv wlan0 getChannelList
1863 *
1864 * Supported Feature: STA
1865 *
1866 * Usage: Internal/External
1867 *
1868 * </ioctl>
1869 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870#define WE_GET_CHANNEL_LIST 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301871/*
1872 * <ioctl>
1873 * getRSSI - Get the Received Signal Strength Indicator
1874 *
1875 * @INPUT: None
1876 *
1877 * @OUTPUT: RSSI
1878 * wlan0 getRSSI:rsssi=-32
1879 *
1880 * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1881 *
1882 * @E.g: iwpriv wlan0 getRSSI
1883 *
1884 * Supported Feature: STA
1885 *
1886 * Usage: Internal/External
1887 *
1888 * </ioctl>
1889 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -08001891
1892/*
1893 * <ioctl>
1894 * getSuspendStats - Get suspend/resume stats
1895 *
1896 * @INPUT: None
1897 *
1898 * @OUTPUT: character string containing formatted suspend/resume stats
1899 *
1900 * This ioctl is used to get suspend/resume stats formatted for display.
1901 * Currently it includes suspend/resume counts, wow wake up reasons, and
1902 * suspend fail reasons.
1903 *
1904 * @E.g: iwpriv wlan0 getSuspendStats
1905 * iwpriv wlan0 getSuspendStats
1906 *
1907 * Supported Feature: suspend/resume
1908 *
1909 * Usage: Internal
1910 *
1911 * </ioctl>
1912 */
1913#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05301915/*
1916 * <ioctl>
1917 * getTdlsPeers - Get all TDLS peers.
1918 *
1919 * @INPUT: None
1920 *
1921 * @OUTPUT: Returns the MAC address of all the TDLS peers
1922 * wlan0 getTdlsPeers:
1923 * MAC Id cap up RSSI
1924 * ---------------------------------
1925 * 00:0a:f5:0e:bd:18 2 Y Y -44
1926 * 00:0a:f5:bf:0e:12 0 N N 0
1927 *
1928 * This IOCTL is used to get all TDLS peers.
1929 *
1930 * @E.g: iwpriv wlan0 getTdlsPeers
1931 *
1932 * Supported Feature: TDLS
1933 *
1934 * Usage: Internal/External
1935 *
1936 * </ioctl>
1937 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938#define WE_GET_TDLS_PEERS 8
1939#endif
1940#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +05301941/*
1942 * <ioctl>
1943 * getPMFInfo - get the PMF info of the connected session
1944 *
1945 * @INPUT: None
1946 *
1947 * @OUTPUT:
1948 * wlan0 getPMFInfo:
1949 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
1950 * Number of Unprotected Disassocs 0
1951 * Number of Unprotected Deauths 0
1952 *
1953 * This IOCTL is used to get the PMF stats/status of the current
1954 * connection.
1955 *
1956 * @e.g:iwpriv wlan0 getPMFInfo
1957 *
1958 * Supported Feature: PMF
1959 *
1960 * Usage: Internal/External
1961 *
1962 * </ioctl>
1963 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964#define WE_GET_11W_INFO 9
1965#endif
1966#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +05301967/*
1968 * <ioctl>
1969 * getIbssSTAs - get ibss sta info
1970 *
1971 * @INPUT: None
1972 *
1973 * @OUTPUT: Give the MAC of the IBSS STA
1974 * wlan0 getIbssSTAs:
1975 * 1 .8c:fd:f0:01:9c:bf
1976 *
1977 * This IOCTL is used to get ibss sta info
1978 *
1979 * @E.g: iwpriv wlan0 getIbssSTAs
1980 *
1981 * Supported Feature: IBSS
1982 *
1983 * Usage: Internal/External
1984 *
1985 * </ioctl>
1986 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001987#define WE_GET_IBSS_STA_INFO 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301988/*
1989 * <ioctl>
1990 * getphymode - Get the current phymode.
1991 *
1992 * @INPUT: None
1993 *
1994 * @OUTPUT: In phymode
1995 * wlan0 getphymode:AUTO MODE
1996 *
1997 * This IOCTL used to gets the current phymode.
1998 *
1999 * @E.g: iwpriv wlan0 getphymode
2000 *
2001 * Supported Feature: STA
2002 *
2003 * Usage: Internal/External
2004 *
2005 * </ioctl>
2006 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007#define WE_GET_PHYMODE 12
Naveen Rawat910726a2017-03-06 11:42:51 -08002008
2009/*
2010 * <ioctl>
2011 * getOemDataCap - Get the oem data caps.
2012 *
2013 * @INPUT: None
2014 *
2015 * @OUTPUT: oem data capability
2016 *
2017 * This IOCTL used to gets the current oem data cap.
2018 *
2019 * @E.g: iwpriv wlan0 getOemDataCap
2020 *
2021 * Usage: Internal/External
2022 *
2023 * </ioctl>
2024 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025#define WE_GET_OEM_DATA_CAP 13
Naveen Rawat910726a2017-03-06 11:42:51 -08002026
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302027/*
2028 * <ioctl>
2029 * getSNR - Enable SNR Monitoring
2030 *
2031 * @INPUT: None
2032 *
2033 * @OUTPUT: Signal strength/ratio
2034 * wlan0 getSNR:1
2035 *
2036 * This IOCTL is used to get ibss sta info
2037 *
2038 * @E.g: iwpriv wlan0 getSNR
2039 *
2040 * Supported Feature: STA
2041 *
2042 * Usage: Internal/External
2043 *
2044 * </ioctl>
2045 */
Naveen Rawat910726a2017-03-06 11:42:51 -08002046
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +05302048#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049
2050/* Private ioctls and their sub-ioctls */
2051#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
2052#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +05302053/*
2054 * <ioctl>
2055 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
2056 *
2057 * @INPUT: None
2058 *
2059 * @OUTPUT: print ibss peer in info logs
2060 * pPeerInfo->numIBSSPeers = 1
2061 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2062 *
2063 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
2064 * in info logs
2065 *
2066 * @E.g: iwpriv wlan0 ibssPeerInfoAll
2067 *
2068 * Supported Feature: IBSS
2069 *
2070 * Usage: Internal/External
2071 *
2072 * </ioctl>
2073 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002074#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -08002075/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002077#define WE_GET_FW_PROFILE_DATA 18
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +05302078/*
2079 * <ioctl>
2080 * stop_obss_scan - Stop obss scan
2081 *
2082 * @INPUT: None
2083 *
2084 * @OUTPUT: None
2085 *
2086 * This IOCTL is used to stop obss scan
2087 *
2088 * @E.g: iwpriv wlan0 stop_obss_scan
2089 *
2090 * Supported Feature: Scan
2091 *
2092 * Usage: Internal/External
2093 *
2094 * </ioctl>
2095 */
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002096#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097
2098/* Private ioctls and their sub-ioctls */
2099#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
2100
2101#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +05302102/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103
Manjeet Singhf82ed072016-07-08 11:40:00 +05302104#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105
2106#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302107/*
2108 * <ioctl>
2109 * setTdlsConfig - Set TDLS configuration parameters.
2110 *
2111 * @INPUT: 11 TDLS configuration parameters
2112 * @args[0]: tdls: [0..2]
2113 * @args[1]: tx_period_t: [1000..4294967295UL]
2114 * @args[2]: tx_packet_n: [0..4294967295UL]
2115 * @args[3]: [discovery_period is not used anymore]
2116 * @args[4]: discovery_tries_n: [1..100]
2117 * @args[5]: [idle_timeout is not used anymore]
2118 * @args[6]: idle_packet_n: [0..40000]
2119 * @args[7]: [rssi_hysteresis is not used anymore]
2120 * @args[8]: rssi_trigger_threshold: [-120..0]
2121 * @args[9]: rssi_teardown_threshold: [-120..0]
2122 * @args[10]: rssi_delta: [-30..0]
2123 *
2124 * @OUTPUT: None
2125 *
2126 * This IOCTL is used to set the TDLS configuration parameters.
2127 *
2128 * @E.g: iwpriv wlan0 setTdlsConfig tdls tx_period_t tx_packet_n
2129 * discovery_period discovery_tries_n idle_timeout
2130 * idle_packet_n rssi_hysteresis rssi_trigger_threshold
2131 * rssi_teardown_threshold rssi_delta
2132 * iwpriv wlan0 setTdlsConfig 1 1500 40 1 5 1 5 0 -70 -70 -10
2133 *
2134 * Supported Feature: TDLS
2135 *
2136 * Usage: Internal/External
2137 *
2138 * </ioctl>
2139 */
2140
2141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142#define WE_TDLS_CONFIG_PARAMS 5
2143#endif
Abhishek Singh49b654e2016-12-01 16:11:17 +05302144/*
2145 * <ioctl>
2146 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
2147 *
2148 * @INPUT: staid
2149 *
2150 * @OUTPUT: print ibss peer corresponding to staid in info logs
2151 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2152 *
2153 * This IOCTL is used to print the specific ibss peers's MAC,
2154 * rate and RSSI in info logs
2155 *
2156 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
2157 * iwpriv wlan0 ibssPeerInfo 0
2158 *
2159 * Supported Feature: IBSS
2160 *
2161 * Usage: Internal/External
2162 *
2163 * </ioctl>
2164 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002165#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166#define WE_UNIT_TEST_CMD 7
2167
2168#define WE_MTRACE_DUMP_CMD 8
2169#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
2170
2171
2172#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2173#define WE_LED_FLASHING_PARAM 10
2174#endif
2175
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302176/*
2177 * <ioctl>
2178 * pm_clist - Increments the index value of the concurrent connection list
2179 * and update with the input parameters provided.
2180 *
2181 * @INPUT: Following 8 arguments:
2182 * @vdev_id: vdev id
2183 * @tx_streams: TX streams
2184 * @rx_streams: RX streams
2185 * @chain_mask: Chain mask
2186 * @type: vdev_type
2187 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2188 * @sub_type: vdev_subtype
2189 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2190 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2191 * @channel: Channel
2192 * @mac: Mac id
2193 *
2194 * @OUTPUT: None
2195 *
2196 * This IOCTL is used to increments the index value of the concurrent connection
2197 * list and update with the input parameters provided.
2198 *
2199 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
2200 * sub_type channel mac
2201 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
2202 *
2203 * Supported Feature: DBS
2204 *
2205 * Usage: Internal/External
2206 *
2207 * </ioctl>
2208 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302210
2211/*
2212 * <ioctl>
2213 * pm_dlist - Delete the index from the concurrent connection list that is
2214 * present in the given vdev_id.
2215 *
2216 * @INPUT: delete_all, vdev_id
2217 * @delete_all: delete all indices
2218 * @vdev_id: vdev id
2219 *
2220 * @OUTPUT: None
2221 *
2222 * This IOCTL is used to delete the index from the concurrent connection list
2223 * that is present in the given vdev_id.
2224 *
2225 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
2226 * iwpriv wlan0 pm_dlist 0 1
2227 *
2228 * Supported Feature: DBS
2229 *
2230 * Usage: Internal/External
2231 *
2232 * </ioctl>
2233 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302235
2236/*
2237 * <ioctl>
2238 * pm_dbs - Set dbs capability and system preference
2239 *
2240 * @INPUT: dbs, system_pref
2241 * @dbs: Value of DBS capability to be set
2242 * @system_pref: System preference
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002243 * 0:PM_THROUGHPUT 1: PM_POWERSAVE 2: PM_LATENCY
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302244 *
2245 * @OUTPUT: None
2246 *
2247 * This IOCTL is used to set dbs capability and system preference.
2248 *
2249 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
2250 * iwpriv wlan0 pm_dbs 1 0
2251 *
2252 * Supported Feature: DBS
2253 *
2254 * Usage: Internal/External
2255 *
2256 * </ioctl>
2257 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302259
2260/*
2261 * <ioctl>
2262 * pm_pcl - Set pcl for concurrency mode.
2263 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002264 * @INPUT: policy_mgr_con_mode
2265 * @policy_mgr_con_mode: concurrency mode for PCL table
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302266 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2267 *
2268 * @OUTPUT: None
2269 *
2270 * This IOCTL is used to set pcl for concurrency mode.
2271 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002272 * @E.g: iwpriv wlan0 pm_pcl policy_mgr_con_mode
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302273 * iwpriv wlan0 pm_pcl 0
2274 *
2275 * Supported Feature: DBS
2276 *
2277 * Usage: Internal/External
2278 *
2279 * </ioctl>
2280 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302282
2283/*
2284 * <ioctl>
2285 * pm_cinfo - Shows the concurrent connection list.
2286 *
2287 * @INPUT: None
2288 *
2289 * @OUTPUT: None
2290 *
2291 * This IOCTL is used to show the concurrent connection list.
2292 *
2293 * @E.g: iwpriv wlan0 pm_cinfo
2294 *
2295 * Supported Feature: DBS
2296 *
2297 * Usage: Internal/External
2298 *
2299 * </ioctl>
2300 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302302
2303/*
2304 * <ioctl>
2305 * pm_ulist - Updates the index value of the concurrent connection list
2306 * with the input parameters provided.
2307 *
2308 * @INPUT: Following 8 arguments:
2309 * @vdev_id: vdev id
2310 * @tx_streams: TX streams
2311 * @rx_streams: RX streams
2312 * @chain_mask: Chain mask
2313 * @type: vdev_type
2314 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2315 * @sub_type: vdev_subtype
2316 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2317 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2318 * @channel: Channel
2319 * @mac: Mac id
2320 *
2321 * @OUTPUT: None
2322 *
2323 * This IOCTL is used to updates the index value of the concurrent
2324 * connection list with the input parameters provided.
2325 *
2326 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
2327 * sub_type channel mac
2328 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
2329 *
2330 * Supported Feature: DBS
2331 *
2332 * Usage: Internal/External
2333 *
2334 * </ioctl>
2335 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302337
2338/*
2339 * <ioctl>
2340 * pm_query_action - Initiate actions needed on current connections as
2341 * per the channel provided.
2342 *
2343 * @INPUT: channel
2344 * @channel: Channel on which new connection will be.
2345 *
2346 * @OUTPUT: None
2347 *
2348 * This IOCTL is used to initiate actions needed on current connections
2349 * as per the channel provided.
2350 *
2351 * @E.g: iwpriv wlan0 pm_query_action channel
2352 * iwpriv wlan0 pm_query_action 6
2353 *
2354 * Supported Feature: DBS
2355 *
2356 * Usage: Internal/External
2357 *
2358 * </ioctl>
2359 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302361
2362/*
2363 * <ioctl>
2364 * pm_query_allow - Checks for allowed concurrency combination
2365 *
2366 * @INPUT: mode, channel, bandwidth
2367 * @mode: new connection mode
2368 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2369 * @channel: channel on which new connection is coming up
2370 * @bandwidth: Bandwidth requested by the connection
2371 * 0:None 1:5MHz 2:10MHz 3:20MHz
2372 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
2373 *
2374 * @OUTPUT: None
2375 *
2376 * This IOCTL is used to checks for allowed concurrency combination.
2377 *
2378 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
2379 * iwpriv wlan0 pm_query_allow 0 6 4
2380 *
2381 * Supported Feature: DBS
2382 *
2383 * Usage: Internal/External
2384 *
2385 * </ioctl>
2386 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302388
2389/*
2390 * <ioctl>
2391 * pm_run_scenario - Create scenario with number of connections provided.
2392 *
2393 * @INPUT: num_of_conn
2394 * @num_of_conn: the number of connections (values: 1~3)
2395 *
2396 * @OUTPUT: None
2397 *
2398 * This IOCTL is used to create scenario with the number of connections
2399 * provided.
2400 *
2401 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
2402 * iwpriv wlan0 pm_run_scenario 1
2403 *
2404 * Supported Feature: DBS
2405 *
2406 * Usage: Internal/External
2407 *
2408 * </ioctl>
2409 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302411
2412/*
2413 * <ioctl>
2414 * pm_set_hw_mode - Set hardware for single/dual mac.
2415 *
2416 * @INPUT: hw_mode
2417 * 0:single mac 1:dual mac
2418 *
2419 * @OUTPUT: None
2420 *
2421 * This IOCTL is used to set hardware for single/dual mac.
2422 *
2423 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
2424 * iwpriv wlan0 pm_set_hw_mode 1
2425 *
2426 * Supported Feature: DBS
2427 *
2428 * Usage: Internal/External
2429 *
2430 * </ioctl>
2431 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432#define WE_POLICY_SET_HW_MODE_CMD 20
2433
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302434/*
2435 * <ioctl>
2436 * set_scan_cfg - Set dual MAC scan config parameters.
2437 *
2438 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2439 * @dbs: Value of DBS bit
2440 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2441 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2442 *
2443 * @OUTPUT: None
2444 *
2445 * This IOCTL is used to set the dual MAC scan config.
2446 *
2447 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2448 * single_mac_scan_with_dbs
2449 * iwpriv wlan0 set_scan_cfg 1 0 1
2450 *
2451 * Supported Feature: DBS
2452 *
2453 * Usage: Internal/External
2454 *
2455 * </ioctl>
2456 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302458
2459/*
2460 * <ioctl>
2461 * set_fw_mode_cfg - Sets the dual mac FW mode config
2462 *
2463 * @INPUT: dbs, dfs
2464 * @dbs: DBS bit
2465 * @dfs: Agile DFS bit
2466 *
2467 * @OUTPUT: None
2468 *
2469 * This IOCTL is used to set the dual mac FW mode config.
2470 *
2471 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2472 * iwpriv wlan0 set_fw_mode_cfg 1 1
2473 *
2474 * Supported Feature: DBS
2475 *
2476 * Usage: Internal/External
2477 *
2478 * </ioctl>
2479 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07002481#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482
2483#ifdef FEATURE_WLAN_TDLS
2484#undef MAX_VAR_ARGS
2485#define MAX_VAR_ARGS 11
2486#else
2487#undef MAX_VAR_ARGS
2488#define MAX_VAR_ARGS 9
2489#endif
2490
2491/* Private ioctls (with no sub-ioctls) */
2492/* note that they must be odd so that they have "get" semantics */
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302493/*
2494 * <ioctl>
2495 * addTspec - Add TSPEC for each AC
2496 *
2497 * @INPUT: 19 TSPEC params
2498 * @[arg0]: handle
2499 * @[arg1]: tid
2500 * @[arg2]: dir
2501 * @[arg3]: psb
2502 * @[arg4]: up
2503 * @[arg5]: nomMsduSize
2504 * @[arg6]: maxMsduSize
2505 * @[arg7]: minDataRate
2506 * @[arg8]: meanDataRate
2507 * @[arg9]: peakDataRate
2508 * @[arg10]: maxBurstSize
2509 * @[arg11]: minPhyRate
2510 * @[arg12]: sba
2511 * @[arg13]: minServiceIntv
2512 * @[arg14]: suspendIntv
2513 * @[arg15]: burstSizeDefn
2514 * @[arg16]: ackPolicy
2515 * @[arg17]: inactivityPeriod
2516 * @[arg18]: maxServiceIntv
2517 *
2518 * @OUTPUT: Success/Failure
2519 *
2520 * This IOCTL is used to add TSPEC for each AC.
2521 *
2522 * @E.g: iwpriv wlan0 addTspec <handle> <tid> <dir> <psb> <up> <nomMsduSize>
2523 * <maxMsduSize> <minDataRate> <meanDataRate>
2524 * <peakDataRate> <maxBurstSize> <minPhyRate>
2525 * <sba> <minServiceIntv> <suspendIntv>
2526 * <burstSizeDefn> <ackPolicy> <inactivityPeriod>
2527 * <maxServiceIntv>
2528 * iwpriv wlan0 addTspec 7001 6 2 1 6 0x80D0 0x80D0 0x14500 0x14500 0x14500
2529 * 0 0x5B8D80 0x2001 20 2000 0 0 0 2000
2530 * wlan0 addTspec:3
2531 *
2532 * Supported Feature: WMM
2533 *
2534 * Usage: Internal/External
2535 *
2536 * </ioctl>
2537 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302539/*
2540 * <ioctl>
2541 * delTspec - Delete TSPEC entry for each AC
2542 *
2543 * @INPUT: 1 TSPEC param
2544 * @[arg0]: handle
2545 *
2546 * @OUTPUT: Success/Failure
2547 *
2548 * This IOCTL is used to delete TSPEC entry for each AC.
2549 *
2550 * @E.g: iwpriv wlan0 delTspec <handle>
2551 * iwpriv wlan0 delTspec 7001
2552 * wlan0 delTspec:16
2553 *
2554 * Supported Feature: WMM
2555 *
2556 * Usage: Internal/External
2557 *
2558 * </ioctl>
2559 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302561/*
2562 * <ioctl>
2563 * getTspec - Get TSPEC entry for each AC
2564 *
2565 * @INPUT: 1 TSPEC param
2566 * @[arg0]: handle
2567 *
2568 * @OUTPUT: Success/Failure
2569 *
2570 * This IOCTL is used to get TSPEC entry for each AC.
2571 *
2572 * @E.g: iwpriv wlan0 getTspec <handle>
2573 * iwpriv wlan0 getTspec 7001
2574 * wlan0 delTspec:18
2575 *
2576 * Supported Feature: WMM
2577 *
2578 * Usage: Internal/External
2579 *
2580 * </ioctl>
2581 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2583
2584/* (SIOCIWFIRSTPRIV + 8) is currently unused */
2585/* (SIOCIWFIRSTPRIV + 10) is currently unused */
2586/* (SIOCIWFIRSTPRIV + 12) is currently unused */
2587/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002588#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
2589#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002590/* (SIOCIWFIRSTPRIV + 16) is currently unused */
2591/* (SIOCIWFIRSTPRIV + 17) is currently unused */
2592/* (SIOCIWFIRSTPRIV + 19) is currently unused */
2593
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595
2596/* Private ioctl for setting the host offload feature */
2597#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2598
2599/* Private ioctl to get the statistics */
2600#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2601
2602/* Private ioctl to set the Keep Alive Params */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302603/*
2604 * <ioctl>
2605 * setKeepAlive - Set the keep alive feature
2606 *
2607 * @INPUT: 28 bytes of information in the order of packet type, time period
2608 * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2609 *
2610 * @OUTPUT: None
2611 *
2612 * This IOCTL sets the keep alive feature to send either NULL
2613 * or unsolicited ARP response packets
2614 *
2615 * @E.g: iwpriv wlan0 setKeepAlive
2616 *
2617 * Supported Feature: STA
2618 *
2619 * Usage: Internal/External
2620 *
2621 * </ioctl>
2622 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2624
2625#ifdef WLAN_FEATURE_PACKET_FILTERING
2626/* Private ioctl to set the packet filtering params */
2627#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2628#endif
2629
2630
2631#ifdef FEATURE_WLAN_SCAN_PNO
2632/* Private ioctl to get the statistics */
2633#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2634#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302635/*
2636 * <ioctl>
2637 * SETBAND - Set the operational band
2638 *
2639 * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2640 *
2641 * @OUTPUT: None
2642 *
2643 * This IOCTL Set the operational band If the new band is different from the
2644 * current operational band, it aborts the pending scan requests, flushes
2645 * the existing scan results, and then change * the band capability
2646 *
2647 * @E.g: iwpriv wlan0 SETBAND <value>
2648 *
2649 * Supported Feature: STA
2650 *
2651 * Usage: Internal/External
2652 *
2653 * </ioctl>
2654 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
2656
Dustin Brown0cbc7572016-12-16 13:54:40 -08002657#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -08002658/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659
2660/* Private ioctls and their sub-ioctls */
2661#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
2662#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -07002663#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664#define WE_SET_FW_CRASH_INJECT 2
2665#endif
2666#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +05302667/* Private sub ioctl for enabling and setting histogram interval of profiling */
2668#define WE_ENABLE_FW_PROFILE 4
2669#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07002671/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002672#define WE_SET_WLAN_SUSPEND 6
2673#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002674
Dustin Brown8d2d0f52017-04-03 17:02:08 -07002675/*
2676 * <ioctl>
2677 * log_buffer - prints host/target related communication logs via dmesg
2678 *
2679 * @INPUT: Log Id, Count
2680 *
2681 * Log Id:
2682 * 0) HTC_CREDIT_HISTORY_LOG
2683 * 1) COMMAND_LOG,
2684 * 2) COMMAND_TX_CMP_LOG,
2685 * 3) MGMT_COMMAND_LOG,
2686 * 4) MGMT_COMMAND_TX_CMP_LOG,
2687 * 5) EVENT_LOG,
2688 * 6) RX_EVENT_LOG,
2689 * 7) MGMT_EVENT_LOG
2690 *
2691 * @OUTPUT: None
2692 *
2693 * @E.g:
2694 * # print up to 10 of the most recent records from HTC Credit History
2695 * iwpriv wlan0 log_buffer 0 10
2696 * # print up to 3 of the most recent records from Event Log
2697 * iwpriv wlan0 log_buffer 5 3
2698 *
2699 * Supported Feature: WLAN Trace
2700 *
2701 * Usage: Internal/External
2702 *
2703 * </ioctl>
2704 */
2705#define WE_LOG_BUFFER 8
2706
2707enum host_target_comm_log {
2708 HTC_CREDIT_HISTORY_LOG = 0,
2709 COMMAND_LOG,
2710 COMMAND_TX_CMP_LOG,
2711 MGMT_COMMAND_LOG,
2712 MGMT_COMMAND_TX_CMP_LOG,
2713 EVENT_LOG,
2714 RX_EVENT_LOG,
2715 MGMT_EVENT_LOG
2716};
2717
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718/* (SIOCIWFIRSTPRIV + 29) is currently unused */
2719
2720/* 802.11p IOCTL */
2721#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
2722
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302723/*
2724 * <ioctl>
2725 * getLinkSpeed - Gets the current link speed in Mbps
2726 *
2727 * @INPUT: None
2728 *
2729 * @OUTPUT: linkspeed in mbps
2730 * wlan0 getLinkSpeed:7
2731 *
2732 * This IOCTL is used get the current link speed in Mbps
2733 *
2734 * @E.g: iwpriv wlan0 getLinkSpeed
2735 *
2736 * Supported Feature: STA
2737 *
2738 * Usage: Internal/External
2739 *
2740 * </ioctl>
2741 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
2743
2744#define WLAN_STATS_INVALID 0
2745#define WLAN_STATS_RETRY_CNT 1
2746#define WLAN_STATS_MUL_RETRY_CNT 2
2747#define WLAN_STATS_TX_FRM_CNT 3
2748#define WLAN_STATS_RX_FRM_CNT 4
2749#define WLAN_STATS_FRM_DUP_CNT 5
2750#define WLAN_STATS_FAIL_CNT 6
2751#define WLAN_STATS_RTS_FAIL_CNT 7
2752#define WLAN_STATS_ACK_FAIL_CNT 8
2753#define WLAN_STATS_RTS_SUC_CNT 9
2754#define WLAN_STATS_RX_DISCARD_CNT 10
2755#define WLAN_STATS_RX_ERROR_CNT 11
2756#define WLAN_STATS_TX_BYTE_CNT 12
2757
2758#define WLAN_STATS_RX_BYTE_CNT 13
2759#define WLAN_STATS_RX_RATE 14
2760#define WLAN_STATS_TX_RATE 15
2761
2762#define WLAN_STATS_RX_UC_BYTE_CNT 16
2763#define WLAN_STATS_RX_MC_BYTE_CNT 17
2764#define WLAN_STATS_RX_BC_BYTE_CNT 18
2765#define WLAN_STATS_TX_UC_BYTE_CNT 19
2766#define WLAN_STATS_TX_MC_BYTE_CNT 20
2767#define WLAN_STATS_TX_BC_BYTE_CNT 21
2768
2769#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
2770 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
2771 *__p++ = __type; \
2772 *__p++ = __size; \
2773 memcpy(__p, __val, __size); \
2774 __p += __size; \
2775 __tlen += __size + 2; \
2776 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07002777 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 } \
2779 } while (0)
2780
2781#define VERSION_VALUE_MAX_LEN 32
2782
2783#define TX_PER_TRACKING_DEFAULT_RATIO 5
2784#define TX_PER_TRACKING_MAX_RATIO 10
2785#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
2786
2787#define WLAN_ADAPTER 0
2788#define P2P_ADAPTER 1
2789
2790/**
2791 * mem_alloc_copy_from_user_helper - copy from user helper
2792 * @wrqu_data: wireless extensions request data
2793 * @len: length of @wrqu_data
2794 *
2795 * Helper function to allocate buffer and copy user data.
2796 *
2797 * Return: On success return a pointer to a kernel buffer containing a
2798 * copy of the userspace data (with an additional NUL character
2799 * appended for safety). On failure return %NULL.
2800 */
2801void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2802{
2803 u8 *ptr = NULL;
2804
2805 /* in order to protect the code, an extra byte is post
2806 * appended to the buffer and the null termination is added.
2807 * However, when allocating (len+1) byte of memory, we need to
2808 * make sure that there is no uint overflow when doing
2809 * addition. In theory check len < UINT_MAX protects the uint
2810 * overflow. For wlan private ioctl, the buffer size is much
2811 * less than UINT_MAX, as a good guess, now, it is assumed
2812 * that the private command buffer size is no greater than 4K
2813 * (4096 bytes). So we use 4096 as the upper boundary for now.
2814 */
2815 if (len > MAX_USER_COMMAND_SIZE) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08002816 hdd_err("Invalid length: %zu max: %u",
2817 len, MAX_USER_COMMAND_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 return NULL;
2819 }
2820
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002821 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002823 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 return NULL;
2825 }
2826
2827 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002828 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002829 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 return NULL;
2831 }
2832 ptr[len] = '\0';
2833 return ptr;
2834}
2835
2836/**
2837 * hdd_priv_get_data() - Get pointer to ioctl private data
2838 * @p_priv_data: pointer to iw_point struct to be filled
2839 * @wrqu: Pointer to IOCTL Data received from userspace
2840 *
2841 * Helper function to get compatible struct iw_point passed to ioctl
2842 *
2843 * Return - 0 if p_priv_data successfully filled, error otherwise
2844 */
2845int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2846{
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002847 if ((NULL == p_priv_data) || (NULL == wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850#ifdef CONFIG_COMPAT
2851 if (is_compat_task()) {
2852 struct compat_iw_point *p_compat_priv_data;
2853
2854 /* Compat task:
2855 * typecast to compat structure and copy the members.
2856 */
2857 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2858
2859 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2860 p_priv_data->length = p_compat_priv_data->length;
2861 p_priv_data->flags = p_compat_priv_data->flags;
2862 } else {
2863#endif /* #ifdef CONFIG_COMPAT */
2864
2865 /* Non compat task: directly copy the structure. */
2866 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
2867
2868#ifdef CONFIG_COMPAT
2869 }
2870#endif /* #ifdef CONFIG_COMPAT */
2871
2872 return 0;
2873}
2874
Jeff Johnson441e1f72017-02-07 08:50:49 -08002875static int hdd_check_wext_control(enum hdd_wext_control wext_control,
2876 struct iw_request_info *info)
2877{
2878 switch (wext_control) {
2879 default:
2880 case hdd_wext_disabled:
2881 hdd_err("Rejecting disabled ioctl %x", info->cmd);
2882 return -ENOTSUPP;
2883 case hdd_wext_deprecated:
2884 hdd_warn("Using deprecated ioctl %x", info->cmd);
2885 return 0;
2886 case hdd_wext_enabled:
2887 return 0;
2888 }
2889}
2890
2891int hdd_check_standard_wext_control(struct hdd_context_s *hdd_ctx,
2892 struct iw_request_info *info)
2893{
2894 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
2895 info);
2896}
2897
2898int hdd_check_private_wext_control(struct hdd_context_s *hdd_ctx,
2899 struct iw_request_info *info)
2900{
2901 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
2902 info);
2903}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904
2905/**
2906 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
2907 * @pAdapter: Pointer to the hdd adapter.
2908 * @length: Size of the data copied
2909 * @buffer: Pointer to char buffer.
2910 * @buf_len: Length of the char buffer.
2911 *
2912 * This function called when the "iwpriv wlan0 get_stats" command is given.
2913 * It used to collect the txrx stats when the device is configured in SAP mode.
2914 *
2915 * Return - none
2916 */
2917void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
2918 char *buffer, uint16_t buf_len)
2919{
2920 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
2921 uint32_t len = 0;
2922 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
2923 uint32_t total_rx_delv = 0, total_rx_refused = 0;
2924 int i = 0;
2925
2926 for (; i < NUM_CPUS; i++) {
2927 total_rx_pkt += pStats->rxPackets[i];
2928 total_rx_dropped += pStats->rxDropped[i];
2929 total_rx_delv += pStats->rxDelivered[i];
2930 total_rx_refused += pStats->rxRefused[i];
2931 }
2932
2933 len = scnprintf(buffer, buf_len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002934 "\nTransmit[%lu] - "
Mohit Khannad0b63f52017-02-18 18:05:52 -08002935 "called %u, dropped %u orphan %u,"
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002936 "\n[dropped] BK %u, BE %u, VI %u, VO %u"
2937 "\n[classified] BK %u, BE %u, VI %u, VO %u"
2938 "\n\nReceive[%lu] - "
2939 "packets %u, dropped %u, delivered %u, refused %u"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940 "\n",
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002941 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 pStats->txXmitCalled,
2943 pStats->txXmitDropped,
Mohit Khannad0b63f52017-02-18 18:05:52 -08002944 pStats->txXmitOrphaned,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945
2946 pStats->txXmitDroppedAC[SME_AC_BK],
2947 pStats->txXmitDroppedAC[SME_AC_BE],
2948 pStats->txXmitDroppedAC[SME_AC_VI],
2949 pStats->txXmitDroppedAC[SME_AC_VO],
2950
2951 pStats->txXmitClassifiedAC[SME_AC_BK],
2952 pStats->txXmitClassifiedAC[SME_AC_BE],
2953 pStats->txXmitClassifiedAC[SME_AC_VI],
2954 pStats->txXmitClassifiedAC[SME_AC_VO],
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002955 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
2957 );
2958
2959 for (i = 0; i < NUM_CPUS; i++) {
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002960 if (pStats->rxPackets[i] == 0)
2961 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002963 "Rx CPU[%d]:"
2964 "packets %u, dropped %u, delivered %u, refused %u\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 i, pStats->rxPackets[i], pStats->rxDropped[i],
2966 pStats->rxDelivered[i], pStats->rxRefused[i]);
2967 }
2968
2969 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07002970 "\nTX_FLOW"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971 "\nCurrent status: %s"
2972 "\ntx-flow timer start count %u"
2973 "\npause count %u, unpause count %u",
2974 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
2975 pStats->txflow_timer_cnt,
2976 pStats->txflow_pause_cnt,
2977 pStats->txflow_unpause_cnt);
2978
Leo Changfdb45c32016-10-28 11:09:23 -07002979 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
2980 pAdapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 *length = len + 1;
2982}
2983
2984/**
Dustin Brownd9322482017-01-09 12:46:03 -08002985 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
2986 * @hdd_ctx: The Hdd context owning the stats to be written
2987 * @buffer: The char buffer to write to
2988 * @max_len: The maximum number of chars to write
2989 *
2990 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
2991 *
2992 * Return - length of written content, negative number on error
2993 */
2994static int wlan_hdd_write_suspend_resume_stats(hdd_context_t *hdd_ctx,
2995 char *buffer, uint16_t max_len)
2996{
2997 QDF_STATUS status;
2998 struct suspend_resume_stats *sr_stats;
2999 struct sir_wake_lock_stats wow_stats;
3000
3001 sr_stats = &hdd_ctx->suspend_resume_stats;
3002
3003 status = wma_get_wakelock_stats(&wow_stats);
3004 if (QDF_IS_STATUS_ERROR(status)) {
3005 hdd_err("Failed to get WoW stats");
3006 return qdf_status_to_os_return(status);
3007 }
3008
3009 return scnprintf(buffer, max_len,
3010 "\n"
3011 "Suspends: %u\n"
3012 "Resumes: %u\n"
3013 "\n"
3014 "Suspend Fail Reasons\n"
3015 "\tIPA: %u\n"
3016 "\tRadar: %u\n"
3017 "\tRoam: %u\n"
3018 "\tScan: %u\n"
3019 "\tInitial Wakeup: %u\n"
3020 "\n"
3021 "WoW Wake Reasons\n"
3022 "\tunicast: %u\n"
3023 "\tbroadcast: %u\n"
3024 "\tIPv4 multicast: %u\n"
3025 "\tIPv6 multicast: %u\n"
3026 "\tIPv6 multicast RA: %u\n"
3027 "\tIPv6 multicast NS: %u\n"
3028 "\tIPv6 multicast NA: %u\n"
3029 "\tICMPv4: %u\n"
3030 "\tICMPv6: %u\n"
3031 "\tRSSI Breach: %u\n"
3032 "\tLow RSSI: %u\n"
3033 "\tG-Scan: %u\n"
3034 "\tPNO Complete: %u\n"
3035 "\tPNO Match: %u\n",
3036 sr_stats->suspends,
3037 sr_stats->resumes,
3038 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
3039 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
3040 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
3041 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
3042 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
3043 wow_stats.wow_ucast_wake_up_count,
3044 wow_stats.wow_bcast_wake_up_count,
3045 wow_stats.wow_ipv4_mcast_wake_up_count,
3046 wow_stats.wow_ipv6_mcast_wake_up_count,
3047 wow_stats.wow_ipv6_mcast_ra_stats,
3048 wow_stats.wow_ipv6_mcast_ns_stats,
3049 wow_stats.wow_ipv6_mcast_na_stats,
3050 wow_stats.wow_icmpv4_count,
3051 wow_stats.wow_icmpv6_count,
3052 wow_stats.wow_rssi_breach_wake_up_count,
3053 wow_stats.wow_low_rssi_wake_up_count,
3054 wow_stats.wow_gscan_wake_up_count,
3055 wow_stats.wow_pno_complete_wake_up_count,
3056 wow_stats.wow_pno_match_wake_up_count);
3057}
3058
3059/**
Govind Singha471e5e2015-10-12 17:11:14 +05303060 * hdd_wlan_list_fw_profile() - Get fw profiling points
3061 * @length: Size of the data copied
3062 * @buffer: Pointer to char buffer.
3063 * @buf_len: Length of the char buffer.
3064 *
3065 * This function called when the "iwpriv wlan0 listProfile" command is given.
3066 * It is used to get the supported profiling points in FW.
3067 *
3068 * Return - none
3069 */
3070void hdd_wlan_list_fw_profile(uint16_t *length,
3071 char *buffer, uint16_t buf_len)
3072{
3073 uint32_t len = 0;
3074
3075 len = scnprintf(buffer, buf_len,
3076 "PROF_CPU_IDLE: %u\n"
3077 "PROF_PPDU_PROC: %u\n"
3078 "PROF_PPDU_POST: %u\n"
3079 "PROF_HTT_TX_INPUT: %u\n"
3080 "PROF_MSDU_ENQ: %u\n"
3081 "PROF_PPDU_POST_HAL: %u\n"
3082 "PROF_COMPUTE_TX_TIME: %u\n",
3083 PROF_CPU_IDLE,
3084 PROF_PPDU_PROC,
3085 PROF_PPDU_POST,
3086 PROF_HTT_TX_INPUT,
3087 PROF_MSDU_ENQ,
3088 PROF_PPDU_POST_HAL,
3089 PROF_COMPUTE_TX_TIME);
3090
3091 *length = len + 1;
3092}
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003093/**
3094 * hdd_display_stats_help() - print statistics help
3095 *
3096 * Return: none
3097 */
3098void hdd_display_stats_help(void)
3099{
3100 hdd_err("iwpriv wlan0 dumpStats [option] - dump statistics");
3101 hdd_err("iwpriv wlan0 clearStats [option] - clear statistics");
3102 hdd_err("options:");
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003103 hdd_err(" 1 -- TXRX PATH statistics");
3104 hdd_err(" 2 -- TXRX HIST statistics");
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003105 hdd_err(" 3 -- TSO statistics");
3106 hdd_err(" 4 -- Network queue statistics");
3107 hdd_err(" 5 -- Flow control statistics");
3108 hdd_err(" 6 -- Per Layer statistics");
3109 hdd_err(" 7 -- Copy engine interrupt statistics");
3110 hdd_err(" 8 -- LRO statistics");
3111 hdd_err(" 9 -- NAPI statistics");
3112}
Govind Singha471e5e2015-10-12 17:11:14 +05303113
3114/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 * hdd_wlan_dump_stats() - display dump Stats
3116 * @adapter: adapter handle
3117 * @value: value from user
3118 *
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003119 * Return: 0 => success, error code on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 */
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003121int hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122{
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003123 int ret = 0;
3124 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003125 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3126
3127 switch (value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003128 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
3130 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003131 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 wlan_hdd_display_netif_queue_history(hdd_ctx);
3133 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003134 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05303135 hdd_display_hif_stats();
3136 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003137 case CDP_LRO_STATS:
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003138 hdd_lro_display_stats(hdd_ctx);
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003139 case CDP_NAPI_STATS:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003140 if (hdd_display_napi_stats()) {
3141 hdd_err("error displaying napi stats");
3142 ret = EFAULT;
3143 }
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003144 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 default:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003146 status = cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC),
3147 value);
3148 if (status == QDF_STATUS_E_INVAL) {
3149 hdd_display_stats_help();
3150 ret = EINVAL;
3151 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 break;
3153 }
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003154 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155}
3156
3157/**
3158 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303159 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 * @wrqu: Pointer to IOCTL REQUEST Data.
3161 * @extra: Pointer to destination buffer
3162 *
3163 * This function is used to get Wlan Driver, Firmware, & Hardware
3164 * Version information. If @wrqu and @extra are specified, then the
3165 * version string is returned. Otherwise it is simply printed to the
3166 * kernel log.
3167 *
3168 * Return: none
3169 */
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303170void hdd_wlan_get_version(hdd_context_t *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003171 char *extra)
3172{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303173 tSirVersionString wcnss_sw_version;
3174 const char *swversion;
3175 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003176 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303178 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003179 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 goto error;
3181 }
3182
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303183 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
3184 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303186 swversion = wcnss_sw_version;
3187 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
3188 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
3189 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
3190 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003191 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303193 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194
3195 if (wrqu && extra) {
3196 wrqu->data.length =
3197 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003198 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003200 msp_id, mspid, siid, crmid,
3201 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003203 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003205 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206 }
3207error:
3208 return;
3209}
3210
3211/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003212 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
3213 * @pAdapter: Adapter upon which the IBSS client is active
3214 * @staIdx: Station index of the IBSS peer
3215 *
3216 * Return: a pointer to the MAC address of the IBSS peer if the peer is
3217 * found, otherwise %NULL.
3218 */
3219struct qdf_mac_addr *
3220hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
3221 uint8_t staIdx)
3222{
3223 uint8_t idx;
3224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3225
Naveen Rawatc45d1622016-07-05 12:20:09 -07003226 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003227 if (0 != pHddStaCtx->conn_info.staId[idx] &&
3228 staIdx == pHddStaCtx->conn_info.staId[idx]) {
3229 return &pHddStaCtx->conn_info.peerMacAddress[idx];
3230 }
3231 }
3232 return NULL;
3233}
3234
3235/**
3236 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
3237 * @pAdapter: Adapter upon which the IBSS client is active
3238 * @staIdx: Station index of the IBSS peer
3239 *
3240 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
3241 * otherwise an appropriate QDF_STATUS_E_* failure code.
3242 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003243static QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter,
3244 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003245{
3246 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3247 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3248 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003249 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003250
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003251 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003252 status = sme_request_ibss_peer_info(hHal, pAdapter,
3253 hdd_get_ibss_peer_info_cb,
3254 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003255
3256 if (QDF_STATUS_SUCCESS == status) {
3257 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003258
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003259 rc = wait_for_completion_timeout
3260 (&pAdapter->ibss_peer_info_comp,
3261 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3262 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003263 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003264 return QDF_STATUS_E_FAILURE;
3265 }
3266
3267 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003268 hdd_debug("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003269 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003270 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3271 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003272
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003273 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
3274 mac_addr, sizeof(mac_addr));
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003275 hdd_debug("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003276 mac_addr, (int)tx_rate,
3277 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003278 }
3279 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003280 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003281 }
3282
3283 return status;
3284}
3285
3286/**
3287 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
3288 * @pAdapter: Adapter upon which the IBSS clients are active
3289 *
3290 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
3291 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
3292 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003293static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003294{
3295 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3296 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3297 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003298 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003299 int i;
3300
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003301 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003302 status = sme_request_ibss_peer_info(hHal, pAdapter,
3303 hdd_get_ibss_peer_info_cb,
3304 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003305
3306 if (QDF_STATUS_SUCCESS == status) {
3307 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003308
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003309 rc = wait_for_completion_timeout
3310 (&pAdapter->ibss_peer_info_comp,
3311 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3312 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003313 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003314 return QDF_STATUS_E_FAILURE;
3315 }
3316
3317 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003318 hdd_debug("pPeerInfo->numIBSSPeers = %d ",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003319 (int)pPeerInfo->numPeers);
3320 for (i = 0; i < pPeerInfo->numPeers; i++) {
3321 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3322 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003323
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003324 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
3325 qdf_mem_copy(mac_addr,
3326 pPeerInfo->peerInfoParams[i].mac_addr,
3327 sizeof(mac_addr));
3328
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003329 hdd_debug(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003330 mac_addr, (int)tx_rate,
3331 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003332 }
3333 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003334 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003335 }
3336
3337 return status;
3338}
3339
3340/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341 * hdd_wlan_get_freq() - Convert channel to frequency
3342 * @channel: channel to be converted
3343 * @pfreq: where to store the frequency
3344 *
3345 * Return: 1 on success, otherwise a negative errno
3346 */
3347int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
3348{
3349 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 if (channel > 0) {
3352 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
3353 if (channel == freq_chan_map[i].chan) {
3354 *pfreq = freq_chan_map[i].freq;
3355 return 1;
3356 }
3357 }
3358 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003359 hdd_err("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 return -EINVAL;
3361}
3362
3363/**
3364 * hdd_is_auth_type_rsn() - RSN authentication type check
3365 * @authType: authentication type to be checked
3366 *
3367 * Return: true if @authType is an RSN authentication type,
3368 * false if it is not
3369 */
3370static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
3371{
3372 bool rsnType = false;
3373 /* is the authType supported? */
3374 switch (authType) {
3375 case eCSR_AUTH_TYPE_NONE: /* never used */
3376 rsnType = false;
3377 break;
3378 /* MAC layer authentication types */
3379 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3380 rsnType = false;
3381 break;
3382 case eCSR_AUTH_TYPE_SHARED_KEY:
3383 rsnType = false;
3384 break;
3385 case eCSR_AUTH_TYPE_AUTOSWITCH:
3386 rsnType = false;
3387 break;
3388
3389 /* Upper layer authentication types */
3390 case eCSR_AUTH_TYPE_WPA:
3391 rsnType = true;
3392 break;
3393 case eCSR_AUTH_TYPE_WPA_PSK:
3394 rsnType = true;
3395 break;
3396 case eCSR_AUTH_TYPE_WPA_NONE:
3397 rsnType = true;
3398 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 case eCSR_AUTH_TYPE_RSN:
3401 rsnType = true;
3402 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 case eCSR_AUTH_TYPE_RSN_PSK:
3405#ifdef WLAN_FEATURE_11W
3406 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3407 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
3408#endif
3409 rsnType = true;
3410 break;
3411 /* case eCSR_AUTH_TYPE_FAILED: */
3412 case eCSR_AUTH_TYPE_UNKNOWN:
3413 rsnType = false;
3414 break;
3415 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003416 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 authType);
3418 rsnType = false;
3419 break;
3420 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003421 hdd_debug("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 authType, rsnType);
3423 return rsnType;
3424}
3425
Jeff Johnsona5444942017-01-23 13:11:08 -08003426struct rssi_priv {
3427 int8_t rssi;
3428};
3429
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430/**
3431 * hdd_get_rssi_cb() - "Get RSSI" callback function
3432 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08003433 * @sta_id: ID of the station
3434 * @context: opaque context originally passed to SME. HDD always passes
3435 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 *
3437 * Return: None
3438 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003439static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440{
Jeff Johnsona5444942017-01-23 13:11:08 -08003441 struct hdd_request *request;
3442 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443
Jeff Johnsona5444942017-01-23 13:11:08 -08003444 request = hdd_request_get(context);
3445 if (!request) {
3446 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 return;
3448 }
3449
Jeff Johnsona5444942017-01-23 13:11:08 -08003450 priv = hdd_request_priv(request);
3451 priv->rssi = rssi;
3452 hdd_request_complete(request);
3453 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454}
3455
3456/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 * wlan_hdd_get_rssi() - Get the current RSSI
3458 * @pAdapter: adapter upon which the measurement is requested
3459 * @rssi_value: pointer to where the RSSI should be returned
3460 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303461 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303463QDF_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 hdd_context_t *pHddCtx;
3466 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303467 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08003468 int ret;
3469 void *cookie;
3470 struct hdd_request *request;
3471 struct rssi_priv *priv;
3472 static const struct hdd_request_params params = {
3473 .priv_size = sizeof(*priv),
3474 .timeout_ms = WLAN_WAIT_TIME_STATS,
3475 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476
3477 if (NULL == pAdapter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003478 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303479 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003481 if (cds_is_driver_recovering()) {
3482 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3483 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 /* return a cached value */
3485 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303486 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 }
3488
3489 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3490 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3491
3492 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003493 hdd_debug("Not associated!, rssi on disconnect %d",
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05303494 pAdapter->rssi_on_disconnect);
3495 *rssi_value = pAdapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303496 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003497 }
3498
3499 if (pHddStaCtx->hdd_ReassocScenario) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003500 hdd_debug("Roaming in progress, return cached RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303502 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 }
3504
Jeff Johnsona5444942017-01-23 13:11:08 -08003505 request = hdd_request_alloc(&params);
3506 if (!request) {
3507 hdd_err("Request allocation failure, return cached RSSI");
3508 *rssi_value = pAdapter->rssi;
3509 return QDF_STATUS_SUCCESS;
3510 }
3511 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512
3513 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
3514 pHddStaCtx->conn_info.staId[0],
3515 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
Jeff Johnsona5444942017-01-23 13:11:08 -08003516 cookie, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303517 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003518 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003519 /* we'll returned a cached value below */
3520 } else {
3521 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08003522 ret = hdd_request_wait_for_response(request);
3523 if (ret) {
3524 hdd_warn("SME timed out while retrieving RSSI");
3525 /* we'll returned a cached value below */
3526 } else {
3527 /* update the adapter with the fresh results */
3528 priv = hdd_request_priv(request);
3529 pAdapter->rssi = priv->rssi;
3530 if (pAdapter->rssi > 0)
3531 pAdapter->rssi = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532 }
3533 }
3534
Jeff Johnsona5444942017-01-23 13:11:08 -08003535 /*
3536 * either we never sent a request, we sent a request and
3537 * received a response or we sent a request and timed out.
3538 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003539 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003540 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541
3542 *rssi_value = pAdapter->rssi;
3543
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303544 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545}
3546
Jeff Johnson002cb972017-01-23 14:59:07 -08003547struct snr_priv {
3548 int8_t snr;
3549};
3550
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08003552 * hdd_get_snr_cb() - "Get SNR" callback function
3553 * @snr: Current SNR of the station
Jeff Johnson002cb972017-01-23 14:59:07 -08003554 * @sta_id: ID of the station
3555 * @context: opaque context originally passed to SME. HDD always passes
3556 * a cookie for the request context
Jeff Johnson8eaff302017-01-23 11:03:31 -08003557 *
3558 * Return: None
3559 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003560static void hdd_get_snr_cb(int8_t snr, uint32_t sta_id, void *context)
Jeff Johnson8eaff302017-01-23 11:03:31 -08003561{
Jeff Johnson002cb972017-01-23 14:59:07 -08003562 struct hdd_request *request;
3563 struct snr_priv *priv;
Jeff Johnson8eaff302017-01-23 11:03:31 -08003564
Jeff Johnson002cb972017-01-23 14:59:07 -08003565 request = hdd_request_get(context);
3566 if (!request) {
3567 hdd_err("Obsolete request");
Jeff Johnson8eaff302017-01-23 11:03:31 -08003568 return;
3569 }
3570
Jeff Johnson002cb972017-01-23 14:59:07 -08003571 /* propagate response back to requesting thread */
3572 priv = hdd_request_priv(request);
3573 priv->snr = snr;
3574 hdd_request_complete(request);
3575 hdd_request_put(request);
Jeff Johnson8eaff302017-01-23 11:03:31 -08003576}
3577
3578/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 * wlan_hdd_get_snr() - Get the current SNR
3580 * @pAdapter: adapter upon which the measurement is requested
3581 * @snr: pointer to where the SNR should be returned
3582 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303583 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303585QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587 hdd_context_t *pHddCtx;
3588 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303589 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 int valid;
Jeff Johnson002cb972017-01-23 14:59:07 -08003591 int ret;
3592 void *cookie;
3593 struct hdd_request *request;
3594 struct snr_priv *priv;
3595 static const struct hdd_request_params params = {
3596 .priv_size = sizeof(*priv),
3597 .timeout_ms = WLAN_WAIT_TIME_STATS,
3598 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003599
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303600 ENTER();
3601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003603 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303604 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 }
3606
3607 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3608
3609 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303610 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303611 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612
3613 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3614
Jeff Johnson002cb972017-01-23 14:59:07 -08003615 request = hdd_request_alloc(&params);
3616 if (!request) {
3617 hdd_err("Request allocation failure");
3618 return QDF_STATUS_E_FAULT;
3619 }
3620 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621
3622 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
3623 pHddStaCtx->conn_info.staId[0],
Jeff Johnson002cb972017-01-23 14:59:07 -08003624 pHddStaCtx->conn_info.bssId, cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303625 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003626 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627 /* we'll returned a cached value below */
3628 } else {
3629 /* request was sent -- wait for the response */
Jeff Johnson002cb972017-01-23 14:59:07 -08003630 ret = hdd_request_wait_for_response(request);
3631 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003632 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 /* we'll now returned a cached value below */
Jeff Johnson002cb972017-01-23 14:59:07 -08003634 } else {
3635 /* update the adapter with the fresh results */
3636 priv = hdd_request_priv(request);
3637 pAdapter->snr = priv->snr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 }
3639 }
3640
Jeff Johnson002cb972017-01-23 14:59:07 -08003641 /*
3642 * either we never sent a request, we sent a request and
3643 * received a response or we sent a request and timed out.
3644 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003646 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647
3648 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303649 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303650 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651}
3652
Jeff Johnsone50427c2017-01-26 10:54:49 -08003653struct linkspeed_priv {
3654 tSirLinkSpeedInfo linkspeed_info;
3655};
3656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657static void
Jeff Johnsone50427c2017-01-26 10:54:49 -08003658hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659{
Jeff Johnsone50427c2017-01-26 10:54:49 -08003660 struct hdd_request *request;
3661 struct linkspeed_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662
Jeff Johnsone50427c2017-01-26 10:54:49 -08003663 if (!linkspeed_info) {
3664 hdd_err("NULL linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665 return;
3666 }
3667
Jeff Johnsone50427c2017-01-26 10:54:49 -08003668 request = hdd_request_get(context);
3669 if (!request) {
3670 hdd_err("Obsolete request");
3671 return;
3672 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673
Jeff Johnsone50427c2017-01-26 10:54:49 -08003674 priv = hdd_request_priv(request);
3675 priv->linkspeed_info = *linkspeed_info;
3676 hdd_request_complete(request);
3677 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003678}
3679
Jeff Johnsone50427c2017-01-26 10:54:49 -08003680int wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *adapter,
3681 struct qdf_mac_addr *mac_address,
3682 uint32_t *linkspeed)
3683{
3684 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303685 QDF_STATUS status;
Jeff Johnsone50427c2017-01-26 10:54:49 -08003686 void *cookie;
3687 tSirLinkSpeedInfo *linkspeed_info;
3688 struct hdd_request *request;
3689 struct linkspeed_priv *priv;
3690 static const struct hdd_request_params params = {
3691 .priv_size = sizeof(*priv),
3692 .timeout_ms = WLAN_WAIT_TIME_STATS,
3693 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694
Jeff Johnsone50427c2017-01-26 10:54:49 -08003695 if ((!adapter) || (!linkspeed)) {
3696 hdd_err("NULL argument");
3697 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699
Jeff Johnsone50427c2017-01-26 10:54:49 -08003700 request = hdd_request_alloc(&params);
3701 if (!request) {
3702 hdd_err("Request allocation failure");
3703 ret = -ENOMEM;
3704 goto return_cached_value;
3705 }
3706
3707 cookie = hdd_request_cookie(request);
3708 priv = hdd_request_priv(request);
3709
3710 linkspeed_info = &priv->linkspeed_info;
3711 qdf_copy_macaddr(&linkspeed_info->peer_macaddr, mac_address);
3712 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(adapter),
3713 linkspeed_info,
3714 cookie, hdd_get_link_speed_cb);
3715 if (QDF_IS_STATUS_ERROR(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003716 hdd_err("Unable to retrieve statistics for link speed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003717 ret = qdf_status_to_os_return(status);
3718 goto cleanup;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 }
Jeff Johnsone50427c2017-01-26 10:54:49 -08003720 ret = hdd_request_wait_for_response(request);
3721 if (ret) {
3722 hdd_err("SME timed out while retrieving link speed");
3723 goto cleanup;
3724 }
3725 adapter->estimated_linkspeed = linkspeed_info->estLinkSpeed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726
Jeff Johnsone50427c2017-01-26 10:54:49 -08003727cleanup:
3728 /*
3729 * either we never sent a request, we sent a request and
3730 * received a response or we sent a request and timed out.
3731 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732 */
Jeff Johnsone50427c2017-01-26 10:54:49 -08003733 hdd_request_put(request);
3734
3735return_cached_value:
3736 *linkspeed = adapter->estimated_linkspeed;
3737
3738 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739}
3740
3741/**
3742 * wlan_hdd_get_link_speed() - get link speed
3743 * @pAdapter: pointer to the adapter
3744 * @link_speed: pointer to link speed
3745 *
3746 * This function fetches per bssid link speed.
3747 *
3748 * Return: if associated, link speed shall be returned.
3749 * if not associated, link speed of 0 is returned.
3750 * On error, error number will be returned.
3751 */
3752int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
3753{
3754 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
3755 hdd_station_ctx_t *hdd_stactx =
3756 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
3757 int ret;
3758
3759 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05303760 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003761 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303763 /* Linkspeed is allowed only for P2P mode */
3764 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
3765 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
3766 hdd_device_mode_to_string(sta_adapter->device_mode),
3767 sta_adapter->device_mode);
3768 return -ENOTSUPP;
3769 }
3770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
3772 /* we are not connected so we don't have a classAstats */
3773 *link_speed = 0;
3774 } else {
Anurag Chouhan6d760662016-02-20 16:05:43 +05303775 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003776
Anurag Chouhanc5548422016-02-24 18:33:27 +05303777 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778
Jeff Johnsone50427c2017-01-26 10:54:49 -08003779 ret = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, &bssid,
3780 link_speed);
3781 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003782 hdd_err("Unable to retrieve SME linkspeed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003783 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 /* linkspeed in units of 500 kbps */
3786 *link_speed = (*link_speed) / 500;
3787 }
3788 return 0;
3789}
3790
3791/**
3792 * hdd_statistics_cb() - "Get statistics" callback function
3793 * @pStats: statistics payload
3794 * @pContext: opaque context originally passed to SME. HDD always passes
3795 * a pointer to an adapter
3796 *
3797 * Return: None
3798 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003799static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800{
3801 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
3802 hdd_stats_t *pStatsCache = NULL;
3803 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05303804 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805
3806 tCsrSummaryStatsInfo *pSummaryStats = NULL;
3807 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809
3810 if (pAdapter != NULL)
3811 pStatsCache = &pAdapter->hdd_stats;
3812
3813 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3814 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Jeff Johnsonf2dac4f2017-03-16 11:41:31 -07003815 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003816
3817 if (pStatsCache != NULL) {
3818 /* copy the stats into the cache we keep in the
3819 * adapter instance structure
3820 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303821 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303823 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303825 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 sizeof(pStatsCache->ClassD_stat));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827 }
3828
3829 if (pAdapter) {
3830 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303831 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05303832 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003833 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003834 return;
3835 }
3836 }
3837}
3838
3839/**
3840 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
3841 * @pAdapter: adapter who's IEs are to be cleared
3842 *
3843 * Return: None
3844 */
3845void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
3846{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003847 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07003848
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003849 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850
3851 /* clear WPA/RSN/WSC IE information in the profile */
3852 pWextState->roamProfile.nWPAReqIELength = 0;
3853 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
3854 pWextState->roamProfile.nRSNReqIELength = 0;
3855 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
3856
3857#ifdef FEATURE_WLAN_WAPI
3858 pWextState->roamProfile.nWAPIReqIELength = 0;
3859 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
3860#endif
3861
3862 pWextState->roamProfile.bWPSAssociation = false;
3863 pWextState->roamProfile.bOSENAssociation = false;
3864 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
3865 pWextState->roamProfile.nAddIEScanLength = 0;
3866 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
3867 pWextState->roamProfile.nAddIEAssocLength = 0;
3868
3869 pWextState->roamProfile.EncryptionType.numEntries = 1;
3870 pWextState->roamProfile.EncryptionType.encryptionType[0]
3871 = eCSR_ENCRYPT_TYPE_NONE;
3872
3873 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3874 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
3875 = eCSR_ENCRYPT_TYPE_NONE;
3876
3877 pWextState->roamProfile.AuthType.numEntries = 1;
3878 pWextState->roamProfile.AuthType.authType[0] =
3879 eCSR_AUTH_TYPE_OPEN_SYSTEM;
3880
Abhishek Singh3c9910e2017-01-06 17:56:47 +05303881 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
3882 QDF_MAC_ADDR_SIZE);
3883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884#ifdef WLAN_FEATURE_11W
3885 pWextState->roamProfile.MFPEnabled = false;
3886 pWextState->roamProfile.MFPRequired = 0;
3887 pWextState->roamProfile.MFPCapable = 0;
3888#endif
3889
3890 pWextState->authKeyMgmt = 0;
3891
Yingying Tang3cc6b792016-10-20 17:00:37 +08003892 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
3893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894#ifdef FEATURE_WLAN_WAPI
3895 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
3896 pAdapter->wapi_info.nWapiMode = 0;
3897#endif
3898
Anurag Chouhanc5548422016-02-24 18:33:27 +05303899 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003900 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901}
3902
3903/**
3904 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
3905 * @oui: The OUI that is being searched for
3906 * @oui_size: The length of @oui
3907 * @ie: The set of IEs within which we're trying to find @oui
3908 * @ie_len: The length of @ie
3909 *
3910 * This function will scan the IEs contained within @ie looking for @oui.
3911 *
3912 * Return: Pointer to @oui embedded within @ie if it is present, NULL
3913 * if @oui is not present within @ie.
3914 */
3915uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
3916 uint8_t *ie, int ie_len)
3917{
3918 int left = ie_len;
3919 uint8_t *ptr = ie;
3920 uint8_t elem_id, elem_len;
3921 uint8_t eid = 0xDD;
3922
3923 if (NULL == ie || 0 == ie_len)
3924 return NULL;
3925
3926 while (left >= 2) {
3927 elem_id = ptr[0];
3928 elem_len = ptr[1];
3929 left -= 2;
3930 if (elem_len > left) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003931 hdd_err("Invalid IEs eid: %d elem_len: %d left: %d",
3932 eid, elem_len, left);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003933 return NULL;
3934 }
3935 if (elem_id == eid) {
3936 if (memcmp(&ptr[2], oui, oui_size) == 0)
3937 return ptr;
3938 }
3939
3940 left -= elem_len;
3941 ptr += (elem_len + 2);
3942 }
3943 return NULL;
3944}
3945
3946/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303947 * hdd_get_ldpc() - Get adapter LDPC
3948 * @adapter: adapter being queried
3949 * @value: where to store the value
3950 *
3951 * Return: 0 on success, negative errno on failure
3952 */
3953int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
3954{
3955 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3956 int ret;
3957
3958 ENTER();
3959 ret = sme_get_ht_config(hal, adapter->sessionId,
3960 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
3961 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003962 hdd_err("Failed to get LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303963 } else {
3964 *value = ret;
3965 ret = 0;
3966 }
3967 return ret;
3968}
3969
3970/**
3971 * hdd_set_ldpc() - Set adapter LDPC
3972 * @adapter: adapter being modified
3973 * @value: new LDPC value
3974 *
3975 * Return: 0 on success, negative errno on failure
3976 */
3977int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
3978{
3979 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3980 int ret;
3981
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003982 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303983 if (value) {
3984 /* make sure HT capabilities allow this */
3985 QDF_STATUS status;
3986 uint32_t cfg_value;
3987 union {
3988 uint16_t cfg_value16;
3989 tSirMacHTCapabilityInfo ht_cap_info;
3990 } u;
3991
3992 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
3993 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003994 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303995 return -EIO;
3996 }
3997 u.cfg_value16 = cfg_value & 0xFFFF;
3998 if (!u.ht_cap_info.advCodingCap) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003999 hdd_err("LDCP not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304000 return -EINVAL;
4001 }
4002 }
4003
4004 ret = sme_update_ht_config(hal, adapter->sessionId,
4005 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
4006 value);
4007 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004008 hdd_err("Failed to set LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304009
4010 return ret;
4011}
4012
4013/**
4014 * hdd_get_tx_stbc() - Get adapter TX STBC
4015 * @adapter: adapter being queried
4016 * @value: where to store the value
4017 *
4018 * Return: 0 on success, negative errno on failure
4019 */
4020int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
4021{
4022 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4023 int ret;
4024
4025 ENTER();
4026 ret = sme_get_ht_config(hal, adapter->sessionId,
4027 WNI_CFG_HT_CAP_INFO_TX_STBC);
4028 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004029 hdd_err("Failed to get TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304030 } else {
4031 *value = ret;
4032 ret = 0;
4033 }
4034
4035 return ret;
4036}
4037
4038/**
4039 * hdd_set_tx_stbc() - Set adapter TX STBC
4040 * @adapter: adapter being modified
4041 * @value: new TX STBC value
4042 *
4043 * Return: 0 on success, negative errno on failure
4044 */
4045int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
4046{
4047 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4048 int ret;
4049
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004050 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304051 if (value) {
4052 /* make sure HT capabilities allow this */
4053 QDF_STATUS status;
4054 uint32_t cfg_value;
4055 union {
4056 uint16_t cfg_value16;
4057 tSirMacHTCapabilityInfo ht_cap_info;
4058 } u;
4059
4060 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4061 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004062 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304063 return -EIO;
4064 }
4065 u.cfg_value16 = cfg_value & 0xFFFF;
4066 if (!u.ht_cap_info.txSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004067 hdd_err("TX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304068 return -EINVAL;
4069 }
4070 }
4071 ret = sme_update_ht_config(hal, adapter->sessionId,
4072 WNI_CFG_HT_CAP_INFO_TX_STBC,
4073 value);
4074 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004075 hdd_err("Failed to set TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304076
4077 return ret;
4078}
4079
4080/**
4081 * hdd_get_rx_stbc() - Get adapter RX STBC
4082 * @adapter: adapter being queried
4083 * @value: where to store the value
4084 *
4085 * Return: 0 on success, negative errno on failure
4086 */
4087int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
4088{
4089 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4090 int ret;
4091
4092 ENTER();
4093 ret = sme_get_ht_config(hal, adapter->sessionId,
4094 WNI_CFG_HT_CAP_INFO_RX_STBC);
4095 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004096 hdd_err("Failed to get RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304097 } else {
4098 *value = ret;
4099 ret = 0;
4100 }
4101
4102 return ret;
4103}
4104
4105/**
4106 * hdd_set_rx_stbc() - Set adapter RX STBC
4107 * @adapter: adapter being modified
4108 * @value: new RX STBC value
4109 *
4110 * Return: 0 on success, negative errno on failure
4111 */
4112int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
4113{
4114 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4115 int ret;
4116
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004117 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304118 if (value) {
4119 /* make sure HT capabilities allow this */
4120 QDF_STATUS status;
4121 uint32_t cfg_value;
4122 union {
4123 uint16_t cfg_value16;
4124 tSirMacHTCapabilityInfo ht_cap_info;
4125 } u;
4126
4127 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4128 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004129 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304130 return -EIO;
4131 }
4132 u.cfg_value16 = cfg_value & 0xFFFF;
4133 if (!u.ht_cap_info.rxSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004134 hdd_warn("RX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304135 return -EINVAL;
4136 }
4137 }
4138 ret = sme_update_ht_config(hal, adapter->sessionId,
4139 WNI_CFG_HT_CAP_INFO_RX_STBC,
4140 value);
4141 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004142 hdd_err("Failed to set RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304143
4144 return ret;
4145}
4146
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004147int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate)
4148{
4149 int set_value;
4150
4151 if (sme_is_feature_supported_by_fw(DOT11AX))
4152 set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble);
4153 else
4154 set_value = (preamble << 6) | (nss << 4) | rate;
4155
4156 return set_value;
4157}
4158
4159int hdd_set_11ax_rate(hdd_adapter_t *adapter, int set_value,
4160 struct sap_Config *sap_config)
4161{
4162 uint8_t preamble = 0, nss = 0, rix = 0;
4163 int ret;
4164
4165 if (!sap_config) {
4166 if (!sme_is_feature_supported_by_fw(DOT11AX)) {
4167 hdd_err("Target does not support 11ax");
4168 return -EIO;
4169 }
4170 } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax &&
4171 sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) {
4172 hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d",
4173 sap_config->SapHw_mode, sap_config->channel);
4174 return -EIO;
4175 }
4176
4177 if (set_value != 0xff) {
4178 rix = RC_2_RATE_IDX_11AX(set_value);
4179 preamble = WMI_RATE_PREAMBLE_HE;
4180 nss = HT_RC_2_STREAMS_11AX(set_value);
4181
4182 set_value = hdd_assemble_rate_code(preamble, nss, rix);
4183 }
4184
4185 hdd_notice("SET_11AX_RATE val %d rix %d preamble %x nss %d",
4186 set_value, rix, preamble, nss);
4187
4188 ret = wma_cli_set_command(adapter->sessionId,
4189 WMI_VDEV_PARAM_FIXED_RATE,
4190 set_value, VDEV_CMD);
4191
4192 return ret;
4193}
4194
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304195/**
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004196 * hdd_get_aid_rc() - Get AID and rate code passed from user
4197 * @aid: pointer to AID
4198 * @rc: pointer to rate code
4199 * @set_value: value passed from user
4200 *
4201 * If target is 11ax capable, set_value will have AID left shifted 16 bits
4202 * and 16 bits for rate code. If the target is not 11ax capable, rate code
4203 * will only be 8 bits.
4204 *
4205 * Return: None
4206 */
4207static void hdd_get_aid_rc(uint8_t *aid, uint16_t *rc, int set_value)
4208{
4209 uint8_t rc_bits;
4210
4211 if (sme_is_feature_supported_by_fw(DOT11AX))
4212 rc_bits = 16;
4213 else
4214 rc_bits = 8;
4215
4216 *aid = set_value >> rc_bits;
4217 *rc = set_value & ((1 << (rc_bits + 1)) - 1);
4218}
4219
4220int hdd_set_peer_rate(hdd_adapter_t *adapter, int set_value)
4221{
4222 uint8_t aid, *peer_mac;
4223 uint16_t rc;
4224 QDF_STATUS status;
4225
4226 if (adapter->device_mode != QDF_SAP_MODE) {
4227 hdd_err("Invalid devicde mode - %d", adapter->device_mode);
4228 return -EINVAL;
4229 }
4230
4231 hdd_get_aid_rc(&aid, &rc, set_value);
4232
4233 if ((adapter->aStaInfo[aid].isUsed) &&
4234 (OL_TXRX_PEER_STATE_CONN == adapter->aStaInfo[aid].tlSTAState)) {
4235 peer_mac =
4236 (uint8_t *)&(adapter->aStaInfo[aid].macAddrSTA.bytes[0]);
4237 hdd_info("Peer AID: %d MAC_ADDR: "MAC_ADDRESS_STR,
4238 aid, MAC_ADDR_ARRAY(peer_mac));
4239 } else {
4240 hdd_err("No matching peer found for AID: %d", aid);
4241 return -EINVAL;
4242 }
4243
4244 status = sme_set_peer_param(peer_mac, WMI_PEER_PARAM_FIXED_RATE,
4245 rc, adapter->sessionId);
4246 if (status != QDF_STATUS_SUCCESS) {
4247 hdd_err("Failed to set peer fixed rate - status: %d", status);
4248 return -EIO;
4249 }
4250
4251 return 0;
4252}
4253
4254/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
4256 * @dev: device upon which the ioctl was received
4257 * @info: ioctl request information
4258 * @wrqu: ioctl request data
4259 * @extra: ioctl extra data
4260 *
4261 * Return: 0 on success, non-zero on error
4262 */
4263static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
4264 union iwreq_data *wrqu, char *extra)
4265{
4266 hdd_adapter_t *adapter;
4267 hdd_context_t *hdd_ctx;
4268 int ret;
4269
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004270 ENTER_DEV(dev);
4271
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4273 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4274 ret = wlan_hdd_validate_context(hdd_ctx);
4275 if (0 != ret)
4276 return ret;
4277
Jeff Johnson441e1f72017-02-07 08:50:49 -08004278 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4279 if (0 != ret)
4280 return ret;
4281
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 /* Do nothing for now */
4283 return 0;
4284}
4285
4286/**
4287 * iw_set_commit() - SSR wrapper function for __iw_set_commit
4288 * @dev: pointer to net_device
4289 * @info: pointer to iw_request_info
4290 * @wrqu: pointer to iwreq_data
4291 * @extra: extra
4292 *
4293 * Return: 0 on success, error number otherwise
4294 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004295static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 union iwreq_data *wrqu, char *extra)
4297{
4298 int ret;
4299
4300 cds_ssr_protect(__func__);
4301 ret = __iw_set_commit(dev, info, wrqu, extra);
4302 cds_ssr_unprotect(__func__);
4303
4304 return ret;
4305}
4306
4307/**
4308 * __iw_get_name() - SIOCGIWNAME ioctl handler
4309 * @dev: device upon which the ioctl was received
4310 * @info: ioctl request information
4311 * @wrqu: ioctl request data
4312 * @extra: ioctl extra data
4313 *
4314 * Return: 0 on success, non-zero on error
4315 */
4316static int __iw_get_name(struct net_device *dev,
4317 struct iw_request_info *info, char *wrqu, char *extra)
4318{
4319 hdd_adapter_t *adapter;
4320 hdd_context_t *hdd_ctx;
4321 int ret;
4322
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004323 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324
4325 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4326 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4327 ret = wlan_hdd_validate_context(hdd_ctx);
4328 if (0 != ret)
4329 return ret;
4330
Jeff Johnson441e1f72017-02-07 08:50:49 -08004331 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4332 if (0 != ret)
4333 return ret;
4334
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
4336 EXIT();
4337 return 0;
4338}
4339
4340/**
4341 * __iw_get_name() - SSR wrapper for __iw_get_name
4342 * @dev: pointer to net_device
4343 * @info: pointer to iw_request_info
4344 * @wrqu: pointer to iwreq_data
4345 * @extra: extra
4346 *
4347 * Return: 0 on success, error number otherwise
4348 */
4349static int iw_get_name(struct net_device *dev,
4350 struct iw_request_info *info,
4351 char *wrqu, char *extra)
4352{
4353 int ret;
4354
4355 cds_ssr_protect(__func__);
4356 ret = __iw_get_name(dev, info, wrqu, extra);
4357 cds_ssr_unprotect(__func__);
4358
4359 return ret;
4360}
4361
4362/**
4363 * __iw_set_mode() - ioctl handler
4364 * @dev: device upon which the ioctl was received
4365 * @info: ioctl request information
4366 * @wrqu: ioctl request data
4367 * @extra: ioctl extra data
4368 *
4369 * Return: 0 on success, non-zero on error
4370 */
4371static int __iw_set_mode(struct net_device *dev,
4372 struct iw_request_info *info,
4373 union iwreq_data *wrqu, char *extra)
4374{
4375 hdd_wext_state_t *pWextState;
4376 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4377 hdd_context_t *hdd_ctx;
4378 tCsrRoamProfile *pRoamProfile;
4379 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 struct hdd_config *pConfig;
4381 struct wireless_dev *wdev;
4382 int ret;
4383
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004384 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385
4386 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4387 ret = wlan_hdd_validate_context(hdd_ctx);
4388 if (0 != ret)
4389 return ret;
4390
Jeff Johnson441e1f72017-02-07 08:50:49 -08004391 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4392 if (0 != ret)
4393 return ret;
4394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4396 wdev = dev->ieee80211_ptr;
4397 pRoamProfile = &pWextState->roamProfile;
4398 LastBSSType = pRoamProfile->BSSType;
4399
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004400 hdd_debug("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401
4402 switch (wrqu->mode) {
4403 case IW_MODE_ADHOC:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004404 hdd_debug("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
4406 /* Set the phymode correctly for IBSS. */
4407 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
4408 pWextState->roamProfile.phyMode =
4409 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08004410 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 wdev->iftype = NL80211_IFTYPE_ADHOC;
4412 break;
4413 case IW_MODE_INFRA:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004414 hdd_debug("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
4416 wdev->iftype = NL80211_IFTYPE_STATION;
4417 break;
4418 case IW_MODE_AUTO:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004419 hdd_debug("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
4421 break;
4422 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004423 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424 return -EOPNOTSUPP;
4425 }
4426
4427 if (LastBSSType != pRoamProfile->BSSType) {
4428 /* the BSS mode changed. We need to issue disconnect
4429 * if connected or in IBSS disconnect state
4430 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07004431 if (hdd_conn_is_connected
4432 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304434 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 /* need to issue a disconnect to CSR. */
4436 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304437 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4439 pAdapter->sessionId,
4440 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304441 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004443
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004444 rc = wait_for_completion_timeout(&pAdapter->
4445 disconnect_comp_var,
4446 msecs_to_jiffies
4447 (WLAN_WAIT_TIME_DISCONNECT));
4448 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004449 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450 }
4451 }
4452 }
4453
4454 EXIT();
4455 return 0;
4456}
4457
4458/**
4459 * iw_set_mode() - SSR wrapper for __iw_set_mode()
4460 * @dev: pointer to net_device
4461 * @info: pointer to iw_request_info
4462 * @wrqu: pointer to iwreq_data
4463 * @extra: pointer to extra ioctl payload
4464 *
4465 * Return: 0 on success, error number otherwise
4466 */
4467static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
4468 union iwreq_data *wrqu, char *extra)
4469{
4470 int ret;
4471
4472 cds_ssr_protect(__func__);
4473 ret = __iw_set_mode(dev, info, wrqu, extra);
4474 cds_ssr_unprotect(__func__);
4475
4476 return ret;
4477}
4478
4479/**
4480 * __iw_get_mode() - SIOCGIWMODE ioctl handler
4481 * @dev: device upon which the ioctl was received
4482 * @info: ioctl request information
4483 * @wrqu: ioctl request data
4484 * @extra: ioctl extra data
4485 *
4486 * Return: 0 on success, non-zero on error
4487 */
4488static int
4489__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4490 union iwreq_data *wrqu, char *extra)
4491{
4492 hdd_wext_state_t *pWextState;
4493 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4494 hdd_context_t *hdd_ctx;
4495 int ret;
4496
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004497 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498
4499 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4500 ret = wlan_hdd_validate_context(hdd_ctx);
4501 if (0 != ret)
4502 return ret;
4503
Jeff Johnson441e1f72017-02-07 08:50:49 -08004504 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4505 if (0 != ret)
4506 return ret;
4507
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4509
4510 switch (pWextState->roamProfile.BSSType) {
4511 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004512 hdd_debug("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 wrqu->mode = IW_MODE_INFRA;
4514 break;
4515 case eCSR_BSS_TYPE_IBSS:
4516 case eCSR_BSS_TYPE_START_IBSS:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004517 hdd_debug("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 wrqu->mode = IW_MODE_ADHOC;
4519 break;
4520 case eCSR_BSS_TYPE_ANY:
4521 default:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004522 hdd_debug("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 wrqu->mode = IW_MODE_AUTO;
4524 break;
4525 }
4526
4527 EXIT();
4528 return 0;
4529}
4530
4531/**
4532 * iw_get_mode() - SSR wrapper for __iw_get_mode()
4533 * @dev: pointer to net_device
4534 * @info: pointer to iw_request_info
4535 * @wrqu: pointer to iwreq_data
4536 * @extra: pointer to extra ioctl payload
4537 *
4538 * Return: 0 on success, error number otherwise
4539 */
4540static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4541 union iwreq_data *wrqu, char *extra)
4542{
4543 int ret;
4544
4545 cds_ssr_protect(__func__);
4546 ret = __iw_get_mode(dev, info, wrqu, extra);
4547 cds_ssr_unprotect(__func__);
4548
4549 return ret;
4550}
4551
4552/**
4553 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
4554 * @dev: device upon which the ioctl was received
4555 * @info: ioctl request information
4556 * @wrqu: ioctl request data
4557 * @extra: ioctl extra data
4558 *
4559 * Return: 0 on success, non-zero on error
4560 */
4561static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4562 union iwreq_data *wrqu, char *extra)
4563{
4564 uint32_t numChans = 0;
4565 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4566 uint32_t indx = 0;
4567 int ret;
4568 hdd_wext_state_t *pWextState;
4569 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4570 hdd_context_t *hdd_ctx;
4571 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4572 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4573 tCsrRoamProfile *pRoamProfile;
4574
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004575 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576
4577 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4578 ret = wlan_hdd_validate_context(hdd_ctx);
4579 if (0 != ret)
4580 return ret;
4581
Jeff Johnson441e1f72017-02-07 08:50:49 -08004582 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4583 if (0 != ret)
4584 return ret;
4585
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4587
4588 pRoamProfile = &pWextState->roamProfile;
4589
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004590 /* Link is up then return cant set channel */
4591 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
4592 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004593 hdd_debug("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 return -EOPNOTSUPP;
4595 }
4596
4597 /* Settings by Frequency as input */
4598 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
4599 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
4600 uint32_t freq = wrqu->freq.m / 100000;
4601
4602 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
4603 && (freq != freq_chan_map[indx].freq))
4604 indx++;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004605 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 wrqu->freq.e = 0;
4609 wrqu->freq.m = freq_chan_map[indx].chan;
4610
4611 }
4612
4613 if (wrqu->freq.e == 0) {
4614 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
4615 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004616 hdd_debug("Channel %d is not in range[%d to %d]",
Jeff Johnson99bac312016-06-28 10:38:18 -07004617 wrqu->freq.m,
4618 WNI_CFG_CURRENT_CHANNEL_STAMIN,
4619 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 return -EINVAL;
4621 }
4622
4623 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4624
4625 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
4626 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304627 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004628 hdd_err("WNI_CFG_VALID_CHANNEL_LIST failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 return -EIO;
4630 }
4631
4632 for (indx = 0; indx < numChans; indx++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004633 if (wrqu->freq.m == validChan[indx])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 }
4636 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 return -EINVAL;
4638 }
4639
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004640 if (indx >= numChans)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642
4643 /* Set the Operational Channel */
4644 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
4645 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
4646 pRoamProfile->ChannelInfo.ChannelList =
4647 &pHddStaCtx->conn_info.operationChannel;
4648
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004649 hdd_debug("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650
4651 EXIT();
4652
4653 return ret;
4654}
4655
4656/**
4657 * iw_set_freq() - SSR wrapper for __iw_set_freq()
4658 * @dev: pointer to net_device
4659 * @info: pointer to iw_request_info
4660 * @wrqu: pointer to iwreq_data
4661 * @extra: pointer to extra ioctl payload
4662 *
4663 * Return: 0 on success, error number otherwise
4664 */
4665static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4666 union iwreq_data *wrqu, char *extra)
4667{
4668 int ret;
4669
4670 cds_ssr_protect(__func__);
4671 ret = __iw_set_freq(dev, info, wrqu, extra);
4672 cds_ssr_unprotect(__func__);
4673
4674 return ret;
4675}
4676
4677/**
4678 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
4679 * @dev: device upon which the ioctl was received
4680 * @info: ioctl request information
4681 * @wrqu: ioctl request data
4682 * @extra: ioctl extra data
4683 *
4684 * Return: 0 on success, non-zero on error
4685 */
4686static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4687 struct iw_freq *fwrq, char *extra)
4688{
4689 uint32_t status = false, channel = 0, freq = 0;
4690 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4691 tHalHandle hHal;
4692 hdd_wext_state_t *pWextState;
4693 tCsrRoamProfile *pRoamProfile;
4694 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4695 hdd_context_t *hdd_ctx;
4696 int ret;
4697
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004698 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699
4700 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4701 ret = wlan_hdd_validate_context(hdd_ctx);
4702 if (0 != ret)
4703 return ret;
4704
Jeff Johnson441e1f72017-02-07 08:50:49 -08004705 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4706 if (0 != ret)
4707 return ret;
4708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4710 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4711
4712 pRoamProfile = &pWextState->roamProfile;
4713
4714 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004715 if (sme_get_operation_channel(hHal, &channel,
4716 pAdapter->sessionId) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004717 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 pAdapter->sessionId);
4719 return -EIO;
Jeff Johnson68755312017-02-10 11:46:55 -08004720 }
Jeff Johnson68755312017-02-10 11:46:55 -08004721 status = hdd_wlan_get_freq(channel, &freq);
4722 if (true == status) {
4723 /* Set Exponent parameter as 6 (MHZ)
4724 * in struct iw_freq iwlist & iwconfig
4725 * command shows frequency into proper
4726 * format (2.412 GHz instead of 246.2
4727 * MHz)
4728 */
4729 fwrq->m = freq;
4730 fwrq->e = MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731 }
4732 } else {
4733 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4734 * iwlist & iwconfig command shows frequency into proper
4735 * format (2.412 GHz instead of 246.2 MHz)
4736 */
4737 fwrq->m = 0;
4738 fwrq->e = MHZ;
4739 }
4740 return 0;
4741}
4742
4743/**
4744 * iw_get_freq() - SSR wrapper for __iw_get_freq()
4745 * @dev: pointer to net_device
4746 * @info: pointer to iw_request_info
4747 * @fwrq: pointer to frequency data
4748 * @extra: pointer to extra ioctl payload
4749 *
4750 * Return: 0 on success, error number otherwise
4751 */
4752static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4753 struct iw_freq *fwrq, char *extra)
4754{
4755 int ret;
4756
4757 cds_ssr_protect(__func__);
4758 ret = __iw_get_freq(dev, info, fwrq, extra);
4759 cds_ssr_unprotect(__func__);
4760
4761 return ret;
4762}
4763
4764/**
4765 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
4766 * @dev: device upon which the ioctl was received
4767 * @info: ioctl request information
4768 * @wrqu: ioctl request data
4769 * @extra: ioctl extra data
4770 *
4771 * Return: 0 on success, non-zero on error
4772 */
4773static int __iw_get_tx_power(struct net_device *dev,
4774 struct iw_request_info *info,
4775 union iwreq_data *wrqu, char *extra)
4776{
4777
4778 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4779 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4780 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4781 int ret;
4782
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004783 ENTER_DEV(dev);
4784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004785 ret = wlan_hdd_validate_context(hdd_ctx);
4786 if (0 != ret)
4787 return ret;
4788
Jeff Johnson441e1f72017-02-07 08:50:49 -08004789 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4790 if (0 != ret)
4791 return ret;
4792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004793 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4794 wrqu->txpower.value = 0;
4795 return 0;
4796 }
4797 wlan_hdd_get_class_astats(pAdapter);
4798 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
4799
4800 return 0;
4801}
4802
4803/**
4804 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
4805 * @dev: pointer to net_device
4806 * @info: pointer to iw_request_info
4807 * @wrqu: pointer to iwreq_data
4808 * @extra: pointer to extra ioctl payload
4809 *
4810 * Return: 0 on success, error number otherwise
4811 */
4812static int iw_get_tx_power(struct net_device *dev,
4813 struct iw_request_info *info,
4814 union iwreq_data *wrqu, char *extra)
4815{
4816 int ret;
4817
4818 cds_ssr_protect(__func__);
4819 ret = __iw_get_tx_power(dev, info, wrqu, extra);
4820 cds_ssr_unprotect(__func__);
4821
4822 return ret;
4823}
4824
4825/**
4826 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
4827 * @dev: device upon which the ioctl was received
4828 * @info: ioctl request information
4829 * @wrqu: ioctl request data
4830 * @extra: ioctl extra data
4831 *
4832 * Return: 0 on success, non-zero on error
4833 */
4834static int __iw_set_tx_power(struct net_device *dev,
4835 struct iw_request_info *info,
4836 union iwreq_data *wrqu, char *extra)
4837{
4838 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4839 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4840 hdd_context_t *hdd_ctx;
4841 int ret;
4842
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004843 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004844
4845 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4846 ret = wlan_hdd_validate_context(hdd_ctx);
4847 if (0 != ret)
4848 return ret;
4849
Jeff Johnson441e1f72017-02-07 08:50:49 -08004850 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4851 if (0 != ret)
4852 return ret;
4853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004854 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304855 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004856 hdd_err("WNI_CFG_CURRENT_TX_POWER_LEVEL failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004857 return -EIO;
4858 }
4859
4860 EXIT();
4861
4862 return 0;
4863}
4864
4865/**
4866 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
4867 * @dev: pointer to net_device
4868 * @info: pointer to iw_request_info
4869 * @wrqu: pointer to iwreq_data
4870 * @extra: pointer to extra ioctl payload
4871 *
4872 * Return: 0 on success, error number otherwise
4873 */
4874static int iw_set_tx_power(struct net_device *dev,
4875 struct iw_request_info *info,
4876 union iwreq_data *wrqu, char *extra)
4877{
4878 int ret;
4879
4880 cds_ssr_protect(__func__);
4881 ret = __iw_set_tx_power(dev, info, wrqu, extra);
4882 cds_ssr_unprotect(__func__);
4883
4884 return ret;
4885}
4886
4887/**
4888 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
4889 * @dev: device upon which the ioctl was received
4890 * @info: ioctl request information
4891 * @wrqu: ioctl request data
4892 * @extra: ioctl extra data
4893 *
4894 * Return: 0 on success, non-zero on error
4895 */
4896static int __iw_get_bitrate(struct net_device *dev,
4897 struct iw_request_info *info,
4898 union iwreq_data *wrqu, char *extra)
4899{
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004900 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004901 hdd_wext_state_t *pWextState;
4902 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4903 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4904 hdd_context_t *hdd_ctx;
4905 int ret;
4906
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004907 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004908
4909 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4910 ret = wlan_hdd_validate_context(hdd_ctx);
4911 if (0 != ret)
4912 return ret;
4913
Jeff Johnson441e1f72017-02-07 08:50:49 -08004914 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4915 if (0 != ret)
4916 return ret;
4917
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4919 wrqu->bitrate.value = 0;
4920 } else {
4921 status =
4922 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4923 eCSR_HDD,
4924 SME_SUMMARY_STATS |
4925 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -08004926 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927 hdd_statistics_cb, 0,
4928 false,
4929 pHddStaCtx->conn_info.staId[0],
4930 pAdapter, pAdapter->sessionId);
4931
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304932 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004933 hdd_err("Unable to retrieve statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004934 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004935 }
4936
4937 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4938
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004939 status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304940 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 WLAN_WAIT_TIME_STATS);
4942
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004943 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004944 hdd_err("SME timeout while retrieving statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004945 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946 }
4947
4948 wrqu->bitrate.value =
4949 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
4950 }
4951
4952 EXIT();
4953
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004954 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955}
4956
4957/**
4958 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
4959 * @dev: pointer to net_device
4960 * @info: pointer to iw_request_info
4961 * @wrqu: pointer to iwreq_data
4962 * @extra: pointer to extra ioctl payload
4963 *
4964 * Return: 0 on success, error number otherwise
4965 */
4966static int iw_get_bitrate(struct net_device *dev,
4967 struct iw_request_info *info,
4968 union iwreq_data *wrqu, char *extra)
4969{
4970 int ret;
4971
4972 cds_ssr_protect(__func__);
4973 ret = __iw_get_bitrate(dev, info, wrqu, extra);
4974 cds_ssr_unprotect(__func__);
4975
4976 return ret;
4977}
4978
4979/**
4980 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
4981 * @dev: device upon which the ioctl was received
4982 * @info: ioctl request information
4983 * @wrqu: ioctl request data
4984 * @extra: ioctl extra data
4985 *
4986 * Return: 0 on success, non-zero on error
4987 */
4988static int __iw_set_bitrate(struct net_device *dev,
4989 struct iw_request_info *info,
4990 union iwreq_data *wrqu, char *extra)
4991{
4992 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4993 hdd_wext_state_t *pWextState;
4994 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4995 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4996 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4997 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4998 uint32_t i, rate;
4999 uint32_t valid_rate = false, active_phy_mode = 0;
5000 hdd_context_t *hdd_ctx;
5001 int ret;
5002
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005003 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005004
5005 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5006 ret = wlan_hdd_validate_context(hdd_ctx);
5007 if (0 != ret)
5008 return ret;
5009
Jeff Johnson441e1f72017-02-07 08:50:49 -08005010 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5011 if (0 != ret)
5012 return ret;
5013
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5015
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005016 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005018
5019 rate = wrqu->bitrate.value;
5020
5021 if (rate == -1) {
5022 rate = WNI_CFG_FIXED_RATE_AUTO;
5023 valid_rate = true;
5024 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
5025 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305026 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005027 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5028 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
5029 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
5030 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
5031 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305032 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 &&
5034 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
5035 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305036 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005037 for (i = 0; i < (b_len + a_len); ++i) {
5038 /* supported rates returned is double
5039 * the actual rate so we divide it by 2
5040 */
5041 if ((supp_rates[i] & 0x7F) / 2 ==
5042 rate) {
5043 valid_rate = true;
5044 rate = i +
5045 WNI_CFG_FIXED_RATE_1MBPS;
5046 break;
5047 }
5048 }
5049 }
5050 }
5051 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005052 if (valid_rate != true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005053 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005054
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305056 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005057 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005058 return -EIO;
5059 }
5060 return 0;
5061}
5062
5063/**
5064 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
5065 * @dev: pointer to net_device
5066 * @info: pointer to iw_request_info
5067 * @wrqu: pointer to iwreq_data
5068 * @extra: pointer to extra ioctl payload
5069 *
5070 * Return: 0 on success, error number otherwise
5071 */
5072static int iw_set_bitrate(struct net_device *dev,
5073 struct iw_request_info *info,
5074 union iwreq_data *wrqu, char *extra)
5075{
5076 int ret;
5077
5078 cds_ssr_protect(__func__);
5079 ret = __iw_set_bitrate(dev, info, wrqu, extra);
5080 cds_ssr_unprotect(__func__);
5081
5082 return ret;
5083}
5084
5085/**
5086 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
5087 * @dev: device upon which the ioctl was received
5088 * @info: ioctl request information
5089 * @wrqu: ioctl request data
5090 * @extra: ioctl extra data
5091 *
5092 * Return: 0 on success, non-zero on error
5093 */
5094static int __iw_set_genie(struct net_device *dev,
5095 struct iw_request_info *info,
5096 union iwreq_data *wrqu, char *extra)
5097{
5098 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5099 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5100 uint8_t *genie = NULL;
5101 uint8_t *base_genie = NULL;
5102 uint16_t remLen;
5103 hdd_context_t *hdd_ctx;
5104 int ret;
5105
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005106 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005107
5108 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5109 ret = wlan_hdd_validate_context(hdd_ctx);
5110 if (0 != ret)
5111 return ret;
5112
Jeff Johnson441e1f72017-02-07 08:50:49 -08005113 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5114 if (0 != ret)
5115 return ret;
5116
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 if (!wrqu->data.length) {
5118 hdd_clear_roam_profile_ie(pAdapter);
5119 EXIT();
5120 return 0;
5121 }
5122
5123 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
5124 wrqu->data.length);
5125 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005126 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 return -ENOMEM;
5128 }
5129
5130 genie = base_genie;
5131
5132 remLen = wrqu->data.length;
5133
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005134 hdd_debug("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005135 genie[1]);
5136
5137 /* clear any previous genIE before this call */
5138 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5139
5140 while (remLen >= 2) {
5141 uint16_t eLen = 0;
5142 uint8_t elementId;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144 elementId = *genie++;
5145 eLen = *genie++;
5146 remLen -= 2;
5147
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005148 hdd_debug("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005149
5150 switch (elementId) {
5151 case IE_EID_VENDOR:
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005152 /* should have at least OUI */
5153 if ((IE_LEN_SIZE + IE_EID_SIZE + IE_VENDOR_OUI_SIZE) > eLen) {
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305154 ret = -EINVAL;
5155 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 }
5157
5158 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
5159 uint16_t curGenIELen = pWextState->genIE.length;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005160
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005161 hdd_debug("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
Jeff Johnson99bac312016-06-28 10:38:18 -07005162 genie[0], genie[1], genie[2],
5163 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005164
5165 if (SIR_MAC_MAX_IE_LENGTH <
5166 (pWextState->genIE.length + eLen)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005167 hdd_err("genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305168 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305169 ret = -ENOMEM;
5170 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005172 /* save to Additional IE; it should be
5173 * accumulated to handle WPS IE + other IE
5174 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 memcpy(pWextState->genIE.addIEdata +
5176 curGenIELen, genie - 2, eLen + 2);
5177 pWextState->genIE.length += eLen + 2;
5178 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005179 hdd_debug("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305180 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005181 hdd_err("genIE, Need bigger buffer space");
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305182 ret = -EINVAL;
5183 QDF_ASSERT(0);
5184 goto exit;
5185 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005186 memset(pWextState->WPARSNIE, 0,
5187 MAX_WPA_RSN_IE_LEN);
5188 memcpy(pWextState->WPARSNIE, genie - 2,
5189 (eLen + 2));
5190 pWextState->roamProfile.pWPAReqIE =
5191 pWextState->WPARSNIE;
5192 pWextState->roamProfile.nWPAReqIELength =
5193 eLen + 2;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005194 } else {
5195 /* any vendorId except WPA IE should
5196 * be accumulated to genIE
5197 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005198 uint16_t curGenIELen = pWextState->genIE.length;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005199
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005200 hdd_debug("Set OUI(%02x %02x %02x %02x) IE(len %d)",
Jeff Johnson99bac312016-06-28 10:38:18 -07005201 genie[0], genie[1], genie[2],
5202 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005203
5204 if (SIR_MAC_MAX_IE_LENGTH <
5205 (pWextState->genIE.length + eLen)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005206 hdd_err("genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305207 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305208 ret = -ENOMEM;
5209 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005211 /* save to Additional IE; it should be
5212 * accumulated to handle WPS IE + other IE
5213 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005214 memcpy(pWextState->genIE.addIEdata +
5215 curGenIELen, genie - 2, eLen + 2);
5216 pWextState->genIE.length += eLen + 2;
5217 }
5218 break;
5219 case DOT11F_EID_RSN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005220 hdd_debug("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305221 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005222 hdd_err("genIE, Need bigger buffer space");
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305223 ret = -EINVAL;
5224 QDF_ASSERT(0);
5225 goto exit;
5226 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005227 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
5228 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
5229 pWextState->roamProfile.pRSNReqIE =
5230 pWextState->WPARSNIE;
5231 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
5232 break;
5233
5234 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005235 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305236 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005237 }
5238 genie += eLen;
5239 remLen -= eLen;
5240 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305241exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005242 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07005243 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305244 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005245}
5246
5247/**
5248 * iw_set_genie() - SSR wrapper for __iw_set_genie()
5249 * @dev: pointer to net_device
5250 * @info: pointer to iw_request_info
5251 * @wrqu: pointer to iwreq_data
5252 * @extra: pointer to extra ioctl payload
5253 *
5254 * Return: 0 on success, error number otherwise
5255 */
5256static int iw_set_genie(struct net_device *dev,
5257 struct iw_request_info *info,
5258 union iwreq_data *wrqu, char *extra)
5259{
5260 int ret;
5261
5262 cds_ssr_protect(__func__);
5263 ret = __iw_set_genie(dev, info, wrqu, extra);
5264 cds_ssr_unprotect(__func__);
5265
5266 return ret;
5267}
5268
5269/**
5270 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
5271 * @dev: device upon which the ioctl was received
5272 * @info: ioctl request information
5273 * @wrqu: ioctl request data
5274 * @extra: ioctl extra data
5275 *
5276 * Return: 0 on success, non-zero on error
5277 */
5278static int __iw_get_genie(struct net_device *dev,
5279 struct iw_request_info *info,
5280 union iwreq_data *wrqu, char *extra)
5281{
5282 hdd_wext_state_t *pWextState;
5283 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5284 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305285 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
5287 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
5288 hdd_context_t *hdd_ctx;
5289 int ret;
5290
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005291 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005292
5293 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5294 ret = wlan_hdd_validate_context(hdd_ctx);
5295 if (0 != ret)
5296 return ret;
5297
Jeff Johnson441e1f72017-02-07 08:50:49 -08005298 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5299 if (0 != ret)
5300 return ret;
5301
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005302 hdd_debug("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303
5304 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5305
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005306 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308
5309 /* Return something ONLY if we are associated with an RSN or
5310 * WPA network
5311 */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005312 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005313 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314
5315 /* Actually retrieve the RSN IE from CSR. (We previously sent
5316 * it down in the CSR Roam Profile.)
5317 */
5318 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
5319 pAdapter->sessionId,
5320 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305321 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005322 hdd_err("Failed to get WPA-RSN IE data status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323 return -EFAULT;
5324 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005325 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05305326 if (length > DOT11F_IE_RSN_MAX_LEN) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005327 hdd_err("Invalid buffer length: %d", length);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305328 return -E2BIG;
5329 }
5330 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005332 hdd_debug("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 wrqu->data.length);
5334
5335 EXIT();
5336
5337 return 0;
5338}
5339
5340/**
5341 * iw_get_genie() - SSR wrapper for __iw_get_genie()
5342 * @dev: pointer to net_device
5343 * @info: pointer to iw_request_info
5344 * @wrqu: pointer to iwreq_data
5345 * @extra: pointer to extra ioctl payload
5346 *
5347 * Return: 0 on success, error number otherwise
5348 */
5349static int iw_get_genie(struct net_device *dev,
5350 struct iw_request_info *info,
5351 union iwreq_data *wrqu, char *extra)
5352{
5353 int ret;
5354
5355 cds_ssr_protect(__func__);
5356 ret = __iw_get_genie(dev, info, wrqu, extra);
5357 cds_ssr_unprotect(__func__);
5358
5359 return ret;
5360}
5361
5362/**
5363 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
5364 * @dev: device upon which the ioctl was received
5365 * @info: ioctl request information
5366 * @wrqu: ioctl request data
5367 * @extra: ioctl extra data
5368 *
5369 * Return: 0 on success, non-zero on error
5370 */
5371static int __iw_get_encode(struct net_device *dev,
5372 struct iw_request_info *info,
5373 struct iw_point *dwrq, char *extra)
5374{
5375 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5376 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5377 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5378 int keyId;
5379 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
5380 int i;
5381 hdd_context_t *hdd_ctx;
5382 int ret;
5383
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005384 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005385
5386 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5387 ret = wlan_hdd_validate_context(hdd_ctx);
5388 if (0 != ret)
5389 return ret;
5390
Jeff Johnson441e1f72017-02-07 08:50:49 -08005391 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5392 if (0 != ret)
5393 return ret;
5394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005395 keyId = pRoamProfile->Keys.defaultIndex;
5396
5397 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005398 hdd_err("Invalid keyId: %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 return -EINVAL;
5400 }
5401
5402 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
5403 dwrq->flags |= IW_ENCODE_ENABLED;
5404 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305405 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406 pRoamProfile->Keys.KeyLength[keyId]);
5407
5408 dwrq->flags |= (keyId + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005409 } else {
5410 dwrq->flags |= IW_ENCODE_DISABLED;
5411 }
5412
5413 for (i = 0; i < MAX_WEP_KEYS; i++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005414 if (pRoamProfile->Keys.KeyLength[i] == 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005415 continue;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005416 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005417 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418 }
5419
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005420 if (MAX_WEP_KEYS == i)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005421 dwrq->flags |= IW_ENCODE_NOKEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005422
5423 authType =
5424 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
5425 conn_info.authType;
5426
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005427 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 dwrq->flags |= IW_ENCODE_OPEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005429 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 dwrq->flags |= IW_ENCODE_RESTRICTED;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005431
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432 EXIT();
5433 return 0;
5434}
5435
5436/**
5437 * iw_get_encode() - SSR wrapper for __iw_get_encode()
5438 * @dev: pointer to net_device
5439 * @info: pointer to iw_request_info
5440 * @dwrq: pointer to encoding information
5441 * @extra: pointer to extra ioctl payload
5442 *
5443 * Return: 0 on success, error number otherwise
5444 */
5445static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
5446 struct iw_point *dwrq, char *extra)
5447{
5448 int ret;
5449
5450 cds_ssr_protect(__func__);
5451 ret = __iw_get_encode(dev, info, dwrq, extra);
5452 cds_ssr_unprotect(__func__);
5453
5454 return ret;
5455}
5456
5457/**
5458 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
5459 * @dev: device upon which the ioctl was received
5460 * @info: ioctl request information
5461 * @wrqu: ioctl request data
5462 * @extra: ioctl extra data
5463 *
5464 * Return: 0 on success, non-zero on error
5465 */
5466static int __iw_get_rts_threshold(struct net_device *dev,
5467 struct iw_request_info *info,
5468 union iwreq_data *wrqu, char *extra)
5469{
Jeff Johnson5b907622017-02-07 10:00:37 -08005470 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5471 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5472 uint32_t threshold = 0;
5473 hdd_context_t *hdd_ctx;
5474 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005475
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005476 ENTER_DEV(dev);
5477
Jeff Johnson5b907622017-02-07 10:00:37 -08005478 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5479 ret = wlan_hdd_validate_context(hdd_ctx);
5480 if (0 != ret)
5481 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005482
Jeff Johnson441e1f72017-02-07 08:50:49 -08005483 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5484 if (0 != ret)
5485 return ret;
5486
Jeff Johnson5b907622017-02-07 10:00:37 -08005487 if (QDF_STATUS_SUCCESS !=
5488 sme_cfg_get_int(hal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
5489 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
5490 return -EIO;
5491 }
5492 wrqu->rts.value = threshold;
5493
5494 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
5495
5496 EXIT();
5497
5498 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499}
5500
5501/**
5502 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
5503 * @dev: device upon which the ioctl was received
5504 * @info: ioctl request information
5505 * @wrqu: ioctl request data
5506 * @extra: ioctl extra data
5507 *
5508 * Return: 0 on success, non-zero on error
5509 */
5510static int __iw_set_rts_threshold(struct net_device *dev,
5511 struct iw_request_info *info,
5512 union iwreq_data *wrqu, char *extra)
5513{
5514 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5515 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5516 hdd_context_t *hdd_ctx;
5517 int ret;
5518
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005519 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520
5521 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5522 ret = wlan_hdd_validate_context(hdd_ctx);
5523 if (0 != ret)
5524 return ret;
5525
Jeff Johnson441e1f72017-02-07 08:50:49 -08005526 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5527 if (0 != ret)
5528 return ret;
5529
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
5531 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
5532 return -EINVAL;
5533 }
5534
5535 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305536 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005537 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538 return -EIO;
5539 }
5540
5541 EXIT();
5542
5543 return 0;
5544}
5545
5546/**
5547 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
5548 * @dev: pointer to net_device
5549 * @info: pointer to iw_request_info
5550 * @wrqu: pointer to iwreq_data
5551 * @extra: pointer to extra ioctl payload
5552 *
5553 * Return: 0 on success, error number otherwise
5554 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005555int iw_get_rts_threshold(struct net_device *dev,
5556 struct iw_request_info *info,
5557 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558{
5559 int ret;
5560
5561 cds_ssr_protect(__func__);
5562 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
5563 cds_ssr_unprotect(__func__);
5564
5565 return ret;
5566}
5567
5568/**
5569 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
5570 * @dev: pointer to net_device
5571 * @info: pointer to iw_request_info
5572 * @wrqu: pointer to iwreq_data
5573 * @extra: pointer to extra ioctl payload
5574 *
5575 * Return: 0 on success, error number otherwise
5576 */
5577static int iw_set_rts_threshold(struct net_device *dev,
5578 struct iw_request_info *info,
5579 union iwreq_data *wrqu, char *extra)
5580{
5581 int ret;
5582
5583 cds_ssr_protect(__func__);
5584 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
5585 cds_ssr_unprotect(__func__);
5586
5587 return ret;
5588}
5589
5590/**
5591 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
5592 * @dev: device upon which the ioctl was received
5593 * @info: ioctl request information
5594 * @wrqu: ioctl request data
5595 * @extra: ioctl extra data
5596 *
5597 * Return: 0 on success, non-zero on error
5598 */
5599static int __iw_get_frag_threshold(struct net_device *dev,
5600 struct iw_request_info *info,
5601 union iwreq_data *wrqu, char *extra)
5602{
Jeff Johnson5b907622017-02-07 10:00:37 -08005603 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5604 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5605 uint32_t threshold = 0;
5606 hdd_context_t *hdd_ctx;
5607 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005609 ENTER_DEV(dev);
5610
Jeff Johnson5b907622017-02-07 10:00:37 -08005611 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5612 ret = wlan_hdd_validate_context(hdd_ctx);
5613 if (0 != ret)
5614 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615
Jeff Johnson441e1f72017-02-07 08:50:49 -08005616 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5617 if (0 != ret)
5618 return ret;
5619
Jeff Johnson5b907622017-02-07 10:00:37 -08005620 if (sme_cfg_get_int(hal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
5621 != QDF_STATUS_SUCCESS) {
5622 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
5623 return -EIO;
5624 }
5625 wrqu->frag.value = threshold;
5626
5627 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
5628
5629 EXIT();
5630
5631 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632}
5633
5634/**
5635 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
5636 * @dev: pointer to net_device
5637 * @info: pointer to iw_request_info
5638 * @wrqu: pointer to iwreq_data
5639 * @extra: pointer to extra ioctl payload
5640 *
5641 * Return: 0 on success, error number otherwise
5642 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005643int iw_get_frag_threshold(struct net_device *dev,
5644 struct iw_request_info *info,
5645 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005646{
5647 int ret;
5648
5649 cds_ssr_protect(__func__);
5650 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
5651 cds_ssr_unprotect(__func__);
5652
5653 return ret;
5654}
5655
5656/**
5657 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
5658 * @dev: device upon which the ioctl was received
5659 * @info: ioctl request information
5660 * @wrqu: ioctl request data
5661 * @extra: ioctl extra data
5662 *
5663 * Return: 0 on success, non-zero on error
5664 */
5665static int __iw_set_frag_threshold(struct net_device *dev,
5666 struct iw_request_info *info,
5667 union iwreq_data *wrqu, char *extra)
5668{
5669 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5670 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5671 hdd_context_t *hdd_ctx;
5672 int ret;
5673
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005674 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005675
5676 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5677 ret = wlan_hdd_validate_context(hdd_ctx);
5678 if (0 != ret)
5679 return ret;
5680
Jeff Johnson441e1f72017-02-07 08:50:49 -08005681 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5682 if (0 != ret)
5683 return ret;
5684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005685 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
5686 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
5687 return -EINVAL;
5688 }
5689
5690 if (sme_cfg_set_int
5691 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305692 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005693 hdd_err("WNI_CFG_FRAGMENTATION_THRESHOLD failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005694 return -EIO;
5695 }
5696
5697 EXIT();
5698
5699 return 0;
5700}
5701
5702/**
5703 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
5704 * @dev: pointer to net_device
5705 * @info: pointer to iw_request_info
5706 * @wrqu: pointer to iwreq_data
5707 * @extra: pointer to extra ioctl payload
5708 *
5709 * Return: 0 on success, error number otherwise
5710 */
5711static int iw_set_frag_threshold(struct net_device *dev,
5712 struct iw_request_info *info,
5713 union iwreq_data *wrqu, char *extra)
5714{
5715 int ret;
5716
5717 cds_ssr_protect(__func__);
5718 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
5719 cds_ssr_unprotect(__func__);
5720
5721 return ret;
5722}
5723
5724/**
5725 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
5726 * @dev: device upon which the ioctl was received
5727 * @info: ioctl request information
5728 * @wrqu: ioctl request data
5729 * @extra: ioctl extra data
5730 *
5731 * Return: 0 on success, non-zero on error
5732 */
5733static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005734 struct iw_request_info *info,
5735 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736{
5737 hdd_adapter_t *adapter;
5738 hdd_context_t *hdd_ctx;
5739 int ret;
5740
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005741 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742
5743 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5744 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5745 ret = wlan_hdd_validate_context(hdd_ctx);
5746 if (0 != ret)
5747 return ret;
5748
Jeff Johnson441e1f72017-02-07 08:50:49 -08005749 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5750 if (0 != ret)
5751 return ret;
5752
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753 return -EOPNOTSUPP;
5754}
5755
5756/**
5757 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
5758 * @dev: pointer to net_device
5759 * @info: pointer to iw_request_info
5760 * @wrqu: pointer to iwreq_data
5761 * @extra: extra
5762 *
5763 * Return: 0 on success, error number otherwise
5764 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005765static int iw_get_power_mode(struct net_device *dev,
5766 struct iw_request_info *info,
5767 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768{
5769 int ret;
5770
5771 cds_ssr_protect(__func__);
5772 ret = __iw_get_power_mode(dev, info, wrqu, extra);
5773 cds_ssr_unprotect(__func__);
5774
5775 return ret;
5776}
5777
5778/**
5779 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
5780 * @dev: device upon which the ioctl was received
5781 * @info: ioctl request information
5782 * @wrqu: ioctl request data
5783 * @extra: ioctl extra data
5784 *
5785 * Return: 0 on success, non-zero on error
5786 */
5787static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005788 struct iw_request_info *info,
5789 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790{
5791 hdd_adapter_t *adapter;
5792 hdd_context_t *hdd_ctx;
5793 int ret;
5794
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005795 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005796
5797 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5798 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5799 ret = wlan_hdd_validate_context(hdd_ctx);
5800 if (0 != ret)
5801 return ret;
5802
Jeff Johnson441e1f72017-02-07 08:50:49 -08005803 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5804 if (0 != ret)
5805 return ret;
5806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005807 return -EOPNOTSUPP;
5808}
5809
5810/**
5811 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
5812 * @dev: pointer to net_device
5813 * @info: pointer to iw_request_info
5814 * @wrqu: pointer to iwreq_data
5815 * @extra: extra
5816 *
5817 * Return: 0 on success, error number otherwise
5818 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005819static int iw_set_power_mode(struct net_device *dev,
5820 struct iw_request_info *info,
5821 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005822{
5823 int ret;
5824
5825 cds_ssr_protect(__func__);
5826 ret = __iw_set_power_mode(dev, info, wrqu, extra);
5827 cds_ssr_unprotect(__func__);
5828
5829 return ret;
5830}
5831
5832/**
5833 * __iw_get_range() - SIOCGIWRANGE ioctl handler
5834 * @dev: device upon which the ioctl was received
5835 * @info: ioctl request information
5836 * @wrqu: ioctl request data
5837 * @extra: ioctl extra data
5838 *
5839 * Return: 0 on success, non-zero on error
5840 */
5841static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
5842 union iwreq_data *wrqu, char *extra)
5843{
5844 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5845 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5846 struct iw_range *range = (struct iw_range *)extra;
5847
5848 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5849
5850 uint32_t num_channels = sizeof(channels);
5851 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
5852 uint32_t a_len;
5853 uint32_t b_len;
5854 uint32_t active_phy_mode = 0;
5855 uint8_t index = 0, i;
5856 hdd_context_t *hdd_ctx;
5857 int ret;
5858
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005859 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860
5861 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5862 ret = wlan_hdd_validate_context(hdd_ctx);
5863 if (0 != ret)
5864 return ret;
5865
Jeff Johnson441e1f72017-02-07 08:50:49 -08005866 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5867 if (0 != ret)
5868 return ret;
5869
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005870 wrqu->data.length = sizeof(struct iw_range);
5871 memset(range, 0, sizeof(struct iw_range));
5872
5873
5874 /*Get the phy mode */
5875 if (sme_cfg_get_int(hHal,
5876 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305877 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005878 hdd_debug("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005879
5880 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5881 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
5882 /*Get the supported rates for 11G band */
5883 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5884 if (sme_cfg_get_str(hHal,
5885 WNI_CFG_SUPPORTED_RATES_11A,
5886 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305887 &a_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005888 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005890
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 for (i = 0; i < a_len; i++) {
5892 range->bitrate[i] =
5893 ((supp_rates[i] & 0x7F) / 2) *
5894 1000000;
5895 }
5896 range->num_bitrates = a_len;
5897 } else {
5898 return -EIO;
5899 }
5900 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
5901 /*Get the supported rates for 11B band */
5902 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5903 if (sme_cfg_get_str(hHal,
5904 WNI_CFG_SUPPORTED_RATES_11B,
5905 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305906 &b_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005907 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005908 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005909
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005910 for (i = 0; i < b_len; i++) {
5911 range->bitrate[i] =
5912 ((supp_rates[i] & 0x7F) / 2) *
5913 1000000;
5914 }
5915 range->num_bitrates = b_len;
5916 } else {
5917 return -EIO;
5918 }
5919 }
5920 }
5921
5922 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
5923 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
5924 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
5925
5926 range->encoding_size[0] = 5;
5927 range->encoding_size[1] = 13;
5928 range->num_encoding_sizes = 2;
5929 range->max_encoding_tokens = MAX_WEP_KEYS;
5930
5931 /* we support through Wireless Extensions 22 */
5932 range->we_version_compiled = WIRELESS_EXT;
5933 range->we_version_source = 22;
5934
5935 /*Supported Channels and Frequencies */
5936 if (sme_cfg_get_str
5937 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305938 &num_channels) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005939 hdd_err("Failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005940 return -EIO;
5941 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005942 if (num_channels > IW_MAX_FREQUENCIES)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005943 num_channels = IW_MAX_FREQUENCIES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944
5945 range->num_channels = num_channels;
5946 range->num_frequency = num_channels;
5947
5948 for (index = 0; index < num_channels; index++) {
5949 uint32_t frq_indx = 0;
5950
5951 range->freq[index].i = channels[index];
5952 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
5953 if (channels[index] == freq_chan_map[frq_indx].chan) {
5954 range->freq[index].m =
5955 freq_chan_map[frq_indx].freq * 100000;
5956 range->freq[index].e = 1;
5957 break;
5958 }
5959 frq_indx++;
5960 }
5961 }
5962
5963 /* Event capability (kernel + driver) */
5964 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
5965 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
5966 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
5967 range->event_capa[1] = IW_EVENT_CAPA_K_1;
5968
5969 /*Encryption capability */
5970 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
5971 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
5972
5973 /* Txpower capability */
5974 range->txpower_capa = IW_TXPOW_MWATT;
5975
5976 /*Scanning capability */
5977#if WIRELESS_EXT >= 22
5978 range->scan_capa =
5979 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
5980#endif
5981
5982 EXIT();
5983 return 0;
5984}
5985
5986/**
5987 * iw_get_range() - SSR wrapper for __iw_get_range()
5988 * @dev: pointer to net_device
5989 * @info: pointer to iw_request_info
5990 * @wrqu: pointer to iwreq_data
5991 * @extra: pointer to extra ioctl payload
5992 *
5993 * Return: 0 on success, error number otherwise
5994 */
5995static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
5996 union iwreq_data *wrqu, char *extra)
5997{
5998 int ret;
5999
6000 cds_ssr_protect(__func__);
6001 ret = __iw_get_range(dev, info, wrqu, extra);
6002 cds_ssr_unprotect(__func__);
6003
6004 return ret;
6005}
6006
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006007struct class_a_stats {
6008 tCsrGlobalClassAStatsInfo class_a_stats;
6009};
6010
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011/**
6012 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006013 * @stats: pointer to Class A stats
6014 * @context: user context originally registered with SME (always the
6015 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 *
6017 * Return: None
6018 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006019static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006020{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006021 struct hdd_request *request;
6022 struct class_a_stats *priv;
6023 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006024
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006025 ENTER();
6026 if ((NULL == stats) || (NULL == context)) {
6027 hdd_err("Bad param, stats [%p] context [%p]",
6028 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006029 return;
6030 }
6031
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006032 request = hdd_request_get(context);
6033 if (!request) {
6034 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 return;
6036 }
6037
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006038 returned_stats = stats;
6039 priv = hdd_request_priv(request);
6040 priv->class_a_stats = *returned_stats;
6041 hdd_request_complete(request);
6042 hdd_request_put(request);
6043 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044}
6045
6046/**
6047 * wlan_hdd_get_class_astats() - Get Class A statistics
6048 * @pAdapter: adapter for which statistics are desired
6049 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306050 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306052QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006053{
6054 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306055 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006056 int ret;
6057 void *cookie;
6058 struct hdd_request *request;
6059 struct class_a_stats *priv;
6060 static const struct hdd_request_params params = {
6061 .priv_size = sizeof(*priv),
6062 .timeout_ms = WLAN_WAIT_TIME_STATS,
6063 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006064
6065 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006066 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306067 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006068 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08006069 if (cds_is_driver_recovering()) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006070 hdd_debug("Recovery in Progress. State: 0x%x Ignore!!!",
Prashanth Bhatta9e143052015-12-04 11:56:47 -08006071 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306072 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006073 }
6074
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006075 request = hdd_request_alloc(&params);
6076 if (!request) {
6077 hdd_err("Request allocation failure");
6078 return QDF_STATUS_E_NOMEM;
6079 }
6080 cookie = hdd_request_cookie(request);
6081
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082 /* query only for Class A statistics (which include link speed) */
6083 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
6084 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
6085 hdd_get_class_a_statistics_cb,
6086 0, /* not periodic */
6087 false, /* non-cached results */
6088 pHddStaCtx->conn_info.staId[0],
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006089 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306090 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07006091 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006092 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093 }
6094
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006095 /* request was sent -- wait for the response */
6096 ret = hdd_request_wait_for_response(request);
6097 if (ret) {
6098 hdd_warn("SME timed out while retrieving Class A statistics");
6099 goto return_cached_results;
6100 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006101
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006102 /* update the adapter with the fresh results */
6103 priv = hdd_request_priv(request);
6104 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6105
6106return_cached_results:
6107 /*
6108 * either we never sent a request, we sent a request and
6109 * received a response or we sent a request and timed out.
6110 * regardless we are done with the request.
6111 */
6112 hdd_request_put(request);
6113
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306114 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006115}
6116
Jeff Johnsondda167c2017-01-23 10:37:57 -08006117struct station_stats {
6118 tCsrSummaryStatsInfo summary_stats;
6119 tCsrGlobalClassAStatsInfo class_a_stats;
6120 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
6121};
6122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123/**
6124 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08006125 * @stats: pointer to combined station stats
6126 * @context: user context originally registered with SME (always the
6127 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006128 *
6129 * Return: None
6130 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006131static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006132{
Jeff Johnsondda167c2017-01-23 10:37:57 -08006133 struct hdd_request *request;
6134 struct station_stats *priv;
6135 tCsrSummaryStatsInfo *summary_stats;
6136 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306137 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006138
Jeff Johnsondda167c2017-01-23 10:37:57 -08006139 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006140 hdd_err("Bad param, pStats [%p] pContext [%p]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08006141 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006142 return;
6143 }
6144
Jeff Johnsondda167c2017-01-23 10:37:57 -08006145 request = hdd_request_get(context);
6146 if (!request) {
6147 hdd_err("Obsolete request");
6148 return;
6149 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006150
Jeff Johnsondda167c2017-01-23 10:37:57 -08006151 summary_stats = (tCsrSummaryStatsInfo *) stats;
6152 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306153 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08006154 (class_a_stats + 1);
6155 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006156
6157 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006158 priv->summary_stats = *summary_stats;
6159 priv->class_a_stats = *class_a_stats;
6160 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006161
Jeff Johnsondda167c2017-01-23 10:37:57 -08006162 hdd_request_complete(request);
6163 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006164}
6165
6166/**
6167 * wlan_hdd_get_station_stats() - Get station statistics
6168 * @pAdapter: adapter for which statistics are desired
6169 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306170 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006171 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306172QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006173{
6174 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306175 QDF_STATUS hstatus;
Jeff Johnsondda167c2017-01-23 10:37:57 -08006176 int ret;
6177 void *cookie;
6178 struct hdd_request *request;
6179 struct station_stats *priv;
6180 static const struct hdd_request_params params = {
6181 .priv_size = sizeof(*priv),
6182 .timeout_ms = WLAN_WAIT_TIME_STATS,
6183 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184
6185 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006186 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306187 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006188 }
6189
Jeff Johnsondda167c2017-01-23 10:37:57 -08006190 request = hdd_request_alloc(&params);
6191 if (!request) {
6192 hdd_err("Request allocation failure");
6193 return QDF_STATUS_E_NOMEM;
6194 }
6195 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006196
6197 /* query only for Summary & Class A statistics */
6198 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
6199 eCSR_HDD,
6200 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306201 SME_GLOBAL_CLASSA_STATS |
6202 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 hdd_get_station_statistics_cb,
6204 0, /* not periodic */
6205 false, /* non-cached results */
6206 pHddStaCtx->conn_info.staId[0],
Jeff Johnsondda167c2017-01-23 10:37:57 -08006207 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306208 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006209 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210 /* we'll return with cached values */
6211 } else {
6212 /* request was sent -- wait for the response */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006213 ret = hdd_request_wait_for_response(request);
6214 if (ret) {
6215 hdd_warn("SME timed out while retrieving statistics");
6216 /* we'll returned a cached value below */
6217 } else {
6218 /* update the adapter with the fresh results */
6219 priv = hdd_request_priv(request);
6220 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
6221 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6222 pAdapter->hdd_stats.per_chain_rssi_stats =
6223 priv->per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006224 }
6225 }
6226
Jeff Johnsondda167c2017-01-23 10:37:57 -08006227 /*
6228 * either we never sent a request, we sent a request and
6229 * received a response or we sent a request and timed out.
6230 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006231 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006232 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006233
6234 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306235 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006236}
6237
6238/**
6239 * iw_get_linkspeed() - Get current link speed ioctl
6240 * @dev: device upon which the ioctl was received
6241 * @info: ioctl request information
6242 * @wrqu: ioctl request data
6243 * @extra: extra ioctl buffer
6244 *
6245 * Return: 0 on success, non-zero on error
6246 */
6247static int __iw_get_linkspeed(struct net_device *dev,
6248 struct iw_request_info *info,
6249 union iwreq_data *wrqu, char *extra)
6250{
6251 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6252 char *pLinkSpeed = (char *)extra;
6253 int len = sizeof(uint32_t) + 1;
6254 uint32_t link_speed = 0;
6255 hdd_context_t *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08006256 int ret;
6257 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006258
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006259 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306260
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006261 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08006262 ret = wlan_hdd_validate_context(hdd_ctx);
6263 if (0 != ret)
6264 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265
Jeff Johnson441e1f72017-02-07 08:50:49 -08006266 ret = hdd_check_private_wext_control(hdd_ctx, info);
6267 if (0 != ret)
6268 return ret;
6269
6270 ret = wlan_hdd_get_link_speed(pAdapter, &link_speed);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006271 if (0 != ret)
Jeff Johnson441e1f72017-02-07 08:50:49 -08006272 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006273
6274 wrqu->data.length = len;
6275 /* return the linkspeed as a string */
6276 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
6277 if ((rc < 0) || (rc >= len)) {
6278 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07006279 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006280 return -EIO;
6281 }
6282
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306283 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006284 /* a value is being successfully returned */
6285 return 0;
6286}
6287
6288static int iw_get_linkspeed(struct net_device *dev,
6289 struct iw_request_info *info,
6290 union iwreq_data *wrqu, char *extra)
6291{
6292 int ret;
6293
6294 cds_ssr_protect(__func__);
6295 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
6296 cds_ssr_unprotect(__func__);
6297
6298 return ret;
6299}
6300
6301/**
6302 * wlan_hdd_change_country_code_callback() - Change country code callback
6303 * @context: opaque context originally passed to SME. All functions
6304 * which use this callback pass the adapter upon which the country
6305 * code change is active
6306 *
6307 * This function is registered as the callback function when
6308 * sme_change_country_code() is invoked. Callers of
6309 * sme_change_country_code() subsequently wait for the adapter's
6310 * @change_country_code completion variable, so all this function
6311 * needs to do is set that completion variable so that execution can
6312 * continue.
6313 *
6314 * Return: none
6315 */
6316void wlan_hdd_change_country_code_callback(void *context)
6317{
6318
6319 hdd_adapter_t *adapter = context;
6320
6321 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
6322 complete(&adapter->change_country_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006323}
6324
6325/**
6326 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
6327 * @dev: device upon which the ioctl was received
6328 * @info: ioctl request information
6329 * @wrqu: ioctl request data
6330 * @extra: ioctl extra data
6331 *
6332 * Return: 0 on success, non-zero on error
6333 */
6334static int __iw_set_nick(struct net_device *dev,
6335 struct iw_request_info *info,
6336 union iwreq_data *wrqu, char *extra)
6337{
6338 hdd_adapter_t *adapter;
6339 hdd_context_t *hdd_ctx;
6340 int ret;
6341
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006342 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006343
6344 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6345 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6346 ret = wlan_hdd_validate_context(hdd_ctx);
6347 if (0 != ret)
6348 return ret;
6349
Jeff Johnson441e1f72017-02-07 08:50:49 -08006350 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6351 if (0 != ret)
6352 return ret;
6353
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006354 return 0;
6355}
6356
6357/**
6358 * iw_set_nick() - SSR wrapper for __iw_set_nick
6359 * @dev: pointer to net_device
6360 * @info: pointer to iw_request_info
6361 * @wrqu: pointer to iwreq_data
6362 * @extra: extra
6363 *
6364 * Return: 0 on success, error number otherwise
6365 */
6366static int iw_set_nick(struct net_device *dev,
6367 struct iw_request_info *info,
6368 union iwreq_data *wrqu, char *extra)
6369{
6370 int ret;
6371
6372 cds_ssr_protect(__func__);
6373 ret = __iw_set_nick(dev, info, wrqu, extra);
6374 cds_ssr_unprotect(__func__);
6375
6376 return ret;
6377}
6378
6379/**
6380 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
6381 * @dev: device upon which the ioctl was received
6382 * @info: ioctl request information
6383 * @wrqu: ioctl request data
6384 * @extra: ioctl extra data
6385 *
6386 * Return: 0 on success, non-zero on error
6387 */
6388static int __iw_get_nick(struct net_device *dev,
6389 struct iw_request_info *info,
6390 union iwreq_data *wrqu, char *extra)
6391{
6392 hdd_adapter_t *adapter;
6393 hdd_context_t *hdd_ctx;
6394 int ret;
6395
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006396 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006397
6398 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6399 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6400 ret = wlan_hdd_validate_context(hdd_ctx);
6401 if (0 != ret)
6402 return ret;
6403
Jeff Johnson441e1f72017-02-07 08:50:49 -08006404 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6405 if (0 != ret)
6406 return ret;
6407
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006408 return 0;
6409}
6410
6411/**
6412 * iw_get_nick() - SSR wrapper for __iw_get_nick
6413 * @dev: pointer to net_device
6414 * @info: pointer to iw_request_info
6415 * @wrqu: pointer to iwreq_data
6416 * @extra: extra
6417 *
6418 * Return: 0 on success, error number otherwise
6419 */
6420static int iw_get_nick(struct net_device *dev,
6421 struct iw_request_info *info,
6422 union iwreq_data *wrqu, char *extra)
6423{
6424 int ret;
6425
6426 cds_ssr_protect(__func__);
6427 ret = __iw_get_nick(dev, info, wrqu, extra);
6428 cds_ssr_unprotect(__func__);
6429
6430 return ret;
6431}
6432
6433/**
6434 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
6435 * @dev: device upon which the ioctl was received
6436 * @info: ioctl request information
6437 * @wrqu: ioctl request data
6438 * @extra: ioctl extra data
6439 *
6440 * Return: 0 on success, non-zero on error
6441 */
6442static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6443 union iwreq_data *wrqu, char *extra)
6444{
6445 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6446 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6447 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6448 hdd_context_t *hdd_ctx;
6449 struct iw_point *encoderq = &(wrqu->encoding);
6450 uint32_t keyId;
6451 uint8_t key_length;
6452 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6453 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306454 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006455 int ret;
6456
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006457 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006458
6459 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6460 ret = wlan_hdd_validate_context(hdd_ctx);
6461 if (0 != ret)
6462 return ret;
6463
Jeff Johnson441e1f72017-02-07 08:50:49 -08006464 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6465 if (0 != ret)
6466 return ret;
6467
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006468 keyId = encoderq->flags & IW_ENCODE_INDEX;
6469
6470 if (keyId) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006471 if (keyId > MAX_WEP_KEYS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006472 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006473
6474 fKeyPresent = 1;
6475 keyId--;
6476 } else {
6477 fKeyPresent = 0;
6478 }
6479
6480 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006481 hdd_debug("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006482 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006483 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
6484 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006485 }
6486 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6487 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6488 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6489 eCSR_ENCRYPT_TYPE_NONE;
6490 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6491 eCSR_ENCRYPT_TYPE_NONE;
6492
6493 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6494 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6495
6496 if (eConnectionState_Associated ==
6497 pHddStaCtx->conn_info.connState) {
6498 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6499 status =
6500 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
6501 pAdapter->sessionId,
6502 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306503 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006504 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006506 rc = wait_for_completion_timeout(&pAdapter->
6507 disconnect_comp_var,
6508 msecs_to_jiffies
6509 (WLAN_WAIT_TIME_DISCONNECT));
6510 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006511 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006512 }
6513 }
6514
6515 return status;
6516
6517 }
6518
6519 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006520 hdd_debug("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006521
6522 pHddStaCtx->conn_info.authType =
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006523 (encoderq->flags & IW_ENCODE_RESTRICTED) ?
6524 eCSR_AUTH_TYPE_SHARED_KEY :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006525 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6526
6527 }
6528
6529 if (wrqu->data.length > 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006530 hdd_debug("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006531
6532 key_length = wrqu->data.length;
6533
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006534 /* IW_ENCODING_TOKEN_MAX is the value that is set
6535 * for wrqu->data.length by iwconfig.c
6536 * when 'iwconfig wlan0 key on' is issued.
6537 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006538
6539 if (5 == key_length) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006540 hdd_debug("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006541 key_length);
6542
6543 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6544 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6545 pHddStaCtx->conn_info.authType)) {
6546 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
6547 } else {
6548 encryptionType =
6549 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6550 }
6551 } else if (13 == key_length) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006552 hdd_debug("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006553 key_length);
6554
6555 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6556 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6557 pHddStaCtx->conn_info.authType)) {
6558 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
6559 } else {
6560 encryptionType =
6561 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6562 }
6563 } else {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006564 hdd_err("Invalid WEP key length :%d", key_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006565 return -EINVAL;
6566 }
6567
6568 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6569 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
6570 pWextState->roamProfile.EncryptionType.numEntries = 1;
6571 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6572 encryptionType;
6573 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
6574 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6575 encryptionType;
6576
6577 if ((eConnectionState_NotConnected ==
6578 pHddStaCtx->conn_info.connState)
6579 &&
6580 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6581 pHddStaCtx->conn_info.authType)
6582 || (eCSR_AUTH_TYPE_SHARED_KEY ==
6583 pHddStaCtx->conn_info.authType))) {
6584
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306585 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006586 KeyMaterial[keyId][0], extra, key_length);
6587
6588 pWextState->roamProfile.Keys.KeyLength[keyId] =
6589 (uint8_t) key_length;
6590 pWextState->roamProfile.Keys.defaultIndex =
6591 (uint8_t) keyId;
6592
6593 return status;
6594 }
6595 }
6596
6597 return 0;
6598}
6599
6600/**
6601 * iw_set_encode() - SSR wrapper for __iw_set_encode()
6602 * @dev: pointer to net_device
6603 * @info: pointer to iw_request_info
6604 * @wrqu: pointer to iwreq_data
6605 * @extra: pointer to extra ioctl payload
6606 *
6607 * Return: 0 on success, error number otherwise
6608 */
6609static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6610 union iwreq_data *wrqu, char *extra)
6611{
6612 int ret;
6613
6614 cds_ssr_protect(__func__);
6615 ret = __iw_set_encode(dev, info, wrqu, extra);
6616 cds_ssr_unprotect(__func__);
6617
6618 return ret;
6619}
6620
6621/**
6622 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
6623 * @dev: device upon which the ioctl was received
6624 * @info: ioctl request information
6625 * @wrqu: ioctl request data
6626 * @extra: ioctl extra data
6627 *
6628 * Return: 0 on success, non-zero on error
6629 */
6630static int __iw_get_encodeext(struct net_device *dev,
6631 struct iw_request_info *info,
6632 struct iw_point *dwrq, char *extra)
6633{
6634 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6635 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6636 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
6637 int keyId;
6638 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6639 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
6640 int i, ret;
6641 hdd_context_t *hdd_ctx;
6642
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006643 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006644
6645 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6646 ret = wlan_hdd_validate_context(hdd_ctx);
6647 if (0 != ret)
6648 return ret;
6649
Jeff Johnson441e1f72017-02-07 08:50:49 -08006650 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6651 if (0 != ret)
6652 return ret;
6653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006654 keyId = pRoamProfile->Keys.defaultIndex;
6655
6656 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006657 hdd_err("Invalid keyId: %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006658 return -EINVAL;
6659 }
6660
6661 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
6662 dwrq->flags |= IW_ENCODE_ENABLED;
6663 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306664 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006665 pRoamProfile->Keys.KeyLength[keyId]);
6666 } else {
6667 dwrq->flags |= IW_ENCODE_DISABLED;
6668 }
6669
6670 for (i = 0; i < MAX_WEP_KEYS; i++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006671 if (pRoamProfile->Keys.KeyLength[i] == 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006672 continue;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006673 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006674 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006675 }
6676
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006677 if (MAX_WEP_KEYS == i)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006678 dwrq->flags |= IW_ENCODE_NOKEY;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006679 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006680 dwrq->flags |= IW_ENCODE_ENABLED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006681
6682 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
6683
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006684 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006685 dwrq->flags |= IW_ENCODE_DISABLED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006686
6687 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
6688
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006689 if (IW_AUTH_ALG_OPEN_SYSTEM == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006690 dwrq->flags |= IW_ENCODE_OPEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006691 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006692 dwrq->flags |= IW_ENCODE_RESTRICTED;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006693
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006694 EXIT();
6695 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006696}
6697
6698/**
6699 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
6700 * @dev: pointer to net_device
6701 * @info: pointer to iw_request_info
6702 * @dwrq: pointer to encoding information
6703 * @extra: pointer to extra ioctl payload
6704 *
6705 * Return: 0 on success, error number otherwise
6706 */
6707static int iw_get_encodeext(struct net_device *dev,
6708 struct iw_request_info *info,
6709 struct iw_point *dwrq, char *extra)
6710{
6711 int ret;
6712
6713 cds_ssr_protect(__func__);
6714 ret = __iw_get_encodeext(dev, info, dwrq, extra);
6715 cds_ssr_unprotect(__func__);
6716
6717 return ret;
6718}
6719
6720/**
6721 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
6722 * @dev: device upon which the ioctl was received
6723 * @info: ioctl request information
6724 * @wrqu: ioctl request data
6725 * @extra: ioctl extra data
6726 *
6727 * Return: 0 on success, non-zero on error
6728 */
6729static int __iw_set_encodeext(struct net_device *dev,
6730 struct iw_request_info *info,
6731 union iwreq_data *wrqu, char *extra)
6732{
6733 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6734 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6735 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6736 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306737 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006738 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6739 int ret;
6740 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6741 int key_index;
6742 struct iw_point *encoding = &wrqu->encoding;
6743 tCsrRoamSetKey setKey;
6744 uint32_t roamId = 0xFF;
6745
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006746 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006747
6748 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6749 ret = wlan_hdd_validate_context(hdd_ctx);
6750 if (0 != ret)
6751 return ret;
6752
Jeff Johnson441e1f72017-02-07 08:50:49 -08006753 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6754 if (0 != ret)
6755 return ret;
6756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006757 key_index = encoding->flags & IW_ENCODE_INDEX;
6758
6759 if (key_index > 0) {
6760
6761 /*Convert from 1-based to 0-based keying */
6762 key_index--;
6763 }
6764 if (!ext->key_len) {
6765
6766 /*Set the encrytion type to NONE */
6767 pRoamProfile->EncryptionType.encryptionType[0] =
6768 eCSR_ENCRYPT_TYPE_NONE;
6769 return ret;
6770 }
6771
6772 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
6773 (IW_ENCODE_ALG_WEP == ext->alg)) {
6774 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
6775
Jeff Johnson99bac312016-06-28 10:38:18 -07006776 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006777 return -EINVAL;
Jeff Johnson68755312017-02-10 11:46:55 -08006778 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006779
Jeff Johnson68755312017-02-10 11:46:55 -08006780 /*Static wep, update the roam profile with the keys */
6781 if (ext->key_len &&
6782 (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
6783 key_index < CSR_MAX_NUM_KEY) {
6784 qdf_mem_copy(&pRoamProfile->Keys.
6785 KeyMaterial[key_index][0],
6786 ext->key, ext->key_len);
6787 pRoamProfile->Keys.KeyLength[key_index] =
6788 (uint8_t) ext->key_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006789
Jeff Johnson68755312017-02-10 11:46:55 -08006790 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
6791 pRoamProfile->Keys.defaultIndex =
6792 (uint8_t) key_index;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006793 }
6794 return ret;
6795 }
6796
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306797 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006798
6799 setKey.keyId = key_index;
6800 setKey.keyLength = ext->key_len;
6801
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006802 if (ext->key_len <= CSR_MAX_KEY_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306803 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006804
6805 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
6806 /*Key direction for group is RX only */
6807 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05306808 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006810 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306811 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306812 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006813 }
6814
6815 /*For supplicant pae role is zero */
6816 setKey.paeRole = 0;
6817
6818 switch (ext->alg) {
6819 case IW_ENCODE_ALG_NONE:
6820 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6821 break;
6822
6823 case IW_ENCODE_ALG_WEP:
6824 setKey.encType =
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006825 (ext->key_len == 5) ? eCSR_ENCRYPT_TYPE_WEP40 :
6826 eCSR_ENCRYPT_TYPE_WEP104;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006827 break;
6828
6829 case IW_ENCODE_ALG_TKIP:
6830 {
6831 uint8_t *pKey = &setKey.Key[0];
6832
6833 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
6834
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306835 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006836
6837 /* Supplicant sends the 32bytes key in this order
6838 * |--------------|----------|----------|
6839 * | Tk1 | TX MIC | RX MIC |
6840 * |--------------|----------|----------|
6841 * <---16bytes---><--8bytes--><--8bytes-->
6842 *
6843 *
6844 * Sme expects the 32 bytes key to be in the below order
6845 * |--------------|----------|----------|
6846 * | Tk1 | RX MIC | TX MIC |
6847 * |--------------|----------|----------|
6848 * <---16bytes---><--8bytes--><--8bytes-->
6849 */
6850
6851 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306852 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006853
6854 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306855 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006856
6857 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306858 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006859
6860 }
6861 break;
6862
6863 case IW_ENCODE_ALG_CCMP:
6864 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
6865 break;
6866
6867#ifdef FEATURE_WLAN_ESE
6868#define IW_ENCODE_ALG_KRK 6
6869 case IW_ENCODE_ALG_KRK:
6870 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
6871 break;
6872#endif /* FEATURE_WLAN_ESE */
6873
6874 default:
6875 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6876 break;
6877 }
6878
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006879 hdd_debug("cipher_alg:%d key_len:%d EncryptionType:%d",
Jeff Johnson99bac312016-06-28 10:38:18 -07006880 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006882 /* The supplicant may attempt to set the PTK once
6883 * pre-authentication is done. Save the key in the UMAC and
6884 * include it in the ADD BSS request
6885 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306886 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006887 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306888 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006889 hdd_debug("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006890 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306891 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006892 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006893 return -EINVAL;
6894 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006895
6896 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6897
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306898 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899 pAdapter->sessionId,
6900 &setKey, &roamId);
6901
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306902 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006903 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306904 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006905
6906 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6907 }
6908
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306909 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006910}
6911
6912/**
6913 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
6914 * @dev: pointer to net_device
6915 * @info: pointer to iw_request_info
6916 * @wrqu: pointer to iwreq_data
6917 * @extra: pointer to extra ioctl payload
6918 *
6919 * Return: 0 on success, error number otherwise
6920 */
6921static int iw_set_encodeext(struct net_device *dev,
6922 struct iw_request_info *info,
6923 union iwreq_data *wrqu, char *extra)
6924{
6925 int ret;
6926
6927 cds_ssr_protect(__func__);
6928 ret = __iw_set_encodeext(dev, info, wrqu, extra);
6929 cds_ssr_unprotect(__func__);
6930
6931 return ret;
6932}
6933
6934/**
6935 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
6936 * @dev: device upon which the ioctl was received
6937 * @info: ioctl request information
6938 * @wrqu: ioctl request data
6939 * @extra: ioctl extra data
6940 *
6941 * Return: 0 on success, non-zero on error
6942 */
6943static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
6944 union iwreq_data *wrqu, char *extra)
6945{
6946 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6947 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6948 hdd_context_t *hdd_ctx;
6949 int ret;
6950
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006951 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006952
6953 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6954 ret = wlan_hdd_validate_context(hdd_ctx);
6955 if (0 != ret)
6956 return ret;
6957
Jeff Johnson441e1f72017-02-07 08:50:49 -08006958 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6959 if (0 != ret)
6960 return ret;
6961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006962 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
6963 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
6964
Jeff Johnson99bac312016-06-28 10:38:18 -07006965 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006966
6967 return -EINVAL;
6968 }
6969
6970 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
6971
6972 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
6973 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
6974 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306975 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006976 hdd_err("WNI_CFG_LONG_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006977 return -EIO;
6978 }
6979 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
6980 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6981 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306982 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006983 hdd_err("WNI_CFG_SHORT_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006984 return -EIO;
6985 }
6986 }
6987 } else {
6988 return -EOPNOTSUPP;
6989 }
6990
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006991 hdd_debug("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006992
6993 EXIT();
6994
6995 return 0;
6996
6997}
6998
6999/**
7000 * iw_set_retry() - SSR wrapper for __iw_set_retry()
7001 * @dev: pointer to net_device
7002 * @info: pointer to iw_request_info
7003 * @wrqu: pointer to iwreq_data
7004 * @extra: pointer to extra ioctl payload
7005 *
7006 * Return: 0 on success, error number otherwise
7007 */
7008static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
7009 union iwreq_data *wrqu, char *extra)
7010{
7011 int ret;
7012
7013 cds_ssr_protect(__func__);
7014 ret = __iw_set_retry(dev, info, wrqu, extra);
7015 cds_ssr_unprotect(__func__);
7016
7017 return ret;
7018}
7019
7020/**
7021 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
7022 * @dev: device upon which the ioctl was received
7023 * @info: ioctl request information
7024 * @wrqu: ioctl request data
7025 * @extra: ioctl extra data
7026 *
7027 * Return: 0 on success, non-zero on error
7028 */
7029static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7030 union iwreq_data *wrqu, char *extra)
7031{
7032 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7033 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7034 uint32_t retry = 0;
7035 hdd_context_t *hdd_ctx;
7036 int ret;
7037
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007038 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007039
7040 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7041 ret = wlan_hdd_validate_context(hdd_ctx);
7042 if (0 != ret)
7043 return ret;
7044
Jeff Johnson441e1f72017-02-07 08:50:49 -08007045 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7046 if (0 != ret)
7047 return ret;
7048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007049 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
7050 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
7051
7052 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307053 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007054 hdd_err("WNI_CFG_LONG_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007055 return -EIO;
7056 }
7057
7058 wrqu->retry.value = retry;
7059 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
7060 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
7061
7062 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307063 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007064 hdd_err("WNI_CFG_SHORT_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007065 return -EIO;
7066 }
7067
7068 wrqu->retry.value = retry;
7069 } else {
7070 return -EOPNOTSUPP;
7071 }
7072
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007073 hdd_debug("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007074
7075 EXIT();
7076
7077 return 0;
7078}
7079
7080/**
7081 * iw_get_retry() - SSR wrapper for __iw_get_retry()
7082 * @dev: pointer to net_device
7083 * @info: pointer to iw_request_info
7084 * @wrqu: pointer to iwreq_data
7085 * @extra: pointer to extra ioctl payload
7086 *
7087 * Return: 0 on success, error number otherwise
7088 */
7089static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7090 union iwreq_data *wrqu, char *extra)
7091{
7092 int ret;
7093
7094 cds_ssr_protect(__func__);
7095 ret = __iw_get_retry(dev, info, wrqu, extra);
7096 cds_ssr_unprotect(__func__);
7097
7098 return ret;
7099}
7100
7101/**
7102 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
7103 * @dev: device upon which the ioctl was received
7104 * @info: ioctl request information
7105 * @wrqu: ioctl request data
7106 * @extra: ioctl extra data
7107 *
7108 * Return: 0 on success, non-zero on error
7109 */
7110static int __iw_set_mlme(struct net_device *dev,
7111 struct iw_request_info *info,
7112 union iwreq_data *wrqu, char *extra)
7113{
7114 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7115 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7116 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307117 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007118 hdd_context_t *hdd_ctx;
7119 int ret;
7120
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007121 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007122
7123 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7124 ret = wlan_hdd_validate_context(hdd_ctx);
7125 if (0 != ret)
7126 return ret;
7127
Jeff Johnson441e1f72017-02-07 08:50:49 -08007128 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7129 if (0 != ret)
7130 return ret;
7131
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007132 /* reason_code is unused. By default it is set to
7133 * eCSR_DISCONNECT_REASON_UNSPECIFIED
7134 */
7135 switch (mlme->cmd) {
7136 case IW_MLME_DISASSOC:
7137 case IW_MLME_DEAUTH:
7138
7139 if (pHddStaCtx->conn_info.connState ==
7140 eConnectionState_Associated) {
7141 eCsrRoamDisconnectReason reason =
7142 eCSR_DISCONNECT_REASON_UNSPECIFIED;
7143
7144 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
7145 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
7146
7147 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7148 status =
7149 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
7150 pAdapter->sessionId, reason);
7151
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307152 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007153 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007155 rc = wait_for_completion_timeout(&pAdapter->
7156 disconnect_comp_var,
7157 msecs_to_jiffies
7158 (WLAN_WAIT_TIME_DISCONNECT));
7159 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007160 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007161 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07007162 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
7163 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007164
7165 /* Resetting authKeyMgmt */
7166 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
7167 0;
7168
Jeff Johnson99bac312016-06-28 10:38:18 -07007169 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007170 wlan_hdd_netif_queue_control(pAdapter,
7171 WLAN_NETIF_TX_DISABLE_N_CARRIER,
7172 WLAN_CONTROL_PATH);
7173
7174 } else {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007175 hdd_warn("%d Command Disassociate/Deauthenticate called but station is not in associated state",
Jeff Johnson99bac312016-06-28 10:38:18 -07007176 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007177 }
7178 break;
7179 default:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007180 hdd_err("Unexpected cmd: %d", (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007181 return -EINVAL;
7182 } /* end of switch */
7183
7184 EXIT();
7185
7186 return status;
7187
7188}
7189
7190/**
7191 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
7192 * @dev: pointer to net_device
7193 * @info: pointer to iw_request_info
7194 * @wrqu: pointer to iwreq_data
7195 * @extra: pointer to extra ioctl payload
7196 *
7197 * Return: 0 on success, error number otherwise
7198 */
7199static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
7200 union iwreq_data *wrqu, char *extra)
7201{
7202 int ret;
7203
7204 cds_ssr_protect(__func__);
7205 ret = __iw_set_mlme(dev, info, wrqu, extra);
7206 cds_ssr_unprotect(__func__);
7207
7208 return ret;
7209}
7210
7211/**
7212 * wlan_hdd_update_phymode() - handle change in PHY mode
7213 * @net: device upon which PHY mode change was received
7214 * @hal: umac handle for the driver
7215 * @new_phymode: new PHY mode for the device
7216 * @phddctx: pointer to the HDD context
7217 *
7218 * This function is called when the device is set to a new PHY mode.
7219 * It takes a holistic look at the desired PHY mode along with the
7220 * configured capabilities of the driver and the reported capabilities
7221 * of the hardware in order to correctly configure all PHY-related
7222 * parameters.
7223 *
7224 * Return: 0 on success, negative errno value on error
7225 */
7226int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
7227 int new_phymode, hdd_context_t *phddctx)
7228{
7229#ifdef QCA_HT_2040_COEX
7230 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307231 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007232#endif
7233 bool band_24 = false, band_5g = false;
7234 bool ch_bond24 = false, ch_bond5g = false;
7235 tSmeConfigParams smeconfig;
7236 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007237 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007238 eCsrPhyMode phymode = -EIO, old_phymode;
7239 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
7240 eCsrBand curr_band = eCSR_BAND_ALL;
7241
7242 old_phymode = sme_get_phy_mode(hal);
7243
7244 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7245 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7246 nChannelBondingMode24GHz))
7247 ch_bond24 = true;
7248
7249 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7250 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7251 nChannelBondingMode5GHz))
7252 ch_bond5g = true;
7253
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007254 if (phddctx->config->nBandCapability == eCSR_BAND_ALL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007255 band_24 = band_5g = true;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007256 else if (phddctx->config->nBandCapability == eCSR_BAND_24)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007257 band_24 = true;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007258 else if (phddctx->config->nBandCapability == eCSR_BAND_5G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007259 band_5g = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007260
7261 vhtchanwidth = phddctx->config->vhtChannelWidth;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007262 hdd_debug("ch_bond24=%d ch_bond5g=%d band_24=%d band_5g=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007263 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
7264
7265 switch (new_phymode) {
7266 case IEEE80211_MODE_AUTO:
7267 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7268 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
7269 phymode = eCSR_DOT11_MODE_AUTO;
7270 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7271 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7272 curr_band = eCSR_BAND_ALL;
7273 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7274 } else {
7275 sme_set_phy_mode(hal, old_phymode);
7276 return -EIO;
7277 }
7278 break;
7279 case IEEE80211_MODE_11A:
7280 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
7281 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7282 phymode = eCSR_DOT11_MODE_11a;
7283 hdd_dot11mode = eHDD_DOT11_MODE_11a;
7284 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7285 curr_band = eCSR_BAND_5G;
7286 } else {
7287 sme_set_phy_mode(hal, old_phymode);
7288 return -EIO;
7289 }
7290 break;
7291 case IEEE80211_MODE_11B:
7292 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
7293 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7294 phymode = eCSR_DOT11_MODE_11b;
7295 hdd_dot11mode = eHDD_DOT11_MODE_11b;
7296 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7297 curr_band = eCSR_BAND_24;
7298 } else {
7299 sme_set_phy_mode(hal, old_phymode);
7300 return -EIO;
7301 }
7302 break;
7303 case IEEE80211_MODE_11G:
7304 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
7305 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7306 phymode = eCSR_DOT11_MODE_11g;
7307 hdd_dot11mode = eHDD_DOT11_MODE_11g;
7308 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7309 curr_band = eCSR_BAND_24;
7310 } else {
7311 sme_set_phy_mode(hal, old_phymode);
7312 return -EIO;
7313 }
7314 break;
7315 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
7316 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
7317 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
7318 */
7319 case IEEE80211_MODE_11NA_HT20:
7320 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7321 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7322 phymode = eCSR_DOT11_MODE_11n;
7323 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7324 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7325 curr_band = eCSR_BAND_5G;
7326 } else {
7327 sme_set_phy_mode(hal, old_phymode);
7328 return -EIO;
7329 }
7330 break;
7331 case IEEE80211_MODE_11NA_HT40:
7332 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7333 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7334 phymode = eCSR_DOT11_MODE_11n;
7335 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7336 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7337 curr_band = eCSR_BAND_5G;
7338 } else {
7339 sme_set_phy_mode(hal, old_phymode);
7340 return -EIO;
7341 }
7342 break;
7343 case IEEE80211_MODE_11NG_HT20:
7344 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7345 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7346 phymode = eCSR_DOT11_MODE_11n;
7347 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7348 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7349 curr_band = eCSR_BAND_24;
7350 } else {
7351 sme_set_phy_mode(hal, old_phymode);
7352 return -EIO;
7353 }
7354 break;
7355 case IEEE80211_MODE_11NG_HT40:
7356 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7357 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7358 phymode = eCSR_DOT11_MODE_11n;
7359 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7360 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7361 curr_band = eCSR_BAND_24;
7362 } else {
7363 sme_set_phy_mode(hal, old_phymode);
7364 return -EIO;
7365 }
7366 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007367 case IEEE80211_MODE_11AC_VHT20:
7368 case IEEE80211_MODE_11AC_VHT40:
7369 case IEEE80211_MODE_11AC_VHT80:
7370 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
7371 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7372 phymode = eCSR_DOT11_MODE_11ac;
7373 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
7374 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7375 curr_band = eCSR_BAND_5G;
7376 } else {
7377 sme_set_phy_mode(hal, old_phymode);
7378 return -EIO;
7379 }
7380 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007381 case IEEE80211_MODE_2G_AUTO:
7382 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7383 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7384 phymode = eCSR_DOT11_MODE_AUTO;
7385 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7386 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7387 curr_band = eCSR_BAND_24;
7388 } else {
7389 sme_set_phy_mode(hal, old_phymode);
7390 return -EIO;
7391 }
7392 break;
7393 case IEEE80211_MODE_5G_AUTO:
7394 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7395 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7396 phymode = eCSR_DOT11_MODE_AUTO;
7397 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7398 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7399 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7400 curr_band = eCSR_BAND_5G;
7401 } else {
7402 sme_set_phy_mode(hal, old_phymode);
7403 return -EIO;
7404 }
7405 break;
7406 case IEEE80211_MODE_11AGN:
7407 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7408 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
7409 phymode = eCSR_DOT11_MODE_11n;
7410 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7411 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7412 curr_band = eCSR_BAND_ALL;
7413 } else {
7414 sme_set_phy_mode(hal, old_phymode);
7415 return -EIO;
7416 }
7417 break;
7418 default:
7419 return -EIO;
7420 }
7421
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007422 switch (new_phymode) {
7423 case IEEE80211_MODE_11AC_VHT20:
7424 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7425 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
7426 break;
7427 case IEEE80211_MODE_11AC_VHT40:
7428 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
7429 break;
7430 case IEEE80211_MODE_11AC_VHT80:
7431 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7432 break;
7433 default:
7434 vhtchanwidth = phddctx->config->vhtChannelWidth;
7435 break;
7436 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007437
7438 if (phymode != -EIO) {
7439 sme_get_config_param(hal, &smeconfig);
7440 smeconfig.csrConfig.phyMode = phymode;
7441#ifdef QCA_HT_2040_COEX
7442 if (phymode == eCSR_DOT11_MODE_11n &&
7443 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
7444 smeconfig.csrConfig.obssEnabled = false;
7445 halStatus = sme_set_ht2040_mode(hal,
7446 pAdapter->sessionId,
7447 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307448 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007449 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007450 return -EIO;
7451 }
7452 } else if (phymode == eCSR_DOT11_MODE_11n &&
7453 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
7454 smeconfig.csrConfig.obssEnabled = true;
7455 halStatus = sme_set_ht2040_mode(hal,
7456 pAdapter->sessionId,
7457 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307458 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007459 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007460 return -EIO;
7461 }
7462 }
7463#endif
7464 smeconfig.csrConfig.eBand = curr_band;
7465 smeconfig.csrConfig.bandCapability = curr_band;
7466 if (curr_band == eCSR_BAND_24)
7467 smeconfig.csrConfig.Is11hSupportEnabled = 0;
7468 else
7469 smeconfig.csrConfig.Is11hSupportEnabled =
7470 phddctx->config->Is11hSupportEnabled;
7471 if (curr_band == eCSR_BAND_24)
7472 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7473 else if (curr_band == eCSR_BAND_24)
7474 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7475 else {
7476 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7477 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7478 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007479 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007480 sme_update_config(hal, &smeconfig);
7481
7482 phddctx->config->dot11Mode = hdd_dot11mode;
7483 phddctx->config->nBandCapability = curr_band;
7484 phddctx->config->nChannelBondingMode24GHz =
7485 smeconfig.csrConfig.channelBondingMode24GHz;
7486 phddctx->config->nChannelBondingMode5GHz =
7487 smeconfig.csrConfig.channelBondingMode5GHz;
7488 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07007489 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007490 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007491 return -EIO;
7492 }
7493 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07007494 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007495 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7496 else
Dustin Browna30892e2016-10-12 17:28:36 -07007497 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007498 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7499
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007500 hdd_debug("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007501 phymode, chwidth, curr_band, vhtchanwidth);
7502 }
7503
7504 return 0;
7505}
7506
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007507struct temperature_priv {
7508 int temperature;
7509};
7510
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007511/**
7512 * hdd_get_temperature_cb() - "Get Temperature" callback function
7513 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007514 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007515 *
7516 * This function is passed to sme_get_temperature() as the callback
7517 * function to be invoked when the temperature measurement is
7518 * available.
7519 *
7520 * Return: None
7521 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007522static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007523{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007524 struct hdd_request *request;
7525 struct temperature_priv *priv;
7526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007527 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007528
7529 request = hdd_request_get(context);
7530 if (!request) {
7531 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007532 return;
7533 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007534
7535 priv = hdd_request_priv(request);
7536 priv->temperature = temperature;
7537 hdd_request_complete(request);
7538 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007539 EXIT();
7540}
7541
7542/**
7543 * wlan_hdd_get_temperature() - get current device temperature
7544 * @pAdapter: device upon which the request was made
7545 * @temperature: pointer to where the temperature is to be returned
7546 *
7547 * Return: 0 if a temperature value (either current or cached) was
7548 * returned, otherwise a negative errno is returned.
7549 *
7550 */
7551int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
7552{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307553 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007554 int ret;
7555 void *cookie;
7556 struct hdd_request *request;
7557 struct temperature_priv *priv;
7558 static const struct hdd_request_params params = {
7559 .priv_size = sizeof(*priv),
7560 .timeout_ms = WLAN_WAIT_TIME_STATS,
7561 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007562
7563 ENTER();
7564 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007565 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007566 return -EPERM;
7567 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007568
7569 request = hdd_request_alloc(&params);
7570 if (!request) {
7571 hdd_err("Request allocation failure");
7572 return -ENOMEM;
7573 }
7574 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007575 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007576 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307577 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007578 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007579 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007580 ret = hdd_request_wait_for_response(request);
7581 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007582 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007583 } else {
7584 /* update the adapter with the fresh results */
7585 priv = hdd_request_priv(request);
7586 if (priv->temperature)
7587 pAdapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007588 }
7589 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007590
7591 /*
7592 * either we never sent a request, we sent a request and
7593 * received a response or we sent a request and timed out.
7594 * regardless we are done with the request.
7595 */
7596 hdd_request_put(request);
7597
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007598 *temperature = pAdapter->temperature;
7599 EXIT();
7600 return 0;
7601}
7602
7603/**
7604 * iw_setint_getnone() - Generic "set integer" private ioctl handler
7605 * @dev: device upon which the ioctl was received
7606 * @info: ioctl request information
7607 * @wrqu: ioctl request data
7608 * @extra: ioctl extra data
7609 *
7610 * Return: 0 on success, non-zero on error
7611 */
7612static int __iw_setint_getnone(struct net_device *dev,
7613 struct iw_request_info *info,
7614 union iwreq_data *wrqu, char *extra)
7615{
7616 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7617 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7618 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007619 hdd_context_t *hdd_ctx;
7620 tSmeConfigParams smeConfig;
7621 int *value = (int *)extra;
7622 int sub_cmd = value[0];
7623 int set_value = value[1];
7624 int ret;
7625 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307626 QDF_STATUS status;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08007627 void *soc = NULL;
7628 struct ol_txrx_stats_req req;
7629 struct cdp_pdev *pdev = NULL;
7630 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007631
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007632 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307633
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007634 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7635 ret = wlan_hdd_validate_context(hdd_ctx);
7636 if (0 != ret)
7637 return ret;
7638
Jeff Johnson441e1f72017-02-07 08:50:49 -08007639 ret = hdd_check_private_wext_control(hdd_ctx, info);
7640 if (0 != ret)
7641 return ret;
7642
Jeff Johnson441e1f72017-02-07 08:50:49 -08007643 memset(&smeConfig, 0x00, sizeof(smeConfig));
7644
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007645 switch (sub_cmd) {
7646 case WE_SET_11D_STATE:
7647 {
7648 if ((ENABLE_11D == set_value)
7649 || (DISABLE_11D == set_value)) {
7650
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007651 sme_get_config_param(hHal, &smeConfig);
7652 smeConfig.csrConfig.Is11dSupportEnabled =
7653 (bool) set_value;
7654
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007655 hdd_debug("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007656 smeConfig.csrConfig.
7657 Is11dSupportEnabled);
7658
7659 sme_update_config(hHal, &smeConfig);
7660 } else {
7661 return -EINVAL;
7662 }
7663 break;
7664 }
7665
7666 case WE_WOWL:
7667 {
7668 switch (set_value) {
7669 case 0x00:
7670 hdd_exit_wowl(pAdapter);
7671 break;
7672 case 0x01:
7673 case 0x02:
7674 case 0x03:
7675 enable_mp = (set_value & 0x01) ? 1 : 0;
7676 enable_pbm = (set_value & 0x02) ? 1 : 0;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007677 hdd_debug("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007678 (enable_mp ? "YES" : "NO"),
7679 (enable_pbm ? "YES" : "NO"));
7680 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
7681 break;
7682 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007683 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007684 set_value);
7685 ret = -EINVAL;
7686 break;
7687 }
7688
7689 break;
7690 }
7691 case WE_SET_POWER:
7692 {
7693 switch (set_value) {
7694 case 1:
7695 /* Enable PowerSave */
7696 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7697 SME_PS_ENABLE);
7698 break;
7699 case 2:
7700 /* Disable PowerSave */
7701 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7702 SME_PS_DISABLE);
7703 break;
7704 case 3: /* Enable UASPD */
7705 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
7706 break;
7707 case 4: /* Disable UASPD */
7708 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
7709 break;
7710 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007711 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007712 set_value);
7713 ret = -EINVAL;
7714 break;
7715 }
7716 break;
7717 }
7718
7719 case WE_SET_MAX_ASSOC:
7720 {
7721 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
7722 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
7723 ret = -EINVAL;
7724 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
7725 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307726 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007727 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007728 ret = -EIO;
7729 }
7730 break;
7731 }
7732
7733 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
7734 if (set_value == 0 || set_value == 1)
7735 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
7736 set_value;
7737 else
7738 ret = -EINVAL;
7739 break;
7740
7741 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007742 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
7743 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
7744 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7745 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307746 set_value) == QDF_STATUS_E_FAILURE)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007747 hdd_err("WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007748 ret = -EINVAL;
7749 }
7750 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007751 case WE_SET_MC_RATE:
7752 {
7753 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
7754 break;
7755 }
7756 case WE_SET_TX_POWER:
7757 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307758 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007759
Anurag Chouhanc5548422016-02-24 18:33:27 +05307760 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007761 if (sme_set_tx_power
7762 (hHal, pAdapter->sessionId, bssid,
7763 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307764 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007765 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007766 return -EIO;
7767 }
7768 break;
7769 }
7770 case WE_SET_MAX_TX_POWER:
7771 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307772 struct qdf_mac_addr bssid;
7773 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007774
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007775
7776 hdd_debug("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007777 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05307778 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
7779 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007780
7781 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307782 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007783 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007784 return -EIO;
7785 }
7786
7787 break;
7788 }
7789 case WE_SET_MAX_TX_POWER_2_4:
7790 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007791 hdd_debug("Setting maximum tx power %d dBm for 2.4 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07007792 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007793 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307794 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007795 hdd_err("Setting max tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007796 return -EIO;
7797 }
7798
7799 break;
7800 }
7801 case WE_SET_MAX_TX_POWER_5_0:
7802 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007803 hdd_debug("Setting maximum tx power %d dBm for 5.0 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07007804 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007805 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307806 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007807 hdd_err("Setting max tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007808 return -EIO;
7809 }
7810
7811 break;
7812 }
7813 case WE_SET_HIGHER_DTIM_TRANSITION:
7814 {
7815 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007816 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007817 set_value);
7818 ret = -EINVAL;
7819 } else {
7820 if (pAdapter->higherDtimTransition != set_value) {
7821 pAdapter->higherDtimTransition =
7822 set_value;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007823 hdd_debug("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007824 pAdapter->higherDtimTransition);
7825 }
7826 }
7827
7828 break;
7829 }
7830
7831 case WE_SET_TM_LEVEL:
7832 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007833 hdd_debug("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007834 (void)sme_set_thermal_level(hHal, set_value);
7835 break;
7836 }
7837
7838 case WE_SET_PHYMODE:
7839 {
7840 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
7841
7842 ret =
7843 wlan_hdd_update_phymode(dev, hHal, set_value,
7844 phddctx);
7845 break;
7846 }
7847
7848 case WE_SET_NSS:
7849 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007850 hdd_debug("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007851 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007852 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007853 ret = -EINVAL;
7854 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307855 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007856 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
7857 set_value))
7858 ret = -EINVAL;
7859 }
7860 break;
7861 }
7862
7863 case WE_SET_GTX_HT_MCS:
7864 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007865 hdd_debug("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007866 ret = wma_cli_set_command(pAdapter->sessionId,
7867 WMI_VDEV_PARAM_GTX_HT_MCS,
7868 set_value, GTX_CMD);
7869 break;
7870 }
7871
7872 case WE_SET_GTX_VHT_MCS:
7873 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007874 hdd_debug("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007875 set_value);
7876 ret = wma_cli_set_command(pAdapter->sessionId,
7877 WMI_VDEV_PARAM_GTX_VHT_MCS,
7878 set_value, GTX_CMD);
7879 break;
7880 }
7881
7882 case WE_SET_GTX_USRCFG:
7883 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007884 hdd_debug("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007885 set_value);
7886 ret = wma_cli_set_command(pAdapter->sessionId,
7887 WMI_VDEV_PARAM_GTX_USR_CFG,
7888 set_value, GTX_CMD);
7889 break;
7890 }
7891
7892 case WE_SET_GTX_THRE:
7893 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007894 hdd_debug("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007895 ret = wma_cli_set_command(pAdapter->sessionId,
7896 WMI_VDEV_PARAM_GTX_THRE,
7897 set_value, GTX_CMD);
7898 break;
7899 }
7900
7901 case WE_SET_GTX_MARGIN:
7902 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007903 hdd_debug("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007904 ret = wma_cli_set_command(pAdapter->sessionId,
7905 WMI_VDEV_PARAM_GTX_MARGIN,
7906 set_value, GTX_CMD);
7907 break;
7908 }
7909
7910 case WE_SET_GTX_STEP:
7911 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007912 hdd_debug("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007913 ret = wma_cli_set_command(pAdapter->sessionId,
7914 WMI_VDEV_PARAM_GTX_STEP,
7915 set_value, GTX_CMD);
7916 break;
7917 }
7918
7919 case WE_SET_GTX_MINTPC:
7920 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007921 hdd_debug("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007922 ret = wma_cli_set_command(pAdapter->sessionId,
7923 WMI_VDEV_PARAM_GTX_MINTPC,
7924 set_value, GTX_CMD);
7925 break;
7926 }
7927
7928 case WE_SET_GTX_BWMASK:
7929 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007930 hdd_debug("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007931 ret = wma_cli_set_command(pAdapter->sessionId,
7932 WMI_VDEV_PARAM_GTX_BW_MASK,
7933 set_value, GTX_CMD);
7934 break;
7935 }
7936
7937 case WE_SET_LDPC:
7938 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307939 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007940 break;
7941 }
7942
7943 case WE_SET_TX_STBC:
7944 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307945 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007946 break;
7947 }
7948
7949 case WE_SET_RX_STBC:
7950 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307951 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007952 break;
7953 }
7954
7955 case WE_SET_SHORT_GI:
7956 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007957 hdd_debug("WMI_VDEV_PARAM_SGI val %d", set_value);
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08007958 /*
7959 * wma_cli_set_command should be called instead of
7960 * sme_update_ht_config since SGI is used for HT/HE.
7961 * This should be refactored.
7962 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
7964 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
7965 set_value);
7966 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07007967 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007968 break;
7969 }
7970
7971 case WE_SET_RTSCTS:
7972 {
7973 uint32_t value;
7974
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007975 hdd_debug("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007976 set_value);
7977
7978 if ((set_value & HDD_RTSCTS_EN_MASK) ==
7979 HDD_RTSCTS_ENABLE)
7980 value =
7981 (WLAN_HDD_GET_CTX(pAdapter))->config->
7982 RTSThreshold;
7983 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
7984 || ((set_value & HDD_RTSCTS_EN_MASK) ==
7985 HDD_CTS_ENABLE))
7986 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
7987 else
7988 return -EIO;
7989
7990 ret = wma_cli_set_command(pAdapter->sessionId,
7991 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7992 set_value, VDEV_CMD);
7993 if (!ret) {
7994 if (sme_cfg_set_int
7995 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307996 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007997 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007998 return -EIO;
7999 }
8000 }
8001
8002 break;
8003 }
8004
8005 case WE_SET_CHWIDTH:
8006 {
8007 bool chwidth = false;
8008 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008009
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008010 /*updating channel bonding only on 5Ghz */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008011 hdd_debug("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008012 set_value);
8013 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008014 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008015 return -EINVAL;
8016 }
8017
8018 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
8019 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
8020 nChannelBondingMode5GHz)))
8021 chwidth = true;
8022
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008023 sme_get_config_param(hHal, &smeConfig);
8024 switch (set_value) {
8025 case eHT_CHANNEL_WIDTH_20MHZ:
8026 smeConfig.csrConfig.channelBondingMode5GHz =
8027 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
8028 break;
8029 case eHT_CHANNEL_WIDTH_40MHZ:
8030 if (chwidth)
8031 smeConfig.csrConfig.
8032 channelBondingMode5GHz =
8033 phddctx->config->
8034 nChannelBondingMode5GHz;
8035 else
8036 return -EINVAL;
8037
8038 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008039 case eHT_CHANNEL_WIDTH_80MHZ:
8040 if (chwidth)
8041 smeConfig.csrConfig.
8042 channelBondingMode5GHz =
8043 phddctx->config->
8044 nChannelBondingMode5GHz;
8045 else
8046 return -EINVAL;
8047
8048 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008049
8050 default:
8051 return -EINVAL;
8052 }
8053
8054 ret = wma_cli_set_command(pAdapter->sessionId,
8055 WMI_VDEV_PARAM_CHWIDTH,
8056 set_value, VDEV_CMD);
8057 if (!ret)
8058 sme_update_config(hHal, &smeConfig);
8059
8060 break;
8061 }
8062
8063 case WE_SET_ANI_EN_DIS:
8064 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008065 hdd_debug("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008066 set_value);
8067 ret = wma_cli_set_command(pAdapter->sessionId,
8068 WMI_PDEV_PARAM_ANI_ENABLE,
8069 set_value, PDEV_CMD);
8070 break;
8071 }
8072
8073 case WE_SET_ANI_POLL_PERIOD:
8074 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008075 hdd_debug("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008076 set_value);
8077 ret = wma_cli_set_command(pAdapter->sessionId,
8078 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
8079 set_value, PDEV_CMD);
8080 break;
8081 }
8082
8083 case WE_SET_ANI_LISTEN_PERIOD:
8084 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008085 hdd_debug("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008086 set_value);
8087 ret = wma_cli_set_command(pAdapter->sessionId,
8088 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
8089 set_value, PDEV_CMD);
8090 break;
8091 }
8092
8093 case WE_SET_ANI_OFDM_LEVEL:
8094 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008095 hdd_debug("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008096 set_value);
8097 ret = wma_cli_set_command(pAdapter->sessionId,
8098 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
8099 set_value, PDEV_CMD);
8100 break;
8101 }
8102
8103 case WE_SET_ANI_CCK_LEVEL:
8104 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008105 hdd_debug("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008106 set_value);
8107 ret = wma_cli_set_command(pAdapter->sessionId,
8108 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
8109 set_value, PDEV_CMD);
8110 break;
8111 }
8112
8113 case WE_SET_DYNAMIC_BW:
8114 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008115 hdd_debug("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008116 set_value);
8117 ret = wma_cli_set_command(pAdapter->sessionId,
8118 WMI_PDEV_PARAM_DYNAMIC_BW,
8119 set_value, PDEV_CMD);
8120 break;
8121 }
8122
8123 case WE_SET_CTS_CBW:
8124 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008125 hdd_debug("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008126 ret = wma_cli_set_command(pAdapter->sessionId,
8127 WMI_PDEV_PARAM_CTS_CBW,
8128 set_value, PDEV_CMD);
8129 break;
8130 }
8131
8132 case WE_SET_11N_RATE:
8133 {
8134 uint8_t preamble = 0, nss = 0, rix = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008135
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008136 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008137 set_value);
8138
8139 if (set_value != 0xff) {
8140 rix = RC_2_RATE_IDX(set_value);
8141 if (set_value & 0x80) {
8142 preamble = WMI_RATE_PREAMBLE_HT;
8143 nss = HT_RC_2_STREAMS(set_value) - 1;
8144 } else {
8145 nss = 0;
8146 rix = RC_2_RATE_IDX(set_value);
8147 if (set_value & 0x10) {
8148 preamble =
8149 WMI_RATE_PREAMBLE_CCK;
8150 if (rix != 0x3)
8151 /* Enable Short
8152 * preamble always for
8153 * CCK except 1mbps
8154 */
8155 rix |= 0x4;
8156 } else {
8157 preamble =
8158 WMI_RATE_PREAMBLE_OFDM;
8159 }
8160 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008161 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008162 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008163 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008164 set_value, rix, preamble, nss);
8165
8166 ret = wma_cli_set_command(pAdapter->sessionId,
8167 WMI_VDEV_PARAM_FIXED_RATE,
8168 set_value, VDEV_CMD);
8169 break;
8170 }
8171
8172 case WE_SET_VHT_RATE:
8173 {
8174 uint8_t preamble = 0, nss = 0, rix = 0;
8175
8176 if (set_value != 0xff) {
8177 rix = RC_2_RATE_IDX_11AC(set_value);
8178 preamble = WMI_RATE_PREAMBLE_VHT;
8179 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
8180
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008181 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008182 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008183 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008184 set_value, rix, preamble, nss);
8185 ret = wma_cli_set_command(pAdapter->sessionId,
8186 WMI_VDEV_PARAM_FIXED_RATE,
8187 set_value, VDEV_CMD);
8188 break;
8189 }
8190
8191 case WE_SET_AMPDU:
8192 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008193 hdd_debug("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008194 ret = wma_cli_set_command(pAdapter->sessionId,
8195 GEN_VDEV_PARAM_AMPDU,
8196 set_value, GEN_CMD);
8197 break;
8198 }
8199
8200 case WE_SET_AMSDU:
8201 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008202 hdd_debug("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008203 ret = wma_cli_set_command(pAdapter->sessionId,
8204 GEN_VDEV_PARAM_AMSDU,
8205 set_value, GEN_CMD);
8206 break;
8207 }
8208
8209 case WE_SET_BURST_ENABLE:
8210 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008211 hdd_debug("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008212 if ((set_value == 0) || (set_value == 1)) {
8213 ret = wma_cli_set_command(pAdapter->sessionId,
8214 WMI_PDEV_PARAM_BURST_ENABLE,
8215 set_value, PDEV_CMD);
8216 } else
8217 ret = -EINVAL;
8218 break;
8219 }
8220 case WE_SET_BURST_DUR:
8221 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008222 hdd_debug("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07008223 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008224 ret = wma_cli_set_command(pAdapter->sessionId,
8225 WMI_PDEV_PARAM_BURST_DUR,
8226 set_value, PDEV_CMD);
8227 else
8228 ret = -EINVAL;
8229 break;
8230 }
8231
8232 case WE_SET_TX_CHAINMASK:
8233 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008234 hdd_debug("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008235 set_value);
8236 ret = wma_cli_set_command(pAdapter->sessionId,
8237 WMI_PDEV_PARAM_TX_CHAIN_MASK,
8238 set_value, PDEV_CMD);
8239 break;
8240 }
8241
8242 case WE_SET_RX_CHAINMASK:
8243 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008244 hdd_debug("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008245 set_value);
8246 ret = wma_cli_set_command(pAdapter->sessionId,
8247 WMI_PDEV_PARAM_RX_CHAIN_MASK,
8248 set_value, PDEV_CMD);
8249 break;
8250 }
8251
8252 case WE_SET_TXPOW_2G:
8253 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008254 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008255 set_value);
8256 ret = wma_cli_set_command(pAdapter->sessionId,
8257 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
8258 set_value, PDEV_CMD);
8259 break;
8260 }
8261
8262 case WE_SET_TXPOW_5G:
8263 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008264 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008265 set_value);
8266 ret = wma_cli_set_command(pAdapter->sessionId,
8267 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
8268 set_value, PDEV_CMD);
8269 break;
8270 }
8271
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008272 /* Firmware debug log */
8273 case WE_DBGLOG_LOG_LEVEL:
8274 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008275 hdd_debug("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008276 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
8277 ret = wma_cli_set_command(pAdapter->sessionId,
8278 WMI_DBGLOG_LOG_LEVEL,
8279 set_value, DBG_CMD);
8280 break;
8281 }
8282
8283 case WE_DBGLOG_VAP_ENABLE:
8284 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008285 hdd_debug("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008286 ret = wma_cli_set_command(pAdapter->sessionId,
8287 WMI_DBGLOG_VAP_ENABLE,
8288 set_value, DBG_CMD);
8289 break;
8290 }
8291
8292 case WE_DBGLOG_VAP_DISABLE:
8293 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008294 hdd_debug("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008295 ret = wma_cli_set_command(pAdapter->sessionId,
8296 WMI_DBGLOG_VAP_DISABLE,
8297 set_value, DBG_CMD);
8298 break;
8299 }
8300
8301 case WE_DBGLOG_MODULE_ENABLE:
8302 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008303 hdd_debug("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008304 set_value);
8305 hdd_ctx->fw_log_settings.enable = set_value;
8306 ret = wma_cli_set_command(pAdapter->sessionId,
8307 WMI_DBGLOG_MODULE_ENABLE,
8308 set_value, DBG_CMD);
8309 break;
8310 }
8311
8312 case WE_DBGLOG_MODULE_DISABLE:
8313 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008314 hdd_debug("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008315 set_value);
8316 hdd_ctx->fw_log_settings.enable = set_value;
8317 ret = wma_cli_set_command(pAdapter->sessionId,
8318 WMI_DBGLOG_MODULE_DISABLE,
8319 set_value, DBG_CMD);
8320 break;
8321 }
8322 case WE_DBGLOG_MOD_LOG_LEVEL:
8323 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008324 hdd_debug("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008325 set_value);
8326
8327 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
8328 hdd_ctx->fw_log_settings.index = 0;
8329
8330 hdd_ctx->fw_log_settings.
8331 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
8332 set_value;
8333 hdd_ctx->fw_log_settings.index++;
8334
8335 ret = wma_cli_set_command(pAdapter->sessionId,
8336 WMI_DBGLOG_MOD_LOG_LEVEL,
8337 set_value, DBG_CMD);
8338 break;
8339 }
8340
8341 case WE_DBGLOG_TYPE:
8342 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008343 hdd_debug("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008344 hdd_ctx->fw_log_settings.dl_type = set_value;
8345 ret = wma_cli_set_command(pAdapter->sessionId,
8346 WMI_DBGLOG_TYPE,
8347 set_value, DBG_CMD);
8348 break;
8349 }
8350 case WE_DBGLOG_REPORT_ENABLE:
8351 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008352 hdd_debug("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008353 set_value);
8354 hdd_ctx->fw_log_settings.dl_report = set_value;
8355 ret = wma_cli_set_command(pAdapter->sessionId,
8356 WMI_DBGLOG_REPORT_ENABLE,
8357 set_value, DBG_CMD);
8358 break;
8359 }
8360
8361 case WE_SET_TXRX_FWSTATS:
8362 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008363 hdd_debug("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008364 ret = wma_cli_set_command(pAdapter->sessionId,
8365 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
8366 set_value, VDEV_CMD);
8367 break;
8368 }
8369
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008370 case WE_SET_TXRX_STATS:
8371 {
8372 hdd_notice("WE_SET_TXRX_STATS val %d", set_value);
8373 ret = cds_get_datapath_handles(&soc, &pdev, &vdev,
8374 pAdapter->sessionId);
8375
8376 if (ret != 0)
8377 break;
8378
8379 qdf_mem_zero(&req, sizeof(req));
8380 ret = cdp_txrx_stats(soc, vdev, &req, set_value);
8381 break;
8382 }
8383
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008384 case WE_TXRX_FWSTATS_RESET:
8385 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008386 hdd_debug("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008387 ret = wma_cli_set_command(pAdapter->sessionId,
8388 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
8389 set_value, VDEV_CMD);
8390 break;
8391 }
8392
8393 case WE_DUMP_STATS:
8394 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008395 hdd_debug("WE_DUMP_STATS val %d", set_value);
Mohit Khanna3e2115b2016-10-11 13:18:29 -07008396 ret = hdd_wlan_dump_stats(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008397 break;
8398 }
8399
8400 case WE_CLEAR_STATS:
8401 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008402 hdd_debug("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008403 switch (set_value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008404 case CDP_HDD_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008405 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
8406 memset(&pAdapter->hdd_stats, 0,
8407 sizeof(pAdapter->hdd_stats));
8408 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008409 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008410 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
8411 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008412 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008413 wlan_hdd_clear_netif_queue_history(hdd_ctx);
8414 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008415 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05308416 hdd_clear_hif_stats();
8417 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008418 default:
Leo Changfdb45c32016-10-28 11:09:23 -07008419 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
8420 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008421 }
8422 break;
8423 }
8424
8425 case WE_PPS_PAID_MATCH:
8426 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008427 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008428 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008429
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008430 hdd_debug("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008431 set_value);
8432 ret = wma_cli_set_command(pAdapter->sessionId,
8433 WMI_VDEV_PPS_PAID_MATCH,
8434 set_value, PPS_CMD);
8435 break;
8436 }
8437
8438 case WE_PPS_GID_MATCH:
8439 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008440 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008441 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008442 hdd_debug("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008443 set_value);
8444 ret = wma_cli_set_command(pAdapter->sessionId,
8445 WMI_VDEV_PPS_GID_MATCH,
8446 set_value, PPS_CMD);
8447 break;
8448 }
8449
8450 case WE_PPS_EARLY_TIM_CLEAR:
8451 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008452 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008453 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008454 hdd_debug(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008455 set_value);
8456 ret = wma_cli_set_command(pAdapter->sessionId,
8457 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
8458 set_value, PPS_CMD);
8459 break;
8460 }
8461
8462 case WE_PPS_EARLY_DTIM_CLEAR:
8463 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008464 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008465 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008466 hdd_debug("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008467 set_value);
8468 ret = wma_cli_set_command(pAdapter->sessionId,
8469 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
8470 set_value, PPS_CMD);
8471 break;
8472 }
8473
8474 case WE_PPS_EOF_PAD_DELIM:
8475 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008476 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008477 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008478 hdd_debug("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008479 set_value);
8480 ret = wma_cli_set_command(pAdapter->sessionId,
8481 WMI_VDEV_PPS_EOF_PAD_DELIM,
8482 set_value, PPS_CMD);
8483 break;
8484 }
8485
8486 case WE_PPS_MACADDR_MISMATCH:
8487 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008488 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008489 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008490 hdd_debug("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008491 set_value);
8492 ret = wma_cli_set_command(pAdapter->sessionId,
8493 WMI_VDEV_PPS_MACADDR_MISMATCH,
8494 set_value, PPS_CMD);
8495 break;
8496 }
8497
8498 case WE_PPS_DELIM_CRC_FAIL:
8499 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008500 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008501 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008502 hdd_debug("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008503 set_value);
8504 ret = wma_cli_set_command(pAdapter->sessionId,
8505 WMI_VDEV_PPS_DELIM_CRC_FAIL,
8506 set_value, PPS_CMD);
8507 break;
8508 }
8509
8510 case WE_PPS_GID_NSTS_ZERO:
8511 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008512 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008513 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008514 hdd_debug("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008515 set_value);
8516 ret = wma_cli_set_command(pAdapter->sessionId,
8517 WMI_VDEV_PPS_GID_NSTS_ZERO,
8518 set_value, PPS_CMD);
8519 break;
8520 }
8521
8522 case WE_PPS_RSSI_CHECK:
8523 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008524 if (pAdapter->device_mode != QDF_STA_MODE)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008525 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008526 hdd_debug("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008527 set_value);
8528 ret = wma_cli_set_command(pAdapter->sessionId,
8529 WMI_VDEV_PPS_RSSI_CHECK,
8530 set_value, PPS_CMD);
8531 break;
8532 }
8533
8534 case WE_PPS_5G_EBT:
8535 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008536 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008537 return -EINVAL;
8538
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008539 hdd_debug("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008540 ret = wma_cli_set_command(pAdapter->sessionId,
8541 WMI_VDEV_PPS_5G_EBT,
8542 set_value, PPS_CMD);
8543 break;
8544 }
8545
8546 case WE_SET_HTSMPS:
8547 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008548 hdd_debug("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008549 ret = wma_cli_set_command(pAdapter->sessionId,
8550 WMI_STA_SMPS_FORCE_MODE_CMDID,
8551 set_value, VDEV_CMD);
8552 break;
8553 }
8554
8555 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
8556 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008557 hdd_debug("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008558 set_value);
8559 ret = wma_cli_set_command(pAdapter->sessionId,
8560 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
8561 set_value, QPOWER_CMD);
8562 break;
8563 }
8564
8565 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
8566 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008567 hdd_debug("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008568 set_value);
8569 ret = wma_cli_set_command(
8570 pAdapter->sessionId,
8571 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
8572 set_value, QPOWER_CMD);
8573 break;
8574 }
8575
8576 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
8577 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008578 hdd_debug("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008579 set_value);
8580 ret = wma_cli_set_command(
8581 pAdapter->sessionId,
8582 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
8583 set_value, QPOWER_CMD);
8584 break;
8585 }
8586
8587 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
8588 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008589 hdd_debug("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008590 set_value);
8591 ret = wma_cli_set_command(
8592 pAdapter->sessionId,
8593 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
8594 set_value, QPOWER_CMD);
8595 break;
8596 }
8597
8598 case WE_MCC_CONFIG_LATENCY:
8599 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008600 wlan_hdd_set_mcc_latency(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008601 break;
8602 }
8603
8604 case WE_MCC_CONFIG_QUOTA:
8605 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008606 hdd_debug("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008607 set_value);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008608 ret = wlan_hdd_set_mcc_p2p_quota(pAdapter,
8609 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008610 break;
8611 }
8612 case WE_SET_DEBUG_LOG:
8613 {
8614 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05308615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008616 hdd_ctx->config->gEnableDebugLog = set_value;
8617 sme_update_connect_debug(hdd_ctx->hHal, set_value);
8618 break;
8619 }
8620 case WE_SET_EARLY_RX_ADJUST_ENABLE:
8621 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008622 hdd_debug("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008623 if ((set_value == 0) || (set_value == 1))
8624 ret = wma_cli_set_command(
8625 pAdapter->sessionId,
8626 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
8627 set_value, VDEV_CMD);
8628 else
8629 ret = -EINVAL;
8630 break;
8631 }
8632 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
8633 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008634 hdd_debug("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008635 ret = wma_cli_set_command(pAdapter->sessionId,
8636 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
8637 set_value, VDEV_CMD);
8638 break;
8639 }
8640 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
8641 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008642 hdd_debug("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008643 set_value);
8644 ret = wma_cli_set_command(
8645 pAdapter->sessionId,
8646 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
8647 set_value, VDEV_CMD);
8648 break;
8649 }
8650 case WE_SET_EARLY_RX_SLOP_STEP:
8651 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008652 hdd_debug("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008653 set_value);
8654 ret = wma_cli_set_command(pAdapter->sessionId,
8655 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
8656 set_value, VDEV_CMD);
8657 break;
8658 }
8659 case WE_SET_EARLY_RX_INIT_SLOP:
8660 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008661 hdd_debug("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008662 set_value);
8663 ret = wma_cli_set_command(pAdapter->sessionId,
8664 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
8665 set_value, VDEV_CMD);
8666 break;
8667 }
8668 case WE_SET_EARLY_RX_ADJUST_PAUSE:
8669 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008670 hdd_debug("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008671 if ((set_value == 0) || (set_value == 1))
8672 ret = wma_cli_set_command(
8673 pAdapter->sessionId,
8674 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
8675 set_value, VDEV_CMD);
8676 else
8677 ret = -EINVAL;
8678 break;
8679 }
8680 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
8681 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008682 hdd_debug("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008683 ret = wma_cli_set_command(pAdapter->sessionId,
8684 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
8685 set_value, VDEV_CMD);
8686 break;
8687 }
8688 case WE_SET_SCAN_DISABLE:
8689 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008690 hdd_debug("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008691 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
8692 break;
8693 }
Govind Singha471e5e2015-10-12 17:11:14 +05308694 case WE_START_FW_PROFILE:
8695 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008696 hdd_debug("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05308697 ret = wma_cli_set_command(pAdapter->sessionId,
8698 WMI_WLAN_PROFILE_TRIGGER_CMDID,
8699 set_value, DBG_CMD);
8700 break;
8701 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308702 case WE_SET_CHANNEL:
8703 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008704 hdd_debug("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308705 pAdapter->sessionId, pAdapter->device_mode);
8706
Krunal Sonif07bb382016-03-10 13:02:11 -08008707 if ((QDF_STA_MODE == pAdapter->device_mode) ||
8708 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308709
8710 status = sme_ext_change_channel(hHal,
8711 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308712 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008713 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308714 status);
8715 ret = -EINVAL;
8716 }
8717 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008718 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308719 pAdapter->device_mode);
8720 ret = -EINVAL;
8721 }
8722 break;
8723 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308724 case WE_SET_CONC_SYSTEM_PREF:
8725 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008726 hdd_debug("New preference: %d", set_value);
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308727 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
8728 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
8729 hdd_err("Invalid system preference %d", set_value);
8730 return -EINVAL;
8731 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308732
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308733 /* hdd_ctx, hdd_ctx->config are already checked for null */
8734 hdd_ctx->config->conc_system_pref = set_value;
8735 break;
8736 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008737 case WE_SET_11AX_RATE:
8738 ret = hdd_set_11ax_rate(pAdapter, set_value, NULL);
8739 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07008740 case WE_SET_DCM:
8741 hdd_notice("Set WMI_VDEV_PARAM_HE_DCM: %d", set_value);
8742 ret = wma_cli_set_command(pAdapter->sessionId,
8743 WMI_VDEV_PARAM_HE_DCM, set_value,
8744 VDEV_CMD);
8745 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07008746 case WE_SET_RANGE_EXT:
8747 hdd_notice("Set WMI_VDEV_PARAM_HE_RANGE_EXT: %d", set_value);
8748 ret = wma_cli_set_command(pAdapter->sessionId,
8749 WMI_VDEV_PARAM_HE_RANGE_EXT,
8750 set_value, VDEV_CMD);
8751 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008752 default:
8753 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008754 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008755 sub_cmd);
8756 ret = -EINVAL;
8757 break;
8758 }
8759 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308760 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008761 return ret;
8762}
8763
8764static int iw_setint_getnone(struct net_device *dev,
8765 struct iw_request_info *info,
8766 union iwreq_data *wrqu,
8767 char *extra)
8768{
8769 int ret;
8770
8771 cds_ssr_protect(__func__);
8772 ret = __iw_setint_getnone(dev, info, wrqu, extra);
8773 cds_ssr_unprotect(__func__);
8774
8775 return ret;
8776}
8777
8778/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008779 * __iw_setnone_get_threeint() - return three value to up layer.
8780 *
8781 * @dev: pointer of net_device of this wireless card
8782 * @info: meta data about Request sent
8783 * @wrqu: include request info
8784 * @extra: buf used for in/Output
8785 *
8786 * Return: execute result
8787 */
8788static int __iw_setnone_get_threeint(struct net_device *dev,
8789 struct iw_request_info *info,
8790 union iwreq_data *wrqu, char *extra)
8791{
8792 int ret = 0; /* success */
8793 uint32_t *value = (int *)extra;
8794 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8795 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8796
8797 ENTER_DEV(dev);
8798 ret = wlan_hdd_validate_context(hdd_ctx);
8799 if (0 != ret)
8800 return ret;
8801
Jeff Johnson441e1f72017-02-07 08:50:49 -08008802 ret = hdd_check_private_wext_control(hdd_ctx, info);
8803 if (0 != ret)
8804 return ret;
8805
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008806 hdd_debug("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008807 switch (value[0]) {
8808 case WE_GET_TSF:
8809 ret = hdd_indicate_tsf(adapter, value, 3);
8810 break;
8811 default:
8812 hdd_err("Invalid IOCTL get_value command %d", value[0]);
8813 break;
8814 }
8815 return ret;
8816}
8817
8818/**
8819 * iw_setnone_get_threeint() - return three value to up layer.
8820 *
8821 * @dev: pointer of net_device of this wireless card
8822 * @info: meta data about Request sent
8823 * @wrqu: include request info
8824 * @extra: buf used for in/Output
8825 *
8826 * Return: execute result
8827 */
8828static int iw_setnone_get_threeint(struct net_device *dev,
8829 struct iw_request_info *info,
8830 union iwreq_data *wrqu, char *extra)
8831{
8832 int ret;
8833
8834 cds_ssr_protect(__func__);
8835 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8836 cds_ssr_unprotect(__func__);
8837
8838 return ret;
8839}
8840
8841/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008842 * iw_setchar_getnone() - Generic "set string" private ioctl handler
8843 * @dev: device upon which the ioctl was received
8844 * @info: ioctl request information
8845 * @wrqu: ioctl request data
8846 * @extra: ioctl extra data
8847 *
8848 * Return: 0 on success, non-zero on error
8849 */
8850static int __iw_setchar_getnone(struct net_device *dev,
8851 struct iw_request_info *info,
8852 union iwreq_data *wrqu, char *extra)
8853{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308854 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008855 int sub_cmd;
8856 int ret;
8857 char *pBuffer = NULL;
8858 hdd_adapter_t *pAdapter = (netdev_priv(dev));
8859 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008860 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008861 struct iw_point s_priv_data;
8862
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008863 ENTER_DEV(dev);
8864
Mukul Sharma34777c62015-11-02 20:22:30 +05308865 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008866 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05308867 return -EPERM;
8868 }
8869
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870 ret = wlan_hdd_validate_context(hdd_ctx);
8871 if (0 != ret)
8872 return ret;
8873
Jeff Johnson441e1f72017-02-07 08:50:49 -08008874 ret = hdd_check_private_wext_control(hdd_ctx, info);
8875 if (0 != ret)
8876 return ret;
8877
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008878 /* helper function to get iwreq_data with compat handling. */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008879 if (hdd_priv_get_data(&s_priv_data, wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008880 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008881
8882 /* make sure all params are correctly passed to function */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008883 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008884 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008885
8886 sub_cmd = s_priv_data.flags;
8887
8888 /* ODD number is used for set, copy data using copy_from_user */
8889 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8890 s_priv_data.length);
8891 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008892 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008893 return -ENOMEM;
8894 }
8895
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008896 hdd_debug("Received length: %d data: %s",
8897 s_priv_data.length, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008898
8899 switch (sub_cmd) {
8900 case WE_WOWL_ADD_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008901 hdd_debug("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008902 hdd_add_wowl_ptrn(pAdapter, pBuffer);
8903 break;
8904 case WE_WOWL_DEL_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008905 hdd_debug("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008906 hdd_del_wowl_ptrn(pAdapter, pBuffer);
8907 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008908 case WE_NEIGHBOR_REPORT_REQUEST:
8909 {
8910 tRrmNeighborReq neighborReq;
8911 tRrmNeighborRspCallbackInfo callbackInfo;
8912
8913 if (pConfig->fRrmEnable) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008914 hdd_debug("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008915 neighborReq.no_ssid =
8916 (s_priv_data.length - 1) ? false : true;
8917 if (!neighborReq.no_ssid) {
8918 neighborReq.ssid.length =
8919 (s_priv_data.length - 1) >
8920 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308921 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008922 pBuffer,
8923 neighborReq.ssid.length);
8924 }
8925
8926 callbackInfo.neighborRspCallback = NULL;
8927 callbackInfo.neighborRspCallbackContext = NULL;
8928 callbackInfo.timeout = 5000; /* 5 seconds */
8929 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
8930 (pAdapter),
8931 pAdapter->sessionId,
8932 &neighborReq,
8933 &callbackInfo);
8934 } else {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008935 hdd_err("Ignoring neighbor request as RRM not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008936 ret = -EINVAL;
8937 }
8938 }
8939 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008940 case WE_SET_AP_WPS_IE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008941 hdd_debug("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008942 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
8943 s_priv_data.length);
8944 break;
8945 case WE_SET_CONFIG:
8946 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008947 if (QDF_STATUS_SUCCESS != vstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008948 ret = -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008950 break;
8951 default:
8952 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008953 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008954 sub_cmd);
8955 ret = -EINVAL;
8956 break;
8957 }
8958 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07008959 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308960 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008961 return ret;
8962}
8963
8964static int iw_setchar_getnone(struct net_device *dev,
8965 struct iw_request_info *info,
8966 union iwreq_data *wrqu, char *extra)
8967{
8968 int ret;
8969
8970 cds_ssr_protect(__func__);
8971 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
8972 cds_ssr_unprotect(__func__);
8973
8974 return ret;
8975}
8976
8977/**
8978 * iw_setnone_getint() - Generic "get integer" private ioctl handler
8979 * @dev: device upon which the ioctl was received
8980 * @info: ioctl request information
8981 * @wrqu: ioctl request data
8982 * @extra: ioctl extra data
8983 *
8984 * Return: 0 on success, non-zero on error
8985 */
8986static int __iw_setnone_getint(struct net_device *dev,
8987 struct iw_request_info *info,
8988 union iwreq_data *wrqu, char *extra)
8989{
8990 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8991 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8992 int *value = (int *)extra;
8993 int ret;
8994 tSmeConfigParams smeConfig;
8995 hdd_context_t *hdd_ctx;
8996
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008997 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308998
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008999 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9000 ret = wlan_hdd_validate_context(hdd_ctx);
9001 if (0 != ret)
9002 return ret;
9003
Jeff Johnson441e1f72017-02-07 08:50:49 -08009004 ret = hdd_check_private_wext_control(hdd_ctx, info);
9005 if (0 != ret)
9006 return ret;
9007
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009008 switch (value[0]) {
9009 case WE_GET_11D_STATE:
9010 {
9011 sme_get_config_param(hHal, &smeConfig);
9012
9013 *value = smeConfig.csrConfig.Is11dSupportEnabled;
9014
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009015 hdd_debug("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009016
9017 break;
9018 }
9019
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009020 case WE_GET_WLAN_DBG:
9021 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309022 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009023 *value = 0;
9024 break;
9025 }
9026 case WE_GET_MAX_ASSOC:
9027 {
9028 if (sme_cfg_get_int
9029 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309030 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009031 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009032 ret = -EIO;
9033 }
9034 break;
9035 }
9036 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
9037 *value = (WLAN_HDD_GET_CTX(
9038 pAdapter))->config->force_sap_acs;
9039 break;
9040
9041 case WE_GET_CONCURRENCY_MODE:
9042 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08009043 *value = policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009044
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009045 hdd_debug("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009046 break;
9047 }
9048
9049 case WE_GET_NSS:
9050 {
9051 sme_get_config_param(hHal, &smeConfig);
9052 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009053 hdd_debug("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009054 break;
9055 }
9056
9057 case WE_GET_GTX_HT_MCS:
9058 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009059 hdd_debug("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009060 *value = wma_cli_get_command(pAdapter->sessionId,
9061 WMI_VDEV_PARAM_GTX_HT_MCS,
9062 GTX_CMD);
9063 break;
9064 }
9065
9066 case WE_GET_GTX_VHT_MCS:
9067 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009068 hdd_debug("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009069 *value = wma_cli_get_command(pAdapter->sessionId,
9070 WMI_VDEV_PARAM_GTX_VHT_MCS,
9071 GTX_CMD);
9072 break;
9073 }
9074
9075 case WE_GET_GTX_USRCFG:
9076 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009077 hdd_debug("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009078 *value = wma_cli_get_command(pAdapter->sessionId,
9079 WMI_VDEV_PARAM_GTX_USR_CFG,
9080 GTX_CMD);
9081 break;
9082 }
9083
9084 case WE_GET_GTX_THRE:
9085 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009086 hdd_debug("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009087 *value = wma_cli_get_command(pAdapter->sessionId,
9088 WMI_VDEV_PARAM_GTX_THRE,
9089 GTX_CMD);
9090 break;
9091 }
9092
9093 case WE_GET_GTX_MARGIN:
9094 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009095 hdd_debug("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009096 *value = wma_cli_get_command(pAdapter->sessionId,
9097 WMI_VDEV_PARAM_GTX_MARGIN,
9098 GTX_CMD);
9099 break;
9100 }
9101
9102 case WE_GET_GTX_STEP:
9103 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009104 hdd_debug("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009105 *value = wma_cli_get_command(pAdapter->sessionId,
9106 WMI_VDEV_PARAM_GTX_STEP,
9107 GTX_CMD);
9108 break;
9109 }
9110
9111 case WE_GET_GTX_MINTPC:
9112 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009113 hdd_debug("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009114 *value = wma_cli_get_command(pAdapter->sessionId,
9115 WMI_VDEV_PARAM_GTX_MINTPC,
9116 GTX_CMD);
9117 break;
9118 }
9119
9120 case WE_GET_GTX_BWMASK:
9121 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009122 hdd_debug("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009123 *value = wma_cli_get_command(pAdapter->sessionId,
9124 WMI_VDEV_PARAM_GTX_BW_MASK,
9125 GTX_CMD);
9126 break;
9127 }
9128
9129 case WE_GET_LDPC:
9130 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309131 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009132 break;
9133 }
9134
9135 case WE_GET_TX_STBC:
9136 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309137 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009138 break;
9139 }
9140
9141 case WE_GET_RX_STBC:
9142 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309143 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009144 break;
9145 }
9146
9147 case WE_GET_SHORT_GI:
9148 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009149 hdd_debug("GET WMI_VDEV_PARAM_SGI");
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009150 *value = wma_cli_get_command(pAdapter->sessionId,
9151 WMI_VDEV_PARAM_SGI,
9152 VDEV_CMD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009153 break;
9154 }
9155
9156 case WE_GET_RTSCTS:
9157 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009158 hdd_debug("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009159 *value = wma_cli_get_command(pAdapter->sessionId,
9160 WMI_VDEV_PARAM_ENABLE_RTSCTS,
9161 VDEV_CMD);
9162 break;
9163 }
9164
9165 case WE_GET_CHWIDTH:
9166 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009167 hdd_debug("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009168 *value = wma_cli_get_command(pAdapter->sessionId,
9169 WMI_VDEV_PARAM_CHWIDTH,
9170 VDEV_CMD);
9171 break;
9172 }
9173
9174 case WE_GET_ANI_EN_DIS:
9175 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009176 hdd_debug("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009177 *value = wma_cli_get_command(pAdapter->sessionId,
9178 WMI_PDEV_PARAM_ANI_ENABLE,
9179 PDEV_CMD);
9180 break;
9181 }
9182
9183 case WE_GET_ANI_POLL_PERIOD:
9184 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009185 hdd_debug("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009186 *value = wma_cli_get_command(pAdapter->sessionId,
9187 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
9188 PDEV_CMD);
9189 break;
9190 }
9191
9192 case WE_GET_ANI_LISTEN_PERIOD:
9193 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009194 hdd_debug("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009195 *value = wma_cli_get_command(pAdapter->sessionId,
9196 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
9197 PDEV_CMD);
9198 break;
9199 }
9200
9201 case WE_GET_ANI_OFDM_LEVEL:
9202 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009203 hdd_debug("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009204 *value = wma_cli_get_command(pAdapter->sessionId,
9205 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
9206 PDEV_CMD);
9207 break;
9208 }
9209
9210 case WE_GET_ANI_CCK_LEVEL:
9211 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009212 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009213 *value = wma_cli_get_command(pAdapter->sessionId,
9214 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
9215 PDEV_CMD);
9216 break;
9217 }
9218
9219 case WE_GET_DYNAMIC_BW:
9220 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009221 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009222 *value = wma_cli_get_command(pAdapter->sessionId,
9223 WMI_PDEV_PARAM_DYNAMIC_BW,
9224 PDEV_CMD);
9225 break;
9226 }
9227
9228 case WE_GET_11N_RATE:
9229 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009230 hdd_debug("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009231 *value = wma_cli_get_command(pAdapter->sessionId,
9232 WMI_VDEV_PARAM_FIXED_RATE,
9233 VDEV_CMD);
9234 break;
9235 }
9236
9237 case WE_GET_AMPDU:
9238 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009239 hdd_debug("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009240 *value = wma_cli_get_command(pAdapter->sessionId,
9241 GEN_VDEV_PARAM_AMPDU,
9242 GEN_CMD);
9243 break;
9244 }
9245
9246 case WE_GET_AMSDU:
9247 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009248 hdd_debug("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009249 *value = wma_cli_get_command(pAdapter->sessionId,
9250 GEN_VDEV_PARAM_AMSDU,
9251 GEN_CMD);
9252 break;
9253 }
9254
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009255 case WE_GET_ROAM_SYNCH_DELAY:
9256 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009257 hdd_debug("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009258 *value = wma_cli_get_command(pAdapter->sessionId,
9259 GEN_VDEV_ROAM_SYNCH_DELAY,
9260 GEN_CMD);
9261 break;
9262 }
9263
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009264 case WE_GET_BURST_ENABLE:
9265 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009266 hdd_debug("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009267 *value = wma_cli_get_command(pAdapter->sessionId,
9268 WMI_PDEV_PARAM_BURST_ENABLE,
9269 PDEV_CMD);
9270 break;
9271 }
9272 case WE_GET_BURST_DUR:
9273 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009274 hdd_debug("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009275 *value = wma_cli_get_command(pAdapter->sessionId,
9276 WMI_PDEV_PARAM_BURST_DUR,
9277 PDEV_CMD);
9278 break;
9279 }
9280
9281 case WE_GET_TX_CHAINMASK:
9282 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009283 hdd_debug("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009284 *value = wma_cli_get_command(pAdapter->sessionId,
9285 WMI_PDEV_PARAM_TX_CHAIN_MASK,
9286 PDEV_CMD);
9287 break;
9288 }
9289
9290 case WE_GET_RX_CHAINMASK:
9291 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009292 hdd_debug("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009293 *value = wma_cli_get_command(pAdapter->sessionId,
9294 WMI_PDEV_PARAM_RX_CHAIN_MASK,
9295 PDEV_CMD);
9296 break;
9297 }
9298
9299 case WE_GET_TXPOW_2G:
9300 {
9301 uint32_t txpow2g = 0;
9302 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009303
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009304 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009305 *value = wma_cli_get_command(pAdapter->sessionId,
9306 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
9307 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309308 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009309 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9310 &txpow2g)) {
9311 return -EIO;
9312 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009313 hdd_debug("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009314 break;
9315 }
9316
9317 case WE_GET_TXPOW_5G:
9318 {
9319 uint32_t txpow5g = 0;
9320 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009321
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009322 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009323 *value = wma_cli_get_command(pAdapter->sessionId,
9324 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
9325 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309326 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009327 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9328 &txpow5g)) {
9329 return -EIO;
9330 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009331 hdd_debug("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009332 break;
9333 }
9334
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009335 case WE_GET_PPS_PAID_MATCH:
9336 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009337 hdd_debug("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009338 *value = wma_cli_get_command(pAdapter->sessionId,
9339 WMI_VDEV_PPS_PAID_MATCH,
9340 PPS_CMD);
9341 break;
9342 }
9343
9344 case WE_GET_PPS_GID_MATCH:
9345 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009346 hdd_debug("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009347 *value = wma_cli_get_command(pAdapter->sessionId,
9348 WMI_VDEV_PPS_GID_MATCH,
9349 PPS_CMD);
9350 break;
9351 }
9352
9353 case WE_GET_PPS_EARLY_TIM_CLEAR:
9354 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009355 hdd_debug("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009356 *value = wma_cli_get_command(pAdapter->sessionId,
9357 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
9358 PPS_CMD);
9359 break;
9360 }
9361
9362 case WE_GET_PPS_EARLY_DTIM_CLEAR:
9363 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009364 hdd_debug("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009365 *value = wma_cli_get_command(pAdapter->sessionId,
9366 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
9367 PPS_CMD);
9368 break;
9369 }
9370
9371 case WE_GET_PPS_EOF_PAD_DELIM:
9372 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009373 hdd_debug("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009374 *value = wma_cli_get_command(pAdapter->sessionId,
9375 WMI_VDEV_PPS_EOF_PAD_DELIM,
9376 PPS_CMD);
9377 break;
9378 }
9379
9380 case WE_GET_PPS_MACADDR_MISMATCH:
9381 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009382 hdd_debug("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009383 *value = wma_cli_get_command(pAdapter->sessionId,
9384 WMI_VDEV_PPS_MACADDR_MISMATCH,
9385 PPS_CMD);
9386 break;
9387 }
9388
9389 case WE_GET_PPS_DELIM_CRC_FAIL:
9390 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009391 hdd_debug("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009392 *value = wma_cli_get_command(pAdapter->sessionId,
9393 WMI_VDEV_PPS_DELIM_CRC_FAIL,
9394 PPS_CMD);
9395 break;
9396 }
9397
9398 case WE_GET_PPS_GID_NSTS_ZERO:
9399 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009400 hdd_debug("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009401 *value = wma_cli_get_command(pAdapter->sessionId,
9402 WMI_VDEV_PPS_GID_NSTS_ZERO,
9403 PPS_CMD);
9404 break;
9405 }
9406
9407 case WE_GET_PPS_RSSI_CHECK:
9408 {
9409
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009410 hdd_debug("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009411 *value = wma_cli_get_command(pAdapter->sessionId,
9412 WMI_VDEV_PPS_RSSI_CHECK,
9413 PPS_CMD);
9414 break;
9415 }
9416
9417 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
9418 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009419 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009420 *value = wma_cli_get_command(pAdapter->sessionId,
9421 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
9422 QPOWER_CMD);
9423 break;
9424 }
9425
9426 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
9427 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009428 hdd_debug("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009429 *value = wma_cli_get_command(pAdapter->sessionId,
9430 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
9431 QPOWER_CMD);
9432 break;
9433 }
9434
9435 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
9436 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009437 hdd_debug("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009438 *value = wma_cli_get_command(pAdapter->sessionId,
9439 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
9440 QPOWER_CMD);
9441 break;
9442 }
9443
9444 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
9445 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009446 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009447 *value = wma_cli_get_command(pAdapter->sessionId,
9448 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
9449 QPOWER_CMD);
9450 break;
9451 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009452 case WE_CAP_TSF:
9453 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
9454 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009455 case WE_GET_TEMPERATURE:
9456 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009457 hdd_debug("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009458 ret = wlan_hdd_get_temperature(pAdapter, value);
9459 break;
9460 }
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07009461 case WE_GET_DCM:
9462 hdd_notice("GET WMI_VDEV_PARAM_HE_DCM");
9463 *value = wma_cli_get_command(pAdapter->sessionId,
9464 WMI_VDEV_PARAM_HE_DCM,
9465 VDEV_CMD);
9466 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07009467 case WE_GET_RANGE_EXT:
9468 hdd_notice("GET WMI_VDEV_PARAM_HE_RANGE_EXT");
9469 *value = wma_cli_get_command(pAdapter->sessionId,
9470 WMI_VDEV_PARAM_HE_RANGE_EXT,
9471 VDEV_CMD);
9472 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009473 default:
9474 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009475 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009476 value[0]);
9477 break;
9478 }
9479 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309480 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009481 return ret;
9482}
9483
9484static int iw_setnone_getint(struct net_device *dev,
9485 struct iw_request_info *info,
9486 union iwreq_data *wrqu, char *extra)
9487{
9488 int ret;
9489
9490 cds_ssr_protect(__func__);
9491 ret = __iw_setnone_getint(dev, info, wrqu, extra);
9492 cds_ssr_unprotect(__func__);
9493
9494 return ret;
9495}
9496
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309497static int hdd_set_fwtest(int argc, int cmd, int value)
9498{
9499 struct set_fwtest_params *fw_test;
9500
9501 /* check for max number of arguments */
9502 if (argc > (WMA_MAX_NUM_ARGS) ||
9503 argc != HDD_FWTEST_PARAMS) {
9504 hdd_err("Too Many args %d", argc);
9505 return -EINVAL;
9506 }
9507 /*
9508 * check if number of arguments are 3 then, check
9509 * then set the default value for sounding interval.
9510 */
9511 if (HDD_FWTEST_PARAMS == argc) {
9512 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
9513 value = HDD_FWTEST_SU_DEFAULT_VALUE;
9514 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
9515 value = HDD_FWTEST_MU_DEFAULT_VALUE;
9516 }
9517 /* check sounding interval value should not exceed to max */
9518 if (value > HDD_FWTEST_MAX_VALUE) {
9519 hdd_err("Invalid arguments value should not exceed max: %d",
9520 value);
9521 return -EINVAL;
9522 }
9523 fw_test = qdf_mem_malloc(sizeof(*fw_test));
9524 if (NULL == fw_test) {
9525 hdd_err("qdf_mem_malloc failed for fw_test");
9526 return -ENOMEM;
9527 }
9528 fw_test->arg = cmd;
9529 fw_test->value = value;
9530 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
9531 qdf_mem_free(fw_test);
9532 hdd_err("Not able to post FW_TEST_CMD message to WMA");
9533 return -EINVAL;
9534 }
9535 return 0;
9536}
9537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009538/**
9539 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
9540 * @dev: device upon which the ioctl was received
9541 * @info: ioctl request information
9542 * @wrqu: ioctl request data
9543 * @extra: ioctl extra data
9544 *
9545 * Return: 0 on success, non-zero on error
9546 */
9547static int __iw_set_three_ints_getnone(struct net_device *dev,
9548 struct iw_request_info *info,
9549 union iwreq_data *wrqu, char *extra)
9550{
9551 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9552 int *value = (int *)extra;
9553 int sub_cmd = value[0];
9554 int ret;
9555 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9556
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009557 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309558
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009559 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009560 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009561 return -EPERM;
9562 }
9563
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009564 ret = wlan_hdd_validate_context(hdd_ctx);
9565 if (0 != ret)
9566 return ret;
9567
Jeff Johnson441e1f72017-02-07 08:50:49 -08009568 ret = hdd_check_private_wext_control(hdd_ctx, info);
9569 if (0 != ret)
9570 return ret;
9571
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009572 switch (sub_cmd) {
9573
9574 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309575 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009576 break;
9577 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309578 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009579 break;
9580
9581 /* value[3] the acs band is not required as start and end channels are
9582 * enough but this cmd is maintained under set three ints for historic
9583 * reasons.
9584 */
9585 case WE_SET_SAP_CHANNELS:
9586 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309587 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009588 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309589 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009590 ret = -EINVAL;
9591 } else {
9592 hdd_ctx->config->force_sap_acs_st_ch = value[1];
9593 hdd_ctx->config->force_sap_acs_end_ch = value[2];
9594 }
9595 break;
9596 case WE_SET_DUAL_MAC_SCAN_CONFIG:
9597 hdd_debug("Ioctl to set dual mac scan config");
9598 if (hdd_ctx->config->dual_mac_feature_disable) {
9599 hdd_err("Dual mac feature is disabled from INI");
9600 return -EPERM;
9601 }
9602 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08009603 policy_mgr_set_dual_mac_scan_config(hdd_ctx->hdd_psoc,
9604 value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009605 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309606 case WE_SET_FW_TEST:
9607 {
9608 ret = hdd_set_fwtest(value[1], value[2], value[3]);
9609 if (ret) {
9610 hdd_err("Not able to set fwtest %d", ret);
9611 return ret;
9612 }
9613 }
9614 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009615 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009616 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009617 break;
9618
9619 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309620 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009621 return ret;
9622}
9623
9624int iw_set_three_ints_getnone(struct net_device *dev,
9625 struct iw_request_info *info,
9626 union iwreq_data *wrqu, char *extra)
9627{
9628 int ret;
9629
9630 cds_ssr_protect(__func__);
9631 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
9632 cds_ssr_unprotect(__func__);
9633
9634 return ret;
9635}
9636
9637/**
9638 * hdd_connection_state_string() - Get connection state string
9639 * @connection_state: enum to be converted to a string
9640 *
9641 * Return: the string equivalent of @connection_state
9642 */
9643static const char *
9644hdd_connection_state_string(eConnectionState connection_state)
9645{
9646 switch (connection_state) {
9647 CASE_RETURN_STRING(eConnectionState_NotConnected);
9648 CASE_RETURN_STRING(eConnectionState_Connecting);
9649 CASE_RETURN_STRING(eConnectionState_Associated);
9650 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
9651 CASE_RETURN_STRING(eConnectionState_IbssConnected);
9652 CASE_RETURN_STRING(eConnectionState_Disconnecting);
9653 default:
9654 return "UNKNOWN";
9655 }
9656}
9657
Naveen Rawat910726a2017-03-06 11:42:51 -08009658#if defined(FEATURE_OEM_DATA_SUPPORT)
9659/**
9660 * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
9661 * wifi_pos api to get oem data caps
9662 * @dev: net device upon which the request was received
9663 * @info: ioctl request information
9664 * @wrqu: ioctl request data
9665 * @extra: ioctl data payload
9666 *
9667 * Return: 0 for success, negative errno value on failure
9668 */
9669static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9670 struct iw_request_info *info,
9671 union iwreq_data *wrqu, char *extra)
9672{
9673 return iw_get_oem_data_cap(dev, info, wrqu, extra);
9674}
9675#elif defined(WIFI_POS_CONVERGED)
9676static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9677 struct iw_request_info *info,
9678 union iwreq_data *wrqu, char *extra)
9679{
9680 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9681 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9682
9683 return os_if_wifi_pos_populate_caps(hdd_ctx->hdd_psoc,
9684 (struct wifi_pos_driver_caps *)extra);
9685}
9686#else
9687static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9688 struct iw_request_info *info,
9689 union iwreq_data *wrqu, char *extra)
9690{
9691 return -ENOTSUPP;
9692}
9693#endif
9694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009695/**
9696 * iw_get_char_setnone() - Generic "get string" private ioctl handler
9697 * @dev: device upon which the ioctl was received
9698 * @info: ioctl request information
9699 * @wrqu: ioctl request data
9700 * @extra: ioctl extra data
9701 *
9702 * Return: 0 on success, non-zero on error
9703 */
9704static int __iw_get_char_setnone(struct net_device *dev,
9705 struct iw_request_info *info,
9706 union iwreq_data *wrqu, char *extra)
9707{
9708 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9709 int sub_cmd = wrqu->data.flags;
9710 hdd_context_t *hdd_ctx;
9711 int ret;
9712#ifdef WLAN_FEATURE_11W
9713 hdd_wext_state_t *pWextState;
9714#endif
9715
9716#ifdef WLAN_FEATURE_11W
9717 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9718#endif
9719
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009720 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009722 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9723 ret = wlan_hdd_validate_context(hdd_ctx);
9724 if (0 != ret)
9725 return ret;
9726
Jeff Johnson441e1f72017-02-07 08:50:49 -08009727 ret = hdd_check_private_wext_control(hdd_ctx, info);
9728 if (0 != ret)
9729 return ret;
9730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009731 switch (sub_cmd) {
9732 case WE_WLAN_VERSION:
9733 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05309734 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009735 break;
9736 }
9737
9738 case WE_GET_STATS:
9739 {
9740 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
9741 extra, WE_MAX_STR_LEN);
9742 break;
9743 }
9744
Dustin Brownd9322482017-01-09 12:46:03 -08009745 case WE_GET_SUSPEND_RESUME_STATS:
9746 {
9747 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
9748 WE_MAX_STR_LEN);
9749 if (ret >= 0) {
9750 wrqu->data.length = ret;
9751 ret = 0;
9752 }
9753
9754 break;
9755 }
9756
Govind Singha471e5e2015-10-12 17:11:14 +05309757 case WE_LIST_FW_PROFILE:
9758 hdd_wlan_list_fw_profile(&(wrqu->data.length),
9759 extra, WE_MAX_STR_LEN);
9760 break;
9761
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009762 /* The case prints the current state of the HDD, SME, CSR, PE,
9763 * TL it can be extended for WDI Global State as well. And
9764 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
9765 * and P2P_GO have not been added as of now.
9766 */
9767 case WE_GET_STATES:
9768 {
9769 int buf = 0, len = 0;
9770 int adapter_num = 0;
9771 int count = 0, check = 1;
9772
9773 tHalHandle hHal = NULL;
9774 tpAniSirGlobal pMac = NULL;
9775 hdd_station_ctx_t *pHddStaCtx = NULL;
9776
9777 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9778 hdd_adapter_t *useAdapter = NULL;
9779
9780 /* Print wlan0 or p2p0 states based on the adapter_num
9781 * by using the correct adapter
9782 */
9783 while (adapter_num < 2) {
9784 if (WLAN_ADAPTER == adapter_num) {
9785 useAdapter = pAdapter;
9786 buf =
9787 scnprintf(extra + len,
9788 WE_MAX_STR_LEN - len,
9789 "\n\n wlan0 States:-");
9790 len += buf;
9791 } else if (P2P_ADAPTER == adapter_num) {
9792 buf =
9793 scnprintf(extra + len,
9794 WE_MAX_STR_LEN - len,
9795 "\n\n p2p0 States:-");
9796 len += buf;
9797
9798 if (!pHddCtx) {
9799 buf =
9800 scnprintf(extra + len,
9801 WE_MAX_STR_LEN -
9802 len,
9803 "\n pHddCtx is NULL");
9804 len += buf;
9805 break;
9806 }
9807
9808 /* Printing p2p0 states only in the
9809 * case when the device is configured
9810 * as a p2p_client
9811 */
9812 useAdapter =
9813 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08009814 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009815 if (!useAdapter) {
9816 buf =
9817 scnprintf(extra + len,
9818 WE_MAX_STR_LEN -
9819 len,
9820 "\n Device not configured as P2P_CLIENT.");
9821 len += buf;
9822 break;
9823 }
9824 }
9825
9826 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
9827 if (!hHal) {
9828 buf =
9829 scnprintf(extra + len,
9830 WE_MAX_STR_LEN - len,
9831 "\n pMac is NULL");
9832 len += buf;
9833 break;
9834 }
9835 pMac = PMAC_STRUCT(hHal);
9836 if (!pMac) {
9837 buf =
9838 scnprintf(extra + len,
9839 WE_MAX_STR_LEN - len,
9840 "\n pMac is NULL");
9841 len += buf;
9842 break;
9843 }
9844 pHddStaCtx =
9845 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
9846
9847
9848 buf =
9849 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9850 "\n HDD Conn State - %s "
9851 "\n \n SME State:"
9852 "\n Neighbour Roam State - %s"
9853 "\n CSR State - %s"
9854 "\n CSR Substate - %s",
9855 hdd_connection_state_string
9856 (pHddStaCtx->conn_info.connState),
9857 mac_trace_get_neighbour_roam_state
9858 (sme_get_neighbor_roam_state
9859 (hHal, useAdapter->sessionId)),
9860 mac_trace_getcsr_roam_state
9861 (sme_get_current_roam_state
9862 (hHal, useAdapter->sessionId)),
9863 mac_trace_getcsr_roam_sub_state
9864 (sme_get_current_roam_sub_state
9865 (hHal, useAdapter->sessionId))
9866 );
9867 len += buf;
9868 adapter_num++;
9869 }
9870
Mukul Sharma81661ae2015-10-30 20:26:02 +05309871 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009872 /* Printing Lim State starting with global lim states */
9873 buf =
9874 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9875 "\n \n LIM STATES:-"
9876 "\n Global Sme State - %s "
9877 "\n Global mlm State - %s " "\n",
9878 mac_trace_get_lim_sme_state
9879 (sme_get_lim_sme_state(hHal)),
9880 mac_trace_get_lim_mlm_state
9881 (sme_get_lim_sme_state(hHal))
9882 );
9883 len += buf;
9884
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009885 while (check < 3 && count < 255) {
9886 if (sme_is_lim_session_valid(hHal, count)) {
9887 buf =
9888 scnprintf(extra + len,
9889 WE_MAX_STR_LEN -
9890 len,
9891 "\n Lim Valid Session %d:-"
9892 "\n PE Sme State - %s "
9893 "\n PE Mlm State - %s "
9894 "\n", check,
9895 mac_trace_get_lim_sme_state
9896 (sme_get_lim_sme_session_state
9897 (hHal, count)),
9898 mac_trace_get_lim_mlm_state
9899 (sme_get_lim_mlm_session_state
9900 (hHal, count))
9901 );
9902
9903 len += buf;
9904 check++;
9905 }
9906 count++;
9907 }
9908 }
9909
9910 wrqu->data.length = strlen(extra) + 1;
9911 break;
9912 }
9913
9914 case WE_GET_CFG:
9915 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009916 hdd_debug("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009917 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
9918 extra,
9919 QCSAP_IOCTL_MAX_STR_LEN);
9920 wrqu->data.length = strlen(extra) + 1;
9921 break;
9922 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009923 case WE_GET_RSSI:
9924 {
9925 int8_t s7Rssi = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009926
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009927 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
9928 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
9929 wrqu->data.length = strlen(extra) + 1;
9930 break;
9931 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009932
9933 case WE_GET_WMM_STATUS:
9934 {
9935 snprintf(extra, WE_MAX_STR_LEN,
9936 "\nDir: 0=up, 1=down, 3=both\n"
9937 "|------------------------|\n"
9938 "|AC | ACM |Admitted| Dir |\n"
9939 "|------------------------|\n"
9940 "|VO | %d | %3s | %d |\n"
9941 "|VI | %d | %3s | %d |\n"
9942 "|BE | %d | %3s | %d |\n"
9943 "|BK | %d | %3s | %d |\n"
9944 "|------------------------|\n",
9945 pAdapter->hddWmmStatus.
9946 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
9947 pAdapter->hddWmmStatus.
9948 wmmAcStatus[SME_AC_VO].
9949 wmmAcAccessAllowed ? "YES" : "NO",
9950 pAdapter->hddWmmStatus.
9951 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
9952 ts_info.direction,
9953 pAdapter->hddWmmStatus.
9954 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
9955 pAdapter->hddWmmStatus.
9956 wmmAcStatus[SME_AC_VI].
9957 wmmAcAccessAllowed ? "YES" : "NO",
9958 pAdapter->hddWmmStatus.
9959 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
9960 ts_info.direction,
9961 pAdapter->hddWmmStatus.
9962 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
9963 pAdapter->hddWmmStatus.
9964 wmmAcStatus[SME_AC_BE].
9965 wmmAcAccessAllowed ? "YES" : "NO",
9966 pAdapter->hddWmmStatus.
9967 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
9968 ts_info.direction,
9969 pAdapter->hddWmmStatus.
9970 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
9971 pAdapter->hddWmmStatus.
9972 wmmAcStatus[SME_AC_BK].
9973 wmmAcAccessAllowed ? "YES" : "NO",
9974 pAdapter->hddWmmStatus.
9975 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
9976 ts_info.direction);
9977
9978 wrqu->data.length = strlen(extra) + 1;
9979 break;
9980 }
9981 case WE_GET_CHANNEL_LIST:
9982 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309983 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009984 uint8_t i, len;
9985 char *buf;
9986 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
9987 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
9988 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9989
Srinivas Girigowdac231df62017-03-24 18:27:57 -07009990 struct channel_list_info channel_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009991
9992 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05309993 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009994 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309995 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009996 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009997 return -EINVAL;
9998 }
9999 buf = extra;
10000 /*
10001 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
10002 * Maximum buffer needed = 5 * number of channels.
10003 * Check ifsufficient buffer is available and then
10004 * proceed to fill the buffer.
10005 */
10006 if (WE_MAX_STR_LEN <
10007 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010008 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010009 return -EINVAL;
10010 }
10011 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
10012 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010013 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010014 ubuf, &ubuf_len)) {
10015 /* Printing Country code in getChannelList */
10016 for (i = 0; i < (ubuf_len - 1); i++)
10017 len += scnprintf(buf + len,
10018 WE_MAX_STR_LEN - len,
10019 "%c", ubuf[i]);
10020 }
10021 for (i = 0; i < channel_list.num_channels; i++) {
10022 len +=
10023 scnprintf(buf + len, WE_MAX_STR_LEN - len,
10024 " %u", channel_list.channels[i]);
10025 }
10026 wrqu->data.length = strlen(extra) + 1;
10027
10028 break;
10029 }
10030#ifdef FEATURE_WLAN_TDLS
10031 case WE_GET_TDLS_PEERS:
10032 {
10033 wrqu->data.length =
10034 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
10035 WE_MAX_STR_LEN) + 1;
10036 break;
10037 }
10038#endif
10039#ifdef WLAN_FEATURE_11W
10040 case WE_GET_11W_INFO:
10041 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010042 hdd_debug("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010043 pWextState->roamProfile.MFPEnabled);
10044
10045 snprintf(extra, WE_MAX_STR_LEN,
10046 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
10047 "\n Number of Unprotected Disassocs %d"
10048 "\n Number of Unprotected Deauths %d",
10049 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
10050 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
10051 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
10052 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
10053 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
10054 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
10055 pWextState->roamProfile.MFPEnabled,
10056 pAdapter->hdd_stats.hddPmfStats.
10057 numUnprotDisassocRx,
10058 pAdapter->hdd_stats.hddPmfStats.
10059 numUnprotDeauthRx);
10060
10061 wrqu->data.length = strlen(extra) + 1;
10062 break;
10063 }
10064#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010065 case WE_GET_IBSS_STA_INFO:
10066 {
10067 hdd_station_ctx_t *pHddStaCtx =
10068 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10069 int idx = 0;
10070 int length = 0, buf = 0;
10071
Naveen Rawatc45d1622016-07-05 12:20:09 -070010072 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010073 if (0 != pHddStaCtx->conn_info.staId[idx]) {
10074 buf = snprintf
10075 ((extra + length),
10076 WE_MAX_STR_LEN - length,
10077 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
10078 pHddStaCtx->conn_info.staId[idx],
10079 pHddStaCtx->conn_info.
10080 peerMacAddress[idx].bytes[0],
10081 pHddStaCtx->conn_info.
10082 peerMacAddress[idx].bytes[1],
10083 pHddStaCtx->conn_info.
10084 peerMacAddress[idx].bytes[2],
10085 pHddStaCtx->conn_info.
10086 peerMacAddress[idx].bytes[3],
10087 pHddStaCtx->conn_info.
10088 peerMacAddress[idx].bytes[4],
10089 pHddStaCtx->conn_info.
10090 peerMacAddress[idx].bytes[5]
10091 );
10092 length += buf;
10093 }
10094 }
10095 wrqu->data.length = strlen(extra) + 1;
10096 break;
10097 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010098 case WE_GET_PHYMODE:
10099 {
10100 bool ch_bond24 = false, ch_bond5g = false;
10101 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
10102 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10103 eCsrPhyMode phymode;
10104 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010105 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010106
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010107 sme_config = qdf_mem_malloc(sizeof(*sme_config));
10108 if (!sme_config) {
10109 hdd_err("Out of memory");
10110 ret = -ENOMEM;
10111 break;
10112 }
10113
10114 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010115 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010116 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010117 ch_bond24 = true;
10118
10119 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010120 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010121 ch_bond5g = true;
10122
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010123 qdf_mem_free(sme_config);
10124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010125 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010126 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010127 sme_get_freq_band(hal, &currBand))) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010128 hdd_err("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010129 return -EIO;
10130 }
10131
10132 switch (phymode) {
10133 case eCSR_DOT11_MODE_AUTO:
10134 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
10135 break;
10136 case eCSR_DOT11_MODE_11n:
10137 case eCSR_DOT11_MODE_11n_ONLY:
10138 if (currBand == eCSR_BAND_24) {
10139 if (ch_bond24)
10140 snprintf(extra, WE_MAX_STR_LEN,
10141 "11NGHT40");
10142 else
10143 snprintf(extra, WE_MAX_STR_LEN,
10144 "11NGHT20");
10145 } else if (currBand == eCSR_BAND_5G) {
10146 if (ch_bond5g)
10147 snprintf(extra, WE_MAX_STR_LEN,
10148 "11NAHT40");
10149 else
10150 snprintf(extra, WE_MAX_STR_LEN,
10151 "11NAHT20");
10152 } else {
10153 snprintf(extra, WE_MAX_STR_LEN, "11N");
10154 }
10155 break;
10156 case eCSR_DOT11_MODE_abg:
10157 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
10158 break;
10159 case eCSR_DOT11_MODE_11a:
10160 snprintf(extra, WE_MAX_STR_LEN, "11A");
10161 break;
10162 case eCSR_DOT11_MODE_11b:
10163 case eCSR_DOT11_MODE_11b_ONLY:
10164 snprintf(extra, WE_MAX_STR_LEN, "11B");
10165 break;
10166 case eCSR_DOT11_MODE_11g:
10167 case eCSR_DOT11_MODE_11g_ONLY:
10168 snprintf(extra, WE_MAX_STR_LEN, "11G");
10169 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010170 case eCSR_DOT11_MODE_11ac:
10171 case eCSR_DOT11_MODE_11ac_ONLY:
10172 if (hddctx->config->vhtChannelWidth ==
10173 eHT_CHANNEL_WIDTH_20MHZ)
10174 snprintf(extra, WE_MAX_STR_LEN,
10175 "11ACVHT20");
10176 else if (hddctx->config->vhtChannelWidth ==
10177 eHT_CHANNEL_WIDTH_40MHZ)
10178 snprintf(extra, WE_MAX_STR_LEN,
10179 "11ACVHT40");
10180 else if (hddctx->config->vhtChannelWidth ==
10181 eHT_CHANNEL_WIDTH_80MHZ)
10182 snprintf(extra, WE_MAX_STR_LEN,
10183 "11ACVHT80");
10184 else if (hddctx->config->vhtChannelWidth ==
10185 eHT_CHANNEL_WIDTH_160MHZ)
10186 snprintf(extra, WE_MAX_STR_LEN,
10187 "11ACVHT160");
10188 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080010189 case eCSR_DOT11_MODE_11ax:
10190 case eCSR_DOT11_MODE_11ax_ONLY:
10191 /* currently using vhtChannelWidth */
10192 if (hddctx->config->vhtChannelWidth ==
10193 eHT_CHANNEL_WIDTH_20MHZ)
10194 snprintf(extra, WE_MAX_STR_LEN,
10195 "11AX_HE_20");
10196 else if (hddctx->config->vhtChannelWidth ==
10197 eHT_CHANNEL_WIDTH_40MHZ)
10198 snprintf(extra, WE_MAX_STR_LEN,
10199 "11AX_HE_40");
10200 else if (hddctx->config->vhtChannelWidth ==
10201 eHT_CHANNEL_WIDTH_80MHZ)
10202 snprintf(extra, WE_MAX_STR_LEN,
10203 "11AX_HE_80");
10204 else if (hddctx->config->vhtChannelWidth ==
10205 eHT_CHANNEL_WIDTH_160MHZ)
10206 snprintf(extra, WE_MAX_STR_LEN,
10207 "11AX_HE_160");
10208 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010209 }
10210
10211 wrqu->data.length = strlen(extra) + 1;
10212 break;
10213 }
10214
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010215 case WE_GET_OEM_DATA_CAP:
Naveen Rawat910726a2017-03-06 11:42:51 -080010216 return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010217 case WE_GET_SNR:
10218 {
10219 int8_t s7snr = 0;
10220 int status = 0;
10221 hdd_context_t *pHddCtx;
10222 hdd_station_ctx_t *pHddStaCtx;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010223
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010224 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10225 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010226 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010227 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010229 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10230 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
10231 eConnectionState_Associated !=
10232 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010233 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010234 pHddCtx->config->fEnableSNRMonitoring,
10235 pHddStaCtx->conn_info.connState);
10236 return -ENONET;
10237 }
10238 wlan_hdd_get_snr(pAdapter, &s7snr);
10239 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
10240 wrqu->data.length = strlen(extra) + 1;
10241 break;
10242 }
10243 default:
10244 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010245 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010246 sub_cmd);
10247 break;
10248 }
10249 }
Dustin Brownd9322482017-01-09 12:46:03 -080010250
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010251 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -080010252 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010253}
10254
10255static int iw_get_char_setnone(struct net_device *dev,
10256 struct iw_request_info *info,
10257 union iwreq_data *wrqu, char *extra)
10258{
10259 int ret;
10260
10261 cds_ssr_protect(__func__);
10262 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
10263 cds_ssr_unprotect(__func__);
10264
10265 return ret;
10266}
10267
10268/**
10269 * iw_setnone_getnone() - Generic "action" private ioctl handler
10270 * @dev: device upon which the ioctl was received
10271 * @info: ioctl request information
10272 * @wrqu: ioctl request data
10273 * @extra: ioctl extra data
10274 *
10275 * Return: 0 on success, non-zero on error
10276 */
10277static int __iw_setnone_getnone(struct net_device *dev,
10278 struct iw_request_info *info,
10279 union iwreq_data *wrqu, char *extra)
10280{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010281 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010282 hdd_context_t *hdd_ctx;
10283 int ret;
10284 int sub_cmd;
10285
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010286 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010287
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010288 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010289 ret = wlan_hdd_validate_context(hdd_ctx);
10290 if (0 != ret)
10291 return ret;
10292
Jeff Johnson441e1f72017-02-07 08:50:49 -080010293 ret = hdd_check_private_wext_control(hdd_ctx, info);
10294 if (0 != ret)
10295 return ret;
10296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010297#ifdef CONFIG_COMPAT
10298 /* this ioctl is a special case where a sub-ioctl is used and both
10299 * the number of get and set args is 0. in this specific case the
10300 * logic in iwpriv places the sub_cmd in the data.flags portion of
10301 * the iwreq. unfortunately the location of this field will be
10302 * different between 32-bit and 64-bit userspace, and the standard
10303 * compat support in the kernel does not handle this case. so we
10304 * need to explicitly handle it here.
10305 */
10306 if (is_compat_task()) {
10307 struct compat_iw_point *compat_iw_point =
10308 (struct compat_iw_point *)&wrqu->data;
10309 sub_cmd = compat_iw_point->flags;
10310 } else {
10311 sub_cmd = wrqu->data.flags;
10312 }
10313#else
10314 sub_cmd = wrqu->data.flags;
10315#endif
10316
10317 switch (sub_cmd) {
10318 case WE_GET_RECOVERY_STAT:
10319 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010320 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010321
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010322 sme_get_recovery_stats(hal);
10323 break;
10324 }
10325
Govind Singha471e5e2015-10-12 17:11:14 +053010326 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010327 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +053010328 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
10329 0, DBG_CMD);
10330 break;
10331
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010332 case WE_IBSS_GET_PEER_INFO_ALL:
10333 {
10334 hdd_wlan_get_ibss_peer_info_all(adapter);
10335 break;
10336 }
10337
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010338 case WE_SET_REASSOC_TRIGGER:
10339 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010340 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010341
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010342 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010343 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010344 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010345 uint8_t operating_ch =
10346 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010347 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010348
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010349 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010350 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010351 if (roaming_offload_enabled(hdd_ctx)) {
10352 qdf_mem_copy(bssid,
10353 &adapter->sessionCtx.station.conn_info.bssId,
10354 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -080010355 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010356 bssid, operating_ch);
10357 } else {
10358 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
10359 NULL, modProfileFields, &roamId, 1);
10360 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010361 return 0;
10362 }
10363
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010364 case WE_STOP_OBSS_SCAN:
10365 {
10366 /*
10367 * 1.OBSS Scan is mandatory while operating in 2.4GHz
10368 * 2.OBSS scan is stopped by Firmware during the disassociation
10369 * 3.OBSS stop comamnd is added for debugging purpose
10370 */
10371 tHalHandle hal;
10372
10373 hal = WLAN_HDD_GET_HAL_CTX(adapter);
10374 if (hal == NULL) {
10375 hdd_err("hal context is NULL");
10376 return -EINVAL;
10377 }
10378 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
10379 }
10380 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010381 default:
10382 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010383 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010384 break;
10385 }
10386 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010387 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010388 return ret;
10389}
10390
10391static int iw_setnone_getnone(struct net_device *dev,
10392 struct iw_request_info *info,
10393 union iwreq_data *wrqu, char *extra)
10394{
10395 int ret;
10396
10397 cds_ssr_protect(__func__);
10398 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
10399 cds_ssr_unprotect(__func__);
10400
10401 return ret;
10402}
10403
Krunal Sonia6e505b2017-01-12 12:25:18 -080010404#ifdef MPC_UT_FRAMEWORK
10405static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10406 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10407{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -080010408 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010409 case WE_POLICY_MANAGER_CLIST_CMD:
10410 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010411 hdd_debug("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010412 policy_mgr_incr_connection_count_utfw(hdd_ctx->hdd_psoc,
10413 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
10414 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010415 }
10416 break;
10417
10418 case WE_POLICY_MANAGER_DLIST_CMD:
10419 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010420 hdd_debug("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010421 policy_mgr_decr_connection_count_utfw(hdd_ctx->hdd_psoc,
10422 apps_args[0], apps_args[1]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010423 }
10424 break;
10425
10426 case WE_POLICY_MANAGER_ULIST_CMD:
10427 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010428 hdd_debug("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010429 policy_mgr_update_connection_info_utfw(hdd_ctx->hdd_psoc,
10430 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
10431 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010432 }
10433 break;
10434
10435 case WE_POLICY_MANAGER_DBS_CMD:
10436 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010437 hdd_debug("<iwpriv wlan0 pm_dbs> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -080010438 if (apps_args[0] == 0)
10439 wma_set_dbs_capability_ut(0);
10440 else
10441 wma_set_dbs_capability_ut(1);
10442
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010443 if (apps_args[1] >= PM_THROUGHPUT &&
10444 apps_args[1] <= PM_LATENCY) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010445 pr_info("setting system pref to [%d]\n", apps_args[1]);
10446 hdd_ctx->config->conc_system_pref = apps_args[1];
10447 }
10448 }
10449 break;
10450
10451 case WE_POLICY_MANAGER_PCL_CMD:
10452 {
10453 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
10454 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
10455 uint32_t pcl_len = 0, i = 0;
10456
10457 hdd_err("<iwpriv wlan0 pm_pcl> is called");
10458
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010459 policy_mgr_get_pcl(hdd_ctx->hdd_psoc, apps_args[0],
Krunal Sonia6e505b2017-01-12 12:25:18 -080010460 pcl, &pcl_len,
10461 weight_list, QDF_ARRAY_SIZE(weight_list));
10462 pr_info("PCL list for role[%d] is {", apps_args[0]);
10463 for (i = 0 ; i < pcl_len; i++)
10464 pr_info(" %d, ", pcl[i]);
10465 pr_info("}--------->\n");
10466 }
10467 break;
10468
10469 case WE_POLICY_SET_HW_MODE_CMD:
10470 {
10471 if (apps_args[0] == 0) {
10472 hdd_err("set hw mode for single mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010473 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010474 adapter->sessionId,
10475 HW_MODE_SS_2x2,
10476 HW_MODE_80_MHZ,
10477 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
10478 HW_MODE_DBS_NONE,
10479 HW_MODE_AGILE_DFS_NONE,
10480 HW_MODE_SBS_NONE,
10481 SIR_UPDATE_REASON_UT);
10482 } else if (apps_args[0] == 1) {
10483 hdd_err("set hw mode for dual mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010484 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010485 adapter->sessionId,
10486 HW_MODE_SS_1x1,
10487 HW_MODE_80_MHZ,
10488 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
10489 HW_MODE_DBS,
10490 HW_MODE_AGILE_DFS_NONE,
10491 HW_MODE_SBS_NONE,
10492 SIR_UPDATE_REASON_UT);
10493 }
10494 }
10495 break;
10496
10497 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10498 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010499 enum policy_mgr_conc_next_action action;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010500
Krunal Sonia6e505b2017-01-12 12:25:18 -080010501 hdd_notice("<iwpriv wlan0 pm_query_action> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010502 action = policy_mgr_current_connections_update(
10503 hdd_ctx->hdd_psoc,
10504 adapter->sessionId, apps_args[0],
10505 SIR_UPDATE_REASON_UT);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010506 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
10507 }
10508 break;
10509
10510 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10511 {
10512 bool allow;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010513
10514 hdd_notice("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010515 allow = policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010516 apps_args[0], apps_args[1], apps_args[2]);
10517 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
10518 }
10519 break;
10520
10521 case WE_POLICY_MANAGER_SCENARIO_CMD:
10522 {
10523 clean_report(hdd_ctx);
10524 if (apps_args[0] == 1) {
10525 wlan_hdd_one_connection_scenario(hdd_ctx);
10526 } else if (apps_args[0] == 2) {
10527 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010528 6, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010529 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010530 36, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010531 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010532 6, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010533 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010534 36, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010535 } else if (apps_args[0] == 3) {
10536 /* MCC on same band with 2x2 same mac*/
10537 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010538 6, 11, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010539 /* MCC on diff band with 2x2 same mac*/
10540 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010541 6, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010542 /* MCC on diff band with 1x1 diff mac */
10543 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010544 36, 6, POLICY_MGR_ONE_ONE, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010545 /* MCC on diff band with 1x1 same mac */
10546 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010547 36, 6, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010548 /* SCC on same band with 2x2 same mac */
10549 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010550 36, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010551 /* SCC on same band with 1x1 same mac */
10552 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010553 36, 36, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010554 /* MCC on same band with 2x2 same mac */
10555 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010556 36, 149, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010557 /* MCC on same band with 1x1 same mac */
10558 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010559 36, 149, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010560 }
10561 print_report(hdd_ctx);
10562 }
10563 break;
10564 }
10565 return 0;
10566}
10567#else
10568static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10569 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10570{
10571 return 0;
10572}
10573#endif
10574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010575/**
10576 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10577 * @dev: device upon which the ioctl was received
10578 * @info: ioctl request information
10579 * @wrqu: ioctl request data
10580 * @extra: ioctl extra data
10581 *
10582 * This is an SSR-protected generic handler for private ioctls which
10583 * take multiple arguments. Note that this implementation is also
10584 * somewhat unique in that it is shared by both STA-mode and SAP-mode
10585 * interfaces.
10586 *
10587 * Return: 0 on success, non-zero on error
10588 */
10589static int __iw_set_var_ints_getnone(struct net_device *dev,
10590 struct iw_request_info *info,
10591 union iwreq_data *wrqu, char *extra)
10592{
10593 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10594 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10595 int sub_cmd;
10596 int *apps_args = (int *) extra;
10597 hdd_context_t *hdd_ctx;
10598 int ret, num_args;
10599
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010600 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010602 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10603 ret = wlan_hdd_validate_context(hdd_ctx);
10604 if (0 != ret)
10605 return ret;
10606
Jeff Johnson441e1f72017-02-07 08:50:49 -080010607 ret = hdd_check_private_wext_control(hdd_ctx, info);
10608 if (0 != ret)
10609 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010610
10611 sub_cmd = wrqu->data.flags;
10612 num_args = wrqu->data.length;
10613
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010614 hdd_debug("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010615
10616 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010617 case WE_IBSS_GET_PEER_INFO:
10618 {
10619 pr_info("Station ID = %d\n", apps_args[0]);
10620 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
10621 }
10622 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010623
10624 case WE_P2P_NOA_CMD:
10625 {
Srinivas Girigowda5d5fdc52017-03-24 22:30:57 -070010626 struct p2p_app_set_ps p2pNoA;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010627
Krunal Sonif07bb382016-03-10 13:02:11 -080010628 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -080010629 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
10630 hdd_device_mode_to_string(
10631 pAdapter->device_mode),
10632 pAdapter->device_mode);
10633 return -EINVAL;
10634 }
10635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010636 p2pNoA.opp_ps = apps_args[0];
10637 p2pNoA.ctWindow = apps_args[1];
10638 p2pNoA.duration = apps_args[2];
10639 p2pNoA.interval = apps_args[3];
10640 p2pNoA.count = apps_args[4];
10641 p2pNoA.single_noa_duration = apps_args[5];
10642 p2pNoA.psSelection = apps_args[6];
10643
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010644 hdd_debug("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
Jeff Johnson99bac312016-06-28 10:38:18 -070010645 apps_args[0], apps_args[1], apps_args[2],
10646 apps_args[3], apps_args[4],
10647 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010648
10649 hdd_set_p2p_ps(dev, &p2pNoA);
10650
10651 }
10652 break;
10653
10654 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
10655 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010656 hdd_debug("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
Jeff Johnson99bac312016-06-28 10:38:18 -070010657 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010658 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010659 }
10660 break;
10661
10662 case WE_MTRACE_DUMP_CMD:
10663 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010664 hdd_debug("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
Jeff Johnson99bac312016-06-28 10:38:18 -070010665 apps_args[0], apps_args[1],
10666 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010667 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010668 apps_args[1], apps_args[2],
10669 apps_args[3]);
10670
10671 }
10672 break;
10673
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010674 case WE_POLICY_MANAGER_CINFO_CMD:
10675 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010676 struct policy_mgr_conc_connection_info *conn_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010677 uint32_t i = 0, len = 0;
10678
Krunal Sonia6e505b2017-01-12 12:25:18 -080010679 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010680 conn_info = policy_mgr_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010681 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010682 for (i = 0; i < len; i++) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010683 pr_info("|table_index[%d]\t\t\n", i);
10684 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
10685 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
10686 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
10687 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
10688 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
10689 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
10690 pr_info("+--------------------------+\n");
10691 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010692 }
10693 }
10694 break;
10695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010696
10697#ifdef FEATURE_WLAN_TDLS
10698 case WE_TDLS_CONFIG_PARAMS:
10699 {
10700 tdls_config_params_t tdlsParams;
10701
10702 tdlsParams.tdls = apps_args[0];
10703 tdlsParams.tx_period_t = apps_args[1];
10704 tdlsParams.tx_packet_n = apps_args[2];
10705 /* ignore args[3] as discovery_period is not used anymore */
10706 tdlsParams.discovery_tries_n = apps_args[4];
10707 /* ignore args[5] as idle_timeout is not used anymore */
10708 tdlsParams.idle_packet_n = apps_args[6];
10709 /* ignore args[7] as rssi_hysteresis is not used anymore */
10710 tdlsParams.rssi_trigger_threshold = apps_args[8];
10711 tdlsParams.rssi_teardown_threshold = apps_args[9];
10712 tdlsParams.rssi_delta = apps_args[10];
10713
10714 wlan_hdd_tdls_set_params(dev, &tdlsParams);
10715 }
10716 break;
10717#endif
10718 case WE_UNIT_TEST_CMD:
10719 {
10720 t_wma_unit_test_cmd *unitTestArgs;
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010721 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010722 int i, j;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010724 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
10725 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010726 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010727 apps_args[0]);
10728 return -EINVAL;
10729 }
Anurag Chouhan77564182016-09-03 16:38:01 +053010730 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
10731 (apps_args[1] < 0)) {
10732 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010733 apps_args[1]);
10734 return -EINVAL;
10735 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010736 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010737 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010738 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010739 return -ENOMEM;
10740 }
10741 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
10742 unitTestArgs->module_id = apps_args[0];
10743 unitTestArgs->num_args = apps_args[1];
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010744 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010745 unitTestArgs->args[i] = apps_args[j];
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010746
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010747 msg.type = SIR_HAL_UNIT_TEST_CMD;
10748 msg.reserved = 0;
10749 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010750 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010751 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010752 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -070010753 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010754 return -EINVAL;
10755 }
10756 }
10757 break;
10758#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
10759 case WE_LED_FLASHING_PARAM:
10760 {
10761 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010762
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010763 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010764 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010765 return -EINVAL;
10766 }
10767 for (i = 0; i < num_args; i++) {
10768 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010769 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010770 return -EINVAL;
10771 }
10772 }
10773 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10774 0, apps_args[0], apps_args[1]);
10775 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10776 1, apps_args[2], apps_args[3]);
10777 }
10778 break;
10779#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010780 case WE_SET_PKTLOG:
10781 {
10782 int ret;
10783
10784 if (num_args < 1 || num_args > 2) {
10785 hdd_err("pktlog: either 1 or 2 parameters are required");
10786 return -EINVAL;
10787 }
10788
10789 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
10790 apps_args[1]);
10791 if (ret)
10792 return ret;
10793 break;
10794 }
10795
Manjeet Singhf82ed072016-07-08 11:40:00 +053010796 case WE_MAC_PWR_DEBUG_CMD:
10797 {
10798 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
10799 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10800 int i, j;
10801
10802 if (num_args < 3) {
10803 hdd_err("number of arguments can't be null %d",
10804 num_args);
10805 return -EINVAL;
10806 }
10807 if (num_args - 3 != apps_args[2]) {
10808 hdd_err("arg list of size %d doesn't match num_args %d",
10809 num_args-3, apps_args[2]);
10810 return -EINVAL;
10811 }
10812 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
10813 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
10814 hdd_err("Invalid MODULE ID %d", apps_args[1]);
10815 return -EINVAL;
10816 }
10817 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
10818 hdd_err("Too Many args %d", apps_args[2]);
10819 return -EINVAL;
10820 }
10821 mac_pwr_dbg_args.pdev_id = apps_args[0];
10822 mac_pwr_dbg_args.module_id = apps_args[1];
10823 mac_pwr_dbg_args.num_args = apps_args[2];
10824
10825 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
10826 mac_pwr_dbg_args.args[i] = apps_args[j];
10827
10828 if (QDF_STATUS_SUCCESS !=
10829 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
10830 &mac_pwr_dbg_args)) {
10831 return -EINVAL;
10832 }
10833 }
10834 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -080010835 case WE_POLICY_MANAGER_CLIST_CMD:
10836 case WE_POLICY_MANAGER_DLIST_CMD:
10837 case WE_POLICY_MANAGER_ULIST_CMD:
10838 case WE_POLICY_MANAGER_DBS_CMD:
10839 case WE_POLICY_MANAGER_PCL_CMD:
10840 case WE_POLICY_SET_HW_MODE_CMD:
10841 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10842 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10843 case WE_POLICY_MANAGER_SCENARIO_CMD:
10844 {
10845 iw_get_policy_manager_ut_ops(hdd_ctx, pAdapter,
10846 sub_cmd, apps_args);
10847 }
10848 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010849 default:
10850 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010851 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010852 }
10853 break;
10854 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010855 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010856 return 0;
10857}
10858
10859/**
10860 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
10861 * @dev: pointer to net_device structure
10862 * @info: pointer to iw_request_info structure
10863 * @wrqu: pointer to iwreq_data
10864 * @extra; extra
10865 *
10866 * Return: 0 on success, error number otherwise
10867 *
10868 */
10869static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
10870 struct iw_request_info *info,
10871 union iwreq_data *wrqu, char *extra)
10872{
10873 union iwreq_data u_priv_wrqu;
10874 int apps_args[MAX_VAR_ARGS] = {0};
10875 int ret, num_args;
10876
Mukul Sharma64a70e82015-11-02 20:05:09 +053010877 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010878 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +053010879 return -EPERM;
10880 }
10881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010882 /* Helper function to get iwreq_data with compat handling. */
10883 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
10884 return -EINVAL;
10885
10886 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010887 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010888 return -EINVAL;
10889 }
10890
10891 num_args = u_priv_wrqu.data.length;
10892 if (num_args > MAX_VAR_ARGS)
10893 num_args = MAX_VAR_ARGS;
10894
10895 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
10896 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010897 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010898 return -EFAULT;
10899 }
10900
10901 cds_ssr_protect(__func__);
10902 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
10903 (char *)&apps_args);
10904 cds_ssr_unprotect(__func__);
10905 return ret;
10906}
10907
10908/**
10909 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10910 * @dev: device upon which the ioctl was received
10911 * @info: ioctl request information
10912 * @wrqu: ioctl request data
10913 * @extra: ioctl extra data
10914 *
10915 * This is a generic handler for private ioctls which take multiple
10916 * arguments. Note that this implementation is also somewhat unique
10917 * in that it is shared by both STA-mode and SAP-mode interfaces.
10918 *
10919 * Return: 0 on success, non-zero on error
10920 */
10921int iw_set_var_ints_getnone(struct net_device *dev,
10922 struct iw_request_info *info,
10923 union iwreq_data *wrqu, char *extra)
10924{
10925 int ret;
10926
10927 cds_ssr_protect(__func__);
10928 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
10929 cds_ssr_unprotect(__func__);
10930 return ret;
10931}
10932
10933/**
10934 * iw_add_tspec - Add TSpec private ioctl handler
10935 * @dev: device upon which the ioctl was received
10936 * @info: ioctl request information
10937 * @wrqu: ioctl request data
10938 * @extra: ioctl extra data
10939 *
10940 * Return: 0 on success, non-zero on error
10941 */
10942static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
10943 union iwreq_data *wrqu, char *extra)
10944{
10945 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10946 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10947 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
10948 int params[HDD_WLAN_WMM_PARAM_COUNT];
10949 sme_QosWmmTspecInfo tSpec;
10950 uint32_t handle;
10951 struct iw_point s_priv_data;
10952 hdd_context_t *hdd_ctx;
10953 int ret;
10954
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010955 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010957 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10958 ret = wlan_hdd_validate_context(hdd_ctx);
10959 if (0 != ret)
10960 return ret;
10961
Jeff Johnson441e1f72017-02-07 08:50:49 -080010962 ret = hdd_check_private_wext_control(hdd_ctx, info);
10963 if (0 != ret)
10964 return ret;
10965
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010966 /* make sure the application is sufficiently priviledged */
10967 /* note that the kernel will do this for "set" ioctls, but since */
10968 /* this ioctl wants to return status to user space it must be */
10969 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010970 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010971 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010972
10973 /* we must be associated in order to add a tspec */
10974 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
10975 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10976 return 0;
10977 }
10978 /* since we are defined to be a "get" ioctl, and since the number */
10979 /* of params exceeds the number of params that wireless extensions */
10980 /* will pass down in the iwreq_data, we must copy the "set" params. */
10981 /* We must handle the compat for iwreq_data in 32U/64K environment. */
10982
10983 /* helper function to get iwreq_data with compat handling. */
10984 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
10985 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10986 return 0;
10987 }
10988 /* make sure all params are correctly passed to function */
10989 if ((NULL == s_priv_data.pointer) ||
10990 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
10991 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10992 return 0;
10993 }
10994 /* from user space ourselves */
10995 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
10996 /* hmmm, can't get them */
10997 return -EIO;
10998 }
10999 /* clear the tspec */
11000 memset(&tSpec, 0, sizeof(tSpec));
11001
11002 /* validate the handle */
11003 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11004 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11005 /* that one is reserved */
11006 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11007 return 0;
11008 }
11009 /* validate the TID */
11010 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
11011 /* out of range */
11012 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11013 return 0;
11014 }
11015 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
11016
11017 /* validate the direction */
11018 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
11019 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
11020 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
11021 break;
11022
11023 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
11024 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
11025 break;
11026
11027 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
11028 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
11029 break;
11030
11031 default:
11032 /* unknown */
11033 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11034 return 0;
11035 }
11036
11037 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
11038
11039 /* validate the user priority */
11040 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
11041 /* out of range */
11042 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11043 return 0;
11044 }
11045 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
11046 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011047 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011048 return 0;
11049 }
11050
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011051 hdd_debug("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011052 tSpec.ts_info.psb, tSpec.ts_info.up);
11053
11054 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
11055 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
11056 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
11057 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
11058 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
11059 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
11060 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
11061 tSpec.surplus_bw_allowance =
11062 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
11063 tSpec.min_service_interval =
11064 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
11065 tSpec.max_service_interval =
11066 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
11067 tSpec.suspension_interval =
11068 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
11069 tSpec.inactivity_interval =
11070 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
11071
11072 tSpec.ts_info.burst_size_defn =
11073 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
11074
11075 /* validate the ts info ack policy */
11076 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
11077 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
11078 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
11079 break;
11080
11081 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
11082 tSpec.ts_info.ack_policy =
11083 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
11084 break;
11085
11086 default:
11087 /* unknown */
11088 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11089 return 0;
11090 }
11091
11092 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011093 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011094 return 0;
11095}
11096
11097static int iw_add_tspec(struct net_device *dev,
11098 struct iw_request_info *info,
11099 union iwreq_data *wrqu, char *extra)
11100{
11101 int ret;
11102
11103 cds_ssr_protect(__func__);
11104 ret = __iw_add_tspec(dev, info, wrqu, extra);
11105 cds_ssr_unprotect(__func__);
11106
11107 return ret;
11108}
11109
11110/**
11111 * iw_del_tspec - Delete TSpec private ioctl handler
11112 * @dev: device upon which the ioctl was received
11113 * @info: ioctl request information
11114 * @wrqu: ioctl request data
11115 * @extra: ioctl extra data
11116 *
11117 * Return: 0 on success, non-zero on error
11118 */
11119static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
11120 union iwreq_data *wrqu, char *extra)
11121{
11122 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11123 hdd_context_t *hdd_ctx;
11124 int *params = (int *)extra;
11125 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11126 uint32_t handle;
11127 int ret;
11128
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011129 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011131 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11132 ret = wlan_hdd_validate_context(hdd_ctx);
11133 if (0 != ret)
11134 return ret;
11135
Jeff Johnson441e1f72017-02-07 08:50:49 -080011136 ret = hdd_check_private_wext_control(hdd_ctx, info);
11137 if (0 != ret)
11138 return ret;
11139
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011140 /* make sure the application is sufficiently priviledged */
11141 /* note that the kernel will do this for "set" ioctls, but since */
11142 /* this ioctl wants to return status to user space it must be */
11143 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011144 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011145 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011146
11147 /* although we are defined to be a "get" ioctl, the params we require */
11148 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11149 /* is no need to copy the params from user space */
11150
11151 /* validate the handle */
11152 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11153 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11154 /* that one is reserved */
11155 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11156 return 0;
11157 }
11158
11159 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011160 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011161 return 0;
11162}
11163
11164static int iw_del_tspec(struct net_device *dev,
11165 struct iw_request_info *info,
11166 union iwreq_data *wrqu, char *extra)
11167{
11168 int ret;
11169
11170 cds_ssr_protect(__func__);
11171 ret = __iw_del_tspec(dev, info, wrqu, extra);
11172 cds_ssr_unprotect(__func__);
11173
11174 return ret;
11175}
11176
11177/**
11178 * iw_get_tspec - Get TSpec private ioctl handler
11179 * @dev: device upon which the ioctl was received
11180 * @info: ioctl request information
11181 * @wrqu: ioctl request data
11182 * @extra: ioctl extra data
11183 *
11184 * Return: 0 on success, non-zero on error
11185 */
11186static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
11187 union iwreq_data *wrqu, char *extra)
11188{
11189 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11190 hdd_context_t *hdd_ctx;
11191 int *params = (int *)extra;
11192 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11193 uint32_t handle;
11194 int ret;
11195
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011196 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011197
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011198 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11199 ret = wlan_hdd_validate_context(hdd_ctx);
11200 if (0 != ret)
11201 return ret;
11202
Jeff Johnson441e1f72017-02-07 08:50:49 -080011203 ret = hdd_check_private_wext_control(hdd_ctx, info);
11204 if (0 != ret)
11205 return ret;
11206
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011207 /* although we are defined to be a "get" ioctl, the params we require */
11208 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11209 /* is no need to copy the params from user space */
11210
11211 /* validate the handle */
11212 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11213 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11214 /* that one is reserved */
11215 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11216 return 0;
11217 }
11218
11219 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011220 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011221 return 0;
11222}
11223
11224static int iw_get_tspec(struct net_device *dev,
11225 struct iw_request_info *info,
11226 union iwreq_data *wrqu, char *extra)
11227{
11228 int ret;
11229
11230 cds_ssr_protect(__func__);
11231 ret = __iw_get_tspec(dev, info, wrqu, extra);
11232 cds_ssr_unprotect(__func__);
11233
11234 return ret;
11235}
11236
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011237/**
11238 * iw_set_fties - Set FT IEs private ioctl handler
11239 * @dev: device upon which the ioctl was received
11240 * @info: ioctl request information
11241 * @wrqu: ioctl request data
11242 * @extra: ioctl extra data
11243 *
11244 * Each time the supplicant has the auth_request or reassoc request
11245 * IEs ready they are pushed to the driver. The driver will in turn
11246 * use it to send out the auth req and reassoc req for 11r FT Assoc.
11247 *
11248 * Return: 0 on success, non-zero on error
11249 */
11250static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
11251 union iwreq_data *wrqu, char *extra)
11252{
11253 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11254 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11255 hdd_context_t *hdd_ctx;
11256 int ret;
11257
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011258 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011260 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11261 ret = wlan_hdd_validate_context(hdd_ctx);
11262 if (0 != ret)
11263 return ret;
11264
Jeff Johnson441e1f72017-02-07 08:50:49 -080011265 ret = hdd_check_private_wext_control(hdd_ctx, info);
11266 if (0 != ret)
11267 return ret;
11268
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011269 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011270 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011271 return -EINVAL;
11272 }
11273 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011274 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011275 return -EINVAL;
11276 }
11277 /* Added for debug on reception of Re-assoc Req. */
11278 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011279 hdd_debug("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011280 wrqu->data.length);
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011281 hdd_debug("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011282 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011283 hdd_debug("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011284
11285 /* Pass the received FT IEs to SME */
11286 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
11287 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011288 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011289 return 0;
11290}
11291
11292static int iw_set_fties(struct net_device *dev,
11293 struct iw_request_info *info,
11294 union iwreq_data *wrqu, char *extra)
11295{
11296 int ret;
11297
11298 cds_ssr_protect(__func__);
11299 ret = __iw_set_fties(dev, info, wrqu, extra);
11300 cds_ssr_unprotect(__func__);
11301
11302 return ret;
11303}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011304
Dustin Brown0cbc7572016-12-16 13:54:40 -080011305/**
11306 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
11307 * @dev: device upon which the ioctl was received
11308 * @info: ioctl request information
11309 * @wrqu: ioctl request data
11310 * @extra: ioctl extra data
11311 *
Dustin Brown860566f2017-01-31 15:24:43 -080011312 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
11313 * time being to provide guidance in migrating to standard APIs.
11314 *
Dustin Brown0cbc7572016-12-16 13:54:40 -080011315 * Return: 0 on success, non-zero on error
11316 */
11317static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
11318 struct iw_request_info *info,
11319 union iwreq_data *wrqu,
11320 char *extra)
11321{
Dustin Brown860566f2017-01-31 15:24:43 -080011322 hdd_err("\n"
11323 "setMCBCFilter is obsolete. Use the following instead:\n"
11324 "Configure multicast filtering via the ‘ip’ command.\n"
11325 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
11326 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
11327 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
11328 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
11329 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Mukul Sharma3ba26b82017-01-12 21:59:41 +053011330 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -080011331}
11332
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011333/**
11334 * iw_set_host_offload - Set host offload ioctl handler
11335 * @dev: device upon which the ioctl was received
11336 * @info: ioctl request information
11337 * @wrqu: ioctl request data
11338 * @extra: ioctl extra data
11339 *
11340 * Return: 0 on success, non-zero on error
11341 */
11342static int __iw_set_host_offload(struct net_device *dev,
11343 struct iw_request_info *info,
11344 union iwreq_data *wrqu, char *extra)
11345{
11346 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowda077143e2017-03-25 10:47:27 -070011347 struct host_offload_req *pRequest = (struct host_offload_req *) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011348 tSirHostOffloadReq offloadRequest;
11349 hdd_context_t *hdd_ctx;
11350 int ret;
11351
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011352 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011353
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011354 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11355 ret = wlan_hdd_validate_context(hdd_ctx);
11356 if (0 != ret)
11357 return ret;
11358
Jeff Johnson441e1f72017-02-07 08:50:49 -080011359 ret = hdd_check_private_wext_control(hdd_ctx, info);
11360 if (0 != ret)
11361 return ret;
11362
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011363 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011364 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011365 return -EINVAL;
11366 }
11367
11368 /* Debug display of request components. */
11369 switch (pRequest->offloadType) {
11370 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011371 hdd_debug("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011372 switch (pRequest->enableOrDisable) {
11373 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011374 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011375 break;
11376 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011377 hdd_debug(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011378 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011379 hdd_debug(" ARP offload enable");
11380 hdd_debug(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011381 pRequest->params.hostIpv4Addr[0],
11382 pRequest->params.hostIpv4Addr[1],
11383 pRequest->params.hostIpv4Addr[2],
11384 pRequest->params.hostIpv4Addr[3]);
11385 }
11386 break;
11387
11388 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011389 hdd_debug("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011390 switch (pRequest->enableOrDisable) {
11391 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011392 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011393 break;
11394 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011395 hdd_debug(" enable");
11396 hdd_debug(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011397 *(uint16_t *) (pRequest->params.hostIpv6Addr),
11398 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11399 2),
11400 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11401 4),
11402 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11403 6),
11404 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11405 8),
11406 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11407 10),
11408 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11409 12),
11410 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11411 14));
11412 }
11413 }
11414
11415 /* Execute offload request. The reason that we can copy the
11416 * request information from the ioctl structure to the SME
11417 * structure is that they are laid out exactly the same.
11418 * Otherwise, each piece of information would have to be
11419 * copied individually.
11420 */
11421 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011422 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011423 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
11424 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011425 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011426 return -EINVAL;
11427 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011428 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011429 return 0;
11430}
11431
11432static int iw_set_host_offload(struct net_device *dev,
11433 struct iw_request_info *info,
11434 union iwreq_data *wrqu, char *extra)
11435{
11436 int ret;
11437
11438 cds_ssr_protect(__func__);
11439 ret = __iw_set_host_offload(dev, info, wrqu, extra);
11440 cds_ssr_unprotect(__func__);
11441
11442 return ret;
11443}
11444
11445/**
11446 * iw_set_keepalive_params - Set keepalive params ioctl handler
11447 * @dev: device upon which the ioctl was received
11448 * @info: ioctl request information
11449 * @wrqu: ioctl request data
11450 * @extra: ioctl extra data
11451 *
11452 * Return: 0 on success, non-zero on error
11453 */
11454static int __iw_set_keepalive_params(struct net_device *dev,
11455 struct iw_request_info *info,
11456 union iwreq_data *wrqu, char *extra)
11457{
11458 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011459 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011460 hdd_context_t *hdd_ctx;
11461 int ret;
11462
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011463 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011465 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11466 ret = wlan_hdd_validate_context(hdd_ctx);
11467 if (0 != ret)
11468 return ret;
11469
Jeff Johnson441e1f72017-02-07 08:50:49 -080011470 ret = hdd_check_private_wext_control(hdd_ctx, info);
11471 if (0 != ret)
11472 return ret;
11473
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011474 if (wrqu->data.length != sizeof(*request)) {
11475 hdd_err("Invalid length %d", wrqu->data.length);
11476 return -EINVAL;
11477 }
11478
11479 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
11480 hdd_err("Value of timePeriod %d exceed Max limit %d",
11481 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011482 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
11483 return -EINVAL;
11484 }
11485
11486 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011487 hdd_debug("Set Keep Alive Request : TimePeriod %d size %zu",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011488 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011489
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011490 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011491 case WLAN_KEEP_ALIVE_NULL_PKT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011492 hdd_debug("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011493 break;
11494
11495 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011496 hdd_debug("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011497
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011498 hdd_debug("Host IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011499 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
11500 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011501
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011502 hdd_debug("Dest IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011503 request->destIpv4Addr[0], request->destIpv4Addr[1],
11504 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011505
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011506 hdd_debug("Dest MAC address: "MAC_ADDRESS_STR,
Srinivas Girigowda9c330a92015-11-24 12:28:25 -080011507 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011508 break;
11509 }
11510
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011511 hdd_debug("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011512
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011513 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011514 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011515 pAdapter->sessionId, request)) {
11516 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011517 return -EINVAL;
11518 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011519 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011520 return 0;
11521}
11522
11523static int iw_set_keepalive_params(struct net_device *dev,
11524 struct iw_request_info *info,
11525 union iwreq_data *wrqu,
11526 char *extra)
11527{
11528 int ret;
11529
11530 cds_ssr_protect(__func__);
11531 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
11532 cds_ssr_unprotect(__func__);
11533
11534 return ret;
11535}
11536
11537#ifdef WLAN_FEATURE_PACKET_FILTERING
11538/**
11539 * wlan_hdd_set_filter() - Set packet filter
11540 * @hdd_ctx: Global HDD context
11541 * @request: Packet filter request struct
11542 * @sessionId: Target session for the request
11543 *
11544 * Return: 0 on success, non-zero on error
11545 */
11546static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
11547 struct pkt_filter_cfg *request,
11548 uint8_t sessionId)
11549{
11550 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
11551 tSirRcvFltPktClearParam packetFilterClrReq = {0};
11552 int i = 0;
11553
11554 if (hdd_ctx->config->disablePacketFilter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011555 hdd_warn("Packet filtering disabled in ini");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011556 return 0;
11557 }
11558
11559 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011560 hdd_debug("Packet Filter Request : FA %d params %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011561 request->filter_action, request->num_params);
11562
11563 switch (request->filter_action) {
11564 case HDD_RCV_FILTER_SET:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011565 hdd_debug("Set Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011566 request->filter_id);
11567
11568 packetFilterSetReq.filterId = request->filter_id;
11569 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
11570 hdd_err("Number of Params exceed Max limit %d",
11571 request->num_params);
11572 return -EINVAL;
11573 }
11574 packetFilterSetReq.numFieldParams = request->num_params;
11575 packetFilterSetReq.coalesceTime = 0;
11576 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
11577 for (i = 0; i < request->num_params; i++) {
11578 packetFilterSetReq.paramsData[i].protocolLayer =
11579 request->params_data[i].protocol_layer;
11580 packetFilterSetReq.paramsData[i].cmpFlag =
11581 request->params_data[i].compare_flag;
11582 packetFilterSetReq.paramsData[i].dataOffset =
11583 request->params_data[i].data_offset;
11584 packetFilterSetReq.paramsData[i].dataLength =
11585 request->params_data[i].data_length;
11586 packetFilterSetReq.paramsData[i].reserved = 0;
11587
Dustin Brown4d1e8462016-12-14 12:12:24 -080011588 if (request->params_data[i].data_offset >
11589 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
11590 hdd_err("Invalid data offset %u for param %d (max = %d)",
11591 request->params_data[i].data_offset,
11592 i,
11593 SIR_MAX_FILTER_TEST_DATA_OFFSET);
11594 return -EINVAL;
11595 }
11596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011597 if (request->params_data[i].data_length >
11598 SIR_MAX_FILTER_TEST_DATA_LEN) {
11599 hdd_err("Error invalid data length %d",
11600 request->params_data[i].data_length);
11601 return -EINVAL;
11602 }
11603
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011604 hdd_debug("Proto %d Comp Flag %d Filter Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011605 request->params_data[i].protocol_layer,
11606 request->params_data[i].compare_flag,
11607 packetFilterSetReq.filterType);
11608
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011609 hdd_debug("Data Offset %d Data Len %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011610 request->params_data[i].data_offset,
11611 request->params_data[i].data_length);
11612
Rajeev Kumarf5b6da22016-04-15 13:24:03 -070011613 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
11614 < (request->params_data[i].data_length)) {
11615 hdd_err("Error invalid data length %d",
11616 request->params_data[i].data_length);
11617 return -EINVAL;
11618 }
11619
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011620 memcpy(&packetFilterSetReq.paramsData[i].compareData,
11621 request->params_data[i].compare_data,
11622 request->params_data[i].data_length);
11623 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
11624 request->params_data[i].data_mask,
11625 request->params_data[i].data_length);
11626
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011627 hdd_debug("CData %d CData %d CData %d CData %d CData %d CData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011628 request->params_data[i].compare_data[0],
11629 request->params_data[i].compare_data[1],
11630 request->params_data[i].compare_data[2],
11631 request->params_data[i].compare_data[3],
11632 request->params_data[i].compare_data[4],
11633 request->params_data[i].compare_data[5]);
11634
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011635 hdd_debug("MData %d MData %d MData %d MData %d MData %d MData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011636 request->params_data[i].data_mask[0],
11637 request->params_data[i].data_mask[1],
11638 request->params_data[i].data_mask[2],
11639 request->params_data[i].data_mask[3],
11640 request->params_data[i].data_mask[4],
11641 request->params_data[i].data_mask[5]);
11642 }
11643
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011644 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011645 sme_receive_filter_set_filter(hdd_ctx->hHal,
11646 &packetFilterSetReq,
11647 sessionId)) {
11648 hdd_err("Failure to execute Set Filter");
11649 return -EINVAL;
11650 }
11651
11652 break;
11653
11654 case HDD_RCV_FILTER_CLEAR:
11655
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011656 hdd_debug("Clear Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011657 request->filter_id);
11658 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011659 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011660 sme_receive_filter_clear_filter(hdd_ctx->hHal,
11661 &packetFilterClrReq,
11662 sessionId)) {
11663 hdd_err("Failure to execute Clear Filter");
11664 return -EINVAL;
11665 }
11666 break;
11667
11668 default:
11669 hdd_err("Packet Filter Request: Invalid %d",
11670 request->filter_action);
11671 return -EINVAL;
11672 }
11673 return 0;
11674}
11675
11676/**
11677 * __iw_set_packet_filter_params() - set packet filter parameters in target
11678 * @dev: Pointer to netdev
11679 * @info: Pointer to iw request info
11680 * @wrqu: Pointer to data
11681 * @extra: Pointer to extra data
11682 *
11683 * Return: 0 on success, non-zero on error
11684 */
11685static int __iw_set_packet_filter_params(struct net_device *dev,
11686 struct iw_request_info *info,
11687 union iwreq_data *wrqu, char *extra)
11688{
11689 int ret;
11690 hdd_context_t *hdd_ctx;
11691 struct iw_point priv_data;
11692 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
11693 struct pkt_filter_cfg *request = NULL;
11694
Mukul Sharma472382f2015-11-02 20:16:31 +053011695 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011696 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +053011697 return -EPERM;
11698 }
11699
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011700 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011702 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11703 ret = wlan_hdd_validate_context(hdd_ctx);
11704 if (0 != ret)
11705 return ret;
11706
Jeff Johnson441e1f72017-02-07 08:50:49 -080011707 ret = hdd_check_private_wext_control(hdd_ctx, info);
11708 if (0 != ret)
11709 return ret;
11710
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011711 if (hdd_priv_get_data(&priv_data, wrqu)) {
11712 hdd_err("failed to get priv data");
11713 return -EINVAL;
11714 }
11715
11716 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
11717 hdd_err("invalid priv data %p or invalid priv data length %d",
11718 priv_data.pointer, priv_data.length);
11719 return -EINVAL;
11720 }
11721
11722 /* copy data using copy_from_user */
11723 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
11724 priv_data.length);
11725 if (NULL == request) {
11726 hdd_err("mem_alloc_copy_from_user_helper fail");
11727 return -ENOMEM;
11728 }
11729
11730 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
11731
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -070011732 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011733 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011734 return ret;
11735}
11736
11737/**
11738 * iw_set_packet_filter_params() - set packet filter parameters in target
11739 * @dev: Pointer to netdev
11740 * @info: Pointer to iw request info
11741 * @wrqu: Pointer to data
11742 * @extra: Pointer to extra data
11743 *
11744 * Return: 0 on success, non-zero on error
11745 */
11746static int iw_set_packet_filter_params(struct net_device *dev,
11747 struct iw_request_info *info,
11748 union iwreq_data *wrqu, char *extra)
11749{
11750 int ret;
11751
11752 cds_ssr_protect(__func__);
11753 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
11754 cds_ssr_unprotect(__func__);
11755
11756 return ret;
11757}
11758#endif
11759
11760
11761static int __iw_get_statistics(struct net_device *dev,
11762 struct iw_request_info *info,
11763 union iwreq_data *wrqu, char *extra)
11764{
11765
Anurag Chouhance0dc992016-02-16 18:18:03 +053011766 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011767 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011768 hdd_wext_state_t *pWextState;
11769 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11770 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11771 char *p = extra;
11772 int tlen = 0;
11773 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
11774 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
11775 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
11776 int ret;
11777
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011778 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011779
11780 ret = wlan_hdd_validate_context(hdd_ctx);
11781 if (0 != ret)
11782 return ret;
11783
Jeff Johnson441e1f72017-02-07 08:50:49 -080011784 ret = hdd_check_private_wext_control(hdd_ctx, info);
11785 if (0 != ret)
11786 return ret;
11787
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011788 if (eConnectionState_Associated !=
11789 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
11790
11791 wrqu->txpower.value = 0;
11792 } else {
11793 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11794 SME_SUMMARY_STATS |
11795 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080011796 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011797 hdd_statistics_cb, 0, false,
11798 (WLAN_HDD_GET_STATION_CTX_PTR
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011799 (pAdapter))->conn_info.staId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011800 pAdapter, pAdapter->sessionId);
11801
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011802 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011803 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011804 return -EINVAL;
11805 }
11806
11807 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11808
Anurag Chouhance0dc992016-02-16 18:18:03 +053011809 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011810 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011811 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011812 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011813 hdd_err("SME timeout while retrieving statistics");
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011814 /* Remove the SME statistics list by
11815 * passing NULL in callback argument
11816 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011817 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11818 SME_SUMMARY_STATS |
11819 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080011820 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011821 NULL, 0, false,
11822 (WLAN_HDD_GET_STATION_CTX_PTR
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011823 (pAdapter))->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011824 staId[0], pAdapter,
11825 pAdapter->sessionId);
11826
11827 return -EINVAL;
11828 }
11829 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
11830 (uint8_t) sizeof(pStats->retry_cnt),
11831 (char *)&(pStats->retry_cnt[0]), tlen);
11832
11833 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
11834 (uint8_t) sizeof(pStats->multiple_retry_cnt),
11835 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
11836
11837 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
11838 (uint8_t) sizeof(pStats->tx_frm_cnt),
11839 (char *)&(pStats->tx_frm_cnt[0]), tlen);
11840
11841 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
11842 (uint8_t) sizeof(pStats->rx_frm_cnt),
11843 (char *)&(pStats->rx_frm_cnt), tlen);
11844
11845 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
11846 (uint8_t) sizeof(pStats->frm_dup_cnt),
11847 (char *)&(pStats->frm_dup_cnt), tlen);
11848
11849 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
11850 (uint8_t) sizeof(pStats->fail_cnt),
11851 (char *)&(pStats->fail_cnt[0]), tlen);
11852
11853 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
11854 (uint8_t) sizeof(pStats->rts_fail_cnt),
11855 (char *)&(pStats->rts_fail_cnt), tlen);
11856
11857 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
11858 (uint8_t) sizeof(pStats->ack_fail_cnt),
11859 (char *)&(pStats->ack_fail_cnt), tlen);
11860
11861 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
11862 (uint8_t) sizeof(pStats->rts_succ_cnt),
11863 (char *)&(pStats->rts_succ_cnt), tlen);
11864
11865 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
11866 (uint8_t) sizeof(pStats->rx_discard_cnt),
11867 (char *)&(pStats->rx_discard_cnt), tlen);
11868
11869 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
11870 (uint8_t) sizeof(pStats->rx_error_cnt),
11871 (char *)&(pStats->rx_error_cnt), tlen);
11872
11873 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
11874 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11875 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11876
11877 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
11878 (uint8_t) sizeof(dStats->rx_byte_cnt),
11879 (char *)&(dStats->rx_byte_cnt), tlen);
11880
11881 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
11882 (uint8_t) sizeof(dStats->rx_rate),
11883 (char *)&(dStats->rx_rate), tlen);
11884
11885 /* Transmit rate, in units of 500 kbit/sec */
11886 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
11887 (uint8_t) sizeof(aStats->tx_rate),
11888 (char *)&(aStats->tx_rate), tlen);
11889
11890 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
11891 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
11892 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
11893 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
11894 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
11895 (char *)&(dStats->rx_mc_byte_cnt), tlen);
11896 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
11897 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
11898 (char *)&(dStats->rx_bc_byte_cnt), tlen);
11899 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
11900 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11901 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11902 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
11903 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
11904 (char *)&(dStats->tx_mc_byte_cnt), tlen);
11905 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
11906 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
11907 (char *)&(dStats->tx_bc_byte_cnt), tlen);
11908
11909 wrqu->data.length = tlen;
11910
11911 }
11912
11913 EXIT();
11914
11915 return 0;
11916}
11917
11918static int iw_get_statistics(struct net_device *dev,
11919 struct iw_request_info *info,
11920 union iwreq_data *wrqu, char *extra)
11921{
11922 int ret;
11923
11924 cds_ssr_protect(__func__);
11925 ret = __iw_get_statistics(dev, info, wrqu, extra);
11926 cds_ssr_unprotect(__func__);
11927
11928 return ret;
11929}
11930
11931#ifdef FEATURE_WLAN_SCAN_PNO
11932
11933/*Max Len for PNO notification*/
11934#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011935static void found_pref_network_cb(void *callbackContext,
11936 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011937{
11938 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
11939 union iwreq_data wrqu;
11940 char buf[MAX_PNO_NOTIFY_LEN + 1];
11941
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011942 hdd_debug("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011943 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
11944
11945 /* create the event */
11946 memset(&wrqu, 0, sizeof(wrqu));
11947 memset(buf, 0, sizeof(buf));
11948
11949 snprintf(buf, MAX_PNO_NOTIFY_LEN,
11950 "QCOM: Found preferred network: %s with RSSI of -%u",
11951 pPrefNetworkFoundInd->ssId.ssId,
11952 (unsigned int)pPrefNetworkFoundInd->rssi);
11953
11954 wrqu.data.pointer = buf;
11955 wrqu.data.length = strlen(buf);
11956
11957 /* send the event */
11958
11959 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
11960
11961}
11962
11963/**
11964 * __iw_set_pno() - Preferred Network Offload ioctl handler
11965 * @dev: device upon which the ioctl was received
11966 * @info: ioctl request information
11967 * @wrqu: ioctl request data
11968 * @extra: ioctl extra data
11969 *
11970 * This function parses a Preferred Network Offload command
11971 * Input is string based and expected to be of the form:
11972 *
11973 * <enable(1) | disable(0)>
11974 * when enabling:
11975 * <number of networks>
11976 * for each network:
11977 * <ssid_len> <ssid> <authentication> <encryption>
11978 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070011979 * <scan_time (seconds)>
11980 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011981 * <suspend mode>
11982 *
11983 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070011984 * 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 -080011985 *
11986 * this translates into:
11987 * -----------------------------
11988 * enable PNO
11989 * 2 networks
11990 * Network 1:
11991 * test - with authentication type 0 and encryption type 0,
11992 * search on 3 channels: 1 6 and 11,
11993 * SSID bcast type is unknown (directed probe will be sent if
11994 * AP not found) and must meet -40dBm RSSI
11995 * Network 2:
11996 * test2 - with authentication type 4 and encryption type 4,
11997 * search on 6 channels 1, 2, 3, 4, 5 and 6
11998 * bcast type is non-bcast (directed probe will be sent)
11999 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012000 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070012001 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012002 */
12003static int __iw_set_pno(struct net_device *dev,
12004 struct iw_request_info *info,
12005 union iwreq_data *wrqu, char *extra)
12006{
12007 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12008 hdd_context_t *hdd_ctx;
12009 int ret;
12010 int offset;
12011 char *ptr;
12012 uint8_t i, j, params, mode;
12013
12014 /* request is a large struct, so we make it static to avoid
12015 * stack overflow. This API is only invoked via ioctl, so it
12016 * is serialized by the kernel rtnl_lock and hence does not
12017 * need to be reentrant
12018 */
12019 static tSirPNOScanReq request;
12020
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012021 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012022
12023 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12024 ret = wlan_hdd_validate_context(hdd_ctx);
12025 if (ret)
12026 return ret;
12027
Jeff Johnson441e1f72017-02-07 08:50:49 -080012028 ret = hdd_check_private_wext_control(hdd_ctx, info);
12029 if (0 != ret)
12030 return ret;
12031
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012032 hdd_debug("PNO data len %d data %s", wrqu->data.length, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012033
12034 request.enable = 0;
12035 request.ucNetworksCount = 0;
12036
12037 ptr = extra;
12038
12039 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
12040 hdd_err("PNO enable input is not valid %s", ptr);
12041 return -EINVAL;
12042 }
12043
12044 if (0 == request.enable) {
12045 /* Disable PNO, ignore any other params */
12046 memset(&request, 0, sizeof(request));
12047 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
12048 &request, adapter->sessionId,
12049 found_pref_network_cb, adapter);
12050 return 0;
12051 }
12052
12053 ptr += offset;
12054
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012055 if (1 != sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012056 hdd_err("PNO count input not valid %s", ptr);
12057 return -EINVAL;
12058
12059 }
12060
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012061 hdd_debug("PNO enable %d networks count %d offset %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012062 request.enable, request.ucNetworksCount, offset);
12063
12064 if ((0 == request.ucNetworksCount) ||
12065 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
12066 hdd_err("Network count %d invalid",
12067 request.ucNetworksCount);
12068 return -EINVAL;
12069 }
12070
12071 ptr += offset;
12072
12073 for (i = 0; i < request.ucNetworksCount; i++) {
12074
12075 request.aNetworks[i].ssId.length = 0;
12076
12077 params = sscanf(ptr, "%hhu %n",
12078 &(request.aNetworks[i].ssId.length),
12079 &offset);
12080
12081 if (1 != params) {
12082 hdd_err("PNO ssid length input is not valid %s", ptr);
12083 return -EINVAL;
12084 }
12085
12086 if ((0 == request.aNetworks[i].ssId.length) ||
12087 (request.aNetworks[i].ssId.length > 32)) {
12088 hdd_err("SSID Len %d is not correct for network %d",
12089 request.aNetworks[i].ssId.length, i);
12090 return -EINVAL;
12091 }
12092
12093 /* Advance to SSID */
12094 ptr += offset;
12095
12096 memcpy(request.aNetworks[i].ssId.ssId, ptr,
12097 request.aNetworks[i].ssId.length);
12098 ptr += request.aNetworks[i].ssId.length;
12099
12100 params = sscanf(ptr, "%u %u %hhu %n",
12101 &(request.aNetworks[i].authentication),
12102 &(request.aNetworks[i].encryption),
12103 &(request.aNetworks[i].ucChannelCount),
12104 &offset);
12105
12106 if (3 != params) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012107 hdd_err("Incorrect cmd %s", ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012108 return -EINVAL;
12109 }
12110
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012111 hdd_debug("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012112 request.aNetworks[i].ssId.length,
12113 request.aNetworks[i].ssId.length,
12114 request.aNetworks[i].ssId.ssId,
12115 request.aNetworks[i].authentication,
12116 request.aNetworks[i].encryption,
12117 request.aNetworks[i].ucChannelCount, offset);
12118
12119 /* Advance to channel list */
12120 ptr += offset;
12121
12122 if (SIR_PNO_MAX_NETW_CHANNELS <
12123 request.aNetworks[i].ucChannelCount) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012124 hdd_err("Incorrect number of channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012125 return -EINVAL;
12126 }
12127
12128 if (0 != request.aNetworks[i].ucChannelCount) {
12129 for (j = 0; j < request.aNetworks[i].ucChannelCount;
12130 j++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012131 if (1 != sscanf(ptr, "%hhu %n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012132 &(request.aNetworks[i].
12133 aChannels[j]), &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012134 hdd_err("PNO network channel is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012135 ptr);
12136 return -EINVAL;
12137 }
12138 /* Advance to next channel number */
12139 ptr += offset;
12140 }
12141 }
12142
12143 if (1 != sscanf(ptr, "%u %n",
12144 &(request.aNetworks[i].bcastNetwType),
12145 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012146 hdd_err("PNO broadcast network type is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012147 ptr);
12148 return -EINVAL;
12149 }
12150
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012151 hdd_debug("PNO bcastNetwType %d offset %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012152 request.aNetworks[i].bcastNetwType, offset);
12153
12154 /* Advance to rssi Threshold */
12155 ptr += offset;
12156 if (1 != sscanf(ptr, "%d %n",
12157 &(request.aNetworks[i].rssiThreshold),
12158 &offset)) {
12159 hdd_err("PNO rssi threshold input is not valid %s",
12160 ptr);
12161 return -EINVAL;
12162 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012163 hdd_debug("PNO rssi %d offset %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012164 request.aNetworks[i].rssiThreshold, offset);
12165 /* Advance to next network */
12166 ptr += offset;
12167 } /* For ucNetworkCount */
12168
Dustin Brown43e87292016-10-10 10:38:25 -070012169 request.fast_scan_period = 0;
12170 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
12171 request.fast_scan_period *= MSEC_PER_SEC;
12172 ptr += offset;
12173 }
12174
12175 request.fast_scan_max_cycles = 0;
12176 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
12177 &offset) > 0)
12178 ptr += offset;
12179
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012180 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
12181
12182 request.modePNO = mode;
12183 /* for LA we just expose suspend option */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012184 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012185 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012186
12187 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
12188 &request,
12189 adapter->sessionId,
12190 found_pref_network_cb, adapter);
12191
12192 return 0;
12193}
12194
12195static int iw_set_pno(struct net_device *dev,
12196 struct iw_request_info *info,
12197 union iwreq_data *wrqu, char *extra)
12198{
12199 int ret;
12200
12201 cds_ssr_protect(__func__);
12202 ret = __iw_set_pno(dev, info, wrqu, extra);
12203 cds_ssr_unprotect(__func__);
12204
12205 return ret;
12206}
12207#endif /* FEATURE_WLAN_SCAN_PNO */
12208
12209/* Common function to SetBand */
12210int hdd_set_band(struct net_device *dev, u8 ui_band)
12211{
12212 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12213 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12214 eCsrBand band;
12215
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012216 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012217 hdd_context_t *pHddCtx;
12218 hdd_adapter_list_node_t *pAdapterNode, *pNext;
12219 eCsrBand currBand = eCSR_BAND_MAX;
12220 eCsrBand connectedBand;
12221
12222 pAdapterNode = NULL;
12223 pNext = NULL;
12224 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12225
12226 switch (ui_band) {
12227 case WLAN_HDD_UI_BAND_AUTO:
12228 band = eCSR_BAND_ALL;
12229 break;
12230 case WLAN_HDD_UI_BAND_5_GHZ:
12231 band = eCSR_BAND_5G;
12232 break;
12233 case WLAN_HDD_UI_BAND_2_4_GHZ:
12234 band = eCSR_BAND_24;
12235 break;
12236 default:
12237 band = eCSR_BAND_MAX;
12238 }
12239
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012240 hdd_debug("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012241
12242 if (band == eCSR_BAND_MAX) {
12243 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -070012244 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012245 return -EINVAL;
12246 }
12247
12248 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
12249 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012250 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012251 band, pHddCtx->config->nBandCapability);
12252 return -EIO;
12253 }
12254
12255 if (band == eCSR_BAND_ALL) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012256 hdd_debug("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012257 pHddCtx->config->nBandCapability);
12258 band = pHddCtx->config->nBandCapability;
12259 }
12260
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012261 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012262 hdd_debug("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012263 return -EIO;
12264 }
12265
12266 if (currBand != band) {
12267 /* Change band request received.
12268 * Abort pending scan requests, flush the existing scan results,
12269 * and change the band capability
12270 */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012271 hdd_debug("Current band value = %u, new setting %u ",
Jeff Johnson99bac312016-06-28 10:38:18 -070012272 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012273
12274 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012275 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012276 pAdapter = pAdapterNode->pAdapter;
12277 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12278 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053012279 INVALID_SCAN_ID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012280 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
12281 connectedBand =
12282 hdd_conn_get_connected_band
12283 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
12284
12285 /* Handling is done only for STA and P2P */
12286 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -080012287 ((pAdapter->device_mode == QDF_STA_MODE)
12288 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012289 &&
12290 (hdd_conn_is_connected
12291 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
12292 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012293 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012294 long lrc;
12295
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012296 /* STA already connected on current
12297 * band, So issue disconnect first,
12298 * then change the band
12299 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012300
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012301 hdd_debug("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012302 hdd_device_mode_to_string(pAdapter->device_mode),
12303 pAdapter->device_mode, currBand, band);
12304 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12305
12306 status =
12307 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
12308 (pAdapter),
12309 pAdapter->sessionId,
12310 eCSR_DISCONNECT_REASON_UNSPECIFIED);
12311
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012312 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012313 hdd_err("sme_roam_disconnect failure, status: %d",
Jeff Johnson99bac312016-06-28 10:38:18 -070012314 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012315 return -EINVAL;
12316 }
12317
12318 lrc =
12319 wait_for_completion_timeout(&pAdapter->
12320 disconnect_comp_var,
12321 msecs_to_jiffies
12322 (WLAN_WAIT_TIME_DISCONNECT));
12323
12324 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012325 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012326 return -ETIMEDOUT;
12327 }
12328 }
12329
12330 sme_scan_flush_result(hHal);
12331
12332 status =
12333 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
12334 pAdapterNode = pNext;
12335 }
12336
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012337 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012338 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012339 hdd_err("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012340 band);
12341 return -EINVAL;
12342 }
12343 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
12344 }
12345 return 0;
12346}
12347
12348int hdd_set_band_helper(struct net_device *dev, const char *command)
12349{
12350 uint8_t band;
12351 int ret;
12352
12353 /* Convert the band value from ascii to integer */
12354 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
12355 ret = kstrtou8(command, 10, &band);
12356 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012357 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012358 return -EINVAL;
12359 }
12360
12361 return hdd_set_band(dev, band);
12362}
12363
12364static int __iw_set_band_config(struct net_device *dev,
12365 struct iw_request_info *info,
12366 union iwreq_data *wrqu, char *extra)
12367{
Jeff Johnson441e1f72017-02-07 08:50:49 -080012368 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12369 hdd_context_t *hdd_ctx;
12370 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012371 int *value = (int *)extra;
12372
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012373 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012374
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012375 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012376 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012377 return -EPERM;
12378 }
12379
Jeff Johnson441e1f72017-02-07 08:50:49 -080012380 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12381 ret = hdd_check_private_wext_control(hdd_ctx, info);
12382 if (0 != ret)
12383 return ret;
12384
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012385 return hdd_set_band(dev, value[0]);
12386}
12387
12388static int iw_set_band_config(struct net_device *dev,
12389 struct iw_request_info *info,
12390 union iwreq_data *wrqu, char *extra)
12391{
12392 int ret;
12393
12394 cds_ssr_protect(__func__);
12395 ret = __iw_set_band_config(dev, info, wrqu, extra);
12396 cds_ssr_unprotect(__func__);
12397
12398 return ret;
12399}
12400
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012401/**
12402 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
12403 * @adapter: Handle to adapter
12404 * @chan: Monitor mode channel
12405 * @bandwidth: Capture channel bandwidth
12406 *
12407 * Return: 0 on success else error code.
12408 */
12409static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
12410 uint32_t bandwidth)
12411{
12412 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12413 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
12414 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
12415 QDF_STATUS status;
12416 tHalHandle hal_hdl = hdd_ctx->hHal;
12417 struct qdf_mac_addr bssid;
12418 tCsrRoamProfile roam_profile;
12419 struct ch_params_s ch_params;
12420
12421 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
12422 hdd_err("Not supported, device is not in monitor mode");
12423 return -EINVAL;
12424 }
12425
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012426 hdd_debug("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080012427 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012428 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
12429 roam_profile.ChannelInfo.numOfChannels = 1;
12430 roam_profile.phyMode = ch_info->phy_mode;
12431 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070012432 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012433
12434 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
12435 QDF_MAC_ADDR_SIZE);
12436
12437 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -070012438 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakashc4dc9382017-03-07 18:50:33 -080012439 if (ch_params.ch_width == CH_WIDTH_INVALID) {
12440 hdd_err("Invalid capture channel or bandwidth for a country");
12441 return -EINVAL;
12442 }
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012443 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
12444 &roam_profile);
12445 if (status) {
12446 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
12447 status);
12448 }
12449
12450 return qdf_status_to_os_return(status);
12451}
12452
Dustin Brown8d2d0f52017-04-03 17:02:08 -070012453static int printk_adapter(void *priv, const char *fmt, ...)
12454{
12455 int ret;
12456 va_list args;
12457
12458 va_start(args, fmt);
12459 ret = vprintk(fmt, args);
12460 ret += printk("\n");
12461 va_end(args);
12462
12463 return ret;
12464}
12465
12466#ifdef WMI_INTERFACE_EVENT_LOGGING
12467static void hdd_ioctl_log_buffer(int log_id, uint32_t count)
12468{
12469 qdf_abstract_print *print = &printk_adapter;
12470
12471 switch (log_id) {
12472 case HTC_CREDIT_HISTORY_LOG:
12473 print(NULL, "HTC Credit History (count %u)", count);
12474 cds_print_htc_credit_history(count, print, NULL);
12475 break;
12476 case COMMAND_LOG:
12477 print(NULL, "Command Log (count %u)", count);
12478 wma_print_wmi_cmd_log(count, print, NULL);
12479 break;
12480 case COMMAND_TX_CMP_LOG:
12481 print(NULL, "Command Tx Complete Log (count %u)", count);
12482 wma_print_wmi_cmd_tx_cmp_log(count, print, NULL);
12483 break;
12484 case MGMT_COMMAND_LOG:
12485 print(NULL, "Management Command Log (count %u)", count);
12486 wma_print_wmi_mgmt_cmd_log(count, print, NULL);
12487 break;
12488 case MGMT_COMMAND_TX_CMP_LOG:
12489 print(NULL, "Management Command Tx Complete Log (count %u)",
12490 count);
12491 wma_print_wmi_mgmt_cmd_tx_cmp_log(count, print, NULL);
12492 break;
12493 case EVENT_LOG:
12494 print(NULL, "Event Log (count %u)", count);
12495 wma_print_wmi_event_log(count, print, NULL);
12496 break;
12497 case RX_EVENT_LOG:
12498 print(NULL, "Rx Event Log (count %u)", count);
12499 wma_print_wmi_rx_event_log(count, print, NULL);
12500 break;
12501 case MGMT_EVENT_LOG:
12502 print(NULL, "Management Event Log (count %u)", count);
12503 wma_print_wmi_mgmt_event_log(count, print, NULL);
12504 break;
12505 default:
12506 print(NULL, "Invalid Log Id %d", log_id);
12507 break;
12508 }
12509}
12510#else
12511static inline void hdd_ioctl_log_buffer(int log_id, uint32_t count)
12512{
12513}
12514#endif /* WMI_INTERFACE_EVENT_LOGGING */
12515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012516static int __iw_set_two_ints_getnone(struct net_device *dev,
12517 struct iw_request_info *info,
12518 union iwreq_data *wrqu, char *extra)
12519{
12520 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12521 int *value = (int *)extra;
12522 int sub_cmd = value[0];
12523 int ret;
12524 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
12525
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012526 ENTER_DEV(dev);
12527
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012528 ret = wlan_hdd_validate_context(hdd_ctx);
12529 if (0 != ret)
12530 return ret;
12531
Jeff Johnson441e1f72017-02-07 08:50:49 -080012532 ret = hdd_check_private_wext_control(hdd_ctx, info);
12533 if (0 != ret)
12534 return ret;
12535
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012536 switch (sub_cmd) {
12537 case WE_SET_SMPS_PARAM:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012538 hdd_debug("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012539 ret = wma_cli_set_command(pAdapter->sessionId,
12540 WMI_STA_SMPS_PARAM_CMDID,
12541 value[1] << WMA_SMPS_PARAM_VALUE_S
12542 | value[2],
12543 VDEV_CMD);
12544 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070012545#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012546 case WE_SET_FW_CRASH_INJECT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012547 hdd_debug("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012548 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053012549 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
12550 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012551 ret = wma_cli_set2_command(pAdapter->sessionId,
12552 GEN_PARAM_CRASH_INJECT,
12553 value[1], value[2], GEN_CMD);
12554 break;
12555#endif
Govind Singha471e5e2015-10-12 17:11:14 +053012556 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070012557 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012558 value[1], value[2]);
12559 ret = wma_cli_set2_command(pAdapter->sessionId,
12560 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
12561 value[1], value[2], DBG_CMD);
12562 break;
12563 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070012564 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012565 value[1], value[2]);
12566 ret = wma_cli_set2_command(pAdapter->sessionId,
12567 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
12568 value[1], value[2], DBG_CMD);
12569 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012570 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
12571 hdd_debug("Ioctl to set dual fw mode config");
12572 if (hdd_ctx->config->dual_mac_feature_disable) {
12573 hdd_err("Dual mac feature is disabled from INI");
12574 return -EPERM;
12575 }
12576 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080012577 policy_mgr_set_dual_mac_fw_mode_config(hdd_ctx->hdd_psoc,
12578 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012579 break;
12580 case WE_DUMP_DP_TRACE_LEVEL:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012581 hdd_debug("WE_DUMP_DP_TRACE_LEVEL: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012582 value[1], value[2]);
12583 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012584 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053012585 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
12586 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053012587 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
12588 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012589 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012590 case WE_SET_MON_MODE_CHAN:
12591 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
12592 break;
Dustin Brown54096432017-02-23 13:00:44 -080012593 case WE_SET_WLAN_SUSPEND: {
Dustin Brown3ed3e9b2017-03-23 12:57:58 -070012594 hdd_info("STA unit-test suspend(%d, %d)", value[1], value[2]);
Dustin Brown54096432017-02-23 13:00:44 -080012595 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
12596 value[1], value[2]);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012597 break;
Dustin Brown54096432017-02-23 13:00:44 -080012598 }
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012599 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070012600 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012601 break;
Dustin Brown8d2d0f52017-04-03 17:02:08 -070012602 case WE_LOG_BUFFER: {
12603 int log_id = value[1];
12604 uint32_t count = value[2] < 0 ? 0 : value[2];
12605
12606 hdd_ioctl_log_buffer(log_id, count);
12607
12608 break;
12609 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012610 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070012611 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012612 break;
12613 }
12614
12615 return ret;
12616}
12617
12618static int iw_set_two_ints_getnone(struct net_device *dev,
12619 struct iw_request_info *info,
12620 union iwreq_data *wrqu, char *extra)
12621{
12622 int ret;
12623
12624 cds_ssr_protect(__func__);
12625 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
12626 cds_ssr_unprotect(__func__);
12627
12628 return ret;
12629}
12630
12631/* Define the Wireless Extensions to the Linux Network Device structure */
12632/* A number of these routines are NULL (meaning they are not implemented.) */
12633
12634static const iw_handler we_handler[] = {
12635 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
12636 (iw_handler) iw_get_name, /* SIOCGIWNAME */
12637 (iw_handler) NULL, /* SIOCSIWNWID */
12638 (iw_handler) NULL, /* SIOCGIWNWID */
12639 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
12640 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
12641 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
12642 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
12643 (iw_handler) NULL, /* SIOCSIWSENS */
12644 (iw_handler) NULL, /* SIOCGIWSENS */
12645 (iw_handler) NULL, /* SIOCSIWRANGE */
12646 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
12647 (iw_handler) NULL, /* SIOCSIWPRIV */
12648 (iw_handler) NULL, /* SIOCGIWPRIV */
12649 (iw_handler) NULL, /* SIOCSIWSTATS */
12650 (iw_handler) NULL, /* SIOCGIWSTATS */
12651 (iw_handler) NULL, /* SIOCSIWSPY */
12652 (iw_handler) NULL, /* SIOCGIWSPY */
12653 (iw_handler) NULL, /* SIOCSIWTHRSPY */
12654 (iw_handler) NULL, /* SIOCGIWTHRSPY */
12655 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
12656 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
12657 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
12658 (iw_handler) NULL, /* SIOCGIWAPLIST */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012659#ifndef NAPIER_SCAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012660 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
12661 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012662#else
12663 (iw_handler) NULL, /* SIOCSIWSCAN */
12664 (iw_handler) NULL, /* SIOCGIWSCAN */
12665#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012666 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
12667 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
12668 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
12669 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
12670 (iw_handler) NULL, /* -- hole -- */
12671 (iw_handler) NULL, /* -- hole -- */
12672 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
12673 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
12674 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
12675 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
12676 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
12677 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
12678 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
12679 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
12680 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
12681 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
12682 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
12683 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
12684 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
12685 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
12686 (iw_handler) NULL, /* -- hole -- */
12687 (iw_handler) NULL, /* -- hole -- */
12688 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
12689 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
12690 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
12691 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
12692 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
12693 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
12694 (iw_handler) NULL, /* SIOCSIWPMKSA */
12695};
12696
12697static const iw_handler we_private[] = {
12698
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012699 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone,
12700 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint,
12701 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012702 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12703 iw_set_three_ints_getnone,
12704 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012705 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012706 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12707 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070012708 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
12709 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012710 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
12711 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
12712 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012713 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012714 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
12715 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
12716 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
12717 iw_set_keepalive_params,
12718#ifdef WLAN_FEATURE_PACKET_FILTERING
12719 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
12720 iw_set_packet_filter_params,
12721#endif
12722#ifdef FEATURE_WLAN_SCAN_PNO
12723 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
12724#endif
12725 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080012726 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
12727 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012728 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
12729 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12730 iw_set_two_ints_getnone,
12731 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
12732 iw_set_dot11p_channel_sched,
12733};
12734
12735/*Maximum command length can be only 15 */
12736static const struct iw_priv_args we_private_args[] = {
12737
12738 /* handlers for main ioctl */
12739 {WLAN_PRIV_SET_INT_GET_NONE,
12740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12741 0,
12742 ""},
12743
12744 /* handlers for sub-ioctl */
12745 {WE_SET_11D_STATE,
12746 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12747 0,
12748 "set11Dstate"},
12749
12750 {WE_WOWL,
12751 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12752 0,
12753 "wowl"},
12754
12755 {WE_SET_POWER,
12756 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12757 0,
12758 "setPower"},
12759
12760 {WE_SET_MAX_ASSOC,
12761 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12762 0,
12763 "setMaxAssoc"},
12764
12765 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
12766 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
12767 "setAutoChannel" },
12768
12769 {WE_SET_SCAN_DISABLE,
12770 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12771 0,
12772 "scan_disable"},
12773
12774 {WE_SET_DATA_INACTIVITY_TO,
12775 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12776 0,
12777 "inactivityTO"},
12778
12779 {WE_SET_MAX_TX_POWER,
12780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12781 0,
12782 "setMaxTxPower"},
12783
12784 {WE_SET_TX_POWER,
12785 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12786 0,
12787 "setTxPower"},
12788
12789 {WE_SET_MC_RATE,
12790 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12791 0,
12792 "setMcRate"},
12793
12794 {WE_SET_MAX_TX_POWER_2_4,
12795 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12796 0,
12797 "setTxMaxPower2G"},
12798
12799 {WE_SET_MAX_TX_POWER_5_0,
12800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12801 0,
12802 "setTxMaxPower5G"},
12803
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012804 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012805 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012806 0,
12807 "pktlog"},
12808
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012809 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
12810 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012811 * will support both
12812 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012813 {WE_SET_MAX_TX_POWER,
12814 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12815 0,
12816 "setTxMaxPower"},
12817
12818 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012819 * 1 = enable and 0 = disable
12820 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012821 {
12822 WE_SET_HIGHER_DTIM_TRANSITION,
12823 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12824 0,
12825 "setHDtimTransn"
12826 },
12827
12828 {WE_SET_TM_LEVEL,
12829 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12830 0,
12831 "setTmLevel"},
12832
12833 {WE_SET_PHYMODE,
12834 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12835 0,
12836 "setphymode"},
12837
12838 {WE_SET_NSS,
12839 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12840 0,
12841 "nss"},
12842
12843 {WE_SET_LDPC,
12844 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12845 0,
12846 "ldpc"},
12847
12848 {WE_SET_TX_STBC,
12849 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12850 0,
12851 "tx_stbc"},
12852
12853 {WE_SET_RX_STBC,
12854 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12855 0,
12856 "rx_stbc"},
12857
12858 {WE_SET_SHORT_GI,
12859 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12860 0,
12861 "shortgi"},
12862
12863 {WE_SET_RTSCTS,
12864 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12865 0,
12866 "enablertscts"},
12867
12868 {WE_SET_CHWIDTH,
12869 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12870 0,
12871 "chwidth"},
12872
12873 {WE_SET_ANI_EN_DIS,
12874 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12875 0,
12876 "anienable"},
12877
12878 {WE_SET_ANI_POLL_PERIOD,
12879 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12880 0,
12881 "aniplen"},
12882
12883 {WE_SET_ANI_LISTEN_PERIOD,
12884 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12885 0,
12886 "anilislen"},
12887
12888 {WE_SET_ANI_OFDM_LEVEL,
12889 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12890 0,
12891 "aniofdmlvl"},
12892
12893 {WE_SET_ANI_CCK_LEVEL,
12894 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12895 0,
12896 "aniccklvl"},
12897
12898 {WE_SET_DYNAMIC_BW,
12899 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12900 0,
12901 "cwmenable"},
12902
12903 {WE_SET_CTS_CBW,
12904 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12905 0,
12906 "cts_cbw" },
12907
12908 {WE_SET_GTX_HT_MCS,
12909 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12910 0,
12911 "gtxHTMcs"},
12912
12913 {WE_SET_GTX_VHT_MCS,
12914 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12915 0,
12916 "gtxVHTMcs"},
12917
12918 {WE_SET_GTX_USRCFG,
12919 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12920 0,
12921 "gtxUsrCfg"},
12922
12923 {WE_SET_GTX_THRE,
12924 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12925 0,
12926 "gtxThre"},
12927
12928 {WE_SET_GTX_MARGIN,
12929 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12930 0,
12931 "gtxMargin"},
12932
12933 {WE_SET_GTX_STEP,
12934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12935 0,
12936 "gtxStep"},
12937
12938 {WE_SET_GTX_MINTPC,
12939 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12940 0,
12941 "gtxMinTpc"},
12942
12943 {WE_SET_GTX_BWMASK,
12944 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12945 0,
12946 "gtxBWMask"},
12947
12948 {WE_SET_TX_CHAINMASK,
12949 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12950 0,
12951 "txchainmask"},
12952
12953 {WE_SET_RX_CHAINMASK,
12954 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12955 0,
12956 "rxchainmask"},
12957
12958 {WE_SET_11N_RATE,
12959 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12960 0,
12961 "set11NRates"},
12962
12963 {WE_SET_VHT_RATE,
12964 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12965 0,
12966 "set11ACRates"},
12967
12968 {WE_SET_AMPDU,
12969 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12970 0,
12971 "ampdu"},
12972
12973 {WE_SET_AMSDU,
12974 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12975 0,
12976 "amsdu"},
12977
12978 {WE_SET_BURST_ENABLE,
12979 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12980 0,
12981 "burst_enable"},
12982
12983 {WE_SET_BURST_DUR,
12984 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12985 0,
12986 "burst_dur"},
12987
12988 {WE_SET_TXPOW_2G,
12989 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12990 0,
12991 "txpow2g"},
12992
12993 {WE_SET_TXPOW_5G,
12994 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12995 0,
12996 "txpow5g"},
12997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012998 /* Sub-cmds DBGLOG specific commands */
12999 {WE_DBGLOG_LOG_LEVEL,
13000 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13001 0,
13002 "dl_loglevel"},
13003
13004 {WE_DBGLOG_VAP_ENABLE,
13005 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13006 0,
13007 "dl_vapon"},
13008
13009 {WE_DBGLOG_VAP_DISABLE,
13010 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13011 0,
13012 "dl_vapoff"},
13013
13014 {WE_DBGLOG_MODULE_ENABLE,
13015 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13016 0,
13017 "dl_modon"},
13018
13019 {WE_DBGLOG_MODULE_DISABLE,
13020 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13021 0,
13022 "dl_modoff"},
13023
13024 {WE_DBGLOG_MOD_LOG_LEVEL,
13025 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13026 0,
13027 "dl_mod_loglevel"},
13028
13029 {WE_DBGLOG_TYPE,
13030 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13031 0,
13032 "dl_type"},
13033 {WE_DBGLOG_REPORT_ENABLE,
13034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13035 0,
13036 "dl_report"},
13037
13038 {WE_SET_TXRX_FWSTATS,
13039 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13040 0,
13041 "txrx_fw_stats"},
13042
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080013043 {WE_SET_TXRX_STATS,
13044 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13045 0,
13046 "txrx_stats"},
13047
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013048 {WE_TXRX_FWSTATS_RESET,
13049 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13050 0,
13051 "txrx_fw_st_rst"},
13052
13053 {WE_PPS_PAID_MATCH,
13054 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13055 0, "paid_match"},
13056
13057 {WE_PPS_GID_MATCH,
13058 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13059 0, "gid_match"},
13060
13061 {WE_PPS_EARLY_TIM_CLEAR,
13062 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13063 0, "tim_clear"},
13064
13065 {WE_PPS_EARLY_DTIM_CLEAR,
13066 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13067 0, "dtim_clear"},
13068
13069 {WE_PPS_EOF_PAD_DELIM,
13070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13071 0, "eof_delim"},
13072
13073 {WE_PPS_MACADDR_MISMATCH,
13074 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13075 0, "mac_match"},
13076
13077 {WE_PPS_DELIM_CRC_FAIL,
13078 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13079 0, "delim_fail"},
13080
13081 {WE_PPS_GID_NSTS_ZERO,
13082 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13083 0, "nsts_zero"},
13084
13085 {WE_PPS_RSSI_CHECK,
13086 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13087 0, "rssi_chk"},
13088
13089 {WE_PPS_5G_EBT,
13090 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13091 0, "5g_ebt"},
13092
13093 {WE_SET_HTSMPS,
13094 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13095 0, "htsmps"},
13096
13097 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
13098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13099 0, "set_qpspollcnt"},
13100
13101 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
13102 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13103 0, "set_qtxwake"},
13104
13105 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13106 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13107 0, "set_qwakeintv"},
13108
13109 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13110 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13111 0, "set_qnodatapoll"},
13112
13113 /* handlers for MCC time quota and latency sub ioctls */
13114 {WE_MCC_CONFIG_LATENCY,
13115 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13116 0, "setMccLatency"},
13117
13118 {WE_MCC_CONFIG_QUOTA,
13119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13120 0, "setMccQuota"},
13121
13122 {WE_SET_DEBUG_LOG,
13123 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13124 0, "setDbgLvl"},
13125
13126 /* handlers for early_rx power save */
13127 {WE_SET_EARLY_RX_ADJUST_ENABLE,
13128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13129 0, "erx_enable"},
13130
13131 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
13132 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13133 0, "erx_bmiss_val"},
13134
13135 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
13136 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13137 0, "erx_bmiss_smpl"},
13138
13139 {WE_SET_EARLY_RX_SLOP_STEP,
13140 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13141 0, "erx_slop_step"},
13142
13143 {WE_SET_EARLY_RX_INIT_SLOP,
13144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13145 0, "erx_init_slop"},
13146
13147 {WE_SET_EARLY_RX_ADJUST_PAUSE,
13148 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13149 0, "erx_adj_pause"},
13150
13151 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
13152 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13153 0, "erx_dri_sample"},
13154
13155 {WE_DUMP_STATS,
13156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13157 0, "dumpStats"},
13158
13159 {WE_CLEAR_STATS,
13160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13161 0, "clearStats"},
13162
Govind Singha471e5e2015-10-12 17:11:14 +053013163 {WE_START_FW_PROFILE,
13164 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13165 0, "startProfile"},
13166
Abhishek Singh1bdb1572015-10-16 16:24:19 +053013167 {WE_SET_CHANNEL,
13168 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13169 0, "setChanChange" },
13170
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053013171 {WE_SET_CONC_SYSTEM_PREF,
13172 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13173 0, "setConcSysPref" },
13174
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013175 {WLAN_PRIV_SET_NONE_GET_INT,
13176 0,
13177 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13178 ""},
13179
13180 /* handlers for sub-ioctl */
13181 {WE_GET_11D_STATE,
13182 0,
13183 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13184 "get11Dstate"},
13185
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013186 {WE_GET_WLAN_DBG,
13187 0,
13188 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13189 "getwlandbg"},
13190
13191 {WE_GET_MAX_ASSOC,
13192 0,
13193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13194 "getMaxAssoc"},
13195
13196 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
13197 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13198 "getAutoChannel" },
13199
13200 {WE_GET_CONCURRENCY_MODE,
13201 0,
13202 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13203 "getconcurrency"},
13204
13205 {WE_GET_NSS,
13206 0,
13207 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13208 "get_nss"},
13209
13210 {WE_GET_LDPC,
13211 0,
13212 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13213 "get_ldpc"},
13214
13215 {WE_GET_TX_STBC,
13216 0,
13217 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13218 "get_tx_stbc"},
13219
13220 {WE_GET_RX_STBC,
13221 0,
13222 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13223 "get_rx_stbc"},
13224
13225 {WE_GET_SHORT_GI,
13226 0,
13227 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13228 "get_shortgi"},
13229
13230 {WE_GET_RTSCTS,
13231 0,
13232 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13233 "get_rtscts"},
13234
13235 {WE_GET_CHWIDTH,
13236 0,
13237 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13238 "get_chwidth"},
13239
13240 {WE_GET_ANI_EN_DIS,
13241 0,
13242 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13243 "get_anienable"},
13244
13245 {WE_GET_ANI_POLL_PERIOD,
13246 0,
13247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13248 "get_aniplen"},
13249
13250 {WE_GET_ANI_LISTEN_PERIOD,
13251 0,
13252 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13253 "get_anilislen"},
13254
13255 {WE_GET_ANI_OFDM_LEVEL,
13256 0,
13257 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13258 "get_aniofdmlvl"},
13259
13260 {WE_GET_ANI_CCK_LEVEL,
13261 0,
13262 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13263 "get_aniccklvl"},
13264
13265 {WE_GET_DYNAMIC_BW,
13266 0,
13267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13268 "get_cwmenable"},
13269
13270 {WE_GET_GTX_HT_MCS,
13271 0,
13272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13273 "get_gtxHTMcs"},
13274
13275 {WE_GET_GTX_VHT_MCS,
13276 0,
13277 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13278 "get_gtxVHTMcs"},
13279
13280 {WE_GET_GTX_USRCFG,
13281 0,
13282 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13283 "get_gtxUsrCfg"},
13284
13285 {WE_GET_GTX_THRE,
13286 0,
13287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13288 "get_gtxThre"},
13289
13290 {WE_GET_GTX_MARGIN,
13291 0,
13292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13293 "get_gtxMargin"},
13294
13295 {WE_GET_GTX_STEP,
13296 0,
13297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13298 "get_gtxStep"},
13299
13300 {WE_GET_GTX_MINTPC,
13301 0,
13302 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13303 "get_gtxMinTpc"},
13304
13305 {WE_GET_GTX_BWMASK,
13306 0,
13307 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13308 "get_gtxBWMask"},
13309
13310 {WE_GET_TX_CHAINMASK,
13311 0,
13312 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13313 "get_txchainmask"},
13314
13315 {WE_GET_RX_CHAINMASK,
13316 0,
13317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13318 "get_rxchainmask"},
13319
13320 {WE_GET_11N_RATE,
13321 0,
13322 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13323 "get_11nrate"},
13324
13325 {WE_GET_AMPDU,
13326 0,
13327 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13328 "get_ampdu"},
13329
13330 {WE_GET_AMSDU,
13331 0,
13332 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13333 "get_amsdu"},
13334
13335 {WE_GET_BURST_ENABLE,
13336 0,
13337 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13338 "get_burst_en"},
13339
13340 {WE_GET_BURST_DUR,
13341 0,
13342 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13343 "get_burst_dur"},
13344
13345 {WE_GET_TXPOW_2G,
13346 0,
13347 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13348 "get_txpow2g"},
13349
13350 {WE_GET_TXPOW_5G,
13351 0,
13352 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13353 "get_txpow5g"},
13354
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013355 {WE_GET_PPS_PAID_MATCH,
13356 0,
13357 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13358 "get_paid_match"},
13359
13360 {WE_GET_PPS_GID_MATCH,
13361 0,
13362 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13363 "get_gid_match"},
13364
13365 {WE_GET_PPS_EARLY_TIM_CLEAR,
13366 0,
13367 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13368 "get_tim_clear"},
13369
13370 {WE_GET_PPS_EARLY_DTIM_CLEAR,
13371 0,
13372 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13373 "get_dtim_clear"},
13374
13375 {WE_GET_PPS_EOF_PAD_DELIM,
13376 0,
13377 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13378 "get_eof_delim"},
13379
13380 {WE_GET_PPS_MACADDR_MISMATCH,
13381 0,
13382 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13383 "get_mac_match"},
13384
13385 {WE_GET_PPS_DELIM_CRC_FAIL,
13386 0,
13387 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13388 "get_delim_fail"},
13389
13390 {WE_GET_PPS_GID_NSTS_ZERO,
13391 0,
13392 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13393 "get_nsts_zero"},
13394
13395 {WE_GET_PPS_RSSI_CHECK,
13396 0,
13397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13398 "get_rssi_chk"},
13399
13400 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
13401 0,
13402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13403 "get_qpspollcnt"},
13404
13405 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
13406 0,
13407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13408 "get_qtxwake"},
13409
13410 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13411 0,
13412 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13413 "get_qwakeintv"},
13414
13415 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13416 0,
13417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13418 "get_qnodatapoll"},
13419
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013420 {WE_CAP_TSF,
13421 0,
13422 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13423 "cap_tsf"},
13424
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013425 {WE_GET_TEMPERATURE,
13426 0,
13427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13428 "get_temp"},
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070013429 {WE_GET_DCM,
13430 0,
13431 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13432 "get_dcm"},
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070013433 {WE_GET_RANGE_EXT,
13434 0,
13435 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13436 "get_range_ext"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013437 /* handlers for main ioctl */
13438 {WLAN_PRIV_SET_CHAR_GET_NONE,
13439 IW_PRIV_TYPE_CHAR | 512,
13440 0,
13441 ""},
13442
13443 /* handlers for sub-ioctl */
13444 {WE_WOWL_ADD_PTRN,
13445 IW_PRIV_TYPE_CHAR | 512,
13446 0,
13447 "wowlAddPtrn"},
13448
13449 {WE_WOWL_DEL_PTRN,
13450 IW_PRIV_TYPE_CHAR | 512,
13451 0,
13452 "wowlDelPtrn"},
13453
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013454 /* handlers for sub-ioctl */
13455 {WE_NEIGHBOR_REPORT_REQUEST,
13456 IW_PRIV_TYPE_CHAR | 512,
13457 0,
13458 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080013459
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013460 {WE_SET_AP_WPS_IE,
13461 IW_PRIV_TYPE_CHAR | 512,
13462 0,
13463 "set_ap_wps_ie"},
13464
13465 {WE_SET_CONFIG,
13466 IW_PRIV_TYPE_CHAR | 512,
13467 0,
13468 "setConfig"},
13469
13470 /* handlers for main ioctl */
13471 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
13472 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13473 0,
13474 ""},
13475
13476 /* handlers for sub-ioctl */
13477 {WE_SET_WLAN_DBG,
13478 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13479 0,
13480 "setwlandbg"},
13481
13482 /* handlers for sub-ioctl */
13483 {WE_SET_DP_TRACE,
13484 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13485 0,
13486 "set_dp_trace"},
13487
13488 {WE_SET_SAP_CHANNELS,
13489 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13490 0,
13491 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013492
13493 {WE_SET_FW_TEST,
13494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13495 0, "fw_test"},
13496
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013497 /* handlers for main ioctl */
13498 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
13499 0,
13500 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13501 "" },
13502 {WE_GET_TSF,
13503 0,
13504 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13505 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013506
13507 {WE_SET_DUAL_MAC_SCAN_CONFIG,
13508 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13509 0,
13510 "set_scan_cfg"},
13511
13512 /* handlers for main ioctl */
13513 {WLAN_PRIV_GET_CHAR_SET_NONE,
13514 0,
13515 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13516 ""},
13517
13518 /* handlers for sub-ioctl */
13519 {WE_WLAN_VERSION,
13520 0,
13521 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13522 "version"},
13523 {WE_GET_STATS,
13524 0,
13525 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13526 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080013527 {WE_GET_SUSPEND_RESUME_STATS,
13528 0,
13529 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13530 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053013531 {WE_LIST_FW_PROFILE,
13532 0,
13533 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13534 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013535 {WE_GET_STATES,
13536 0,
13537 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13538 "getHostStates"},
13539 {WE_GET_CFG,
13540 0,
13541 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13542 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013543 {WE_GET_RSSI,
13544 0,
13545 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13546 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013547 {WE_GET_WMM_STATUS,
13548 0,
13549 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13550 "getWmmStatus"},
13551 {
13552 WE_GET_CHANNEL_LIST,
13553 0,
13554 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13555 "getChannelList"
13556 },
13557#ifdef FEATURE_WLAN_TDLS
13558 {
13559 WE_GET_TDLS_PEERS,
13560 0,
13561 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13562 "getTdlsPeers"
13563 },
13564#endif
13565#ifdef WLAN_FEATURE_11W
13566 {
13567 WE_GET_11W_INFO,
13568 0,
13569 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13570 "getPMFInfo"
13571 },
13572#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013573 {
13574 WE_GET_IBSS_STA_INFO,
13575 0,
13576 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13577 "getIbssSTAs"
13578 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013579 {WE_GET_PHYMODE,
13580 0,
13581 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13582 "getphymode"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013583#if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013584 {WE_GET_OEM_DATA_CAP,
13585 0,
13586 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13587 "getOemDataCap"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013588#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013589 {WE_GET_SNR,
13590 0,
13591 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13592 "getSNR"},
13593
13594 /* handlers for main ioctl */
13595 {WLAN_PRIV_SET_NONE_GET_NONE,
13596 0,
13597 0,
13598 ""},
13599
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013600 /* handlers for sub-ioctl */
13601 {
13602 WE_IBSS_GET_PEER_INFO_ALL,
13603 0,
13604 0,
13605 "ibssPeerInfoAll"
13606 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013607 {WE_GET_RECOVERY_STAT,
13608 0,
13609 0,
13610 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053013611
13612 {WE_GET_FW_PROFILE_DATA,
13613 0,
13614 0,
13615 "getProfileData"},
13616
13617 {WE_SET_REASSOC_TRIGGER,
13618 0,
13619 0,
13620 "reassoc"},
13621
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080013622 {WE_STOP_OBSS_SCAN,
13623 0,
13624 0,
13625 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013626 /* handlers for main ioctl */
13627 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
13628 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13629 0,
13630 ""},
13631
13632 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013633 {WE_IBSS_GET_PEER_INFO,
13634 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13635 0,
13636 "ibssPeerInfo"},
13637
13638 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013639 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
13640 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13641 0,
13642 "setdumplog"},
13643
13644 {WE_MTRACE_DUMP_CMD,
13645 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13646 0,
13647 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080013648
13649 {WE_POLICY_MANAGER_CINFO_CMD,
13650 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13651 0,
13652 "pm_cinfo"},
13653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013654#ifdef MPC_UT_FRAMEWORK
13655 {WE_POLICY_MANAGER_CLIST_CMD,
13656 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13657 0,
13658 "pm_clist"},
13659
13660 {WE_POLICY_MANAGER_DLIST_CMD,
13661 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13662 0,
13663 "pm_dlist"},
13664
13665 {WE_POLICY_MANAGER_DBS_CMD,
13666 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13667 0,
13668 "pm_dbs"},
13669
13670 {WE_POLICY_MANAGER_PCL_CMD,
13671 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13672 0,
13673 "pm_pcl"},
13674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013675 {WE_POLICY_MANAGER_ULIST_CMD,
13676 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13677 0,
13678 "pm_ulist"},
13679
13680 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
13681 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13682 0,
13683 "pm_query_action"},
13684
13685 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
13686 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13687 0,
13688 "pm_query_allow"},
13689
13690 {WE_POLICY_MANAGER_SCENARIO_CMD,
13691 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13692 0,
13693 "pm_run_scenario"},
13694
13695 {WE_POLICY_SET_HW_MODE_CMD,
13696 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13697 0,
13698 "pm_set_hw_mode"},
13699#endif
13700#ifdef FEATURE_WLAN_TDLS
13701 /* handlers for sub ioctl */
13702 {
13703 WE_TDLS_CONFIG_PARAMS,
13704 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13705 0,
13706 "setTdlsConfig"
13707 },
13708#endif
13709 {
13710 WE_UNIT_TEST_CMD,
13711 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13712 0,
13713 "setUnitTestCmd"
13714 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053013715 {
13716 WE_MAC_PWR_DEBUG_CMD,
13717 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13718 0,
13719 "halPwrDebug"
13720 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013721
13722#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
13723 {WE_LED_FLASHING_PARAM,
13724 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13725 0,
13726 "gpio_control"},
13727#endif
13728 /* handlers for main ioctl */
13729 {WLAN_PRIV_ADD_TSPEC,
13730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
13731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13732 "addTspec"},
13733
13734 /* handlers for main ioctl */
13735 {WLAN_PRIV_DEL_TSPEC,
13736 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13737 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13738 "delTspec"},
13739
13740 /* handlers for main ioctl */
13741 {WLAN_PRIV_GET_TSPEC,
13742 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13743 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13744 "getTspec"},
13745
13746 /* handlers for main ioctl - host offload */
13747 {
13748 WLAN_PRIV_SET_HOST_OFFLOAD,
Srinivas Girigowda077143e2017-03-25 10:47:27 -070013749 IW_PRIV_TYPE_BYTE | sizeof(struct host_offload_req),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013750 0,
13751 "setHostOffload"
13752 }
13753 ,
13754
13755 {
13756 WLAN_GET_WLAN_STATISTICS,
13757 0,
13758 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
13759 "getWlanStats"
13760 }
13761 ,
13762
13763 {
13764 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053013765 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
13766 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013767 0,
13768 "setKeepAlive"
13769 }
13770 ,
13771#ifdef WLAN_FEATURE_PACKET_FILTERING
13772 {
13773 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053013774 IW_PRIV_TYPE_BYTE |
13775 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013776 0,
13777 "setPktFilter"
13778 }
13779 ,
13780#endif
13781#ifdef FEATURE_WLAN_SCAN_PNO
13782 {
13783 WLAN_SET_PNO,
13784 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13785 0,
13786 "setpno"
13787 }
13788 ,
13789#endif
13790 {
13791 WLAN_SET_BAND_CONFIG,
13792 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13793 0,
13794 "SETBAND"
13795 }
13796 ,
13797 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080013798 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080013799 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013800 0,
13801 "setMCBCFilter"
13802 }
13803 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013804
13805 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013806 WLAN_GET_LINK_SPEED,
13807 IW_PRIV_TYPE_CHAR | 18,
13808 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
13809 }
13810 ,
13811
13812 /* handlers for main ioctl */
13813 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
13814 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13815 0,
13816 ""}
13817 ,
13818 {WE_SET_SMPS_PARAM,
13819 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13820 0, "set_smps_param"}
13821 ,
13822 {WLAN_SET_DOT11P_CHANNEL_SCHED,
13823 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
13824 0, "set_dot11p" }
13825 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070013826#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013827 {WE_SET_FW_CRASH_INJECT,
13828 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13829 0, "crash_inject"}
13830 ,
Dustin Brown8d2d0f52017-04-03 17:02:08 -070013831 {WE_LOG_BUFFER,
13832 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13833 0, "log_buffer"}
13834 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013835#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070013836#ifdef WLAN_SUSPEND_RESUME_TEST
13837 {WE_SET_WLAN_SUSPEND,
13838 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13839 0, "wlan_suspend"}
13840 ,
13841 {WE_SET_WLAN_RESUME,
13842 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13843 0, "wlan_resume"}
13844 ,
13845#endif
Govind Singha471e5e2015-10-12 17:11:14 +053013846 {WE_ENABLE_FW_PROFILE,
13847 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13848 0, "enableProfile"}
13849 ,
13850 {WE_SET_FW_PROFILE_HIST_INTVL,
13851 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13852 0, "set_hist_intvl"}
13853 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013854 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
13855 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13856 0, "set_fw_mode_cfg"}
13857 ,
13858 {WE_DUMP_DP_TRACE_LEVEL,
13859 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13860 0, "dump_dp_trace"}
13861 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070013862 {WE_SET_MON_MODE_CHAN,
13863 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13864 0, "setMonChan"}
13865 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070013866
13867 {WE_GET_ROAM_SYNCH_DELAY,
13868 0,
13869 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13870 "hostroamdelay"}
13871 ,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -080013872 {WE_SET_11AX_RATE,
13873 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13874 0,
13875 "set_11ax_rate"}
13876 ,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070013877 {WE_SET_DCM,
13878 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13879 0,
13880 "enable_dcm"}
13881 ,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070013882 {WE_SET_RANGE_EXT,
13883 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13884 0,
13885 "enable_range_ext"}
13886 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013887};
13888
13889const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053013890 .num_standard = QDF_ARRAY_SIZE(we_handler),
13891 .num_private = QDF_ARRAY_SIZE(we_private),
13892 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013893
13894 .standard = (iw_handler *) we_handler,
13895 .private = (iw_handler *) we_private,
13896 .private_args = we_private_args,
13897 .get_wireless_stats = NULL,
13898};
13899
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013900/* hdd_set_wext() - configures bss parameters
13901 * @pAdapter: handle to adapter context
13902 *
13903 * Returns: none
13904 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070013905static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013906{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013907 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13908 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013909
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013910 ENTER();
13911
13912 if (!pwextBuf) {
13913 hdd_err("ERROR: pwextBuf is NULL");
13914 return QDF_STATUS_E_FAILURE;
13915 }
13916
13917 if (!pHddStaCtx) {
13918 hdd_err("ERROR: pHddStaCtx is NULL");
13919 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013920 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013921
13922 /* Now configure the roaming profile links. To SSID and bssid. */
13923 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013924 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013925
13926 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013927 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013928
13929 /*Set the numOfChannels to zero to scan all the channels */
13930 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
13931 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
13932
13933 /* Default is no encryption */
13934 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
13935 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
13936 eCSR_ENCRYPT_TYPE_NONE;
13937
13938 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
13939 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
13940 eCSR_ENCRYPT_TYPE_NONE;
13941
13942 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
13943
13944 /* Default is no authentication */
13945 pwextBuf->roamProfile.AuthType.numEntries = 1;
13946 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13947
13948 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
13949 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
13950
13951 /*Set the default scan mode */
13952 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
13953
13954 hdd_clear_roam_profile_ie(pAdapter);
13955
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013956 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013957 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013958
13959}
13960
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013961/**
13962 * hdd_register_wext() - register wext context
13963 * @dev: net device handle
13964 *
13965 * Registers wext interface context for a given net device
13966 *
13967 * Returns: 0 on success, errno on failure
13968 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013969int hdd_register_wext(struct net_device *dev)
13970{
13971 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013972 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053013973 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013974
13975 ENTER();
13976
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013977 if (!pwextBuf) {
13978 hdd_err(FL("ERROR: pwextBuf is NULL"));
13979 return QDF_STATUS_E_FAILURE;
13980 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013981
13982 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013983 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
13984
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013985 status = hdd_set_wext(pAdapter);
13986
Anurag Chouhance0dc992016-02-16 18:18:03 +053013987 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070013988 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013989 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013990 }
13991
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070013992 status = qdf_event_create(&pwextBuf->hdd_qdf_event);
13993 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070013994 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013995 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013996 }
13997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013998 /* Register as a wireless device */
13999 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
14000
14001 EXIT();
14002 return 0;
14003}
14004
14005int hdd_unregister_wext(struct net_device *dev)
14006{
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080014007 hdd_debug("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014008
14009 if (dev != NULL) {
14010 rtnl_lock();
14011 dev->wireless_handlers = NULL;
14012 rtnl_unlock();
14013 }
14014
14015 return 0;
14016}