blob: 5dd46297b1deda854ca31db1b0baa5df6036e5bc [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>
Manjunathappa Prakash3454fd62016-04-01 08:52:06 -070044#include <cdp_txrx_stats.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "sir_params.h"
46#include "csr_api.h"
47#include "csr_inside_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "sme_rrm_internal.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include <ani_global.h>
50#include "dot11f.h"
51#include <wlan_hdd_wowl.h>
52#include <wlan_hdd_cfg.h>
53#include <wlan_hdd_wmm.h>
54#include "utils_api.h"
55#include "wlan_hdd_p2p.h"
56#ifdef FEATURE_WLAN_TDLS
57#include "wlan_hdd_tdls.h"
58#endif
59
60#include "cds_ieee80211_common.h"
61#include "ol_if_athvar.h"
62#include "dbglog_host.h"
63#include "wma.h"
64
65#include "wlan_hdd_power.h"
66#include "qwlan_version.h"
67#include "wlan_hdd_host_offload.h"
68
69#include <linux/wireless.h>
70#include <net/cfg80211.h>
71
72#include "wlan_hdd_misc.h"
73
74#include "qc_sap_ioctl.h"
75#include "sme_api.h"
76#include "wma_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053077#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078#include "wlan_hdd_assoc.h"
79#include "wlan_hdd_ioctl.h"
80#include "wlan_hdd_scan.h"
81#include "sme_power_save_api.h"
82#include "cds_concurrency.h"
83#include "wlan_hdd_conc_ut.h"
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070084#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085#include "wlan_hdd_ocb.h"
86#include "wlan_hdd_napi.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080087#include "cdp_txrx_flow_ctrl_legacy.h"
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070088#include "wlan_hdd_nan_datapath.h"
Nirav Shahbf1b0332016-05-25 14:27:39 +053089#include "wlan_hdd_stats.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070090#ifdef WLAN_SUSPEND_RESUME_TEST
91#include "wlan_hdd_driver_ops.h"
92#include "hif.h"
Rajeev Kumar9bb2e852016-09-24 12:29:25 -070093#include "pld_common.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070094#endif
Dhanashri Atree7d442a2016-07-14 18:20:29 -070095#include "wlan_hdd_lro.h"
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053096#include "cds_utils.h"
Jeff Johnsona6ace5b2017-01-23 07:11:02 -080097#include "wlan_hdd_request_manager.h"
Naveen Rawat910726a2017-03-06 11:42:51 -080098#include "os_if_wifi_pos.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800100#define HDD_FINISH_ULA_TIME_OUT 800
101#define HDD_SET_MCBC_FILTERS_TO_FW 1
102#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
103
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800104/* To Validate Channel against the Frequency and Vice-Versa */
105static const hdd_freq_chan_map_t freq_chan_map[] = {
106 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
107 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
108 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
109 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
110 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
111 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
112 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
113 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
114 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
115 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
116 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
117 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
118
119#define FREQ_CHAN_MAP_TABLE_SIZE \
120 (sizeof(freq_chan_map) / sizeof(freq_chan_map[0]))
121
122/* Private ioctls and their sub-ioctls */
123#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
124#define WE_SET_11D_STATE 1
125#define WE_WOWL 2
126#define WE_SET_POWER 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530127/*
128 * <ioctl>
129 * setMaxAssoc - Sets the maximum number of associated stations
130 *
131 * @INPUT: 1 to 32
132 *
133 * @OUTPUT: None
134 *
135 * This IOTCL sets the maximum number of associated stations
136 *
137 * @E.g: iwpriv wlan0 setMaxAssoc <value>
138 *
139 * Supported Feature: STA
140 *
141 * Usage: Internal/External
142 *
143 * </ioctl>
144 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145#define WE_SET_MAX_ASSOC 4
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +0530146/*
147 * <ioctl>
148 * scan_diable - Disable scan
149 *
150 * @INPUT: set_value
151 *
152 * @OUTPUT: None
153 *
154 * This IOCTL is used to set disable scan
155 *
156 * @E.g: iwpriv wlan0 scan_disable 1
157 *
158 * Supported Feature: Scan
159 *
160 * Usage: Internal/External
161 *
162 * </ioctl>
163 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164#define WE_SET_SCAN_DISABLE 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530165/*
166 * <ioctl>
167 * inactivityTO - sets the timeout value for inactivity data while
168 * in power save mode
169 *
170 * @INPUT: int1…..int255
171 *
172 * @OUTPUT: None
173 *
174 * This IOCTL set the timeout value for inactivity data in power save mode
175 *
176 * @E.g: iwpriv wlan0 inactivityTO 20
177 *
178 * Supported Feature: STA
179 *
180 * Usage: Internal/External
181 *
182 * </ioctl>
183 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184#define WE_SET_DATA_INACTIVITY_TO 6
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530185/*
186 * <ioctl>
187 * setMaxTxPower - Dynamically sets the maximum transmission power
188 *
189 * @INPUT: Transmission power in dBm
190 *
191 * @OUTPUT: None
192 *
193 * This IOCTL dynamically sets the maximum transmission power
194 * This setting does not persist over reboots
195 *
196 * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
197 *
198 * Supported Feature: STA
199 *
200 * Usage: Internal/External
201 *
202 * </ioctl>
203 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204#define WE_SET_MAX_TX_POWER 7
205#define WE_SET_HIGHER_DTIM_TRANSITION 8
206#define WE_SET_TM_LEVEL 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530207/*
208 * <ioctl>
209 * setphymode - Set the phymode dynamically
210 *
211 * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
212 *
213 * @OUTPUT: None
214 *
215 * This IOCTL sets the phymode dynamically
216 *
217 * @E.g: iwpriv wlan0 setphymode 10
218 *
219 * Supported Feature: STA
220 *
221 * Usage: Internal/External
222 *
223 * </ioctl>
224 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225#define WE_SET_PHYMODE 10
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530226/*
227 * <ioctl>
228 * nss - Set the number of spatial streams
229 *
230 * @INPUT: int1…..int3
231 *
232 * @OUTPUT: None
233 *
234 * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
235 *
236 * @E.g: iwpriv wlan0 nss 2
237 *
238 * Supported Feature: STA
239 *
240 * Usage: Internal/External
241 *
242 * </ioctl>
243 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244#define WE_SET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530245/*
246 * <ioctl>
247 * ldpc - Enables or disables LDPC
248 *
249 * @INPUT: 0 – Disable, 1 - Enable
250 *
251 * @OUTPUT: None
252 *
253 * This IOCTL enables or disables LDPC
254 *
255 * @E.g: iwpriv wlan0 ldpc 1
256 *
257 * Supported Feature: STA
258 *
259 * Usage: Internal/External
260 *
261 * </ioctl>
262 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263#define WE_SET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530264/*
265 * <ioctl>
266 * tx_stbc - Enables or disables tx_stbc
267 *
268 * @INPUT: Int 0 – Disable, 1 - Enable
269 *
270 * @OUTPUT: None
271 *
272 * This IOTCL used to enables or disables tx_stbc
273 *
274 * @E.g: iwpriv wlan0 tx_stbc <value>
275 *
276 * Supported Feature: STA
277 *
278 * Usage: Internal/External
279 *
280 * </ioctl>
281 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800282#define WE_SET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530283/*
284 * <ioctl>
285 * rx_stbc - Set the rx_stbc parameter
286 *
287 * @INPUT: Int 0 – Disable, 1 - Enable
288 *
289 * @OUTPUT: None
290 *
291 * This IOTCL used to set rx_stbc parameter
292 *
293 * @E.g: iwpriv wlan0 rx_stbc <value>
294 *
295 * Supported Feature: STA
296 *
297 * Usage: Internal/External
298 *
299 * </ioctl>
300 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301#define WE_SET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530302/*
303 * <ioctl>
304 * shortgi - Enables or disables a short-guard interval
305 *
306 * @INPUT: Int 0 – Disable, 1 - Enable
307 *
308 * @OUTPUT: None
309 *
310 * This IOCTL enables or disables a short-guard interval.
311 *
312 * @E.g: iwpriv wlan0 shortgi <value>
313 *
314 * Supported Feature: STA
315 *
316 * Usage: Internal/External
317 *
318 * </ioctl>
319 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320#define WE_SET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530321/*
322 * <ioctl>
323 * enablertscts - enables or disables rts/cts.
324 *
325 * @INPUT: 1-Enable , 0-Disable
326 *
327 * @OUTPUT: None
328 *
329 * This IOCTL enables or disables rts/cts.
330 *
331 * @E.g: iwpriv wlan0 enablertscts <value>
332 *
333 * Supported Feature: STA
334 *
335 * Usage: Internal/External
336 *
337 * </ioctl>
338 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339#define WE_SET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530340/*
341 * <ioctl>
342 * chwidth - Set the channel bandwidth
343 *
344 * @INPUT: 0-20mhz to 3-160mhz
345 *
346 * @OUTPUT: None
347 *
348 * This IOTCL used to set the channel bandwidth
349 *
350 * @E.g: iwpriv wlan0 chwidth 1
351 *
352 * Supported Feature: STA
353 *
354 * Usage: Internal/External
355 *
356 * </ioctl>
357 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800358#define WE_SET_CHWIDTH 17
359#define WE_SET_ANI_EN_DIS 18
360#define WE_SET_ANI_POLL_PERIOD 19
361#define WE_SET_ANI_LISTEN_PERIOD 20
362#define WE_SET_ANI_OFDM_LEVEL 21
363#define WE_SET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530364/*
365 * <ioctl>
366 * cwmenable - Enables or disables the dynamic channel bandwidth
367 *
368 * @INPUT: 0-Disable, 1-Enable
369 *
370 * @OUTPUT: None
371 *
372 * This IOTCL used to enables or disables the dynamic channel bandwidth
373 *
374 * @E.g: iwpriv wlan0 cwmenable <value>
375 *
376 * Supported Feature: STA
377 *
378 * Usage: Internal/External
379 *
380 * </ioctl>
381 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382#define WE_SET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530383/*
384 * <ioctl>
385 * txchainmask - This IOCTL sets the current Tx chain mask
386 *
387 * @INPUT: Mask Value
388 *
389 * @OUTPUT: None
390 *
391 * This IOCTL sets the current Tx chain mask
392 *
393 * @E.g: iwpriv wlan0 txchainmask 1
394 *
395 * Supported Feature: STA
396 *
397 * Usage: Internal/External
398 *
399 * </ioctl>
400 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401#define WE_SET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530402/*
403 * <ioctl>
404 * rxchainmask - Sets the current Rx chain mask
405 *
406 * @INPUT: Mask Value
407 *
408 * @OUTPUT: None
409 *
410 * This IOCTL sets the current Rx chain mask. This command is the
411 * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
412 *
413 * @E.g: iwpriv wlan0 rxchainmask <value>
414 *
415 * Supported Feature: STA
416 *
417 * Usage: Internal/External
418 *
419 * </ioctl>
420 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421#define WE_SET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530422/*
423 * <ioctl>
424 * set11NRates - Fixes the Tx data rate of the 11N mode.
425 *
426 * @INPUT: 0x1b to 0x8f
427 *
428 * @OUTPUT: None
429 *
430 * This IOCTL fixes the Tx data rate of the 11N mode.
431 *
432 * @E.g: iwpriv wlan0 set11NRates 0x85
433 *
434 * Supported Feature: STA
435 *
436 * Usage: Internal/External
437 *
438 * </ioctl>
439 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440#define WE_SET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530441/*
442 * <ioctl>
443 * ampdu - Set the the maximum subframe of ampdu
444 *
445 * @INPUT: int 1 to int 63
446 *
447 * @OUTPUT: None
448 *
449 * This IOCTL sets the maximum subframe of ampdu.
450 *
451 * @E.g: iwpriv wlan0 ampdu 9
452 *
453 * Supported Feature: STA
454 *
455 * Usage: Internal/External
456 *
457 * </ioctl>
458 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459#define WE_SET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530460/*
461 * <ioctl>
462 * amsdu - Sets the maximum subframe of amsdu.
463 *
464 * @INPUT: int 1 to int 31
465 *
466 * @OUTPUT: None
467 *
468 * This IOCTL sets the maximum subframe of amsdu.
469 *
470 * @E.g: iwpriv wlan0 amsdu 9
471 *
472 * Supported Feature: STA
473 *
474 * Usage: Internal/External
475 *
476 * </ioctl>
477 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478#define WE_SET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530479/*
480 * <ioctl>
481 * txpow2g - current 2 GHz Tx power setting
482 *
483 * @INPUT: Tx power in dBm
484 *
485 * @OUTPUT: None
486 *
487 * This IOTCL used to set 2 ghz tx power
488 *
489 * @E.g: iwpriv wlan0 txpow2g
490 *
491 * Supported Feature: STA
492 *
493 * Usage: Internal/External
494 *
495 * </ioctl>
496 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800497#define WE_SET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530498/*
499 * <ioctl>
500 * txpow5g - Current 5 GHz tx power setting
501 *
502 * @INPUT: Tx power in dBm
503 *
504 * @OUTPUT: None
505 *
506 * This IOTCL used to set the 5 ghz txpower
507 *
508 * @E.g: iwpriv wlan0 txpow5g
509 *
510 * Supported Feature: STA
511 *
512 * Usage: Internal/External
513 *
514 * </ioctl>
515 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516#define WE_SET_TXPOW_5G 30
517/* Private ioctl for firmware debug log */
518#define WE_DBGLOG_LOG_LEVEL 31
519#define WE_DBGLOG_VAP_ENABLE 32
520#define WE_DBGLOG_VAP_DISABLE 33
521#define WE_DBGLOG_MODULE_ENABLE 34
522#define WE_DBGLOG_MODULE_DISABLE 35
523#define WE_DBGLOG_MOD_LOG_LEVEL 36
524#define WE_DBGLOG_TYPE 37
525#define WE_SET_TXRX_FWSTATS 38
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530526/*
527 * <ioctl>
528 * set11ACRates - Fixes the Tx data rate of 11AC
529 *
530 * @INPUT: 0x1 to 0x9
531 *
532 * @OUTPUT: None
533 *
534 * This IOCTL fixes the Tx data rate of 11AC.
535 *
536 * @E.g: iwpriv wlan0 set11ACRates 0x9
537 *
538 * Supported Feature: STA
539 *
540 * Usage: Internal/External
541 *
542 * </ioctl>
543 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800544#define WE_SET_VHT_RATE 39
545#define WE_DBGLOG_REPORT_ENABLE 40
546#define WE_TXRX_FWSTATS_RESET 41
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530547/*
548 * <ioctl>
549 * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
550 *
551 * @INPUT: Transmission power in dBm
552 *
553 * @OUTPUT: None
554 *
555 * This IOCTL sets the maximum transmit power for the 2.4-GHz band
556 * This setting does not persist over reboots
557 *
558 * @E.g: iwpriv wlan0 setTxMaxPower2G 10
559 *
560 * Supported Feature: STA
561 *
562 * Usage: Internal/External
563 *
564 * </ioctl>
565 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566#define WE_SET_MAX_TX_POWER_2_4 42
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530567/*
568 * <ioctl>
569 * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
570 *
571 * @INPUT: Transmission power in dBm
572 *
573 * @OUTPUT: None
574 *
575 * This IOCTL sets the maximum transmit power for the 5-GHz band
576 * This setting does not persist over reboots
577 *
578 * @E.g: iwpriv wlan0 setTxMaxPower5G 10
579 *
580 * Supported Feature: STA
581 *
582 * Usage: Internal/External
583 *
584 * </ioctl>
585 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800587#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588/* Private ioctl for packet powe save */
589#define WE_PPS_PAID_MATCH 45
590#define WE_PPS_GID_MATCH 46
591#define WE_PPS_EARLY_TIM_CLEAR 47
592#define WE_PPS_EARLY_DTIM_CLEAR 48
593#define WE_PPS_EOF_PAD_DELIM 49
594#define WE_PPS_MACADDR_MISMATCH 50
595#define WE_PPS_DELIM_CRC_FAIL 51
596#define WE_PPS_GID_NSTS_ZERO 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530597/*
598 * <ioctl>
599 * rssi_chk - Chek the rssi
600 *
601 * @INPUT: One argument as input
602 *
603 * @OUTPUT: rssi
604 * wlan0 rssi_chk:56
605 *
606 * This IOTCL used to chek rssi
607 *
608 * @E.g: iwpriv wlan0 rssi_chk <value>
609 *
610 * Supported Feature: STA
611 *
612 * Usage: Internal/External
613 *
614 * </ioctl>
615 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616#define WE_PPS_RSSI_CHECK 53
617#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530618/*
619 * <ioctl>
620 * htsmps - Sets the htsmps
621 *
622 * @INPUT: Atleast one int argument
623 *
624 * @OUTPUT: None
625 *
626 * This IOTCL used to set htsmps
627 *
628 * @E.g: iwpriv wlan0 htsmps <value>
629 *
630 * Supported Feature: STA
631 *
632 * Usage: Internal/External
633 *
634 * </ioctl>
635 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636#define WE_SET_HTSMPS 55
637/* Private ioctl for QPower */
638#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
639#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
640#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
641#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530642/*
643 * <ioctl>
644 * burst_enable - Enables or disables the burst feature
645 *
646 * @INPUT: 0-Disable, 1-Enable
647 *
648 * @OUTPUT: None
649 *
650 * This IOCTL enables or disables the burst feature.
651 *
652 * @E.g: iwpriv wlan0 burst_enable 0
653 *
654 * Supported Feature: STA
655 *
656 * Usage: Internal/External
657 *
658 * </ioctl>
659 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660#define WE_SET_BURST_ENABLE 60
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530661/*
662 * <ioctl>
663 * burst_dur - Enables or disables the burst feature
664 *
665 * @INPUT: int 1…..int 8191 in microseconds
666 *
667 * @OUTPUT: None
668 *
669 * This IOCTL sets the burst duration.
670 *
671 * @E.g: iwpriv wlan0 burst_dur <value>
672 *
673 * Supported Feature: STA
674 *
675 * Usage: Internal/External
676 *
677 * </ioctl>
678 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679#define WE_SET_BURST_DUR 61
680/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530681/*
682 * <ioctl>
683 * gtxHTMcs - Set the tx HTM value
684 *
685 * @INPUT: Atleast one int orgument
686 *
687 * @OUTPUT: None
688 *
689 * This IOTCL sets htm tx value
690 *
691 * @E.g: iwpriv wlan0 gtxHTMcs <value>
692 *
693 * Supported Feature: STA
694 *
695 * Usage: Internal/External
696 *
697 * </ioctl>
698 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699#define WE_SET_GTX_HT_MCS 62
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530700/*
701 * <ioctl>
702 * gtxVHTMcs - Set gtxVHTMcs value
703 *
704 * @INPUT: Atleast one int argument
705 *
706 * @OUTPUT: None
707 *
708 * This IOTCL used to set gtxVHTMcs value
709 *
710 * @E.g: iwpriv wlan0 gtxVHTMcs <value>
711 *
712 * Supported Feature: STA
713 *
714 * Usage: Internal/External
715 *
716 * </ioctl>
717 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718#define WE_SET_GTX_VHT_MCS 63
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530719/*
720 * <ioctl>
721 * gtxUsrCfg - Host request for GTX mask
722 *
723 * @INPUT: Atleast one int orgument
724 *
725 * @OUTPUT: None
726 *
727 * This IOTCL used send the host request for GTX mask
728 *
729 * @E.g: iwpriv wlan0 gtxUsrCfg <value>
730 *
731 * Supported Feature: STA
732 *
733 * Usage: Internal/External
734 *
735 * </ioctl>
736 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737#define WE_SET_GTX_USRCFG 64
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530738/*
739 * <ioctl>
740 * gtxThre - Set the tx threshold
741 *
742 * @INPUT: Atleast one int argument
743 *
744 * @OUTPUT: None
745 *
746 * This IOTCL used to set tx threshold
747 *
748 * @E.g: iwpriv wlan0 gtxThre <value>
749 *
750 * Supported Feature: STA
751 *
752 * Usage: Internal/External
753 *
754 * </ioctl>
755 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756#define WE_SET_GTX_THRE 65
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530757/*
758 * <ioctl>
759 * gtxMargin - Set the gtxMargin
760 *
761 * @INPUT: 1 to 32
762 *
763 * @OUTPUT: None
764 *
765 * This IOTCL use dto set gtxMargin
766 *
767 * @E.g: iwpriv wlan0 gtxMargini <value>
768 *
769 * Supported Feature: STA
770 *
771 * Usage: Internal/External
772 *
773 * </ioctl>
774 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800775#define WE_SET_GTX_MARGIN 66
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530776/*
777 * <ioctl>
778 * gtxStep - Set the gtxStep
779 *
780 * @INPUT: None
781 *
782 * @OUTPUT: None
783 *
784 * This IOTCL used to sets gtxStep
785 *
786 * @E.g: iwpriv wlan0 gtxStep <value>
787 *
788 * Supported Feature: STA
789 *
790 * Usage: Internal/External
791 *
792 * </ioctl>
793 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794#define WE_SET_GTX_STEP 67
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530795/*
796 * <ioctl>
797 * gtxMinTpc - Sets the gtxMinTpc
798 *
799 * @INPUT: Atleast one int argument
800 *
801 * @OUTPUT: None
802 *
803 * This IOTCL sets the tx MinTpc
804 *
805 * @E.g: iwpriv wlan0 gtxMinTpc <value>
806 *
807 * Supported Feature: STA
808 *
809 * Usage: Internal/External
810 *
811 * </ioctl>
812 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813#define WE_SET_GTX_MINTPC 68
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530814/*
815 * <ioctl>
816 * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
817 *
818 * @INPUT: Mask value
819 *
820 * @OUTPUT: None
821 *
822 * This IOTCL used to set gtxBWMask
823 *
824 * @E.g: iwpriv wlan0 gtxBWMask <value>
825 *
826 * Supported Feature: STA
827 *
828 * Usage: Internal/External
829 *
830 * </ioctl>
831 */
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530832
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530833#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530834/*
835 * <ioctl>
836 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
837 *
838 * @INPUT: set_value
839 *
840 * @OUTPUT: None
841 *
842 * This IOCTL is used to set the MCC latency value in milliseconds
843 * during STA-P2P concurrency.
844 *
845 * If 0ms latency is provided, then FW will set to a default.
846 * Otherwise, latency must be at least 30ms.
847 *
848 * @E.g: iwpriv wlan0 setMccLatency 40
849 *
850 *
851 * Supported Feature: Concurrency
852 *
853 * Usage: Internal/External
854 *
855 * </ioctl>
856 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530858
859/*
860 * <ioctl>
861 * setMccQuota- Set the quota for P2P cases
862 *
863 * @INPUT: set_value [0,100]
864 *
865 * @OUTPUT: None
866 *
867 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
868 *
869 * Currently used to set time quota for 2 MCC vdevs/adapters using
870 * (operating channel, quota) for each mode.
871 * The info is provided run time using iwpriv command:
872 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
873 * Note: the quota provided in command is for the same mode in cmd.
874 * HDD checks if MCC mode is active, gets the second mode and its
875 * operating chan.
876 * Quota for the 2nd role is calculated as 100 - quota of first mode.
877 *
878 * @E.g: iwpriv wlan0 setMccQuota 50
879 * iwpriv p2p0 setMccQuota 50
880 *
881 * Supported Feature: Concurrency
882 *
883 * Usage: Internal/External
884 *
885 * </ioctl>
886 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887#define WE_MCC_CONFIG_QUOTA 71
888/* Private IOCTL for debug connection issues */
889#define WE_SET_DEBUG_LOG 72
890#ifdef WE_SET_TX_POWER
891#undef WE_SET_TX_POWER
892#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530893/*
894 * <ioctl>
895 * setTxPower - Set the current transmit power
896 *
897 * @INPUT: Transmission power in dBm
898 *
899 * @OUTPUT: None
900 *
901 * This IOCTL sets the current transmit power.
902 * This setting does not persist over reboots.
903 *
904 * @E.g: iwpriv wlan0 setTxPower 10
905 *
906 * Supported Feature: STA
907 *
908 * Usage: Internal/External
909 *
910 * </ioctl>
911 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912#define WE_SET_TX_POWER 74
913/* Private ioctl for earlyrx power save feature */
914#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
915#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
916#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
917#define WE_SET_EARLY_RX_SLOP_STEP 78
918#define WE_SET_EARLY_RX_INIT_SLOP 79
919#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530920/*
921 * <ioctl>
922 * setMcRate - Set the data rate for multicast data
923 *
924 * @INPUT: 1 to 32
925 *
926 * @OUTPUT: None
927 *
928 * This IOCTL sets the data rate for multicast data. Note that this command
929 * is allowed only in STA, IBSS, or QCMobileAP mode
930 *
931 * @E.g: iwpriv wlan0 setMcRate <value>
932 *
933 * Supported Feature: STA
934 *
935 * Usage: Internal/External
936 *
937 * </ioctl>
938 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939#define WE_SET_MC_RATE 81
940#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
941/* Private ioctl for packet power save */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530942/*
943 * <ioctl>
944 * 5g_ebt - Sets the 5g_ebt
945 *
946 * @INPUT: <value>
947 *
948 * @OUTPUT: None
949 *
950 * This IOTCL used to set 5g_ebt
951 *
952 * @E.g: iwpriv wlan0 5g_ebt <value>
953 *
954 * Supported Feature: STA
955 *
956 * Usage: Internal/External
957 *
958 * </ioctl>
959 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960#define WE_PPS_5G_EBT 83
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530961/*
962 * <ioctl>
963 * cts_cbw - Set CTS channel BW for dynamic BW adjustment
964 *
965 * @INPUT: 20 t0 160
966 *
967 * @OUTPUT: None
968 *
969 * This IOTCL used to set CTS channel BW for dynamic BW adjustment
970 *
971 * @E.g: iwpriv wlan0 cts_cbw <value>
972 *
973 * Supported Feature: STA
974 *
975 * Usage: Internal/External
976 *
977 * </ioctl>
978 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979#define WE_SET_CTS_CBW 84
980#define WE_DUMP_STATS 85
981#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530982/* Private sub ioctl for starting/stopping the profiling */
983#define WE_START_FW_PROFILE 87
Abhishek Singh3c507012016-12-01 11:15:42 +0530984/*
985 * <ioctl>
986 * setChanChange - Initiate channel change
987 *
988 * @INPUT: channel number to switch to.
989 *
990 * @OUTPUT: None
991 *
992 * This IOCTL is used to initiate a channel change.
993 * If called on STA/CLI interface it will send the
994 * ECSA action frame to the connected SAP/GO asking to
995 * initiate the ECSA, if supported.
996 * If called on SAP/GO interface it will initiate
997 * ECSA and ask connected peers to move to new channel.
998 *
999 * @E.g: iwpriv wlan0 setChanChange <channel>
1000 * iwpriv wlan0 setChanChange 1
1001 *
1002 * Supported Feature: ECSA
1003 *
1004 * Usage: Internal/External
1005 *
1006 * </ioctl>
1007 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +05301008#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05301009#define WE_SET_CONC_SYSTEM_PREF 89
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010
1011/* Private ioctls and their sub-ioctls */
1012#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
1013#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014#define WE_SET_SAP_CHANNELS 3
1015#define WE_GET_WLAN_DBG 4
1016#define WE_GET_MAX_ASSOC 6
1017/* 7 is unused */
1018#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +05301019
1020/*
1021 * <ioctl>
1022 * getconcurrency - Get concurrency mode
1023 *
1024 * @INPUT: None
1025 *
1026 * @OUTPUT: It shows concurrency value
1027 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
1028 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
1029 * 8:OCB 9:EPPING 10:QVIT 11:NDI
1030 *
1031 * This IOCTL is used to retrieve concurrency mode.
1032 *
1033 * @E.g: iwpriv wlan0 getconcurrency
1034 * wlan0 getconcurrency:5
1035 * Above value shows STA+P2P_Client
1036 *
1037 * Supported Feature: Concurrency
1038 *
1039 * Usage: Internal/External
1040 *
1041 * </ioctl>
1042 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043#define WE_GET_CONCURRENCY_MODE 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301044/*
1045 * <ioctl>
1046 * get_nss - Get the number of spatial STBC streams (NSS)
1047 *
1048 * @INPUT: None
1049 *
1050 * @OUTPUT: NSS
1051 * wlan0 get_nss:2
1052 *
1053 * This IOTCL used to get the number of spatial STBC streams
1054 *
1055 * @E.g: iwpriv wlan0 get_nss
1056 *
1057 * Supported Feature: STA
1058 *
1059 * Usage: Internal/External
1060 *
1061 * </ioctl>
1062 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063#define WE_GET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301064/*
1065 * <ioctl>
1066 * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1067 *
1068 * @INPUT: None
1069 *
1070 * @OUTPUT: ldpc
1071 * wlan0 get_ldpc:1
1072 *
1073 * This IOTCL used to gets the low density parity check (LDPC)
1074 *
1075 * @E.g: iwpriv wlan0 get_ldpc
1076 *
1077 * Supported Feature: STA
1078 *
1079 * Usage: Internal/External
1080 *
1081 * </ioctl>
1082 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083#define WE_GET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301084/*
1085 * <ioctl>
1086 * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1087 *
1088 * @INPUT: None
1089 *
1090 * @OUTPUT: TXSTBC
1091 * wlan0 get_tx_stbc:1
1092 *
1093 * This IOTCL get the value of the current Tx space time block code (STBC)
1094 *
1095 * @E.g: iwpriv wlan0 get_tx_stbc
1096 *
1097 * Supported Feature: STA
1098 *
1099 * Usage: Internal/External
1100 *
1101 * </ioctl>
1102 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103#define WE_GET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301104/*
1105 * <ioctl>
1106 * get_rx_stbc - Gets the value of the current Rx STBC
1107 *
1108 * @INPUT: None
1109 *
1110 * @OUTPUT: Rx STBC
1111 * wlan0 get_rx_stbc:1
1112 *
1113 * This IOTCL used to get the value of the current Rx STBC
1114 *
1115 * @E.g: iwpriv wlan0 get_rx_stbc
1116 *
1117 * Supported Feature: STA
1118 *
1119 * Usage: Internal/External
1120 *
1121 * </ioctl>
1122 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123#define WE_GET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301124/*
1125 * <ioctl>
1126 * get_shortgi - Get the value of the current short GI setting
1127 *
1128 * @INPUT: None
1129 *
1130 * @OUTPUT: Enable/disable of shortgi
1131 * wlan0 get_shortgi:1
1132 *
1133 * This IOCTL gets the value of the current short GI setting
1134 *
1135 * @E.g: iwpriv wlan0 get_shortgi
1136 *
1137 * Supported Feature: STA
1138 *
1139 * Usage: Internal/External
1140 *
1141 * </ioctl>
1142 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143#define WE_GET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301144/*
1145 * <ioctl>
1146 * get_rtscts - Get the value of the current RTS/CTS setting.
1147 *
1148 * @INPUT: None
1149 *
1150 * @OUTPUT: Enable/disable of RTS/CTS
1151 * wlan0 get_rtscts:33
1152 *
1153 * This IOTCL get the value of the current RTS/CTS setting.
1154 *
1155 * @E.g: iwpriv wlan0 get_rtscts
1156 *
1157 * Supported Feature: STA
1158 *
1159 * Usage: Internal/External
1160 *
1161 * </ioctl>
1162 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163#define WE_GET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301164/*
1165 * <ioctl>
1166 * get_chwidth - Get the current channel width setting
1167 *
1168 * @INPUT: None
1169 *
1170 * @OUTPUT: channel width
1171 * wlan0 get_chwidth:0
1172 *
1173 * This IOTCL get the current channel width setting.
1174 *
1175 * @E.g: iwpriv wlan0 get_chwidth
1176 *
1177 * Supported Feature: STA
1178 *
1179 * Usage: Internal/External
1180 *
1181 * </ioctl>
1182 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001183#define WE_GET_CHWIDTH 17
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301184/*
1185 * <ioctl>
1186 * get_anienable - Get the anienable
1187 *
1188 * @INPUT: None
1189 *
1190 * @OUTPUT:
1191 * wlan0 get_anienable:0
1192 *
1193 * This IOTCL get the anienable
1194 *
1195 * @E.g: iwpriv wlan0 get_anienable
1196 *
1197 * Supported Feature: STA
1198 *
1199 * Usage: Internal/External
1200 *
1201 * </ioctl>
1202 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203#define WE_GET_ANI_EN_DIS 18
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301204/*
1205 * <ioctl>
1206 * get_aniplen - Get the aniplen
1207 *
1208 * @INPUT: None
1209 *
1210 * @OUTPUT:
1211 * wlan0 get_aniplen:0
1212 *
1213 * This IOTCL get the aniplen
1214 *
1215 * @E.g: iwpriv wlan0 get_aniplen
1216 *
1217 * Supported Feature: STA
1218 *
1219 * Usage: Internal/External
1220 *
1221 * </ioctl>
1222 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223#define WE_GET_ANI_POLL_PERIOD 19
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301224/*
1225 * <ioctl>
1226 * get_anilislen- Get the anilislen
1227 *
1228 * @INPUT: None
1229 *
1230 * @OUTPUT:
1231 * wlan0 get_anilislen:0
1232 *
1233 * This IOTCL used to get anilislen
1234 *
1235 * @E.g: iwpriv wlan0 get_anilislen
1236 *
1237 * Supported Feature: STA
1238 *
1239 * Usage: Internal/External
1240 *
1241 * </ioctl>
1242 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243#define WE_GET_ANI_LISTEN_PERIOD 20
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301244/*
1245 * <ioctl>
1246 * get_aniofdmlvl - Get the OFDM level
1247 *
1248 * @INPUT: None
1249 *
1250 * @OUTPUT: OFDM
1251 * wlan0 get_aniofdmlvl:0
1252 *
1253 * This IOTCL used to get ofdm level
1254 *
1255 * @E.g: iwpriv wlan0 get_aniofdmlvl
1256 *
1257 * Supported Feature: STA
1258 *
1259 * Usage: Internal/External
1260 *
1261 * </ioctl>
1262 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263#define WE_GET_ANI_OFDM_LEVEL 21
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301264/*
1265 * <ioctl>
1266 * get_aniccklvl - Get the cck level
1267 *
1268 * @INPUT: None
1269 *
1270 * @OUTPUT:
1271 * wlan0 get_aniccklvl:0
1272 *
1273 * This IOTCL used to get cck level
1274 *
1275 * @E.g: iwpriv wlan0 get_aniccklvl
1276 *
1277 * Supported Feature: STA
1278 *
1279 * Usage: Internal/External
1280 *
1281 * </ioctl>
1282 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283#define WE_GET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301284/*
1285 * <ioctl>
1286 * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1287 *
1288 * @INPUT: None
1289 *
1290 * @OUTPUT: Enable/disable dynamic channel bandwidth
1291 * wlan0 get_cwmenable:0
1292 *
1293 * This IOTCL get the value of the dynamic channel bandwidth setting
1294 *
1295 * @E.g: iwpriv wlan0 get_cwmenable
1296 *
1297 * Supported Feature: STA
1298 *
1299 * Usage: Internal/External
1300 *
1301 * </ioctl>
1302 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303#define WE_GET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301304/*
1305 * <ioctl>
1306 * get_txchainmask - Get the txchainmask that was set
1307 *
1308 * @INPUT: None
1309 *
1310 * @OUTPUT: txchainmask
1311 * wlan0 get_txchainmask:1
1312 *
1313 * This IOCTL gets the txchainmask that was set
1314 * This command is useful if it was previously set
1315 *
1316 * @E.g: iwpriv wlan0 get_txchainmask
1317 *
1318 * Supported Feature: STA
1319 *
1320 * Usage: Internal/External
1321 *
1322 * </ioctl>
1323 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324#define WE_GET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301325/*
1326 * <ioctl>
1327 * get_rxchainmask - Get the rxchainmask that was set
1328 *
1329 * @INPUT: None
1330 *
1331 * @OUTPUT: rxchainmask
1332 * wlan0 get_rxchainmask:1
1333 *
1334 * This IOCTL gets the rxchainmask that was set
1335 * This command is useful only if it was previously set.
1336 *
1337 * @E.g: iwpriv wlan0 get_rxchainmask
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_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301346/*
1347 * <ioctl>
1348 * get_11nrate - Get the fixed Tx data rate
1349 *
1350 * @INPUT: None
1351 *
1352 * @OUTPUT: Using this command does not return the same value as set
1353 * wlan0 get_11nrate:0
1354 *
1355 * This IOCTL gets the fixed Tx data rate
1356 * This command is useful only if setting the fixed Tx rate.
1357 *
1358 * @E.g: iwpriv wlan0 get_11nrate
1359 *
1360 * Supported Feature: STA
1361 *
1362 * Usage: Internal/External
1363 *
1364 * </ioctl>
1365 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366#define WE_GET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301367/*
1368 * <ioctl>
1369 * get_ampdu - Get the maximum subframe of ampdu
1370 *
1371 * @INPUT: None
1372 *
1373 * @OUTPUT: Maximum subframe of ampdu
1374 * wlan0 get_ampdu:1
1375 *
1376 * This IOCTL gets the maximum subframe of ampdu
1377 * This command is useful only if setting ampdu.
1378 *
1379 * @E.g: iwpriv wlan0 get_ampdu
1380 *
1381 * Supported Feature: STA
1382 *
1383 * Usage: Internal/External
1384 *
1385 * </ioctl>
1386 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387#define WE_GET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301388/*
1389 * <ioctl>
1390 * get_amsdu - Get the maximum subframe of amsdu
1391 *
1392 * @INPUT: None
1393 *
1394 * @OUTPUT: Maximum subframe of amsdu
1395 * wlan0 get_amsdu:1
1396 *
1397 * This IOCTL gets the maximum subframe of amsdu.
1398 * This command is useful only if setting amsdu
1399 *
1400 * @E.g: iwpriv wlan0 get_amsdu
1401 *
1402 * Supported Feature: STA
1403 *
1404 * Usage: Internal/External
1405 *
1406 * </ioctl>
1407 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408#define WE_GET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301409/*
1410 * <ioctl>
1411 * get_txpow2g - Get the current 2 GHz Tx power setting
1412 *
1413 * @INPUT: None
1414 *
1415 * @OUTPUT: Tx Power in dbm
1416 * wlan0 get_txpow2g:0
1417 *
1418 * This IOCTL gets the current 2 GHz Tx power setting
1419 * This command is useful if setting Tx power
1420 *
1421 * @E.g: iwpriv wlan0 get_txpow2g
1422 *
1423 * Supported Feature: STA
1424 *
1425 * Usage: Internal/External
1426 *
1427 * </ioctl>
1428 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429#define WE_GET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301430/*
1431 * <ioctl>
1432 * get_txpow5g - Get the current 5 GHz Tx power setting
1433 *
1434 * @INPUT: None
1435 *
1436 * @OUTPUT: Tx Power in dbm
1437 * wlan0 get_txpow5g:0
1438 *
1439 * This IOCTL gets the current 5 GHz Tx power setting
1440 * This command is useful if setting Tx power
1441 *
1442 * @E.g: iwpriv wlan0 get_txpow5g
1443 *
1444 * Supported Feature: STA
1445 *
1446 * Usage: Internal/External
1447 *
1448 * </ioctl>
1449 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -08001451/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452#define WE_GET_PPS_PAID_MATCH 32
1453#define WE_GET_PPS_GID_MATCH 33
1454#define WE_GET_PPS_EARLY_TIM_CLEAR 34
1455#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
1456#define WE_GET_PPS_EOF_PAD_DELIM 36
1457#define WE_GET_PPS_MACADDR_MISMATCH 37
1458#define WE_GET_PPS_DELIM_CRC_FAIL 38
1459#define WE_GET_PPS_GID_NSTS_ZERO 39
1460#define WE_GET_PPS_RSSI_CHECK 40
1461/* Private ioctl for QPower */
1462#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
1463#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
1464#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
1465#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301466/*
1467 * <ioctl>
1468 * get_burst_en - Enables or disables the burst feature
1469 *
1470 * @INPUT: None
1471 *
1472 * @OUTPUT: Enable/disable of burst feature
1473 * wlan0 get_burst_en:1
1474 *
1475 * This IOCTL enables or disables the burst feature
1476 *
1477 * @E.g: iwpriv wlan0 get_burst_en
1478 *
1479 * Supported Feature:STA
1480 *
1481 * Usage: Internal/External
1482 *
1483 * </ioctl>
1484 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485#define WE_GET_BURST_ENABLE 45
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301486/*
1487 * <ioctl>
1488 * get_burst_dur - Get the burst duration
1489 *
1490 * @INPUT: None
1491 *
1492 * @OUTPUT: Duration in microseconds
1493 * wlan0 get_burst_dur:8160
1494 *
1495 * This IOCTL gets the burst duration
1496 * This command is useful if setting burst enable
1497 *
1498 * @E.g: iwpriv wlan0 get_burst_dur
1499 *
1500 * Supported Feature: STA
1501 *
1502 * Usage: Internal/External
1503 *
1504 * </ioctl>
1505 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506#define WE_GET_BURST_DUR 46
1507/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301508/*
1509 * <ioctl>
1510 * get_gtxHTMcs - Get the tx HTM
1511 *
1512 * @INPUT: None
1513 *
1514 * @OUTPUT: HTM
1515 * wlan0 get_gtxHTMcs:32896
1516 *
1517 * This IOTCL used to get HTM
1518 *
1519 * @E.g: iwpriv wlan0 get_gtxHTMcs
1520 *
1521 * Supported Feature: STA
1522 *
1523 * Usage: Internal/External
1524 *
1525 * </ioctl>
1526 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527#define WE_GET_GTX_HT_MCS 47
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301528/*
1529 * <ioctl>
1530 * get_gtxVHTMcs - Get the VHTM
1531 *
1532 * @INPUT: None
1533 *
1534 * @OUTPUT: VHTM
1535 * wlan0 get_gtxVHTMcs:524800
1536 *
1537 * This IOTCL used to get the VHTM
1538 *
1539 * @E.g: iwpriv wlan0 get_gtxVHTMcs
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_GTX_VHT_MCS 48
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301548/*
1549 * <ioctl>
1550 * get_gtxUsrCfg - Get the tx cfg
1551 *
1552 * @INPUT: None
1553 *
1554 * @OUTPUT: TXCFG
1555 * wlan0 get_gtxUsrCfg:32
1556 *
1557 * This IOTCL used to get the tx cfg
1558 *
1559 * @E.g: iwpriv wlan0 get_gtxUsrCfg
1560 *
1561 * Supported Feature: STA
1562 *
1563 * Usage: Internal/External
1564 *
1565 * </ioctl>
1566 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567#define WE_GET_GTX_USRCFG 49
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301568/*
1569 * <ioctl>
1570 * get_gtxThre - Get the tx threshold
1571 *
1572 * @INPUT: None
1573 *
1574 * @OUTPUT: Threshold
1575 * wlan0 get_gtxThre:3
1576 *
1577 * This IOCTL is used to get tx threshold
1578 *
1579 * @E.g: iwpriv wlan0 get_gtxThre
1580 *
1581 * Supported Feature: STA
1582 *
1583 * Usage: Internal/External
1584 *
1585 * </ioctl>
1586 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587#define WE_GET_GTX_THRE 50
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301588/*
1589 * <ioctl>
1590 * get_gtxMargin - Get the tx margin
1591 *
1592 * @INPUT: None
1593 *
1594 * @OUTPUT: GTXMARGIN
1595 * wlan0 get_gtxMargin:2
1596 *
1597 * This IOCTL is used to set tx margin
1598 *
1599 * @E.g: iwpriv wlan0 get_gtxMargin
1600 *
1601 * Supported Feature: STA
1602 *
1603 * Usage: Internal/External
1604 *
1605 * </ioctl>
1606 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607#define WE_GET_GTX_MARGIN 51
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301608/*
1609 * <ioctl>
1610 * get_gtxStep - Get the tx step
1611 *
1612 * @INPUT: None
1613 *
1614 * @OUTPUT: GTXSTEP
1615 * wlan0 get_gtxStep:0
1616 *
1617 * This IOCTL is used to get the gtx step
1618 *
1619 * @E.g: iwpriv wlan0 get_gtxStep
1620 *
1621 * Supported Feature: STA
1622 *
1623 * Usage: Internal/External
1624 *
1625 * </ioctl>
1626 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627#define WE_GET_GTX_STEP 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301628/*
1629 * <ioctl>
1630 * get_gtxMinTpc - Get the tx miminum tpc
1631 *
1632 * @INPUT: None
1633 *
1634 * @OUTPUT: TPC
1635 * wlan0 get_gtxMinTpc:0
1636 *
1637 * This IOCTL is used to get tx miminum tpc
1638 *
1639 * @E.g: iwpriv wlan0 get_gtxMinTpc
1640 *
1641 * Supported Feature: STA
1642 *
1643 * Usage: Internal/External
1644 *
1645 * </ioctl>
1646 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647#define WE_GET_GTX_MINTPC 53
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301648/*
1649 * <ioctl>
1650 * get_gtxBWMask - Get the tx BW MASK
1651 *
1652 * @INPUT: None
1653 *
1654 * @OUTPUT: MASK
1655 * wlan0 get_gtxBWMask:15
1656 *
1657 * This IOCTL is used get gtx bw mask
1658 *
1659 * @E.g: iwpriv wlan0 get_gtxBWMask
1660 *
1661 * Supported Feature: STA
1662 *
1663 * Usage: Internal/External
1664 *
1665 * </ioctl>
1666 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667#define WE_GET_GTX_BWMASK 54
1668#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001669#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07001670#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671
1672/* Private ioctls and their sub-ioctls */
1673#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
1674
1675/* Private ioctls and their sub-ioctls */
1676#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
1677#define WE_WOWL_ADD_PTRN 1
1678#define WE_WOWL_DEL_PTRN 2
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679#define WE_NEIGHBOR_REPORT_REQUEST 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301680/*
1681 * <ioctl>
1682 * set_ap_wps_ie - Set the P2P IE of the probe response
1683 *
1684 * @INPUT: string
1685 *
1686 * @OUTPUT: None
1687 *
1688 * This IOCTL sets the P2P IE of the probe response
1689 *
1690 * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1691 *
1692 * Supported Feature: STA
1693 *
1694 * Usage: Internal/External
1695 *
1696 * </ioctl>
1697 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698#define WE_SET_AP_WPS_IE 4 /* This is called in station mode to set probe rsp ie. */
1699#define WE_SET_CONFIG 5
1700
1701/* Private ioctls and their sub-ioctls */
1702#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
1703#define WE_SET_WLAN_DBG 1
1704#define WE_SET_DP_TRACE 2
1705#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05301706#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707
1708/* Private ioctls and their sub-ioctls */
1709#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
1710#define WE_WLAN_VERSION 1
1711#define WE_GET_STATS 2
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301712/*
1713 * <ioctl>
1714 * getConfig - gets the values of all configurations listed in WCNSS
1715 *
1716 * @INPUT: None
1717 *
1718 * @OUTPUT: Current configuration to the sys log
1719 * wlan0 getConfig: WLAN configuration written to system log
1720 *
1721 * This IOCTL gets the values of all configurations listed in WCNSS
1722 *
1723 * @E.g: iwpriv wlan0 getConfig
1724 *
1725 * Supported Feature: STA
1726 *
1727 * Usage: Internal/External
1728 *
1729 * </ioctl>
1730 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731#define WE_GET_CFG 3
1732#define WE_GET_WMM_STATUS 4
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301733/*
1734 * <ioctl>
1735 * getChannelList - Get the available channel list while in QCMobileAP
1736 *
1737 * @INPUT: None
1738 *
1739 * @OUTPUT: Channel list
1740 * wlan0 getChannelList:36 US 1..165
1741 *
1742 * This IOCTL gets the available channel list while in QCMobileAP
1743 *
1744 * @E.g: iwpriv wlan0 getChannelList
1745 *
1746 * Supported Feature: STA
1747 *
1748 * Usage: Internal/External
1749 *
1750 * </ioctl>
1751 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001752#define WE_GET_CHANNEL_LIST 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301753/*
1754 * <ioctl>
1755 * getRSSI - Get the Received Signal Strength Indicator
1756 *
1757 * @INPUT: None
1758 *
1759 * @OUTPUT: RSSI
1760 * wlan0 getRSSI:rsssi=-32
1761 *
1762 * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1763 *
1764 * @E.g: iwpriv wlan0 getRSSI
1765 *
1766 * Supported Feature: STA
1767 *
1768 * Usage: Internal/External
1769 *
1770 * </ioctl>
1771 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -08001773
1774/*
1775 * <ioctl>
1776 * getSuspendStats - Get suspend/resume stats
1777 *
1778 * @INPUT: None
1779 *
1780 * @OUTPUT: character string containing formatted suspend/resume stats
1781 *
1782 * This ioctl is used to get suspend/resume stats formatted for display.
1783 * Currently it includes suspend/resume counts, wow wake up reasons, and
1784 * suspend fail reasons.
1785 *
1786 * @E.g: iwpriv wlan0 getSuspendStats
1787 * iwpriv wlan0 getSuspendStats
1788 *
1789 * Supported Feature: suspend/resume
1790 *
1791 * Usage: Internal
1792 *
1793 * </ioctl>
1794 */
1795#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05301797/*
1798 * <ioctl>
1799 * getTdlsPeers - Get all TDLS peers.
1800 *
1801 * @INPUT: None
1802 *
1803 * @OUTPUT: Returns the MAC address of all the TDLS peers
1804 * wlan0 getTdlsPeers:
1805 * MAC Id cap up RSSI
1806 * ---------------------------------
1807 * 00:0a:f5:0e:bd:18 2 Y Y -44
1808 * 00:0a:f5:bf:0e:12 0 N N 0
1809 *
1810 * This IOCTL is used to get all TDLS peers.
1811 *
1812 * @E.g: iwpriv wlan0 getTdlsPeers
1813 *
1814 * Supported Feature: TDLS
1815 *
1816 * Usage: Internal/External
1817 *
1818 * </ioctl>
1819 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820#define WE_GET_TDLS_PEERS 8
1821#endif
1822#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +05301823/*
1824 * <ioctl>
1825 * getPMFInfo - get the PMF info of the connected session
1826 *
1827 * @INPUT: None
1828 *
1829 * @OUTPUT:
1830 * wlan0 getPMFInfo:
1831 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
1832 * Number of Unprotected Disassocs 0
1833 * Number of Unprotected Deauths 0
1834 *
1835 * This IOCTL is used to get the PMF stats/status of the current
1836 * connection.
1837 *
1838 * @e.g:iwpriv wlan0 getPMFInfo
1839 *
1840 * Supported Feature: PMF
1841 *
1842 * Usage: Internal/External
1843 *
1844 * </ioctl>
1845 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846#define WE_GET_11W_INFO 9
1847#endif
1848#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +05301849/*
1850 * <ioctl>
1851 * getIbssSTAs - get ibss sta info
1852 *
1853 * @INPUT: None
1854 *
1855 * @OUTPUT: Give the MAC of the IBSS STA
1856 * wlan0 getIbssSTAs:
1857 * 1 .8c:fd:f0:01:9c:bf
1858 *
1859 * This IOCTL is used to get ibss sta info
1860 *
1861 * @E.g: iwpriv wlan0 getIbssSTAs
1862 *
1863 * Supported Feature: IBSS
1864 *
1865 * Usage: Internal/External
1866 *
1867 * </ioctl>
1868 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001869#define WE_GET_IBSS_STA_INFO 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301870/*
1871 * <ioctl>
1872 * getphymode - Get the current phymode.
1873 *
1874 * @INPUT: None
1875 *
1876 * @OUTPUT: In phymode
1877 * wlan0 getphymode:AUTO MODE
1878 *
1879 * This IOCTL used to gets the current phymode.
1880 *
1881 * @E.g: iwpriv wlan0 getphymode
1882 *
1883 * Supported Feature: STA
1884 *
1885 * Usage: Internal/External
1886 *
1887 * </ioctl>
1888 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889#define WE_GET_PHYMODE 12
Naveen Rawat910726a2017-03-06 11:42:51 -08001890
1891/*
1892 * <ioctl>
1893 * getOemDataCap - Get the oem data caps.
1894 *
1895 * @INPUT: None
1896 *
1897 * @OUTPUT: oem data capability
1898 *
1899 * This IOCTL used to gets the current oem data cap.
1900 *
1901 * @E.g: iwpriv wlan0 getOemDataCap
1902 *
1903 * Usage: Internal/External
1904 *
1905 * </ioctl>
1906 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907#define WE_GET_OEM_DATA_CAP 13
Naveen Rawat910726a2017-03-06 11:42:51 -08001908
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301909/*
1910 * <ioctl>
1911 * getSNR - Enable SNR Monitoring
1912 *
1913 * @INPUT: None
1914 *
1915 * @OUTPUT: Signal strength/ratio
1916 * wlan0 getSNR:1
1917 *
1918 * This IOCTL is used to get ibss sta info
1919 *
1920 * @E.g: iwpriv wlan0 getSNR
1921 *
1922 * Supported Feature: STA
1923 *
1924 * Usage: Internal/External
1925 *
1926 * </ioctl>
1927 */
Naveen Rawat910726a2017-03-06 11:42:51 -08001928
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +05301930#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931
1932/* Private ioctls and their sub-ioctls */
1933#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
1934#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +05301935/*
1936 * <ioctl>
1937 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
1938 *
1939 * @INPUT: None
1940 *
1941 * @OUTPUT: print ibss peer in info logs
1942 * pPeerInfo->numIBSSPeers = 1
1943 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
1944 *
1945 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
1946 * in info logs
1947 *
1948 * @E.g: iwpriv wlan0 ibssPeerInfoAll
1949 *
1950 * Supported Feature: IBSS
1951 *
1952 * Usage: Internal/External
1953 *
1954 * </ioctl>
1955 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001956#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -08001957/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08001959#define WE_GET_FW_PROFILE_DATA 18
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +05301960/*
1961 * <ioctl>
1962 * stop_obss_scan - Stop obss scan
1963 *
1964 * @INPUT: None
1965 *
1966 * @OUTPUT: None
1967 *
1968 * This IOCTL is used to stop obss scan
1969 *
1970 * @E.g: iwpriv wlan0 stop_obss_scan
1971 *
1972 * Supported Feature: Scan
1973 *
1974 * Usage: Internal/External
1975 *
1976 * </ioctl>
1977 */
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08001978#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979
1980/* Private ioctls and their sub-ioctls */
1981#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
1982
1983#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +05301984/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985
Manjeet Singhf82ed072016-07-08 11:40:00 +05301986#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987
1988#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05301989/*
1990 * <ioctl>
1991 * setTdlsConfig - Set TDLS configuration parameters.
1992 *
1993 * @INPUT: 11 TDLS configuration parameters
1994 * @args[0]: tdls: [0..2]
1995 * @args[1]: tx_period_t: [1000..4294967295UL]
1996 * @args[2]: tx_packet_n: [0..4294967295UL]
1997 * @args[3]: [discovery_period is not used anymore]
1998 * @args[4]: discovery_tries_n: [1..100]
1999 * @args[5]: [idle_timeout is not used anymore]
2000 * @args[6]: idle_packet_n: [0..40000]
2001 * @args[7]: [rssi_hysteresis is not used anymore]
2002 * @args[8]: rssi_trigger_threshold: [-120..0]
2003 * @args[9]: rssi_teardown_threshold: [-120..0]
2004 * @args[10]: rssi_delta: [-30..0]
2005 *
2006 * @OUTPUT: None
2007 *
2008 * This IOCTL is used to set the TDLS configuration parameters.
2009 *
2010 * @E.g: iwpriv wlan0 setTdlsConfig tdls tx_period_t tx_packet_n
2011 * discovery_period discovery_tries_n idle_timeout
2012 * idle_packet_n rssi_hysteresis rssi_trigger_threshold
2013 * rssi_teardown_threshold rssi_delta
2014 * iwpriv wlan0 setTdlsConfig 1 1500 40 1 5 1 5 0 -70 -70 -10
2015 *
2016 * Supported Feature: TDLS
2017 *
2018 * Usage: Internal/External
2019 *
2020 * </ioctl>
2021 */
2022
2023
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024#define WE_TDLS_CONFIG_PARAMS 5
2025#endif
Abhishek Singh49b654e2016-12-01 16:11:17 +05302026/*
2027 * <ioctl>
2028 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
2029 *
2030 * @INPUT: staid
2031 *
2032 * @OUTPUT: print ibss peer corresponding to staid in info logs
2033 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2034 *
2035 * This IOCTL is used to print the specific ibss peers's MAC,
2036 * rate and RSSI in info logs
2037 *
2038 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
2039 * iwpriv wlan0 ibssPeerInfo 0
2040 *
2041 * Supported Feature: IBSS
2042 *
2043 * Usage: Internal/External
2044 *
2045 * </ioctl>
2046 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002047#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048#define WE_UNIT_TEST_CMD 7
2049
2050#define WE_MTRACE_DUMP_CMD 8
2051#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
2052
2053
2054#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2055#define WE_LED_FLASHING_PARAM 10
2056#endif
2057
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302058/*
2059 * <ioctl>
2060 * pm_clist - Increments the index value of the concurrent connection list
2061 * and update with the input parameters provided.
2062 *
2063 * @INPUT: Following 8 arguments:
2064 * @vdev_id: vdev id
2065 * @tx_streams: TX streams
2066 * @rx_streams: RX streams
2067 * @chain_mask: Chain mask
2068 * @type: vdev_type
2069 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2070 * @sub_type: vdev_subtype
2071 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2072 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2073 * @channel: Channel
2074 * @mac: Mac id
2075 *
2076 * @OUTPUT: None
2077 *
2078 * This IOCTL is used to increments the index value of the concurrent connection
2079 * list and update with the input parameters provided.
2080 *
2081 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
2082 * sub_type channel mac
2083 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
2084 *
2085 * Supported Feature: DBS
2086 *
2087 * Usage: Internal/External
2088 *
2089 * </ioctl>
2090 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302092
2093/*
2094 * <ioctl>
2095 * pm_dlist - Delete the index from the concurrent connection list that is
2096 * present in the given vdev_id.
2097 *
2098 * @INPUT: delete_all, vdev_id
2099 * @delete_all: delete all indices
2100 * @vdev_id: vdev id
2101 *
2102 * @OUTPUT: None
2103 *
2104 * This IOCTL is used to delete the index from the concurrent connection list
2105 * that is present in the given vdev_id.
2106 *
2107 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
2108 * iwpriv wlan0 pm_dlist 0 1
2109 *
2110 * Supported Feature: DBS
2111 *
2112 * Usage: Internal/External
2113 *
2114 * </ioctl>
2115 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302117
2118/*
2119 * <ioctl>
2120 * pm_dbs - Set dbs capability and system preference
2121 *
2122 * @INPUT: dbs, system_pref
2123 * @dbs: Value of DBS capability to be set
2124 * @system_pref: System preference
2125 * 0:CDS_THROUGHPUT 1: CDS_POWERSAVE 2: CDS_LATENCY
2126 *
2127 * @OUTPUT: None
2128 *
2129 * This IOCTL is used to set dbs capability and system preference.
2130 *
2131 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
2132 * iwpriv wlan0 pm_dbs 1 0
2133 *
2134 * Supported Feature: DBS
2135 *
2136 * Usage: Internal/External
2137 *
2138 * </ioctl>
2139 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302141
2142/*
2143 * <ioctl>
2144 * pm_pcl - Set pcl for concurrency mode.
2145 *
2146 * @INPUT: cds_con_mode
2147 * @cds_con_mode: concurrency mode for PCL table
2148 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2149 *
2150 * @OUTPUT: None
2151 *
2152 * This IOCTL is used to set pcl for concurrency mode.
2153 *
2154 * @E.g: iwpriv wlan0 pm_pcl cds_con_mode
2155 * iwpriv wlan0 pm_pcl 0
2156 *
2157 * Supported Feature: DBS
2158 *
2159 * Usage: Internal/External
2160 *
2161 * </ioctl>
2162 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302164
2165/*
2166 * <ioctl>
2167 * pm_cinfo - Shows the concurrent connection list.
2168 *
2169 * @INPUT: None
2170 *
2171 * @OUTPUT: None
2172 *
2173 * This IOCTL is used to show the concurrent connection list.
2174 *
2175 * @E.g: iwpriv wlan0 pm_cinfo
2176 *
2177 * Supported Feature: DBS
2178 *
2179 * Usage: Internal/External
2180 *
2181 * </ioctl>
2182 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302184
2185/*
2186 * <ioctl>
2187 * pm_ulist - Updates the index value of the concurrent connection list
2188 * with the input parameters provided.
2189 *
2190 * @INPUT: Following 8 arguments:
2191 * @vdev_id: vdev id
2192 * @tx_streams: TX streams
2193 * @rx_streams: RX streams
2194 * @chain_mask: Chain mask
2195 * @type: vdev_type
2196 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2197 * @sub_type: vdev_subtype
2198 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2199 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2200 * @channel: Channel
2201 * @mac: Mac id
2202 *
2203 * @OUTPUT: None
2204 *
2205 * This IOCTL is used to updates the index value of the concurrent
2206 * connection list with the input parameters provided.
2207 *
2208 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
2209 * sub_type channel mac
2210 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
2211 *
2212 * Supported Feature: DBS
2213 *
2214 * Usage: Internal/External
2215 *
2216 * </ioctl>
2217 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302219
2220/*
2221 * <ioctl>
2222 * pm_query_action - Initiate actions needed on current connections as
2223 * per the channel provided.
2224 *
2225 * @INPUT: channel
2226 * @channel: Channel on which new connection will be.
2227 *
2228 * @OUTPUT: None
2229 *
2230 * This IOCTL is used to initiate actions needed on current connections
2231 * as per the channel provided.
2232 *
2233 * @E.g: iwpriv wlan0 pm_query_action channel
2234 * iwpriv wlan0 pm_query_action 6
2235 *
2236 * Supported Feature: DBS
2237 *
2238 * Usage: Internal/External
2239 *
2240 * </ioctl>
2241 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302243
2244/*
2245 * <ioctl>
2246 * pm_query_allow - Checks for allowed concurrency combination
2247 *
2248 * @INPUT: mode, channel, bandwidth
2249 * @mode: new connection mode
2250 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2251 * @channel: channel on which new connection is coming up
2252 * @bandwidth: Bandwidth requested by the connection
2253 * 0:None 1:5MHz 2:10MHz 3:20MHz
2254 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
2255 *
2256 * @OUTPUT: None
2257 *
2258 * This IOCTL is used to checks for allowed concurrency combination.
2259 *
2260 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
2261 * iwpriv wlan0 pm_query_allow 0 6 4
2262 *
2263 * Supported Feature: DBS
2264 *
2265 * Usage: Internal/External
2266 *
2267 * </ioctl>
2268 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302270
2271/*
2272 * <ioctl>
2273 * pm_run_scenario - Create scenario with number of connections provided.
2274 *
2275 * @INPUT: num_of_conn
2276 * @num_of_conn: the number of connections (values: 1~3)
2277 *
2278 * @OUTPUT: None
2279 *
2280 * This IOCTL is used to create scenario with the number of connections
2281 * provided.
2282 *
2283 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
2284 * iwpriv wlan0 pm_run_scenario 1
2285 *
2286 * Supported Feature: DBS
2287 *
2288 * Usage: Internal/External
2289 *
2290 * </ioctl>
2291 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302293
2294/*
2295 * <ioctl>
2296 * pm_set_hw_mode - Set hardware for single/dual mac.
2297 *
2298 * @INPUT: hw_mode
2299 * 0:single mac 1:dual mac
2300 *
2301 * @OUTPUT: None
2302 *
2303 * This IOCTL is used to set hardware for single/dual mac.
2304 *
2305 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
2306 * iwpriv wlan0 pm_set_hw_mode 1
2307 *
2308 * Supported Feature: DBS
2309 *
2310 * Usage: Internal/External
2311 *
2312 * </ioctl>
2313 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314#define WE_POLICY_SET_HW_MODE_CMD 20
2315
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302316/*
2317 * <ioctl>
2318 * set_scan_cfg - Set dual MAC scan config parameters.
2319 *
2320 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2321 * @dbs: Value of DBS bit
2322 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2323 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2324 *
2325 * @OUTPUT: None
2326 *
2327 * This IOCTL is used to set the dual MAC scan config.
2328 *
2329 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2330 * single_mac_scan_with_dbs
2331 * iwpriv wlan0 set_scan_cfg 1 0 1
2332 *
2333 * Supported Feature: DBS
2334 *
2335 * Usage: Internal/External
2336 *
2337 * </ioctl>
2338 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302340
2341/*
2342 * <ioctl>
2343 * set_fw_mode_cfg - Sets the dual mac FW mode config
2344 *
2345 * @INPUT: dbs, dfs
2346 * @dbs: DBS bit
2347 * @dfs: Agile DFS bit
2348 *
2349 * @OUTPUT: None
2350 *
2351 * This IOCTL is used to set the dual mac FW mode config.
2352 *
2353 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2354 * iwpriv wlan0 set_fw_mode_cfg 1 1
2355 *
2356 * Supported Feature: DBS
2357 *
2358 * Usage: Internal/External
2359 *
2360 * </ioctl>
2361 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07002363#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364
2365#ifdef FEATURE_WLAN_TDLS
2366#undef MAX_VAR_ARGS
2367#define MAX_VAR_ARGS 11
2368#else
2369#undef MAX_VAR_ARGS
2370#define MAX_VAR_ARGS 9
2371#endif
2372
2373/* Private ioctls (with no sub-ioctls) */
2374/* note that they must be odd so that they have "get" semantics */
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302375/*
2376 * <ioctl>
2377 * addTspec - Add TSPEC for each AC
2378 *
2379 * @INPUT: 19 TSPEC params
2380 * @[arg0]: handle
2381 * @[arg1]: tid
2382 * @[arg2]: dir
2383 * @[arg3]: psb
2384 * @[arg4]: up
2385 * @[arg5]: nomMsduSize
2386 * @[arg6]: maxMsduSize
2387 * @[arg7]: minDataRate
2388 * @[arg8]: meanDataRate
2389 * @[arg9]: peakDataRate
2390 * @[arg10]: maxBurstSize
2391 * @[arg11]: minPhyRate
2392 * @[arg12]: sba
2393 * @[arg13]: minServiceIntv
2394 * @[arg14]: suspendIntv
2395 * @[arg15]: burstSizeDefn
2396 * @[arg16]: ackPolicy
2397 * @[arg17]: inactivityPeriod
2398 * @[arg18]: maxServiceIntv
2399 *
2400 * @OUTPUT: Success/Failure
2401 *
2402 * This IOCTL is used to add TSPEC for each AC.
2403 *
2404 * @E.g: iwpriv wlan0 addTspec <handle> <tid> <dir> <psb> <up> <nomMsduSize>
2405 * <maxMsduSize> <minDataRate> <meanDataRate>
2406 * <peakDataRate> <maxBurstSize> <minPhyRate>
2407 * <sba> <minServiceIntv> <suspendIntv>
2408 * <burstSizeDefn> <ackPolicy> <inactivityPeriod>
2409 * <maxServiceIntv>
2410 * iwpriv wlan0 addTspec 7001 6 2 1 6 0x80D0 0x80D0 0x14500 0x14500 0x14500
2411 * 0 0x5B8D80 0x2001 20 2000 0 0 0 2000
2412 * wlan0 addTspec:3
2413 *
2414 * Supported Feature: WMM
2415 *
2416 * Usage: Internal/External
2417 *
2418 * </ioctl>
2419 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302421/*
2422 * <ioctl>
2423 * delTspec - Delete TSPEC entry for each AC
2424 *
2425 * @INPUT: 1 TSPEC param
2426 * @[arg0]: handle
2427 *
2428 * @OUTPUT: Success/Failure
2429 *
2430 * This IOCTL is used to delete TSPEC entry for each AC.
2431 *
2432 * @E.g: iwpriv wlan0 delTspec <handle>
2433 * iwpriv wlan0 delTspec 7001
2434 * wlan0 delTspec:16
2435 *
2436 * Supported Feature: WMM
2437 *
2438 * Usage: Internal/External
2439 *
2440 * </ioctl>
2441 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302443/*
2444 * <ioctl>
2445 * getTspec - Get TSPEC entry for each AC
2446 *
2447 * @INPUT: 1 TSPEC param
2448 * @[arg0]: handle
2449 *
2450 * @OUTPUT: Success/Failure
2451 *
2452 * This IOCTL is used to get TSPEC entry for each AC.
2453 *
2454 * @E.g: iwpriv wlan0 getTspec <handle>
2455 * iwpriv wlan0 getTspec 7001
2456 * wlan0 delTspec:18
2457 *
2458 * Supported Feature: WMM
2459 *
2460 * Usage: Internal/External
2461 *
2462 * </ioctl>
2463 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2465
2466/* (SIOCIWFIRSTPRIV + 8) is currently unused */
2467/* (SIOCIWFIRSTPRIV + 10) is currently unused */
2468/* (SIOCIWFIRSTPRIV + 12) is currently unused */
2469/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002470#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
2471#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472/* (SIOCIWFIRSTPRIV + 16) is currently unused */
2473/* (SIOCIWFIRSTPRIV + 17) is currently unused */
2474/* (SIOCIWFIRSTPRIV + 19) is currently unused */
2475
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002476#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477
2478/* Private ioctl for setting the host offload feature */
2479#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2480
2481/* Private ioctl to get the statistics */
2482#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2483
2484/* Private ioctl to set the Keep Alive Params */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302485/*
2486 * <ioctl>
2487 * setKeepAlive - Set the keep alive feature
2488 *
2489 * @INPUT: 28 bytes of information in the order of packet type, time period
2490 * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2491 *
2492 * @OUTPUT: None
2493 *
2494 * This IOCTL sets the keep alive feature to send either NULL
2495 * or unsolicited ARP response packets
2496 *
2497 * @E.g: iwpriv wlan0 setKeepAlive
2498 *
2499 * Supported Feature: STA
2500 *
2501 * Usage: Internal/External
2502 *
2503 * </ioctl>
2504 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2506
2507#ifdef WLAN_FEATURE_PACKET_FILTERING
2508/* Private ioctl to set the packet filtering params */
2509#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2510#endif
2511
2512
2513#ifdef FEATURE_WLAN_SCAN_PNO
2514/* Private ioctl to get the statistics */
2515#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2516#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302517/*
2518 * <ioctl>
2519 * SETBAND - Set the operational band
2520 *
2521 * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2522 *
2523 * @OUTPUT: None
2524 *
2525 * This IOCTL Set the operational band If the new band is different from the
2526 * current operational band, it aborts the pending scan requests, flushes
2527 * the existing scan results, and then change * the band capability
2528 *
2529 * @E.g: iwpriv wlan0 SETBAND <value>
2530 *
2531 * Supported Feature: STA
2532 *
2533 * Usage: Internal/External
2534 *
2535 * </ioctl>
2536 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
2538
Dustin Brown0cbc7572016-12-16 13:54:40 -08002539#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -08002540/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541
2542/* Private ioctls and their sub-ioctls */
2543#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
2544#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -07002545#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546#define WE_SET_FW_CRASH_INJECT 2
2547#endif
2548#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +05302549/* Private sub ioctl for enabling and setting histogram interval of profiling */
2550#define WE_ENABLE_FW_PROFILE 4
2551#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07002553/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002554#define WE_SET_WLAN_SUSPEND 6
2555#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002556
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557/* (SIOCIWFIRSTPRIV + 29) is currently unused */
2558
2559/* 802.11p IOCTL */
2560#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
2561
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302562/*
2563 * <ioctl>
2564 * getLinkSpeed - Gets the current link speed in Mbps
2565 *
2566 * @INPUT: None
2567 *
2568 * @OUTPUT: linkspeed in mbps
2569 * wlan0 getLinkSpeed:7
2570 *
2571 * This IOCTL is used get the current link speed in Mbps
2572 *
2573 * @E.g: iwpriv wlan0 getLinkSpeed
2574 *
2575 * Supported Feature: STA
2576 *
2577 * Usage: Internal/External
2578 *
2579 * </ioctl>
2580 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
2582
2583#define WLAN_STATS_INVALID 0
2584#define WLAN_STATS_RETRY_CNT 1
2585#define WLAN_STATS_MUL_RETRY_CNT 2
2586#define WLAN_STATS_TX_FRM_CNT 3
2587#define WLAN_STATS_RX_FRM_CNT 4
2588#define WLAN_STATS_FRM_DUP_CNT 5
2589#define WLAN_STATS_FAIL_CNT 6
2590#define WLAN_STATS_RTS_FAIL_CNT 7
2591#define WLAN_STATS_ACK_FAIL_CNT 8
2592#define WLAN_STATS_RTS_SUC_CNT 9
2593#define WLAN_STATS_RX_DISCARD_CNT 10
2594#define WLAN_STATS_RX_ERROR_CNT 11
2595#define WLAN_STATS_TX_BYTE_CNT 12
2596
2597#define WLAN_STATS_RX_BYTE_CNT 13
2598#define WLAN_STATS_RX_RATE 14
2599#define WLAN_STATS_TX_RATE 15
2600
2601#define WLAN_STATS_RX_UC_BYTE_CNT 16
2602#define WLAN_STATS_RX_MC_BYTE_CNT 17
2603#define WLAN_STATS_RX_BC_BYTE_CNT 18
2604#define WLAN_STATS_TX_UC_BYTE_CNT 19
2605#define WLAN_STATS_TX_MC_BYTE_CNT 20
2606#define WLAN_STATS_TX_BC_BYTE_CNT 21
2607
2608#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
2609 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
2610 *__p++ = __type; \
2611 *__p++ = __size; \
2612 memcpy(__p, __val, __size); \
2613 __p += __size; \
2614 __tlen += __size + 2; \
2615 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07002616 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 } \
2618 } while (0)
2619
2620#define VERSION_VALUE_MAX_LEN 32
2621
2622#define TX_PER_TRACKING_DEFAULT_RATIO 5
2623#define TX_PER_TRACKING_MAX_RATIO 10
2624#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
2625
2626#define WLAN_ADAPTER 0
2627#define P2P_ADAPTER 1
2628
2629/**
2630 * mem_alloc_copy_from_user_helper - copy from user helper
2631 * @wrqu_data: wireless extensions request data
2632 * @len: length of @wrqu_data
2633 *
2634 * Helper function to allocate buffer and copy user data.
2635 *
2636 * Return: On success return a pointer to a kernel buffer containing a
2637 * copy of the userspace data (with an additional NUL character
2638 * appended for safety). On failure return %NULL.
2639 */
2640void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2641{
2642 u8 *ptr = NULL;
2643
2644 /* in order to protect the code, an extra byte is post
2645 * appended to the buffer and the null termination is added.
2646 * However, when allocating (len+1) byte of memory, we need to
2647 * make sure that there is no uint overflow when doing
2648 * addition. In theory check len < UINT_MAX protects the uint
2649 * overflow. For wlan private ioctl, the buffer size is much
2650 * less than UINT_MAX, as a good guess, now, it is assumed
2651 * that the private command buffer size is no greater than 4K
2652 * (4096 bytes). So we use 4096 as the upper boundary for now.
2653 */
2654 if (len > MAX_USER_COMMAND_SIZE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002655 hdd_err("Invalid length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 return NULL;
2657 }
2658
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002659 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002661 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 return NULL;
2663 }
2664
2665 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002666 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002667 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 return NULL;
2669 }
2670 ptr[len] = '\0';
2671 return ptr;
2672}
2673
2674/**
2675 * hdd_priv_get_data() - Get pointer to ioctl private data
2676 * @p_priv_data: pointer to iw_point struct to be filled
2677 * @wrqu: Pointer to IOCTL Data received from userspace
2678 *
2679 * Helper function to get compatible struct iw_point passed to ioctl
2680 *
2681 * Return - 0 if p_priv_data successfully filled, error otherwise
2682 */
2683int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2684{
2685 if ((NULL == p_priv_data) || (NULL == wrqu)) {
2686 return -EINVAL;
2687 }
2688#ifdef CONFIG_COMPAT
2689 if (is_compat_task()) {
2690 struct compat_iw_point *p_compat_priv_data;
2691
2692 /* Compat task:
2693 * typecast to compat structure and copy the members.
2694 */
2695 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2696
2697 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2698 p_priv_data->length = p_compat_priv_data->length;
2699 p_priv_data->flags = p_compat_priv_data->flags;
2700 } else {
2701#endif /* #ifdef CONFIG_COMPAT */
2702
2703 /* Non compat task: directly copy the structure. */
2704 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
2705
2706#ifdef CONFIG_COMPAT
2707 }
2708#endif /* #ifdef CONFIG_COMPAT */
2709
2710 return 0;
2711}
2712
Jeff Johnson441e1f72017-02-07 08:50:49 -08002713static int hdd_check_wext_control(enum hdd_wext_control wext_control,
2714 struct iw_request_info *info)
2715{
2716 switch (wext_control) {
2717 default:
2718 case hdd_wext_disabled:
2719 hdd_err("Rejecting disabled ioctl %x", info->cmd);
2720 return -ENOTSUPP;
2721 case hdd_wext_deprecated:
2722 hdd_warn("Using deprecated ioctl %x", info->cmd);
2723 return 0;
2724 case hdd_wext_enabled:
2725 return 0;
2726 }
2727}
2728
2729int hdd_check_standard_wext_control(struct hdd_context_s *hdd_ctx,
2730 struct iw_request_info *info)
2731{
2732 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
2733 info);
2734}
2735
2736int hdd_check_private_wext_control(struct hdd_context_s *hdd_ctx,
2737 struct iw_request_info *info)
2738{
2739 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
2740 info);
2741}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742
2743/**
2744 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
2745 * @pAdapter: Pointer to the hdd adapter.
2746 * @length: Size of the data copied
2747 * @buffer: Pointer to char buffer.
2748 * @buf_len: Length of the char buffer.
2749 *
2750 * This function called when the "iwpriv wlan0 get_stats" command is given.
2751 * It used to collect the txrx stats when the device is configured in SAP mode.
2752 *
2753 * Return - none
2754 */
2755void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
2756 char *buffer, uint16_t buf_len)
2757{
2758 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
2759 uint32_t len = 0;
2760 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
2761 uint32_t total_rx_delv = 0, total_rx_refused = 0;
2762 int i = 0;
2763
2764 for (; i < NUM_CPUS; i++) {
2765 total_rx_pkt += pStats->rxPackets[i];
2766 total_rx_dropped += pStats->rxDropped[i];
2767 total_rx_delv += pStats->rxDelivered[i];
2768 total_rx_refused += pStats->rxRefused[i];
2769 }
2770
2771 len = scnprintf(buffer, buf_len,
2772 "\nTransmit"
2773 "\ncalled %u, dropped %u,"
2774 "\n dropped BK %u, BE %u, VI %u, VO %u"
2775 "\n classified BK %u, BE %u, VI %u, VO %u"
2776 "\ncompleted %u,"
2777 "\n\nReceive Total"
2778 "\n packets %u, dropped %u, delivered %u, refused %u"
2779 "\n",
2780 pStats->txXmitCalled,
2781 pStats->txXmitDropped,
2782
2783 pStats->txXmitDroppedAC[SME_AC_BK],
2784 pStats->txXmitDroppedAC[SME_AC_BE],
2785 pStats->txXmitDroppedAC[SME_AC_VI],
2786 pStats->txXmitDroppedAC[SME_AC_VO],
2787
2788 pStats->txXmitClassifiedAC[SME_AC_BK],
2789 pStats->txXmitClassifiedAC[SME_AC_BE],
2790 pStats->txXmitClassifiedAC[SME_AC_VI],
2791 pStats->txXmitClassifiedAC[SME_AC_VO],
2792
2793 pStats->txCompleted,
2794 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
2795 );
2796
2797 for (i = 0; i < NUM_CPUS; i++) {
2798 len += scnprintf(buffer + len, buf_len - len,
2799 "\nReceive CPU: %d"
2800 "\n packets %u, dropped %u, delivered %u, refused %u",
2801 i, pStats->rxPackets[i], pStats->rxDropped[i],
2802 pStats->rxDelivered[i], pStats->rxRefused[i]);
2803 }
2804
2805 len += scnprintf(buffer + len, buf_len - len,
2806 "\n\nTX_FLOW"
2807 "\nCurrent status: %s"
2808 "\ntx-flow timer start count %u"
2809 "\npause count %u, unpause count %u",
2810 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
2811 pStats->txflow_timer_cnt,
2812 pStats->txflow_pause_cnt,
2813 pStats->txflow_unpause_cnt);
2814
Leo Changfdb45c32016-10-28 11:09:23 -07002815 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
2816 pAdapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817
2818 len += hdd_napi_stats(buffer + len, buf_len - len,
2819 NULL, hdd_napi_get_all());
2820
2821 *length = len + 1;
2822}
2823
2824/**
Dustin Brownd9322482017-01-09 12:46:03 -08002825 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
2826 * @hdd_ctx: The Hdd context owning the stats to be written
2827 * @buffer: The char buffer to write to
2828 * @max_len: The maximum number of chars to write
2829 *
2830 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
2831 *
2832 * Return - length of written content, negative number on error
2833 */
2834static int wlan_hdd_write_suspend_resume_stats(hdd_context_t *hdd_ctx,
2835 char *buffer, uint16_t max_len)
2836{
2837 QDF_STATUS status;
2838 struct suspend_resume_stats *sr_stats;
2839 struct sir_wake_lock_stats wow_stats;
2840
2841 sr_stats = &hdd_ctx->suspend_resume_stats;
2842
2843 status = wma_get_wakelock_stats(&wow_stats);
2844 if (QDF_IS_STATUS_ERROR(status)) {
2845 hdd_err("Failed to get WoW stats");
2846 return qdf_status_to_os_return(status);
2847 }
2848
2849 return scnprintf(buffer, max_len,
2850 "\n"
2851 "Suspends: %u\n"
2852 "Resumes: %u\n"
2853 "\n"
2854 "Suspend Fail Reasons\n"
2855 "\tIPA: %u\n"
2856 "\tRadar: %u\n"
2857 "\tRoam: %u\n"
2858 "\tScan: %u\n"
2859 "\tInitial Wakeup: %u\n"
2860 "\n"
2861 "WoW Wake Reasons\n"
2862 "\tunicast: %u\n"
2863 "\tbroadcast: %u\n"
2864 "\tIPv4 multicast: %u\n"
2865 "\tIPv6 multicast: %u\n"
2866 "\tIPv6 multicast RA: %u\n"
2867 "\tIPv6 multicast NS: %u\n"
2868 "\tIPv6 multicast NA: %u\n"
2869 "\tICMPv4: %u\n"
2870 "\tICMPv6: %u\n"
2871 "\tRSSI Breach: %u\n"
2872 "\tLow RSSI: %u\n"
2873 "\tG-Scan: %u\n"
2874 "\tPNO Complete: %u\n"
2875 "\tPNO Match: %u\n",
2876 sr_stats->suspends,
2877 sr_stats->resumes,
2878 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
2879 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
2880 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
2881 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
2882 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
2883 wow_stats.wow_ucast_wake_up_count,
2884 wow_stats.wow_bcast_wake_up_count,
2885 wow_stats.wow_ipv4_mcast_wake_up_count,
2886 wow_stats.wow_ipv6_mcast_wake_up_count,
2887 wow_stats.wow_ipv6_mcast_ra_stats,
2888 wow_stats.wow_ipv6_mcast_ns_stats,
2889 wow_stats.wow_ipv6_mcast_na_stats,
2890 wow_stats.wow_icmpv4_count,
2891 wow_stats.wow_icmpv6_count,
2892 wow_stats.wow_rssi_breach_wake_up_count,
2893 wow_stats.wow_low_rssi_wake_up_count,
2894 wow_stats.wow_gscan_wake_up_count,
2895 wow_stats.wow_pno_complete_wake_up_count,
2896 wow_stats.wow_pno_match_wake_up_count);
2897}
2898
2899/**
Govind Singha471e5e2015-10-12 17:11:14 +05302900 * hdd_wlan_list_fw_profile() - Get fw profiling points
2901 * @length: Size of the data copied
2902 * @buffer: Pointer to char buffer.
2903 * @buf_len: Length of the char buffer.
2904 *
2905 * This function called when the "iwpriv wlan0 listProfile" command is given.
2906 * It is used to get the supported profiling points in FW.
2907 *
2908 * Return - none
2909 */
2910void hdd_wlan_list_fw_profile(uint16_t *length,
2911 char *buffer, uint16_t buf_len)
2912{
2913 uint32_t len = 0;
2914
2915 len = scnprintf(buffer, buf_len,
2916 "PROF_CPU_IDLE: %u\n"
2917 "PROF_PPDU_PROC: %u\n"
2918 "PROF_PPDU_POST: %u\n"
2919 "PROF_HTT_TX_INPUT: %u\n"
2920 "PROF_MSDU_ENQ: %u\n"
2921 "PROF_PPDU_POST_HAL: %u\n"
2922 "PROF_COMPUTE_TX_TIME: %u\n",
2923 PROF_CPU_IDLE,
2924 PROF_PPDU_PROC,
2925 PROF_PPDU_POST,
2926 PROF_HTT_TX_INPUT,
2927 PROF_MSDU_ENQ,
2928 PROF_PPDU_POST_HAL,
2929 PROF_COMPUTE_TX_TIME);
2930
2931 *length = len + 1;
2932}
2933
2934/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 * hdd_wlan_dump_stats() - display dump Stats
2936 * @adapter: adapter handle
2937 * @value: value from user
2938 *
2939 * Return: none
2940 */
2941void hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value)
2942{
2943 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
2944
2945 switch (value) {
2946
2947 case WLAN_TXRX_HIST_STATS:
2948 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
2949 break;
2950 case WLAN_HDD_NETIF_OPER_HISTORY:
2951 wlan_hdd_display_netif_queue_history(hdd_ctx);
2952 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05302953 case WLAN_HIF_STATS:
2954 hdd_display_hif_stats();
2955 break;
Dhanashri Atree7d442a2016-07-14 18:20:29 -07002956 case WLAN_LRO_STATS:
2957 hdd_lro_display_stats(hdd_ctx);
2958 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 default:
Leo Changfdb45c32016-10-28 11:09:23 -07002960 cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961 break;
2962 }
2963}
2964
2965/**
2966 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302967 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 * @wrqu: Pointer to IOCTL REQUEST Data.
2969 * @extra: Pointer to destination buffer
2970 *
2971 * This function is used to get Wlan Driver, Firmware, & Hardware
2972 * Version information. If @wrqu and @extra are specified, then the
2973 * version string is returned. Otherwise it is simply printed to the
2974 * kernel log.
2975 *
2976 * Return: none
2977 */
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302978void hdd_wlan_get_version(hdd_context_t *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 char *extra)
2980{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302981 tSirVersionString wcnss_sw_version;
2982 const char *swversion;
2983 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07002984 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302986 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002987 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 goto error;
2989 }
2990
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302991 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
2992 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302994 swversion = wcnss_sw_version;
2995 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
2996 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
2997 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
2998 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07002999 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303001 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002
3003 if (wrqu && extra) {
3004 wrqu->data.length =
3005 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003006 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003008 msp_id, mspid, siid, crmid,
3009 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003011 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003013 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 }
3015error:
3016 return;
3017}
3018
3019/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003020 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
3021 * @pAdapter: Adapter upon which the IBSS client is active
3022 * @staIdx: Station index of the IBSS peer
3023 *
3024 * Return: a pointer to the MAC address of the IBSS peer if the peer is
3025 * found, otherwise %NULL.
3026 */
3027struct qdf_mac_addr *
3028hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
3029 uint8_t staIdx)
3030{
3031 uint8_t idx;
3032 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3033
Naveen Rawatc45d1622016-07-05 12:20:09 -07003034 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003035 if (0 != pHddStaCtx->conn_info.staId[idx] &&
3036 staIdx == pHddStaCtx->conn_info.staId[idx]) {
3037 return &pHddStaCtx->conn_info.peerMacAddress[idx];
3038 }
3039 }
3040 return NULL;
3041}
3042
3043/**
3044 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
3045 * @pAdapter: Adapter upon which the IBSS client is active
3046 * @staIdx: Station index of the IBSS peer
3047 *
3048 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
3049 * otherwise an appropriate QDF_STATUS_E_* failure code.
3050 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003051static QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter,
3052 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003053{
3054 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3055 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3056 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003057 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003058
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003059 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003060 status = sme_request_ibss_peer_info(hHal, pAdapter,
3061 hdd_get_ibss_peer_info_cb,
3062 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003063
3064 if (QDF_STATUS_SUCCESS == status) {
3065 unsigned long rc;
3066 rc = wait_for_completion_timeout
3067 (&pAdapter->ibss_peer_info_comp,
3068 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3069 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003070 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003071 return QDF_STATUS_E_FAILURE;
3072 }
3073
3074 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003075 hdd_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003076 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003077 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3078 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003079
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003080 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
3081 mac_addr, sizeof(mac_addr));
3082 hdd_info("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
3083 mac_addr, (int)tx_rate,
3084 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003085 }
3086 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003087 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003088 }
3089
3090 return status;
3091}
3092
3093/**
3094 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
3095 * @pAdapter: Adapter upon which the IBSS clients are active
3096 *
3097 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
3098 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
3099 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003100static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003101{
3102 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3103 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3104 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003105 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003106 int i;
3107
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003108 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003109 status = sme_request_ibss_peer_info(hHal, pAdapter,
3110 hdd_get_ibss_peer_info_cb,
3111 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003112
3113 if (QDF_STATUS_SUCCESS == status) {
3114 unsigned long rc;
3115 rc = wait_for_completion_timeout
3116 (&pAdapter->ibss_peer_info_comp,
3117 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3118 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003119 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003120 return QDF_STATUS_E_FAILURE;
3121 }
3122
3123 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003124 hdd_info("pPeerInfo->numIBSSPeers = %d ",
3125 (int)pPeerInfo->numPeers);
3126 for (i = 0; i < pPeerInfo->numPeers; i++) {
3127 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3128 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003129
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003130 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
3131 qdf_mem_copy(mac_addr,
3132 pPeerInfo->peerInfoParams[i].mac_addr,
3133 sizeof(mac_addr));
3134
3135 hdd_info(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
3136 mac_addr, (int)tx_rate,
3137 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003138 }
3139 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003140 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003141 }
3142
3143 return status;
3144}
3145
3146/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 * hdd_wlan_get_freq() - Convert channel to frequency
3148 * @channel: channel to be converted
3149 * @pfreq: where to store the frequency
3150 *
3151 * Return: 1 on success, otherwise a negative errno
3152 */
3153int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
3154{
3155 int i;
3156 if (channel > 0) {
3157 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
3158 if (channel == freq_chan_map[i].chan) {
3159 *pfreq = freq_chan_map[i].freq;
3160 return 1;
3161 }
3162 }
3163 }
Jeff Johnson99bac312016-06-28 10:38:18 -07003164 hdd_notice("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 return -EINVAL;
3166}
3167
3168/**
3169 * hdd_is_auth_type_rsn() - RSN authentication type check
3170 * @authType: authentication type to be checked
3171 *
3172 * Return: true if @authType is an RSN authentication type,
3173 * false if it is not
3174 */
3175static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
3176{
3177 bool rsnType = false;
3178 /* is the authType supported? */
3179 switch (authType) {
3180 case eCSR_AUTH_TYPE_NONE: /* never used */
3181 rsnType = false;
3182 break;
3183 /* MAC layer authentication types */
3184 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3185 rsnType = false;
3186 break;
3187 case eCSR_AUTH_TYPE_SHARED_KEY:
3188 rsnType = false;
3189 break;
3190 case eCSR_AUTH_TYPE_AUTOSWITCH:
3191 rsnType = false;
3192 break;
3193
3194 /* Upper layer authentication types */
3195 case eCSR_AUTH_TYPE_WPA:
3196 rsnType = true;
3197 break;
3198 case eCSR_AUTH_TYPE_WPA_PSK:
3199 rsnType = true;
3200 break;
3201 case eCSR_AUTH_TYPE_WPA_NONE:
3202 rsnType = true;
3203 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 case eCSR_AUTH_TYPE_RSN:
3206 rsnType = true;
3207 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 case eCSR_AUTH_TYPE_RSN_PSK:
3210#ifdef WLAN_FEATURE_11W
3211 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3212 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
3213#endif
3214 rsnType = true;
3215 break;
3216 /* case eCSR_AUTH_TYPE_FAILED: */
3217 case eCSR_AUTH_TYPE_UNKNOWN:
3218 rsnType = false;
3219 break;
3220 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003221 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 authType);
3223 rsnType = false;
3224 break;
3225 }
Jeff Johnson99bac312016-06-28 10:38:18 -07003226 hdd_notice("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 authType, rsnType);
3228 return rsnType;
3229}
3230
Jeff Johnsona5444942017-01-23 13:11:08 -08003231struct rssi_priv {
3232 int8_t rssi;
3233};
3234
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235/**
3236 * hdd_get_rssi_cb() - "Get RSSI" callback function
3237 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08003238 * @sta_id: ID of the station
3239 * @context: opaque context originally passed to SME. HDD always passes
3240 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 *
3242 * Return: None
3243 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003244static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245{
Jeff Johnsona5444942017-01-23 13:11:08 -08003246 struct hdd_request *request;
3247 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248
Jeff Johnsona5444942017-01-23 13:11:08 -08003249 request = hdd_request_get(context);
3250 if (!request) {
3251 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 return;
3253 }
3254
Jeff Johnsona5444942017-01-23 13:11:08 -08003255 priv = hdd_request_priv(request);
3256 priv->rssi = rssi;
3257 hdd_request_complete(request);
3258 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259}
3260
3261/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 * wlan_hdd_get_rssi() - Get the current RSSI
3263 * @pAdapter: adapter upon which the measurement is requested
3264 * @rssi_value: pointer to where the RSSI should be returned
3265 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303266 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303268QDF_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 hdd_context_t *pHddCtx;
3271 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303272 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08003273 int ret;
3274 void *cookie;
3275 struct hdd_request *request;
3276 struct rssi_priv *priv;
3277 static const struct hdd_request_params params = {
3278 .priv_size = sizeof(*priv),
3279 .timeout_ms = WLAN_WAIT_TIME_STATS,
3280 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281
3282 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003283 hdd_warn("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303284 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003286 if (cds_is_driver_recovering()) {
3287 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3288 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 /* return a cached value */
3290 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303291 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 }
3293
3294 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3295 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3296
3297 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05303298 hdd_err("Not associated!, rssi on disconnect %d",
3299 pAdapter->rssi_on_disconnect);
3300 *rssi_value = pAdapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303301 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 }
3303
3304 if (pHddStaCtx->hdd_ReassocScenario) {
3305 hdd_info("Roaming in progress, return cached RSSI");
3306 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303307 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 }
3309
Jeff Johnsona5444942017-01-23 13:11:08 -08003310 request = hdd_request_alloc(&params);
3311 if (!request) {
3312 hdd_err("Request allocation failure, return cached RSSI");
3313 *rssi_value = pAdapter->rssi;
3314 return QDF_STATUS_SUCCESS;
3315 }
3316 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317
3318 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
3319 pHddStaCtx->conn_info.staId[0],
3320 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
Jeff Johnsona5444942017-01-23 13:11:08 -08003321 cookie, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303322 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003323 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 /* we'll returned a cached value below */
3325 } else {
3326 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08003327 ret = hdd_request_wait_for_response(request);
3328 if (ret) {
3329 hdd_warn("SME timed out while retrieving RSSI");
3330 /* we'll returned a cached value below */
3331 } else {
3332 /* update the adapter with the fresh results */
3333 priv = hdd_request_priv(request);
3334 pAdapter->rssi = priv->rssi;
3335 if (pAdapter->rssi > 0)
3336 pAdapter->rssi = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 }
3338 }
3339
Jeff Johnsona5444942017-01-23 13:11:08 -08003340 /*
3341 * either we never sent a request, we sent a request and
3342 * received a response or we sent a request and timed out.
3343 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003345 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346
3347 *rssi_value = pAdapter->rssi;
3348
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303349 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350}
3351
Jeff Johnson002cb972017-01-23 14:59:07 -08003352struct snr_priv {
3353 int8_t snr;
3354};
3355
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08003357 * hdd_get_snr_cb() - "Get SNR" callback function
3358 * @snr: Current SNR of the station
Jeff Johnson002cb972017-01-23 14:59:07 -08003359 * @sta_id: ID of the station
3360 * @context: opaque context originally passed to SME. HDD always passes
3361 * a cookie for the request context
Jeff Johnson8eaff302017-01-23 11:03:31 -08003362 *
3363 * Return: None
3364 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003365static void hdd_get_snr_cb(int8_t snr, uint32_t sta_id, void *context)
Jeff Johnson8eaff302017-01-23 11:03:31 -08003366{
Jeff Johnson002cb972017-01-23 14:59:07 -08003367 struct hdd_request *request;
3368 struct snr_priv *priv;
Jeff Johnson8eaff302017-01-23 11:03:31 -08003369
Jeff Johnson002cb972017-01-23 14:59:07 -08003370 request = hdd_request_get(context);
3371 if (!request) {
3372 hdd_err("Obsolete request");
Jeff Johnson8eaff302017-01-23 11:03:31 -08003373 return;
3374 }
3375
Jeff Johnson002cb972017-01-23 14:59:07 -08003376 /* propagate response back to requesting thread */
3377 priv = hdd_request_priv(request);
3378 priv->snr = snr;
3379 hdd_request_complete(request);
3380 hdd_request_put(request);
Jeff Johnson8eaff302017-01-23 11:03:31 -08003381}
3382
3383/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 * wlan_hdd_get_snr() - Get the current SNR
3385 * @pAdapter: adapter upon which the measurement is requested
3386 * @snr: pointer to where the SNR should be returned
3387 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303388 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303390QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 hdd_context_t *pHddCtx;
3393 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303394 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 int valid;
Jeff Johnson002cb972017-01-23 14:59:07 -08003396 int ret;
3397 void *cookie;
3398 struct hdd_request *request;
3399 struct snr_priv *priv;
3400 static const struct hdd_request_params params = {
3401 .priv_size = sizeof(*priv),
3402 .timeout_ms = WLAN_WAIT_TIME_STATS,
3403 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303405 ENTER();
3406
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003408 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303409 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 }
3411
3412 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3413
3414 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303415 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303416 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417
3418 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3419
Jeff Johnson002cb972017-01-23 14:59:07 -08003420 request = hdd_request_alloc(&params);
3421 if (!request) {
3422 hdd_err("Request allocation failure");
3423 return QDF_STATUS_E_FAULT;
3424 }
3425 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426
3427 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
3428 pHddStaCtx->conn_info.staId[0],
Jeff Johnson002cb972017-01-23 14:59:07 -08003429 pHddStaCtx->conn_info.bssId, cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303430 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003431 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 /* we'll returned a cached value below */
3433 } else {
3434 /* request was sent -- wait for the response */
Jeff Johnson002cb972017-01-23 14:59:07 -08003435 ret = hdd_request_wait_for_response(request);
3436 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003437 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 /* we'll now returned a cached value below */
Jeff Johnson002cb972017-01-23 14:59:07 -08003439 } else {
3440 /* update the adapter with the fresh results */
3441 priv = hdd_request_priv(request);
3442 pAdapter->snr = priv->snr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 }
3444 }
3445
Jeff Johnson002cb972017-01-23 14:59:07 -08003446 /*
3447 * either we never sent a request, we sent a request and
3448 * received a response or we sent a request and timed out.
3449 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003451 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452
3453 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303454 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303455 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456}
3457
Jeff Johnsone50427c2017-01-26 10:54:49 -08003458struct linkspeed_priv {
3459 tSirLinkSpeedInfo linkspeed_info;
3460};
3461
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462static void
Jeff Johnsone50427c2017-01-26 10:54:49 -08003463hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464{
Jeff Johnsone50427c2017-01-26 10:54:49 -08003465 struct hdd_request *request;
3466 struct linkspeed_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467
Jeff Johnsone50427c2017-01-26 10:54:49 -08003468 if (!linkspeed_info) {
3469 hdd_err("NULL linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 return;
3471 }
3472
Jeff Johnsone50427c2017-01-26 10:54:49 -08003473 request = hdd_request_get(context);
3474 if (!request) {
3475 hdd_err("Obsolete request");
3476 return;
3477 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478
Jeff Johnsone50427c2017-01-26 10:54:49 -08003479 priv = hdd_request_priv(request);
3480 priv->linkspeed_info = *linkspeed_info;
3481 hdd_request_complete(request);
3482 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483}
3484
Jeff Johnsone50427c2017-01-26 10:54:49 -08003485int wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *adapter,
3486 struct qdf_mac_addr *mac_address,
3487 uint32_t *linkspeed)
3488{
3489 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303490 QDF_STATUS status;
Jeff Johnsone50427c2017-01-26 10:54:49 -08003491 void *cookie;
3492 tSirLinkSpeedInfo *linkspeed_info;
3493 struct hdd_request *request;
3494 struct linkspeed_priv *priv;
3495 static const struct hdd_request_params params = {
3496 .priv_size = sizeof(*priv),
3497 .timeout_ms = WLAN_WAIT_TIME_STATS,
3498 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499
Jeff Johnsone50427c2017-01-26 10:54:49 -08003500 if ((!adapter) || (!linkspeed)) {
3501 hdd_err("NULL argument");
3502 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504
Jeff Johnsone50427c2017-01-26 10:54:49 -08003505 request = hdd_request_alloc(&params);
3506 if (!request) {
3507 hdd_err("Request allocation failure");
3508 ret = -ENOMEM;
3509 goto return_cached_value;
3510 }
3511
3512 cookie = hdd_request_cookie(request);
3513 priv = hdd_request_priv(request);
3514
3515 linkspeed_info = &priv->linkspeed_info;
3516 qdf_copy_macaddr(&linkspeed_info->peer_macaddr, mac_address);
3517 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(adapter),
3518 linkspeed_info,
3519 cookie, hdd_get_link_speed_cb);
3520 if (QDF_IS_STATUS_ERROR(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003521 hdd_err("Unable to retrieve statistics for link speed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003522 ret = qdf_status_to_os_return(status);
3523 goto cleanup;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 }
Jeff Johnsone50427c2017-01-26 10:54:49 -08003525 ret = hdd_request_wait_for_response(request);
3526 if (ret) {
3527 hdd_err("SME timed out while retrieving link speed");
3528 goto cleanup;
3529 }
3530 adapter->estimated_linkspeed = linkspeed_info->estLinkSpeed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531
Jeff Johnsone50427c2017-01-26 10:54:49 -08003532cleanup:
3533 /*
3534 * either we never sent a request, we sent a request and
3535 * received a response or we sent a request and timed out.
3536 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 */
Jeff Johnsone50427c2017-01-26 10:54:49 -08003538 hdd_request_put(request);
3539
3540return_cached_value:
3541 *linkspeed = adapter->estimated_linkspeed;
3542
3543 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544}
3545
3546/**
3547 * wlan_hdd_get_link_speed() - get link speed
3548 * @pAdapter: pointer to the adapter
3549 * @link_speed: pointer to link speed
3550 *
3551 * This function fetches per bssid link speed.
3552 *
3553 * Return: if associated, link speed shall be returned.
3554 * if not associated, link speed of 0 is returned.
3555 * On error, error number will be returned.
3556 */
3557int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
3558{
3559 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
3560 hdd_station_ctx_t *hdd_stactx =
3561 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
3562 int ret;
3563
3564 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05303565 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303568 /* Linkspeed is allowed only for P2P mode */
3569 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
3570 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
3571 hdd_device_mode_to_string(sta_adapter->device_mode),
3572 sta_adapter->device_mode);
3573 return -ENOTSUPP;
3574 }
3575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
3577 /* we are not connected so we don't have a classAstats */
3578 *link_speed = 0;
3579 } else {
Anurag Chouhan6d760662016-02-20 16:05:43 +05303580 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581
Anurag Chouhanc5548422016-02-24 18:33:27 +05303582 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583
Jeff Johnsone50427c2017-01-26 10:54:49 -08003584 ret = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, &bssid,
3585 link_speed);
3586 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003587 hdd_err("Unable to retrieve SME linkspeed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003588 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 /* linkspeed in units of 500 kbps */
3591 *link_speed = (*link_speed) / 500;
3592 }
3593 return 0;
3594}
3595
3596/**
3597 * hdd_statistics_cb() - "Get statistics" callback function
3598 * @pStats: statistics payload
3599 * @pContext: opaque context originally passed to SME. HDD always passes
3600 * a pointer to an adapter
3601 *
3602 * Return: None
3603 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003604static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605{
3606 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
3607 hdd_stats_t *pStatsCache = NULL;
3608 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05303609 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610
3611 tCsrSummaryStatsInfo *pSummaryStats = NULL;
3612 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
3613 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
3614 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
3615 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616
3617 if (pAdapter != NULL)
3618 pStatsCache = &pAdapter->hdd_stats;
3619
3620 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3621 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
3622 pClassBStats = (tCsrGlobalClassBStatsInfo *) (pClassAStats + 1);
3623 pClassCStats = (tCsrGlobalClassCStatsInfo *) (pClassBStats + 1);
3624 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassCStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625
3626 if (pStatsCache != NULL) {
3627 /* copy the stats into the cache we keep in the
3628 * adapter instance structure
3629 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303630 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303632 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303634 qdf_mem_copy(&pStatsCache->ClassB_stat, pClassBStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635 sizeof(pStatsCache->ClassB_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303636 qdf_mem_copy(&pStatsCache->ClassC_stat, pClassCStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003637 sizeof(pStatsCache->ClassC_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303638 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 sizeof(pStatsCache->ClassD_stat));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 }
3641
3642 if (pAdapter) {
3643 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303644 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05303645 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003646 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 return;
3648 }
3649 }
3650}
3651
3652/**
3653 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
3654 * @pAdapter: adapter who's IEs are to be cleared
3655 *
3656 * Return: None
3657 */
3658void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
3659{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003660 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07003661
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003662 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663
3664 /* clear WPA/RSN/WSC IE information in the profile */
3665 pWextState->roamProfile.nWPAReqIELength = 0;
3666 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
3667 pWextState->roamProfile.nRSNReqIELength = 0;
3668 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
3669
3670#ifdef FEATURE_WLAN_WAPI
3671 pWextState->roamProfile.nWAPIReqIELength = 0;
3672 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
3673#endif
3674
3675 pWextState->roamProfile.bWPSAssociation = false;
3676 pWextState->roamProfile.bOSENAssociation = false;
3677 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
3678 pWextState->roamProfile.nAddIEScanLength = 0;
3679 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
3680 pWextState->roamProfile.nAddIEAssocLength = 0;
3681
3682 pWextState->roamProfile.EncryptionType.numEntries = 1;
3683 pWextState->roamProfile.EncryptionType.encryptionType[0]
3684 = eCSR_ENCRYPT_TYPE_NONE;
3685
3686 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3687 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
3688 = eCSR_ENCRYPT_TYPE_NONE;
3689
3690 pWextState->roamProfile.AuthType.numEntries = 1;
3691 pWextState->roamProfile.AuthType.authType[0] =
3692 eCSR_AUTH_TYPE_OPEN_SYSTEM;
3693
Abhishek Singh3c9910e2017-01-06 17:56:47 +05303694 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
3695 QDF_MAC_ADDR_SIZE);
3696
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697#ifdef WLAN_FEATURE_11W
3698 pWextState->roamProfile.MFPEnabled = false;
3699 pWextState->roamProfile.MFPRequired = 0;
3700 pWextState->roamProfile.MFPCapable = 0;
3701#endif
3702
3703 pWextState->authKeyMgmt = 0;
3704
Yingying Tang3cc6b792016-10-20 17:00:37 +08003705 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
3706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707#ifdef FEATURE_WLAN_WAPI
3708 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
3709 pAdapter->wapi_info.nWapiMode = 0;
3710#endif
3711
Anurag Chouhanc5548422016-02-24 18:33:27 +05303712 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003713 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714}
3715
3716/**
3717 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
3718 * @oui: The OUI that is being searched for
3719 * @oui_size: The length of @oui
3720 * @ie: The set of IEs within which we're trying to find @oui
3721 * @ie_len: The length of @ie
3722 *
3723 * This function will scan the IEs contained within @ie looking for @oui.
3724 *
3725 * Return: Pointer to @oui embedded within @ie if it is present, NULL
3726 * if @oui is not present within @ie.
3727 */
3728uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
3729 uint8_t *ie, int ie_len)
3730{
3731 int left = ie_len;
3732 uint8_t *ptr = ie;
3733 uint8_t elem_id, elem_len;
3734 uint8_t eid = 0xDD;
3735
3736 if (NULL == ie || 0 == ie_len)
3737 return NULL;
3738
3739 while (left >= 2) {
3740 elem_id = ptr[0];
3741 elem_len = ptr[1];
3742 left -= 2;
3743 if (elem_len > left) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003744 hdd_alert("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 eid, elem_len, left);
3746 return NULL;
3747 }
3748 if (elem_id == eid) {
3749 if (memcmp(&ptr[2], oui, oui_size) == 0)
3750 return ptr;
3751 }
3752
3753 left -= elem_len;
3754 ptr += (elem_len + 2);
3755 }
3756 return NULL;
3757}
3758
3759/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303760 * hdd_get_ldpc() - Get adapter LDPC
3761 * @adapter: adapter being queried
3762 * @value: where to store the value
3763 *
3764 * Return: 0 on success, negative errno on failure
3765 */
3766int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
3767{
3768 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3769 int ret;
3770
3771 ENTER();
3772 ret = sme_get_ht_config(hal, adapter->sessionId,
3773 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
3774 if (ret < 0) {
3775 hdd_alert("Failed to get LDPC value");
3776 } else {
3777 *value = ret;
3778 ret = 0;
3779 }
3780 return ret;
3781}
3782
3783/**
3784 * hdd_set_ldpc() - Set adapter LDPC
3785 * @adapter: adapter being modified
3786 * @value: new LDPC value
3787 *
3788 * Return: 0 on success, negative errno on failure
3789 */
3790int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
3791{
3792 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3793 int ret;
3794
3795 hdd_alert("%d", value);
3796 if (value) {
3797 /* make sure HT capabilities allow this */
3798 QDF_STATUS status;
3799 uint32_t cfg_value;
3800 union {
3801 uint16_t cfg_value16;
3802 tSirMacHTCapabilityInfo ht_cap_info;
3803 } u;
3804
3805 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
3806 if (QDF_STATUS_SUCCESS != status) {
3807 hdd_alert("Failed to get HT capability info");
3808 return -EIO;
3809 }
3810 u.cfg_value16 = cfg_value & 0xFFFF;
3811 if (!u.ht_cap_info.advCodingCap) {
3812 hdd_alert("LDCP not supported");
3813 return -EINVAL;
3814 }
3815 }
3816
3817 ret = sme_update_ht_config(hal, adapter->sessionId,
3818 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
3819 value);
3820 if (ret)
3821 hdd_alert("Failed to set LDPC value");
3822
3823 return ret;
3824}
3825
3826/**
3827 * hdd_get_tx_stbc() - Get adapter TX STBC
3828 * @adapter: adapter being queried
3829 * @value: where to store the value
3830 *
3831 * Return: 0 on success, negative errno on failure
3832 */
3833int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
3834{
3835 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3836 int ret;
3837
3838 ENTER();
3839 ret = sme_get_ht_config(hal, adapter->sessionId,
3840 WNI_CFG_HT_CAP_INFO_TX_STBC);
3841 if (ret < 0) {
3842 hdd_alert("Failed to get TX STBC value");
3843 } else {
3844 *value = ret;
3845 ret = 0;
3846 }
3847
3848 return ret;
3849}
3850
3851/**
3852 * hdd_set_tx_stbc() - Set adapter TX STBC
3853 * @adapter: adapter being modified
3854 * @value: new TX STBC value
3855 *
3856 * Return: 0 on success, negative errno on failure
3857 */
3858int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
3859{
3860 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3861 int ret;
3862
3863 hdd_alert("%d", value);
3864 if (value) {
3865 /* make sure HT capabilities allow this */
3866 QDF_STATUS status;
3867 uint32_t cfg_value;
3868 union {
3869 uint16_t cfg_value16;
3870 tSirMacHTCapabilityInfo ht_cap_info;
3871 } u;
3872
3873 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
3874 if (QDF_STATUS_SUCCESS != status) {
3875 hdd_alert("Failed to get HT capability info");
3876 return -EIO;
3877 }
3878 u.cfg_value16 = cfg_value & 0xFFFF;
3879 if (!u.ht_cap_info.txSTBC) {
3880 hdd_alert("TX STBC not supported");
3881 return -EINVAL;
3882 }
3883 }
3884 ret = sme_update_ht_config(hal, adapter->sessionId,
3885 WNI_CFG_HT_CAP_INFO_TX_STBC,
3886 value);
3887 if (ret)
3888 hdd_alert("Failed to set TX STBC value");
3889
3890 return ret;
3891}
3892
3893/**
3894 * hdd_get_rx_stbc() - Get adapter RX STBC
3895 * @adapter: adapter being queried
3896 * @value: where to store the value
3897 *
3898 * Return: 0 on success, negative errno on failure
3899 */
3900int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
3901{
3902 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3903 int ret;
3904
3905 ENTER();
3906 ret = sme_get_ht_config(hal, adapter->sessionId,
3907 WNI_CFG_HT_CAP_INFO_RX_STBC);
3908 if (ret < 0) {
3909 hdd_alert("Failed to get RX STBC value");
3910 } else {
3911 *value = ret;
3912 ret = 0;
3913 }
3914
3915 return ret;
3916}
3917
3918/**
3919 * hdd_set_rx_stbc() - Set adapter RX STBC
3920 * @adapter: adapter being modified
3921 * @value: new RX STBC value
3922 *
3923 * Return: 0 on success, negative errno on failure
3924 */
3925int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
3926{
3927 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3928 int ret;
3929
3930 hdd_alert("%d", value);
3931 if (value) {
3932 /* make sure HT capabilities allow this */
3933 QDF_STATUS status;
3934 uint32_t cfg_value;
3935 union {
3936 uint16_t cfg_value16;
3937 tSirMacHTCapabilityInfo ht_cap_info;
3938 } u;
3939
3940 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
3941 if (QDF_STATUS_SUCCESS != status) {
3942 hdd_alert("Failed to get HT capability info");
3943 return -EIO;
3944 }
3945 u.cfg_value16 = cfg_value & 0xFFFF;
3946 if (!u.ht_cap_info.rxSTBC) {
3947 hdd_alert("RX STBC not supported");
3948 return -EINVAL;
3949 }
3950 }
3951 ret = sme_update_ht_config(hal, adapter->sessionId,
3952 WNI_CFG_HT_CAP_INFO_RX_STBC,
3953 value);
3954 if (ret)
3955 hdd_alert("Failed to set RX STBC value");
3956
3957 return ret;
3958}
3959
3960/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003961 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
3962 * @dev: device upon which the ioctl was received
3963 * @info: ioctl request information
3964 * @wrqu: ioctl request data
3965 * @extra: ioctl extra data
3966 *
3967 * Return: 0 on success, non-zero on error
3968 */
3969static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
3970 union iwreq_data *wrqu, char *extra)
3971{
3972 hdd_adapter_t *adapter;
3973 hdd_context_t *hdd_ctx;
3974 int ret;
3975
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003976 ENTER_DEV(dev);
3977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3979 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3980 ret = wlan_hdd_validate_context(hdd_ctx);
3981 if (0 != ret)
3982 return ret;
3983
Jeff Johnson441e1f72017-02-07 08:50:49 -08003984 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3985 if (0 != ret)
3986 return ret;
3987
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003988 /* Do nothing for now */
3989 return 0;
3990}
3991
3992/**
3993 * iw_set_commit() - SSR wrapper function for __iw_set_commit
3994 * @dev: pointer to net_device
3995 * @info: pointer to iw_request_info
3996 * @wrqu: pointer to iwreq_data
3997 * @extra: extra
3998 *
3999 * Return: 0 on success, error number otherwise
4000 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004001static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002 union iwreq_data *wrqu, char *extra)
4003{
4004 int ret;
4005
4006 cds_ssr_protect(__func__);
4007 ret = __iw_set_commit(dev, info, wrqu, extra);
4008 cds_ssr_unprotect(__func__);
4009
4010 return ret;
4011}
4012
4013/**
4014 * __iw_get_name() - SIOCGIWNAME ioctl handler
4015 * @dev: device upon which the ioctl was received
4016 * @info: ioctl request information
4017 * @wrqu: ioctl request data
4018 * @extra: ioctl extra data
4019 *
4020 * Return: 0 on success, non-zero on error
4021 */
4022static int __iw_get_name(struct net_device *dev,
4023 struct iw_request_info *info, char *wrqu, char *extra)
4024{
4025 hdd_adapter_t *adapter;
4026 hdd_context_t *hdd_ctx;
4027 int ret;
4028
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004029 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030
4031 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4032 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4033 ret = wlan_hdd_validate_context(hdd_ctx);
4034 if (0 != ret)
4035 return ret;
4036
Jeff Johnson441e1f72017-02-07 08:50:49 -08004037 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4038 if (0 != ret)
4039 return ret;
4040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
4042 EXIT();
4043 return 0;
4044}
4045
4046/**
4047 * __iw_get_name() - SSR wrapper for __iw_get_name
4048 * @dev: pointer to net_device
4049 * @info: pointer to iw_request_info
4050 * @wrqu: pointer to iwreq_data
4051 * @extra: extra
4052 *
4053 * Return: 0 on success, error number otherwise
4054 */
4055static int iw_get_name(struct net_device *dev,
4056 struct iw_request_info *info,
4057 char *wrqu, char *extra)
4058{
4059 int ret;
4060
4061 cds_ssr_protect(__func__);
4062 ret = __iw_get_name(dev, info, wrqu, extra);
4063 cds_ssr_unprotect(__func__);
4064
4065 return ret;
4066}
4067
4068/**
4069 * __iw_set_mode() - ioctl handler
4070 * @dev: device upon which the ioctl was received
4071 * @info: ioctl request information
4072 * @wrqu: ioctl request data
4073 * @extra: ioctl extra data
4074 *
4075 * Return: 0 on success, non-zero on error
4076 */
4077static int __iw_set_mode(struct net_device *dev,
4078 struct iw_request_info *info,
4079 union iwreq_data *wrqu, char *extra)
4080{
4081 hdd_wext_state_t *pWextState;
4082 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4083 hdd_context_t *hdd_ctx;
4084 tCsrRoamProfile *pRoamProfile;
4085 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 struct hdd_config *pConfig;
4087 struct wireless_dev *wdev;
4088 int ret;
4089
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004090 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091
4092 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4093 ret = wlan_hdd_validate_context(hdd_ctx);
4094 if (0 != ret)
4095 return ret;
4096
Jeff Johnson441e1f72017-02-07 08:50:49 -08004097 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4098 if (0 != ret)
4099 return ret;
4100
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4102 wdev = dev->ieee80211_ptr;
4103 pRoamProfile = &pWextState->roamProfile;
4104 LastBSSType = pRoamProfile->BSSType;
4105
Jeff Johnson99bac312016-06-28 10:38:18 -07004106 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107
4108 switch (wrqu->mode) {
4109 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07004110 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
4112 /* Set the phymode correctly for IBSS. */
4113 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
4114 pWextState->roamProfile.phyMode =
4115 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08004116 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 wdev->iftype = NL80211_IFTYPE_ADHOC;
4118 break;
4119 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07004120 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
4122 wdev->iftype = NL80211_IFTYPE_STATION;
4123 break;
4124 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07004125 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
4127 break;
4128 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004129 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130 return -EOPNOTSUPP;
4131 }
4132
4133 if (LastBSSType != pRoamProfile->BSSType) {
4134 /* the BSS mode changed. We need to issue disconnect
4135 * if connected or in IBSS disconnect state
4136 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07004137 if (hdd_conn_is_connected
4138 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304140 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004141 /* need to issue a disconnect to CSR. */
4142 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304143 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4145 pAdapter->sessionId,
4146 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304147 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 unsigned long rc;
4149 rc = wait_for_completion_timeout(&pAdapter->
4150 disconnect_comp_var,
4151 msecs_to_jiffies
4152 (WLAN_WAIT_TIME_DISCONNECT));
4153 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004154 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 }
4156 }
4157 }
4158
4159 EXIT();
4160 return 0;
4161}
4162
4163/**
4164 * iw_set_mode() - SSR wrapper for __iw_set_mode()
4165 * @dev: pointer to net_device
4166 * @info: pointer to iw_request_info
4167 * @wrqu: pointer to iwreq_data
4168 * @extra: pointer to extra ioctl payload
4169 *
4170 * Return: 0 on success, error number otherwise
4171 */
4172static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
4173 union iwreq_data *wrqu, char *extra)
4174{
4175 int ret;
4176
4177 cds_ssr_protect(__func__);
4178 ret = __iw_set_mode(dev, info, wrqu, extra);
4179 cds_ssr_unprotect(__func__);
4180
4181 return ret;
4182}
4183
4184/**
4185 * __iw_get_mode() - SIOCGIWMODE ioctl handler
4186 * @dev: device upon which the ioctl was received
4187 * @info: ioctl request information
4188 * @wrqu: ioctl request data
4189 * @extra: ioctl extra data
4190 *
4191 * Return: 0 on success, non-zero on error
4192 */
4193static int
4194__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4195 union iwreq_data *wrqu, char *extra)
4196{
4197 hdd_wext_state_t *pWextState;
4198 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4199 hdd_context_t *hdd_ctx;
4200 int ret;
4201
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004202 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203
4204 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4205 ret = wlan_hdd_validate_context(hdd_ctx);
4206 if (0 != ret)
4207 return ret;
4208
Jeff Johnson441e1f72017-02-07 08:50:49 -08004209 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4210 if (0 != ret)
4211 return ret;
4212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4214
4215 switch (pWextState->roamProfile.BSSType) {
4216 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07004217 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 wrqu->mode = IW_MODE_INFRA;
4219 break;
4220 case eCSR_BSS_TYPE_IBSS:
4221 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07004222 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223 wrqu->mode = IW_MODE_ADHOC;
4224 break;
4225 case eCSR_BSS_TYPE_ANY:
4226 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004227 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228 wrqu->mode = IW_MODE_AUTO;
4229 break;
4230 }
4231
4232 EXIT();
4233 return 0;
4234}
4235
4236/**
4237 * iw_get_mode() - SSR wrapper for __iw_get_mode()
4238 * @dev: pointer to net_device
4239 * @info: pointer to iw_request_info
4240 * @wrqu: pointer to iwreq_data
4241 * @extra: pointer to extra ioctl payload
4242 *
4243 * Return: 0 on success, error number otherwise
4244 */
4245static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4246 union iwreq_data *wrqu, char *extra)
4247{
4248 int ret;
4249
4250 cds_ssr_protect(__func__);
4251 ret = __iw_get_mode(dev, info, wrqu, extra);
4252 cds_ssr_unprotect(__func__);
4253
4254 return ret;
4255}
4256
4257/**
4258 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
4259 * @dev: device upon which the ioctl was received
4260 * @info: ioctl request information
4261 * @wrqu: ioctl request data
4262 * @extra: ioctl extra data
4263 *
4264 * Return: 0 on success, non-zero on error
4265 */
4266static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4267 union iwreq_data *wrqu, char *extra)
4268{
4269 uint32_t numChans = 0;
4270 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4271 uint32_t indx = 0;
4272 int ret;
4273 hdd_wext_state_t *pWextState;
4274 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4275 hdd_context_t *hdd_ctx;
4276 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4277 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4278 tCsrRoamProfile *pRoamProfile;
4279
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004280 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281
4282 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4283 ret = wlan_hdd_validate_context(hdd_ctx);
4284 if (0 != ret)
4285 return ret;
4286
Jeff Johnson441e1f72017-02-07 08:50:49 -08004287 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4288 if (0 != ret)
4289 return ret;
4290
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4292
4293 pRoamProfile = &pWextState->roamProfile;
4294
Jeff Johnson99bac312016-06-28 10:38:18 -07004295 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296
4297 /* Link is up then return cant set channel */
4298 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
4299 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004300 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301 return -EOPNOTSUPP;
4302 }
4303
4304 /* Settings by Frequency as input */
4305 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
4306 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
4307 uint32_t freq = wrqu->freq.m / 100000;
4308
4309 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
4310 && (freq != freq_chan_map[indx].freq))
4311 indx++;
4312 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
4313 return -EINVAL;
4314 }
4315 wrqu->freq.e = 0;
4316 wrqu->freq.m = freq_chan_map[indx].chan;
4317
4318 }
4319
4320 if (wrqu->freq.e == 0) {
4321 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
4322 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004323 hdd_notice("Channel %d is outside valid range from %d to %d",
4324 wrqu->freq.m,
4325 WNI_CFG_CURRENT_CHANNEL_STAMIN,
4326 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327 return -EINVAL;
4328 }
4329
4330 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4331
4332 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
4333 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304334 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004335 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 return -EIO;
4337 }
4338
4339 for (indx = 0; indx < numChans; indx++) {
4340 if (wrqu->freq.m == validChan[indx]) {
4341 break;
4342 }
4343 }
4344 } else {
4345
4346 return -EINVAL;
4347 }
4348
4349 if (indx >= numChans) {
4350 return -EINVAL;
4351 }
4352
4353 /* Set the Operational Channel */
4354 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
4355 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
4356 pRoamProfile->ChannelInfo.ChannelList =
4357 &pHddStaCtx->conn_info.operationChannel;
4358
Jeff Johnson99bac312016-06-28 10:38:18 -07004359 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004360
4361 EXIT();
4362
4363 return ret;
4364}
4365
4366/**
4367 * iw_set_freq() - SSR wrapper for __iw_set_freq()
4368 * @dev: pointer to net_device
4369 * @info: pointer to iw_request_info
4370 * @wrqu: pointer to iwreq_data
4371 * @extra: pointer to extra ioctl payload
4372 *
4373 * Return: 0 on success, error number otherwise
4374 */
4375static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4376 union iwreq_data *wrqu, char *extra)
4377{
4378 int ret;
4379
4380 cds_ssr_protect(__func__);
4381 ret = __iw_set_freq(dev, info, wrqu, extra);
4382 cds_ssr_unprotect(__func__);
4383
4384 return ret;
4385}
4386
4387/**
4388 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
4389 * @dev: device upon which the ioctl was received
4390 * @info: ioctl request information
4391 * @wrqu: ioctl request data
4392 * @extra: ioctl extra data
4393 *
4394 * Return: 0 on success, non-zero on error
4395 */
4396static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4397 struct iw_freq *fwrq, char *extra)
4398{
4399 uint32_t status = false, channel = 0, freq = 0;
4400 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4401 tHalHandle hHal;
4402 hdd_wext_state_t *pWextState;
4403 tCsrRoamProfile *pRoamProfile;
4404 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4405 hdd_context_t *hdd_ctx;
4406 int ret;
4407
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004408 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409
4410 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4411 ret = wlan_hdd_validate_context(hdd_ctx);
4412 if (0 != ret)
4413 return ret;
4414
Jeff Johnson441e1f72017-02-07 08:50:49 -08004415 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4416 if (0 != ret)
4417 return ret;
4418
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4420 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4421
4422 pRoamProfile = &pWextState->roamProfile;
4423
4424 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
4425 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304426 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004427 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 pAdapter->sessionId);
4429 return -EIO;
Jeff Johnson68755312017-02-10 11:46:55 -08004430 }
4431
4432 status = hdd_wlan_get_freq(channel, &freq);
4433 if (true == status) {
4434 /* Set Exponent parameter as 6 (MHZ)
4435 * in struct iw_freq iwlist & iwconfig
4436 * command shows frequency into proper
4437 * format (2.412 GHz instead of 246.2
4438 * MHz)
4439 */
4440 fwrq->m = freq;
4441 fwrq->e = MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442 }
4443 } else {
4444 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4445 * iwlist & iwconfig command shows frequency into proper
4446 * format (2.412 GHz instead of 246.2 MHz)
4447 */
4448 fwrq->m = 0;
4449 fwrq->e = MHZ;
4450 }
4451 return 0;
4452}
4453
4454/**
4455 * iw_get_freq() - SSR wrapper for __iw_get_freq()
4456 * @dev: pointer to net_device
4457 * @info: pointer to iw_request_info
4458 * @fwrq: pointer to frequency data
4459 * @extra: pointer to extra ioctl payload
4460 *
4461 * Return: 0 on success, error number otherwise
4462 */
4463static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4464 struct iw_freq *fwrq, char *extra)
4465{
4466 int ret;
4467
4468 cds_ssr_protect(__func__);
4469 ret = __iw_get_freq(dev, info, fwrq, extra);
4470 cds_ssr_unprotect(__func__);
4471
4472 return ret;
4473}
4474
4475/**
4476 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
4477 * @dev: device upon which the ioctl was received
4478 * @info: ioctl request information
4479 * @wrqu: ioctl request data
4480 * @extra: ioctl extra data
4481 *
4482 * Return: 0 on success, non-zero on error
4483 */
4484static int __iw_get_tx_power(struct net_device *dev,
4485 struct iw_request_info *info,
4486 union iwreq_data *wrqu, char *extra)
4487{
4488
4489 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4490 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4491 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4492 int ret;
4493
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004494 ENTER_DEV(dev);
4495
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 ret = wlan_hdd_validate_context(hdd_ctx);
4497 if (0 != ret)
4498 return ret;
4499
Jeff Johnson441e1f72017-02-07 08:50:49 -08004500 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4501 if (0 != ret)
4502 return ret;
4503
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4505 wrqu->txpower.value = 0;
4506 return 0;
4507 }
4508 wlan_hdd_get_class_astats(pAdapter);
4509 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
4510
4511 return 0;
4512}
4513
4514/**
4515 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
4516 * @dev: pointer to net_device
4517 * @info: pointer to iw_request_info
4518 * @wrqu: pointer to iwreq_data
4519 * @extra: pointer to extra ioctl payload
4520 *
4521 * Return: 0 on success, error number otherwise
4522 */
4523static int iw_get_tx_power(struct net_device *dev,
4524 struct iw_request_info *info,
4525 union iwreq_data *wrqu, char *extra)
4526{
4527 int ret;
4528
4529 cds_ssr_protect(__func__);
4530 ret = __iw_get_tx_power(dev, info, wrqu, extra);
4531 cds_ssr_unprotect(__func__);
4532
4533 return ret;
4534}
4535
4536/**
4537 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
4538 * @dev: device upon which the ioctl was received
4539 * @info: ioctl request information
4540 * @wrqu: ioctl request data
4541 * @extra: ioctl extra data
4542 *
4543 * Return: 0 on success, non-zero on error
4544 */
4545static int __iw_set_tx_power(struct net_device *dev,
4546 struct iw_request_info *info,
4547 union iwreq_data *wrqu, char *extra)
4548{
4549 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4550 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4551 hdd_context_t *hdd_ctx;
4552 int ret;
4553
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004554 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555
4556 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4557 ret = wlan_hdd_validate_context(hdd_ctx);
4558 if (0 != ret)
4559 return ret;
4560
Jeff Johnson441e1f72017-02-07 08:50:49 -08004561 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4562 if (0 != ret)
4563 return ret;
4564
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304566 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004567 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 return -EIO;
4569 }
4570
4571 EXIT();
4572
4573 return 0;
4574}
4575
4576/**
4577 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
4578 * @dev: pointer to net_device
4579 * @info: pointer to iw_request_info
4580 * @wrqu: pointer to iwreq_data
4581 * @extra: pointer to extra ioctl payload
4582 *
4583 * Return: 0 on success, error number otherwise
4584 */
4585static int iw_set_tx_power(struct net_device *dev,
4586 struct iw_request_info *info,
4587 union iwreq_data *wrqu, char *extra)
4588{
4589 int ret;
4590
4591 cds_ssr_protect(__func__);
4592 ret = __iw_set_tx_power(dev, info, wrqu, extra);
4593 cds_ssr_unprotect(__func__);
4594
4595 return ret;
4596}
4597
4598/**
4599 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
4600 * @dev: device upon which the ioctl was received
4601 * @info: ioctl request information
4602 * @wrqu: ioctl request data
4603 * @extra: ioctl extra data
4604 *
4605 * Return: 0 on success, non-zero on error
4606 */
4607static int __iw_get_bitrate(struct net_device *dev,
4608 struct iw_request_info *info,
4609 union iwreq_data *wrqu, char *extra)
4610{
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004611 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 hdd_wext_state_t *pWextState;
4613 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4614 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4615 hdd_context_t *hdd_ctx;
4616 int ret;
4617
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004618 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619
4620 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4621 ret = wlan_hdd_validate_context(hdd_ctx);
4622 if (0 != ret)
4623 return ret;
4624
Jeff Johnson441e1f72017-02-07 08:50:49 -08004625 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4626 if (0 != ret)
4627 return ret;
4628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4630 wrqu->bitrate.value = 0;
4631 } else {
4632 status =
4633 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4634 eCSR_HDD,
4635 SME_SUMMARY_STATS |
4636 SME_GLOBAL_CLASSA_STATS |
4637 SME_GLOBAL_CLASSB_STATS |
4638 SME_GLOBAL_CLASSC_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -08004639 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 hdd_statistics_cb, 0,
4641 false,
4642 pHddStaCtx->conn_info.staId[0],
4643 pAdapter, pAdapter->sessionId);
4644
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304645 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004646 hdd_err("Unable to retrieve statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004647 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 }
4649
4650 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4651
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004652 status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304653 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 WLAN_WAIT_TIME_STATS);
4655
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004656 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004657 hdd_err("SME timeout while retrieving statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004658 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659 }
4660
4661 wrqu->bitrate.value =
4662 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
4663 }
4664
4665 EXIT();
4666
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004667 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668}
4669
4670/**
4671 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
4672 * @dev: pointer to net_device
4673 * @info: pointer to iw_request_info
4674 * @wrqu: pointer to iwreq_data
4675 * @extra: pointer to extra ioctl payload
4676 *
4677 * Return: 0 on success, error number otherwise
4678 */
4679static int iw_get_bitrate(struct net_device *dev,
4680 struct iw_request_info *info,
4681 union iwreq_data *wrqu, char *extra)
4682{
4683 int ret;
4684
4685 cds_ssr_protect(__func__);
4686 ret = __iw_get_bitrate(dev, info, wrqu, extra);
4687 cds_ssr_unprotect(__func__);
4688
4689 return ret;
4690}
4691
4692/**
4693 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
4694 * @dev: device upon which the ioctl was received
4695 * @info: ioctl request information
4696 * @wrqu: ioctl request data
4697 * @extra: ioctl extra data
4698 *
4699 * Return: 0 on success, non-zero on error
4700 */
4701static int __iw_set_bitrate(struct net_device *dev,
4702 struct iw_request_info *info,
4703 union iwreq_data *wrqu, char *extra)
4704{
4705 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4706 hdd_wext_state_t *pWextState;
4707 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4708 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4709 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4710 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4711 uint32_t i, rate;
4712 uint32_t valid_rate = false, active_phy_mode = 0;
4713 hdd_context_t *hdd_ctx;
4714 int ret;
4715
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004716 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717
4718 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4719 ret = wlan_hdd_validate_context(hdd_ctx);
4720 if (0 != ret)
4721 return ret;
4722
Jeff Johnson441e1f72017-02-07 08:50:49 -08004723 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4724 if (0 != ret)
4725 return ret;
4726
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4728
4729 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4730 return -ENXIO;
4731 }
4732
4733 rate = wrqu->bitrate.value;
4734
4735 if (rate == -1) {
4736 rate = WNI_CFG_FIXED_RATE_AUTO;
4737 valid_rate = true;
4738 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
4739 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304740 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004741 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
4742 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
4743 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
4744 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
4745 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304746 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747 &&
4748 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
4749 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304750 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 for (i = 0; i < (b_len + a_len); ++i) {
4752 /* supported rates returned is double
4753 * the actual rate so we divide it by 2
4754 */
4755 if ((supp_rates[i] & 0x7F) / 2 ==
4756 rate) {
4757 valid_rate = true;
4758 rate = i +
4759 WNI_CFG_FIXED_RATE_1MBPS;
4760 break;
4761 }
4762 }
4763 }
4764 }
4765 }
4766 if (valid_rate != true) {
4767 return -EINVAL;
4768 }
4769 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304770 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004771 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004772 return -EIO;
4773 }
4774 return 0;
4775}
4776
4777/**
4778 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
4779 * @dev: pointer to net_device
4780 * @info: pointer to iw_request_info
4781 * @wrqu: pointer to iwreq_data
4782 * @extra: pointer to extra ioctl payload
4783 *
4784 * Return: 0 on success, error number otherwise
4785 */
4786static int iw_set_bitrate(struct net_device *dev,
4787 struct iw_request_info *info,
4788 union iwreq_data *wrqu, char *extra)
4789{
4790 int ret;
4791
4792 cds_ssr_protect(__func__);
4793 ret = __iw_set_bitrate(dev, info, wrqu, extra);
4794 cds_ssr_unprotect(__func__);
4795
4796 return ret;
4797}
4798
4799/**
4800 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
4801 * @dev: device upon which the ioctl was received
4802 * @info: ioctl request information
4803 * @wrqu: ioctl request data
4804 * @extra: ioctl extra data
4805 *
4806 * Return: 0 on success, non-zero on error
4807 */
4808static int __iw_set_genie(struct net_device *dev,
4809 struct iw_request_info *info,
4810 union iwreq_data *wrqu, char *extra)
4811{
4812 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4813 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4814 uint8_t *genie = NULL;
4815 uint8_t *base_genie = NULL;
4816 uint16_t remLen;
4817 hdd_context_t *hdd_ctx;
4818 int ret;
4819
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004820 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004821
4822 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4823 ret = wlan_hdd_validate_context(hdd_ctx);
4824 if (0 != ret)
4825 return ret;
4826
Jeff Johnson441e1f72017-02-07 08:50:49 -08004827 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4828 if (0 != ret)
4829 return ret;
4830
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 if (!wrqu->data.length) {
4832 hdd_clear_roam_profile_ie(pAdapter);
4833 EXIT();
4834 return 0;
4835 }
4836
4837 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4838 wrqu->data.length);
4839 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004840 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004841 return -ENOMEM;
4842 }
4843
4844 genie = base_genie;
4845
4846 remLen = wrqu->data.length;
4847
Jeff Johnson99bac312016-06-28 10:38:18 -07004848 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004849 genie[1]);
4850
4851 /* clear any previous genIE before this call */
4852 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
4853
4854 while (remLen >= 2) {
4855 uint16_t eLen = 0;
4856 uint8_t elementId;
4857 elementId = *genie++;
4858 eLen = *genie++;
4859 remLen -= 2;
4860
Jeff Johnson99bac312016-06-28 10:38:18 -07004861 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004862
4863 switch (elementId) {
4864 case IE_EID_VENDOR:
4865 if ((IE_LEN_SIZE + IE_EID_SIZE + IE_VENDOR_OUI_SIZE) > eLen) { /* should have at least OUI */
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304866 ret = -EINVAL;
4867 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004868 }
4869
4870 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
4871 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07004872 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
4873 genie[0], genie[1], genie[2],
4874 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004875
4876 if (SIR_MAC_MAX_IE_LENGTH <
4877 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004878 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304879 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304880 ret = -ENOMEM;
4881 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 }
4883 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
4884 memcpy(pWextState->genIE.addIEdata +
4885 curGenIELen, genie - 2, eLen + 2);
4886 pWextState->genIE.length += eLen + 2;
4887 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004888 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304889 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
4890 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
4891 ret = -EINVAL;
4892 QDF_ASSERT(0);
4893 goto exit;
4894 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004895 memset(pWextState->WPARSNIE, 0,
4896 MAX_WPA_RSN_IE_LEN);
4897 memcpy(pWextState->WPARSNIE, genie - 2,
4898 (eLen + 2));
4899 pWextState->roamProfile.pWPAReqIE =
4900 pWextState->WPARSNIE;
4901 pWextState->roamProfile.nWPAReqIELength =
4902 eLen + 2;
4903 } else { /* any vendorId except WPA IE should be accumulated to genIE */
4904
4905 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07004906 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
4907 genie[0], genie[1], genie[2],
4908 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909
4910 if (SIR_MAC_MAX_IE_LENGTH <
4911 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004912 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304913 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304914 ret = -ENOMEM;
4915 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004916 }
4917 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
4918 memcpy(pWextState->genIE.addIEdata +
4919 curGenIELen, genie - 2, eLen + 2);
4920 pWextState->genIE.length += eLen + 2;
4921 }
4922 break;
4923 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07004924 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304925 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
4926 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
4927 ret = -EINVAL;
4928 QDF_ASSERT(0);
4929 goto exit;
4930 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
4932 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
4933 pWextState->roamProfile.pRSNReqIE =
4934 pWextState->WPARSNIE;
4935 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
4936 break;
4937
4938 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004939 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304940 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 }
4942 genie += eLen;
4943 remLen -= eLen;
4944 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304945exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07004947 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304948 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949}
4950
4951/**
4952 * iw_set_genie() - SSR wrapper for __iw_set_genie()
4953 * @dev: pointer to net_device
4954 * @info: pointer to iw_request_info
4955 * @wrqu: pointer to iwreq_data
4956 * @extra: pointer to extra ioctl payload
4957 *
4958 * Return: 0 on success, error number otherwise
4959 */
4960static int iw_set_genie(struct net_device *dev,
4961 struct iw_request_info *info,
4962 union iwreq_data *wrqu, char *extra)
4963{
4964 int ret;
4965
4966 cds_ssr_protect(__func__);
4967 ret = __iw_set_genie(dev, info, wrqu, extra);
4968 cds_ssr_unprotect(__func__);
4969
4970 return ret;
4971}
4972
4973/**
4974 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
4975 * @dev: device upon which the ioctl was received
4976 * @info: ioctl request information
4977 * @wrqu: ioctl request data
4978 * @extra: ioctl extra data
4979 *
4980 * Return: 0 on success, non-zero on error
4981 */
4982static int __iw_get_genie(struct net_device *dev,
4983 struct iw_request_info *info,
4984 union iwreq_data *wrqu, char *extra)
4985{
4986 hdd_wext_state_t *pWextState;
4987 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4988 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304989 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004990 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
4991 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
4992 hdd_context_t *hdd_ctx;
4993 int ret;
4994
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004995 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004996
4997 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4998 ret = wlan_hdd_validate_context(hdd_ctx);
4999 if (0 != ret)
5000 return ret;
5001
Jeff Johnson441e1f72017-02-07 08:50:49 -08005002 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5003 if (0 != ret)
5004 return ret;
5005
Jeff Johnson99bac312016-06-28 10:38:18 -07005006 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007
5008 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5009
5010 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
5011 return -ENXIO;
5012 }
5013
5014 /* Return something ONLY if we are associated with an RSN or
5015 * WPA network
5016 */
5017 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
5018 return -ENXIO;
5019 }
5020
5021 /* Actually retrieve the RSN IE from CSR. (We previously sent
5022 * it down in the CSR Roam Profile.)
5023 */
5024 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
5025 pAdapter->sessionId,
5026 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305027 if (QDF_STATUS_SUCCESS != status) {
5028 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005029 return -EFAULT;
5030 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005031 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05305032 if (length > DOT11F_IE_RSN_MAX_LEN) {
5033 hdd_notice("invalid buffer length length:%d", length);
5034 return -E2BIG;
5035 }
5036 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005037
Jeff Johnson99bac312016-06-28 10:38:18 -07005038 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005039 wrqu->data.length);
5040
5041 EXIT();
5042
5043 return 0;
5044}
5045
5046/**
5047 * iw_get_genie() - SSR wrapper for __iw_get_genie()
5048 * @dev: pointer to net_device
5049 * @info: pointer to iw_request_info
5050 * @wrqu: pointer to iwreq_data
5051 * @extra: pointer to extra ioctl payload
5052 *
5053 * Return: 0 on success, error number otherwise
5054 */
5055static int iw_get_genie(struct net_device *dev,
5056 struct iw_request_info *info,
5057 union iwreq_data *wrqu, char *extra)
5058{
5059 int ret;
5060
5061 cds_ssr_protect(__func__);
5062 ret = __iw_get_genie(dev, info, wrqu, extra);
5063 cds_ssr_unprotect(__func__);
5064
5065 return ret;
5066}
5067
5068/**
5069 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
5070 * @dev: device upon which the ioctl was received
5071 * @info: ioctl request information
5072 * @wrqu: ioctl request data
5073 * @extra: ioctl extra data
5074 *
5075 * Return: 0 on success, non-zero on error
5076 */
5077static int __iw_get_encode(struct net_device *dev,
5078 struct iw_request_info *info,
5079 struct iw_point *dwrq, char *extra)
5080{
5081 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5082 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5083 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5084 int keyId;
5085 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
5086 int i;
5087 hdd_context_t *hdd_ctx;
5088 int ret;
5089
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005090 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091
5092 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5093 ret = wlan_hdd_validate_context(hdd_ctx);
5094 if (0 != ret)
5095 return ret;
5096
Jeff Johnson441e1f72017-02-07 08:50:49 -08005097 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5098 if (0 != ret)
5099 return ret;
5100
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005101 keyId = pRoamProfile->Keys.defaultIndex;
5102
5103 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005104 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105 return -EINVAL;
5106 }
5107
5108 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
5109 dwrq->flags |= IW_ENCODE_ENABLED;
5110 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305111 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 pRoamProfile->Keys.KeyLength[keyId]);
5113
5114 dwrq->flags |= (keyId + 1);
5115
5116 } else {
5117 dwrq->flags |= IW_ENCODE_DISABLED;
5118 }
5119
5120 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08005121 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005122 continue;
5123 } else {
5124 break;
5125 }
5126 }
5127
5128 if (MAX_WEP_KEYS == i) {
5129 dwrq->flags |= IW_ENCODE_NOKEY;
5130 }
5131
5132 authType =
5133 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
5134 conn_info.authType;
5135
5136 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
5137 dwrq->flags |= IW_ENCODE_OPEN;
5138 } else {
5139 dwrq->flags |= IW_ENCODE_RESTRICTED;
5140 }
5141 EXIT();
5142 return 0;
5143}
5144
5145/**
5146 * iw_get_encode() - SSR wrapper for __iw_get_encode()
5147 * @dev: pointer to net_device
5148 * @info: pointer to iw_request_info
5149 * @dwrq: pointer to encoding information
5150 * @extra: pointer to extra ioctl payload
5151 *
5152 * Return: 0 on success, error number otherwise
5153 */
5154static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
5155 struct iw_point *dwrq, char *extra)
5156{
5157 int ret;
5158
5159 cds_ssr_protect(__func__);
5160 ret = __iw_get_encode(dev, info, dwrq, extra);
5161 cds_ssr_unprotect(__func__);
5162
5163 return ret;
5164}
5165
5166/**
5167 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
5168 * @dev: device upon which the ioctl was received
5169 * @info: ioctl request information
5170 * @wrqu: ioctl request data
5171 * @extra: ioctl extra data
5172 *
5173 * Return: 0 on success, non-zero on error
5174 */
5175static int __iw_get_rts_threshold(struct net_device *dev,
5176 struct iw_request_info *info,
5177 union iwreq_data *wrqu, char *extra)
5178{
Jeff Johnson5b907622017-02-07 10:00:37 -08005179 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5180 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5181 uint32_t threshold = 0;
5182 hdd_context_t *hdd_ctx;
5183 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005185 ENTER_DEV(dev);
5186
Jeff Johnson5b907622017-02-07 10:00:37 -08005187 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5188 ret = wlan_hdd_validate_context(hdd_ctx);
5189 if (0 != ret)
5190 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005191
Jeff Johnson441e1f72017-02-07 08:50:49 -08005192 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5193 if (0 != ret)
5194 return ret;
5195
Jeff Johnson5b907622017-02-07 10:00:37 -08005196 if (QDF_STATUS_SUCCESS !=
5197 sme_cfg_get_int(hal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
5198 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
5199 return -EIO;
5200 }
5201 wrqu->rts.value = threshold;
5202
5203 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
5204
5205 EXIT();
5206
5207 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208}
5209
5210/**
5211 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
5212 * @dev: device upon which the ioctl was received
5213 * @info: ioctl request information
5214 * @wrqu: ioctl request data
5215 * @extra: ioctl extra data
5216 *
5217 * Return: 0 on success, non-zero on error
5218 */
5219static int __iw_set_rts_threshold(struct net_device *dev,
5220 struct iw_request_info *info,
5221 union iwreq_data *wrqu, char *extra)
5222{
5223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5224 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5225 hdd_context_t *hdd_ctx;
5226 int ret;
5227
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005228 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229
5230 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5231 ret = wlan_hdd_validate_context(hdd_ctx);
5232 if (0 != ret)
5233 return ret;
5234
Jeff Johnson441e1f72017-02-07 08:50:49 -08005235 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5236 if (0 != ret)
5237 return ret;
5238
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
5240 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
5241 return -EINVAL;
5242 }
5243
5244 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305245 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005246 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247 return -EIO;
5248 }
5249
5250 EXIT();
5251
5252 return 0;
5253}
5254
5255/**
5256 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
5257 * @dev: pointer to net_device
5258 * @info: pointer to iw_request_info
5259 * @wrqu: pointer to iwreq_data
5260 * @extra: pointer to extra ioctl payload
5261 *
5262 * Return: 0 on success, error number otherwise
5263 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005264int iw_get_rts_threshold(struct net_device *dev,
5265 struct iw_request_info *info,
5266 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005267{
5268 int ret;
5269
5270 cds_ssr_protect(__func__);
5271 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
5272 cds_ssr_unprotect(__func__);
5273
5274 return ret;
5275}
5276
5277/**
5278 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
5279 * @dev: pointer to net_device
5280 * @info: pointer to iw_request_info
5281 * @wrqu: pointer to iwreq_data
5282 * @extra: pointer to extra ioctl payload
5283 *
5284 * Return: 0 on success, error number otherwise
5285 */
5286static int iw_set_rts_threshold(struct net_device *dev,
5287 struct iw_request_info *info,
5288 union iwreq_data *wrqu, char *extra)
5289{
5290 int ret;
5291
5292 cds_ssr_protect(__func__);
5293 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
5294 cds_ssr_unprotect(__func__);
5295
5296 return ret;
5297}
5298
5299/**
5300 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
5301 * @dev: device upon which the ioctl was received
5302 * @info: ioctl request information
5303 * @wrqu: ioctl request data
5304 * @extra: ioctl extra data
5305 *
5306 * Return: 0 on success, non-zero on error
5307 */
5308static int __iw_get_frag_threshold(struct net_device *dev,
5309 struct iw_request_info *info,
5310 union iwreq_data *wrqu, char *extra)
5311{
Jeff Johnson5b907622017-02-07 10:00:37 -08005312 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5313 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5314 uint32_t threshold = 0;
5315 hdd_context_t *hdd_ctx;
5316 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005318 ENTER_DEV(dev);
5319
Jeff Johnson5b907622017-02-07 10:00:37 -08005320 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5321 ret = wlan_hdd_validate_context(hdd_ctx);
5322 if (0 != ret)
5323 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324
Jeff Johnson441e1f72017-02-07 08:50:49 -08005325 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5326 if (0 != ret)
5327 return ret;
5328
Jeff Johnson5b907622017-02-07 10:00:37 -08005329 if (sme_cfg_get_int(hal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
5330 != QDF_STATUS_SUCCESS) {
5331 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
5332 return -EIO;
5333 }
5334 wrqu->frag.value = threshold;
5335
5336 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
5337
5338 EXIT();
5339
5340 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341}
5342
5343/**
5344 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
5345 * @dev: pointer to net_device
5346 * @info: pointer to iw_request_info
5347 * @wrqu: pointer to iwreq_data
5348 * @extra: pointer to extra ioctl payload
5349 *
5350 * Return: 0 on success, error number otherwise
5351 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005352int iw_get_frag_threshold(struct net_device *dev,
5353 struct iw_request_info *info,
5354 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005355{
5356 int ret;
5357
5358 cds_ssr_protect(__func__);
5359 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
5360 cds_ssr_unprotect(__func__);
5361
5362 return ret;
5363}
5364
5365/**
5366 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
5367 * @dev: device upon which the ioctl was received
5368 * @info: ioctl request information
5369 * @wrqu: ioctl request data
5370 * @extra: ioctl extra data
5371 *
5372 * Return: 0 on success, non-zero on error
5373 */
5374static int __iw_set_frag_threshold(struct net_device *dev,
5375 struct iw_request_info *info,
5376 union iwreq_data *wrqu, char *extra)
5377{
5378 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5379 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5380 hdd_context_t *hdd_ctx;
5381 int ret;
5382
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005383 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384
5385 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5386 ret = wlan_hdd_validate_context(hdd_ctx);
5387 if (0 != ret)
5388 return ret;
5389
Jeff Johnson441e1f72017-02-07 08:50:49 -08005390 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5391 if (0 != ret)
5392 return ret;
5393
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
5395 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
5396 return -EINVAL;
5397 }
5398
5399 if (sme_cfg_set_int
5400 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305401 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005402 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005403 return -EIO;
5404 }
5405
5406 EXIT();
5407
5408 return 0;
5409}
5410
5411/**
5412 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
5413 * @dev: pointer to net_device
5414 * @info: pointer to iw_request_info
5415 * @wrqu: pointer to iwreq_data
5416 * @extra: pointer to extra ioctl payload
5417 *
5418 * Return: 0 on success, error number otherwise
5419 */
5420static int iw_set_frag_threshold(struct net_device *dev,
5421 struct iw_request_info *info,
5422 union iwreq_data *wrqu, char *extra)
5423{
5424 int ret;
5425
5426 cds_ssr_protect(__func__);
5427 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
5428 cds_ssr_unprotect(__func__);
5429
5430 return ret;
5431}
5432
5433/**
5434 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
5435 * @dev: device upon which the ioctl was received
5436 * @info: ioctl request information
5437 * @wrqu: ioctl request data
5438 * @extra: ioctl extra data
5439 *
5440 * Return: 0 on success, non-zero on error
5441 */
5442static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005443 struct iw_request_info *info,
5444 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445{
5446 hdd_adapter_t *adapter;
5447 hdd_context_t *hdd_ctx;
5448 int ret;
5449
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005450 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451
5452 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5453 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5454 ret = wlan_hdd_validate_context(hdd_ctx);
5455 if (0 != ret)
5456 return ret;
5457
Jeff Johnson441e1f72017-02-07 08:50:49 -08005458 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5459 if (0 != ret)
5460 return ret;
5461
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462 return -EOPNOTSUPP;
5463}
5464
5465/**
5466 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
5467 * @dev: pointer to net_device
5468 * @info: pointer to iw_request_info
5469 * @wrqu: pointer to iwreq_data
5470 * @extra: extra
5471 *
5472 * Return: 0 on success, error number otherwise
5473 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005474static int iw_get_power_mode(struct net_device *dev,
5475 struct iw_request_info *info,
5476 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477{
5478 int ret;
5479
5480 cds_ssr_protect(__func__);
5481 ret = __iw_get_power_mode(dev, info, wrqu, extra);
5482 cds_ssr_unprotect(__func__);
5483
5484 return ret;
5485}
5486
5487/**
5488 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
5489 * @dev: device upon which the ioctl was received
5490 * @info: ioctl request information
5491 * @wrqu: ioctl request data
5492 * @extra: ioctl extra data
5493 *
5494 * Return: 0 on success, non-zero on error
5495 */
5496static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005497 struct iw_request_info *info,
5498 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499{
5500 hdd_adapter_t *adapter;
5501 hdd_context_t *hdd_ctx;
5502 int ret;
5503
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005504 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005505
5506 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5507 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5508 ret = wlan_hdd_validate_context(hdd_ctx);
5509 if (0 != ret)
5510 return ret;
5511
Jeff Johnson441e1f72017-02-07 08:50:49 -08005512 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5513 if (0 != ret)
5514 return ret;
5515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 return -EOPNOTSUPP;
5517}
5518
5519/**
5520 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
5521 * @dev: pointer to net_device
5522 * @info: pointer to iw_request_info
5523 * @wrqu: pointer to iwreq_data
5524 * @extra: extra
5525 *
5526 * Return: 0 on success, error number otherwise
5527 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005528static int iw_set_power_mode(struct net_device *dev,
5529 struct iw_request_info *info,
5530 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005531{
5532 int ret;
5533
5534 cds_ssr_protect(__func__);
5535 ret = __iw_set_power_mode(dev, info, wrqu, extra);
5536 cds_ssr_unprotect(__func__);
5537
5538 return ret;
5539}
5540
5541/**
5542 * __iw_get_range() - SIOCGIWRANGE ioctl handler
5543 * @dev: device upon which the ioctl was received
5544 * @info: ioctl request information
5545 * @wrqu: ioctl request data
5546 * @extra: ioctl extra data
5547 *
5548 * Return: 0 on success, non-zero on error
5549 */
5550static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
5551 union iwreq_data *wrqu, char *extra)
5552{
5553 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5554 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5555 struct iw_range *range = (struct iw_range *)extra;
5556
5557 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5558
5559 uint32_t num_channels = sizeof(channels);
5560 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
5561 uint32_t a_len;
5562 uint32_t b_len;
5563 uint32_t active_phy_mode = 0;
5564 uint8_t index = 0, i;
5565 hdd_context_t *hdd_ctx;
5566 int ret;
5567
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005568 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569
5570 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5571 ret = wlan_hdd_validate_context(hdd_ctx);
5572 if (0 != ret)
5573 return ret;
5574
Jeff Johnson441e1f72017-02-07 08:50:49 -08005575 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5576 if (0 != ret)
5577 return ret;
5578
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005579 wrqu->data.length = sizeof(struct iw_range);
5580 memset(range, 0, sizeof(struct iw_range));
5581
5582
5583 /*Get the phy mode */
5584 if (sme_cfg_get_int(hHal,
5585 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305586 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005587 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588
5589 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5590 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
5591 /*Get the supported rates for 11G band */
5592 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5593 if (sme_cfg_get_str(hHal,
5594 WNI_CFG_SUPPORTED_RATES_11A,
5595 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305596 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
5598 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5599 }
5600 for (i = 0; i < a_len; i++) {
5601 range->bitrate[i] =
5602 ((supp_rates[i] & 0x7F) / 2) *
5603 1000000;
5604 }
5605 range->num_bitrates = a_len;
5606 } else {
5607 return -EIO;
5608 }
5609 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
5610 /*Get the supported rates for 11B band */
5611 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5612 if (sme_cfg_get_str(hHal,
5613 WNI_CFG_SUPPORTED_RATES_11B,
5614 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305615 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
5617 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5618 }
5619 for (i = 0; i < b_len; i++) {
5620 range->bitrate[i] =
5621 ((supp_rates[i] & 0x7F) / 2) *
5622 1000000;
5623 }
5624 range->num_bitrates = b_len;
5625 } else {
5626 return -EIO;
5627 }
5628 }
5629 }
5630
5631 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
5632 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
5633 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
5634
5635 range->encoding_size[0] = 5;
5636 range->encoding_size[1] = 13;
5637 range->num_encoding_sizes = 2;
5638 range->max_encoding_tokens = MAX_WEP_KEYS;
5639
5640 /* we support through Wireless Extensions 22 */
5641 range->we_version_compiled = WIRELESS_EXT;
5642 range->we_version_source = 22;
5643
5644 /*Supported Channels and Frequencies */
5645 if (sme_cfg_get_str
5646 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305647 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005648 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005649 return -EIO;
5650 }
5651 if (num_channels > IW_MAX_FREQUENCIES) {
5652 num_channels = IW_MAX_FREQUENCIES;
5653 }
5654
5655 range->num_channels = num_channels;
5656 range->num_frequency = num_channels;
5657
5658 for (index = 0; index < num_channels; index++) {
5659 uint32_t frq_indx = 0;
5660
5661 range->freq[index].i = channels[index];
5662 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
5663 if (channels[index] == freq_chan_map[frq_indx].chan) {
5664 range->freq[index].m =
5665 freq_chan_map[frq_indx].freq * 100000;
5666 range->freq[index].e = 1;
5667 break;
5668 }
5669 frq_indx++;
5670 }
5671 }
5672
5673 /* Event capability (kernel + driver) */
5674 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
5675 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
5676 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
5677 range->event_capa[1] = IW_EVENT_CAPA_K_1;
5678
5679 /*Encryption capability */
5680 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
5681 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
5682
5683 /* Txpower capability */
5684 range->txpower_capa = IW_TXPOW_MWATT;
5685
5686 /*Scanning capability */
5687#if WIRELESS_EXT >= 22
5688 range->scan_capa =
5689 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
5690#endif
5691
5692 EXIT();
5693 return 0;
5694}
5695
5696/**
5697 * iw_get_range() - SSR wrapper for __iw_get_range()
5698 * @dev: pointer to net_device
5699 * @info: pointer to iw_request_info
5700 * @wrqu: pointer to iwreq_data
5701 * @extra: pointer to extra ioctl payload
5702 *
5703 * Return: 0 on success, error number otherwise
5704 */
5705static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
5706 union iwreq_data *wrqu, char *extra)
5707{
5708 int ret;
5709
5710 cds_ssr_protect(__func__);
5711 ret = __iw_get_range(dev, info, wrqu, extra);
5712 cds_ssr_unprotect(__func__);
5713
5714 return ret;
5715}
5716
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005717struct class_a_stats {
5718 tCsrGlobalClassAStatsInfo class_a_stats;
5719};
5720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721/**
5722 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005723 * @stats: pointer to Class A stats
5724 * @context: user context originally registered with SME (always the
5725 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005726 *
5727 * Return: None
5728 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005729static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005730{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005731 struct hdd_request *request;
5732 struct class_a_stats *priv;
5733 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005735 ENTER();
5736 if ((NULL == stats) || (NULL == context)) {
5737 hdd_err("Bad param, stats [%p] context [%p]",
5738 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005739 return;
5740 }
5741
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005742 request = hdd_request_get(context);
5743 if (!request) {
5744 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005745 return;
5746 }
5747
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005748 returned_stats = stats;
5749 priv = hdd_request_priv(request);
5750 priv->class_a_stats = *returned_stats;
5751 hdd_request_complete(request);
5752 hdd_request_put(request);
5753 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005754}
5755
5756/**
5757 * wlan_hdd_get_class_astats() - Get Class A statistics
5758 * @pAdapter: adapter for which statistics are desired
5759 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305760 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005761 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305762QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005763{
5764 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305765 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005766 int ret;
5767 void *cookie;
5768 struct hdd_request *request;
5769 struct class_a_stats *priv;
5770 static const struct hdd_request_params params = {
5771 .priv_size = sizeof(*priv),
5772 .timeout_ms = WLAN_WAIT_TIME_STATS,
5773 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005774
5775 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005776 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305777 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005778 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08005779 if (cds_is_driver_recovering()) {
5780 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
5781 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305782 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 }
5784
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005785 request = hdd_request_alloc(&params);
5786 if (!request) {
5787 hdd_err("Request allocation failure");
5788 return QDF_STATUS_E_NOMEM;
5789 }
5790 cookie = hdd_request_cookie(request);
5791
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005792 /* query only for Class A statistics (which include link speed) */
5793 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
5794 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
5795 hdd_get_class_a_statistics_cb,
5796 0, /* not periodic */
5797 false, /* non-cached results */
5798 pHddStaCtx->conn_info.staId[0],
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005799 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305800 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07005801 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005802 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005803 }
5804
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005805 /* request was sent -- wait for the response */
5806 ret = hdd_request_wait_for_response(request);
5807 if (ret) {
5808 hdd_warn("SME timed out while retrieving Class A statistics");
5809 goto return_cached_results;
5810 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005812 /* update the adapter with the fresh results */
5813 priv = hdd_request_priv(request);
5814 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
5815
5816return_cached_results:
5817 /*
5818 * either we never sent a request, we sent a request and
5819 * received a response or we sent a request and timed out.
5820 * regardless we are done with the request.
5821 */
5822 hdd_request_put(request);
5823
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305824 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005825}
5826
Jeff Johnsondda167c2017-01-23 10:37:57 -08005827struct station_stats {
5828 tCsrSummaryStatsInfo summary_stats;
5829 tCsrGlobalClassAStatsInfo class_a_stats;
5830 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
5831};
5832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005833/**
5834 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08005835 * @stats: pointer to combined station stats
5836 * @context: user context originally registered with SME (always the
5837 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005838 *
5839 * Return: None
5840 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08005841static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005842{
Jeff Johnsondda167c2017-01-23 10:37:57 -08005843 struct hdd_request *request;
5844 struct station_stats *priv;
5845 tCsrSummaryStatsInfo *summary_stats;
5846 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05305847 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005848
Jeff Johnsondda167c2017-01-23 10:37:57 -08005849 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005850 hdd_err("Bad param, pStats [%p] pContext [%p]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08005851 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 return;
5853 }
5854
Jeff Johnsondda167c2017-01-23 10:37:57 -08005855 request = hdd_request_get(context);
5856 if (!request) {
5857 hdd_err("Obsolete request");
5858 return;
5859 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860
Jeff Johnsondda167c2017-01-23 10:37:57 -08005861 summary_stats = (tCsrSummaryStatsInfo *) stats;
5862 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05305863 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08005864 (class_a_stats + 1);
5865 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005866
5867 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08005868 priv->summary_stats = *summary_stats;
5869 priv->class_a_stats = *class_a_stats;
5870 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871
Jeff Johnsondda167c2017-01-23 10:37:57 -08005872 hdd_request_complete(request);
5873 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005874}
5875
5876/**
5877 * wlan_hdd_get_station_stats() - Get station statistics
5878 * @pAdapter: adapter for which statistics are desired
5879 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305880 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005881 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305882QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005883{
5884 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305885 QDF_STATUS hstatus;
Jeff Johnsondda167c2017-01-23 10:37:57 -08005886 int ret;
5887 void *cookie;
5888 struct hdd_request *request;
5889 struct station_stats *priv;
5890 static const struct hdd_request_params params = {
5891 .priv_size = sizeof(*priv),
5892 .timeout_ms = WLAN_WAIT_TIME_STATS,
5893 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005894
5895 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005896 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305897 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898 }
5899
Jeff Johnsondda167c2017-01-23 10:37:57 -08005900 request = hdd_request_alloc(&params);
5901 if (!request) {
5902 hdd_err("Request allocation failure");
5903 return QDF_STATUS_E_NOMEM;
5904 }
5905 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906
5907 /* query only for Summary & Class A statistics */
5908 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
5909 eCSR_HDD,
5910 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05305911 SME_GLOBAL_CLASSA_STATS |
5912 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005913 hdd_get_station_statistics_cb,
5914 0, /* not periodic */
5915 false, /* non-cached results */
5916 pHddStaCtx->conn_info.staId[0],
Jeff Johnsondda167c2017-01-23 10:37:57 -08005917 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305918 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005919 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005920 /* we'll return with cached values */
5921 } else {
5922 /* request was sent -- wait for the response */
Jeff Johnsondda167c2017-01-23 10:37:57 -08005923 ret = hdd_request_wait_for_response(request);
5924 if (ret) {
5925 hdd_warn("SME timed out while retrieving statistics");
5926 /* we'll returned a cached value below */
5927 } else {
5928 /* update the adapter with the fresh results */
5929 priv = hdd_request_priv(request);
5930 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
5931 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
5932 pAdapter->hdd_stats.per_chain_rssi_stats =
5933 priv->per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005934 }
5935 }
5936
Jeff Johnsondda167c2017-01-23 10:37:57 -08005937 /*
5938 * either we never sent a request, we sent a request and
5939 * received a response or we sent a request and timed out.
5940 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005941 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08005942 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005943
5944 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305945 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005946}
5947
5948/**
5949 * iw_get_linkspeed() - Get current link speed ioctl
5950 * @dev: device upon which the ioctl was received
5951 * @info: ioctl request information
5952 * @wrqu: ioctl request data
5953 * @extra: extra ioctl buffer
5954 *
5955 * Return: 0 on success, non-zero on error
5956 */
5957static int __iw_get_linkspeed(struct net_device *dev,
5958 struct iw_request_info *info,
5959 union iwreq_data *wrqu, char *extra)
5960{
5961 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5962 char *pLinkSpeed = (char *)extra;
5963 int len = sizeof(uint32_t) + 1;
5964 uint32_t link_speed = 0;
5965 hdd_context_t *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08005966 int ret;
5967 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005968
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005969 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305970
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005971 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08005972 ret = wlan_hdd_validate_context(hdd_ctx);
5973 if (0 != ret)
5974 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975
Jeff Johnson441e1f72017-02-07 08:50:49 -08005976 ret = hdd_check_private_wext_control(hdd_ctx, info);
5977 if (0 != ret)
5978 return ret;
5979
5980 ret = wlan_hdd_get_link_speed(pAdapter, &link_speed);
5981 if (0 != ret) {
5982 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983 }
5984
5985 wrqu->data.length = len;
5986 /* return the linkspeed as a string */
5987 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
5988 if ((rc < 0) || (rc >= len)) {
5989 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07005990 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005991 return -EIO;
5992 }
5993
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305994 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 /* a value is being successfully returned */
5996 return 0;
5997}
5998
5999static int iw_get_linkspeed(struct net_device *dev,
6000 struct iw_request_info *info,
6001 union iwreq_data *wrqu, char *extra)
6002{
6003 int ret;
6004
6005 cds_ssr_protect(__func__);
6006 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
6007 cds_ssr_unprotect(__func__);
6008
6009 return ret;
6010}
6011
6012/**
6013 * wlan_hdd_change_country_code_callback() - Change country code callback
6014 * @context: opaque context originally passed to SME. All functions
6015 * which use this callback pass the adapter upon which the country
6016 * code change is active
6017 *
6018 * This function is registered as the callback function when
6019 * sme_change_country_code() is invoked. Callers of
6020 * sme_change_country_code() subsequently wait for the adapter's
6021 * @change_country_code completion variable, so all this function
6022 * needs to do is set that completion variable so that execution can
6023 * continue.
6024 *
6025 * Return: none
6026 */
6027void wlan_hdd_change_country_code_callback(void *context)
6028{
6029
6030 hdd_adapter_t *adapter = context;
6031
6032 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
6033 complete(&adapter->change_country_code);
6034
6035 return;
6036}
6037
6038/**
6039 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
6040 * @dev: device upon which the ioctl was received
6041 * @info: ioctl request information
6042 * @wrqu: ioctl request data
6043 * @extra: ioctl extra data
6044 *
6045 * Return: 0 on success, non-zero on error
6046 */
6047static int __iw_set_nick(struct net_device *dev,
6048 struct iw_request_info *info,
6049 union iwreq_data *wrqu, char *extra)
6050{
6051 hdd_adapter_t *adapter;
6052 hdd_context_t *hdd_ctx;
6053 int ret;
6054
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006055 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056
6057 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6058 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6059 ret = wlan_hdd_validate_context(hdd_ctx);
6060 if (0 != ret)
6061 return ret;
6062
Jeff Johnson441e1f72017-02-07 08:50:49 -08006063 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6064 if (0 != ret)
6065 return ret;
6066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067 return 0;
6068}
6069
6070/**
6071 * iw_set_nick() - SSR wrapper for __iw_set_nick
6072 * @dev: pointer to net_device
6073 * @info: pointer to iw_request_info
6074 * @wrqu: pointer to iwreq_data
6075 * @extra: extra
6076 *
6077 * Return: 0 on success, error number otherwise
6078 */
6079static int iw_set_nick(struct net_device *dev,
6080 struct iw_request_info *info,
6081 union iwreq_data *wrqu, char *extra)
6082{
6083 int ret;
6084
6085 cds_ssr_protect(__func__);
6086 ret = __iw_set_nick(dev, info, wrqu, extra);
6087 cds_ssr_unprotect(__func__);
6088
6089 return ret;
6090}
6091
6092/**
6093 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
6094 * @dev: device upon which the ioctl was received
6095 * @info: ioctl request information
6096 * @wrqu: ioctl request data
6097 * @extra: ioctl extra data
6098 *
6099 * Return: 0 on success, non-zero on error
6100 */
6101static int __iw_get_nick(struct net_device *dev,
6102 struct iw_request_info *info,
6103 union iwreq_data *wrqu, char *extra)
6104{
6105 hdd_adapter_t *adapter;
6106 hdd_context_t *hdd_ctx;
6107 int ret;
6108
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006109 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110
6111 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6112 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6113 ret = wlan_hdd_validate_context(hdd_ctx);
6114 if (0 != ret)
6115 return ret;
6116
Jeff Johnson441e1f72017-02-07 08:50:49 -08006117 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6118 if (0 != ret)
6119 return ret;
6120
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006121 return 0;
6122}
6123
6124/**
6125 * iw_get_nick() - SSR wrapper for __iw_get_nick
6126 * @dev: pointer to net_device
6127 * @info: pointer to iw_request_info
6128 * @wrqu: pointer to iwreq_data
6129 * @extra: extra
6130 *
6131 * Return: 0 on success, error number otherwise
6132 */
6133static int iw_get_nick(struct net_device *dev,
6134 struct iw_request_info *info,
6135 union iwreq_data *wrqu, char *extra)
6136{
6137 int ret;
6138
6139 cds_ssr_protect(__func__);
6140 ret = __iw_get_nick(dev, info, wrqu, extra);
6141 cds_ssr_unprotect(__func__);
6142
6143 return ret;
6144}
6145
6146/**
6147 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
6148 * @dev: device upon which the ioctl was received
6149 * @info: ioctl request information
6150 * @wrqu: ioctl request data
6151 * @extra: ioctl extra data
6152 *
6153 * Return: 0 on success, non-zero on error
6154 */
6155static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6156 union iwreq_data *wrqu, char *extra)
6157{
6158 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6159 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6160 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6161 hdd_context_t *hdd_ctx;
6162 struct iw_point *encoderq = &(wrqu->encoding);
6163 uint32_t keyId;
6164 uint8_t key_length;
6165 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6166 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306167 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006168 int ret;
6169
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006170 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006171
6172 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6173 ret = wlan_hdd_validate_context(hdd_ctx);
6174 if (0 != ret)
6175 return ret;
6176
Jeff Johnson441e1f72017-02-07 08:50:49 -08006177 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6178 if (0 != ret)
6179 return ret;
6180
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006181 keyId = encoderq->flags & IW_ENCODE_INDEX;
6182
6183 if (keyId) {
6184 if (keyId > MAX_WEP_KEYS) {
6185 return -EINVAL;
6186 }
6187
6188 fKeyPresent = 1;
6189 keyId--;
6190 } else {
6191 fKeyPresent = 0;
6192 }
6193
6194 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006195 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006196 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006197 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
6198 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199 }
6200 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6201 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6202 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6203 eCSR_ENCRYPT_TYPE_NONE;
6204 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6205 eCSR_ENCRYPT_TYPE_NONE;
6206
6207 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6208 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6209
6210 if (eConnectionState_Associated ==
6211 pHddStaCtx->conn_info.connState) {
6212 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6213 status =
6214 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
6215 pAdapter->sessionId,
6216 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306217 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006218 unsigned long rc;
6219 rc = wait_for_completion_timeout(&pAdapter->
6220 disconnect_comp_var,
6221 msecs_to_jiffies
6222 (WLAN_WAIT_TIME_DISCONNECT));
6223 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07006224 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006225 }
6226 }
6227
6228 return status;
6229
6230 }
6231
6232 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006233 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006234
6235 pHddStaCtx->conn_info.authType =
6236 (encoderq->
6237 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
6238 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6239
6240 }
6241
6242 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006243 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006244
6245 key_length = wrqu->data.length;
6246
6247 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
6248
6249 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006250 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251 key_length);
6252
6253 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6254 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6255 pHddStaCtx->conn_info.authType)) {
6256 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
6257 } else {
6258 encryptionType =
6259 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6260 }
6261 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006262 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006263 key_length);
6264
6265 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6266 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6267 pHddStaCtx->conn_info.authType)) {
6268 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
6269 } else {
6270 encryptionType =
6271 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6272 }
6273 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006274 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006275 key_length);
6276 return -EINVAL;
6277 }
6278
6279 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6280 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
6281 pWextState->roamProfile.EncryptionType.numEntries = 1;
6282 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6283 encryptionType;
6284 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
6285 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6286 encryptionType;
6287
6288 if ((eConnectionState_NotConnected ==
6289 pHddStaCtx->conn_info.connState)
6290 &&
6291 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6292 pHddStaCtx->conn_info.authType)
6293 || (eCSR_AUTH_TYPE_SHARED_KEY ==
6294 pHddStaCtx->conn_info.authType))) {
6295
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306296 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006297 KeyMaterial[keyId][0], extra, key_length);
6298
6299 pWextState->roamProfile.Keys.KeyLength[keyId] =
6300 (uint8_t) key_length;
6301 pWextState->roamProfile.Keys.defaultIndex =
6302 (uint8_t) keyId;
6303
6304 return status;
6305 }
6306 }
6307
6308 return 0;
6309}
6310
6311/**
6312 * iw_set_encode() - SSR wrapper for __iw_set_encode()
6313 * @dev: pointer to net_device
6314 * @info: pointer to iw_request_info
6315 * @wrqu: pointer to iwreq_data
6316 * @extra: pointer to extra ioctl payload
6317 *
6318 * Return: 0 on success, error number otherwise
6319 */
6320static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6321 union iwreq_data *wrqu, char *extra)
6322{
6323 int ret;
6324
6325 cds_ssr_protect(__func__);
6326 ret = __iw_set_encode(dev, info, wrqu, extra);
6327 cds_ssr_unprotect(__func__);
6328
6329 return ret;
6330}
6331
6332/**
6333 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
6334 * @dev: device upon which the ioctl was received
6335 * @info: ioctl request information
6336 * @wrqu: ioctl request data
6337 * @extra: ioctl extra data
6338 *
6339 * Return: 0 on success, non-zero on error
6340 */
6341static int __iw_get_encodeext(struct net_device *dev,
6342 struct iw_request_info *info,
6343 struct iw_point *dwrq, char *extra)
6344{
6345 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6346 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6347 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
6348 int keyId;
6349 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6350 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
6351 int i, ret;
6352 hdd_context_t *hdd_ctx;
6353
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006354 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006355
6356 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6357 ret = wlan_hdd_validate_context(hdd_ctx);
6358 if (0 != ret)
6359 return ret;
6360
Jeff Johnson441e1f72017-02-07 08:50:49 -08006361 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6362 if (0 != ret)
6363 return ret;
6364
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006365 keyId = pRoamProfile->Keys.defaultIndex;
6366
6367 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006368 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006369 return -EINVAL;
6370 }
6371
6372 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
6373 dwrq->flags |= IW_ENCODE_ENABLED;
6374 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306375 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006376 pRoamProfile->Keys.KeyLength[keyId]);
6377 } else {
6378 dwrq->flags |= IW_ENCODE_DISABLED;
6379 }
6380
6381 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006382 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006383 continue;
6384 } else {
6385 break;
6386 }
6387 }
6388
6389 if (MAX_WEP_KEYS == i) {
6390 dwrq->flags |= IW_ENCODE_NOKEY;
6391 } else {
6392 dwrq->flags |= IW_ENCODE_ENABLED;
6393 }
6394
6395 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
6396
6397 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
6398 dwrq->flags |= IW_ENCODE_DISABLED;
6399 }
6400
6401 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
6402
6403 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
6404 dwrq->flags |= IW_ENCODE_OPEN;
6405 } else {
6406 dwrq->flags |= IW_ENCODE_RESTRICTED;
6407 }
6408 EXIT();
6409 return 0;
6410
6411}
6412
6413/**
6414 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
6415 * @dev: pointer to net_device
6416 * @info: pointer to iw_request_info
6417 * @dwrq: pointer to encoding information
6418 * @extra: pointer to extra ioctl payload
6419 *
6420 * Return: 0 on success, error number otherwise
6421 */
6422static int iw_get_encodeext(struct net_device *dev,
6423 struct iw_request_info *info,
6424 struct iw_point *dwrq, char *extra)
6425{
6426 int ret;
6427
6428 cds_ssr_protect(__func__);
6429 ret = __iw_get_encodeext(dev, info, dwrq, extra);
6430 cds_ssr_unprotect(__func__);
6431
6432 return ret;
6433}
6434
6435/**
6436 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
6437 * @dev: device upon which the ioctl was received
6438 * @info: ioctl request information
6439 * @wrqu: ioctl request data
6440 * @extra: ioctl extra data
6441 *
6442 * Return: 0 on success, non-zero on error
6443 */
6444static int __iw_set_encodeext(struct net_device *dev,
6445 struct iw_request_info *info,
6446 union iwreq_data *wrqu, char *extra)
6447{
6448 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6449 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6450 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6451 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306452 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006453 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6454 int ret;
6455 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6456 int key_index;
6457 struct iw_point *encoding = &wrqu->encoding;
6458 tCsrRoamSetKey setKey;
6459 uint32_t roamId = 0xFF;
6460
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006461 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006462
6463 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6464 ret = wlan_hdd_validate_context(hdd_ctx);
6465 if (0 != ret)
6466 return ret;
6467
Jeff Johnson441e1f72017-02-07 08:50:49 -08006468 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6469 if (0 != ret)
6470 return ret;
6471
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006472 key_index = encoding->flags & IW_ENCODE_INDEX;
6473
6474 if (key_index > 0) {
6475
6476 /*Convert from 1-based to 0-based keying */
6477 key_index--;
6478 }
6479 if (!ext->key_len) {
6480
6481 /*Set the encrytion type to NONE */
6482 pRoamProfile->EncryptionType.encryptionType[0] =
6483 eCSR_ENCRYPT_TYPE_NONE;
6484 return ret;
6485 }
6486
6487 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
6488 (IW_ENCODE_ALG_WEP == ext->alg)) {
6489 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
6490
Jeff Johnson99bac312016-06-28 10:38:18 -07006491 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006492 return -EINVAL;
Jeff Johnson68755312017-02-10 11:46:55 -08006493 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006494
Jeff Johnson68755312017-02-10 11:46:55 -08006495 /*Static wep, update the roam profile with the keys */
6496 if (ext->key_len &&
6497 (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
6498 key_index < CSR_MAX_NUM_KEY) {
6499 qdf_mem_copy(&pRoamProfile->Keys.
6500 KeyMaterial[key_index][0],
6501 ext->key, ext->key_len);
6502 pRoamProfile->Keys.KeyLength[key_index] =
6503 (uint8_t) ext->key_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006504
Jeff Johnson68755312017-02-10 11:46:55 -08006505 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
6506 pRoamProfile->Keys.defaultIndex =
6507 (uint8_t) key_index;
6508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006509 }
6510 return ret;
6511 }
6512
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306513 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006514
6515 setKey.keyId = key_index;
6516 setKey.keyLength = ext->key_len;
6517
6518 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306519 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006520 }
6521
6522 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
6523 /*Key direction for group is RX only */
6524 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05306525 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006526 } else {
6527
6528 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306529 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306530 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006531 }
6532
6533 /*For supplicant pae role is zero */
6534 setKey.paeRole = 0;
6535
6536 switch (ext->alg) {
6537 case IW_ENCODE_ALG_NONE:
6538 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6539 break;
6540
6541 case IW_ENCODE_ALG_WEP:
6542 setKey.encType =
6543 (ext->key_len ==
6544 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
6545 break;
6546
6547 case IW_ENCODE_ALG_TKIP:
6548 {
6549 uint8_t *pKey = &setKey.Key[0];
6550
6551 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
6552
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306553 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006554
6555 /* Supplicant sends the 32bytes key in this order
6556 * |--------------|----------|----------|
6557 * | Tk1 | TX MIC | RX MIC |
6558 * |--------------|----------|----------|
6559 * <---16bytes---><--8bytes--><--8bytes-->
6560 *
6561 *
6562 * Sme expects the 32 bytes key to be in the below order
6563 * |--------------|----------|----------|
6564 * | Tk1 | RX MIC | TX MIC |
6565 * |--------------|----------|----------|
6566 * <---16bytes---><--8bytes--><--8bytes-->
6567 */
6568
6569 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306570 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006571
6572 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306573 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006574
6575 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306576 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006577
6578 }
6579 break;
6580
6581 case IW_ENCODE_ALG_CCMP:
6582 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
6583 break;
6584
6585#ifdef FEATURE_WLAN_ESE
6586#define IW_ENCODE_ALG_KRK 6
6587 case IW_ENCODE_ALG_KRK:
6588 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
6589 break;
6590#endif /* FEATURE_WLAN_ESE */
6591
6592 default:
6593 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6594 break;
6595 }
6596
Jeff Johnson99bac312016-06-28 10:38:18 -07006597 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
6598 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006599
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006600 /* The supplicant may attempt to set the PTK once
6601 * pre-authentication is done. Save the key in the UMAC and
6602 * include it in the ADD BSS request
6603 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306604 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006605 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306606 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006607 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006608 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306609 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006610 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006611 return -EINVAL;
6612 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006613
6614 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6615
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306616 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006617 pAdapter->sessionId,
6618 &setKey, &roamId);
6619
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306620 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006621 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306622 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006623
6624 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6625 }
6626
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306627 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006628}
6629
6630/**
6631 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
6632 * @dev: pointer to net_device
6633 * @info: pointer to iw_request_info
6634 * @wrqu: pointer to iwreq_data
6635 * @extra: pointer to extra ioctl payload
6636 *
6637 * Return: 0 on success, error number otherwise
6638 */
6639static int iw_set_encodeext(struct net_device *dev,
6640 struct iw_request_info *info,
6641 union iwreq_data *wrqu, char *extra)
6642{
6643 int ret;
6644
6645 cds_ssr_protect(__func__);
6646 ret = __iw_set_encodeext(dev, info, wrqu, extra);
6647 cds_ssr_unprotect(__func__);
6648
6649 return ret;
6650}
6651
6652/**
6653 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
6654 * @dev: device upon which the ioctl was received
6655 * @info: ioctl request information
6656 * @wrqu: ioctl request data
6657 * @extra: ioctl extra data
6658 *
6659 * Return: 0 on success, non-zero on error
6660 */
6661static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
6662 union iwreq_data *wrqu, char *extra)
6663{
6664 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6665 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6666 hdd_context_t *hdd_ctx;
6667 int ret;
6668
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006669 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006670
6671 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6672 ret = wlan_hdd_validate_context(hdd_ctx);
6673 if (0 != ret)
6674 return ret;
6675
Jeff Johnson441e1f72017-02-07 08:50:49 -08006676 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6677 if (0 != ret)
6678 return ret;
6679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006680 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
6681 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
6682
Jeff Johnson99bac312016-06-28 10:38:18 -07006683 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006684
6685 return -EINVAL;
6686 }
6687
6688 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
6689
6690 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
6691 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
6692 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306693 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006694 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006695 return -EIO;
6696 }
6697 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
6698 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6699 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306700 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05306701 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006702 return -EIO;
6703 }
6704 }
6705 } else {
6706 return -EOPNOTSUPP;
6707 }
6708
Jeff Johnson99bac312016-06-28 10:38:18 -07006709 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006710
6711 EXIT();
6712
6713 return 0;
6714
6715}
6716
6717/**
6718 * iw_set_retry() - SSR wrapper for __iw_set_retry()
6719 * @dev: pointer to net_device
6720 * @info: pointer to iw_request_info
6721 * @wrqu: pointer to iwreq_data
6722 * @extra: pointer to extra ioctl payload
6723 *
6724 * Return: 0 on success, error number otherwise
6725 */
6726static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
6727 union iwreq_data *wrqu, char *extra)
6728{
6729 int ret;
6730
6731 cds_ssr_protect(__func__);
6732 ret = __iw_set_retry(dev, info, wrqu, extra);
6733 cds_ssr_unprotect(__func__);
6734
6735 return ret;
6736}
6737
6738/**
6739 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
6740 * @dev: device upon which the ioctl was received
6741 * @info: ioctl request information
6742 * @wrqu: ioctl request data
6743 * @extra: ioctl extra data
6744 *
6745 * Return: 0 on success, non-zero on error
6746 */
6747static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
6748 union iwreq_data *wrqu, char *extra)
6749{
6750 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6751 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6752 uint32_t retry = 0;
6753 hdd_context_t *hdd_ctx;
6754 int ret;
6755
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006756 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006757
6758 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6759 ret = wlan_hdd_validate_context(hdd_ctx);
6760 if (0 != ret)
6761 return ret;
6762
Jeff Johnson441e1f72017-02-07 08:50:49 -08006763 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6764 if (0 != ret)
6765 return ret;
6766
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006767 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
6768 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
6769
6770 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306771 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006772 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006773 return -EIO;
6774 }
6775
6776 wrqu->retry.value = retry;
6777 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
6778 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
6779
6780 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306781 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05306782 hdd_warn("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006783 return -EIO;
6784 }
6785
6786 wrqu->retry.value = retry;
6787 } else {
6788 return -EOPNOTSUPP;
6789 }
6790
Jeff Johnson99bac312016-06-28 10:38:18 -07006791 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006792
6793 EXIT();
6794
6795 return 0;
6796}
6797
6798/**
6799 * iw_get_retry() - SSR wrapper for __iw_get_retry()
6800 * @dev: pointer to net_device
6801 * @info: pointer to iw_request_info
6802 * @wrqu: pointer to iwreq_data
6803 * @extra: pointer to extra ioctl payload
6804 *
6805 * Return: 0 on success, error number otherwise
6806 */
6807static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
6808 union iwreq_data *wrqu, char *extra)
6809{
6810 int ret;
6811
6812 cds_ssr_protect(__func__);
6813 ret = __iw_get_retry(dev, info, wrqu, extra);
6814 cds_ssr_unprotect(__func__);
6815
6816 return ret;
6817}
6818
6819/**
6820 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
6821 * @dev: device upon which the ioctl was received
6822 * @info: ioctl request information
6823 * @wrqu: ioctl request data
6824 * @extra: ioctl extra data
6825 *
6826 * Return: 0 on success, non-zero on error
6827 */
6828static int __iw_set_mlme(struct net_device *dev,
6829 struct iw_request_info *info,
6830 union iwreq_data *wrqu, char *extra)
6831{
6832 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6833 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6834 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306835 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006836 hdd_context_t *hdd_ctx;
6837 int ret;
6838
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006839 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006840
6841 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6842 ret = wlan_hdd_validate_context(hdd_ctx);
6843 if (0 != ret)
6844 return ret;
6845
Jeff Johnson441e1f72017-02-07 08:50:49 -08006846 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6847 if (0 != ret)
6848 return ret;
6849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006850 /* reason_code is unused. By default it is set to
6851 * eCSR_DISCONNECT_REASON_UNSPECIFIED
6852 */
6853 switch (mlme->cmd) {
6854 case IW_MLME_DISASSOC:
6855 case IW_MLME_DEAUTH:
6856
6857 if (pHddStaCtx->conn_info.connState ==
6858 eConnectionState_Associated) {
6859 eCsrRoamDisconnectReason reason =
6860 eCSR_DISCONNECT_REASON_UNSPECIFIED;
6861
6862 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
6863 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
6864
6865 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6866 status =
6867 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
6868 pAdapter->sessionId, reason);
6869
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306870 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006871 unsigned long rc;
6872 rc = wait_for_completion_timeout(&pAdapter->
6873 disconnect_comp_var,
6874 msecs_to_jiffies
6875 (WLAN_WAIT_TIME_DISCONNECT));
6876 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07006877 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006878 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07006879 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
6880 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006881
6882 /* Resetting authKeyMgmt */
6883 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
6884 0;
6885
Jeff Johnson99bac312016-06-28 10:38:18 -07006886 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006887 wlan_hdd_netif_queue_control(pAdapter,
6888 WLAN_NETIF_TX_DISABLE_N_CARRIER,
6889 WLAN_CONTROL_PATH);
6890
6891 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006892 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
6893 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006894 }
6895 break;
6896 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07006897 hdd_err("%d Command should be Disassociate/Deauthenticate",
6898 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899 return -EINVAL;
6900 } /* end of switch */
6901
6902 EXIT();
6903
6904 return status;
6905
6906}
6907
6908/**
6909 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
6910 * @dev: pointer to net_device
6911 * @info: pointer to iw_request_info
6912 * @wrqu: pointer to iwreq_data
6913 * @extra: pointer to extra ioctl payload
6914 *
6915 * Return: 0 on success, error number otherwise
6916 */
6917static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
6918 union iwreq_data *wrqu, char *extra)
6919{
6920 int ret;
6921
6922 cds_ssr_protect(__func__);
6923 ret = __iw_set_mlme(dev, info, wrqu, extra);
6924 cds_ssr_unprotect(__func__);
6925
6926 return ret;
6927}
6928
6929/**
6930 * wlan_hdd_update_phymode() - handle change in PHY mode
6931 * @net: device upon which PHY mode change was received
6932 * @hal: umac handle for the driver
6933 * @new_phymode: new PHY mode for the device
6934 * @phddctx: pointer to the HDD context
6935 *
6936 * This function is called when the device is set to a new PHY mode.
6937 * It takes a holistic look at the desired PHY mode along with the
6938 * configured capabilities of the driver and the reported capabilities
6939 * of the hardware in order to correctly configure all PHY-related
6940 * parameters.
6941 *
6942 * Return: 0 on success, negative errno value on error
6943 */
6944int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
6945 int new_phymode, hdd_context_t *phddctx)
6946{
6947#ifdef QCA_HT_2040_COEX
6948 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306949 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006950#endif
6951 bool band_24 = false, band_5g = false;
6952 bool ch_bond24 = false, ch_bond5g = false;
6953 tSmeConfigParams smeconfig;
6954 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006955 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006956 eCsrPhyMode phymode = -EIO, old_phymode;
6957 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
6958 eCsrBand curr_band = eCSR_BAND_ALL;
6959
6960 old_phymode = sme_get_phy_mode(hal);
6961
6962 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
6963 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
6964 nChannelBondingMode24GHz))
6965 ch_bond24 = true;
6966
6967 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
6968 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
6969 nChannelBondingMode5GHz))
6970 ch_bond5g = true;
6971
6972 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
6973 band_24 = band_5g = true;
6974 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
6975 band_24 = true;
6976 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
6977 band_5g = true;
6978 }
6979
6980 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07006981 hdd_warn("ch_bond24=%d ch_bond5g=%d band_24=%d band_5g=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006982 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
6983
6984 switch (new_phymode) {
6985 case IEEE80211_MODE_AUTO:
6986 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
6987 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
6988 phymode = eCSR_DOT11_MODE_AUTO;
6989 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
6990 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
6991 curr_band = eCSR_BAND_ALL;
6992 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
6993 } else {
6994 sme_set_phy_mode(hal, old_phymode);
6995 return -EIO;
6996 }
6997 break;
6998 case IEEE80211_MODE_11A:
6999 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
7000 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7001 phymode = eCSR_DOT11_MODE_11a;
7002 hdd_dot11mode = eHDD_DOT11_MODE_11a;
7003 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7004 curr_band = eCSR_BAND_5G;
7005 } else {
7006 sme_set_phy_mode(hal, old_phymode);
7007 return -EIO;
7008 }
7009 break;
7010 case IEEE80211_MODE_11B:
7011 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
7012 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7013 phymode = eCSR_DOT11_MODE_11b;
7014 hdd_dot11mode = eHDD_DOT11_MODE_11b;
7015 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7016 curr_band = eCSR_BAND_24;
7017 } else {
7018 sme_set_phy_mode(hal, old_phymode);
7019 return -EIO;
7020 }
7021 break;
7022 case IEEE80211_MODE_11G:
7023 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
7024 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7025 phymode = eCSR_DOT11_MODE_11g;
7026 hdd_dot11mode = eHDD_DOT11_MODE_11g;
7027 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7028 curr_band = eCSR_BAND_24;
7029 } else {
7030 sme_set_phy_mode(hal, old_phymode);
7031 return -EIO;
7032 }
7033 break;
7034 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
7035 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
7036 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
7037 */
7038 case IEEE80211_MODE_11NA_HT20:
7039 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7040 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7041 phymode = eCSR_DOT11_MODE_11n;
7042 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7043 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7044 curr_band = eCSR_BAND_5G;
7045 } else {
7046 sme_set_phy_mode(hal, old_phymode);
7047 return -EIO;
7048 }
7049 break;
7050 case IEEE80211_MODE_11NA_HT40:
7051 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7052 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7053 phymode = eCSR_DOT11_MODE_11n;
7054 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7055 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7056 curr_band = eCSR_BAND_5G;
7057 } else {
7058 sme_set_phy_mode(hal, old_phymode);
7059 return -EIO;
7060 }
7061 break;
7062 case IEEE80211_MODE_11NG_HT20:
7063 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7064 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7065 phymode = eCSR_DOT11_MODE_11n;
7066 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7067 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7068 curr_band = eCSR_BAND_24;
7069 } else {
7070 sme_set_phy_mode(hal, old_phymode);
7071 return -EIO;
7072 }
7073 break;
7074 case IEEE80211_MODE_11NG_HT40:
7075 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7076 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7077 phymode = eCSR_DOT11_MODE_11n;
7078 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7079 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7080 curr_band = eCSR_BAND_24;
7081 } else {
7082 sme_set_phy_mode(hal, old_phymode);
7083 return -EIO;
7084 }
7085 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007086 case IEEE80211_MODE_11AC_VHT20:
7087 case IEEE80211_MODE_11AC_VHT40:
7088 case IEEE80211_MODE_11AC_VHT80:
7089 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
7090 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7091 phymode = eCSR_DOT11_MODE_11ac;
7092 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
7093 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7094 curr_band = eCSR_BAND_5G;
7095 } else {
7096 sme_set_phy_mode(hal, old_phymode);
7097 return -EIO;
7098 }
7099 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007100 case IEEE80211_MODE_2G_AUTO:
7101 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7102 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7103 phymode = eCSR_DOT11_MODE_AUTO;
7104 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7105 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7106 curr_band = eCSR_BAND_24;
7107 } else {
7108 sme_set_phy_mode(hal, old_phymode);
7109 return -EIO;
7110 }
7111 break;
7112 case IEEE80211_MODE_5G_AUTO:
7113 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7114 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7115 phymode = eCSR_DOT11_MODE_AUTO;
7116 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7117 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7118 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7119 curr_band = eCSR_BAND_5G;
7120 } else {
7121 sme_set_phy_mode(hal, old_phymode);
7122 return -EIO;
7123 }
7124 break;
7125 case IEEE80211_MODE_11AGN:
7126 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7127 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
7128 phymode = eCSR_DOT11_MODE_11n;
7129 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7130 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7131 curr_band = eCSR_BAND_ALL;
7132 } else {
7133 sme_set_phy_mode(hal, old_phymode);
7134 return -EIO;
7135 }
7136 break;
7137 default:
7138 return -EIO;
7139 }
7140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007141 switch (new_phymode) {
7142 case IEEE80211_MODE_11AC_VHT20:
7143 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7144 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
7145 break;
7146 case IEEE80211_MODE_11AC_VHT40:
7147 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
7148 break;
7149 case IEEE80211_MODE_11AC_VHT80:
7150 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7151 break;
7152 default:
7153 vhtchanwidth = phddctx->config->vhtChannelWidth;
7154 break;
7155 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007156
7157 if (phymode != -EIO) {
7158 sme_get_config_param(hal, &smeconfig);
7159 smeconfig.csrConfig.phyMode = phymode;
7160#ifdef QCA_HT_2040_COEX
7161 if (phymode == eCSR_DOT11_MODE_11n &&
7162 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
7163 smeconfig.csrConfig.obssEnabled = false;
7164 halStatus = sme_set_ht2040_mode(hal,
7165 pAdapter->sessionId,
7166 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307167 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007168 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007169 return -EIO;
7170 }
7171 } else if (phymode == eCSR_DOT11_MODE_11n &&
7172 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
7173 smeconfig.csrConfig.obssEnabled = true;
7174 halStatus = sme_set_ht2040_mode(hal,
7175 pAdapter->sessionId,
7176 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307177 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007178 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007179 return -EIO;
7180 }
7181 }
7182#endif
7183 smeconfig.csrConfig.eBand = curr_band;
7184 smeconfig.csrConfig.bandCapability = curr_band;
7185 if (curr_band == eCSR_BAND_24)
7186 smeconfig.csrConfig.Is11hSupportEnabled = 0;
7187 else
7188 smeconfig.csrConfig.Is11hSupportEnabled =
7189 phddctx->config->Is11hSupportEnabled;
7190 if (curr_band == eCSR_BAND_24)
7191 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7192 else if (curr_band == eCSR_BAND_24)
7193 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7194 else {
7195 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7196 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7197 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007198 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007199 sme_update_config(hal, &smeconfig);
7200
7201 phddctx->config->dot11Mode = hdd_dot11mode;
7202 phddctx->config->nBandCapability = curr_band;
7203 phddctx->config->nChannelBondingMode24GHz =
7204 smeconfig.csrConfig.channelBondingMode24GHz;
7205 phddctx->config->nChannelBondingMode5GHz =
7206 smeconfig.csrConfig.channelBondingMode5GHz;
7207 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07007208 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007209 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007210 return -EIO;
7211 }
7212 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07007213 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007214 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7215 else
Dustin Browna30892e2016-10-12 17:28:36 -07007216 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007217 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7218
Jeff Johnson99bac312016-06-28 10:38:18 -07007219 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007220 phymode, chwidth, curr_band, vhtchanwidth);
7221 }
7222
7223 return 0;
7224}
7225
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007226struct temperature_priv {
7227 int temperature;
7228};
7229
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007230/**
7231 * hdd_get_temperature_cb() - "Get Temperature" callback function
7232 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007233 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007234 *
7235 * This function is passed to sme_get_temperature() as the callback
7236 * function to be invoked when the temperature measurement is
7237 * available.
7238 *
7239 * Return: None
7240 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007241static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007242{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007243 struct hdd_request *request;
7244 struct temperature_priv *priv;
7245
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007246 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007247
7248 request = hdd_request_get(context);
7249 if (!request) {
7250 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007251 return;
7252 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007253
7254 priv = hdd_request_priv(request);
7255 priv->temperature = temperature;
7256 hdd_request_complete(request);
7257 hdd_request_put(request);
7258
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007259 EXIT();
7260}
7261
7262/**
7263 * wlan_hdd_get_temperature() - get current device temperature
7264 * @pAdapter: device upon which the request was made
7265 * @temperature: pointer to where the temperature is to be returned
7266 *
7267 * Return: 0 if a temperature value (either current or cached) was
7268 * returned, otherwise a negative errno is returned.
7269 *
7270 */
7271int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
7272{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307273 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007274 int ret;
7275 void *cookie;
7276 struct hdd_request *request;
7277 struct temperature_priv *priv;
7278 static const struct hdd_request_params params = {
7279 .priv_size = sizeof(*priv),
7280 .timeout_ms = WLAN_WAIT_TIME_STATS,
7281 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007282
7283 ENTER();
7284 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007285 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007286 return -EPERM;
7287 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007288
7289 request = hdd_request_alloc(&params);
7290 if (!request) {
7291 hdd_err("Request allocation failure");
7292 return -ENOMEM;
7293 }
7294 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007295 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007296 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307297 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007298 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007299 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007300 ret = hdd_request_wait_for_response(request);
7301 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007302 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007303 } else {
7304 /* update the adapter with the fresh results */
7305 priv = hdd_request_priv(request);
7306 if (priv->temperature)
7307 pAdapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007308 }
7309 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007310
7311 /*
7312 * either we never sent a request, we sent a request and
7313 * received a response or we sent a request and timed out.
7314 * regardless we are done with the request.
7315 */
7316 hdd_request_put(request);
7317
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007318 *temperature = pAdapter->temperature;
7319 EXIT();
7320 return 0;
7321}
7322
7323/**
7324 * iw_setint_getnone() - Generic "set integer" private ioctl handler
7325 * @dev: device upon which the ioctl was received
7326 * @info: ioctl request information
7327 * @wrqu: ioctl request data
7328 * @extra: ioctl extra data
7329 *
7330 * Return: 0 on success, non-zero on error
7331 */
7332static int __iw_setint_getnone(struct net_device *dev,
7333 struct iw_request_info *info,
7334 union iwreq_data *wrqu, char *extra)
7335{
7336 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7337 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7338 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007339 hdd_context_t *hdd_ctx;
7340 tSmeConfigParams smeConfig;
7341 int *value = (int *)extra;
7342 int sub_cmd = value[0];
7343 int set_value = value[1];
7344 int ret;
7345 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307346 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007347
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007348 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307349
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007350 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7351 ret = wlan_hdd_validate_context(hdd_ctx);
7352 if (0 != ret)
7353 return ret;
7354
Jeff Johnson441e1f72017-02-07 08:50:49 -08007355 ret = hdd_check_private_wext_control(hdd_ctx, info);
7356 if (0 != ret)
7357 return ret;
7358
Jeff Johnson441e1f72017-02-07 08:50:49 -08007359 memset(&smeConfig, 0x00, sizeof(smeConfig));
7360
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007361 switch (sub_cmd) {
7362 case WE_SET_11D_STATE:
7363 {
7364 if ((ENABLE_11D == set_value)
7365 || (DISABLE_11D == set_value)) {
7366
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007367 sme_get_config_param(hHal, &smeConfig);
7368 smeConfig.csrConfig.Is11dSupportEnabled =
7369 (bool) set_value;
7370
Jeff Johnson99bac312016-06-28 10:38:18 -07007371 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007372 smeConfig.csrConfig.
7373 Is11dSupportEnabled);
7374
7375 sme_update_config(hHal, &smeConfig);
7376 } else {
7377 return -EINVAL;
7378 }
7379 break;
7380 }
7381
7382 case WE_WOWL:
7383 {
7384 switch (set_value) {
7385 case 0x00:
7386 hdd_exit_wowl(pAdapter);
7387 break;
7388 case 0x01:
7389 case 0x02:
7390 case 0x03:
7391 enable_mp = (set_value & 0x01) ? 1 : 0;
7392 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07007393 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007394 (enable_mp ? "YES" : "NO"),
7395 (enable_pbm ? "YES" : "NO"));
7396 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
7397 break;
7398 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007399 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007400 set_value);
7401 ret = -EINVAL;
7402 break;
7403 }
7404
7405 break;
7406 }
7407 case WE_SET_POWER:
7408 {
7409 switch (set_value) {
7410 case 1:
7411 /* Enable PowerSave */
7412 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7413 SME_PS_ENABLE);
7414 break;
7415 case 2:
7416 /* Disable PowerSave */
7417 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7418 SME_PS_DISABLE);
7419 break;
7420 case 3: /* Enable UASPD */
7421 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
7422 break;
7423 case 4: /* Disable UASPD */
7424 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
7425 break;
7426 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007427 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007428 set_value);
7429 ret = -EINVAL;
7430 break;
7431 }
7432 break;
7433 }
7434
7435 case WE_SET_MAX_ASSOC:
7436 {
7437 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
7438 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
7439 ret = -EINVAL;
7440 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
7441 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307442 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007443 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007444 ret = -EIO;
7445 }
7446 break;
7447 }
7448
7449 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
7450 if (set_value == 0 || set_value == 1)
7451 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
7452 set_value;
7453 else
7454 ret = -EINVAL;
7455 break;
7456
7457 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007458 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
7459 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
7460 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7461 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307462 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007463 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007464 ret = -EINVAL;
7465 }
7466 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007467 case WE_SET_MC_RATE:
7468 {
7469 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
7470 break;
7471 }
7472 case WE_SET_TX_POWER:
7473 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307474 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007475
Anurag Chouhanc5548422016-02-24 18:33:27 +05307476 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007477 if (sme_set_tx_power
7478 (hHal, pAdapter->sessionId, bssid,
7479 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307480 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007481 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007482 return -EIO;
7483 }
7484 break;
7485 }
7486 case WE_SET_MAX_TX_POWER:
7487 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307488 struct qdf_mac_addr bssid;
7489 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007490
Jeff Johnson99bac312016-06-28 10:38:18 -07007491 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007492 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05307493 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
7494 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007495
7496 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307497 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007498 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007499 return -EIO;
7500 }
7501
7502 break;
7503 }
7504 case WE_SET_MAX_TX_POWER_2_4:
7505 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007506 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
7507 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007508 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307509 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007510 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007511 return -EIO;
7512 }
7513
7514 break;
7515 }
7516 case WE_SET_MAX_TX_POWER_5_0:
7517 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007518 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
7519 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007520 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307521 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007522 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007523 return -EIO;
7524 }
7525
7526 break;
7527 }
7528 case WE_SET_HIGHER_DTIM_TRANSITION:
7529 {
7530 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007531 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007532 set_value);
7533 ret = -EINVAL;
7534 } else {
7535 if (pAdapter->higherDtimTransition != set_value) {
7536 pAdapter->higherDtimTransition =
7537 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07007538 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007539 pAdapter->higherDtimTransition);
7540 }
7541 }
7542
7543 break;
7544 }
7545
7546 case WE_SET_TM_LEVEL:
7547 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007548 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007549 (void)sme_set_thermal_level(hHal, set_value);
7550 break;
7551 }
7552
7553 case WE_SET_PHYMODE:
7554 {
7555 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
7556
7557 ret =
7558 wlan_hdd_update_phymode(dev, hHal, set_value,
7559 phddctx);
7560 break;
7561 }
7562
7563 case WE_SET_NSS:
7564 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007565 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007566 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007567 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007568 ret = -EINVAL;
7569 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307570 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007571 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
7572 set_value))
7573 ret = -EINVAL;
7574 }
7575 break;
7576 }
7577
7578 case WE_SET_GTX_HT_MCS:
7579 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007580 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007581 ret = wma_cli_set_command(pAdapter->sessionId,
7582 WMI_VDEV_PARAM_GTX_HT_MCS,
7583 set_value, GTX_CMD);
7584 break;
7585 }
7586
7587 case WE_SET_GTX_VHT_MCS:
7588 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007589 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007590 set_value);
7591 ret = wma_cli_set_command(pAdapter->sessionId,
7592 WMI_VDEV_PARAM_GTX_VHT_MCS,
7593 set_value, GTX_CMD);
7594 break;
7595 }
7596
7597 case WE_SET_GTX_USRCFG:
7598 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007599 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007600 set_value);
7601 ret = wma_cli_set_command(pAdapter->sessionId,
7602 WMI_VDEV_PARAM_GTX_USR_CFG,
7603 set_value, GTX_CMD);
7604 break;
7605 }
7606
7607 case WE_SET_GTX_THRE:
7608 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007609 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007610 ret = wma_cli_set_command(pAdapter->sessionId,
7611 WMI_VDEV_PARAM_GTX_THRE,
7612 set_value, GTX_CMD);
7613 break;
7614 }
7615
7616 case WE_SET_GTX_MARGIN:
7617 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007618 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007619 ret = wma_cli_set_command(pAdapter->sessionId,
7620 WMI_VDEV_PARAM_GTX_MARGIN,
7621 set_value, GTX_CMD);
7622 break;
7623 }
7624
7625 case WE_SET_GTX_STEP:
7626 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007627 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007628 ret = wma_cli_set_command(pAdapter->sessionId,
7629 WMI_VDEV_PARAM_GTX_STEP,
7630 set_value, GTX_CMD);
7631 break;
7632 }
7633
7634 case WE_SET_GTX_MINTPC:
7635 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007636 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007637 ret = wma_cli_set_command(pAdapter->sessionId,
7638 WMI_VDEV_PARAM_GTX_MINTPC,
7639 set_value, GTX_CMD);
7640 break;
7641 }
7642
7643 case WE_SET_GTX_BWMASK:
7644 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007645 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007646 ret = wma_cli_set_command(pAdapter->sessionId,
7647 WMI_VDEV_PARAM_GTX_BW_MASK,
7648 set_value, GTX_CMD);
7649 break;
7650 }
7651
7652 case WE_SET_LDPC:
7653 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307654 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007655 break;
7656 }
7657
7658 case WE_SET_TX_STBC:
7659 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307660 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007661 break;
7662 }
7663
7664 case WE_SET_RX_STBC:
7665 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307666 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007667 break;
7668 }
7669
7670 case WE_SET_SHORT_GI:
7671 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007672 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007673 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
7674 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
7675 set_value);
7676 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07007677 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007678 break;
7679 }
7680
7681 case WE_SET_RTSCTS:
7682 {
7683 uint32_t value;
7684
Jeff Johnson99bac312016-06-28 10:38:18 -07007685 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007686 set_value);
7687
7688 if ((set_value & HDD_RTSCTS_EN_MASK) ==
7689 HDD_RTSCTS_ENABLE)
7690 value =
7691 (WLAN_HDD_GET_CTX(pAdapter))->config->
7692 RTSThreshold;
7693 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
7694 || ((set_value & HDD_RTSCTS_EN_MASK) ==
7695 HDD_CTS_ENABLE))
7696 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
7697 else
7698 return -EIO;
7699
7700 ret = wma_cli_set_command(pAdapter->sessionId,
7701 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7702 set_value, VDEV_CMD);
7703 if (!ret) {
7704 if (sme_cfg_set_int
7705 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307706 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007707 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007708 return -EIO;
7709 }
7710 }
7711
7712 break;
7713 }
7714
7715 case WE_SET_CHWIDTH:
7716 {
7717 bool chwidth = false;
7718 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
7719 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07007720 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007721 set_value);
7722 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007723 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007724 return -EINVAL;
7725 }
7726
7727 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7728 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
7729 nChannelBondingMode5GHz)))
7730 chwidth = true;
7731
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007732 sme_get_config_param(hHal, &smeConfig);
7733 switch (set_value) {
7734 case eHT_CHANNEL_WIDTH_20MHZ:
7735 smeConfig.csrConfig.channelBondingMode5GHz =
7736 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7737 break;
7738 case eHT_CHANNEL_WIDTH_40MHZ:
7739 if (chwidth)
7740 smeConfig.csrConfig.
7741 channelBondingMode5GHz =
7742 phddctx->config->
7743 nChannelBondingMode5GHz;
7744 else
7745 return -EINVAL;
7746
7747 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007748 case eHT_CHANNEL_WIDTH_80MHZ:
7749 if (chwidth)
7750 smeConfig.csrConfig.
7751 channelBondingMode5GHz =
7752 phddctx->config->
7753 nChannelBondingMode5GHz;
7754 else
7755 return -EINVAL;
7756
7757 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007758
7759 default:
7760 return -EINVAL;
7761 }
7762
7763 ret = wma_cli_set_command(pAdapter->sessionId,
7764 WMI_VDEV_PARAM_CHWIDTH,
7765 set_value, VDEV_CMD);
7766 if (!ret)
7767 sme_update_config(hHal, &smeConfig);
7768
7769 break;
7770 }
7771
7772 case WE_SET_ANI_EN_DIS:
7773 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007774 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007775 set_value);
7776 ret = wma_cli_set_command(pAdapter->sessionId,
7777 WMI_PDEV_PARAM_ANI_ENABLE,
7778 set_value, PDEV_CMD);
7779 break;
7780 }
7781
7782 case WE_SET_ANI_POLL_PERIOD:
7783 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007784 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007785 set_value);
7786 ret = wma_cli_set_command(pAdapter->sessionId,
7787 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
7788 set_value, PDEV_CMD);
7789 break;
7790 }
7791
7792 case WE_SET_ANI_LISTEN_PERIOD:
7793 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007794 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007795 set_value);
7796 ret = wma_cli_set_command(pAdapter->sessionId,
7797 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
7798 set_value, PDEV_CMD);
7799 break;
7800 }
7801
7802 case WE_SET_ANI_OFDM_LEVEL:
7803 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007804 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007805 set_value);
7806 ret = wma_cli_set_command(pAdapter->sessionId,
7807 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
7808 set_value, PDEV_CMD);
7809 break;
7810 }
7811
7812 case WE_SET_ANI_CCK_LEVEL:
7813 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007814 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007815 set_value);
7816 ret = wma_cli_set_command(pAdapter->sessionId,
7817 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
7818 set_value, PDEV_CMD);
7819 break;
7820 }
7821
7822 case WE_SET_DYNAMIC_BW:
7823 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007824 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007825 set_value);
7826 ret = wma_cli_set_command(pAdapter->sessionId,
7827 WMI_PDEV_PARAM_DYNAMIC_BW,
7828 set_value, PDEV_CMD);
7829 break;
7830 }
7831
7832 case WE_SET_CTS_CBW:
7833 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007834 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007835 ret = wma_cli_set_command(pAdapter->sessionId,
7836 WMI_PDEV_PARAM_CTS_CBW,
7837 set_value, PDEV_CMD);
7838 break;
7839 }
7840
7841 case WE_SET_11N_RATE:
7842 {
7843 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07007844 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007845 set_value);
7846
7847 if (set_value != 0xff) {
7848 rix = RC_2_RATE_IDX(set_value);
7849 if (set_value & 0x80) {
7850 preamble = WMI_RATE_PREAMBLE_HT;
7851 nss = HT_RC_2_STREAMS(set_value) - 1;
7852 } else {
7853 nss = 0;
7854 rix = RC_2_RATE_IDX(set_value);
7855 if (set_value & 0x10) {
7856 preamble =
7857 WMI_RATE_PREAMBLE_CCK;
7858 if (rix != 0x3)
7859 /* Enable Short
7860 * preamble always for
7861 * CCK except 1mbps
7862 */
7863 rix |= 0x4;
7864 } else {
7865 preamble =
7866 WMI_RATE_PREAMBLE_OFDM;
7867 }
7868 }
7869 set_value = (preamble << 6) | (nss << 4) | rix;
7870 }
7871 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
7872 set_value, rix, preamble, nss);
7873
7874 ret = wma_cli_set_command(pAdapter->sessionId,
7875 WMI_VDEV_PARAM_FIXED_RATE,
7876 set_value, VDEV_CMD);
7877 break;
7878 }
7879
7880 case WE_SET_VHT_RATE:
7881 {
7882 uint8_t preamble = 0, nss = 0, rix = 0;
7883
7884 if (set_value != 0xff) {
7885 rix = RC_2_RATE_IDX_11AC(set_value);
7886 preamble = WMI_RATE_PREAMBLE_VHT;
7887 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
7888
7889 set_value = (preamble << 6) | (nss << 4) | rix;
7890 }
7891 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
7892 set_value, rix, preamble, nss);
7893 ret = wma_cli_set_command(pAdapter->sessionId,
7894 WMI_VDEV_PARAM_FIXED_RATE,
7895 set_value, VDEV_CMD);
7896 break;
7897 }
7898
7899 case WE_SET_AMPDU:
7900 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007901 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007902 ret = wma_cli_set_command(pAdapter->sessionId,
7903 GEN_VDEV_PARAM_AMPDU,
7904 set_value, GEN_CMD);
7905 break;
7906 }
7907
7908 case WE_SET_AMSDU:
7909 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007910 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007911 ret = wma_cli_set_command(pAdapter->sessionId,
7912 GEN_VDEV_PARAM_AMSDU,
7913 set_value, GEN_CMD);
7914 break;
7915 }
7916
7917 case WE_SET_BURST_ENABLE:
7918 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007919 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007920 if ((set_value == 0) || (set_value == 1)) {
7921 ret = wma_cli_set_command(pAdapter->sessionId,
7922 WMI_PDEV_PARAM_BURST_ENABLE,
7923 set_value, PDEV_CMD);
7924 } else
7925 ret = -EINVAL;
7926 break;
7927 }
7928 case WE_SET_BURST_DUR:
7929 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007930 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07007931 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007932 ret = wma_cli_set_command(pAdapter->sessionId,
7933 WMI_PDEV_PARAM_BURST_DUR,
7934 set_value, PDEV_CMD);
7935 else
7936 ret = -EINVAL;
7937 break;
7938 }
7939
7940 case WE_SET_TX_CHAINMASK:
7941 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007942 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007943 set_value);
7944 ret = wma_cli_set_command(pAdapter->sessionId,
7945 WMI_PDEV_PARAM_TX_CHAIN_MASK,
7946 set_value, PDEV_CMD);
7947 break;
7948 }
7949
7950 case WE_SET_RX_CHAINMASK:
7951 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007952 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007953 set_value);
7954 ret = wma_cli_set_command(pAdapter->sessionId,
7955 WMI_PDEV_PARAM_RX_CHAIN_MASK,
7956 set_value, PDEV_CMD);
7957 break;
7958 }
7959
7960 case WE_SET_TXPOW_2G:
7961 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007962 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963 set_value);
7964 ret = wma_cli_set_command(pAdapter->sessionId,
7965 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
7966 set_value, PDEV_CMD);
7967 break;
7968 }
7969
7970 case WE_SET_TXPOW_5G:
7971 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007972 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007973 set_value);
7974 ret = wma_cli_set_command(pAdapter->sessionId,
7975 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
7976 set_value, PDEV_CMD);
7977 break;
7978 }
7979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007980 /* Firmware debug log */
7981 case WE_DBGLOG_LOG_LEVEL:
7982 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007983 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007984 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
7985 ret = wma_cli_set_command(pAdapter->sessionId,
7986 WMI_DBGLOG_LOG_LEVEL,
7987 set_value, DBG_CMD);
7988 break;
7989 }
7990
7991 case WE_DBGLOG_VAP_ENABLE:
7992 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007993 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007994 ret = wma_cli_set_command(pAdapter->sessionId,
7995 WMI_DBGLOG_VAP_ENABLE,
7996 set_value, DBG_CMD);
7997 break;
7998 }
7999
8000 case WE_DBGLOG_VAP_DISABLE:
8001 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008002 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008003 ret = wma_cli_set_command(pAdapter->sessionId,
8004 WMI_DBGLOG_VAP_DISABLE,
8005 set_value, DBG_CMD);
8006 break;
8007 }
8008
8009 case WE_DBGLOG_MODULE_ENABLE:
8010 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008011 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008012 set_value);
8013 hdd_ctx->fw_log_settings.enable = set_value;
8014 ret = wma_cli_set_command(pAdapter->sessionId,
8015 WMI_DBGLOG_MODULE_ENABLE,
8016 set_value, DBG_CMD);
8017 break;
8018 }
8019
8020 case WE_DBGLOG_MODULE_DISABLE:
8021 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008022 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008023 set_value);
8024 hdd_ctx->fw_log_settings.enable = set_value;
8025 ret = wma_cli_set_command(pAdapter->sessionId,
8026 WMI_DBGLOG_MODULE_DISABLE,
8027 set_value, DBG_CMD);
8028 break;
8029 }
8030 case WE_DBGLOG_MOD_LOG_LEVEL:
8031 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008032 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008033 set_value);
8034
8035 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
8036 hdd_ctx->fw_log_settings.index = 0;
8037
8038 hdd_ctx->fw_log_settings.
8039 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
8040 set_value;
8041 hdd_ctx->fw_log_settings.index++;
8042
8043 ret = wma_cli_set_command(pAdapter->sessionId,
8044 WMI_DBGLOG_MOD_LOG_LEVEL,
8045 set_value, DBG_CMD);
8046 break;
8047 }
8048
8049 case WE_DBGLOG_TYPE:
8050 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008051 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008052 hdd_ctx->fw_log_settings.dl_type = set_value;
8053 ret = wma_cli_set_command(pAdapter->sessionId,
8054 WMI_DBGLOG_TYPE,
8055 set_value, DBG_CMD);
8056 break;
8057 }
8058 case WE_DBGLOG_REPORT_ENABLE:
8059 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008060 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008061 set_value);
8062 hdd_ctx->fw_log_settings.dl_report = set_value;
8063 ret = wma_cli_set_command(pAdapter->sessionId,
8064 WMI_DBGLOG_REPORT_ENABLE,
8065 set_value, DBG_CMD);
8066 break;
8067 }
8068
8069 case WE_SET_TXRX_FWSTATS:
8070 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008071 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008072 ret = wma_cli_set_command(pAdapter->sessionId,
8073 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
8074 set_value, VDEV_CMD);
8075 break;
8076 }
8077
8078 case WE_TXRX_FWSTATS_RESET:
8079 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008080 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008081 ret = wma_cli_set_command(pAdapter->sessionId,
8082 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
8083 set_value, VDEV_CMD);
8084 break;
8085 }
8086
8087 case WE_DUMP_STATS:
8088 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008089 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008090 hdd_wlan_dump_stats(pAdapter, set_value);
8091 break;
8092 }
8093
8094 case WE_CLEAR_STATS:
8095 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008096 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008097 switch (set_value) {
8098 case WLAN_HDD_STATS:
8099 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
8100 memset(&pAdapter->hdd_stats, 0,
8101 sizeof(pAdapter->hdd_stats));
8102 break;
8103 case WLAN_TXRX_HIST_STATS:
8104 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
8105 break;
8106 case WLAN_HDD_NETIF_OPER_HISTORY:
8107 wlan_hdd_clear_netif_queue_history(hdd_ctx);
8108 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05308109 case WLAN_HIF_STATS:
8110 hdd_clear_hif_stats();
8111 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008112 default:
Leo Changfdb45c32016-10-28 11:09:23 -07008113 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
8114 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008115 }
8116 break;
8117 }
8118
8119 case WE_PPS_PAID_MATCH:
8120 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008121 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008122 return EINVAL;
8123
Jeff Johnson99bac312016-06-28 10:38:18 -07008124 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008125 set_value);
8126 ret = wma_cli_set_command(pAdapter->sessionId,
8127 WMI_VDEV_PPS_PAID_MATCH,
8128 set_value, PPS_CMD);
8129 break;
8130 }
8131
8132 case WE_PPS_GID_MATCH:
8133 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008134 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008135 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008136 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008137 set_value);
8138 ret = wma_cli_set_command(pAdapter->sessionId,
8139 WMI_VDEV_PPS_GID_MATCH,
8140 set_value, PPS_CMD);
8141 break;
8142 }
8143
8144 case WE_PPS_EARLY_TIM_CLEAR:
8145 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008146 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008147 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008148 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008149 set_value);
8150 ret = wma_cli_set_command(pAdapter->sessionId,
8151 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
8152 set_value, PPS_CMD);
8153 break;
8154 }
8155
8156 case WE_PPS_EARLY_DTIM_CLEAR:
8157 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008158 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008159 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008160 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008161 set_value);
8162 ret = wma_cli_set_command(pAdapter->sessionId,
8163 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
8164 set_value, PPS_CMD);
8165 break;
8166 }
8167
8168 case WE_PPS_EOF_PAD_DELIM:
8169 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008170 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008171 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008172 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008173 set_value);
8174 ret = wma_cli_set_command(pAdapter->sessionId,
8175 WMI_VDEV_PPS_EOF_PAD_DELIM,
8176 set_value, PPS_CMD);
8177 break;
8178 }
8179
8180 case WE_PPS_MACADDR_MISMATCH:
8181 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008182 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008183 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008184 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008185 set_value);
8186 ret = wma_cli_set_command(pAdapter->sessionId,
8187 WMI_VDEV_PPS_MACADDR_MISMATCH,
8188 set_value, PPS_CMD);
8189 break;
8190 }
8191
8192 case WE_PPS_DELIM_CRC_FAIL:
8193 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008194 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008195 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008196 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008197 set_value);
8198 ret = wma_cli_set_command(pAdapter->sessionId,
8199 WMI_VDEV_PPS_DELIM_CRC_FAIL,
8200 set_value, PPS_CMD);
8201 break;
8202 }
8203
8204 case WE_PPS_GID_NSTS_ZERO:
8205 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008206 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008207 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008208 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008209 set_value);
8210 ret = wma_cli_set_command(pAdapter->sessionId,
8211 WMI_VDEV_PPS_GID_NSTS_ZERO,
8212 set_value, PPS_CMD);
8213 break;
8214 }
8215
8216 case WE_PPS_RSSI_CHECK:
8217 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008218 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008219 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008220 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008221 set_value);
8222 ret = wma_cli_set_command(pAdapter->sessionId,
8223 WMI_VDEV_PPS_RSSI_CHECK,
8224 set_value, PPS_CMD);
8225 break;
8226 }
8227
8228 case WE_PPS_5G_EBT:
8229 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008230 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008231 return -EINVAL;
8232
Jeff Johnson99bac312016-06-28 10:38:18 -07008233 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008234 ret = wma_cli_set_command(pAdapter->sessionId,
8235 WMI_VDEV_PPS_5G_EBT,
8236 set_value, PPS_CMD);
8237 break;
8238 }
8239
8240 case WE_SET_HTSMPS:
8241 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008242 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008243 ret = wma_cli_set_command(pAdapter->sessionId,
8244 WMI_STA_SMPS_FORCE_MODE_CMDID,
8245 set_value, VDEV_CMD);
8246 break;
8247 }
8248
8249 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
8250 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008251 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008252 set_value);
8253 ret = wma_cli_set_command(pAdapter->sessionId,
8254 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
8255 set_value, QPOWER_CMD);
8256 break;
8257 }
8258
8259 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
8260 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008261 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008262 set_value);
8263 ret = wma_cli_set_command(
8264 pAdapter->sessionId,
8265 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
8266 set_value, QPOWER_CMD);
8267 break;
8268 }
8269
8270 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
8271 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008272 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008273 set_value);
8274 ret = wma_cli_set_command(
8275 pAdapter->sessionId,
8276 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
8277 set_value, QPOWER_CMD);
8278 break;
8279 }
8280
8281 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
8282 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008283 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008284 set_value);
8285 ret = wma_cli_set_command(
8286 pAdapter->sessionId,
8287 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
8288 set_value, QPOWER_CMD);
8289 break;
8290 }
8291
8292 case WE_MCC_CONFIG_LATENCY:
8293 {
8294 cds_set_mcc_latency(pAdapter, set_value);
8295 break;
8296 }
8297
8298 case WE_MCC_CONFIG_QUOTA:
8299 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008300 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008301 set_value);
8302 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
8303 break;
8304 }
8305 case WE_SET_DEBUG_LOG:
8306 {
8307 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05308308
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008309 hdd_ctx->config->gEnableDebugLog = set_value;
8310 sme_update_connect_debug(hdd_ctx->hHal, set_value);
8311 break;
8312 }
8313 case WE_SET_EARLY_RX_ADJUST_ENABLE:
8314 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008315 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008316 if ((set_value == 0) || (set_value == 1))
8317 ret = wma_cli_set_command(
8318 pAdapter->sessionId,
8319 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
8320 set_value, VDEV_CMD);
8321 else
8322 ret = -EINVAL;
8323 break;
8324 }
8325 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
8326 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008327 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008328 ret = wma_cli_set_command(pAdapter->sessionId,
8329 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
8330 set_value, VDEV_CMD);
8331 break;
8332 }
8333 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
8334 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008335 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008336 set_value);
8337 ret = wma_cli_set_command(
8338 pAdapter->sessionId,
8339 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
8340 set_value, VDEV_CMD);
8341 break;
8342 }
8343 case WE_SET_EARLY_RX_SLOP_STEP:
8344 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008345 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008346 set_value);
8347 ret = wma_cli_set_command(pAdapter->sessionId,
8348 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
8349 set_value, VDEV_CMD);
8350 break;
8351 }
8352 case WE_SET_EARLY_RX_INIT_SLOP:
8353 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008354 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008355 set_value);
8356 ret = wma_cli_set_command(pAdapter->sessionId,
8357 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
8358 set_value, VDEV_CMD);
8359 break;
8360 }
8361 case WE_SET_EARLY_RX_ADJUST_PAUSE:
8362 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008363 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008364 if ((set_value == 0) || (set_value == 1))
8365 ret = wma_cli_set_command(
8366 pAdapter->sessionId,
8367 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
8368 set_value, VDEV_CMD);
8369 else
8370 ret = -EINVAL;
8371 break;
8372 }
8373 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
8374 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008375 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008376 ret = wma_cli_set_command(pAdapter->sessionId,
8377 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
8378 set_value, VDEV_CMD);
8379 break;
8380 }
8381 case WE_SET_SCAN_DISABLE:
8382 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008383 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008384 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
8385 break;
8386 }
Govind Singha471e5e2015-10-12 17:11:14 +05308387 case WE_START_FW_PROFILE:
8388 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008389 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05308390 ret = wma_cli_set_command(pAdapter->sessionId,
8391 WMI_WLAN_PROFILE_TRIGGER_CMDID,
8392 set_value, DBG_CMD);
8393 break;
8394 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308395 case WE_SET_CHANNEL:
8396 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008397 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308398 pAdapter->sessionId, pAdapter->device_mode);
8399
Krunal Sonif07bb382016-03-10 13:02:11 -08008400 if ((QDF_STA_MODE == pAdapter->device_mode) ||
8401 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308402
8403 status = sme_ext_change_channel(hHal,
8404 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308405 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008406 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308407 status);
8408 ret = -EINVAL;
8409 }
8410 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008411 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308412 pAdapter->device_mode);
8413 ret = -EINVAL;
8414 }
8415 break;
8416 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308417 case WE_SET_CONC_SYSTEM_PREF:
8418 {
8419 hdd_info("New preference: %d", set_value);
8420 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
8421 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
8422 hdd_err("Invalid system preference %d", set_value);
8423 return -EINVAL;
8424 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308425
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308426 /* hdd_ctx, hdd_ctx->config are already checked for null */
8427 hdd_ctx->config->conc_system_pref = set_value;
8428 break;
8429 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008430 default:
8431 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008432 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008433 sub_cmd);
8434 ret = -EINVAL;
8435 break;
8436 }
8437 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308438 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008439 return ret;
8440}
8441
8442static int iw_setint_getnone(struct net_device *dev,
8443 struct iw_request_info *info,
8444 union iwreq_data *wrqu,
8445 char *extra)
8446{
8447 int ret;
8448
8449 cds_ssr_protect(__func__);
8450 ret = __iw_setint_getnone(dev, info, wrqu, extra);
8451 cds_ssr_unprotect(__func__);
8452
8453 return ret;
8454}
8455
8456/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008457 * __iw_setnone_get_threeint() - return three value to up layer.
8458 *
8459 * @dev: pointer of net_device of this wireless card
8460 * @info: meta data about Request sent
8461 * @wrqu: include request info
8462 * @extra: buf used for in/Output
8463 *
8464 * Return: execute result
8465 */
8466static int __iw_setnone_get_threeint(struct net_device *dev,
8467 struct iw_request_info *info,
8468 union iwreq_data *wrqu, char *extra)
8469{
8470 int ret = 0; /* success */
8471 uint32_t *value = (int *)extra;
8472 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8473 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8474
8475 ENTER_DEV(dev);
8476 ret = wlan_hdd_validate_context(hdd_ctx);
8477 if (0 != ret)
8478 return ret;
8479
Jeff Johnson441e1f72017-02-07 08:50:49 -08008480 ret = hdd_check_private_wext_control(hdd_ctx, info);
8481 if (0 != ret)
8482 return ret;
8483
Jeff Johnson99bac312016-06-28 10:38:18 -07008484 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008485 switch (value[0]) {
8486 case WE_GET_TSF:
8487 ret = hdd_indicate_tsf(adapter, value, 3);
8488 break;
8489 default:
8490 hdd_err("Invalid IOCTL get_value command %d", value[0]);
8491 break;
8492 }
8493 return ret;
8494}
8495
8496/**
8497 * iw_setnone_get_threeint() - return three value to up layer.
8498 *
8499 * @dev: pointer of net_device of this wireless card
8500 * @info: meta data about Request sent
8501 * @wrqu: include request info
8502 * @extra: buf used for in/Output
8503 *
8504 * Return: execute result
8505 */
8506static int iw_setnone_get_threeint(struct net_device *dev,
8507 struct iw_request_info *info,
8508 union iwreq_data *wrqu, char *extra)
8509{
8510 int ret;
8511
8512 cds_ssr_protect(__func__);
8513 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8514 cds_ssr_unprotect(__func__);
8515
8516 return ret;
8517}
8518
8519/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008520 * iw_setchar_getnone() - Generic "set string" private ioctl handler
8521 * @dev: device upon which the ioctl was received
8522 * @info: ioctl request information
8523 * @wrqu: ioctl request data
8524 * @extra: ioctl extra data
8525 *
8526 * Return: 0 on success, non-zero on error
8527 */
8528static int __iw_setchar_getnone(struct net_device *dev,
8529 struct iw_request_info *info,
8530 union iwreq_data *wrqu, char *extra)
8531{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308532 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008533 int sub_cmd;
8534 int ret;
8535 char *pBuffer = NULL;
8536 hdd_adapter_t *pAdapter = (netdev_priv(dev));
8537 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008538 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008539 struct iw_point s_priv_data;
8540
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008541 ENTER_DEV(dev);
8542
Mukul Sharma34777c62015-11-02 20:22:30 +05308543 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008544 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05308545 return -EPERM;
8546 }
8547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008548 ret = wlan_hdd_validate_context(hdd_ctx);
8549 if (0 != ret)
8550 return ret;
8551
Jeff Johnson441e1f72017-02-07 08:50:49 -08008552 ret = hdd_check_private_wext_control(hdd_ctx, info);
8553 if (0 != ret)
8554 return ret;
8555
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008556 /* helper function to get iwreq_data with compat handling. */
8557 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8558 return -EINVAL;
8559 }
8560
8561 /* make sure all params are correctly passed to function */
8562 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
8563 return -EINVAL;
8564 }
8565
8566 sub_cmd = s_priv_data.flags;
8567
8568 /* ODD number is used for set, copy data using copy_from_user */
8569 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8570 s_priv_data.length);
8571 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008572 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008573 return -ENOMEM;
8574 }
8575
Jeff Johnson99bac312016-06-28 10:38:18 -07008576 hdd_notice("Received length %d", s_priv_data.length);
8577 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008578
8579 switch (sub_cmd) {
8580 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07008581 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008582 hdd_add_wowl_ptrn(pAdapter, pBuffer);
8583 break;
8584 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07008585 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008586 hdd_del_wowl_ptrn(pAdapter, pBuffer);
8587 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008588 case WE_NEIGHBOR_REPORT_REQUEST:
8589 {
8590 tRrmNeighborReq neighborReq;
8591 tRrmNeighborRspCallbackInfo callbackInfo;
8592
8593 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008594 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008595 neighborReq.no_ssid =
8596 (s_priv_data.length - 1) ? false : true;
8597 if (!neighborReq.no_ssid) {
8598 neighborReq.ssid.length =
8599 (s_priv_data.length - 1) >
8600 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308601 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008602 pBuffer,
8603 neighborReq.ssid.length);
8604 }
8605
8606 callbackInfo.neighborRspCallback = NULL;
8607 callbackInfo.neighborRspCallbackContext = NULL;
8608 callbackInfo.timeout = 5000; /* 5 seconds */
8609 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
8610 (pAdapter),
8611 pAdapter->sessionId,
8612 &neighborReq,
8613 &callbackInfo);
8614 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008615 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008616 ret = -EINVAL;
8617 }
8618 }
8619 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008620 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008621 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008622 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
8623 s_priv_data.length);
8624 break;
8625 case WE_SET_CONFIG:
8626 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308627 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008628 ret = -EINVAL;
8629 }
8630 break;
8631 default:
8632 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008633 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008634 sub_cmd);
8635 ret = -EINVAL;
8636 break;
8637 }
8638 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07008639 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308640 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008641 return ret;
8642}
8643
8644static int iw_setchar_getnone(struct net_device *dev,
8645 struct iw_request_info *info,
8646 union iwreq_data *wrqu, char *extra)
8647{
8648 int ret;
8649
8650 cds_ssr_protect(__func__);
8651 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
8652 cds_ssr_unprotect(__func__);
8653
8654 return ret;
8655}
8656
8657/**
8658 * iw_setnone_getint() - Generic "get integer" private ioctl handler
8659 * @dev: device upon which the ioctl was received
8660 * @info: ioctl request information
8661 * @wrqu: ioctl request data
8662 * @extra: ioctl extra data
8663 *
8664 * Return: 0 on success, non-zero on error
8665 */
8666static int __iw_setnone_getint(struct net_device *dev,
8667 struct iw_request_info *info,
8668 union iwreq_data *wrqu, char *extra)
8669{
8670 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8671 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8672 int *value = (int *)extra;
8673 int ret;
8674 tSmeConfigParams smeConfig;
8675 hdd_context_t *hdd_ctx;
8676
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008677 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308678
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008679 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8680 ret = wlan_hdd_validate_context(hdd_ctx);
8681 if (0 != ret)
8682 return ret;
8683
Jeff Johnson441e1f72017-02-07 08:50:49 -08008684 ret = hdd_check_private_wext_control(hdd_ctx, info);
8685 if (0 != ret)
8686 return ret;
8687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008688 switch (value[0]) {
8689 case WE_GET_11D_STATE:
8690 {
8691 sme_get_config_param(hHal, &smeConfig);
8692
8693 *value = smeConfig.csrConfig.Is11dSupportEnabled;
8694
Jeff Johnson99bac312016-06-28 10:38:18 -07008695 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008696
8697 break;
8698 }
8699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008700 case WE_GET_WLAN_DBG:
8701 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308702 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008703 *value = 0;
8704 break;
8705 }
8706 case WE_GET_MAX_ASSOC:
8707 {
8708 if (sme_cfg_get_int
8709 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308710 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008711 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008712 ret = -EIO;
8713 }
8714 break;
8715 }
8716 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
8717 *value = (WLAN_HDD_GET_CTX(
8718 pAdapter))->config->force_sap_acs;
8719 break;
8720
8721 case WE_GET_CONCURRENCY_MODE:
8722 {
8723 *value = cds_get_concurrency_mode();
8724
Jeff Johnson99bac312016-06-28 10:38:18 -07008725 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008726 break;
8727 }
8728
8729 case WE_GET_NSS:
8730 {
8731 sme_get_config_param(hHal, &smeConfig);
8732 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07008733 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008734 break;
8735 }
8736
8737 case WE_GET_GTX_HT_MCS:
8738 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008739 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008740 *value = wma_cli_get_command(pAdapter->sessionId,
8741 WMI_VDEV_PARAM_GTX_HT_MCS,
8742 GTX_CMD);
8743 break;
8744 }
8745
8746 case WE_GET_GTX_VHT_MCS:
8747 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008748 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008749 *value = wma_cli_get_command(pAdapter->sessionId,
8750 WMI_VDEV_PARAM_GTX_VHT_MCS,
8751 GTX_CMD);
8752 break;
8753 }
8754
8755 case WE_GET_GTX_USRCFG:
8756 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008757 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008758 *value = wma_cli_get_command(pAdapter->sessionId,
8759 WMI_VDEV_PARAM_GTX_USR_CFG,
8760 GTX_CMD);
8761 break;
8762 }
8763
8764 case WE_GET_GTX_THRE:
8765 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008766 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008767 *value = wma_cli_get_command(pAdapter->sessionId,
8768 WMI_VDEV_PARAM_GTX_THRE,
8769 GTX_CMD);
8770 break;
8771 }
8772
8773 case WE_GET_GTX_MARGIN:
8774 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008775 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008776 *value = wma_cli_get_command(pAdapter->sessionId,
8777 WMI_VDEV_PARAM_GTX_MARGIN,
8778 GTX_CMD);
8779 break;
8780 }
8781
8782 case WE_GET_GTX_STEP:
8783 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008784 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008785 *value = wma_cli_get_command(pAdapter->sessionId,
8786 WMI_VDEV_PARAM_GTX_STEP,
8787 GTX_CMD);
8788 break;
8789 }
8790
8791 case WE_GET_GTX_MINTPC:
8792 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008793 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008794 *value = wma_cli_get_command(pAdapter->sessionId,
8795 WMI_VDEV_PARAM_GTX_MINTPC,
8796 GTX_CMD);
8797 break;
8798 }
8799
8800 case WE_GET_GTX_BWMASK:
8801 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008802 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008803 *value = wma_cli_get_command(pAdapter->sessionId,
8804 WMI_VDEV_PARAM_GTX_BW_MASK,
8805 GTX_CMD);
8806 break;
8807 }
8808
8809 case WE_GET_LDPC:
8810 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308811 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008812 break;
8813 }
8814
8815 case WE_GET_TX_STBC:
8816 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308817 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008818 break;
8819 }
8820
8821 case WE_GET_RX_STBC:
8822 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308823 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008824 break;
8825 }
8826
8827 case WE_GET_SHORT_GI:
8828 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008829 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008830 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
8831 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
8832 break;
8833 }
8834
8835 case WE_GET_RTSCTS:
8836 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008837 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008838 *value = wma_cli_get_command(pAdapter->sessionId,
8839 WMI_VDEV_PARAM_ENABLE_RTSCTS,
8840 VDEV_CMD);
8841 break;
8842 }
8843
8844 case WE_GET_CHWIDTH:
8845 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008846 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008847 *value = wma_cli_get_command(pAdapter->sessionId,
8848 WMI_VDEV_PARAM_CHWIDTH,
8849 VDEV_CMD);
8850 break;
8851 }
8852
8853 case WE_GET_ANI_EN_DIS:
8854 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008855 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008856 *value = wma_cli_get_command(pAdapter->sessionId,
8857 WMI_PDEV_PARAM_ANI_ENABLE,
8858 PDEV_CMD);
8859 break;
8860 }
8861
8862 case WE_GET_ANI_POLL_PERIOD:
8863 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008864 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008865 *value = wma_cli_get_command(pAdapter->sessionId,
8866 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
8867 PDEV_CMD);
8868 break;
8869 }
8870
8871 case WE_GET_ANI_LISTEN_PERIOD:
8872 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008873 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008874 *value = wma_cli_get_command(pAdapter->sessionId,
8875 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
8876 PDEV_CMD);
8877 break;
8878 }
8879
8880 case WE_GET_ANI_OFDM_LEVEL:
8881 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008882 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008883 *value = wma_cli_get_command(pAdapter->sessionId,
8884 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
8885 PDEV_CMD);
8886 break;
8887 }
8888
8889 case WE_GET_ANI_CCK_LEVEL:
8890 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008891 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008892 *value = wma_cli_get_command(pAdapter->sessionId,
8893 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
8894 PDEV_CMD);
8895 break;
8896 }
8897
8898 case WE_GET_DYNAMIC_BW:
8899 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008900 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008901 *value = wma_cli_get_command(pAdapter->sessionId,
8902 WMI_PDEV_PARAM_DYNAMIC_BW,
8903 PDEV_CMD);
8904 break;
8905 }
8906
8907 case WE_GET_11N_RATE:
8908 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008909 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008910 *value = wma_cli_get_command(pAdapter->sessionId,
8911 WMI_VDEV_PARAM_FIXED_RATE,
8912 VDEV_CMD);
8913 break;
8914 }
8915
8916 case WE_GET_AMPDU:
8917 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008918 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008919 *value = wma_cli_get_command(pAdapter->sessionId,
8920 GEN_VDEV_PARAM_AMPDU,
8921 GEN_CMD);
8922 break;
8923 }
8924
8925 case WE_GET_AMSDU:
8926 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008927 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008928 *value = wma_cli_get_command(pAdapter->sessionId,
8929 GEN_VDEV_PARAM_AMSDU,
8930 GEN_CMD);
8931 break;
8932 }
8933
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07008934 case WE_GET_ROAM_SYNCH_DELAY:
8935 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008936 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07008937 *value = wma_cli_get_command(pAdapter->sessionId,
8938 GEN_VDEV_ROAM_SYNCH_DELAY,
8939 GEN_CMD);
8940 break;
8941 }
8942
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008943 case WE_GET_BURST_ENABLE:
8944 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008945 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008946 *value = wma_cli_get_command(pAdapter->sessionId,
8947 WMI_PDEV_PARAM_BURST_ENABLE,
8948 PDEV_CMD);
8949 break;
8950 }
8951 case WE_GET_BURST_DUR:
8952 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008953 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008954 *value = wma_cli_get_command(pAdapter->sessionId,
8955 WMI_PDEV_PARAM_BURST_DUR,
8956 PDEV_CMD);
8957 break;
8958 }
8959
8960 case WE_GET_TX_CHAINMASK:
8961 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008962 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008963 *value = wma_cli_get_command(pAdapter->sessionId,
8964 WMI_PDEV_PARAM_TX_CHAIN_MASK,
8965 PDEV_CMD);
8966 break;
8967 }
8968
8969 case WE_GET_RX_CHAINMASK:
8970 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008971 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008972 *value = wma_cli_get_command(pAdapter->sessionId,
8973 WMI_PDEV_PARAM_RX_CHAIN_MASK,
8974 PDEV_CMD);
8975 break;
8976 }
8977
8978 case WE_GET_TXPOW_2G:
8979 {
8980 uint32_t txpow2g = 0;
8981 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07008982 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008983 *value = wma_cli_get_command(pAdapter->sessionId,
8984 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
8985 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308986 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008987 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
8988 &txpow2g)) {
8989 return -EIO;
8990 }
Jeff Johnson99bac312016-06-28 10:38:18 -07008991 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008992 break;
8993 }
8994
8995 case WE_GET_TXPOW_5G:
8996 {
8997 uint32_t txpow5g = 0;
8998 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07008999 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009000 *value = wma_cli_get_command(pAdapter->sessionId,
9001 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
9002 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309003 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009004 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9005 &txpow5g)) {
9006 return -EIO;
9007 }
Jeff Johnson99bac312016-06-28 10:38:18 -07009008 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009009 break;
9010 }
9011
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009012 case WE_GET_PPS_PAID_MATCH:
9013 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009014 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009015 *value = wma_cli_get_command(pAdapter->sessionId,
9016 WMI_VDEV_PPS_PAID_MATCH,
9017 PPS_CMD);
9018 break;
9019 }
9020
9021 case WE_GET_PPS_GID_MATCH:
9022 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009023 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009024 *value = wma_cli_get_command(pAdapter->sessionId,
9025 WMI_VDEV_PPS_GID_MATCH,
9026 PPS_CMD);
9027 break;
9028 }
9029
9030 case WE_GET_PPS_EARLY_TIM_CLEAR:
9031 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009032 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009033 *value = wma_cli_get_command(pAdapter->sessionId,
9034 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
9035 PPS_CMD);
9036 break;
9037 }
9038
9039 case WE_GET_PPS_EARLY_DTIM_CLEAR:
9040 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009041 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009042 *value = wma_cli_get_command(pAdapter->sessionId,
9043 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
9044 PPS_CMD);
9045 break;
9046 }
9047
9048 case WE_GET_PPS_EOF_PAD_DELIM:
9049 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009050 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009051 *value = wma_cli_get_command(pAdapter->sessionId,
9052 WMI_VDEV_PPS_EOF_PAD_DELIM,
9053 PPS_CMD);
9054 break;
9055 }
9056
9057 case WE_GET_PPS_MACADDR_MISMATCH:
9058 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009059 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009060 *value = wma_cli_get_command(pAdapter->sessionId,
9061 WMI_VDEV_PPS_MACADDR_MISMATCH,
9062 PPS_CMD);
9063 break;
9064 }
9065
9066 case WE_GET_PPS_DELIM_CRC_FAIL:
9067 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009068 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009069 *value = wma_cli_get_command(pAdapter->sessionId,
9070 WMI_VDEV_PPS_DELIM_CRC_FAIL,
9071 PPS_CMD);
9072 break;
9073 }
9074
9075 case WE_GET_PPS_GID_NSTS_ZERO:
9076 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009077 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009078 *value = wma_cli_get_command(pAdapter->sessionId,
9079 WMI_VDEV_PPS_GID_NSTS_ZERO,
9080 PPS_CMD);
9081 break;
9082 }
9083
9084 case WE_GET_PPS_RSSI_CHECK:
9085 {
9086
Jeff Johnson99bac312016-06-28 10:38:18 -07009087 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009088 *value = wma_cli_get_command(pAdapter->sessionId,
9089 WMI_VDEV_PPS_RSSI_CHECK,
9090 PPS_CMD);
9091 break;
9092 }
9093
9094 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
9095 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009096 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009097 *value = wma_cli_get_command(pAdapter->sessionId,
9098 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
9099 QPOWER_CMD);
9100 break;
9101 }
9102
9103 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
9104 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009105 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009106 *value = wma_cli_get_command(pAdapter->sessionId,
9107 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
9108 QPOWER_CMD);
9109 break;
9110 }
9111
9112 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
9113 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009114 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009115 *value = wma_cli_get_command(pAdapter->sessionId,
9116 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
9117 QPOWER_CMD);
9118 break;
9119 }
9120
9121 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
9122 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009123 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009124 *value = wma_cli_get_command(pAdapter->sessionId,
9125 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
9126 QPOWER_CMD);
9127 break;
9128 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009129 case WE_CAP_TSF:
9130 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
9131 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009132 case WE_GET_TEMPERATURE:
9133 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009134 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009135 ret = wlan_hdd_get_temperature(pAdapter, value);
9136 break;
9137 }
9138 default:
9139 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009140 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009141 value[0]);
9142 break;
9143 }
9144 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309145 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009146 return ret;
9147}
9148
9149static int iw_setnone_getint(struct net_device *dev,
9150 struct iw_request_info *info,
9151 union iwreq_data *wrqu, char *extra)
9152{
9153 int ret;
9154
9155 cds_ssr_protect(__func__);
9156 ret = __iw_setnone_getint(dev, info, wrqu, extra);
9157 cds_ssr_unprotect(__func__);
9158
9159 return ret;
9160}
9161
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309162static int hdd_set_fwtest(int argc, int cmd, int value)
9163{
9164 struct set_fwtest_params *fw_test;
9165
9166 /* check for max number of arguments */
9167 if (argc > (WMA_MAX_NUM_ARGS) ||
9168 argc != HDD_FWTEST_PARAMS) {
9169 hdd_err("Too Many args %d", argc);
9170 return -EINVAL;
9171 }
9172 /*
9173 * check if number of arguments are 3 then, check
9174 * then set the default value for sounding interval.
9175 */
9176 if (HDD_FWTEST_PARAMS == argc) {
9177 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
9178 value = HDD_FWTEST_SU_DEFAULT_VALUE;
9179 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
9180 value = HDD_FWTEST_MU_DEFAULT_VALUE;
9181 }
9182 /* check sounding interval value should not exceed to max */
9183 if (value > HDD_FWTEST_MAX_VALUE) {
9184 hdd_err("Invalid arguments value should not exceed max: %d",
9185 value);
9186 return -EINVAL;
9187 }
9188 fw_test = qdf_mem_malloc(sizeof(*fw_test));
9189 if (NULL == fw_test) {
9190 hdd_err("qdf_mem_malloc failed for fw_test");
9191 return -ENOMEM;
9192 }
9193 fw_test->arg = cmd;
9194 fw_test->value = value;
9195 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
9196 qdf_mem_free(fw_test);
9197 hdd_err("Not able to post FW_TEST_CMD message to WMA");
9198 return -EINVAL;
9199 }
9200 return 0;
9201}
9202
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009203/**
9204 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
9205 * @dev: device upon which the ioctl was received
9206 * @info: ioctl request information
9207 * @wrqu: ioctl request data
9208 * @extra: ioctl extra data
9209 *
9210 * Return: 0 on success, non-zero on error
9211 */
9212static int __iw_set_three_ints_getnone(struct net_device *dev,
9213 struct iw_request_info *info,
9214 union iwreq_data *wrqu, char *extra)
9215{
9216 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9217 int *value = (int *)extra;
9218 int sub_cmd = value[0];
9219 int ret;
9220 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9221
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009222 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309223
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009224 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009225 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009226 return -EPERM;
9227 }
9228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009229 ret = wlan_hdd_validate_context(hdd_ctx);
9230 if (0 != ret)
9231 return ret;
9232
Jeff Johnson441e1f72017-02-07 08:50:49 -08009233 ret = hdd_check_private_wext_control(hdd_ctx, info);
9234 if (0 != ret)
9235 return ret;
9236
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009237 switch (sub_cmd) {
9238
9239 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309240 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009241 break;
9242 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309243 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009244 break;
9245
9246 /* value[3] the acs band is not required as start and end channels are
9247 * enough but this cmd is maintained under set three ints for historic
9248 * reasons.
9249 */
9250 case WE_SET_SAP_CHANNELS:
9251 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309252 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009253 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309254 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009255 ret = -EINVAL;
9256 } else {
9257 hdd_ctx->config->force_sap_acs_st_ch = value[1];
9258 hdd_ctx->config->force_sap_acs_end_ch = value[2];
9259 }
9260 break;
9261 case WE_SET_DUAL_MAC_SCAN_CONFIG:
9262 hdd_debug("Ioctl to set dual mac scan config");
9263 if (hdd_ctx->config->dual_mac_feature_disable) {
9264 hdd_err("Dual mac feature is disabled from INI");
9265 return -EPERM;
9266 }
9267 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08009268 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009269 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309270 case WE_SET_FW_TEST:
9271 {
9272 ret = hdd_set_fwtest(value[1], value[2], value[3]);
9273 if (ret) {
9274 hdd_err("Not able to set fwtest %d", ret);
9275 return ret;
9276 }
9277 }
9278 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009279 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009280 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009281 break;
9282
9283 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309284 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009285 return ret;
9286}
9287
9288int iw_set_three_ints_getnone(struct net_device *dev,
9289 struct iw_request_info *info,
9290 union iwreq_data *wrqu, char *extra)
9291{
9292 int ret;
9293
9294 cds_ssr_protect(__func__);
9295 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
9296 cds_ssr_unprotect(__func__);
9297
9298 return ret;
9299}
9300
9301/**
9302 * hdd_connection_state_string() - Get connection state string
9303 * @connection_state: enum to be converted to a string
9304 *
9305 * Return: the string equivalent of @connection_state
9306 */
9307static const char *
9308hdd_connection_state_string(eConnectionState connection_state)
9309{
9310 switch (connection_state) {
9311 CASE_RETURN_STRING(eConnectionState_NotConnected);
9312 CASE_RETURN_STRING(eConnectionState_Connecting);
9313 CASE_RETURN_STRING(eConnectionState_Associated);
9314 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
9315 CASE_RETURN_STRING(eConnectionState_IbssConnected);
9316 CASE_RETURN_STRING(eConnectionState_Disconnecting);
9317 default:
9318 return "UNKNOWN";
9319 }
9320}
9321
Naveen Rawat910726a2017-03-06 11:42:51 -08009322#if defined(FEATURE_OEM_DATA_SUPPORT)
9323/**
9324 * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
9325 * wifi_pos api to get oem data caps
9326 * @dev: net device upon which the request was received
9327 * @info: ioctl request information
9328 * @wrqu: ioctl request data
9329 * @extra: ioctl data payload
9330 *
9331 * Return: 0 for success, negative errno value on failure
9332 */
9333static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9334 struct iw_request_info *info,
9335 union iwreq_data *wrqu, char *extra)
9336{
9337 return iw_get_oem_data_cap(dev, info, wrqu, extra);
9338}
9339#elif defined(WIFI_POS_CONVERGED)
9340static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9341 struct iw_request_info *info,
9342 union iwreq_data *wrqu, char *extra)
9343{
9344 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9345 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
9346
9347 return os_if_wifi_pos_populate_caps(hdd_ctx->hdd_psoc,
9348 (struct wifi_pos_driver_caps *)extra);
9349}
9350#else
9351static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9352 struct iw_request_info *info,
9353 union iwreq_data *wrqu, char *extra)
9354{
9355 return -ENOTSUPP;
9356}
9357#endif
9358
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009359/**
9360 * iw_get_char_setnone() - Generic "get string" private ioctl handler
9361 * @dev: device upon which the ioctl was received
9362 * @info: ioctl request information
9363 * @wrqu: ioctl request data
9364 * @extra: ioctl extra data
9365 *
9366 * Return: 0 on success, non-zero on error
9367 */
9368static int __iw_get_char_setnone(struct net_device *dev,
9369 struct iw_request_info *info,
9370 union iwreq_data *wrqu, char *extra)
9371{
9372 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9373 int sub_cmd = wrqu->data.flags;
9374 hdd_context_t *hdd_ctx;
9375 int ret;
9376#ifdef WLAN_FEATURE_11W
9377 hdd_wext_state_t *pWextState;
9378#endif
9379
9380#ifdef WLAN_FEATURE_11W
9381 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9382#endif
9383
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009384 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309385
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009386 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9387 ret = wlan_hdd_validate_context(hdd_ctx);
9388 if (0 != ret)
9389 return ret;
9390
Jeff Johnson441e1f72017-02-07 08:50:49 -08009391 ret = hdd_check_private_wext_control(hdd_ctx, info);
9392 if (0 != ret)
9393 return ret;
9394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009395 switch (sub_cmd) {
9396 case WE_WLAN_VERSION:
9397 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05309398 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009399 break;
9400 }
9401
9402 case WE_GET_STATS:
9403 {
9404 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
9405 extra, WE_MAX_STR_LEN);
9406 break;
9407 }
9408
Dustin Brownd9322482017-01-09 12:46:03 -08009409 case WE_GET_SUSPEND_RESUME_STATS:
9410 {
9411 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
9412 WE_MAX_STR_LEN);
9413 if (ret >= 0) {
9414 wrqu->data.length = ret;
9415 ret = 0;
9416 }
9417
9418 break;
9419 }
9420
Govind Singha471e5e2015-10-12 17:11:14 +05309421 case WE_LIST_FW_PROFILE:
9422 hdd_wlan_list_fw_profile(&(wrqu->data.length),
9423 extra, WE_MAX_STR_LEN);
9424 break;
9425
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009426 /* The case prints the current state of the HDD, SME, CSR, PE,
9427 * TL it can be extended for WDI Global State as well. And
9428 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
9429 * and P2P_GO have not been added as of now.
9430 */
9431 case WE_GET_STATES:
9432 {
9433 int buf = 0, len = 0;
9434 int adapter_num = 0;
9435 int count = 0, check = 1;
9436
9437 tHalHandle hHal = NULL;
9438 tpAniSirGlobal pMac = NULL;
9439 hdd_station_ctx_t *pHddStaCtx = NULL;
9440
9441 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9442 hdd_adapter_t *useAdapter = NULL;
9443
9444 /* Print wlan0 or p2p0 states based on the adapter_num
9445 * by using the correct adapter
9446 */
9447 while (adapter_num < 2) {
9448 if (WLAN_ADAPTER == adapter_num) {
9449 useAdapter = pAdapter;
9450 buf =
9451 scnprintf(extra + len,
9452 WE_MAX_STR_LEN - len,
9453 "\n\n wlan0 States:-");
9454 len += buf;
9455 } else if (P2P_ADAPTER == adapter_num) {
9456 buf =
9457 scnprintf(extra + len,
9458 WE_MAX_STR_LEN - len,
9459 "\n\n p2p0 States:-");
9460 len += buf;
9461
9462 if (!pHddCtx) {
9463 buf =
9464 scnprintf(extra + len,
9465 WE_MAX_STR_LEN -
9466 len,
9467 "\n pHddCtx is NULL");
9468 len += buf;
9469 break;
9470 }
9471
9472 /* Printing p2p0 states only in the
9473 * case when the device is configured
9474 * as a p2p_client
9475 */
9476 useAdapter =
9477 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08009478 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009479 if (!useAdapter) {
9480 buf =
9481 scnprintf(extra + len,
9482 WE_MAX_STR_LEN -
9483 len,
9484 "\n Device not configured as P2P_CLIENT.");
9485 len += buf;
9486 break;
9487 }
9488 }
9489
9490 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
9491 if (!hHal) {
9492 buf =
9493 scnprintf(extra + len,
9494 WE_MAX_STR_LEN - len,
9495 "\n pMac is NULL");
9496 len += buf;
9497 break;
9498 }
9499 pMac = PMAC_STRUCT(hHal);
9500 if (!pMac) {
9501 buf =
9502 scnprintf(extra + len,
9503 WE_MAX_STR_LEN - len,
9504 "\n pMac is NULL");
9505 len += buf;
9506 break;
9507 }
9508 pHddStaCtx =
9509 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
9510
9511
9512 buf =
9513 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9514 "\n HDD Conn State - %s "
9515 "\n \n SME State:"
9516 "\n Neighbour Roam State - %s"
9517 "\n CSR State - %s"
9518 "\n CSR Substate - %s",
9519 hdd_connection_state_string
9520 (pHddStaCtx->conn_info.connState),
9521 mac_trace_get_neighbour_roam_state
9522 (sme_get_neighbor_roam_state
9523 (hHal, useAdapter->sessionId)),
9524 mac_trace_getcsr_roam_state
9525 (sme_get_current_roam_state
9526 (hHal, useAdapter->sessionId)),
9527 mac_trace_getcsr_roam_sub_state
9528 (sme_get_current_roam_sub_state
9529 (hHal, useAdapter->sessionId))
9530 );
9531 len += buf;
9532 adapter_num++;
9533 }
9534
Mukul Sharma81661ae2015-10-30 20:26:02 +05309535 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009536 /* Printing Lim State starting with global lim states */
9537 buf =
9538 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9539 "\n \n LIM STATES:-"
9540 "\n Global Sme State - %s "
9541 "\n Global mlm State - %s " "\n",
9542 mac_trace_get_lim_sme_state
9543 (sme_get_lim_sme_state(hHal)),
9544 mac_trace_get_lim_mlm_state
9545 (sme_get_lim_sme_state(hHal))
9546 );
9547 len += buf;
9548
9549 /* Printing the PE Sme and Mlm states for valid lim sessions */
9550 while (check < 3 && count < 255) {
9551 if (sme_is_lim_session_valid(hHal, count)) {
9552 buf =
9553 scnprintf(extra + len,
9554 WE_MAX_STR_LEN -
9555 len,
9556 "\n Lim Valid Session %d:-"
9557 "\n PE Sme State - %s "
9558 "\n PE Mlm State - %s "
9559 "\n", check,
9560 mac_trace_get_lim_sme_state
9561 (sme_get_lim_sme_session_state
9562 (hHal, count)),
9563 mac_trace_get_lim_mlm_state
9564 (sme_get_lim_mlm_session_state
9565 (hHal, count))
9566 );
9567
9568 len += buf;
9569 check++;
9570 }
9571 count++;
9572 }
9573 }
9574
9575 wrqu->data.length = strlen(extra) + 1;
9576 break;
9577 }
9578
9579 case WE_GET_CFG:
9580 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009581 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009582 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
9583 extra,
9584 QCSAP_IOCTL_MAX_STR_LEN);
9585 wrqu->data.length = strlen(extra) + 1;
9586 break;
9587 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009588 case WE_GET_RSSI:
9589 {
9590 int8_t s7Rssi = 0;
9591 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
9592 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
9593 wrqu->data.length = strlen(extra) + 1;
9594 break;
9595 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009596
9597 case WE_GET_WMM_STATUS:
9598 {
9599 snprintf(extra, WE_MAX_STR_LEN,
9600 "\nDir: 0=up, 1=down, 3=both\n"
9601 "|------------------------|\n"
9602 "|AC | ACM |Admitted| Dir |\n"
9603 "|------------------------|\n"
9604 "|VO | %d | %3s | %d |\n"
9605 "|VI | %d | %3s | %d |\n"
9606 "|BE | %d | %3s | %d |\n"
9607 "|BK | %d | %3s | %d |\n"
9608 "|------------------------|\n",
9609 pAdapter->hddWmmStatus.
9610 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
9611 pAdapter->hddWmmStatus.
9612 wmmAcStatus[SME_AC_VO].
9613 wmmAcAccessAllowed ? "YES" : "NO",
9614 pAdapter->hddWmmStatus.
9615 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
9616 ts_info.direction,
9617 pAdapter->hddWmmStatus.
9618 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
9619 pAdapter->hddWmmStatus.
9620 wmmAcStatus[SME_AC_VI].
9621 wmmAcAccessAllowed ? "YES" : "NO",
9622 pAdapter->hddWmmStatus.
9623 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
9624 ts_info.direction,
9625 pAdapter->hddWmmStatus.
9626 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
9627 pAdapter->hddWmmStatus.
9628 wmmAcStatus[SME_AC_BE].
9629 wmmAcAccessAllowed ? "YES" : "NO",
9630 pAdapter->hddWmmStatus.
9631 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
9632 ts_info.direction,
9633 pAdapter->hddWmmStatus.
9634 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
9635 pAdapter->hddWmmStatus.
9636 wmmAcStatus[SME_AC_BK].
9637 wmmAcAccessAllowed ? "YES" : "NO",
9638 pAdapter->hddWmmStatus.
9639 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
9640 ts_info.direction);
9641
9642 wrqu->data.length = strlen(extra) + 1;
9643 break;
9644 }
9645 case WE_GET_CHANNEL_LIST:
9646 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309647 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009648 uint8_t i, len;
9649 char *buf;
9650 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
9651 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
9652 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9653
9654 tChannelListInfo channel_list;
9655
9656 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05309657 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009658 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309659 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009660 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009661 return -EINVAL;
9662 }
9663 buf = extra;
9664 /*
9665 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
9666 * Maximum buffer needed = 5 * number of channels.
9667 * Check ifsufficient buffer is available and then
9668 * proceed to fill the buffer.
9669 */
9670 if (WE_MAX_STR_LEN <
9671 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009672 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009673 return -EINVAL;
9674 }
9675 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
9676 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309677 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009678 ubuf, &ubuf_len)) {
9679 /* Printing Country code in getChannelList */
9680 for (i = 0; i < (ubuf_len - 1); i++)
9681 len += scnprintf(buf + len,
9682 WE_MAX_STR_LEN - len,
9683 "%c", ubuf[i]);
9684 }
9685 for (i = 0; i < channel_list.num_channels; i++) {
9686 len +=
9687 scnprintf(buf + len, WE_MAX_STR_LEN - len,
9688 " %u", channel_list.channels[i]);
9689 }
9690 wrqu->data.length = strlen(extra) + 1;
9691
9692 break;
9693 }
9694#ifdef FEATURE_WLAN_TDLS
9695 case WE_GET_TDLS_PEERS:
9696 {
9697 wrqu->data.length =
9698 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
9699 WE_MAX_STR_LEN) + 1;
9700 break;
9701 }
9702#endif
9703#ifdef WLAN_FEATURE_11W
9704 case WE_GET_11W_INFO:
9705 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009706 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009707 pWextState->roamProfile.MFPEnabled);
9708
9709 snprintf(extra, WE_MAX_STR_LEN,
9710 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
9711 "\n Number of Unprotected Disassocs %d"
9712 "\n Number of Unprotected Deauths %d",
9713 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
9714 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
9715 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
9716 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
9717 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
9718 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
9719 pWextState->roamProfile.MFPEnabled,
9720 pAdapter->hdd_stats.hddPmfStats.
9721 numUnprotDisassocRx,
9722 pAdapter->hdd_stats.hddPmfStats.
9723 numUnprotDeauthRx);
9724
9725 wrqu->data.length = strlen(extra) + 1;
9726 break;
9727 }
9728#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009729 case WE_GET_IBSS_STA_INFO:
9730 {
9731 hdd_station_ctx_t *pHddStaCtx =
9732 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9733 int idx = 0;
9734 int length = 0, buf = 0;
9735
Naveen Rawatc45d1622016-07-05 12:20:09 -07009736 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009737 if (0 != pHddStaCtx->conn_info.staId[idx]) {
9738 buf = snprintf
9739 ((extra + length),
9740 WE_MAX_STR_LEN - length,
9741 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
9742 pHddStaCtx->conn_info.staId[idx],
9743 pHddStaCtx->conn_info.
9744 peerMacAddress[idx].bytes[0],
9745 pHddStaCtx->conn_info.
9746 peerMacAddress[idx].bytes[1],
9747 pHddStaCtx->conn_info.
9748 peerMacAddress[idx].bytes[2],
9749 pHddStaCtx->conn_info.
9750 peerMacAddress[idx].bytes[3],
9751 pHddStaCtx->conn_info.
9752 peerMacAddress[idx].bytes[4],
9753 pHddStaCtx->conn_info.
9754 peerMacAddress[idx].bytes[5]
9755 );
9756 length += buf;
9757 }
9758 }
9759 wrqu->data.length = strlen(extra) + 1;
9760 break;
9761 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009762 case WE_GET_PHYMODE:
9763 {
9764 bool ch_bond24 = false, ch_bond5g = false;
9765 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
9766 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9767 eCsrPhyMode phymode;
9768 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -08009769 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009770
Dustin Browne9c6b3a2017-01-23 17:17:32 -08009771 sme_config = qdf_mem_malloc(sizeof(*sme_config));
9772 if (!sme_config) {
9773 hdd_err("Out of memory");
9774 ret = -ENOMEM;
9775 break;
9776 }
9777
9778 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009779 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08009780 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009781 ch_bond24 = true;
9782
9783 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08009784 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009785 ch_bond5g = true;
9786
Dustin Browne9c6b3a2017-01-23 17:17:32 -08009787 qdf_mem_free(sme_config);
9788
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009789 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309790 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009791 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009792 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009793 return -EIO;
9794 }
9795
9796 switch (phymode) {
9797 case eCSR_DOT11_MODE_AUTO:
9798 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
9799 break;
9800 case eCSR_DOT11_MODE_11n:
9801 case eCSR_DOT11_MODE_11n_ONLY:
9802 if (currBand == eCSR_BAND_24) {
9803 if (ch_bond24)
9804 snprintf(extra, WE_MAX_STR_LEN,
9805 "11NGHT40");
9806 else
9807 snprintf(extra, WE_MAX_STR_LEN,
9808 "11NGHT20");
9809 } else if (currBand == eCSR_BAND_5G) {
9810 if (ch_bond5g)
9811 snprintf(extra, WE_MAX_STR_LEN,
9812 "11NAHT40");
9813 else
9814 snprintf(extra, WE_MAX_STR_LEN,
9815 "11NAHT20");
9816 } else {
9817 snprintf(extra, WE_MAX_STR_LEN, "11N");
9818 }
9819 break;
9820 case eCSR_DOT11_MODE_abg:
9821 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
9822 break;
9823 case eCSR_DOT11_MODE_11a:
9824 snprintf(extra, WE_MAX_STR_LEN, "11A");
9825 break;
9826 case eCSR_DOT11_MODE_11b:
9827 case eCSR_DOT11_MODE_11b_ONLY:
9828 snprintf(extra, WE_MAX_STR_LEN, "11B");
9829 break;
9830 case eCSR_DOT11_MODE_11g:
9831 case eCSR_DOT11_MODE_11g_ONLY:
9832 snprintf(extra, WE_MAX_STR_LEN, "11G");
9833 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009834 case eCSR_DOT11_MODE_11ac:
9835 case eCSR_DOT11_MODE_11ac_ONLY:
9836 if (hddctx->config->vhtChannelWidth ==
9837 eHT_CHANNEL_WIDTH_20MHZ)
9838 snprintf(extra, WE_MAX_STR_LEN,
9839 "11ACVHT20");
9840 else if (hddctx->config->vhtChannelWidth ==
9841 eHT_CHANNEL_WIDTH_40MHZ)
9842 snprintf(extra, WE_MAX_STR_LEN,
9843 "11ACVHT40");
9844 else if (hddctx->config->vhtChannelWidth ==
9845 eHT_CHANNEL_WIDTH_80MHZ)
9846 snprintf(extra, WE_MAX_STR_LEN,
9847 "11ACVHT80");
9848 else if (hddctx->config->vhtChannelWidth ==
9849 eHT_CHANNEL_WIDTH_160MHZ)
9850 snprintf(extra, WE_MAX_STR_LEN,
9851 "11ACVHT160");
9852 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009853 }
9854
9855 wrqu->data.length = strlen(extra) + 1;
9856 break;
9857 }
9858
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009859 case WE_GET_OEM_DATA_CAP:
Naveen Rawat910726a2017-03-06 11:42:51 -08009860 return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009861 case WE_GET_SNR:
9862 {
9863 int8_t s7snr = 0;
9864 int status = 0;
9865 hdd_context_t *pHddCtx;
9866 hdd_station_ctx_t *pHddStaCtx;
9867 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9868 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05309869 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009870 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05309871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009872 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9873 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
9874 eConnectionState_Associated !=
9875 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009876 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009877 pHddCtx->config->fEnableSNRMonitoring,
9878 pHddStaCtx->conn_info.connState);
9879 return -ENONET;
9880 }
9881 wlan_hdd_get_snr(pAdapter, &s7snr);
9882 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
9883 wrqu->data.length = strlen(extra) + 1;
9884 break;
9885 }
9886 default:
9887 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009888 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009889 sub_cmd);
9890 break;
9891 }
9892 }
Dustin Brownd9322482017-01-09 12:46:03 -08009893
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309894 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -08009895 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009896}
9897
9898static int iw_get_char_setnone(struct net_device *dev,
9899 struct iw_request_info *info,
9900 union iwreq_data *wrqu, char *extra)
9901{
9902 int ret;
9903
9904 cds_ssr_protect(__func__);
9905 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
9906 cds_ssr_unprotect(__func__);
9907
9908 return ret;
9909}
9910
9911/**
9912 * iw_setnone_getnone() - Generic "action" private ioctl handler
9913 * @dev: device upon which the ioctl was received
9914 * @info: ioctl request information
9915 * @wrqu: ioctl request data
9916 * @extra: ioctl extra data
9917 *
9918 * Return: 0 on success, non-zero on error
9919 */
9920static int __iw_setnone_getnone(struct net_device *dev,
9921 struct iw_request_info *info,
9922 union iwreq_data *wrqu, char *extra)
9923{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009924 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009925 hdd_context_t *hdd_ctx;
9926 int ret;
9927 int sub_cmd;
9928
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009929 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309930
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009931 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009932 ret = wlan_hdd_validate_context(hdd_ctx);
9933 if (0 != ret)
9934 return ret;
9935
Jeff Johnson441e1f72017-02-07 08:50:49 -08009936 ret = hdd_check_private_wext_control(hdd_ctx, info);
9937 if (0 != ret)
9938 return ret;
9939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009940#ifdef CONFIG_COMPAT
9941 /* this ioctl is a special case where a sub-ioctl is used and both
9942 * the number of get and set args is 0. in this specific case the
9943 * logic in iwpriv places the sub_cmd in the data.flags portion of
9944 * the iwreq. unfortunately the location of this field will be
9945 * different between 32-bit and 64-bit userspace, and the standard
9946 * compat support in the kernel does not handle this case. so we
9947 * need to explicitly handle it here.
9948 */
9949 if (is_compat_task()) {
9950 struct compat_iw_point *compat_iw_point =
9951 (struct compat_iw_point *)&wrqu->data;
9952 sub_cmd = compat_iw_point->flags;
9953 } else {
9954 sub_cmd = wrqu->data.flags;
9955 }
9956#else
9957 sub_cmd = wrqu->data.flags;
9958#endif
9959
9960 switch (sub_cmd) {
9961 case WE_GET_RECOVERY_STAT:
9962 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009963 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009964 sme_get_recovery_stats(hal);
9965 break;
9966 }
9967
Govind Singha471e5e2015-10-12 17:11:14 +05309968 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009969 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05309970 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
9971 0, DBG_CMD);
9972 break;
9973
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009974 case WE_IBSS_GET_PEER_INFO_ALL:
9975 {
9976 hdd_wlan_get_ibss_peer_info_all(adapter);
9977 break;
9978 }
9979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009980 case WE_SET_REASSOC_TRIGGER:
9981 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009982 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9983 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05309984 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009985 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05309986 uint8_t operating_ch =
9987 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009988 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009989
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009990 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009991 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05309992 if (roaming_offload_enabled(hdd_ctx)) {
9993 qdf_mem_copy(bssid,
9994 &adapter->sessionCtx.station.conn_info.bssId,
9995 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -08009996 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05309997 bssid, operating_ch);
9998 } else {
9999 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
10000 NULL, modProfileFields, &roamId, 1);
10001 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010002 return 0;
10003 }
10004
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010005 case WE_STOP_OBSS_SCAN:
10006 {
10007 /*
10008 * 1.OBSS Scan is mandatory while operating in 2.4GHz
10009 * 2.OBSS scan is stopped by Firmware during the disassociation
10010 * 3.OBSS stop comamnd is added for debugging purpose
10011 */
10012 tHalHandle hal;
10013
10014 hal = WLAN_HDD_GET_HAL_CTX(adapter);
10015 if (hal == NULL) {
10016 hdd_err("hal context is NULL");
10017 return -EINVAL;
10018 }
10019 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
10020 }
10021 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010022 default:
10023 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010024 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010025 break;
10026 }
10027 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010028 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010029 return ret;
10030}
10031
10032static int iw_setnone_getnone(struct net_device *dev,
10033 struct iw_request_info *info,
10034 union iwreq_data *wrqu, char *extra)
10035{
10036 int ret;
10037
10038 cds_ssr_protect(__func__);
10039 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
10040 cds_ssr_unprotect(__func__);
10041
10042 return ret;
10043}
10044
Krunal Sonia6e505b2017-01-12 12:25:18 -080010045#ifdef MPC_UT_FRAMEWORK
10046static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10047 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10048{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -080010049 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010050 case WE_POLICY_MANAGER_CLIST_CMD:
10051 {
10052 hdd_err("<iwpriv wlan0 pm_clist> is called");
10053 cds_incr_connection_count_utfw(apps_args[0],
10054 apps_args[1], apps_args[2], apps_args[3],
10055 apps_args[4], apps_args[5], apps_args[6],
10056 apps_args[7]);
10057 }
10058 break;
10059
10060 case WE_POLICY_MANAGER_DLIST_CMD:
10061 {
10062 hdd_err("<iwpriv wlan0 pm_dlist> is called");
10063 cds_decr_connection_count_utfw(apps_args[0],
10064 apps_args[1]);
10065 }
10066 break;
10067
10068 case WE_POLICY_MANAGER_ULIST_CMD:
10069 {
10070 hdd_err("<iwpriv wlan0 pm_ulist> is called");
10071 cds_update_connection_info_utfw(apps_args[0],
10072 apps_args[1], apps_args[2], apps_args[3],
10073 apps_args[4], apps_args[5], apps_args[6],
10074 apps_args[7]);
10075 }
10076 break;
10077
10078 case WE_POLICY_MANAGER_DBS_CMD:
10079 {
10080 hdd_err("<iwpriv wlan0 pm_dbs> is called");
10081 if (apps_args[0] == 0)
10082 wma_set_dbs_capability_ut(0);
10083 else
10084 wma_set_dbs_capability_ut(1);
10085
10086 if (apps_args[1] >= CDS_THROUGHPUT &&
10087 apps_args[1] <= CDS_LATENCY) {
10088 pr_info("setting system pref to [%d]\n", apps_args[1]);
10089 hdd_ctx->config->conc_system_pref = apps_args[1];
10090 }
10091 }
10092 break;
10093
10094 case WE_POLICY_MANAGER_PCL_CMD:
10095 {
10096 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
10097 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
10098 uint32_t pcl_len = 0, i = 0;
10099
10100 hdd_err("<iwpriv wlan0 pm_pcl> is called");
10101
10102 cds_get_pcl(apps_args[0],
10103 pcl, &pcl_len,
10104 weight_list, QDF_ARRAY_SIZE(weight_list));
10105 pr_info("PCL list for role[%d] is {", apps_args[0]);
10106 for (i = 0 ; i < pcl_len; i++)
10107 pr_info(" %d, ", pcl[i]);
10108 pr_info("}--------->\n");
10109 }
10110 break;
10111
10112 case WE_POLICY_SET_HW_MODE_CMD:
10113 {
10114 if (apps_args[0] == 0) {
10115 hdd_err("set hw mode for single mac");
10116 cds_pdev_set_hw_mode(
10117 adapter->sessionId,
10118 HW_MODE_SS_2x2,
10119 HW_MODE_80_MHZ,
10120 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
10121 HW_MODE_DBS_NONE,
10122 HW_MODE_AGILE_DFS_NONE,
10123 HW_MODE_SBS_NONE,
10124 SIR_UPDATE_REASON_UT);
10125 } else if (apps_args[0] == 1) {
10126 hdd_err("set hw mode for dual mac");
10127 cds_pdev_set_hw_mode(
10128 adapter->sessionId,
10129 HW_MODE_SS_1x1,
10130 HW_MODE_80_MHZ,
10131 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
10132 HW_MODE_DBS,
10133 HW_MODE_AGILE_DFS_NONE,
10134 HW_MODE_SBS_NONE,
10135 SIR_UPDATE_REASON_UT);
10136 }
10137 }
10138 break;
10139
10140 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10141 {
10142 enum cds_conc_next_action action;
10143 hdd_notice("<iwpriv wlan0 pm_query_action> is called");
10144 action = cds_current_connections_update(adapter->sessionId,
10145 apps_args[0],
10146 SIR_UPDATE_REASON_UT);
10147 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
10148 }
10149 break;
10150
10151 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10152 {
10153 bool allow;
10154 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
10155 allow = cds_allow_concurrency(
10156 apps_args[0], apps_args[1], apps_args[2]);
10157 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
10158 }
10159 break;
10160
10161 case WE_POLICY_MANAGER_SCENARIO_CMD:
10162 {
10163 clean_report(hdd_ctx);
10164 if (apps_args[0] == 1) {
10165 wlan_hdd_one_connection_scenario(hdd_ctx);
10166 } else if (apps_args[0] == 2) {
10167 wlan_hdd_two_connections_scenario(hdd_ctx,
10168 6, CDS_TWO_TWO);
10169 wlan_hdd_two_connections_scenario(hdd_ctx,
10170 36, CDS_TWO_TWO);
10171 wlan_hdd_two_connections_scenario(hdd_ctx,
10172 6, CDS_ONE_ONE);
10173 wlan_hdd_two_connections_scenario(hdd_ctx,
10174 36, CDS_ONE_ONE);
10175 } else if (apps_args[0] == 3) {
10176 /* MCC on same band with 2x2 same mac*/
10177 wlan_hdd_three_connections_scenario(hdd_ctx,
10178 6, 11, CDS_TWO_TWO, 0);
10179 /* MCC on diff band with 2x2 same mac*/
10180 wlan_hdd_three_connections_scenario(hdd_ctx,
10181 6, 36, CDS_TWO_TWO, 0);
10182 /* MCC on diff band with 1x1 diff mac */
10183 wlan_hdd_three_connections_scenario(hdd_ctx,
10184 36, 6, CDS_ONE_ONE, 0);
10185 /* MCC on diff band with 1x1 same mac */
10186 wlan_hdd_three_connections_scenario(hdd_ctx,
10187 36, 6, CDS_ONE_ONE, 1);
10188 /* SCC on same band with 2x2 same mac */
10189 wlan_hdd_three_connections_scenario(hdd_ctx,
10190 36, 36, CDS_TWO_TWO, 0);
10191 /* SCC on same band with 1x1 same mac */
10192 wlan_hdd_three_connections_scenario(hdd_ctx,
10193 36, 36, CDS_ONE_ONE, 1);
10194 /* MCC on same band with 2x2 same mac */
10195 wlan_hdd_three_connections_scenario(hdd_ctx,
10196 36, 149, CDS_TWO_TWO, 0);
10197 /* MCC on same band with 1x1 same mac */
10198 wlan_hdd_three_connections_scenario(hdd_ctx,
10199 36, 149, CDS_ONE_ONE, 1);
10200 }
10201 print_report(hdd_ctx);
10202 }
10203 break;
10204 }
10205 return 0;
10206}
10207#else
10208static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10209 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10210{
10211 return 0;
10212}
10213#endif
10214
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010215/**
10216 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10217 * @dev: device upon which the ioctl was received
10218 * @info: ioctl request information
10219 * @wrqu: ioctl request data
10220 * @extra: ioctl extra data
10221 *
10222 * This is an SSR-protected generic handler for private ioctls which
10223 * take multiple arguments. Note that this implementation is also
10224 * somewhat unique in that it is shared by both STA-mode and SAP-mode
10225 * interfaces.
10226 *
10227 * Return: 0 on success, non-zero on error
10228 */
10229static int __iw_set_var_ints_getnone(struct net_device *dev,
10230 struct iw_request_info *info,
10231 union iwreq_data *wrqu, char *extra)
10232{
10233 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10234 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10235 int sub_cmd;
10236 int *apps_args = (int *) extra;
10237 hdd_context_t *hdd_ctx;
10238 int ret, num_args;
10239
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010240 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010241
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010242 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10243 ret = wlan_hdd_validate_context(hdd_ctx);
10244 if (0 != ret)
10245 return ret;
10246
Jeff Johnson441e1f72017-02-07 08:50:49 -080010247 ret = hdd_check_private_wext_control(hdd_ctx, info);
10248 if (0 != ret)
10249 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010250
10251 sub_cmd = wrqu->data.flags;
10252 num_args = wrqu->data.length;
10253
Jeff Johnson99bac312016-06-28 10:38:18 -070010254 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010255
10256 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010257 case WE_IBSS_GET_PEER_INFO:
10258 {
10259 pr_info("Station ID = %d\n", apps_args[0]);
10260 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
10261 }
10262 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010263
10264 case WE_P2P_NOA_CMD:
10265 {
10266 p2p_app_setP2pPs_t p2pNoA;
10267
Krunal Sonif07bb382016-03-10 13:02:11 -080010268 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -080010269 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
10270 hdd_device_mode_to_string(
10271 pAdapter->device_mode),
10272 pAdapter->device_mode);
10273 return -EINVAL;
10274 }
10275
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010276 p2pNoA.opp_ps = apps_args[0];
10277 p2pNoA.ctWindow = apps_args[1];
10278 p2pNoA.duration = apps_args[2];
10279 p2pNoA.interval = apps_args[3];
10280 p2pNoA.count = apps_args[4];
10281 p2pNoA.single_noa_duration = apps_args[5];
10282 p2pNoA.psSelection = apps_args[6];
10283
Jeff Johnson99bac312016-06-28 10:38:18 -070010284 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
10285 apps_args[0], apps_args[1], apps_args[2],
10286 apps_args[3], apps_args[4],
10287 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010288
10289 hdd_set_p2p_ps(dev, &p2pNoA);
10290
10291 }
10292 break;
10293
10294 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
10295 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010296 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
10297 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010298 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010299 }
10300 break;
10301
10302 case WE_MTRACE_DUMP_CMD:
10303 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010304 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
10305 apps_args[0], apps_args[1],
10306 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010307 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010308 apps_args[1], apps_args[2],
10309 apps_args[3]);
10310
10311 }
10312 break;
10313
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010314 case WE_POLICY_MANAGER_CINFO_CMD:
10315 {
10316 struct cds_conc_connection_info *conn_info;
10317 uint32_t i = 0, len = 0;
10318
Krunal Sonia6e505b2017-01-12 12:25:18 -080010319 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -080010320 conn_info = cds_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010321 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010322 for (i = 0; i < len; i++) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010323 pr_info("|table_index[%d]\t\t\n", i);
10324 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
10325 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
10326 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
10327 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
10328 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
10329 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
10330 pr_info("+--------------------------+\n");
10331 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010332 }
10333 }
10334 break;
10335
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010336
10337#ifdef FEATURE_WLAN_TDLS
10338 case WE_TDLS_CONFIG_PARAMS:
10339 {
10340 tdls_config_params_t tdlsParams;
10341
10342 tdlsParams.tdls = apps_args[0];
10343 tdlsParams.tx_period_t = apps_args[1];
10344 tdlsParams.tx_packet_n = apps_args[2];
10345 /* ignore args[3] as discovery_period is not used anymore */
10346 tdlsParams.discovery_tries_n = apps_args[4];
10347 /* ignore args[5] as idle_timeout is not used anymore */
10348 tdlsParams.idle_packet_n = apps_args[6];
10349 /* ignore args[7] as rssi_hysteresis is not used anymore */
10350 tdlsParams.rssi_trigger_threshold = apps_args[8];
10351 tdlsParams.rssi_teardown_threshold = apps_args[9];
10352 tdlsParams.rssi_delta = apps_args[10];
10353
10354 wlan_hdd_tdls_set_params(dev, &tdlsParams);
10355 }
10356 break;
10357#endif
10358 case WE_UNIT_TEST_CMD:
10359 {
10360 t_wma_unit_test_cmd *unitTestArgs;
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010361 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010362 int i, j;
10363 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
10364 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010365 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010366 apps_args[0]);
10367 return -EINVAL;
10368 }
Anurag Chouhan77564182016-09-03 16:38:01 +053010369 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
10370 (apps_args[1] < 0)) {
10371 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010372 apps_args[1]);
10373 return -EINVAL;
10374 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010375 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010376 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010377 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010378 return -ENOMEM;
10379 }
10380 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
10381 unitTestArgs->module_id = apps_args[0];
10382 unitTestArgs->num_args = apps_args[1];
10383 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
10384 unitTestArgs->args[i] = apps_args[j];
10385 }
10386 msg.type = SIR_HAL_UNIT_TEST_CMD;
10387 msg.reserved = 0;
10388 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010389 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010390 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010391 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -070010392 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010393 return -EINVAL;
10394 }
10395 }
10396 break;
10397#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
10398 case WE_LED_FLASHING_PARAM:
10399 {
10400 int i;
10401 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010402 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010403 return -EINVAL;
10404 }
10405 for (i = 0; i < num_args; i++) {
10406 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010407 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010408 return -EINVAL;
10409 }
10410 }
10411 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10412 0, apps_args[0], apps_args[1]);
10413 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10414 1, apps_args[2], apps_args[3]);
10415 }
10416 break;
10417#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010418 case WE_SET_PKTLOG:
10419 {
10420 int ret;
10421
10422 if (num_args < 1 || num_args > 2) {
10423 hdd_err("pktlog: either 1 or 2 parameters are required");
10424 return -EINVAL;
10425 }
10426
10427 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
10428 apps_args[1]);
10429 if (ret)
10430 return ret;
10431 break;
10432 }
10433
Manjeet Singhf82ed072016-07-08 11:40:00 +053010434 case WE_MAC_PWR_DEBUG_CMD:
10435 {
10436 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
10437 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10438 int i, j;
10439
10440 if (num_args < 3) {
10441 hdd_err("number of arguments can't be null %d",
10442 num_args);
10443 return -EINVAL;
10444 }
10445 if (num_args - 3 != apps_args[2]) {
10446 hdd_err("arg list of size %d doesn't match num_args %d",
10447 num_args-3, apps_args[2]);
10448 return -EINVAL;
10449 }
10450 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
10451 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
10452 hdd_err("Invalid MODULE ID %d", apps_args[1]);
10453 return -EINVAL;
10454 }
10455 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
10456 hdd_err("Too Many args %d", apps_args[2]);
10457 return -EINVAL;
10458 }
10459 mac_pwr_dbg_args.pdev_id = apps_args[0];
10460 mac_pwr_dbg_args.module_id = apps_args[1];
10461 mac_pwr_dbg_args.num_args = apps_args[2];
10462
10463 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
10464 mac_pwr_dbg_args.args[i] = apps_args[j];
10465
10466 if (QDF_STATUS_SUCCESS !=
10467 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
10468 &mac_pwr_dbg_args)) {
10469 return -EINVAL;
10470 }
10471 }
10472 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -080010473 case WE_POLICY_MANAGER_CLIST_CMD:
10474 case WE_POLICY_MANAGER_DLIST_CMD:
10475 case WE_POLICY_MANAGER_ULIST_CMD:
10476 case WE_POLICY_MANAGER_DBS_CMD:
10477 case WE_POLICY_MANAGER_PCL_CMD:
10478 case WE_POLICY_SET_HW_MODE_CMD:
10479 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10480 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10481 case WE_POLICY_MANAGER_SCENARIO_CMD:
10482 {
10483 iw_get_policy_manager_ut_ops(hdd_ctx, pAdapter,
10484 sub_cmd, apps_args);
10485 }
10486 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010487 default:
10488 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010489 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010490 }
10491 break;
10492 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010493 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010494 return 0;
10495}
10496
10497/**
10498 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
10499 * @dev: pointer to net_device structure
10500 * @info: pointer to iw_request_info structure
10501 * @wrqu: pointer to iwreq_data
10502 * @extra; extra
10503 *
10504 * Return: 0 on success, error number otherwise
10505 *
10506 */
10507static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
10508 struct iw_request_info *info,
10509 union iwreq_data *wrqu, char *extra)
10510{
10511 union iwreq_data u_priv_wrqu;
10512 int apps_args[MAX_VAR_ARGS] = {0};
10513 int ret, num_args;
10514
Mukul Sharma64a70e82015-11-02 20:05:09 +053010515 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010516 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +053010517 return -EPERM;
10518 }
10519
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010520 /* Helper function to get iwreq_data with compat handling. */
10521 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
10522 return -EINVAL;
10523
10524 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010525 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010526 return -EINVAL;
10527 }
10528
10529 num_args = u_priv_wrqu.data.length;
10530 if (num_args > MAX_VAR_ARGS)
10531 num_args = MAX_VAR_ARGS;
10532
10533 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
10534 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010535 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010536 return -EFAULT;
10537 }
10538
10539 cds_ssr_protect(__func__);
10540 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
10541 (char *)&apps_args);
10542 cds_ssr_unprotect(__func__);
10543 return ret;
10544}
10545
10546/**
10547 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10548 * @dev: device upon which the ioctl was received
10549 * @info: ioctl request information
10550 * @wrqu: ioctl request data
10551 * @extra: ioctl extra data
10552 *
10553 * This is a generic handler for private ioctls which take multiple
10554 * arguments. Note that this implementation is also somewhat unique
10555 * in that it is shared by both STA-mode and SAP-mode interfaces.
10556 *
10557 * Return: 0 on success, non-zero on error
10558 */
10559int iw_set_var_ints_getnone(struct net_device *dev,
10560 struct iw_request_info *info,
10561 union iwreq_data *wrqu, char *extra)
10562{
10563 int ret;
10564
10565 cds_ssr_protect(__func__);
10566 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
10567 cds_ssr_unprotect(__func__);
10568 return ret;
10569}
10570
10571/**
10572 * iw_add_tspec - Add TSpec private ioctl handler
10573 * @dev: device upon which the ioctl was received
10574 * @info: ioctl request information
10575 * @wrqu: ioctl request data
10576 * @extra: ioctl extra data
10577 *
10578 * Return: 0 on success, non-zero on error
10579 */
10580static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
10581 union iwreq_data *wrqu, char *extra)
10582{
10583 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10584 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10585 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
10586 int params[HDD_WLAN_WMM_PARAM_COUNT];
10587 sme_QosWmmTspecInfo tSpec;
10588 uint32_t handle;
10589 struct iw_point s_priv_data;
10590 hdd_context_t *hdd_ctx;
10591 int ret;
10592
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010593 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010594
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010595 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10596 ret = wlan_hdd_validate_context(hdd_ctx);
10597 if (0 != ret)
10598 return ret;
10599
Jeff Johnson441e1f72017-02-07 08:50:49 -080010600 ret = hdd_check_private_wext_control(hdd_ctx, info);
10601 if (0 != ret)
10602 return ret;
10603
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010604 /* make sure the application is sufficiently priviledged */
10605 /* note that the kernel will do this for "set" ioctls, but since */
10606 /* this ioctl wants to return status to user space it must be */
10607 /* defined as a "get" ioctl */
10608 if (!capable(CAP_NET_ADMIN)) {
10609 return -EPERM;
10610 }
10611
10612 /* we must be associated in order to add a tspec */
10613 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
10614 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10615 return 0;
10616 }
10617 /* since we are defined to be a "get" ioctl, and since the number */
10618 /* of params exceeds the number of params that wireless extensions */
10619 /* will pass down in the iwreq_data, we must copy the "set" params. */
10620 /* We must handle the compat for iwreq_data in 32U/64K environment. */
10621
10622 /* helper function to get iwreq_data with compat handling. */
10623 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
10624 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10625 return 0;
10626 }
10627 /* make sure all params are correctly passed to function */
10628 if ((NULL == s_priv_data.pointer) ||
10629 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
10630 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10631 return 0;
10632 }
10633 /* from user space ourselves */
10634 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
10635 /* hmmm, can't get them */
10636 return -EIO;
10637 }
10638 /* clear the tspec */
10639 memset(&tSpec, 0, sizeof(tSpec));
10640
10641 /* validate the handle */
10642 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
10643 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
10644 /* that one is reserved */
10645 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10646 return 0;
10647 }
10648 /* validate the TID */
10649 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
10650 /* out of range */
10651 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10652 return 0;
10653 }
10654 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
10655
10656 /* validate the direction */
10657 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
10658 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
10659 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
10660 break;
10661
10662 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
10663 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
10664 break;
10665
10666 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
10667 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
10668 break;
10669
10670 default:
10671 /* unknown */
10672 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10673 return 0;
10674 }
10675
10676 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
10677
10678 /* validate the user priority */
10679 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
10680 /* out of range */
10681 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10682 return 0;
10683 }
10684 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
10685 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010686 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687 return 0;
10688 }
10689
Jeff Johnson99bac312016-06-28 10:38:18 -070010690 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010691 tSpec.ts_info.psb, tSpec.ts_info.up);
10692
10693 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
10694 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
10695 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
10696 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
10697 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
10698 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
10699 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
10700 tSpec.surplus_bw_allowance =
10701 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
10702 tSpec.min_service_interval =
10703 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
10704 tSpec.max_service_interval =
10705 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
10706 tSpec.suspension_interval =
10707 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
10708 tSpec.inactivity_interval =
10709 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
10710
10711 tSpec.ts_info.burst_size_defn =
10712 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
10713
10714 /* validate the ts info ack policy */
10715 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
10716 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
10717 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
10718 break;
10719
10720 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
10721 tSpec.ts_info.ack_policy =
10722 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
10723 break;
10724
10725 default:
10726 /* unknown */
10727 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10728 return 0;
10729 }
10730
10731 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010732 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010733 return 0;
10734}
10735
10736static int iw_add_tspec(struct net_device *dev,
10737 struct iw_request_info *info,
10738 union iwreq_data *wrqu, char *extra)
10739{
10740 int ret;
10741
10742 cds_ssr_protect(__func__);
10743 ret = __iw_add_tspec(dev, info, wrqu, extra);
10744 cds_ssr_unprotect(__func__);
10745
10746 return ret;
10747}
10748
10749/**
10750 * iw_del_tspec - Delete TSpec private ioctl handler
10751 * @dev: device upon which the ioctl was received
10752 * @info: ioctl request information
10753 * @wrqu: ioctl request data
10754 * @extra: ioctl extra data
10755 *
10756 * Return: 0 on success, non-zero on error
10757 */
10758static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
10759 union iwreq_data *wrqu, char *extra)
10760{
10761 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10762 hdd_context_t *hdd_ctx;
10763 int *params = (int *)extra;
10764 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
10765 uint32_t handle;
10766 int ret;
10767
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010768 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010769
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010770 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10771 ret = wlan_hdd_validate_context(hdd_ctx);
10772 if (0 != ret)
10773 return ret;
10774
Jeff Johnson441e1f72017-02-07 08:50:49 -080010775 ret = hdd_check_private_wext_control(hdd_ctx, info);
10776 if (0 != ret)
10777 return ret;
10778
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010779 /* make sure the application is sufficiently priviledged */
10780 /* note that the kernel will do this for "set" ioctls, but since */
10781 /* this ioctl wants to return status to user space it must be */
10782 /* defined as a "get" ioctl */
10783 if (!capable(CAP_NET_ADMIN)) {
10784 return -EPERM;
10785 }
10786
10787 /* although we are defined to be a "get" ioctl, the params we require */
10788 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
10789 /* is no need to copy the params from user space */
10790
10791 /* validate the handle */
10792 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
10793 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
10794 /* that one is reserved */
10795 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10796 return 0;
10797 }
10798
10799 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010800 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010801 return 0;
10802}
10803
10804static int iw_del_tspec(struct net_device *dev,
10805 struct iw_request_info *info,
10806 union iwreq_data *wrqu, char *extra)
10807{
10808 int ret;
10809
10810 cds_ssr_protect(__func__);
10811 ret = __iw_del_tspec(dev, info, wrqu, extra);
10812 cds_ssr_unprotect(__func__);
10813
10814 return ret;
10815}
10816
10817/**
10818 * iw_get_tspec - Get TSpec private ioctl handler
10819 * @dev: device upon which the ioctl was received
10820 * @info: ioctl request information
10821 * @wrqu: ioctl request data
10822 * @extra: ioctl extra data
10823 *
10824 * Return: 0 on success, non-zero on error
10825 */
10826static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
10827 union iwreq_data *wrqu, char *extra)
10828{
10829 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10830 hdd_context_t *hdd_ctx;
10831 int *params = (int *)extra;
10832 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
10833 uint32_t handle;
10834 int ret;
10835
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010836 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010837
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010838 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10839 ret = wlan_hdd_validate_context(hdd_ctx);
10840 if (0 != ret)
10841 return ret;
10842
Jeff Johnson441e1f72017-02-07 08:50:49 -080010843 ret = hdd_check_private_wext_control(hdd_ctx, info);
10844 if (0 != ret)
10845 return ret;
10846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010847 /* although we are defined to be a "get" ioctl, the params we require */
10848 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
10849 /* is no need to copy the params from user space */
10850
10851 /* validate the handle */
10852 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
10853 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
10854 /* that one is reserved */
10855 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10856 return 0;
10857 }
10858
10859 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010860 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010861 return 0;
10862}
10863
10864static int iw_get_tspec(struct net_device *dev,
10865 struct iw_request_info *info,
10866 union iwreq_data *wrqu, char *extra)
10867{
10868 int ret;
10869
10870 cds_ssr_protect(__func__);
10871 ret = __iw_get_tspec(dev, info, wrqu, extra);
10872 cds_ssr_unprotect(__func__);
10873
10874 return ret;
10875}
10876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010877/**
10878 * iw_set_fties - Set FT IEs private ioctl handler
10879 * @dev: device upon which the ioctl was received
10880 * @info: ioctl request information
10881 * @wrqu: ioctl request data
10882 * @extra: ioctl extra data
10883 *
10884 * Each time the supplicant has the auth_request or reassoc request
10885 * IEs ready they are pushed to the driver. The driver will in turn
10886 * use it to send out the auth req and reassoc req for 11r FT Assoc.
10887 *
10888 * Return: 0 on success, non-zero on error
10889 */
10890static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
10891 union iwreq_data *wrqu, char *extra)
10892{
10893 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10894 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10895 hdd_context_t *hdd_ctx;
10896 int ret;
10897
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010898 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010899
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010900 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10901 ret = wlan_hdd_validate_context(hdd_ctx);
10902 if (0 != ret)
10903 return ret;
10904
Jeff Johnson441e1f72017-02-07 08:50:49 -080010905 ret = hdd_check_private_wext_control(hdd_ctx, info);
10906 if (0 != ret)
10907 return ret;
10908
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010909 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010910 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010911 return -EINVAL;
10912 }
10913 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010914 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010915 return -EINVAL;
10916 }
10917 /* Added for debug on reception of Re-assoc Req. */
10918 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010919 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010920 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -070010921 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010922 }
Jeff Johnson99bac312016-06-28 10:38:18 -070010923 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010924
10925 /* Pass the received FT IEs to SME */
10926 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
10927 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010928 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010929 return 0;
10930}
10931
10932static int iw_set_fties(struct net_device *dev,
10933 struct iw_request_info *info,
10934 union iwreq_data *wrqu, char *extra)
10935{
10936 int ret;
10937
10938 cds_ssr_protect(__func__);
10939 ret = __iw_set_fties(dev, info, wrqu, extra);
10940 cds_ssr_unprotect(__func__);
10941
10942 return ret;
10943}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010944
Dustin Brown0cbc7572016-12-16 13:54:40 -080010945/**
10946 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
10947 * @dev: device upon which the ioctl was received
10948 * @info: ioctl request information
10949 * @wrqu: ioctl request data
10950 * @extra: ioctl extra data
10951 *
Dustin Brown860566f2017-01-31 15:24:43 -080010952 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
10953 * time being to provide guidance in migrating to standard APIs.
10954 *
Dustin Brown0cbc7572016-12-16 13:54:40 -080010955 * Return: 0 on success, non-zero on error
10956 */
10957static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
10958 struct iw_request_info *info,
10959 union iwreq_data *wrqu,
10960 char *extra)
10961{
Dustin Brown860566f2017-01-31 15:24:43 -080010962 hdd_err("\n"
10963 "setMCBCFilter is obsolete. Use the following instead:\n"
10964 "Configure multicast filtering via the ‘ip’ command.\n"
10965 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
10966 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
10967 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
10968 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
10969 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Mukul Sharma3ba26b82017-01-12 21:59:41 +053010970 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -080010971}
10972
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010973/**
10974 * iw_set_host_offload - Set host offload ioctl handler
10975 * @dev: device upon which the ioctl was received
10976 * @info: ioctl request information
10977 * @wrqu: ioctl request data
10978 * @extra: ioctl extra data
10979 *
10980 * Return: 0 on success, non-zero on error
10981 */
10982static int __iw_set_host_offload(struct net_device *dev,
10983 struct iw_request_info *info,
10984 union iwreq_data *wrqu, char *extra)
10985{
10986 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10987 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
10988 tSirHostOffloadReq offloadRequest;
10989 hdd_context_t *hdd_ctx;
10990 int ret;
10991
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010992 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010993
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010994 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10995 ret = wlan_hdd_validate_context(hdd_ctx);
10996 if (0 != ret)
10997 return ret;
10998
Jeff Johnson441e1f72017-02-07 08:50:49 -080010999 ret = hdd_check_private_wext_control(hdd_ctx, info);
11000 if (0 != ret)
11001 return ret;
11002
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011003 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011004 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011005 return -EINVAL;
11006 }
11007
11008 /* Debug display of request components. */
11009 switch (pRequest->offloadType) {
11010 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -070011011 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011012 switch (pRequest->enableOrDisable) {
11013 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070011014 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011015 break;
11016 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070011017 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011018 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070011019 hdd_warn(" ARP offload enable");
11020 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011021 pRequest->params.hostIpv4Addr[0],
11022 pRequest->params.hostIpv4Addr[1],
11023 pRequest->params.hostIpv4Addr[2],
11024 pRequest->params.hostIpv4Addr[3]);
11025 }
11026 break;
11027
11028 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -070011029 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011030 switch (pRequest->enableOrDisable) {
11031 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070011032 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011033 break;
11034 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070011035 hdd_info(" enable");
11036 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011037 *(uint16_t *) (pRequest->params.hostIpv6Addr),
11038 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11039 2),
11040 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11041 4),
11042 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11043 6),
11044 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11045 8),
11046 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11047 10),
11048 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11049 12),
11050 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11051 14));
11052 }
11053 }
11054
11055 /* Execute offload request. The reason that we can copy the
11056 * request information from the ioctl structure to the SME
11057 * structure is that they are laid out exactly the same.
11058 * Otherwise, each piece of information would have to be
11059 * copied individually.
11060 */
11061 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011062 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011063 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
11064 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011065 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011066 return -EINVAL;
11067 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011068 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011069 return 0;
11070}
11071
11072static int iw_set_host_offload(struct net_device *dev,
11073 struct iw_request_info *info,
11074 union iwreq_data *wrqu, char *extra)
11075{
11076 int ret;
11077
11078 cds_ssr_protect(__func__);
11079 ret = __iw_set_host_offload(dev, info, wrqu, extra);
11080 cds_ssr_unprotect(__func__);
11081
11082 return ret;
11083}
11084
11085/**
11086 * iw_set_keepalive_params - Set keepalive params ioctl handler
11087 * @dev: device upon which the ioctl was received
11088 * @info: ioctl request information
11089 * @wrqu: ioctl request data
11090 * @extra: ioctl extra data
11091 *
11092 * Return: 0 on success, non-zero on error
11093 */
11094static int __iw_set_keepalive_params(struct net_device *dev,
11095 struct iw_request_info *info,
11096 union iwreq_data *wrqu, char *extra)
11097{
11098 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011099 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011100 hdd_context_t *hdd_ctx;
11101 int ret;
11102
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011103 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011105 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11106 ret = wlan_hdd_validate_context(hdd_ctx);
11107 if (0 != ret)
11108 return ret;
11109
Jeff Johnson441e1f72017-02-07 08:50:49 -080011110 ret = hdd_check_private_wext_control(hdd_ctx, info);
11111 if (0 != ret)
11112 return ret;
11113
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011114 if (wrqu->data.length != sizeof(*request)) {
11115 hdd_err("Invalid length %d", wrqu->data.length);
11116 return -EINVAL;
11117 }
11118
11119 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
11120 hdd_err("Value of timePeriod %d exceed Max limit %d",
11121 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011122 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
11123 return -EINVAL;
11124 }
11125
11126 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011127 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
11128 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011129
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011130 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011131 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011132 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011133 break;
11134
11135 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011136 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011137
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011138 hdd_info("Host IP address: %d.%d.%d.%d",
11139 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
11140 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011141
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011142 hdd_info("Dest IP address: %d.%d.%d.%d",
11143 request->destIpv4Addr[0], request->destIpv4Addr[1],
11144 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011145
Srinivas Girigowda9c330a92015-11-24 12:28:25 -080011146 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
11147 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011148 break;
11149 }
11150
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011151 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011152
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011153 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011154 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011155 pAdapter->sessionId, request)) {
11156 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011157 return -EINVAL;
11158 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011159 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011160 return 0;
11161}
11162
11163static int iw_set_keepalive_params(struct net_device *dev,
11164 struct iw_request_info *info,
11165 union iwreq_data *wrqu,
11166 char *extra)
11167{
11168 int ret;
11169
11170 cds_ssr_protect(__func__);
11171 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
11172 cds_ssr_unprotect(__func__);
11173
11174 return ret;
11175}
11176
11177#ifdef WLAN_FEATURE_PACKET_FILTERING
11178/**
11179 * wlan_hdd_set_filter() - Set packet filter
11180 * @hdd_ctx: Global HDD context
11181 * @request: Packet filter request struct
11182 * @sessionId: Target session for the request
11183 *
11184 * Return: 0 on success, non-zero on error
11185 */
11186static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
11187 struct pkt_filter_cfg *request,
11188 uint8_t sessionId)
11189{
11190 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
11191 tSirRcvFltPktClearParam packetFilterClrReq = {0};
11192 int i = 0;
11193
11194 if (hdd_ctx->config->disablePacketFilter) {
11195 hdd_err("packet filtering disabled in ini returning");
11196 return 0;
11197 }
11198
11199 /* Debug display of request components. */
11200 hdd_info("Packet Filter Request : FA %d params %d",
11201 request->filter_action, request->num_params);
11202
11203 switch (request->filter_action) {
11204 case HDD_RCV_FILTER_SET:
11205 hdd_info("Set Packet Filter Request for Id: %d",
11206 request->filter_id);
11207
11208 packetFilterSetReq.filterId = request->filter_id;
11209 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
11210 hdd_err("Number of Params exceed Max limit %d",
11211 request->num_params);
11212 return -EINVAL;
11213 }
11214 packetFilterSetReq.numFieldParams = request->num_params;
11215 packetFilterSetReq.coalesceTime = 0;
11216 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
11217 for (i = 0; i < request->num_params; i++) {
11218 packetFilterSetReq.paramsData[i].protocolLayer =
11219 request->params_data[i].protocol_layer;
11220 packetFilterSetReq.paramsData[i].cmpFlag =
11221 request->params_data[i].compare_flag;
11222 packetFilterSetReq.paramsData[i].dataOffset =
11223 request->params_data[i].data_offset;
11224 packetFilterSetReq.paramsData[i].dataLength =
11225 request->params_data[i].data_length;
11226 packetFilterSetReq.paramsData[i].reserved = 0;
11227
Dustin Brown4d1e8462016-12-14 12:12:24 -080011228 if (request->params_data[i].data_offset >
11229 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
11230 hdd_err("Invalid data offset %u for param %d (max = %d)",
11231 request->params_data[i].data_offset,
11232 i,
11233 SIR_MAX_FILTER_TEST_DATA_OFFSET);
11234 return -EINVAL;
11235 }
11236
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011237 if (request->params_data[i].data_length >
11238 SIR_MAX_FILTER_TEST_DATA_LEN) {
11239 hdd_err("Error invalid data length %d",
11240 request->params_data[i].data_length);
11241 return -EINVAL;
11242 }
11243
11244 hdd_info("Proto %d Comp Flag %d Filter Type %d",
11245 request->params_data[i].protocol_layer,
11246 request->params_data[i].compare_flag,
11247 packetFilterSetReq.filterType);
11248
11249 hdd_info("Data Offset %d Data Len %d",
11250 request->params_data[i].data_offset,
11251 request->params_data[i].data_length);
11252
Rajeev Kumarf5b6da22016-04-15 13:24:03 -070011253 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
11254 < (request->params_data[i].data_length)) {
11255 hdd_err("Error invalid data length %d",
11256 request->params_data[i].data_length);
11257 return -EINVAL;
11258 }
11259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011260 memcpy(&packetFilterSetReq.paramsData[i].compareData,
11261 request->params_data[i].compare_data,
11262 request->params_data[i].data_length);
11263 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
11264 request->params_data[i].data_mask,
11265 request->params_data[i].data_length);
11266
11267 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
11268 request->params_data[i].compare_data[0],
11269 request->params_data[i].compare_data[1],
11270 request->params_data[i].compare_data[2],
11271 request->params_data[i].compare_data[3],
11272 request->params_data[i].compare_data[4],
11273 request->params_data[i].compare_data[5]);
11274
11275 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
11276 request->params_data[i].data_mask[0],
11277 request->params_data[i].data_mask[1],
11278 request->params_data[i].data_mask[2],
11279 request->params_data[i].data_mask[3],
11280 request->params_data[i].data_mask[4],
11281 request->params_data[i].data_mask[5]);
11282 }
11283
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011284 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011285 sme_receive_filter_set_filter(hdd_ctx->hHal,
11286 &packetFilterSetReq,
11287 sessionId)) {
11288 hdd_err("Failure to execute Set Filter");
11289 return -EINVAL;
11290 }
11291
11292 break;
11293
11294 case HDD_RCV_FILTER_CLEAR:
11295
11296 hdd_info("Clear Packet Filter Request for Id: %d",
11297 request->filter_id);
11298 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011299 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011300 sme_receive_filter_clear_filter(hdd_ctx->hHal,
11301 &packetFilterClrReq,
11302 sessionId)) {
11303 hdd_err("Failure to execute Clear Filter");
11304 return -EINVAL;
11305 }
11306 break;
11307
11308 default:
11309 hdd_err("Packet Filter Request: Invalid %d",
11310 request->filter_action);
11311 return -EINVAL;
11312 }
11313 return 0;
11314}
11315
11316/**
11317 * __iw_set_packet_filter_params() - set packet filter parameters in target
11318 * @dev: Pointer to netdev
11319 * @info: Pointer to iw request info
11320 * @wrqu: Pointer to data
11321 * @extra: Pointer to extra data
11322 *
11323 * Return: 0 on success, non-zero on error
11324 */
11325static int __iw_set_packet_filter_params(struct net_device *dev,
11326 struct iw_request_info *info,
11327 union iwreq_data *wrqu, char *extra)
11328{
11329 int ret;
11330 hdd_context_t *hdd_ctx;
11331 struct iw_point priv_data;
11332 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
11333 struct pkt_filter_cfg *request = NULL;
11334
Mukul Sharma472382f2015-11-02 20:16:31 +053011335 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011336 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +053011337 return -EPERM;
11338 }
11339
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011340 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011342 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11343 ret = wlan_hdd_validate_context(hdd_ctx);
11344 if (0 != ret)
11345 return ret;
11346
Jeff Johnson441e1f72017-02-07 08:50:49 -080011347 ret = hdd_check_private_wext_control(hdd_ctx, info);
11348 if (0 != ret)
11349 return ret;
11350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011351 if (hdd_priv_get_data(&priv_data, wrqu)) {
11352 hdd_err("failed to get priv data");
11353 return -EINVAL;
11354 }
11355
11356 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
11357 hdd_err("invalid priv data %p or invalid priv data length %d",
11358 priv_data.pointer, priv_data.length);
11359 return -EINVAL;
11360 }
11361
11362 /* copy data using copy_from_user */
11363 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
11364 priv_data.length);
11365 if (NULL == request) {
11366 hdd_err("mem_alloc_copy_from_user_helper fail");
11367 return -ENOMEM;
11368 }
11369
11370 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
11371
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -070011372 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011373 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011374 return ret;
11375}
11376
11377/**
11378 * iw_set_packet_filter_params() - set packet filter parameters in target
11379 * @dev: Pointer to netdev
11380 * @info: Pointer to iw request info
11381 * @wrqu: Pointer to data
11382 * @extra: Pointer to extra data
11383 *
11384 * Return: 0 on success, non-zero on error
11385 */
11386static int iw_set_packet_filter_params(struct net_device *dev,
11387 struct iw_request_info *info,
11388 union iwreq_data *wrqu, char *extra)
11389{
11390 int ret;
11391
11392 cds_ssr_protect(__func__);
11393 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
11394 cds_ssr_unprotect(__func__);
11395
11396 return ret;
11397}
11398#endif
11399
11400
11401static int __iw_get_statistics(struct net_device *dev,
11402 struct iw_request_info *info,
11403 union iwreq_data *wrqu, char *extra)
11404{
11405
Anurag Chouhance0dc992016-02-16 18:18:03 +053011406 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011407 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011408 hdd_wext_state_t *pWextState;
11409 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11410 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11411 char *p = extra;
11412 int tlen = 0;
11413 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
11414 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
11415 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
11416 int ret;
11417
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011418 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011419
11420 ret = wlan_hdd_validate_context(hdd_ctx);
11421 if (0 != ret)
11422 return ret;
11423
Jeff Johnson441e1f72017-02-07 08:50:49 -080011424 ret = hdd_check_private_wext_control(hdd_ctx, info);
11425 if (0 != ret)
11426 return ret;
11427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011428 if (eConnectionState_Associated !=
11429 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
11430
11431 wrqu->txpower.value = 0;
11432 } else {
11433 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11434 SME_SUMMARY_STATS |
11435 SME_GLOBAL_CLASSA_STATS |
11436 SME_GLOBAL_CLASSB_STATS |
11437 SME_GLOBAL_CLASSC_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080011438 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011439 hdd_statistics_cb, 0, false,
11440 (WLAN_HDD_GET_STATION_CTX_PTR
11441 (pAdapter))->conn_info.staId[0],
11442 pAdapter, pAdapter->sessionId);
11443
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011444 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011445 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011446 return -EINVAL;
11447 }
11448
11449 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11450
Anurag Chouhance0dc992016-02-16 18:18:03 +053011451 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011452 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011453 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011454 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011455 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011456 /*Remove the SME statistics list by passing NULL in callback argument */
11457 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11458 SME_SUMMARY_STATS |
11459 SME_GLOBAL_CLASSA_STATS |
11460 SME_GLOBAL_CLASSB_STATS |
11461 SME_GLOBAL_CLASSC_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080011462 SME_GLOBAL_CLASSD_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011463 NULL, 0, false,
11464 (WLAN_HDD_GET_STATION_CTX_PTR
11465 (pAdapter))->conn_info.
11466 staId[0], pAdapter,
11467 pAdapter->sessionId);
11468
11469 return -EINVAL;
11470 }
11471 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
11472 (uint8_t) sizeof(pStats->retry_cnt),
11473 (char *)&(pStats->retry_cnt[0]), tlen);
11474
11475 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
11476 (uint8_t) sizeof(pStats->multiple_retry_cnt),
11477 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
11478
11479 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
11480 (uint8_t) sizeof(pStats->tx_frm_cnt),
11481 (char *)&(pStats->tx_frm_cnt[0]), tlen);
11482
11483 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
11484 (uint8_t) sizeof(pStats->rx_frm_cnt),
11485 (char *)&(pStats->rx_frm_cnt), tlen);
11486
11487 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
11488 (uint8_t) sizeof(pStats->frm_dup_cnt),
11489 (char *)&(pStats->frm_dup_cnt), tlen);
11490
11491 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
11492 (uint8_t) sizeof(pStats->fail_cnt),
11493 (char *)&(pStats->fail_cnt[0]), tlen);
11494
11495 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
11496 (uint8_t) sizeof(pStats->rts_fail_cnt),
11497 (char *)&(pStats->rts_fail_cnt), tlen);
11498
11499 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
11500 (uint8_t) sizeof(pStats->ack_fail_cnt),
11501 (char *)&(pStats->ack_fail_cnt), tlen);
11502
11503 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
11504 (uint8_t) sizeof(pStats->rts_succ_cnt),
11505 (char *)&(pStats->rts_succ_cnt), tlen);
11506
11507 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
11508 (uint8_t) sizeof(pStats->rx_discard_cnt),
11509 (char *)&(pStats->rx_discard_cnt), tlen);
11510
11511 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
11512 (uint8_t) sizeof(pStats->rx_error_cnt),
11513 (char *)&(pStats->rx_error_cnt), tlen);
11514
11515 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
11516 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11517 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11518
11519 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
11520 (uint8_t) sizeof(dStats->rx_byte_cnt),
11521 (char *)&(dStats->rx_byte_cnt), tlen);
11522
11523 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
11524 (uint8_t) sizeof(dStats->rx_rate),
11525 (char *)&(dStats->rx_rate), tlen);
11526
11527 /* Transmit rate, in units of 500 kbit/sec */
11528 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
11529 (uint8_t) sizeof(aStats->tx_rate),
11530 (char *)&(aStats->tx_rate), tlen);
11531
11532 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
11533 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
11534 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
11535 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
11536 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
11537 (char *)&(dStats->rx_mc_byte_cnt), tlen);
11538 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
11539 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
11540 (char *)&(dStats->rx_bc_byte_cnt), tlen);
11541 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
11542 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11543 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11544 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
11545 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
11546 (char *)&(dStats->tx_mc_byte_cnt), tlen);
11547 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
11548 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
11549 (char *)&(dStats->tx_bc_byte_cnt), tlen);
11550
11551 wrqu->data.length = tlen;
11552
11553 }
11554
11555 EXIT();
11556
11557 return 0;
11558}
11559
11560static int iw_get_statistics(struct net_device *dev,
11561 struct iw_request_info *info,
11562 union iwreq_data *wrqu, char *extra)
11563{
11564 int ret;
11565
11566 cds_ssr_protect(__func__);
11567 ret = __iw_get_statistics(dev, info, wrqu, extra);
11568 cds_ssr_unprotect(__func__);
11569
11570 return ret;
11571}
11572
11573#ifdef FEATURE_WLAN_SCAN_PNO
11574
11575/*Max Len for PNO notification*/
11576#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011577static void found_pref_network_cb(void *callbackContext,
11578 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011579{
11580 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
11581 union iwreq_data wrqu;
11582 char buf[MAX_PNO_NOTIFY_LEN + 1];
11583
Jeff Johnson99bac312016-06-28 10:38:18 -070011584 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011585 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
11586
11587 /* create the event */
11588 memset(&wrqu, 0, sizeof(wrqu));
11589 memset(buf, 0, sizeof(buf));
11590
11591 snprintf(buf, MAX_PNO_NOTIFY_LEN,
11592 "QCOM: Found preferred network: %s with RSSI of -%u",
11593 pPrefNetworkFoundInd->ssId.ssId,
11594 (unsigned int)pPrefNetworkFoundInd->rssi);
11595
11596 wrqu.data.pointer = buf;
11597 wrqu.data.length = strlen(buf);
11598
11599 /* send the event */
11600
11601 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
11602
11603}
11604
11605/**
11606 * __iw_set_pno() - Preferred Network Offload ioctl handler
11607 * @dev: device upon which the ioctl was received
11608 * @info: ioctl request information
11609 * @wrqu: ioctl request data
11610 * @extra: ioctl extra data
11611 *
11612 * This function parses a Preferred Network Offload command
11613 * Input is string based and expected to be of the form:
11614 *
11615 * <enable(1) | disable(0)>
11616 * when enabling:
11617 * <number of networks>
11618 * for each network:
11619 * <ssid_len> <ssid> <authentication> <encryption>
11620 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070011621 * <scan_time (seconds)>
11622 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011623 * <suspend mode>
11624 *
11625 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070011626 * 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 -080011627 *
11628 * this translates into:
11629 * -----------------------------
11630 * enable PNO
11631 * 2 networks
11632 * Network 1:
11633 * test - with authentication type 0 and encryption type 0,
11634 * search on 3 channels: 1 6 and 11,
11635 * SSID bcast type is unknown (directed probe will be sent if
11636 * AP not found) and must meet -40dBm RSSI
11637 * Network 2:
11638 * test2 - with authentication type 4 and encryption type 4,
11639 * search on 6 channels 1, 2, 3, 4, 5 and 6
11640 * bcast type is non-bcast (directed probe will be sent)
11641 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011642 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070011643 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011644 */
11645static int __iw_set_pno(struct net_device *dev,
11646 struct iw_request_info *info,
11647 union iwreq_data *wrqu, char *extra)
11648{
11649 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
11650 hdd_context_t *hdd_ctx;
11651 int ret;
11652 int offset;
11653 char *ptr;
11654 uint8_t i, j, params, mode;
11655
11656 /* request is a large struct, so we make it static to avoid
11657 * stack overflow. This API is only invoked via ioctl, so it
11658 * is serialized by the kernel rtnl_lock and hence does not
11659 * need to be reentrant
11660 */
11661 static tSirPNOScanReq request;
11662
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011663 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011664
11665 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11666 ret = wlan_hdd_validate_context(hdd_ctx);
11667 if (ret)
11668 return ret;
11669
Jeff Johnson441e1f72017-02-07 08:50:49 -080011670 ret = hdd_check_private_wext_control(hdd_ctx, info);
11671 if (0 != ret)
11672 return ret;
11673
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011674 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
11675
11676 request.enable = 0;
11677 request.ucNetworksCount = 0;
11678
11679 ptr = extra;
11680
11681 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
11682 hdd_err("PNO enable input is not valid %s", ptr);
11683 return -EINVAL;
11684 }
11685
11686 if (0 == request.enable) {
11687 /* Disable PNO, ignore any other params */
11688 memset(&request, 0, sizeof(request));
11689 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
11690 &request, adapter->sessionId,
11691 found_pref_network_cb, adapter);
11692 return 0;
11693 }
11694
11695 ptr += offset;
11696
11697 if (1 !=
11698 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
11699 hdd_err("PNO count input not valid %s", ptr);
11700 return -EINVAL;
11701
11702 }
11703
11704 hdd_info("PNO enable %d networks count %d offset %d",
11705 request.enable, request.ucNetworksCount, offset);
11706
11707 if ((0 == request.ucNetworksCount) ||
11708 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
11709 hdd_err("Network count %d invalid",
11710 request.ucNetworksCount);
11711 return -EINVAL;
11712 }
11713
11714 ptr += offset;
11715
11716 for (i = 0; i < request.ucNetworksCount; i++) {
11717
11718 request.aNetworks[i].ssId.length = 0;
11719
11720 params = sscanf(ptr, "%hhu %n",
11721 &(request.aNetworks[i].ssId.length),
11722 &offset);
11723
11724 if (1 != params) {
11725 hdd_err("PNO ssid length input is not valid %s", ptr);
11726 return -EINVAL;
11727 }
11728
11729 if ((0 == request.aNetworks[i].ssId.length) ||
11730 (request.aNetworks[i].ssId.length > 32)) {
11731 hdd_err("SSID Len %d is not correct for network %d",
11732 request.aNetworks[i].ssId.length, i);
11733 return -EINVAL;
11734 }
11735
11736 /* Advance to SSID */
11737 ptr += offset;
11738
11739 memcpy(request.aNetworks[i].ssId.ssId, ptr,
11740 request.aNetworks[i].ssId.length);
11741 ptr += request.aNetworks[i].ssId.length;
11742
11743 params = sscanf(ptr, "%u %u %hhu %n",
11744 &(request.aNetworks[i].authentication),
11745 &(request.aNetworks[i].encryption),
11746 &(request.aNetworks[i].ucChannelCount),
11747 &offset);
11748
11749 if (3 != params) {
11750 hdd_warn("Incorrect cmd %s", ptr);
11751 return -EINVAL;
11752 }
11753
11754 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
11755 request.aNetworks[i].ssId.length,
11756 request.aNetworks[i].ssId.length,
11757 request.aNetworks[i].ssId.ssId,
11758 request.aNetworks[i].authentication,
11759 request.aNetworks[i].encryption,
11760 request.aNetworks[i].ucChannelCount, offset);
11761
11762 /* Advance to channel list */
11763 ptr += offset;
11764
11765 if (SIR_PNO_MAX_NETW_CHANNELS <
11766 request.aNetworks[i].ucChannelCount) {
11767 hdd_warn("Incorrect number of channels");
11768 return -EINVAL;
11769 }
11770
11771 if (0 != request.aNetworks[i].ucChannelCount) {
11772 for (j = 0; j < request.aNetworks[i].ucChannelCount;
11773 j++) {
11774 if (1 !=
11775 sscanf(ptr, "%hhu %n",
11776 &(request.aNetworks[i].
11777 aChannels[j]), &offset)) {
11778 hdd_err("PNO network channel input is not valid %s",
11779 ptr);
11780 return -EINVAL;
11781 }
11782 /* Advance to next channel number */
11783 ptr += offset;
11784 }
11785 }
11786
11787 if (1 != sscanf(ptr, "%u %n",
11788 &(request.aNetworks[i].bcastNetwType),
11789 &offset)) {
11790 hdd_err("PNO broadcast network type input is not valid %s",
11791 ptr);
11792 return -EINVAL;
11793 }
11794
11795 hdd_notice("PNO bcastNetwType %d offset %d",
11796 request.aNetworks[i].bcastNetwType, offset);
11797
11798 /* Advance to rssi Threshold */
11799 ptr += offset;
11800 if (1 != sscanf(ptr, "%d %n",
11801 &(request.aNetworks[i].rssiThreshold),
11802 &offset)) {
11803 hdd_err("PNO rssi threshold input is not valid %s",
11804 ptr);
11805 return -EINVAL;
11806 }
11807 hdd_notice("PNO rssi %d offset %d",
11808 request.aNetworks[i].rssiThreshold, offset);
11809 /* Advance to next network */
11810 ptr += offset;
11811 } /* For ucNetworkCount */
11812
Dustin Brown43e87292016-10-10 10:38:25 -070011813 request.fast_scan_period = 0;
11814 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
11815 request.fast_scan_period *= MSEC_PER_SEC;
11816 ptr += offset;
11817 }
11818
11819 request.fast_scan_max_cycles = 0;
11820 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
11821 &offset) > 0)
11822 ptr += offset;
11823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011824 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
11825
11826 request.modePNO = mode;
11827 /* for LA we just expose suspend option */
11828 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
11829 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
11830 }
11831
11832 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
11833 &request,
11834 adapter->sessionId,
11835 found_pref_network_cb, adapter);
11836
11837 return 0;
11838}
11839
11840static int iw_set_pno(struct net_device *dev,
11841 struct iw_request_info *info,
11842 union iwreq_data *wrqu, char *extra)
11843{
11844 int ret;
11845
11846 cds_ssr_protect(__func__);
11847 ret = __iw_set_pno(dev, info, wrqu, extra);
11848 cds_ssr_unprotect(__func__);
11849
11850 return ret;
11851}
11852#endif /* FEATURE_WLAN_SCAN_PNO */
11853
11854/* Common function to SetBand */
11855int hdd_set_band(struct net_device *dev, u8 ui_band)
11856{
11857 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11858 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11859 eCsrBand band;
11860
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011861 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011862 hdd_context_t *pHddCtx;
11863 hdd_adapter_list_node_t *pAdapterNode, *pNext;
11864 eCsrBand currBand = eCSR_BAND_MAX;
11865 eCsrBand connectedBand;
11866
11867 pAdapterNode = NULL;
11868 pNext = NULL;
11869 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11870
11871 switch (ui_band) {
11872 case WLAN_HDD_UI_BAND_AUTO:
11873 band = eCSR_BAND_ALL;
11874 break;
11875 case WLAN_HDD_UI_BAND_5_GHZ:
11876 band = eCSR_BAND_5G;
11877 break;
11878 case WLAN_HDD_UI_BAND_2_4_GHZ:
11879 band = eCSR_BAND_24;
11880 break;
11881 default:
11882 band = eCSR_BAND_MAX;
11883 }
11884
Jeff Johnson99bac312016-06-28 10:38:18 -070011885 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011886
11887 if (band == eCSR_BAND_MAX) {
11888 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -070011889 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011890 return -EINVAL;
11891 }
11892
11893 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
11894 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011895 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011896 band, pHddCtx->config->nBandCapability);
11897 return -EIO;
11898 }
11899
11900 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011901 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011902 pHddCtx->config->nBandCapability);
11903 band = pHddCtx->config->nBandCapability;
11904 }
11905
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011906 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011907 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011908 return -EIO;
11909 }
11910
11911 if (currBand != band) {
11912 /* Change band request received.
11913 * Abort pending scan requests, flush the existing scan results,
11914 * and change the band capability
11915 */
Jeff Johnson99bac312016-06-28 10:38:18 -070011916 hdd_notice("Current band value = %u, new setting %u ",
11917 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011918
11919 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011920 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011921 pAdapter = pAdapterNode->pAdapter;
11922 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11923 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053011924 INVALID_SCAN_ID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011925 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
11926 connectedBand =
11927 hdd_conn_get_connected_band
11928 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
11929
11930 /* Handling is done only for STA and P2P */
11931 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -080011932 ((pAdapter->device_mode == QDF_STA_MODE)
11933 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011934 &&
11935 (hdd_conn_is_connected
11936 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
11937 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011938 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011939 long lrc;
11940
Jeff Johnson3bb7c732017-01-12 08:40:17 -080011941 /* STA already connected on current
11942 * band, So issue disconnect first,
11943 * then change the band
11944 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011945
Jeff Johnson99bac312016-06-28 10:38:18 -070011946 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011947 hdd_device_mode_to_string(pAdapter->device_mode),
11948 pAdapter->device_mode, currBand, band);
11949 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11950
11951 status =
11952 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
11953 (pAdapter),
11954 pAdapter->sessionId,
11955 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11956
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011957 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011958 hdd_err("csr_roam_disconnect failure, returned %d",
11959 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011960 return -EINVAL;
11961 }
11962
11963 lrc =
11964 wait_for_completion_timeout(&pAdapter->
11965 disconnect_comp_var,
11966 msecs_to_jiffies
11967 (WLAN_WAIT_TIME_DISCONNECT));
11968
11969 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011970 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011971 return -ETIMEDOUT;
11972 }
11973 }
11974
11975 sme_scan_flush_result(hHal);
11976
11977 status =
11978 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
11979 pAdapterNode = pNext;
11980 }
11981
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011982 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011983 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011984 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011985 band);
11986 return -EINVAL;
11987 }
11988 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
11989 }
11990 return 0;
11991}
11992
11993int hdd_set_band_helper(struct net_device *dev, const char *command)
11994{
11995 uint8_t band;
11996 int ret;
11997
11998 /* Convert the band value from ascii to integer */
11999 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
12000 ret = kstrtou8(command, 10, &band);
12001 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012002 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012003 return -EINVAL;
12004 }
12005
12006 return hdd_set_band(dev, band);
12007}
12008
12009static int __iw_set_band_config(struct net_device *dev,
12010 struct iw_request_info *info,
12011 union iwreq_data *wrqu, char *extra)
12012{
Jeff Johnson441e1f72017-02-07 08:50:49 -080012013 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12014 hdd_context_t *hdd_ctx;
12015 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012016 int *value = (int *)extra;
12017
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012018 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012019
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012020 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012021 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012022 return -EPERM;
12023 }
12024
Jeff Johnson441e1f72017-02-07 08:50:49 -080012025 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12026 ret = hdd_check_private_wext_control(hdd_ctx, info);
12027 if (0 != ret)
12028 return ret;
12029
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012030 return hdd_set_band(dev, value[0]);
12031}
12032
12033static int iw_set_band_config(struct net_device *dev,
12034 struct iw_request_info *info,
12035 union iwreq_data *wrqu, char *extra)
12036{
12037 int ret;
12038
12039 cds_ssr_protect(__func__);
12040 ret = __iw_set_band_config(dev, info, wrqu, extra);
12041 cds_ssr_unprotect(__func__);
12042
12043 return ret;
12044}
12045
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012046/**
12047 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
12048 * @adapter: Handle to adapter
12049 * @chan: Monitor mode channel
12050 * @bandwidth: Capture channel bandwidth
12051 *
12052 * Return: 0 on success else error code.
12053 */
12054static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
12055 uint32_t bandwidth)
12056{
12057 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12058 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
12059 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
12060 QDF_STATUS status;
12061 tHalHandle hal_hdl = hdd_ctx->hHal;
12062 struct qdf_mac_addr bssid;
12063 tCsrRoamProfile roam_profile;
12064 struct ch_params_s ch_params;
12065
12066 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
12067 hdd_err("Not supported, device is not in monitor mode");
12068 return -EINVAL;
12069 }
12070
12071 hdd_info("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080012072 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012073 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
12074 roam_profile.ChannelInfo.numOfChannels = 1;
12075 roam_profile.phyMode = ch_info->phy_mode;
12076 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070012077 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012078
12079 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
12080 QDF_MAC_ADDR_SIZE);
12081
12082 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -070012083 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012084 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
12085 &roam_profile);
12086 if (status) {
12087 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
12088 status);
12089 }
12090
12091 return qdf_status_to_os_return(status);
12092}
12093
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012094static int __iw_set_two_ints_getnone(struct net_device *dev,
12095 struct iw_request_info *info,
12096 union iwreq_data *wrqu, char *extra)
12097{
12098 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12099 int *value = (int *)extra;
12100 int sub_cmd = value[0];
12101 int ret;
12102 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
12103
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012104 ENTER_DEV(dev);
12105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012106 ret = wlan_hdd_validate_context(hdd_ctx);
12107 if (0 != ret)
12108 return ret;
12109
Jeff Johnson441e1f72017-02-07 08:50:49 -080012110 ret = hdd_check_private_wext_control(hdd_ctx, info);
12111 if (0 != ret)
12112 return ret;
12113
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012114 switch (sub_cmd) {
12115 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -070012116 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012117 ret = wma_cli_set_command(pAdapter->sessionId,
12118 WMI_STA_SMPS_PARAM_CMDID,
12119 value[1] << WMA_SMPS_PARAM_VALUE_S
12120 | value[2],
12121 VDEV_CMD);
12122 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070012123#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012124 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -070012125 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012126 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053012127 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
12128 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012129 ret = wma_cli_set2_command(pAdapter->sessionId,
12130 GEN_PARAM_CRASH_INJECT,
12131 value[1], value[2], GEN_CMD);
12132 break;
12133#endif
Govind Singha471e5e2015-10-12 17:11:14 +053012134 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070012135 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012136 value[1], value[2]);
12137 ret = wma_cli_set2_command(pAdapter->sessionId,
12138 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
12139 value[1], value[2], DBG_CMD);
12140 break;
12141 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070012142 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012143 value[1], value[2]);
12144 ret = wma_cli_set2_command(pAdapter->sessionId,
12145 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
12146 value[1], value[2], DBG_CMD);
12147 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012148 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
12149 hdd_debug("Ioctl to set dual fw mode config");
12150 if (hdd_ctx->config->dual_mac_feature_disable) {
12151 hdd_err("Dual mac feature is disabled from INI");
12152 return -EPERM;
12153 }
12154 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -080012155 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012156 break;
12157 case WE_DUMP_DP_TRACE_LEVEL:
12158 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
12159 value[1], value[2]);
12160 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012161 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053012162 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
12163 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053012164 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
12165 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012166 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012167 case WE_SET_MON_MODE_CHAN:
12168 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
12169 break;
Dustin Brown54096432017-02-23 13:00:44 -080012170 case WE_SET_WLAN_SUSPEND: {
12171 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
12172 value[1], value[2]);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012173 break;
Dustin Brown54096432017-02-23 13:00:44 -080012174 }
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012175 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070012176 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012177 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012178 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070012179 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012180 break;
12181 }
12182
12183 return ret;
12184}
12185
12186static int iw_set_two_ints_getnone(struct net_device *dev,
12187 struct iw_request_info *info,
12188 union iwreq_data *wrqu, char *extra)
12189{
12190 int ret;
12191
12192 cds_ssr_protect(__func__);
12193 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
12194 cds_ssr_unprotect(__func__);
12195
12196 return ret;
12197}
12198
12199/* Define the Wireless Extensions to the Linux Network Device structure */
12200/* A number of these routines are NULL (meaning they are not implemented.) */
12201
12202static const iw_handler we_handler[] = {
12203 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
12204 (iw_handler) iw_get_name, /* SIOCGIWNAME */
12205 (iw_handler) NULL, /* SIOCSIWNWID */
12206 (iw_handler) NULL, /* SIOCGIWNWID */
12207 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
12208 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
12209 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
12210 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
12211 (iw_handler) NULL, /* SIOCSIWSENS */
12212 (iw_handler) NULL, /* SIOCGIWSENS */
12213 (iw_handler) NULL, /* SIOCSIWRANGE */
12214 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
12215 (iw_handler) NULL, /* SIOCSIWPRIV */
12216 (iw_handler) NULL, /* SIOCGIWPRIV */
12217 (iw_handler) NULL, /* SIOCSIWSTATS */
12218 (iw_handler) NULL, /* SIOCGIWSTATS */
12219 (iw_handler) NULL, /* SIOCSIWSPY */
12220 (iw_handler) NULL, /* SIOCGIWSPY */
12221 (iw_handler) NULL, /* SIOCSIWTHRSPY */
12222 (iw_handler) NULL, /* SIOCGIWTHRSPY */
12223 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
12224 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
12225 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
12226 (iw_handler) NULL, /* SIOCGIWAPLIST */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012227#ifndef NAPIER_SCAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012228 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
12229 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012230#else
12231 (iw_handler) NULL, /* SIOCSIWSCAN */
12232 (iw_handler) NULL, /* SIOCGIWSCAN */
12233#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012234 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
12235 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
12236 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
12237 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
12238 (iw_handler) NULL, /* -- hole -- */
12239 (iw_handler) NULL, /* -- hole -- */
12240 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
12241 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
12242 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
12243 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
12244 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
12245 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
12246 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
12247 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
12248 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
12249 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
12250 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
12251 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
12252 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
12253 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
12254 (iw_handler) NULL, /* -- hole -- */
12255 (iw_handler) NULL, /* -- hole -- */
12256 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
12257 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
12258 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
12259 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
12260 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
12261 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
12262 (iw_handler) NULL, /* SIOCSIWPMKSA */
12263};
12264
12265static const iw_handler we_private[] = {
12266
12267 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
12268 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
12269 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
12270 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12271 iw_set_three_ints_getnone,
12272 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
12273 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
12274 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12275 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070012276 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
12277 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012278 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
12279 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
12280 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012281 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012282 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
12283 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
12284 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
12285 iw_set_keepalive_params,
12286#ifdef WLAN_FEATURE_PACKET_FILTERING
12287 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
12288 iw_set_packet_filter_params,
12289#endif
12290#ifdef FEATURE_WLAN_SCAN_PNO
12291 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
12292#endif
12293 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080012294 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
12295 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012296 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
12297 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12298 iw_set_two_ints_getnone,
12299 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
12300 iw_set_dot11p_channel_sched,
12301};
12302
12303/*Maximum command length can be only 15 */
12304static const struct iw_priv_args we_private_args[] = {
12305
12306 /* handlers for main ioctl */
12307 {WLAN_PRIV_SET_INT_GET_NONE,
12308 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12309 0,
12310 ""},
12311
12312 /* handlers for sub-ioctl */
12313 {WE_SET_11D_STATE,
12314 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12315 0,
12316 "set11Dstate"},
12317
12318 {WE_WOWL,
12319 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12320 0,
12321 "wowl"},
12322
12323 {WE_SET_POWER,
12324 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12325 0,
12326 "setPower"},
12327
12328 {WE_SET_MAX_ASSOC,
12329 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12330 0,
12331 "setMaxAssoc"},
12332
12333 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
12334 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
12335 "setAutoChannel" },
12336
12337 {WE_SET_SCAN_DISABLE,
12338 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12339 0,
12340 "scan_disable"},
12341
12342 {WE_SET_DATA_INACTIVITY_TO,
12343 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12344 0,
12345 "inactivityTO"},
12346
12347 {WE_SET_MAX_TX_POWER,
12348 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12349 0,
12350 "setMaxTxPower"},
12351
12352 {WE_SET_TX_POWER,
12353 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12354 0,
12355 "setTxPower"},
12356
12357 {WE_SET_MC_RATE,
12358 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12359 0,
12360 "setMcRate"},
12361
12362 {WE_SET_MAX_TX_POWER_2_4,
12363 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12364 0,
12365 "setTxMaxPower2G"},
12366
12367 {WE_SET_MAX_TX_POWER_5_0,
12368 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12369 0,
12370 "setTxMaxPower5G"},
12371
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012372 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012373 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012374 0,
12375 "pktlog"},
12376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012377 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
12378 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012379 * will support both
12380 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012381 {WE_SET_MAX_TX_POWER,
12382 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12383 0,
12384 "setTxMaxPower"},
12385
12386 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012387 * 1 = enable and 0 = disable
12388 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012389 {
12390 WE_SET_HIGHER_DTIM_TRANSITION,
12391 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12392 0,
12393 "setHDtimTransn"
12394 },
12395
12396 {WE_SET_TM_LEVEL,
12397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12398 0,
12399 "setTmLevel"},
12400
12401 {WE_SET_PHYMODE,
12402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12403 0,
12404 "setphymode"},
12405
12406 {WE_SET_NSS,
12407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12408 0,
12409 "nss"},
12410
12411 {WE_SET_LDPC,
12412 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12413 0,
12414 "ldpc"},
12415
12416 {WE_SET_TX_STBC,
12417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12418 0,
12419 "tx_stbc"},
12420
12421 {WE_SET_RX_STBC,
12422 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12423 0,
12424 "rx_stbc"},
12425
12426 {WE_SET_SHORT_GI,
12427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12428 0,
12429 "shortgi"},
12430
12431 {WE_SET_RTSCTS,
12432 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12433 0,
12434 "enablertscts"},
12435
12436 {WE_SET_CHWIDTH,
12437 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12438 0,
12439 "chwidth"},
12440
12441 {WE_SET_ANI_EN_DIS,
12442 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12443 0,
12444 "anienable"},
12445
12446 {WE_SET_ANI_POLL_PERIOD,
12447 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12448 0,
12449 "aniplen"},
12450
12451 {WE_SET_ANI_LISTEN_PERIOD,
12452 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12453 0,
12454 "anilislen"},
12455
12456 {WE_SET_ANI_OFDM_LEVEL,
12457 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12458 0,
12459 "aniofdmlvl"},
12460
12461 {WE_SET_ANI_CCK_LEVEL,
12462 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12463 0,
12464 "aniccklvl"},
12465
12466 {WE_SET_DYNAMIC_BW,
12467 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12468 0,
12469 "cwmenable"},
12470
12471 {WE_SET_CTS_CBW,
12472 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12473 0,
12474 "cts_cbw" },
12475
12476 {WE_SET_GTX_HT_MCS,
12477 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12478 0,
12479 "gtxHTMcs"},
12480
12481 {WE_SET_GTX_VHT_MCS,
12482 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12483 0,
12484 "gtxVHTMcs"},
12485
12486 {WE_SET_GTX_USRCFG,
12487 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12488 0,
12489 "gtxUsrCfg"},
12490
12491 {WE_SET_GTX_THRE,
12492 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12493 0,
12494 "gtxThre"},
12495
12496 {WE_SET_GTX_MARGIN,
12497 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12498 0,
12499 "gtxMargin"},
12500
12501 {WE_SET_GTX_STEP,
12502 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12503 0,
12504 "gtxStep"},
12505
12506 {WE_SET_GTX_MINTPC,
12507 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12508 0,
12509 "gtxMinTpc"},
12510
12511 {WE_SET_GTX_BWMASK,
12512 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12513 0,
12514 "gtxBWMask"},
12515
12516 {WE_SET_TX_CHAINMASK,
12517 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12518 0,
12519 "txchainmask"},
12520
12521 {WE_SET_RX_CHAINMASK,
12522 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12523 0,
12524 "rxchainmask"},
12525
12526 {WE_SET_11N_RATE,
12527 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12528 0,
12529 "set11NRates"},
12530
12531 {WE_SET_VHT_RATE,
12532 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12533 0,
12534 "set11ACRates"},
12535
12536 {WE_SET_AMPDU,
12537 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12538 0,
12539 "ampdu"},
12540
12541 {WE_SET_AMSDU,
12542 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12543 0,
12544 "amsdu"},
12545
12546 {WE_SET_BURST_ENABLE,
12547 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12548 0,
12549 "burst_enable"},
12550
12551 {WE_SET_BURST_DUR,
12552 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12553 0,
12554 "burst_dur"},
12555
12556 {WE_SET_TXPOW_2G,
12557 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12558 0,
12559 "txpow2g"},
12560
12561 {WE_SET_TXPOW_5G,
12562 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12563 0,
12564 "txpow5g"},
12565
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012566 /* Sub-cmds DBGLOG specific commands */
12567 {WE_DBGLOG_LOG_LEVEL,
12568 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12569 0,
12570 "dl_loglevel"},
12571
12572 {WE_DBGLOG_VAP_ENABLE,
12573 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12574 0,
12575 "dl_vapon"},
12576
12577 {WE_DBGLOG_VAP_DISABLE,
12578 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12579 0,
12580 "dl_vapoff"},
12581
12582 {WE_DBGLOG_MODULE_ENABLE,
12583 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12584 0,
12585 "dl_modon"},
12586
12587 {WE_DBGLOG_MODULE_DISABLE,
12588 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12589 0,
12590 "dl_modoff"},
12591
12592 {WE_DBGLOG_MOD_LOG_LEVEL,
12593 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12594 0,
12595 "dl_mod_loglevel"},
12596
12597 {WE_DBGLOG_TYPE,
12598 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12599 0,
12600 "dl_type"},
12601 {WE_DBGLOG_REPORT_ENABLE,
12602 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12603 0,
12604 "dl_report"},
12605
12606 {WE_SET_TXRX_FWSTATS,
12607 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12608 0,
12609 "txrx_fw_stats"},
12610
12611 {WE_TXRX_FWSTATS_RESET,
12612 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12613 0,
12614 "txrx_fw_st_rst"},
12615
12616 {WE_PPS_PAID_MATCH,
12617 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12618 0, "paid_match"},
12619
12620 {WE_PPS_GID_MATCH,
12621 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12622 0, "gid_match"},
12623
12624 {WE_PPS_EARLY_TIM_CLEAR,
12625 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12626 0, "tim_clear"},
12627
12628 {WE_PPS_EARLY_DTIM_CLEAR,
12629 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12630 0, "dtim_clear"},
12631
12632 {WE_PPS_EOF_PAD_DELIM,
12633 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12634 0, "eof_delim"},
12635
12636 {WE_PPS_MACADDR_MISMATCH,
12637 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12638 0, "mac_match"},
12639
12640 {WE_PPS_DELIM_CRC_FAIL,
12641 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12642 0, "delim_fail"},
12643
12644 {WE_PPS_GID_NSTS_ZERO,
12645 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12646 0, "nsts_zero"},
12647
12648 {WE_PPS_RSSI_CHECK,
12649 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12650 0, "rssi_chk"},
12651
12652 {WE_PPS_5G_EBT,
12653 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12654 0, "5g_ebt"},
12655
12656 {WE_SET_HTSMPS,
12657 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12658 0, "htsmps"},
12659
12660 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
12661 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12662 0, "set_qpspollcnt"},
12663
12664 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
12665 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12666 0, "set_qtxwake"},
12667
12668 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
12669 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12670 0, "set_qwakeintv"},
12671
12672 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
12673 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12674 0, "set_qnodatapoll"},
12675
12676 /* handlers for MCC time quota and latency sub ioctls */
12677 {WE_MCC_CONFIG_LATENCY,
12678 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12679 0, "setMccLatency"},
12680
12681 {WE_MCC_CONFIG_QUOTA,
12682 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12683 0, "setMccQuota"},
12684
12685 {WE_SET_DEBUG_LOG,
12686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12687 0, "setDbgLvl"},
12688
12689 /* handlers for early_rx power save */
12690 {WE_SET_EARLY_RX_ADJUST_ENABLE,
12691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12692 0, "erx_enable"},
12693
12694 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
12695 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12696 0, "erx_bmiss_val"},
12697
12698 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
12699 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12700 0, "erx_bmiss_smpl"},
12701
12702 {WE_SET_EARLY_RX_SLOP_STEP,
12703 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12704 0, "erx_slop_step"},
12705
12706 {WE_SET_EARLY_RX_INIT_SLOP,
12707 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12708 0, "erx_init_slop"},
12709
12710 {WE_SET_EARLY_RX_ADJUST_PAUSE,
12711 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12712 0, "erx_adj_pause"},
12713
12714 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
12715 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12716 0, "erx_dri_sample"},
12717
12718 {WE_DUMP_STATS,
12719 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12720 0, "dumpStats"},
12721
12722 {WE_CLEAR_STATS,
12723 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12724 0, "clearStats"},
12725
Govind Singha471e5e2015-10-12 17:11:14 +053012726 {WE_START_FW_PROFILE,
12727 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12728 0, "startProfile"},
12729
Abhishek Singh1bdb1572015-10-16 16:24:19 +053012730 {WE_SET_CHANNEL,
12731 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12732 0, "setChanChange" },
12733
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053012734 {WE_SET_CONC_SYSTEM_PREF,
12735 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12736 0, "setConcSysPref" },
12737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012738 {WLAN_PRIV_SET_NONE_GET_INT,
12739 0,
12740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12741 ""},
12742
12743 /* handlers for sub-ioctl */
12744 {WE_GET_11D_STATE,
12745 0,
12746 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12747 "get11Dstate"},
12748
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012749 {WE_GET_WLAN_DBG,
12750 0,
12751 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12752 "getwlandbg"},
12753
12754 {WE_GET_MAX_ASSOC,
12755 0,
12756 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12757 "getMaxAssoc"},
12758
12759 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
12760 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12761 "getAutoChannel" },
12762
12763 {WE_GET_CONCURRENCY_MODE,
12764 0,
12765 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12766 "getconcurrency"},
12767
12768 {WE_GET_NSS,
12769 0,
12770 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12771 "get_nss"},
12772
12773 {WE_GET_LDPC,
12774 0,
12775 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12776 "get_ldpc"},
12777
12778 {WE_GET_TX_STBC,
12779 0,
12780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12781 "get_tx_stbc"},
12782
12783 {WE_GET_RX_STBC,
12784 0,
12785 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12786 "get_rx_stbc"},
12787
12788 {WE_GET_SHORT_GI,
12789 0,
12790 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12791 "get_shortgi"},
12792
12793 {WE_GET_RTSCTS,
12794 0,
12795 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12796 "get_rtscts"},
12797
12798 {WE_GET_CHWIDTH,
12799 0,
12800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12801 "get_chwidth"},
12802
12803 {WE_GET_ANI_EN_DIS,
12804 0,
12805 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12806 "get_anienable"},
12807
12808 {WE_GET_ANI_POLL_PERIOD,
12809 0,
12810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12811 "get_aniplen"},
12812
12813 {WE_GET_ANI_LISTEN_PERIOD,
12814 0,
12815 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12816 "get_anilislen"},
12817
12818 {WE_GET_ANI_OFDM_LEVEL,
12819 0,
12820 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12821 "get_aniofdmlvl"},
12822
12823 {WE_GET_ANI_CCK_LEVEL,
12824 0,
12825 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12826 "get_aniccklvl"},
12827
12828 {WE_GET_DYNAMIC_BW,
12829 0,
12830 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12831 "get_cwmenable"},
12832
12833 {WE_GET_GTX_HT_MCS,
12834 0,
12835 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12836 "get_gtxHTMcs"},
12837
12838 {WE_GET_GTX_VHT_MCS,
12839 0,
12840 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12841 "get_gtxVHTMcs"},
12842
12843 {WE_GET_GTX_USRCFG,
12844 0,
12845 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12846 "get_gtxUsrCfg"},
12847
12848 {WE_GET_GTX_THRE,
12849 0,
12850 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12851 "get_gtxThre"},
12852
12853 {WE_GET_GTX_MARGIN,
12854 0,
12855 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12856 "get_gtxMargin"},
12857
12858 {WE_GET_GTX_STEP,
12859 0,
12860 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12861 "get_gtxStep"},
12862
12863 {WE_GET_GTX_MINTPC,
12864 0,
12865 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12866 "get_gtxMinTpc"},
12867
12868 {WE_GET_GTX_BWMASK,
12869 0,
12870 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12871 "get_gtxBWMask"},
12872
12873 {WE_GET_TX_CHAINMASK,
12874 0,
12875 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12876 "get_txchainmask"},
12877
12878 {WE_GET_RX_CHAINMASK,
12879 0,
12880 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12881 "get_rxchainmask"},
12882
12883 {WE_GET_11N_RATE,
12884 0,
12885 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12886 "get_11nrate"},
12887
12888 {WE_GET_AMPDU,
12889 0,
12890 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12891 "get_ampdu"},
12892
12893 {WE_GET_AMSDU,
12894 0,
12895 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12896 "get_amsdu"},
12897
12898 {WE_GET_BURST_ENABLE,
12899 0,
12900 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12901 "get_burst_en"},
12902
12903 {WE_GET_BURST_DUR,
12904 0,
12905 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12906 "get_burst_dur"},
12907
12908 {WE_GET_TXPOW_2G,
12909 0,
12910 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12911 "get_txpow2g"},
12912
12913 {WE_GET_TXPOW_5G,
12914 0,
12915 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12916 "get_txpow5g"},
12917
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012918 {WE_GET_PPS_PAID_MATCH,
12919 0,
12920 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12921 "get_paid_match"},
12922
12923 {WE_GET_PPS_GID_MATCH,
12924 0,
12925 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12926 "get_gid_match"},
12927
12928 {WE_GET_PPS_EARLY_TIM_CLEAR,
12929 0,
12930 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12931 "get_tim_clear"},
12932
12933 {WE_GET_PPS_EARLY_DTIM_CLEAR,
12934 0,
12935 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12936 "get_dtim_clear"},
12937
12938 {WE_GET_PPS_EOF_PAD_DELIM,
12939 0,
12940 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12941 "get_eof_delim"},
12942
12943 {WE_GET_PPS_MACADDR_MISMATCH,
12944 0,
12945 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12946 "get_mac_match"},
12947
12948 {WE_GET_PPS_DELIM_CRC_FAIL,
12949 0,
12950 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12951 "get_delim_fail"},
12952
12953 {WE_GET_PPS_GID_NSTS_ZERO,
12954 0,
12955 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12956 "get_nsts_zero"},
12957
12958 {WE_GET_PPS_RSSI_CHECK,
12959 0,
12960 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12961 "get_rssi_chk"},
12962
12963 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
12964 0,
12965 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12966 "get_qpspollcnt"},
12967
12968 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
12969 0,
12970 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12971 "get_qtxwake"},
12972
12973 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
12974 0,
12975 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12976 "get_qwakeintv"},
12977
12978 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
12979 0,
12980 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12981 "get_qnodatapoll"},
12982
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070012983 {WE_CAP_TSF,
12984 0,
12985 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12986 "cap_tsf"},
12987
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012988 {WE_GET_TEMPERATURE,
12989 0,
12990 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12991 "get_temp"},
12992 /* handlers for main ioctl */
12993 {WLAN_PRIV_SET_CHAR_GET_NONE,
12994 IW_PRIV_TYPE_CHAR | 512,
12995 0,
12996 ""},
12997
12998 /* handlers for sub-ioctl */
12999 {WE_WOWL_ADD_PTRN,
13000 IW_PRIV_TYPE_CHAR | 512,
13001 0,
13002 "wowlAddPtrn"},
13003
13004 {WE_WOWL_DEL_PTRN,
13005 IW_PRIV_TYPE_CHAR | 512,
13006 0,
13007 "wowlDelPtrn"},
13008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013009 /* handlers for sub-ioctl */
13010 {WE_NEIGHBOR_REPORT_REQUEST,
13011 IW_PRIV_TYPE_CHAR | 512,
13012 0,
13013 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080013014
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013015 {WE_SET_AP_WPS_IE,
13016 IW_PRIV_TYPE_CHAR | 512,
13017 0,
13018 "set_ap_wps_ie"},
13019
13020 {WE_SET_CONFIG,
13021 IW_PRIV_TYPE_CHAR | 512,
13022 0,
13023 "setConfig"},
13024
13025 /* handlers for main ioctl */
13026 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
13027 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13028 0,
13029 ""},
13030
13031 /* handlers for sub-ioctl */
13032 {WE_SET_WLAN_DBG,
13033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13034 0,
13035 "setwlandbg"},
13036
13037 /* handlers for sub-ioctl */
13038 {WE_SET_DP_TRACE,
13039 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13040 0,
13041 "set_dp_trace"},
13042
13043 {WE_SET_SAP_CHANNELS,
13044 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13045 0,
13046 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013047
13048 {WE_SET_FW_TEST,
13049 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13050 0, "fw_test"},
13051
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013052 /* handlers for main ioctl */
13053 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
13054 0,
13055 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13056 "" },
13057 {WE_GET_TSF,
13058 0,
13059 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13060 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013061
13062 {WE_SET_DUAL_MAC_SCAN_CONFIG,
13063 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13064 0,
13065 "set_scan_cfg"},
13066
13067 /* handlers for main ioctl */
13068 {WLAN_PRIV_GET_CHAR_SET_NONE,
13069 0,
13070 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13071 ""},
13072
13073 /* handlers for sub-ioctl */
13074 {WE_WLAN_VERSION,
13075 0,
13076 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13077 "version"},
13078 {WE_GET_STATS,
13079 0,
13080 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13081 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080013082 {WE_GET_SUSPEND_RESUME_STATS,
13083 0,
13084 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13085 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053013086 {WE_LIST_FW_PROFILE,
13087 0,
13088 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13089 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013090 {WE_GET_STATES,
13091 0,
13092 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13093 "getHostStates"},
13094 {WE_GET_CFG,
13095 0,
13096 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13097 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013098 {WE_GET_RSSI,
13099 0,
13100 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13101 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013102 {WE_GET_WMM_STATUS,
13103 0,
13104 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13105 "getWmmStatus"},
13106 {
13107 WE_GET_CHANNEL_LIST,
13108 0,
13109 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13110 "getChannelList"
13111 },
13112#ifdef FEATURE_WLAN_TDLS
13113 {
13114 WE_GET_TDLS_PEERS,
13115 0,
13116 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13117 "getTdlsPeers"
13118 },
13119#endif
13120#ifdef WLAN_FEATURE_11W
13121 {
13122 WE_GET_11W_INFO,
13123 0,
13124 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13125 "getPMFInfo"
13126 },
13127#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013128 {
13129 WE_GET_IBSS_STA_INFO,
13130 0,
13131 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13132 "getIbssSTAs"
13133 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013134 {WE_GET_PHYMODE,
13135 0,
13136 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13137 "getphymode"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013138#if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013139 {WE_GET_OEM_DATA_CAP,
13140 0,
13141 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13142 "getOemDataCap"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013143#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013144 {WE_GET_SNR,
13145 0,
13146 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13147 "getSNR"},
13148
13149 /* handlers for main ioctl */
13150 {WLAN_PRIV_SET_NONE_GET_NONE,
13151 0,
13152 0,
13153 ""},
13154
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013155 /* handlers for sub-ioctl */
13156 {
13157 WE_IBSS_GET_PEER_INFO_ALL,
13158 0,
13159 0,
13160 "ibssPeerInfoAll"
13161 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013162 {WE_GET_RECOVERY_STAT,
13163 0,
13164 0,
13165 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053013166
13167 {WE_GET_FW_PROFILE_DATA,
13168 0,
13169 0,
13170 "getProfileData"},
13171
13172 {WE_SET_REASSOC_TRIGGER,
13173 0,
13174 0,
13175 "reassoc"},
13176
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080013177 {WE_STOP_OBSS_SCAN,
13178 0,
13179 0,
13180 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013181 /* handlers for main ioctl */
13182 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
13183 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13184 0,
13185 ""},
13186
13187 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013188 {WE_IBSS_GET_PEER_INFO,
13189 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13190 0,
13191 "ibssPeerInfo"},
13192
13193 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013194 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
13195 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13196 0,
13197 "setdumplog"},
13198
13199 {WE_MTRACE_DUMP_CMD,
13200 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13201 0,
13202 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080013203
13204 {WE_POLICY_MANAGER_CINFO_CMD,
13205 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13206 0,
13207 "pm_cinfo"},
13208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013209#ifdef MPC_UT_FRAMEWORK
13210 {WE_POLICY_MANAGER_CLIST_CMD,
13211 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13212 0,
13213 "pm_clist"},
13214
13215 {WE_POLICY_MANAGER_DLIST_CMD,
13216 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13217 0,
13218 "pm_dlist"},
13219
13220 {WE_POLICY_MANAGER_DBS_CMD,
13221 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13222 0,
13223 "pm_dbs"},
13224
13225 {WE_POLICY_MANAGER_PCL_CMD,
13226 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13227 0,
13228 "pm_pcl"},
13229
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013230 {WE_POLICY_MANAGER_ULIST_CMD,
13231 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13232 0,
13233 "pm_ulist"},
13234
13235 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
13236 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13237 0,
13238 "pm_query_action"},
13239
13240 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
13241 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13242 0,
13243 "pm_query_allow"},
13244
13245 {WE_POLICY_MANAGER_SCENARIO_CMD,
13246 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13247 0,
13248 "pm_run_scenario"},
13249
13250 {WE_POLICY_SET_HW_MODE_CMD,
13251 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13252 0,
13253 "pm_set_hw_mode"},
13254#endif
13255#ifdef FEATURE_WLAN_TDLS
13256 /* handlers for sub ioctl */
13257 {
13258 WE_TDLS_CONFIG_PARAMS,
13259 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13260 0,
13261 "setTdlsConfig"
13262 },
13263#endif
13264 {
13265 WE_UNIT_TEST_CMD,
13266 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13267 0,
13268 "setUnitTestCmd"
13269 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053013270 {
13271 WE_MAC_PWR_DEBUG_CMD,
13272 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13273 0,
13274 "halPwrDebug"
13275 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013276
13277#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
13278 {WE_LED_FLASHING_PARAM,
13279 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13280 0,
13281 "gpio_control"},
13282#endif
13283 /* handlers for main ioctl */
13284 {WLAN_PRIV_ADD_TSPEC,
13285 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
13286 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13287 "addTspec"},
13288
13289 /* handlers for main ioctl */
13290 {WLAN_PRIV_DEL_TSPEC,
13291 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13293 "delTspec"},
13294
13295 /* handlers for main ioctl */
13296 {WLAN_PRIV_GET_TSPEC,
13297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13298 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13299 "getTspec"},
13300
13301 /* handlers for main ioctl - host offload */
13302 {
13303 WLAN_PRIV_SET_HOST_OFFLOAD,
13304 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
13305 0,
13306 "setHostOffload"
13307 }
13308 ,
13309
13310 {
13311 WLAN_GET_WLAN_STATISTICS,
13312 0,
13313 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
13314 "getWlanStats"
13315 }
13316 ,
13317
13318 {
13319 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053013320 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
13321 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013322 0,
13323 "setKeepAlive"
13324 }
13325 ,
13326#ifdef WLAN_FEATURE_PACKET_FILTERING
13327 {
13328 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053013329 IW_PRIV_TYPE_BYTE |
13330 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013331 0,
13332 "setPktFilter"
13333 }
13334 ,
13335#endif
13336#ifdef FEATURE_WLAN_SCAN_PNO
13337 {
13338 WLAN_SET_PNO,
13339 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13340 0,
13341 "setpno"
13342 }
13343 ,
13344#endif
13345 {
13346 WLAN_SET_BAND_CONFIG,
13347 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13348 0,
13349 "SETBAND"
13350 }
13351 ,
13352 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080013353 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080013354 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013355 0,
13356 "setMCBCFilter"
13357 }
13358 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013359
13360 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013361 WLAN_GET_LINK_SPEED,
13362 IW_PRIV_TYPE_CHAR | 18,
13363 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
13364 }
13365 ,
13366
13367 /* handlers for main ioctl */
13368 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
13369 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13370 0,
13371 ""}
13372 ,
13373 {WE_SET_SMPS_PARAM,
13374 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13375 0, "set_smps_param"}
13376 ,
13377 {WLAN_SET_DOT11P_CHANNEL_SCHED,
13378 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
13379 0, "set_dot11p" }
13380 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070013381#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013382 {WE_SET_FW_CRASH_INJECT,
13383 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13384 0, "crash_inject"}
13385 ,
13386#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070013387#ifdef WLAN_SUSPEND_RESUME_TEST
13388 {WE_SET_WLAN_SUSPEND,
13389 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13390 0, "wlan_suspend"}
13391 ,
13392 {WE_SET_WLAN_RESUME,
13393 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13394 0, "wlan_resume"}
13395 ,
13396#endif
Govind Singha471e5e2015-10-12 17:11:14 +053013397 {WE_ENABLE_FW_PROFILE,
13398 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13399 0, "enableProfile"}
13400 ,
13401 {WE_SET_FW_PROFILE_HIST_INTVL,
13402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13403 0, "set_hist_intvl"}
13404 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013405 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
13406 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13407 0, "set_fw_mode_cfg"}
13408 ,
13409 {WE_DUMP_DP_TRACE_LEVEL,
13410 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13411 0, "dump_dp_trace"}
13412 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070013413 {WE_SET_MON_MODE_CHAN,
13414 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13415 0, "setMonChan"}
13416 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070013417
13418 {WE_GET_ROAM_SYNCH_DELAY,
13419 0,
13420 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13421 "hostroamdelay"}
13422 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013423};
13424
13425const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053013426 .num_standard = QDF_ARRAY_SIZE(we_handler),
13427 .num_private = QDF_ARRAY_SIZE(we_private),
13428 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013429
13430 .standard = (iw_handler *) we_handler,
13431 .private = (iw_handler *) we_private,
13432 .private_args = we_private_args,
13433 .get_wireless_stats = NULL,
13434};
13435
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013436/* hdd_set_wext() - configures bss parameters
13437 * @pAdapter: handle to adapter context
13438 *
13439 * Returns: none
13440 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070013441static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013442{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013443 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13444 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013445
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013446 ENTER();
13447
13448 if (!pwextBuf) {
13449 hdd_err("ERROR: pwextBuf is NULL");
13450 return QDF_STATUS_E_FAILURE;
13451 }
13452
13453 if (!pHddStaCtx) {
13454 hdd_err("ERROR: pHddStaCtx is NULL");
13455 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013456 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013457
13458 /* Now configure the roaming profile links. To SSID and bssid. */
13459 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013460 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013461
13462 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013463 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013464
13465 /*Set the numOfChannels to zero to scan all the channels */
13466 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
13467 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
13468
13469 /* Default is no encryption */
13470 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
13471 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
13472 eCSR_ENCRYPT_TYPE_NONE;
13473
13474 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
13475 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
13476 eCSR_ENCRYPT_TYPE_NONE;
13477
13478 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
13479
13480 /* Default is no authentication */
13481 pwextBuf->roamProfile.AuthType.numEntries = 1;
13482 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13483
13484 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
13485 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
13486
13487 /*Set the default scan mode */
13488 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
13489
13490 hdd_clear_roam_profile_ie(pAdapter);
13491
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013492 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013493 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013494
13495}
13496
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013497/**
13498 * hdd_register_wext() - register wext context
13499 * @dev: net device handle
13500 *
13501 * Registers wext interface context for a given net device
13502 *
13503 * Returns: 0 on success, errno on failure
13504 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013505int hdd_register_wext(struct net_device *dev)
13506{
13507 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013508 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053013509 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013510
13511 ENTER();
13512
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013513 if (!pwextBuf) {
13514 hdd_err(FL("ERROR: pwextBuf is NULL"));
13515 return QDF_STATUS_E_FAILURE;
13516 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013517
13518 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013519 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
13520
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013521 status = hdd_set_wext(pAdapter);
13522
Anurag Chouhance0dc992016-02-16 18:18:03 +053013523 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013524
Jeff Johnson99bac312016-06-28 10:38:18 -070013525 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013526 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013527 }
13528
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013529 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070013530 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013531 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013532 }
13533
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013534 /* Register as a wireless device */
13535 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
13536
13537 EXIT();
13538 return 0;
13539}
13540
13541int hdd_unregister_wext(struct net_device *dev)
13542{
Jeff Johnson99bac312016-06-28 10:38:18 -070013543 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013544
13545 if (dev != NULL) {
13546 rtnl_lock();
13547 dev->wireless_handlers = NULL;
13548 rtnl_unlock();
13549 }
13550
13551 return 0;
13552}