blob: 279b0c920c9801428c167a6c829c9b4c658ce4de [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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099#define HDD_FINISH_ULA_TIME_OUT 800
100#define HDD_SET_MCBC_FILTERS_TO_FW 1
101#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103/* To Validate Channel against the Frequency and Vice-Versa */
104static const hdd_freq_chan_map_t freq_chan_map[] = {
105 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
106 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
107 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
108 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
109 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
110 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
111 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
112 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
113 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
114 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
115 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
116 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
117
118#define FREQ_CHAN_MAP_TABLE_SIZE \
119 (sizeof(freq_chan_map) / sizeof(freq_chan_map[0]))
120
121/* Private ioctls and their sub-ioctls */
122#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
123#define WE_SET_11D_STATE 1
124#define WE_WOWL 2
125#define WE_SET_POWER 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530126/*
127 * <ioctl>
128 * setMaxAssoc - Sets the maximum number of associated stations
129 *
130 * @INPUT: 1 to 32
131 *
132 * @OUTPUT: None
133 *
134 * This IOTCL sets the maximum number of associated stations
135 *
136 * @E.g: iwpriv wlan0 setMaxAssoc <value>
137 *
138 * Supported Feature: STA
139 *
140 * Usage: Internal/External
141 *
142 * </ioctl>
143 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800144#define WE_SET_MAX_ASSOC 4
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +0530145/*
146 * <ioctl>
147 * scan_diable - Disable scan
148 *
149 * @INPUT: set_value
150 *
151 * @OUTPUT: None
152 *
153 * This IOCTL is used to set disable scan
154 *
155 * @E.g: iwpriv wlan0 scan_disable 1
156 *
157 * Supported Feature: Scan
158 *
159 * Usage: Internal/External
160 *
161 * </ioctl>
162 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163#define WE_SET_SCAN_DISABLE 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530164/*
165 * <ioctl>
166 * inactivityTO - sets the timeout value for inactivity data while
167 * in power save mode
168 *
169 * @INPUT: int1…..int255
170 *
171 * @OUTPUT: None
172 *
173 * This IOCTL set the timeout value for inactivity data in power save mode
174 *
175 * @E.g: iwpriv wlan0 inactivityTO 20
176 *
177 * Supported Feature: STA
178 *
179 * Usage: Internal/External
180 *
181 * </ioctl>
182 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183#define WE_SET_DATA_INACTIVITY_TO 6
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530184/*
185 * <ioctl>
186 * setMaxTxPower - Dynamically sets the maximum transmission power
187 *
188 * @INPUT: Transmission power in dBm
189 *
190 * @OUTPUT: None
191 *
192 * This IOCTL dynamically sets the maximum transmission power
193 * This setting does not persist over reboots
194 *
195 * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
196 *
197 * Supported Feature: STA
198 *
199 * Usage: Internal/External
200 *
201 * </ioctl>
202 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203#define WE_SET_MAX_TX_POWER 7
204#define WE_SET_HIGHER_DTIM_TRANSITION 8
205#define WE_SET_TM_LEVEL 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530206/*
207 * <ioctl>
208 * setphymode - Set the phymode dynamically
209 *
210 * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
211 *
212 * @OUTPUT: None
213 *
214 * This IOCTL sets the phymode dynamically
215 *
216 * @E.g: iwpriv wlan0 setphymode 10
217 *
218 * Supported Feature: STA
219 *
220 * Usage: Internal/External
221 *
222 * </ioctl>
223 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224#define WE_SET_PHYMODE 10
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530225/*
226 * <ioctl>
227 * nss - Set the number of spatial streams
228 *
229 * @INPUT: int1…..int3
230 *
231 * @OUTPUT: None
232 *
233 * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
234 *
235 * @E.g: iwpriv wlan0 nss 2
236 *
237 * Supported Feature: STA
238 *
239 * Usage: Internal/External
240 *
241 * </ioctl>
242 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243#define WE_SET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530244/*
245 * <ioctl>
246 * ldpc - Enables or disables LDPC
247 *
248 * @INPUT: 0 – Disable, 1 - Enable
249 *
250 * @OUTPUT: None
251 *
252 * This IOCTL enables or disables LDPC
253 *
254 * @E.g: iwpriv wlan0 ldpc 1
255 *
256 * Supported Feature: STA
257 *
258 * Usage: Internal/External
259 *
260 * </ioctl>
261 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262#define WE_SET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530263/*
264 * <ioctl>
265 * tx_stbc - Enables or disables tx_stbc
266 *
267 * @INPUT: Int 0 – Disable, 1 - Enable
268 *
269 * @OUTPUT: None
270 *
271 * This IOTCL used to enables or disables tx_stbc
272 *
273 * @E.g: iwpriv wlan0 tx_stbc <value>
274 *
275 * Supported Feature: STA
276 *
277 * Usage: Internal/External
278 *
279 * </ioctl>
280 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281#define WE_SET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530282/*
283 * <ioctl>
284 * rx_stbc - Set the rx_stbc parameter
285 *
286 * @INPUT: Int 0 – Disable, 1 - Enable
287 *
288 * @OUTPUT: None
289 *
290 * This IOTCL used to set rx_stbc parameter
291 *
292 * @E.g: iwpriv wlan0 rx_stbc <value>
293 *
294 * Supported Feature: STA
295 *
296 * Usage: Internal/External
297 *
298 * </ioctl>
299 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300#define WE_SET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530301/*
302 * <ioctl>
303 * shortgi - Enables or disables a short-guard interval
304 *
305 * @INPUT: Int 0 – Disable, 1 - Enable
306 *
307 * @OUTPUT: None
308 *
309 * This IOCTL enables or disables a short-guard interval.
310 *
311 * @E.g: iwpriv wlan0 shortgi <value>
312 *
313 * Supported Feature: STA
314 *
315 * Usage: Internal/External
316 *
317 * </ioctl>
318 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319#define WE_SET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530320/*
321 * <ioctl>
322 * enablertscts - enables or disables rts/cts.
323 *
324 * @INPUT: 1-Enable , 0-Disable
325 *
326 * @OUTPUT: None
327 *
328 * This IOCTL enables or disables rts/cts.
329 *
330 * @E.g: iwpriv wlan0 enablertscts <value>
331 *
332 * Supported Feature: STA
333 *
334 * Usage: Internal/External
335 *
336 * </ioctl>
337 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338#define WE_SET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530339/*
340 * <ioctl>
341 * chwidth - Set the channel bandwidth
342 *
343 * @INPUT: 0-20mhz to 3-160mhz
344 *
345 * @OUTPUT: None
346 *
347 * This IOTCL used to set the channel bandwidth
348 *
349 * @E.g: iwpriv wlan0 chwidth 1
350 *
351 * Supported Feature: STA
352 *
353 * Usage: Internal/External
354 *
355 * </ioctl>
356 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357#define WE_SET_CHWIDTH 17
358#define WE_SET_ANI_EN_DIS 18
359#define WE_SET_ANI_POLL_PERIOD 19
360#define WE_SET_ANI_LISTEN_PERIOD 20
361#define WE_SET_ANI_OFDM_LEVEL 21
362#define WE_SET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530363/*
364 * <ioctl>
365 * cwmenable - Enables or disables the dynamic channel bandwidth
366 *
367 * @INPUT: 0-Disable, 1-Enable
368 *
369 * @OUTPUT: None
370 *
371 * This IOTCL used to enables or disables the dynamic channel bandwidth
372 *
373 * @E.g: iwpriv wlan0 cwmenable <value>
374 *
375 * Supported Feature: STA
376 *
377 * Usage: Internal/External
378 *
379 * </ioctl>
380 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381#define WE_SET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530382/*
383 * <ioctl>
384 * txchainmask - This IOCTL sets the current Tx chain mask
385 *
386 * @INPUT: Mask Value
387 *
388 * @OUTPUT: None
389 *
390 * This IOCTL sets the current Tx chain mask
391 *
392 * @E.g: iwpriv wlan0 txchainmask 1
393 *
394 * Supported Feature: STA
395 *
396 * Usage: Internal/External
397 *
398 * </ioctl>
399 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400#define WE_SET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530401/*
402 * <ioctl>
403 * rxchainmask - Sets the current Rx chain mask
404 *
405 * @INPUT: Mask Value
406 *
407 * @OUTPUT: None
408 *
409 * This IOCTL sets the current Rx chain mask. This command is the
410 * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
411 *
412 * @E.g: iwpriv wlan0 rxchainmask <value>
413 *
414 * Supported Feature: STA
415 *
416 * Usage: Internal/External
417 *
418 * </ioctl>
419 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420#define WE_SET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530421/*
422 * <ioctl>
423 * set11NRates - Fixes the Tx data rate of the 11N mode.
424 *
425 * @INPUT: 0x1b to 0x8f
426 *
427 * @OUTPUT: None
428 *
429 * This IOCTL fixes the Tx data rate of the 11N mode.
430 *
431 * @E.g: iwpriv wlan0 set11NRates 0x85
432 *
433 * Supported Feature: STA
434 *
435 * Usage: Internal/External
436 *
437 * </ioctl>
438 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439#define WE_SET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530440/*
441 * <ioctl>
442 * ampdu - Set the the maximum subframe of ampdu
443 *
444 * @INPUT: int 1 to int 63
445 *
446 * @OUTPUT: None
447 *
448 * This IOCTL sets the maximum subframe of ampdu.
449 *
450 * @E.g: iwpriv wlan0 ampdu 9
451 *
452 * Supported Feature: STA
453 *
454 * Usage: Internal/External
455 *
456 * </ioctl>
457 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458#define WE_SET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530459/*
460 * <ioctl>
461 * amsdu - Sets the maximum subframe of amsdu.
462 *
463 * @INPUT: int 1 to int 31
464 *
465 * @OUTPUT: None
466 *
467 * This IOCTL sets the maximum subframe of amsdu.
468 *
469 * @E.g: iwpriv wlan0 amsdu 9
470 *
471 * Supported Feature: STA
472 *
473 * Usage: Internal/External
474 *
475 * </ioctl>
476 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477#define WE_SET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530478/*
479 * <ioctl>
480 * txpow2g - current 2 GHz Tx power setting
481 *
482 * @INPUT: Tx power in dBm
483 *
484 * @OUTPUT: None
485 *
486 * This IOTCL used to set 2 ghz tx power
487 *
488 * @E.g: iwpriv wlan0 txpow2g
489 *
490 * Supported Feature: STA
491 *
492 * Usage: Internal/External
493 *
494 * </ioctl>
495 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800496#define WE_SET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530497/*
498 * <ioctl>
499 * txpow5g - Current 5 GHz tx power setting
500 *
501 * @INPUT: Tx power in dBm
502 *
503 * @OUTPUT: None
504 *
505 * This IOTCL used to set the 5 ghz txpower
506 *
507 * @E.g: iwpriv wlan0 txpow5g
508 *
509 * Supported Feature: STA
510 *
511 * Usage: Internal/External
512 *
513 * </ioctl>
514 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515#define WE_SET_TXPOW_5G 30
516/* Private ioctl for firmware debug log */
517#define WE_DBGLOG_LOG_LEVEL 31
518#define WE_DBGLOG_VAP_ENABLE 32
519#define WE_DBGLOG_VAP_DISABLE 33
520#define WE_DBGLOG_MODULE_ENABLE 34
521#define WE_DBGLOG_MODULE_DISABLE 35
522#define WE_DBGLOG_MOD_LOG_LEVEL 36
523#define WE_DBGLOG_TYPE 37
524#define WE_SET_TXRX_FWSTATS 38
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530525/*
526 * <ioctl>
527 * set11ACRates - Fixes the Tx data rate of 11AC
528 *
529 * @INPUT: 0x1 to 0x9
530 *
531 * @OUTPUT: None
532 *
533 * This IOCTL fixes the Tx data rate of 11AC.
534 *
535 * @E.g: iwpriv wlan0 set11ACRates 0x9
536 *
537 * Supported Feature: STA
538 *
539 * Usage: Internal/External
540 *
541 * </ioctl>
542 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800543#define WE_SET_VHT_RATE 39
544#define WE_DBGLOG_REPORT_ENABLE 40
545#define WE_TXRX_FWSTATS_RESET 41
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530546/*
547 * <ioctl>
548 * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
549 *
550 * @INPUT: Transmission power in dBm
551 *
552 * @OUTPUT: None
553 *
554 * This IOCTL sets the maximum transmit power for the 2.4-GHz band
555 * This setting does not persist over reboots
556 *
557 * @E.g: iwpriv wlan0 setTxMaxPower2G 10
558 *
559 * Supported Feature: STA
560 *
561 * Usage: Internal/External
562 *
563 * </ioctl>
564 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565#define WE_SET_MAX_TX_POWER_2_4 42
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530566/*
567 * <ioctl>
568 * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
569 *
570 * @INPUT: Transmission power in dBm
571 *
572 * @OUTPUT: None
573 *
574 * This IOCTL sets the maximum transmit power for the 5-GHz band
575 * This setting does not persist over reboots
576 *
577 * @E.g: iwpriv wlan0 setTxMaxPower5G 10
578 *
579 * Supported Feature: STA
580 *
581 * Usage: Internal/External
582 *
583 * </ioctl>
584 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800586#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800587/* Private ioctl for packet powe save */
588#define WE_PPS_PAID_MATCH 45
589#define WE_PPS_GID_MATCH 46
590#define WE_PPS_EARLY_TIM_CLEAR 47
591#define WE_PPS_EARLY_DTIM_CLEAR 48
592#define WE_PPS_EOF_PAD_DELIM 49
593#define WE_PPS_MACADDR_MISMATCH 50
594#define WE_PPS_DELIM_CRC_FAIL 51
595#define WE_PPS_GID_NSTS_ZERO 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530596/*
597 * <ioctl>
598 * rssi_chk - Chek the rssi
599 *
600 * @INPUT: One argument as input
601 *
602 * @OUTPUT: rssi
603 * wlan0 rssi_chk:56
604 *
605 * This IOTCL used to chek rssi
606 *
607 * @E.g: iwpriv wlan0 rssi_chk <value>
608 *
609 * Supported Feature: STA
610 *
611 * Usage: Internal/External
612 *
613 * </ioctl>
614 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615#define WE_PPS_RSSI_CHECK 53
616#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530617/*
618 * <ioctl>
619 * htsmps - Sets the htsmps
620 *
621 * @INPUT: Atleast one int argument
622 *
623 * @OUTPUT: None
624 *
625 * This IOTCL used to set htsmps
626 *
627 * @E.g: iwpriv wlan0 htsmps <value>
628 *
629 * Supported Feature: STA
630 *
631 * Usage: Internal/External
632 *
633 * </ioctl>
634 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635#define WE_SET_HTSMPS 55
636/* Private ioctl for QPower */
637#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
638#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
639#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
640#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530641/*
642 * <ioctl>
643 * burst_enable - Enables or disables the burst feature
644 *
645 * @INPUT: 0-Disable, 1-Enable
646 *
647 * @OUTPUT: None
648 *
649 * This IOCTL enables or disables the burst feature.
650 *
651 * @E.g: iwpriv wlan0 burst_enable 0
652 *
653 * Supported Feature: STA
654 *
655 * Usage: Internal/External
656 *
657 * </ioctl>
658 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659#define WE_SET_BURST_ENABLE 60
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530660/*
661 * <ioctl>
662 * burst_dur - Enables or disables the burst feature
663 *
664 * @INPUT: int 1…..int 8191 in microseconds
665 *
666 * @OUTPUT: None
667 *
668 * This IOCTL sets the burst duration.
669 *
670 * @E.g: iwpriv wlan0 burst_dur <value>
671 *
672 * Supported Feature: STA
673 *
674 * Usage: Internal/External
675 *
676 * </ioctl>
677 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678#define WE_SET_BURST_DUR 61
679/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530680/*
681 * <ioctl>
682 * gtxHTMcs - Set the tx HTM value
683 *
684 * @INPUT: Atleast one int orgument
685 *
686 * @OUTPUT: None
687 *
688 * This IOTCL sets htm tx value
689 *
690 * @E.g: iwpriv wlan0 gtxHTMcs <value>
691 *
692 * Supported Feature: STA
693 *
694 * Usage: Internal/External
695 *
696 * </ioctl>
697 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698#define WE_SET_GTX_HT_MCS 62
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530699/*
700 * <ioctl>
701 * gtxVHTMcs - Set gtxVHTMcs value
702 *
703 * @INPUT: Atleast one int argument
704 *
705 * @OUTPUT: None
706 *
707 * This IOTCL used to set gtxVHTMcs value
708 *
709 * @E.g: iwpriv wlan0 gtxVHTMcs <value>
710 *
711 * Supported Feature: STA
712 *
713 * Usage: Internal/External
714 *
715 * </ioctl>
716 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717#define WE_SET_GTX_VHT_MCS 63
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530718/*
719 * <ioctl>
720 * gtxUsrCfg - Host request for GTX mask
721 *
722 * @INPUT: Atleast one int orgument
723 *
724 * @OUTPUT: None
725 *
726 * This IOTCL used send the host request for GTX mask
727 *
728 * @E.g: iwpriv wlan0 gtxUsrCfg <value>
729 *
730 * Supported Feature: STA
731 *
732 * Usage: Internal/External
733 *
734 * </ioctl>
735 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736#define WE_SET_GTX_USRCFG 64
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530737/*
738 * <ioctl>
739 * gtxThre - Set the tx threshold
740 *
741 * @INPUT: Atleast one int argument
742 *
743 * @OUTPUT: None
744 *
745 * This IOTCL used to set tx threshold
746 *
747 * @E.g: iwpriv wlan0 gtxThre <value>
748 *
749 * Supported Feature: STA
750 *
751 * Usage: Internal/External
752 *
753 * </ioctl>
754 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755#define WE_SET_GTX_THRE 65
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530756/*
757 * <ioctl>
758 * gtxMargin - Set the gtxMargin
759 *
760 * @INPUT: 1 to 32
761 *
762 * @OUTPUT: None
763 *
764 * This IOTCL use dto set gtxMargin
765 *
766 * @E.g: iwpriv wlan0 gtxMargini <value>
767 *
768 * Supported Feature: STA
769 *
770 * Usage: Internal/External
771 *
772 * </ioctl>
773 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774#define WE_SET_GTX_MARGIN 66
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530775/*
776 * <ioctl>
777 * gtxStep - Set the gtxStep
778 *
779 * @INPUT: None
780 *
781 * @OUTPUT: None
782 *
783 * This IOTCL used to sets gtxStep
784 *
785 * @E.g: iwpriv wlan0 gtxStep <value>
786 *
787 * Supported Feature: STA
788 *
789 * Usage: Internal/External
790 *
791 * </ioctl>
792 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793#define WE_SET_GTX_STEP 67
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530794/*
795 * <ioctl>
796 * gtxMinTpc - Sets the gtxMinTpc
797 *
798 * @INPUT: Atleast one int argument
799 *
800 * @OUTPUT: None
801 *
802 * This IOTCL sets the tx MinTpc
803 *
804 * @E.g: iwpriv wlan0 gtxMinTpc <value>
805 *
806 * Supported Feature: STA
807 *
808 * Usage: Internal/External
809 *
810 * </ioctl>
811 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812#define WE_SET_GTX_MINTPC 68
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530813/*
814 * <ioctl>
815 * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
816 *
817 * @INPUT: Mask value
818 *
819 * @OUTPUT: None
820 *
821 * This IOTCL used to set gtxBWMask
822 *
823 * @E.g: iwpriv wlan0 gtxBWMask <value>
824 *
825 * Supported Feature: STA
826 *
827 * Usage: Internal/External
828 *
829 * </ioctl>
830 */
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530831
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530832#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530833/*
834 * <ioctl>
835 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
836 *
837 * @INPUT: set_value
838 *
839 * @OUTPUT: None
840 *
841 * This IOCTL is used to set the MCC latency value in milliseconds
842 * during STA-P2P concurrency.
843 *
844 * If 0ms latency is provided, then FW will set to a default.
845 * Otherwise, latency must be at least 30ms.
846 *
847 * @E.g: iwpriv wlan0 setMccLatency 40
848 *
849 *
850 * Supported Feature: Concurrency
851 *
852 * Usage: Internal/External
853 *
854 * </ioctl>
855 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530857
858/*
859 * <ioctl>
860 * setMccQuota- Set the quota for P2P cases
861 *
862 * @INPUT: set_value [0,100]
863 *
864 * @OUTPUT: None
865 *
866 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
867 *
868 * Currently used to set time quota for 2 MCC vdevs/adapters using
869 * (operating channel, quota) for each mode.
870 * The info is provided run time using iwpriv command:
871 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
872 * Note: the quota provided in command is for the same mode in cmd.
873 * HDD checks if MCC mode is active, gets the second mode and its
874 * operating chan.
875 * Quota for the 2nd role is calculated as 100 - quota of first mode.
876 *
877 * @E.g: iwpriv wlan0 setMccQuota 50
878 * iwpriv p2p0 setMccQuota 50
879 *
880 * Supported Feature: Concurrency
881 *
882 * Usage: Internal/External
883 *
884 * </ioctl>
885 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886#define WE_MCC_CONFIG_QUOTA 71
887/* Private IOCTL for debug connection issues */
888#define WE_SET_DEBUG_LOG 72
889#ifdef WE_SET_TX_POWER
890#undef WE_SET_TX_POWER
891#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530892/*
893 * <ioctl>
894 * setTxPower - Set the current transmit power
895 *
896 * @INPUT: Transmission power in dBm
897 *
898 * @OUTPUT: None
899 *
900 * This IOCTL sets the current transmit power.
901 * This setting does not persist over reboots.
902 *
903 * @E.g: iwpriv wlan0 setTxPower 10
904 *
905 * Supported Feature: STA
906 *
907 * Usage: Internal/External
908 *
909 * </ioctl>
910 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911#define WE_SET_TX_POWER 74
912/* Private ioctl for earlyrx power save feature */
913#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
914#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
915#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
916#define WE_SET_EARLY_RX_SLOP_STEP 78
917#define WE_SET_EARLY_RX_INIT_SLOP 79
918#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530919/*
920 * <ioctl>
921 * setMcRate - Set the data rate for multicast data
922 *
923 * @INPUT: 1 to 32
924 *
925 * @OUTPUT: None
926 *
927 * This IOCTL sets the data rate for multicast data. Note that this command
928 * is allowed only in STA, IBSS, or QCMobileAP mode
929 *
930 * @E.g: iwpriv wlan0 setMcRate <value>
931 *
932 * Supported Feature: STA
933 *
934 * Usage: Internal/External
935 *
936 * </ioctl>
937 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938#define WE_SET_MC_RATE 81
939#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
940/* Private ioctl for packet power save */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530941/*
942 * <ioctl>
943 * 5g_ebt - Sets the 5g_ebt
944 *
945 * @INPUT: <value>
946 *
947 * @OUTPUT: None
948 *
949 * This IOTCL used to set 5g_ebt
950 *
951 * @E.g: iwpriv wlan0 5g_ebt <value>
952 *
953 * Supported Feature: STA
954 *
955 * Usage: Internal/External
956 *
957 * </ioctl>
958 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959#define WE_PPS_5G_EBT 83
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530960/*
961 * <ioctl>
962 * cts_cbw - Set CTS channel BW for dynamic BW adjustment
963 *
964 * @INPUT: 20 t0 160
965 *
966 * @OUTPUT: None
967 *
968 * This IOTCL used to set CTS channel BW for dynamic BW adjustment
969 *
970 * @E.g: iwpriv wlan0 cts_cbw <value>
971 *
972 * Supported Feature: STA
973 *
974 * Usage: Internal/External
975 *
976 * </ioctl>
977 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978#define WE_SET_CTS_CBW 84
979#define WE_DUMP_STATS 85
980#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +0530981/* Private sub ioctl for starting/stopping the profiling */
982#define WE_START_FW_PROFILE 87
Abhishek Singh3c507012016-12-01 11:15:42 +0530983/*
984 * <ioctl>
985 * setChanChange - Initiate channel change
986 *
987 * @INPUT: channel number to switch to.
988 *
989 * @OUTPUT: None
990 *
991 * This IOCTL is used to initiate a channel change.
992 * If called on STA/CLI interface it will send the
993 * ECSA action frame to the connected SAP/GO asking to
994 * initiate the ECSA, if supported.
995 * If called on SAP/GO interface it will initiate
996 * ECSA and ask connected peers to move to new channel.
997 *
998 * @E.g: iwpriv wlan0 setChanChange <channel>
999 * iwpriv wlan0 setChanChange 1
1000 *
1001 * Supported Feature: ECSA
1002 *
1003 * Usage: Internal/External
1004 *
1005 * </ioctl>
1006 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +05301007#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05301008#define WE_SET_CONC_SYSTEM_PREF 89
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009
1010/* Private ioctls and their sub-ioctls */
1011#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
1012#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013#define WE_SET_SAP_CHANNELS 3
1014#define WE_GET_WLAN_DBG 4
1015#define WE_GET_MAX_ASSOC 6
1016/* 7 is unused */
1017#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +05301018
1019/*
1020 * <ioctl>
1021 * getconcurrency - Get concurrency mode
1022 *
1023 * @INPUT: None
1024 *
1025 * @OUTPUT: It shows concurrency value
1026 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
1027 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
1028 * 8:OCB 9:EPPING 10:QVIT 11:NDI
1029 *
1030 * This IOCTL is used to retrieve concurrency mode.
1031 *
1032 * @E.g: iwpriv wlan0 getconcurrency
1033 * wlan0 getconcurrency:5
1034 * Above value shows STA+P2P_Client
1035 *
1036 * Supported Feature: Concurrency
1037 *
1038 * Usage: Internal/External
1039 *
1040 * </ioctl>
1041 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042#define WE_GET_CONCURRENCY_MODE 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301043/*
1044 * <ioctl>
1045 * get_nss - Get the number of spatial STBC streams (NSS)
1046 *
1047 * @INPUT: None
1048 *
1049 * @OUTPUT: NSS
1050 * wlan0 get_nss:2
1051 *
1052 * This IOTCL used to get the number of spatial STBC streams
1053 *
1054 * @E.g: iwpriv wlan0 get_nss
1055 *
1056 * Supported Feature: STA
1057 *
1058 * Usage: Internal/External
1059 *
1060 * </ioctl>
1061 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062#define WE_GET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301063/*
1064 * <ioctl>
1065 * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1066 *
1067 * @INPUT: None
1068 *
1069 * @OUTPUT: ldpc
1070 * wlan0 get_ldpc:1
1071 *
1072 * This IOTCL used to gets the low density parity check (LDPC)
1073 *
1074 * @E.g: iwpriv wlan0 get_ldpc
1075 *
1076 * Supported Feature: STA
1077 *
1078 * Usage: Internal/External
1079 *
1080 * </ioctl>
1081 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082#define WE_GET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301083/*
1084 * <ioctl>
1085 * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1086 *
1087 * @INPUT: None
1088 *
1089 * @OUTPUT: TXSTBC
1090 * wlan0 get_tx_stbc:1
1091 *
1092 * This IOTCL get the value of the current Tx space time block code (STBC)
1093 *
1094 * @E.g: iwpriv wlan0 get_tx_stbc
1095 *
1096 * Supported Feature: STA
1097 *
1098 * Usage: Internal/External
1099 *
1100 * </ioctl>
1101 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102#define WE_GET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301103/*
1104 * <ioctl>
1105 * get_rx_stbc - Gets the value of the current Rx STBC
1106 *
1107 * @INPUT: None
1108 *
1109 * @OUTPUT: Rx STBC
1110 * wlan0 get_rx_stbc:1
1111 *
1112 * This IOTCL used to get the value of the current Rx STBC
1113 *
1114 * @E.g: iwpriv wlan0 get_rx_stbc
1115 *
1116 * Supported Feature: STA
1117 *
1118 * Usage: Internal/External
1119 *
1120 * </ioctl>
1121 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122#define WE_GET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301123/*
1124 * <ioctl>
1125 * get_shortgi - Get the value of the current short GI setting
1126 *
1127 * @INPUT: None
1128 *
1129 * @OUTPUT: Enable/disable of shortgi
1130 * wlan0 get_shortgi:1
1131 *
1132 * This IOCTL gets the value of the current short GI setting
1133 *
1134 * @E.g: iwpriv wlan0 get_shortgi
1135 *
1136 * Supported Feature: STA
1137 *
1138 * Usage: Internal/External
1139 *
1140 * </ioctl>
1141 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142#define WE_GET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301143/*
1144 * <ioctl>
1145 * get_rtscts - Get the value of the current RTS/CTS setting.
1146 *
1147 * @INPUT: None
1148 *
1149 * @OUTPUT: Enable/disable of RTS/CTS
1150 * wlan0 get_rtscts:33
1151 *
1152 * This IOTCL get the value of the current RTS/CTS setting.
1153 *
1154 * @E.g: iwpriv wlan0 get_rtscts
1155 *
1156 * Supported Feature: STA
1157 *
1158 * Usage: Internal/External
1159 *
1160 * </ioctl>
1161 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162#define WE_GET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301163/*
1164 * <ioctl>
1165 * get_chwidth - Get the current channel width setting
1166 *
1167 * @INPUT: None
1168 *
1169 * @OUTPUT: channel width
1170 * wlan0 get_chwidth:0
1171 *
1172 * This IOTCL get the current channel width setting.
1173 *
1174 * @E.g: iwpriv wlan0 get_chwidth
1175 *
1176 * Supported Feature: STA
1177 *
1178 * Usage: Internal/External
1179 *
1180 * </ioctl>
1181 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182#define WE_GET_CHWIDTH 17
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301183/*
1184 * <ioctl>
1185 * get_anienable - Get the anienable
1186 *
1187 * @INPUT: None
1188 *
1189 * @OUTPUT:
1190 * wlan0 get_anienable:0
1191 *
1192 * This IOTCL get the anienable
1193 *
1194 * @E.g: iwpriv wlan0 get_anienable
1195 *
1196 * Supported Feature: STA
1197 *
1198 * Usage: Internal/External
1199 *
1200 * </ioctl>
1201 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001202#define WE_GET_ANI_EN_DIS 18
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301203/*
1204 * <ioctl>
1205 * get_aniplen - Get the aniplen
1206 *
1207 * @INPUT: None
1208 *
1209 * @OUTPUT:
1210 * wlan0 get_aniplen:0
1211 *
1212 * This IOTCL get the aniplen
1213 *
1214 * @E.g: iwpriv wlan0 get_aniplen
1215 *
1216 * Supported Feature: STA
1217 *
1218 * Usage: Internal/External
1219 *
1220 * </ioctl>
1221 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222#define WE_GET_ANI_POLL_PERIOD 19
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301223/*
1224 * <ioctl>
1225 * get_anilislen- Get the anilislen
1226 *
1227 * @INPUT: None
1228 *
1229 * @OUTPUT:
1230 * wlan0 get_anilislen:0
1231 *
1232 * This IOTCL used to get anilislen
1233 *
1234 * @E.g: iwpriv wlan0 get_anilislen
1235 *
1236 * Supported Feature: STA
1237 *
1238 * Usage: Internal/External
1239 *
1240 * </ioctl>
1241 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242#define WE_GET_ANI_LISTEN_PERIOD 20
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301243/*
1244 * <ioctl>
1245 * get_aniofdmlvl - Get the OFDM level
1246 *
1247 * @INPUT: None
1248 *
1249 * @OUTPUT: OFDM
1250 * wlan0 get_aniofdmlvl:0
1251 *
1252 * This IOTCL used to get ofdm level
1253 *
1254 * @E.g: iwpriv wlan0 get_aniofdmlvl
1255 *
1256 * Supported Feature: STA
1257 *
1258 * Usage: Internal/External
1259 *
1260 * </ioctl>
1261 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262#define WE_GET_ANI_OFDM_LEVEL 21
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301263/*
1264 * <ioctl>
1265 * get_aniccklvl - Get the cck level
1266 *
1267 * @INPUT: None
1268 *
1269 * @OUTPUT:
1270 * wlan0 get_aniccklvl:0
1271 *
1272 * This IOTCL used to get cck level
1273 *
1274 * @E.g: iwpriv wlan0 get_aniccklvl
1275 *
1276 * Supported Feature: STA
1277 *
1278 * Usage: Internal/External
1279 *
1280 * </ioctl>
1281 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282#define WE_GET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301283/*
1284 * <ioctl>
1285 * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1286 *
1287 * @INPUT: None
1288 *
1289 * @OUTPUT: Enable/disable dynamic channel bandwidth
1290 * wlan0 get_cwmenable:0
1291 *
1292 * This IOTCL get the value of the dynamic channel bandwidth setting
1293 *
1294 * @E.g: iwpriv wlan0 get_cwmenable
1295 *
1296 * Supported Feature: STA
1297 *
1298 * Usage: Internal/External
1299 *
1300 * </ioctl>
1301 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302#define WE_GET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301303/*
1304 * <ioctl>
1305 * get_txchainmask - Get the txchainmask that was set
1306 *
1307 * @INPUT: None
1308 *
1309 * @OUTPUT: txchainmask
1310 * wlan0 get_txchainmask:1
1311 *
1312 * This IOCTL gets the txchainmask that was set
1313 * This command is useful if it was previously set
1314 *
1315 * @E.g: iwpriv wlan0 get_txchainmask
1316 *
1317 * Supported Feature: STA
1318 *
1319 * Usage: Internal/External
1320 *
1321 * </ioctl>
1322 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323#define WE_GET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301324/*
1325 * <ioctl>
1326 * get_rxchainmask - Get the rxchainmask that was set
1327 *
1328 * @INPUT: None
1329 *
1330 * @OUTPUT: rxchainmask
1331 * wlan0 get_rxchainmask:1
1332 *
1333 * This IOCTL gets the rxchainmask that was set
1334 * This command is useful only if it was previously set.
1335 *
1336 * @E.g: iwpriv wlan0 get_rxchainmask
1337 *
1338 * Supported Feature: STA
1339 *
1340 * Usage: Internal/External
1341 *
1342 * </ioctl>
1343 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344#define WE_GET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301345/*
1346 * <ioctl>
1347 * get_11nrate - Get the fixed Tx data rate
1348 *
1349 * @INPUT: None
1350 *
1351 * @OUTPUT: Using this command does not return the same value as set
1352 * wlan0 get_11nrate:0
1353 *
1354 * This IOCTL gets the fixed Tx data rate
1355 * This command is useful only if setting the fixed Tx rate.
1356 *
1357 * @E.g: iwpriv wlan0 get_11nrate
1358 *
1359 * Supported Feature: STA
1360 *
1361 * Usage: Internal/External
1362 *
1363 * </ioctl>
1364 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365#define WE_GET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301366/*
1367 * <ioctl>
1368 * get_ampdu - Get the maximum subframe of ampdu
1369 *
1370 * @INPUT: None
1371 *
1372 * @OUTPUT: Maximum subframe of ampdu
1373 * wlan0 get_ampdu:1
1374 *
1375 * This IOCTL gets the maximum subframe of ampdu
1376 * This command is useful only if setting ampdu.
1377 *
1378 * @E.g: iwpriv wlan0 get_ampdu
1379 *
1380 * Supported Feature: STA
1381 *
1382 * Usage: Internal/External
1383 *
1384 * </ioctl>
1385 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386#define WE_GET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301387/*
1388 * <ioctl>
1389 * get_amsdu - Get the maximum subframe of amsdu
1390 *
1391 * @INPUT: None
1392 *
1393 * @OUTPUT: Maximum subframe of amsdu
1394 * wlan0 get_amsdu:1
1395 *
1396 * This IOCTL gets the maximum subframe of amsdu.
1397 * This command is useful only if setting amsdu
1398 *
1399 * @E.g: iwpriv wlan0 get_amsdu
1400 *
1401 * Supported Feature: STA
1402 *
1403 * Usage: Internal/External
1404 *
1405 * </ioctl>
1406 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407#define WE_GET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301408/*
1409 * <ioctl>
1410 * get_txpow2g - Get the current 2 GHz Tx power setting
1411 *
1412 * @INPUT: None
1413 *
1414 * @OUTPUT: Tx Power in dbm
1415 * wlan0 get_txpow2g:0
1416 *
1417 * This IOCTL gets the current 2 GHz Tx power setting
1418 * This command is useful if setting Tx power
1419 *
1420 * @E.g: iwpriv wlan0 get_txpow2g
1421 *
1422 * Supported Feature: STA
1423 *
1424 * Usage: Internal/External
1425 *
1426 * </ioctl>
1427 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428#define WE_GET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301429/*
1430 * <ioctl>
1431 * get_txpow5g - Get the current 5 GHz Tx power setting
1432 *
1433 * @INPUT: None
1434 *
1435 * @OUTPUT: Tx Power in dbm
1436 * wlan0 get_txpow5g:0
1437 *
1438 * This IOCTL gets the current 5 GHz Tx power setting
1439 * This command is useful if setting Tx power
1440 *
1441 * @E.g: iwpriv wlan0 get_txpow5g
1442 *
1443 * Supported Feature: STA
1444 *
1445 * Usage: Internal/External
1446 *
1447 * </ioctl>
1448 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -08001450/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001451#define WE_GET_PPS_PAID_MATCH 32
1452#define WE_GET_PPS_GID_MATCH 33
1453#define WE_GET_PPS_EARLY_TIM_CLEAR 34
1454#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
1455#define WE_GET_PPS_EOF_PAD_DELIM 36
1456#define WE_GET_PPS_MACADDR_MISMATCH 37
1457#define WE_GET_PPS_DELIM_CRC_FAIL 38
1458#define WE_GET_PPS_GID_NSTS_ZERO 39
1459#define WE_GET_PPS_RSSI_CHECK 40
1460/* Private ioctl for QPower */
1461#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
1462#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
1463#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
1464#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301465/*
1466 * <ioctl>
1467 * get_burst_en - Enables or disables the burst feature
1468 *
1469 * @INPUT: None
1470 *
1471 * @OUTPUT: Enable/disable of burst feature
1472 * wlan0 get_burst_en:1
1473 *
1474 * This IOCTL enables or disables the burst feature
1475 *
1476 * @E.g: iwpriv wlan0 get_burst_en
1477 *
1478 * Supported Feature:STA
1479 *
1480 * Usage: Internal/External
1481 *
1482 * </ioctl>
1483 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001484#define WE_GET_BURST_ENABLE 45
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301485/*
1486 * <ioctl>
1487 * get_burst_dur - Get the burst duration
1488 *
1489 * @INPUT: None
1490 *
1491 * @OUTPUT: Duration in microseconds
1492 * wlan0 get_burst_dur:8160
1493 *
1494 * This IOCTL gets the burst duration
1495 * This command is useful if setting burst enable
1496 *
1497 * @E.g: iwpriv wlan0 get_burst_dur
1498 *
1499 * Supported Feature: STA
1500 *
1501 * Usage: Internal/External
1502 *
1503 * </ioctl>
1504 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505#define WE_GET_BURST_DUR 46
1506/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301507/*
1508 * <ioctl>
1509 * get_gtxHTMcs - Get the tx HTM
1510 *
1511 * @INPUT: None
1512 *
1513 * @OUTPUT: HTM
1514 * wlan0 get_gtxHTMcs:32896
1515 *
1516 * This IOTCL used to get HTM
1517 *
1518 * @E.g: iwpriv wlan0 get_gtxHTMcs
1519 *
1520 * Supported Feature: STA
1521 *
1522 * Usage: Internal/External
1523 *
1524 * </ioctl>
1525 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526#define WE_GET_GTX_HT_MCS 47
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301527/*
1528 * <ioctl>
1529 * get_gtxVHTMcs - Get the VHTM
1530 *
1531 * @INPUT: None
1532 *
1533 * @OUTPUT: VHTM
1534 * wlan0 get_gtxVHTMcs:524800
1535 *
1536 * This IOTCL used to get the VHTM
1537 *
1538 * @E.g: iwpriv wlan0 get_gtxVHTMcs
1539 *
1540 * Supported Feature: STA
1541 *
1542 * Usage: Internal/External
1543 *
1544 * </ioctl>
1545 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546#define WE_GET_GTX_VHT_MCS 48
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301547/*
1548 * <ioctl>
1549 * get_gtxUsrCfg - Get the tx cfg
1550 *
1551 * @INPUT: None
1552 *
1553 * @OUTPUT: TXCFG
1554 * wlan0 get_gtxUsrCfg:32
1555 *
1556 * This IOTCL used to get the tx cfg
1557 *
1558 * @E.g: iwpriv wlan0 get_gtxUsrCfg
1559 *
1560 * Supported Feature: STA
1561 *
1562 * Usage: Internal/External
1563 *
1564 * </ioctl>
1565 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566#define WE_GET_GTX_USRCFG 49
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301567/*
1568 * <ioctl>
1569 * get_gtxThre - Get the tx threshold
1570 *
1571 * @INPUT: None
1572 *
1573 * @OUTPUT: Threshold
1574 * wlan0 get_gtxThre:3
1575 *
1576 * This IOCTL is used to get tx threshold
1577 *
1578 * @E.g: iwpriv wlan0 get_gtxThre
1579 *
1580 * Supported Feature: STA
1581 *
1582 * Usage: Internal/External
1583 *
1584 * </ioctl>
1585 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586#define WE_GET_GTX_THRE 50
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301587/*
1588 * <ioctl>
1589 * get_gtxMargin - Get the tx margin
1590 *
1591 * @INPUT: None
1592 *
1593 * @OUTPUT: GTXMARGIN
1594 * wlan0 get_gtxMargin:2
1595 *
1596 * This IOCTL is used to set tx margin
1597 *
1598 * @E.g: iwpriv wlan0 get_gtxMargin
1599 *
1600 * Supported Feature: STA
1601 *
1602 * Usage: Internal/External
1603 *
1604 * </ioctl>
1605 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606#define WE_GET_GTX_MARGIN 51
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301607/*
1608 * <ioctl>
1609 * get_gtxStep - Get the tx step
1610 *
1611 * @INPUT: None
1612 *
1613 * @OUTPUT: GTXSTEP
1614 * wlan0 get_gtxStep:0
1615 *
1616 * This IOCTL is used to get the gtx step
1617 *
1618 * @E.g: iwpriv wlan0 get_gtxStep
1619 *
1620 * Supported Feature: STA
1621 *
1622 * Usage: Internal/External
1623 *
1624 * </ioctl>
1625 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626#define WE_GET_GTX_STEP 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301627/*
1628 * <ioctl>
1629 * get_gtxMinTpc - Get the tx miminum tpc
1630 *
1631 * @INPUT: None
1632 *
1633 * @OUTPUT: TPC
1634 * wlan0 get_gtxMinTpc:0
1635 *
1636 * This IOCTL is used to get tx miminum tpc
1637 *
1638 * @E.g: iwpriv wlan0 get_gtxMinTpc
1639 *
1640 * Supported Feature: STA
1641 *
1642 * Usage: Internal/External
1643 *
1644 * </ioctl>
1645 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646#define WE_GET_GTX_MINTPC 53
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301647/*
1648 * <ioctl>
1649 * get_gtxBWMask - Get the tx BW MASK
1650 *
1651 * @INPUT: None
1652 *
1653 * @OUTPUT: MASK
1654 * wlan0 get_gtxBWMask:15
1655 *
1656 * This IOCTL is used get gtx bw mask
1657 *
1658 * @E.g: iwpriv wlan0 get_gtxBWMask
1659 *
1660 * Supported Feature: STA
1661 *
1662 * Usage: Internal/External
1663 *
1664 * </ioctl>
1665 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666#define WE_GET_GTX_BWMASK 54
1667#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001668#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07001669#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670
1671/* Private ioctls and their sub-ioctls */
1672#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
1673
1674/* Private ioctls and their sub-ioctls */
1675#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
1676#define WE_WOWL_ADD_PTRN 1
1677#define WE_WOWL_DEL_PTRN 2
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678#define WE_NEIGHBOR_REPORT_REQUEST 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301679/*
1680 * <ioctl>
1681 * set_ap_wps_ie - Set the P2P IE of the probe response
1682 *
1683 * @INPUT: string
1684 *
1685 * @OUTPUT: None
1686 *
1687 * This IOCTL sets the P2P IE of the probe response
1688 *
1689 * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1690 *
1691 * Supported Feature: STA
1692 *
1693 * Usage: Internal/External
1694 *
1695 * </ioctl>
1696 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697#define WE_SET_AP_WPS_IE 4 /* This is called in station mode to set probe rsp ie. */
1698#define WE_SET_CONFIG 5
1699
1700/* Private ioctls and their sub-ioctls */
1701#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
1702#define WE_SET_WLAN_DBG 1
1703#define WE_SET_DP_TRACE 2
1704#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05301705#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706
1707/* Private ioctls and their sub-ioctls */
1708#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
1709#define WE_WLAN_VERSION 1
1710#define WE_GET_STATS 2
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301711/*
1712 * <ioctl>
1713 * getConfig - gets the values of all configurations listed in WCNSS
1714 *
1715 * @INPUT: None
1716 *
1717 * @OUTPUT: Current configuration to the sys log
1718 * wlan0 getConfig: WLAN configuration written to system log
1719 *
1720 * This IOCTL gets the values of all configurations listed in WCNSS
1721 *
1722 * @E.g: iwpriv wlan0 getConfig
1723 *
1724 * Supported Feature: STA
1725 *
1726 * Usage: Internal/External
1727 *
1728 * </ioctl>
1729 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730#define WE_GET_CFG 3
1731#define WE_GET_WMM_STATUS 4
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301732/*
1733 * <ioctl>
1734 * getChannelList - Get the available channel list while in QCMobileAP
1735 *
1736 * @INPUT: None
1737 *
1738 * @OUTPUT: Channel list
1739 * wlan0 getChannelList:36 US 1..165
1740 *
1741 * This IOCTL gets the available channel list while in QCMobileAP
1742 *
1743 * @E.g: iwpriv wlan0 getChannelList
1744 *
1745 * Supported Feature: STA
1746 *
1747 * Usage: Internal/External
1748 *
1749 * </ioctl>
1750 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751#define WE_GET_CHANNEL_LIST 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301752/*
1753 * <ioctl>
1754 * getRSSI - Get the Received Signal Strength Indicator
1755 *
1756 * @INPUT: None
1757 *
1758 * @OUTPUT: RSSI
1759 * wlan0 getRSSI:rsssi=-32
1760 *
1761 * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1762 *
1763 * @E.g: iwpriv wlan0 getRSSI
1764 *
1765 * Supported Feature: STA
1766 *
1767 * Usage: Internal/External
1768 *
1769 * </ioctl>
1770 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -08001772
1773/*
1774 * <ioctl>
1775 * getSuspendStats - Get suspend/resume stats
1776 *
1777 * @INPUT: None
1778 *
1779 * @OUTPUT: character string containing formatted suspend/resume stats
1780 *
1781 * This ioctl is used to get suspend/resume stats formatted for display.
1782 * Currently it includes suspend/resume counts, wow wake up reasons, and
1783 * suspend fail reasons.
1784 *
1785 * @E.g: iwpriv wlan0 getSuspendStats
1786 * iwpriv wlan0 getSuspendStats
1787 *
1788 * Supported Feature: suspend/resume
1789 *
1790 * Usage: Internal
1791 *
1792 * </ioctl>
1793 */
1794#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05301796/*
1797 * <ioctl>
1798 * getTdlsPeers - Get all TDLS peers.
1799 *
1800 * @INPUT: None
1801 *
1802 * @OUTPUT: Returns the MAC address of all the TDLS peers
1803 * wlan0 getTdlsPeers:
1804 * MAC Id cap up RSSI
1805 * ---------------------------------
1806 * 00:0a:f5:0e:bd:18 2 Y Y -44
1807 * 00:0a:f5:bf:0e:12 0 N N 0
1808 *
1809 * This IOCTL is used to get all TDLS peers.
1810 *
1811 * @E.g: iwpriv wlan0 getTdlsPeers
1812 *
1813 * Supported Feature: TDLS
1814 *
1815 * Usage: Internal/External
1816 *
1817 * </ioctl>
1818 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819#define WE_GET_TDLS_PEERS 8
1820#endif
1821#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +05301822/*
1823 * <ioctl>
1824 * getPMFInfo - get the PMF info of the connected session
1825 *
1826 * @INPUT: None
1827 *
1828 * @OUTPUT:
1829 * wlan0 getPMFInfo:
1830 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
1831 * Number of Unprotected Disassocs 0
1832 * Number of Unprotected Deauths 0
1833 *
1834 * This IOCTL is used to get the PMF stats/status of the current
1835 * connection.
1836 *
1837 * @e.g:iwpriv wlan0 getPMFInfo
1838 *
1839 * Supported Feature: PMF
1840 *
1841 * Usage: Internal/External
1842 *
1843 * </ioctl>
1844 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845#define WE_GET_11W_INFO 9
1846#endif
1847#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +05301848/*
1849 * <ioctl>
1850 * getIbssSTAs - get ibss sta info
1851 *
1852 * @INPUT: None
1853 *
1854 * @OUTPUT: Give the MAC of the IBSS STA
1855 * wlan0 getIbssSTAs:
1856 * 1 .8c:fd:f0:01:9c:bf
1857 *
1858 * This IOCTL is used to get ibss sta info
1859 *
1860 * @E.g: iwpriv wlan0 getIbssSTAs
1861 *
1862 * Supported Feature: IBSS
1863 *
1864 * Usage: Internal/External
1865 *
1866 * </ioctl>
1867 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001868#define WE_GET_IBSS_STA_INFO 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301869/*
1870 * <ioctl>
1871 * getphymode - Get the current phymode.
1872 *
1873 * @INPUT: None
1874 *
1875 * @OUTPUT: In phymode
1876 * wlan0 getphymode:AUTO MODE
1877 *
1878 * This IOCTL used to gets the current phymode.
1879 *
1880 * @E.g: iwpriv wlan0 getphymode
1881 *
1882 * Supported Feature: STA
1883 *
1884 * Usage: Internal/External
1885 *
1886 * </ioctl>
1887 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888#define WE_GET_PHYMODE 12
1889#ifdef FEATURE_OEM_DATA_SUPPORT
1890#define WE_GET_OEM_DATA_CAP 13
1891#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301892/*
1893 * <ioctl>
1894 * getSNR - Enable SNR Monitoring
1895 *
1896 * @INPUT: None
1897 *
1898 * @OUTPUT: Signal strength/ratio
1899 * wlan0 getSNR:1
1900 *
1901 * This IOCTL is used to get ibss sta info
1902 *
1903 * @E.g: iwpriv wlan0 getSNR
1904 *
1905 * Supported Feature: STA
1906 *
1907 * Usage: Internal/External
1908 *
1909 * </ioctl>
1910 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +05301912#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913
1914/* Private ioctls and their sub-ioctls */
1915#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
1916#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +05301917/*
1918 * <ioctl>
1919 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
1920 *
1921 * @INPUT: None
1922 *
1923 * @OUTPUT: print ibss peer in info logs
1924 * pPeerInfo->numIBSSPeers = 1
1925 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
1926 *
1927 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
1928 * in info logs
1929 *
1930 * @E.g: iwpriv wlan0 ibssPeerInfoAll
1931 *
1932 * Supported Feature: IBSS
1933 *
1934 * Usage: Internal/External
1935 *
1936 * </ioctl>
1937 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001938#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -08001939/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08001941#define WE_GET_FW_PROFILE_DATA 18
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +05301942/*
1943 * <ioctl>
1944 * stop_obss_scan - Stop obss scan
1945 *
1946 * @INPUT: None
1947 *
1948 * @OUTPUT: None
1949 *
1950 * This IOCTL is used to stop obss scan
1951 *
1952 * @E.g: iwpriv wlan0 stop_obss_scan
1953 *
1954 * Supported Feature: Scan
1955 *
1956 * Usage: Internal/External
1957 *
1958 * </ioctl>
1959 */
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08001960#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961
1962/* Private ioctls and their sub-ioctls */
1963#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
1964
1965#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +05301966/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967
Manjeet Singhf82ed072016-07-08 11:40:00 +05301968#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969
1970#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05301971/*
1972 * <ioctl>
1973 * setTdlsConfig - Set TDLS configuration parameters.
1974 *
1975 * @INPUT: 11 TDLS configuration parameters
1976 * @args[0]: tdls: [0..2]
1977 * @args[1]: tx_period_t: [1000..4294967295UL]
1978 * @args[2]: tx_packet_n: [0..4294967295UL]
1979 * @args[3]: [discovery_period is not used anymore]
1980 * @args[4]: discovery_tries_n: [1..100]
1981 * @args[5]: [idle_timeout is not used anymore]
1982 * @args[6]: idle_packet_n: [0..40000]
1983 * @args[7]: [rssi_hysteresis is not used anymore]
1984 * @args[8]: rssi_trigger_threshold: [-120..0]
1985 * @args[9]: rssi_teardown_threshold: [-120..0]
1986 * @args[10]: rssi_delta: [-30..0]
1987 *
1988 * @OUTPUT: None
1989 *
1990 * This IOCTL is used to set the TDLS configuration parameters.
1991 *
1992 * @E.g: iwpriv wlan0 setTdlsConfig tdls tx_period_t tx_packet_n
1993 * discovery_period discovery_tries_n idle_timeout
1994 * idle_packet_n rssi_hysteresis rssi_trigger_threshold
1995 * rssi_teardown_threshold rssi_delta
1996 * iwpriv wlan0 setTdlsConfig 1 1500 40 1 5 1 5 0 -70 -70 -10
1997 *
1998 * Supported Feature: TDLS
1999 *
2000 * Usage: Internal/External
2001 *
2002 * </ioctl>
2003 */
2004
2005
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006#define WE_TDLS_CONFIG_PARAMS 5
2007#endif
Abhishek Singh49b654e2016-12-01 16:11:17 +05302008/*
2009 * <ioctl>
2010 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
2011 *
2012 * @INPUT: staid
2013 *
2014 * @OUTPUT: print ibss peer corresponding to staid in info logs
2015 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2016 *
2017 * This IOCTL is used to print the specific ibss peers's MAC,
2018 * rate and RSSI in info logs
2019 *
2020 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
2021 * iwpriv wlan0 ibssPeerInfo 0
2022 *
2023 * Supported Feature: IBSS
2024 *
2025 * Usage: Internal/External
2026 *
2027 * </ioctl>
2028 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002029#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030#define WE_UNIT_TEST_CMD 7
2031
2032#define WE_MTRACE_DUMP_CMD 8
2033#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
2034
2035
2036#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2037#define WE_LED_FLASHING_PARAM 10
2038#endif
2039
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302040/*
2041 * <ioctl>
2042 * pm_clist - Increments the index value of the concurrent connection list
2043 * and update with the input parameters provided.
2044 *
2045 * @INPUT: Following 8 arguments:
2046 * @vdev_id: vdev id
2047 * @tx_streams: TX streams
2048 * @rx_streams: RX streams
2049 * @chain_mask: Chain mask
2050 * @type: vdev_type
2051 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2052 * @sub_type: vdev_subtype
2053 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2054 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2055 * @channel: Channel
2056 * @mac: Mac id
2057 *
2058 * @OUTPUT: None
2059 *
2060 * This IOCTL is used to increments the index value of the concurrent connection
2061 * list and update with the input parameters provided.
2062 *
2063 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
2064 * sub_type channel mac
2065 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
2066 *
2067 * Supported Feature: DBS
2068 *
2069 * Usage: Internal/External
2070 *
2071 * </ioctl>
2072 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302074
2075/*
2076 * <ioctl>
2077 * pm_dlist - Delete the index from the concurrent connection list that is
2078 * present in the given vdev_id.
2079 *
2080 * @INPUT: delete_all, vdev_id
2081 * @delete_all: delete all indices
2082 * @vdev_id: vdev id
2083 *
2084 * @OUTPUT: None
2085 *
2086 * This IOCTL is used to delete the index from the concurrent connection list
2087 * that is present in the given vdev_id.
2088 *
2089 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
2090 * iwpriv wlan0 pm_dlist 0 1
2091 *
2092 * Supported Feature: DBS
2093 *
2094 * Usage: Internal/External
2095 *
2096 * </ioctl>
2097 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302099
2100/*
2101 * <ioctl>
2102 * pm_dbs - Set dbs capability and system preference
2103 *
2104 * @INPUT: dbs, system_pref
2105 * @dbs: Value of DBS capability to be set
2106 * @system_pref: System preference
2107 * 0:CDS_THROUGHPUT 1: CDS_POWERSAVE 2: CDS_LATENCY
2108 *
2109 * @OUTPUT: None
2110 *
2111 * This IOCTL is used to set dbs capability and system preference.
2112 *
2113 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
2114 * iwpriv wlan0 pm_dbs 1 0
2115 *
2116 * Supported Feature: DBS
2117 *
2118 * Usage: Internal/External
2119 *
2120 * </ioctl>
2121 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302123
2124/*
2125 * <ioctl>
2126 * pm_pcl - Set pcl for concurrency mode.
2127 *
2128 * @INPUT: cds_con_mode
2129 * @cds_con_mode: concurrency mode for PCL table
2130 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2131 *
2132 * @OUTPUT: None
2133 *
2134 * This IOCTL is used to set pcl for concurrency mode.
2135 *
2136 * @E.g: iwpriv wlan0 pm_pcl cds_con_mode
2137 * iwpriv wlan0 pm_pcl 0
2138 *
2139 * Supported Feature: DBS
2140 *
2141 * Usage: Internal/External
2142 *
2143 * </ioctl>
2144 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302146
2147/*
2148 * <ioctl>
2149 * pm_cinfo - Shows the concurrent connection list.
2150 *
2151 * @INPUT: None
2152 *
2153 * @OUTPUT: None
2154 *
2155 * This IOCTL is used to show the concurrent connection list.
2156 *
2157 * @E.g: iwpriv wlan0 pm_cinfo
2158 *
2159 * Supported Feature: DBS
2160 *
2161 * Usage: Internal/External
2162 *
2163 * </ioctl>
2164 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302166
2167/*
2168 * <ioctl>
2169 * pm_ulist - Updates the index value of the concurrent connection list
2170 * with the input parameters provided.
2171 *
2172 * @INPUT: Following 8 arguments:
2173 * @vdev_id: vdev id
2174 * @tx_streams: TX streams
2175 * @rx_streams: RX streams
2176 * @chain_mask: Chain mask
2177 * @type: vdev_type
2178 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2179 * @sub_type: vdev_subtype
2180 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2181 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2182 * @channel: Channel
2183 * @mac: Mac id
2184 *
2185 * @OUTPUT: None
2186 *
2187 * This IOCTL is used to updates the index value of the concurrent
2188 * connection list with the input parameters provided.
2189 *
2190 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
2191 * sub_type channel mac
2192 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
2193 *
2194 * Supported Feature: DBS
2195 *
2196 * Usage: Internal/External
2197 *
2198 * </ioctl>
2199 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302201
2202/*
2203 * <ioctl>
2204 * pm_query_action - Initiate actions needed on current connections as
2205 * per the channel provided.
2206 *
2207 * @INPUT: channel
2208 * @channel: Channel on which new connection will be.
2209 *
2210 * @OUTPUT: None
2211 *
2212 * This IOCTL is used to initiate actions needed on current connections
2213 * as per the channel provided.
2214 *
2215 * @E.g: iwpriv wlan0 pm_query_action channel
2216 * iwpriv wlan0 pm_query_action 6
2217 *
2218 * Supported Feature: DBS
2219 *
2220 * Usage: Internal/External
2221 *
2222 * </ioctl>
2223 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002224#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302225
2226/*
2227 * <ioctl>
2228 * pm_query_allow - Checks for allowed concurrency combination
2229 *
2230 * @INPUT: mode, channel, bandwidth
2231 * @mode: new connection mode
2232 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2233 * @channel: channel on which new connection is coming up
2234 * @bandwidth: Bandwidth requested by the connection
2235 * 0:None 1:5MHz 2:10MHz 3:20MHz
2236 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
2237 *
2238 * @OUTPUT: None
2239 *
2240 * This IOCTL is used to checks for allowed concurrency combination.
2241 *
2242 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
2243 * iwpriv wlan0 pm_query_allow 0 6 4
2244 *
2245 * Supported Feature: DBS
2246 *
2247 * Usage: Internal/External
2248 *
2249 * </ioctl>
2250 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302252
2253/*
2254 * <ioctl>
2255 * pm_run_scenario - Create scenario with number of connections provided.
2256 *
2257 * @INPUT: num_of_conn
2258 * @num_of_conn: the number of connections (values: 1~3)
2259 *
2260 * @OUTPUT: None
2261 *
2262 * This IOCTL is used to create scenario with the number of connections
2263 * provided.
2264 *
2265 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
2266 * iwpriv wlan0 pm_run_scenario 1
2267 *
2268 * Supported Feature: DBS
2269 *
2270 * Usage: Internal/External
2271 *
2272 * </ioctl>
2273 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302275
2276/*
2277 * <ioctl>
2278 * pm_set_hw_mode - Set hardware for single/dual mac.
2279 *
2280 * @INPUT: hw_mode
2281 * 0:single mac 1:dual mac
2282 *
2283 * @OUTPUT: None
2284 *
2285 * This IOCTL is used to set hardware for single/dual mac.
2286 *
2287 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
2288 * iwpriv wlan0 pm_set_hw_mode 1
2289 *
2290 * Supported Feature: DBS
2291 *
2292 * Usage: Internal/External
2293 *
2294 * </ioctl>
2295 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296#define WE_POLICY_SET_HW_MODE_CMD 20
2297
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302298/*
2299 * <ioctl>
2300 * set_scan_cfg - Set dual MAC scan config parameters.
2301 *
2302 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2303 * @dbs: Value of DBS bit
2304 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2305 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2306 *
2307 * @OUTPUT: None
2308 *
2309 * This IOCTL is used to set the dual MAC scan config.
2310 *
2311 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2312 * single_mac_scan_with_dbs
2313 * iwpriv wlan0 set_scan_cfg 1 0 1
2314 *
2315 * Supported Feature: DBS
2316 *
2317 * Usage: Internal/External
2318 *
2319 * </ioctl>
2320 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302322
2323/*
2324 * <ioctl>
2325 * set_fw_mode_cfg - Sets the dual mac FW mode config
2326 *
2327 * @INPUT: dbs, dfs
2328 * @dbs: DBS bit
2329 * @dfs: Agile DFS bit
2330 *
2331 * @OUTPUT: None
2332 *
2333 * This IOCTL is used to set the dual mac FW mode config.
2334 *
2335 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2336 * iwpriv wlan0 set_fw_mode_cfg 1 1
2337 *
2338 * Supported Feature: DBS
2339 *
2340 * Usage: Internal/External
2341 *
2342 * </ioctl>
2343 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07002345#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346
2347#ifdef FEATURE_WLAN_TDLS
2348#undef MAX_VAR_ARGS
2349#define MAX_VAR_ARGS 11
2350#else
2351#undef MAX_VAR_ARGS
2352#define MAX_VAR_ARGS 9
2353#endif
2354
2355/* Private ioctls (with no sub-ioctls) */
2356/* note that they must be odd so that they have "get" semantics */
2357#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
2358#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
2359#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2360
2361/* (SIOCIWFIRSTPRIV + 8) is currently unused */
2362/* (SIOCIWFIRSTPRIV + 10) is currently unused */
2363/* (SIOCIWFIRSTPRIV + 12) is currently unused */
2364/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002365#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
2366#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367/* (SIOCIWFIRSTPRIV + 16) is currently unused */
2368/* (SIOCIWFIRSTPRIV + 17) is currently unused */
2369/* (SIOCIWFIRSTPRIV + 19) is currently unused */
2370
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372
2373/* Private ioctl for setting the host offload feature */
2374#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2375
2376/* Private ioctl to get the statistics */
2377#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2378
2379/* Private ioctl to set the Keep Alive Params */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302380/*
2381 * <ioctl>
2382 * setKeepAlive - Set the keep alive feature
2383 *
2384 * @INPUT: 28 bytes of information in the order of packet type, time period
2385 * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2386 *
2387 * @OUTPUT: None
2388 *
2389 * This IOCTL sets the keep alive feature to send either NULL
2390 * or unsolicited ARP response packets
2391 *
2392 * @E.g: iwpriv wlan0 setKeepAlive
2393 *
2394 * Supported Feature: STA
2395 *
2396 * Usage: Internal/External
2397 *
2398 * </ioctl>
2399 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002400#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2401
2402#ifdef WLAN_FEATURE_PACKET_FILTERING
2403/* Private ioctl to set the packet filtering params */
2404#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2405#endif
2406
2407
2408#ifdef FEATURE_WLAN_SCAN_PNO
2409/* Private ioctl to get the statistics */
2410#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2411#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302412/*
2413 * <ioctl>
2414 * SETBAND - Set the operational band
2415 *
2416 * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2417 *
2418 * @OUTPUT: None
2419 *
2420 * This IOCTL Set the operational band If the new band is different from the
2421 * current operational band, it aborts the pending scan requests, flushes
2422 * the existing scan results, and then change * the band capability
2423 *
2424 * @E.g: iwpriv wlan0 SETBAND <value>
2425 *
2426 * Supported Feature: STA
2427 *
2428 * Usage: Internal/External
2429 *
2430 * </ioctl>
2431 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
2433
Dustin Brown0cbc7572016-12-16 13:54:40 -08002434#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -08002435/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436
2437/* Private ioctls and their sub-ioctls */
2438#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
2439#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -07002440#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441#define WE_SET_FW_CRASH_INJECT 2
2442#endif
2443#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +05302444/* Private sub ioctl for enabling and setting histogram interval of profiling */
2445#define WE_ENABLE_FW_PROFILE 4
2446#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07002448/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002449#define WE_SET_WLAN_SUSPEND 6
2450#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002451
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452/* (SIOCIWFIRSTPRIV + 29) is currently unused */
2453
2454/* 802.11p IOCTL */
2455#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
2456
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302457/*
2458 * <ioctl>
2459 * getLinkSpeed - Gets the current link speed in Mbps
2460 *
2461 * @INPUT: None
2462 *
2463 * @OUTPUT: linkspeed in mbps
2464 * wlan0 getLinkSpeed:7
2465 *
2466 * This IOCTL is used get the current link speed in Mbps
2467 *
2468 * @E.g: iwpriv wlan0 getLinkSpeed
2469 *
2470 * Supported Feature: STA
2471 *
2472 * Usage: Internal/External
2473 *
2474 * </ioctl>
2475 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002476#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
2477
2478#define WLAN_STATS_INVALID 0
2479#define WLAN_STATS_RETRY_CNT 1
2480#define WLAN_STATS_MUL_RETRY_CNT 2
2481#define WLAN_STATS_TX_FRM_CNT 3
2482#define WLAN_STATS_RX_FRM_CNT 4
2483#define WLAN_STATS_FRM_DUP_CNT 5
2484#define WLAN_STATS_FAIL_CNT 6
2485#define WLAN_STATS_RTS_FAIL_CNT 7
2486#define WLAN_STATS_ACK_FAIL_CNT 8
2487#define WLAN_STATS_RTS_SUC_CNT 9
2488#define WLAN_STATS_RX_DISCARD_CNT 10
2489#define WLAN_STATS_RX_ERROR_CNT 11
2490#define WLAN_STATS_TX_BYTE_CNT 12
2491
2492#define WLAN_STATS_RX_BYTE_CNT 13
2493#define WLAN_STATS_RX_RATE 14
2494#define WLAN_STATS_TX_RATE 15
2495
2496#define WLAN_STATS_RX_UC_BYTE_CNT 16
2497#define WLAN_STATS_RX_MC_BYTE_CNT 17
2498#define WLAN_STATS_RX_BC_BYTE_CNT 18
2499#define WLAN_STATS_TX_UC_BYTE_CNT 19
2500#define WLAN_STATS_TX_MC_BYTE_CNT 20
2501#define WLAN_STATS_TX_BC_BYTE_CNT 21
2502
2503#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
2504 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
2505 *__p++ = __type; \
2506 *__p++ = __size; \
2507 memcpy(__p, __val, __size); \
2508 __p += __size; \
2509 __tlen += __size + 2; \
2510 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07002511 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 } \
2513 } while (0)
2514
2515#define VERSION_VALUE_MAX_LEN 32
2516
2517#define TX_PER_TRACKING_DEFAULT_RATIO 5
2518#define TX_PER_TRACKING_MAX_RATIO 10
2519#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
2520
2521#define WLAN_ADAPTER 0
2522#define P2P_ADAPTER 1
2523
2524/**
2525 * mem_alloc_copy_from_user_helper - copy from user helper
2526 * @wrqu_data: wireless extensions request data
2527 * @len: length of @wrqu_data
2528 *
2529 * Helper function to allocate buffer and copy user data.
2530 *
2531 * Return: On success return a pointer to a kernel buffer containing a
2532 * copy of the userspace data (with an additional NUL character
2533 * appended for safety). On failure return %NULL.
2534 */
2535void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2536{
2537 u8 *ptr = NULL;
2538
2539 /* in order to protect the code, an extra byte is post
2540 * appended to the buffer and the null termination is added.
2541 * However, when allocating (len+1) byte of memory, we need to
2542 * make sure that there is no uint overflow when doing
2543 * addition. In theory check len < UINT_MAX protects the uint
2544 * overflow. For wlan private ioctl, the buffer size is much
2545 * less than UINT_MAX, as a good guess, now, it is assumed
2546 * that the private command buffer size is no greater than 4K
2547 * (4096 bytes). So we use 4096 as the upper boundary for now.
2548 */
2549 if (len > MAX_USER_COMMAND_SIZE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002550 hdd_err("Invalid length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551 return NULL;
2552 }
2553
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002554 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002556 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557 return NULL;
2558 }
2559
2560 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002561 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002562 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 return NULL;
2564 }
2565 ptr[len] = '\0';
2566 return ptr;
2567}
2568
2569/**
2570 * hdd_priv_get_data() - Get pointer to ioctl private data
2571 * @p_priv_data: pointer to iw_point struct to be filled
2572 * @wrqu: Pointer to IOCTL Data received from userspace
2573 *
2574 * Helper function to get compatible struct iw_point passed to ioctl
2575 *
2576 * Return - 0 if p_priv_data successfully filled, error otherwise
2577 */
2578int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2579{
2580 if ((NULL == p_priv_data) || (NULL == wrqu)) {
2581 return -EINVAL;
2582 }
2583#ifdef CONFIG_COMPAT
2584 if (is_compat_task()) {
2585 struct compat_iw_point *p_compat_priv_data;
2586
2587 /* Compat task:
2588 * typecast to compat structure and copy the members.
2589 */
2590 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2591
2592 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2593 p_priv_data->length = p_compat_priv_data->length;
2594 p_priv_data->flags = p_compat_priv_data->flags;
2595 } else {
2596#endif /* #ifdef CONFIG_COMPAT */
2597
2598 /* Non compat task: directly copy the structure. */
2599 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
2600
2601#ifdef CONFIG_COMPAT
2602 }
2603#endif /* #ifdef CONFIG_COMPAT */
2604
2605 return 0;
2606}
2607
Jeff Johnson441e1f72017-02-07 08:50:49 -08002608static int hdd_check_wext_control(enum hdd_wext_control wext_control,
2609 struct iw_request_info *info)
2610{
2611 switch (wext_control) {
2612 default:
2613 case hdd_wext_disabled:
2614 hdd_err("Rejecting disabled ioctl %x", info->cmd);
2615 return -ENOTSUPP;
2616 case hdd_wext_deprecated:
2617 hdd_warn("Using deprecated ioctl %x", info->cmd);
2618 return 0;
2619 case hdd_wext_enabled:
2620 return 0;
2621 }
2622}
2623
2624int hdd_check_standard_wext_control(struct hdd_context_s *hdd_ctx,
2625 struct iw_request_info *info)
2626{
2627 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
2628 info);
2629}
2630
2631int hdd_check_private_wext_control(struct hdd_context_s *hdd_ctx,
2632 struct iw_request_info *info)
2633{
2634 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
2635 info);
2636}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637
2638/**
2639 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
2640 * @pAdapter: Pointer to the hdd adapter.
2641 * @length: Size of the data copied
2642 * @buffer: Pointer to char buffer.
2643 * @buf_len: Length of the char buffer.
2644 *
2645 * This function called when the "iwpriv wlan0 get_stats" command is given.
2646 * It used to collect the txrx stats when the device is configured in SAP mode.
2647 *
2648 * Return - none
2649 */
2650void hdd_wlan_get_stats(hdd_adapter_t *pAdapter, uint16_t *length,
2651 char *buffer, uint16_t buf_len)
2652{
2653 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
2654 uint32_t len = 0;
2655 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
2656 uint32_t total_rx_delv = 0, total_rx_refused = 0;
2657 int i = 0;
2658
2659 for (; i < NUM_CPUS; i++) {
2660 total_rx_pkt += pStats->rxPackets[i];
2661 total_rx_dropped += pStats->rxDropped[i];
2662 total_rx_delv += pStats->rxDelivered[i];
2663 total_rx_refused += pStats->rxRefused[i];
2664 }
2665
2666 len = scnprintf(buffer, buf_len,
2667 "\nTransmit"
2668 "\ncalled %u, dropped %u,"
2669 "\n dropped BK %u, BE %u, VI %u, VO %u"
2670 "\n classified BK %u, BE %u, VI %u, VO %u"
2671 "\ncompleted %u,"
2672 "\n\nReceive Total"
2673 "\n packets %u, dropped %u, delivered %u, refused %u"
2674 "\n",
2675 pStats->txXmitCalled,
2676 pStats->txXmitDropped,
2677
2678 pStats->txXmitDroppedAC[SME_AC_BK],
2679 pStats->txXmitDroppedAC[SME_AC_BE],
2680 pStats->txXmitDroppedAC[SME_AC_VI],
2681 pStats->txXmitDroppedAC[SME_AC_VO],
2682
2683 pStats->txXmitClassifiedAC[SME_AC_BK],
2684 pStats->txXmitClassifiedAC[SME_AC_BE],
2685 pStats->txXmitClassifiedAC[SME_AC_VI],
2686 pStats->txXmitClassifiedAC[SME_AC_VO],
2687
2688 pStats->txCompleted,
2689 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
2690 );
2691
2692 for (i = 0; i < NUM_CPUS; i++) {
2693 len += scnprintf(buffer + len, buf_len - len,
2694 "\nReceive CPU: %d"
2695 "\n packets %u, dropped %u, delivered %u, refused %u",
2696 i, pStats->rxPackets[i], pStats->rxDropped[i],
2697 pStats->rxDelivered[i], pStats->rxRefused[i]);
2698 }
2699
2700 len += scnprintf(buffer + len, buf_len - len,
2701 "\n\nTX_FLOW"
2702 "\nCurrent status: %s"
2703 "\ntx-flow timer start count %u"
2704 "\npause count %u, unpause count %u",
2705 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
2706 pStats->txflow_timer_cnt,
2707 pStats->txflow_pause_cnt,
2708 pStats->txflow_unpause_cnt);
2709
Leo Changfdb45c32016-10-28 11:09:23 -07002710 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
2711 pAdapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712
2713 len += hdd_napi_stats(buffer + len, buf_len - len,
2714 NULL, hdd_napi_get_all());
2715
2716 *length = len + 1;
2717}
2718
2719/**
Dustin Brownd9322482017-01-09 12:46:03 -08002720 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
2721 * @hdd_ctx: The Hdd context owning the stats to be written
2722 * @buffer: The char buffer to write to
2723 * @max_len: The maximum number of chars to write
2724 *
2725 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
2726 *
2727 * Return - length of written content, negative number on error
2728 */
2729static int wlan_hdd_write_suspend_resume_stats(hdd_context_t *hdd_ctx,
2730 char *buffer, uint16_t max_len)
2731{
2732 QDF_STATUS status;
2733 struct suspend_resume_stats *sr_stats;
2734 struct sir_wake_lock_stats wow_stats;
2735
2736 sr_stats = &hdd_ctx->suspend_resume_stats;
2737
2738 status = wma_get_wakelock_stats(&wow_stats);
2739 if (QDF_IS_STATUS_ERROR(status)) {
2740 hdd_err("Failed to get WoW stats");
2741 return qdf_status_to_os_return(status);
2742 }
2743
2744 return scnprintf(buffer, max_len,
2745 "\n"
2746 "Suspends: %u\n"
2747 "Resumes: %u\n"
2748 "\n"
2749 "Suspend Fail Reasons\n"
2750 "\tIPA: %u\n"
2751 "\tRadar: %u\n"
2752 "\tRoam: %u\n"
2753 "\tScan: %u\n"
2754 "\tInitial Wakeup: %u\n"
2755 "\n"
2756 "WoW Wake Reasons\n"
2757 "\tunicast: %u\n"
2758 "\tbroadcast: %u\n"
2759 "\tIPv4 multicast: %u\n"
2760 "\tIPv6 multicast: %u\n"
2761 "\tIPv6 multicast RA: %u\n"
2762 "\tIPv6 multicast NS: %u\n"
2763 "\tIPv6 multicast NA: %u\n"
2764 "\tICMPv4: %u\n"
2765 "\tICMPv6: %u\n"
2766 "\tRSSI Breach: %u\n"
2767 "\tLow RSSI: %u\n"
2768 "\tG-Scan: %u\n"
2769 "\tPNO Complete: %u\n"
2770 "\tPNO Match: %u\n",
2771 sr_stats->suspends,
2772 sr_stats->resumes,
2773 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
2774 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
2775 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
2776 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
2777 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
2778 wow_stats.wow_ucast_wake_up_count,
2779 wow_stats.wow_bcast_wake_up_count,
2780 wow_stats.wow_ipv4_mcast_wake_up_count,
2781 wow_stats.wow_ipv6_mcast_wake_up_count,
2782 wow_stats.wow_ipv6_mcast_ra_stats,
2783 wow_stats.wow_ipv6_mcast_ns_stats,
2784 wow_stats.wow_ipv6_mcast_na_stats,
2785 wow_stats.wow_icmpv4_count,
2786 wow_stats.wow_icmpv6_count,
2787 wow_stats.wow_rssi_breach_wake_up_count,
2788 wow_stats.wow_low_rssi_wake_up_count,
2789 wow_stats.wow_gscan_wake_up_count,
2790 wow_stats.wow_pno_complete_wake_up_count,
2791 wow_stats.wow_pno_match_wake_up_count);
2792}
2793
2794/**
Govind Singha471e5e2015-10-12 17:11:14 +05302795 * hdd_wlan_list_fw_profile() - Get fw profiling points
2796 * @length: Size of the data copied
2797 * @buffer: Pointer to char buffer.
2798 * @buf_len: Length of the char buffer.
2799 *
2800 * This function called when the "iwpriv wlan0 listProfile" command is given.
2801 * It is used to get the supported profiling points in FW.
2802 *
2803 * Return - none
2804 */
2805void hdd_wlan_list_fw_profile(uint16_t *length,
2806 char *buffer, uint16_t buf_len)
2807{
2808 uint32_t len = 0;
2809
2810 len = scnprintf(buffer, buf_len,
2811 "PROF_CPU_IDLE: %u\n"
2812 "PROF_PPDU_PROC: %u\n"
2813 "PROF_PPDU_POST: %u\n"
2814 "PROF_HTT_TX_INPUT: %u\n"
2815 "PROF_MSDU_ENQ: %u\n"
2816 "PROF_PPDU_POST_HAL: %u\n"
2817 "PROF_COMPUTE_TX_TIME: %u\n",
2818 PROF_CPU_IDLE,
2819 PROF_PPDU_PROC,
2820 PROF_PPDU_POST,
2821 PROF_HTT_TX_INPUT,
2822 PROF_MSDU_ENQ,
2823 PROF_PPDU_POST_HAL,
2824 PROF_COMPUTE_TX_TIME);
2825
2826 *length = len + 1;
2827}
2828
2829/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 * hdd_wlan_dump_stats() - display dump Stats
2831 * @adapter: adapter handle
2832 * @value: value from user
2833 *
2834 * Return: none
2835 */
2836void hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value)
2837{
2838 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
2839
2840 switch (value) {
2841
2842 case WLAN_TXRX_HIST_STATS:
2843 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
2844 break;
2845 case WLAN_HDD_NETIF_OPER_HISTORY:
2846 wlan_hdd_display_netif_queue_history(hdd_ctx);
2847 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05302848 case WLAN_HIF_STATS:
2849 hdd_display_hif_stats();
2850 break;
Dhanashri Atree7d442a2016-07-14 18:20:29 -07002851 case WLAN_LRO_STATS:
2852 hdd_lro_display_stats(hdd_ctx);
2853 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 default:
Leo Changfdb45c32016-10-28 11:09:23 -07002855 cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 break;
2857 }
2858}
2859
2860/**
2861 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302862 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 * @wrqu: Pointer to IOCTL REQUEST Data.
2864 * @extra: Pointer to destination buffer
2865 *
2866 * This function is used to get Wlan Driver, Firmware, & Hardware
2867 * Version information. If @wrqu and @extra are specified, then the
2868 * version string is returned. Otherwise it is simply printed to the
2869 * kernel log.
2870 *
2871 * Return: none
2872 */
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302873void hdd_wlan_get_version(hdd_context_t *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 char *extra)
2875{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302876 tSirVersionString wcnss_sw_version;
2877 const char *swversion;
2878 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07002879 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302881 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002882 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 goto error;
2884 }
2885
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302886 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
2887 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302889 swversion = wcnss_sw_version;
2890 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
2891 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
2892 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
2893 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07002894 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895
Arun Khandavallia96c2c02016-05-17 19:15:34 +05302896 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897
2898 if (wrqu && extra) {
2899 wrqu->data.length =
2900 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07002901 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07002903 msp_id, mspid, siid, crmid,
2904 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07002906 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07002908 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 }
2910error:
2911 return;
2912}
2913
2914/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002915 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
2916 * @pAdapter: Adapter upon which the IBSS client is active
2917 * @staIdx: Station index of the IBSS peer
2918 *
2919 * Return: a pointer to the MAC address of the IBSS peer if the peer is
2920 * found, otherwise %NULL.
2921 */
2922struct qdf_mac_addr *
2923hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
2924 uint8_t staIdx)
2925{
2926 uint8_t idx;
2927 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2928
Naveen Rawatc45d1622016-07-05 12:20:09 -07002929 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002930 if (0 != pHddStaCtx->conn_info.staId[idx] &&
2931 staIdx == pHddStaCtx->conn_info.staId[idx]) {
2932 return &pHddStaCtx->conn_info.peerMacAddress[idx];
2933 }
2934 }
2935 return NULL;
2936}
2937
2938/**
2939 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
2940 * @pAdapter: Adapter upon which the IBSS client is active
2941 * @staIdx: Station index of the IBSS peer
2942 *
2943 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
2944 * otherwise an appropriate QDF_STATUS_E_* failure code.
2945 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07002946static QDF_STATUS hdd_wlan_get_ibss_peer_info(hdd_adapter_t *pAdapter,
2947 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002948{
2949 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2950 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2951 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07002952 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002953
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002954 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08002955 status = sme_request_ibss_peer_info(hHal, pAdapter,
2956 hdd_get_ibss_peer_info_cb,
2957 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002958
2959 if (QDF_STATUS_SUCCESS == status) {
2960 unsigned long rc;
2961 rc = wait_for_completion_timeout
2962 (&pAdapter->ibss_peer_info_comp,
2963 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
2964 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002965 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002966 return QDF_STATUS_E_FAILURE;
2967 }
2968
2969 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -07002970 hdd_info("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002971 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07002972 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
2973 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002974
Rajeev Kumar94c9b452016-03-24 12:58:47 -07002975 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
2976 mac_addr, sizeof(mac_addr));
2977 hdd_info("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
2978 mac_addr, (int)tx_rate,
2979 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002980 }
2981 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07002982 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002983 }
2984
2985 return status;
2986}
2987
2988/**
2989 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
2990 * @pAdapter: Adapter upon which the IBSS clients are active
2991 *
2992 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
2993 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
2994 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07002995static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(hdd_adapter_t *pAdapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002996{
2997 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2998 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2999 hdd_station_ctx_t *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003000 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003001 int i;
3002
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003003 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003004 status = sme_request_ibss_peer_info(hHal, pAdapter,
3005 hdd_get_ibss_peer_info_cb,
3006 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003007
3008 if (QDF_STATUS_SUCCESS == status) {
3009 unsigned long rc;
3010 rc = wait_for_completion_timeout
3011 (&pAdapter->ibss_peer_info_comp,
3012 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3013 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003014 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003015 return QDF_STATUS_E_FAILURE;
3016 }
3017
3018 /** Print the peer info */
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003019 hdd_info("pPeerInfo->numIBSSPeers = %d ",
3020 (int)pPeerInfo->numPeers);
3021 for (i = 0; i < pPeerInfo->numPeers; i++) {
3022 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3023 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003024
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003025 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
3026 qdf_mem_copy(mac_addr,
3027 pPeerInfo->peerInfoParams[i].mac_addr,
3028 sizeof(mac_addr));
3029
3030 hdd_info(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
3031 mac_addr, (int)tx_rate,
3032 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003033 }
3034 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003035 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003036 }
3037
3038 return status;
3039}
3040
3041/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 * hdd_wlan_get_freq() - Convert channel to frequency
3043 * @channel: channel to be converted
3044 * @pfreq: where to store the frequency
3045 *
3046 * Return: 1 on success, otherwise a negative errno
3047 */
3048int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
3049{
3050 int i;
3051 if (channel > 0) {
3052 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
3053 if (channel == freq_chan_map[i].chan) {
3054 *pfreq = freq_chan_map[i].freq;
3055 return 1;
3056 }
3057 }
3058 }
Jeff Johnson99bac312016-06-28 10:38:18 -07003059 hdd_notice("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 return -EINVAL;
3061}
3062
3063/**
3064 * hdd_is_auth_type_rsn() - RSN authentication type check
3065 * @authType: authentication type to be checked
3066 *
3067 * Return: true if @authType is an RSN authentication type,
3068 * false if it is not
3069 */
3070static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
3071{
3072 bool rsnType = false;
3073 /* is the authType supported? */
3074 switch (authType) {
3075 case eCSR_AUTH_TYPE_NONE: /* never used */
3076 rsnType = false;
3077 break;
3078 /* MAC layer authentication types */
3079 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3080 rsnType = false;
3081 break;
3082 case eCSR_AUTH_TYPE_SHARED_KEY:
3083 rsnType = false;
3084 break;
3085 case eCSR_AUTH_TYPE_AUTOSWITCH:
3086 rsnType = false;
3087 break;
3088
3089 /* Upper layer authentication types */
3090 case eCSR_AUTH_TYPE_WPA:
3091 rsnType = true;
3092 break;
3093 case eCSR_AUTH_TYPE_WPA_PSK:
3094 rsnType = true;
3095 break;
3096 case eCSR_AUTH_TYPE_WPA_NONE:
3097 rsnType = true;
3098 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 case eCSR_AUTH_TYPE_RSN:
3101 rsnType = true;
3102 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 case eCSR_AUTH_TYPE_RSN_PSK:
3105#ifdef WLAN_FEATURE_11W
3106 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3107 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
3108#endif
3109 rsnType = true;
3110 break;
3111 /* case eCSR_AUTH_TYPE_FAILED: */
3112 case eCSR_AUTH_TYPE_UNKNOWN:
3113 rsnType = false;
3114 break;
3115 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003116 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 authType);
3118 rsnType = false;
3119 break;
3120 }
Jeff Johnson99bac312016-06-28 10:38:18 -07003121 hdd_notice("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 authType, rsnType);
3123 return rsnType;
3124}
3125
Jeff Johnsona5444942017-01-23 13:11:08 -08003126struct rssi_priv {
3127 int8_t rssi;
3128};
3129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130/**
3131 * hdd_get_rssi_cb() - "Get RSSI" callback function
3132 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08003133 * @sta_id: ID of the station
3134 * @context: opaque context originally passed to SME. HDD always passes
3135 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 *
3137 * Return: None
3138 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003139static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140{
Jeff Johnsona5444942017-01-23 13:11:08 -08003141 struct hdd_request *request;
3142 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143
Jeff Johnsona5444942017-01-23 13:11:08 -08003144 request = hdd_request_get(context);
3145 if (!request) {
3146 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 return;
3148 }
3149
Jeff Johnsona5444942017-01-23 13:11:08 -08003150 priv = hdd_request_priv(request);
3151 priv->rssi = rssi;
3152 hdd_request_complete(request);
3153 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154}
3155
3156/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157 * wlan_hdd_get_rssi() - Get the current RSSI
3158 * @pAdapter: adapter upon which the measurement is requested
3159 * @rssi_value: pointer to where the RSSI should be returned
3160 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303161 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303163QDF_STATUS wlan_hdd_get_rssi(hdd_adapter_t *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 hdd_context_t *pHddCtx;
3166 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303167 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08003168 int ret;
3169 void *cookie;
3170 struct hdd_request *request;
3171 struct rssi_priv *priv;
3172 static const struct hdd_request_params params = {
3173 .priv_size = sizeof(*priv),
3174 .timeout_ms = WLAN_WAIT_TIME_STATS,
3175 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176
3177 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003178 hdd_warn("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303179 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003181 if (cds_is_driver_recovering()) {
3182 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3183 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 /* return a cached value */
3185 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303186 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 }
3188
3189 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3190 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3191
3192 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05303193 hdd_err("Not associated!, rssi on disconnect %d",
3194 pAdapter->rssi_on_disconnect);
3195 *rssi_value = pAdapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303196 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 }
3198
3199 if (pHddStaCtx->hdd_ReassocScenario) {
3200 hdd_info("Roaming in progress, return cached RSSI");
3201 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303202 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 }
3204
Jeff Johnsona5444942017-01-23 13:11:08 -08003205 request = hdd_request_alloc(&params);
3206 if (!request) {
3207 hdd_err("Request allocation failure, return cached RSSI");
3208 *rssi_value = pAdapter->rssi;
3209 return QDF_STATUS_SUCCESS;
3210 }
3211 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212
3213 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
3214 pHddStaCtx->conn_info.staId[0],
3215 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
Jeff Johnsona5444942017-01-23 13:11:08 -08003216 cookie, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303217 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003218 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 /* we'll returned a cached value below */
3220 } else {
3221 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08003222 ret = hdd_request_wait_for_response(request);
3223 if (ret) {
3224 hdd_warn("SME timed out while retrieving RSSI");
3225 /* we'll returned a cached value below */
3226 } else {
3227 /* update the adapter with the fresh results */
3228 priv = hdd_request_priv(request);
3229 pAdapter->rssi = priv->rssi;
3230 if (pAdapter->rssi > 0)
3231 pAdapter->rssi = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232 }
3233 }
3234
Jeff Johnsona5444942017-01-23 13:11:08 -08003235 /*
3236 * either we never sent a request, we sent a request and
3237 * received a response or we sent a request and timed out.
3238 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003240 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241
3242 *rssi_value = pAdapter->rssi;
3243
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303244 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245}
3246
Jeff Johnson002cb972017-01-23 14:59:07 -08003247struct snr_priv {
3248 int8_t snr;
3249};
3250
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08003252 * hdd_get_snr_cb() - "Get SNR" callback function
3253 * @snr: Current SNR of the station
Jeff Johnson002cb972017-01-23 14:59:07 -08003254 * @sta_id: ID of the station
3255 * @context: opaque context originally passed to SME. HDD always passes
3256 * a cookie for the request context
Jeff Johnson8eaff302017-01-23 11:03:31 -08003257 *
3258 * Return: None
3259 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003260static void hdd_get_snr_cb(int8_t snr, uint32_t sta_id, void *context)
Jeff Johnson8eaff302017-01-23 11:03:31 -08003261{
Jeff Johnson002cb972017-01-23 14:59:07 -08003262 struct hdd_request *request;
3263 struct snr_priv *priv;
Jeff Johnson8eaff302017-01-23 11:03:31 -08003264
Jeff Johnson002cb972017-01-23 14:59:07 -08003265 request = hdd_request_get(context);
3266 if (!request) {
3267 hdd_err("Obsolete request");
Jeff Johnson8eaff302017-01-23 11:03:31 -08003268 return;
3269 }
3270
Jeff Johnson002cb972017-01-23 14:59:07 -08003271 /* propagate response back to requesting thread */
3272 priv = hdd_request_priv(request);
3273 priv->snr = snr;
3274 hdd_request_complete(request);
3275 hdd_request_put(request);
Jeff Johnson8eaff302017-01-23 11:03:31 -08003276}
3277
3278/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 * wlan_hdd_get_snr() - Get the current SNR
3280 * @pAdapter: adapter upon which the measurement is requested
3281 * @snr: pointer to where the SNR should be returned
3282 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303283 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303285QDF_STATUS wlan_hdd_get_snr(hdd_adapter_t *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 hdd_context_t *pHddCtx;
3288 hdd_station_ctx_t *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303289 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 int valid;
Jeff Johnson002cb972017-01-23 14:59:07 -08003291 int ret;
3292 void *cookie;
3293 struct hdd_request *request;
3294 struct snr_priv *priv;
3295 static const struct hdd_request_params params = {
3296 .priv_size = sizeof(*priv),
3297 .timeout_ms = WLAN_WAIT_TIME_STATS,
3298 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303300 ENTER();
3301
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003303 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303304 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 }
3306
3307 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3308
3309 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303310 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303311 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312
3313 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3314
Jeff Johnson002cb972017-01-23 14:59:07 -08003315 request = hdd_request_alloc(&params);
3316 if (!request) {
3317 hdd_err("Request allocation failure");
3318 return QDF_STATUS_E_FAULT;
3319 }
3320 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321
3322 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
3323 pHddStaCtx->conn_info.staId[0],
Jeff Johnson002cb972017-01-23 14:59:07 -08003324 pHddStaCtx->conn_info.bssId, cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303325 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003326 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 /* we'll returned a cached value below */
3328 } else {
3329 /* request was sent -- wait for the response */
Jeff Johnson002cb972017-01-23 14:59:07 -08003330 ret = hdd_request_wait_for_response(request);
3331 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003332 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 /* we'll now returned a cached value below */
Jeff Johnson002cb972017-01-23 14:59:07 -08003334 } else {
3335 /* update the adapter with the fresh results */
3336 priv = hdd_request_priv(request);
3337 pAdapter->snr = priv->snr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338 }
3339 }
3340
Jeff Johnson002cb972017-01-23 14:59:07 -08003341 /*
3342 * either we never sent a request, we sent a request and
3343 * received a response or we sent a request and timed out.
3344 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003346 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347
3348 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303349 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303350 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351}
3352
Jeff Johnsone50427c2017-01-26 10:54:49 -08003353struct linkspeed_priv {
3354 tSirLinkSpeedInfo linkspeed_info;
3355};
3356
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357static void
Jeff Johnsone50427c2017-01-26 10:54:49 -08003358hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359{
Jeff Johnsone50427c2017-01-26 10:54:49 -08003360 struct hdd_request *request;
3361 struct linkspeed_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362
Jeff Johnsone50427c2017-01-26 10:54:49 -08003363 if (!linkspeed_info) {
3364 hdd_err("NULL linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 return;
3366 }
3367
Jeff Johnsone50427c2017-01-26 10:54:49 -08003368 request = hdd_request_get(context);
3369 if (!request) {
3370 hdd_err("Obsolete request");
3371 return;
3372 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373
Jeff Johnsone50427c2017-01-26 10:54:49 -08003374 priv = hdd_request_priv(request);
3375 priv->linkspeed_info = *linkspeed_info;
3376 hdd_request_complete(request);
3377 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378}
3379
Jeff Johnsone50427c2017-01-26 10:54:49 -08003380int wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *adapter,
3381 struct qdf_mac_addr *mac_address,
3382 uint32_t *linkspeed)
3383{
3384 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303385 QDF_STATUS status;
Jeff Johnsone50427c2017-01-26 10:54:49 -08003386 void *cookie;
3387 tSirLinkSpeedInfo *linkspeed_info;
3388 struct hdd_request *request;
3389 struct linkspeed_priv *priv;
3390 static const struct hdd_request_params params = {
3391 .priv_size = sizeof(*priv),
3392 .timeout_ms = WLAN_WAIT_TIME_STATS,
3393 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394
Jeff Johnsone50427c2017-01-26 10:54:49 -08003395 if ((!adapter) || (!linkspeed)) {
3396 hdd_err("NULL argument");
3397 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399
Jeff Johnsone50427c2017-01-26 10:54:49 -08003400 request = hdd_request_alloc(&params);
3401 if (!request) {
3402 hdd_err("Request allocation failure");
3403 ret = -ENOMEM;
3404 goto return_cached_value;
3405 }
3406
3407 cookie = hdd_request_cookie(request);
3408 priv = hdd_request_priv(request);
3409
3410 linkspeed_info = &priv->linkspeed_info;
3411 qdf_copy_macaddr(&linkspeed_info->peer_macaddr, mac_address);
3412 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(adapter),
3413 linkspeed_info,
3414 cookie, hdd_get_link_speed_cb);
3415 if (QDF_IS_STATUS_ERROR(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003416 hdd_err("Unable to retrieve statistics for link speed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003417 ret = qdf_status_to_os_return(status);
3418 goto cleanup;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 }
Jeff Johnsone50427c2017-01-26 10:54:49 -08003420 ret = hdd_request_wait_for_response(request);
3421 if (ret) {
3422 hdd_err("SME timed out while retrieving link speed");
3423 goto cleanup;
3424 }
3425 adapter->estimated_linkspeed = linkspeed_info->estLinkSpeed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426
Jeff Johnsone50427c2017-01-26 10:54:49 -08003427cleanup:
3428 /*
3429 * either we never sent a request, we sent a request and
3430 * received a response or we sent a request and timed out.
3431 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 */
Jeff Johnsone50427c2017-01-26 10:54:49 -08003433 hdd_request_put(request);
3434
3435return_cached_value:
3436 *linkspeed = adapter->estimated_linkspeed;
3437
3438 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439}
3440
3441/**
3442 * wlan_hdd_get_link_speed() - get link speed
3443 * @pAdapter: pointer to the adapter
3444 * @link_speed: pointer to link speed
3445 *
3446 * This function fetches per bssid link speed.
3447 *
3448 * Return: if associated, link speed shall be returned.
3449 * if not associated, link speed of 0 is returned.
3450 * On error, error number will be returned.
3451 */
3452int wlan_hdd_get_link_speed(hdd_adapter_t *sta_adapter, uint32_t *link_speed)
3453{
3454 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
3455 hdd_station_ctx_t *hdd_stactx =
3456 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
3457 int ret;
3458
3459 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05303460 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003461 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303463 /* Linkspeed is allowed only for P2P mode */
3464 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
3465 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
3466 hdd_device_mode_to_string(sta_adapter->device_mode),
3467 sta_adapter->device_mode);
3468 return -ENOTSUPP;
3469 }
3470
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
3472 /* we are not connected so we don't have a classAstats */
3473 *link_speed = 0;
3474 } else {
Anurag Chouhan6d760662016-02-20 16:05:43 +05303475 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476
Anurag Chouhanc5548422016-02-24 18:33:27 +05303477 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478
Jeff Johnsone50427c2017-01-26 10:54:49 -08003479 ret = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, &bssid,
3480 link_speed);
3481 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003482 hdd_err("Unable to retrieve SME linkspeed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003483 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 /* linkspeed in units of 500 kbps */
3486 *link_speed = (*link_speed) / 500;
3487 }
3488 return 0;
3489}
3490
3491/**
3492 * hdd_statistics_cb() - "Get statistics" callback function
3493 * @pStats: statistics payload
3494 * @pContext: opaque context originally passed to SME. HDD always passes
3495 * a pointer to an adapter
3496 *
3497 * Return: None
3498 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003499static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500{
3501 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
3502 hdd_stats_t *pStatsCache = NULL;
3503 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05303504 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505
3506 tCsrSummaryStatsInfo *pSummaryStats = NULL;
3507 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
3508 tCsrGlobalClassBStatsInfo *pClassBStats = NULL;
3509 tCsrGlobalClassCStatsInfo *pClassCStats = NULL;
3510 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
3511 tCsrPerStaStatsInfo *pPerStaStats = NULL;
3512
3513 if (pAdapter != NULL)
3514 pStatsCache = &pAdapter->hdd_stats;
3515
3516 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
3517 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
3518 pClassBStats = (tCsrGlobalClassBStatsInfo *) (pClassAStats + 1);
3519 pClassCStats = (tCsrGlobalClassCStatsInfo *) (pClassBStats + 1);
3520 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassCStats + 1);
3521 pPerStaStats = (tCsrPerStaStatsInfo *) (pClassDStats + 1);
3522
3523 if (pStatsCache != NULL) {
3524 /* copy the stats into the cache we keep in the
3525 * adapter instance structure
3526 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303527 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303529 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303531 qdf_mem_copy(&pStatsCache->ClassB_stat, pClassBStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532 sizeof(pStatsCache->ClassB_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303533 qdf_mem_copy(&pStatsCache->ClassC_stat, pClassCStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 sizeof(pStatsCache->ClassC_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303535 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536 sizeof(pStatsCache->ClassD_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303537 qdf_mem_copy(&pStatsCache->perStaStats, pPerStaStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538 sizeof(pStatsCache->perStaStats));
3539 }
3540
3541 if (pAdapter) {
3542 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303543 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05303544 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003545 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 return;
3547 }
3548 }
3549}
3550
3551/**
3552 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
3553 * @pAdapter: adapter who's IEs are to be cleared
3554 *
3555 * Return: None
3556 */
3557void hdd_clear_roam_profile_ie(hdd_adapter_t *pAdapter)
3558{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003559 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07003560
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003561 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562
3563 /* clear WPA/RSN/WSC IE information in the profile */
3564 pWextState->roamProfile.nWPAReqIELength = 0;
3565 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
3566 pWextState->roamProfile.nRSNReqIELength = 0;
3567 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
3568
3569#ifdef FEATURE_WLAN_WAPI
3570 pWextState->roamProfile.nWAPIReqIELength = 0;
3571 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
3572#endif
3573
3574 pWextState->roamProfile.bWPSAssociation = false;
3575 pWextState->roamProfile.bOSENAssociation = false;
3576 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
3577 pWextState->roamProfile.nAddIEScanLength = 0;
3578 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
3579 pWextState->roamProfile.nAddIEAssocLength = 0;
3580
3581 pWextState->roamProfile.EncryptionType.numEntries = 1;
3582 pWextState->roamProfile.EncryptionType.encryptionType[0]
3583 = eCSR_ENCRYPT_TYPE_NONE;
3584
3585 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
3586 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
3587 = eCSR_ENCRYPT_TYPE_NONE;
3588
3589 pWextState->roamProfile.AuthType.numEntries = 1;
3590 pWextState->roamProfile.AuthType.authType[0] =
3591 eCSR_AUTH_TYPE_OPEN_SYSTEM;
3592
Abhishek Singh3c9910e2017-01-06 17:56:47 +05303593 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
3594 QDF_MAC_ADDR_SIZE);
3595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596#ifdef WLAN_FEATURE_11W
3597 pWextState->roamProfile.MFPEnabled = false;
3598 pWextState->roamProfile.MFPRequired = 0;
3599 pWextState->roamProfile.MFPCapable = 0;
3600#endif
3601
3602 pWextState->authKeyMgmt = 0;
3603
Yingying Tang3cc6b792016-10-20 17:00:37 +08003604 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
3605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606#ifdef FEATURE_WLAN_WAPI
3607 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
3608 pAdapter->wapi_info.nWapiMode = 0;
3609#endif
3610
Anurag Chouhanc5548422016-02-24 18:33:27 +05303611 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07003612 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613}
3614
3615/**
3616 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
3617 * @oui: The OUI that is being searched for
3618 * @oui_size: The length of @oui
3619 * @ie: The set of IEs within which we're trying to find @oui
3620 * @ie_len: The length of @ie
3621 *
3622 * This function will scan the IEs contained within @ie looking for @oui.
3623 *
3624 * Return: Pointer to @oui embedded within @ie if it is present, NULL
3625 * if @oui is not present within @ie.
3626 */
3627uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
3628 uint8_t *ie, int ie_len)
3629{
3630 int left = ie_len;
3631 uint8_t *ptr = ie;
3632 uint8_t elem_id, elem_len;
3633 uint8_t eid = 0xDD;
3634
3635 if (NULL == ie || 0 == ie_len)
3636 return NULL;
3637
3638 while (left >= 2) {
3639 elem_id = ptr[0];
3640 elem_len = ptr[1];
3641 left -= 2;
3642 if (elem_len > left) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003643 hdd_alert("****Invalid IEs eid = %d elem_len=%d left=%d*****",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 eid, elem_len, left);
3645 return NULL;
3646 }
3647 if (elem_id == eid) {
3648 if (memcmp(&ptr[2], oui, oui_size) == 0)
3649 return ptr;
3650 }
3651
3652 left -= elem_len;
3653 ptr += (elem_len + 2);
3654 }
3655 return NULL;
3656}
3657
3658/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05303659 * hdd_get_ldpc() - Get adapter LDPC
3660 * @adapter: adapter being queried
3661 * @value: where to store the value
3662 *
3663 * Return: 0 on success, negative errno on failure
3664 */
3665int hdd_get_ldpc(hdd_adapter_t *adapter, int *value)
3666{
3667 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3668 int ret;
3669
3670 ENTER();
3671 ret = sme_get_ht_config(hal, adapter->sessionId,
3672 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
3673 if (ret < 0) {
3674 hdd_alert("Failed to get LDPC value");
3675 } else {
3676 *value = ret;
3677 ret = 0;
3678 }
3679 return ret;
3680}
3681
3682/**
3683 * hdd_set_ldpc() - Set adapter LDPC
3684 * @adapter: adapter being modified
3685 * @value: new LDPC value
3686 *
3687 * Return: 0 on success, negative errno on failure
3688 */
3689int hdd_set_ldpc(hdd_adapter_t *adapter, int value)
3690{
3691 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3692 int ret;
3693
3694 hdd_alert("%d", value);
3695 if (value) {
3696 /* make sure HT capabilities allow this */
3697 QDF_STATUS status;
3698 uint32_t cfg_value;
3699 union {
3700 uint16_t cfg_value16;
3701 tSirMacHTCapabilityInfo ht_cap_info;
3702 } u;
3703
3704 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
3705 if (QDF_STATUS_SUCCESS != status) {
3706 hdd_alert("Failed to get HT capability info");
3707 return -EIO;
3708 }
3709 u.cfg_value16 = cfg_value & 0xFFFF;
3710 if (!u.ht_cap_info.advCodingCap) {
3711 hdd_alert("LDCP not supported");
3712 return -EINVAL;
3713 }
3714 }
3715
3716 ret = sme_update_ht_config(hal, adapter->sessionId,
3717 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
3718 value);
3719 if (ret)
3720 hdd_alert("Failed to set LDPC value");
3721
3722 return ret;
3723}
3724
3725/**
3726 * hdd_get_tx_stbc() - Get adapter TX STBC
3727 * @adapter: adapter being queried
3728 * @value: where to store the value
3729 *
3730 * Return: 0 on success, negative errno on failure
3731 */
3732int hdd_get_tx_stbc(hdd_adapter_t *adapter, int *value)
3733{
3734 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3735 int ret;
3736
3737 ENTER();
3738 ret = sme_get_ht_config(hal, adapter->sessionId,
3739 WNI_CFG_HT_CAP_INFO_TX_STBC);
3740 if (ret < 0) {
3741 hdd_alert("Failed to get TX STBC value");
3742 } else {
3743 *value = ret;
3744 ret = 0;
3745 }
3746
3747 return ret;
3748}
3749
3750/**
3751 * hdd_set_tx_stbc() - Set adapter TX STBC
3752 * @adapter: adapter being modified
3753 * @value: new TX STBC value
3754 *
3755 * Return: 0 on success, negative errno on failure
3756 */
3757int hdd_set_tx_stbc(hdd_adapter_t *adapter, int value)
3758{
3759 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3760 int ret;
3761
3762 hdd_alert("%d", value);
3763 if (value) {
3764 /* make sure HT capabilities allow this */
3765 QDF_STATUS status;
3766 uint32_t cfg_value;
3767 union {
3768 uint16_t cfg_value16;
3769 tSirMacHTCapabilityInfo ht_cap_info;
3770 } u;
3771
3772 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
3773 if (QDF_STATUS_SUCCESS != status) {
3774 hdd_alert("Failed to get HT capability info");
3775 return -EIO;
3776 }
3777 u.cfg_value16 = cfg_value & 0xFFFF;
3778 if (!u.ht_cap_info.txSTBC) {
3779 hdd_alert("TX STBC not supported");
3780 return -EINVAL;
3781 }
3782 }
3783 ret = sme_update_ht_config(hal, adapter->sessionId,
3784 WNI_CFG_HT_CAP_INFO_TX_STBC,
3785 value);
3786 if (ret)
3787 hdd_alert("Failed to set TX STBC value");
3788
3789 return ret;
3790}
3791
3792/**
3793 * hdd_get_rx_stbc() - Get adapter RX STBC
3794 * @adapter: adapter being queried
3795 * @value: where to store the value
3796 *
3797 * Return: 0 on success, negative errno on failure
3798 */
3799int hdd_get_rx_stbc(hdd_adapter_t *adapter, int *value)
3800{
3801 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3802 int ret;
3803
3804 ENTER();
3805 ret = sme_get_ht_config(hal, adapter->sessionId,
3806 WNI_CFG_HT_CAP_INFO_RX_STBC);
3807 if (ret < 0) {
3808 hdd_alert("Failed to get RX STBC value");
3809 } else {
3810 *value = ret;
3811 ret = 0;
3812 }
3813
3814 return ret;
3815}
3816
3817/**
3818 * hdd_set_rx_stbc() - Set adapter RX STBC
3819 * @adapter: adapter being modified
3820 * @value: new RX STBC value
3821 *
3822 * Return: 0 on success, negative errno on failure
3823 */
3824int hdd_set_rx_stbc(hdd_adapter_t *adapter, int value)
3825{
3826 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
3827 int ret;
3828
3829 hdd_alert("%d", value);
3830 if (value) {
3831 /* make sure HT capabilities allow this */
3832 QDF_STATUS status;
3833 uint32_t cfg_value;
3834 union {
3835 uint16_t cfg_value16;
3836 tSirMacHTCapabilityInfo ht_cap_info;
3837 } u;
3838
3839 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
3840 if (QDF_STATUS_SUCCESS != status) {
3841 hdd_alert("Failed to get HT capability info");
3842 return -EIO;
3843 }
3844 u.cfg_value16 = cfg_value & 0xFFFF;
3845 if (!u.ht_cap_info.rxSTBC) {
3846 hdd_alert("RX STBC not supported");
3847 return -EINVAL;
3848 }
3849 }
3850 ret = sme_update_ht_config(hal, adapter->sessionId,
3851 WNI_CFG_HT_CAP_INFO_RX_STBC,
3852 value);
3853 if (ret)
3854 hdd_alert("Failed to set RX STBC value");
3855
3856 return ret;
3857}
3858
3859/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003860 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
3861 * @dev: device upon which the ioctl was received
3862 * @info: ioctl request information
3863 * @wrqu: ioctl request data
3864 * @extra: ioctl extra data
3865 *
3866 * Return: 0 on success, non-zero on error
3867 */
3868static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
3869 union iwreq_data *wrqu, char *extra)
3870{
3871 hdd_adapter_t *adapter;
3872 hdd_context_t *hdd_ctx;
3873 int ret;
3874
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003875 ENTER_DEV(dev);
3876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3878 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3879 ret = wlan_hdd_validate_context(hdd_ctx);
3880 if (0 != ret)
3881 return ret;
3882
Jeff Johnson441e1f72017-02-07 08:50:49 -08003883 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3884 if (0 != ret)
3885 return ret;
3886
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 /* Do nothing for now */
3888 return 0;
3889}
3890
3891/**
3892 * iw_set_commit() - SSR wrapper function for __iw_set_commit
3893 * @dev: pointer to net_device
3894 * @info: pointer to iw_request_info
3895 * @wrqu: pointer to iwreq_data
3896 * @extra: extra
3897 *
3898 * Return: 0 on success, error number otherwise
3899 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003900static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 union iwreq_data *wrqu, char *extra)
3902{
3903 int ret;
3904
3905 cds_ssr_protect(__func__);
3906 ret = __iw_set_commit(dev, info, wrqu, extra);
3907 cds_ssr_unprotect(__func__);
3908
3909 return ret;
3910}
3911
3912/**
3913 * __iw_get_name() - SIOCGIWNAME ioctl handler
3914 * @dev: device upon which the ioctl was received
3915 * @info: ioctl request information
3916 * @wrqu: ioctl request data
3917 * @extra: ioctl extra data
3918 *
3919 * Return: 0 on success, non-zero on error
3920 */
3921static int __iw_get_name(struct net_device *dev,
3922 struct iw_request_info *info, char *wrqu, char *extra)
3923{
3924 hdd_adapter_t *adapter;
3925 hdd_context_t *hdd_ctx;
3926 int ret;
3927
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003928 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929
3930 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
3931 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3932 ret = wlan_hdd_validate_context(hdd_ctx);
3933 if (0 != ret)
3934 return ret;
3935
Jeff Johnson441e1f72017-02-07 08:50:49 -08003936 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3937 if (0 != ret)
3938 return ret;
3939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
3941 EXIT();
3942 return 0;
3943}
3944
3945/**
3946 * __iw_get_name() - SSR wrapper for __iw_get_name
3947 * @dev: pointer to net_device
3948 * @info: pointer to iw_request_info
3949 * @wrqu: pointer to iwreq_data
3950 * @extra: extra
3951 *
3952 * Return: 0 on success, error number otherwise
3953 */
3954static int iw_get_name(struct net_device *dev,
3955 struct iw_request_info *info,
3956 char *wrqu, char *extra)
3957{
3958 int ret;
3959
3960 cds_ssr_protect(__func__);
3961 ret = __iw_get_name(dev, info, wrqu, extra);
3962 cds_ssr_unprotect(__func__);
3963
3964 return ret;
3965}
3966
3967/**
3968 * __iw_set_mode() - ioctl handler
3969 * @dev: device upon which the ioctl was received
3970 * @info: ioctl request information
3971 * @wrqu: ioctl request data
3972 * @extra: ioctl extra data
3973 *
3974 * Return: 0 on success, non-zero on error
3975 */
3976static int __iw_set_mode(struct net_device *dev,
3977 struct iw_request_info *info,
3978 union iwreq_data *wrqu, char *extra)
3979{
3980 hdd_wext_state_t *pWextState;
3981 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3982 hdd_context_t *hdd_ctx;
3983 tCsrRoamProfile *pRoamProfile;
3984 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 struct hdd_config *pConfig;
3986 struct wireless_dev *wdev;
3987 int ret;
3988
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08003989 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990
3991 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3992 ret = wlan_hdd_validate_context(hdd_ctx);
3993 if (0 != ret)
3994 return ret;
3995
Jeff Johnson441e1f72017-02-07 08:50:49 -08003996 ret = hdd_check_standard_wext_control(hdd_ctx, info);
3997 if (0 != ret)
3998 return ret;
3999
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4001 wdev = dev->ieee80211_ptr;
4002 pRoamProfile = &pWextState->roamProfile;
4003 LastBSSType = pRoamProfile->BSSType;
4004
Jeff Johnson99bac312016-06-28 10:38:18 -07004005 hdd_notice("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006
4007 switch (wrqu->mode) {
4008 case IW_MODE_ADHOC:
Jeff Johnson99bac312016-06-28 10:38:18 -07004009 hdd_notice("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
4011 /* Set the phymode correctly for IBSS. */
4012 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
4013 pWextState->roamProfile.phyMode =
4014 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08004015 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004016 wdev->iftype = NL80211_IFTYPE_ADHOC;
4017 break;
4018 case IW_MODE_INFRA:
Jeff Johnson99bac312016-06-28 10:38:18 -07004019 hdd_notice("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
4021 wdev->iftype = NL80211_IFTYPE_STATION;
4022 break;
4023 case IW_MODE_AUTO:
Jeff Johnson99bac312016-06-28 10:38:18 -07004024 hdd_notice("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
4026 break;
4027 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004028 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 return -EOPNOTSUPP;
4030 }
4031
4032 if (LastBSSType != pRoamProfile->BSSType) {
4033 /* the BSS mode changed. We need to issue disconnect
4034 * if connected or in IBSS disconnect state
4035 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07004036 if (hdd_conn_is_connected
4037 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304039 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004040 /* need to issue a disconnect to CSR. */
4041 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304042 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4044 pAdapter->sessionId,
4045 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304046 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 unsigned long rc;
4048 rc = wait_for_completion_timeout(&pAdapter->
4049 disconnect_comp_var,
4050 msecs_to_jiffies
4051 (WLAN_WAIT_TIME_DISCONNECT));
4052 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07004053 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054 }
4055 }
4056 }
4057
4058 EXIT();
4059 return 0;
4060}
4061
4062/**
4063 * iw_set_mode() - SSR wrapper for __iw_set_mode()
4064 * @dev: pointer to net_device
4065 * @info: pointer to iw_request_info
4066 * @wrqu: pointer to iwreq_data
4067 * @extra: pointer to extra ioctl payload
4068 *
4069 * Return: 0 on success, error number otherwise
4070 */
4071static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
4072 union iwreq_data *wrqu, char *extra)
4073{
4074 int ret;
4075
4076 cds_ssr_protect(__func__);
4077 ret = __iw_set_mode(dev, info, wrqu, extra);
4078 cds_ssr_unprotect(__func__);
4079
4080 return ret;
4081}
4082
4083/**
4084 * __iw_get_mode() - SIOCGIWMODE ioctl handler
4085 * @dev: device upon which the ioctl was received
4086 * @info: ioctl request information
4087 * @wrqu: ioctl request data
4088 * @extra: ioctl extra data
4089 *
4090 * Return: 0 on success, non-zero on error
4091 */
4092static int
4093__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4094 union iwreq_data *wrqu, char *extra)
4095{
4096 hdd_wext_state_t *pWextState;
4097 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4098 hdd_context_t *hdd_ctx;
4099 int ret;
4100
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004101 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102
4103 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4104 ret = wlan_hdd_validate_context(hdd_ctx);
4105 if (0 != ret)
4106 return ret;
4107
Jeff Johnson441e1f72017-02-07 08:50:49 -08004108 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4109 if (0 != ret)
4110 return ret;
4111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4113
4114 switch (pWextState->roamProfile.BSSType) {
4115 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Jeff Johnson99bac312016-06-28 10:38:18 -07004116 hdd_notice("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 wrqu->mode = IW_MODE_INFRA;
4118 break;
4119 case eCSR_BSS_TYPE_IBSS:
4120 case eCSR_BSS_TYPE_START_IBSS:
Jeff Johnson99bac312016-06-28 10:38:18 -07004121 hdd_notice("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 wrqu->mode = IW_MODE_ADHOC;
4123 break;
4124 case eCSR_BSS_TYPE_ANY:
4125 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004126 hdd_notice("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127 wrqu->mode = IW_MODE_AUTO;
4128 break;
4129 }
4130
4131 EXIT();
4132 return 0;
4133}
4134
4135/**
4136 * iw_get_mode() - SSR wrapper for __iw_get_mode()
4137 * @dev: pointer to net_device
4138 * @info: pointer to iw_request_info
4139 * @wrqu: pointer to iwreq_data
4140 * @extra: pointer to extra ioctl payload
4141 *
4142 * Return: 0 on success, error number otherwise
4143 */
4144static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4145 union iwreq_data *wrqu, char *extra)
4146{
4147 int ret;
4148
4149 cds_ssr_protect(__func__);
4150 ret = __iw_get_mode(dev, info, wrqu, extra);
4151 cds_ssr_unprotect(__func__);
4152
4153 return ret;
4154}
4155
4156/**
4157 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
4158 * @dev: device upon which the ioctl was received
4159 * @info: ioctl request information
4160 * @wrqu: ioctl request data
4161 * @extra: ioctl extra data
4162 *
4163 * Return: 0 on success, non-zero on error
4164 */
4165static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4166 union iwreq_data *wrqu, char *extra)
4167{
4168 uint32_t numChans = 0;
4169 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4170 uint32_t indx = 0;
4171 int ret;
4172 hdd_wext_state_t *pWextState;
4173 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4174 hdd_context_t *hdd_ctx;
4175 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4176 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4177 tCsrRoamProfile *pRoamProfile;
4178
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004179 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180
4181 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4182 ret = wlan_hdd_validate_context(hdd_ctx);
4183 if (0 != ret)
4184 return ret;
4185
Jeff Johnson441e1f72017-02-07 08:50:49 -08004186 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4187 if (0 != ret)
4188 return ret;
4189
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4191
4192 pRoamProfile = &pWextState->roamProfile;
4193
Jeff Johnson99bac312016-06-28 10:38:18 -07004194 hdd_notice("setCHANNEL ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195
4196 /* Link is up then return cant set channel */
4197 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
4198 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004199 hdd_err("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 return -EOPNOTSUPP;
4201 }
4202
4203 /* Settings by Frequency as input */
4204 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
4205 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
4206 uint32_t freq = wrqu->freq.m / 100000;
4207
4208 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
4209 && (freq != freq_chan_map[indx].freq))
4210 indx++;
4211 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE) {
4212 return -EINVAL;
4213 }
4214 wrqu->freq.e = 0;
4215 wrqu->freq.m = freq_chan_map[indx].chan;
4216
4217 }
4218
4219 if (wrqu->freq.e == 0) {
4220 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
4221 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004222 hdd_notice("Channel %d is outside valid range from %d to %d",
4223 wrqu->freq.m,
4224 WNI_CFG_CURRENT_CHANNEL_STAMIN,
4225 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226 return -EINVAL;
4227 }
4228
4229 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4230
4231 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
4232 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304233 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004234 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 return -EIO;
4236 }
4237
4238 for (indx = 0; indx < numChans; indx++) {
4239 if (wrqu->freq.m == validChan[indx]) {
4240 break;
4241 }
4242 }
4243 } else {
4244
4245 return -EINVAL;
4246 }
4247
4248 if (indx >= numChans) {
4249 return -EINVAL;
4250 }
4251
4252 /* Set the Operational Channel */
4253 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
4254 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
4255 pRoamProfile->ChannelInfo.ChannelList =
4256 &pHddStaCtx->conn_info.operationChannel;
4257
Jeff Johnson99bac312016-06-28 10:38:18 -07004258 hdd_notice("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259
4260 EXIT();
4261
4262 return ret;
4263}
4264
4265/**
4266 * iw_set_freq() - SSR wrapper for __iw_set_freq()
4267 * @dev: pointer to net_device
4268 * @info: pointer to iw_request_info
4269 * @wrqu: pointer to iwreq_data
4270 * @extra: pointer to extra ioctl payload
4271 *
4272 * Return: 0 on success, error number otherwise
4273 */
4274static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4275 union iwreq_data *wrqu, char *extra)
4276{
4277 int ret;
4278
4279 cds_ssr_protect(__func__);
4280 ret = __iw_set_freq(dev, info, wrqu, extra);
4281 cds_ssr_unprotect(__func__);
4282
4283 return ret;
4284}
4285
4286/**
4287 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
4288 * @dev: device upon which the ioctl was received
4289 * @info: ioctl request information
4290 * @wrqu: ioctl request data
4291 * @extra: ioctl extra data
4292 *
4293 * Return: 0 on success, non-zero on error
4294 */
4295static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4296 struct iw_freq *fwrq, char *extra)
4297{
4298 uint32_t status = false, channel = 0, freq = 0;
4299 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4300 tHalHandle hHal;
4301 hdd_wext_state_t *pWextState;
4302 tCsrRoamProfile *pRoamProfile;
4303 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4304 hdd_context_t *hdd_ctx;
4305 int ret;
4306
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004307 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308
4309 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4310 ret = wlan_hdd_validate_context(hdd_ctx);
4311 if (0 != ret)
4312 return ret;
4313
Jeff Johnson441e1f72017-02-07 08:50:49 -08004314 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4315 if (0 != ret)
4316 return ret;
4317
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4319 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4320
4321 pRoamProfile = &pWextState->roamProfile;
4322
4323 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
4324 if (sme_get_operation_channel(hHal, &channel, pAdapter->sessionId)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304325 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004326 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327 pAdapter->sessionId);
4328 return -EIO;
Jeff Johnson68755312017-02-10 11:46:55 -08004329 }
4330
4331 status = hdd_wlan_get_freq(channel, &freq);
4332 if (true == status) {
4333 /* Set Exponent parameter as 6 (MHZ)
4334 * in struct iw_freq iwlist & iwconfig
4335 * command shows frequency into proper
4336 * format (2.412 GHz instead of 246.2
4337 * MHz)
4338 */
4339 fwrq->m = freq;
4340 fwrq->e = MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004341 }
4342 } else {
4343 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
4344 * iwlist & iwconfig command shows frequency into proper
4345 * format (2.412 GHz instead of 246.2 MHz)
4346 */
4347 fwrq->m = 0;
4348 fwrq->e = MHZ;
4349 }
4350 return 0;
4351}
4352
4353/**
4354 * iw_get_freq() - SSR wrapper for __iw_get_freq()
4355 * @dev: pointer to net_device
4356 * @info: pointer to iw_request_info
4357 * @fwrq: pointer to frequency data
4358 * @extra: pointer to extra ioctl payload
4359 *
4360 * Return: 0 on success, error number otherwise
4361 */
4362static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
4363 struct iw_freq *fwrq, char *extra)
4364{
4365 int ret;
4366
4367 cds_ssr_protect(__func__);
4368 ret = __iw_get_freq(dev, info, fwrq, extra);
4369 cds_ssr_unprotect(__func__);
4370
4371 return ret;
4372}
4373
4374/**
4375 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
4376 * @dev: device upon which the ioctl was received
4377 * @info: ioctl request information
4378 * @wrqu: ioctl request data
4379 * @extra: ioctl extra data
4380 *
4381 * Return: 0 on success, non-zero on error
4382 */
4383static int __iw_get_tx_power(struct net_device *dev,
4384 struct iw_request_info *info,
4385 union iwreq_data *wrqu, char *extra)
4386{
4387
4388 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4389 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4390 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4391 int ret;
4392
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004393 ENTER_DEV(dev);
4394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 ret = wlan_hdd_validate_context(hdd_ctx);
4396 if (0 != ret)
4397 return ret;
4398
Jeff Johnson441e1f72017-02-07 08:50:49 -08004399 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4400 if (0 != ret)
4401 return ret;
4402
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4404 wrqu->txpower.value = 0;
4405 return 0;
4406 }
4407 wlan_hdd_get_class_astats(pAdapter);
4408 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
4409
4410 return 0;
4411}
4412
4413/**
4414 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
4415 * @dev: pointer to net_device
4416 * @info: pointer to iw_request_info
4417 * @wrqu: pointer to iwreq_data
4418 * @extra: pointer to extra ioctl payload
4419 *
4420 * Return: 0 on success, error number otherwise
4421 */
4422static int iw_get_tx_power(struct net_device *dev,
4423 struct iw_request_info *info,
4424 union iwreq_data *wrqu, char *extra)
4425{
4426 int ret;
4427
4428 cds_ssr_protect(__func__);
4429 ret = __iw_get_tx_power(dev, info, wrqu, extra);
4430 cds_ssr_unprotect(__func__);
4431
4432 return ret;
4433}
4434
4435/**
4436 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
4437 * @dev: device upon which the ioctl was received
4438 * @info: ioctl request information
4439 * @wrqu: ioctl request data
4440 * @extra: ioctl extra data
4441 *
4442 * Return: 0 on success, non-zero on error
4443 */
4444static int __iw_set_tx_power(struct net_device *dev,
4445 struct iw_request_info *info,
4446 union iwreq_data *wrqu, char *extra)
4447{
4448 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4449 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4450 hdd_context_t *hdd_ctx;
4451 int ret;
4452
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004453 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454
4455 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4456 ret = wlan_hdd_validate_context(hdd_ctx);
4457 if (0 != ret)
4458 return ret;
4459
Jeff Johnson441e1f72017-02-07 08:50:49 -08004460 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4461 if (0 != ret)
4462 return ret;
4463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304465 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004466 hdd_err("failed to set ini parameter, WNI_CFG_CURRENT_TX_POWER_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 return -EIO;
4468 }
4469
4470 EXIT();
4471
4472 return 0;
4473}
4474
4475/**
4476 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
4477 * @dev: pointer to net_device
4478 * @info: pointer to iw_request_info
4479 * @wrqu: pointer to iwreq_data
4480 * @extra: pointer to extra ioctl payload
4481 *
4482 * Return: 0 on success, error number otherwise
4483 */
4484static int iw_set_tx_power(struct net_device *dev,
4485 struct iw_request_info *info,
4486 union iwreq_data *wrqu, char *extra)
4487{
4488 int ret;
4489
4490 cds_ssr_protect(__func__);
4491 ret = __iw_set_tx_power(dev, info, wrqu, extra);
4492 cds_ssr_unprotect(__func__);
4493
4494 return ret;
4495}
4496
4497/**
4498 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
4499 * @dev: device upon which the ioctl was received
4500 * @info: ioctl request information
4501 * @wrqu: ioctl request data
4502 * @extra: ioctl extra data
4503 *
4504 * Return: 0 on success, non-zero on error
4505 */
4506static int __iw_get_bitrate(struct net_device *dev,
4507 struct iw_request_info *info,
4508 union iwreq_data *wrqu, char *extra)
4509{
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004510 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511 hdd_wext_state_t *pWextState;
4512 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4513 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4514 hdd_context_t *hdd_ctx;
4515 int ret;
4516
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004517 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518
4519 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4520 ret = wlan_hdd_validate_context(hdd_ctx);
4521 if (0 != ret)
4522 return ret;
4523
Jeff Johnson441e1f72017-02-07 08:50:49 -08004524 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4525 if (0 != ret)
4526 return ret;
4527
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004528 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4529 wrqu->bitrate.value = 0;
4530 } else {
4531 status =
4532 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
4533 eCSR_HDD,
4534 SME_SUMMARY_STATS |
4535 SME_GLOBAL_CLASSA_STATS |
4536 SME_GLOBAL_CLASSB_STATS |
4537 SME_GLOBAL_CLASSC_STATS |
4538 SME_GLOBAL_CLASSD_STATS |
4539 SME_PER_STA_STATS,
4540 hdd_statistics_cb, 0,
4541 false,
4542 pHddStaCtx->conn_info.staId[0],
4543 pAdapter, pAdapter->sessionId);
4544
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304545 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004546 hdd_err("Unable to retrieve statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004547 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548 }
4549
4550 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4551
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004552 status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304553 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 WLAN_WAIT_TIME_STATS);
4555
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004556 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004557 hdd_err("SME timeout while retrieving statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004558 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559 }
4560
4561 wrqu->bitrate.value =
4562 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
4563 }
4564
4565 EXIT();
4566
Jeff Johnsonf25ac102017-02-07 09:16:02 -08004567 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568}
4569
4570/**
4571 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
4572 * @dev: pointer to net_device
4573 * @info: pointer to iw_request_info
4574 * @wrqu: pointer to iwreq_data
4575 * @extra: pointer to extra ioctl payload
4576 *
4577 * Return: 0 on success, error number otherwise
4578 */
4579static int iw_get_bitrate(struct net_device *dev,
4580 struct iw_request_info *info,
4581 union iwreq_data *wrqu, char *extra)
4582{
4583 int ret;
4584
4585 cds_ssr_protect(__func__);
4586 ret = __iw_get_bitrate(dev, info, wrqu, extra);
4587 cds_ssr_unprotect(__func__);
4588
4589 return ret;
4590}
4591
4592/**
4593 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
4594 * @dev: device upon which the ioctl was received
4595 * @info: ioctl request information
4596 * @wrqu: ioctl request data
4597 * @extra: ioctl extra data
4598 *
4599 * Return: 0 on success, non-zero on error
4600 */
4601static int __iw_set_bitrate(struct net_device *dev,
4602 struct iw_request_info *info,
4603 union iwreq_data *wrqu, char *extra)
4604{
4605 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4606 hdd_wext_state_t *pWextState;
4607 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4608 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
4609 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
4610 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
4611 uint32_t i, rate;
4612 uint32_t valid_rate = false, active_phy_mode = 0;
4613 hdd_context_t *hdd_ctx;
4614 int ret;
4615
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004616 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617
4618 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4619 ret = wlan_hdd_validate_context(hdd_ctx);
4620 if (0 != ret)
4621 return ret;
4622
Jeff Johnson441e1f72017-02-07 08:50:49 -08004623 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4624 if (0 != ret)
4625 return ret;
4626
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4628
4629 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
4630 return -ENXIO;
4631 }
4632
4633 rate = wrqu->bitrate.value;
4634
4635 if (rate == -1) {
4636 rate = WNI_CFG_FIXED_RATE_AUTO;
4637 valid_rate = true;
4638 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
4639 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304640 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
4642 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
4643 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
4644 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
4645 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304646 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 &&
4648 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
4649 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304650 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 for (i = 0; i < (b_len + a_len); ++i) {
4652 /* supported rates returned is double
4653 * the actual rate so we divide it by 2
4654 */
4655 if ((supp_rates[i] & 0x7F) / 2 ==
4656 rate) {
4657 valid_rate = true;
4658 rate = i +
4659 WNI_CFG_FIXED_RATE_1MBPS;
4660 break;
4661 }
4662 }
4663 }
4664 }
4665 }
4666 if (valid_rate != true) {
4667 return -EINVAL;
4668 }
4669 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304670 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004671 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672 return -EIO;
4673 }
4674 return 0;
4675}
4676
4677/**
4678 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
4679 * @dev: pointer to net_device
4680 * @info: pointer to iw_request_info
4681 * @wrqu: pointer to iwreq_data
4682 * @extra: pointer to extra ioctl payload
4683 *
4684 * Return: 0 on success, error number otherwise
4685 */
4686static int iw_set_bitrate(struct net_device *dev,
4687 struct iw_request_info *info,
4688 union iwreq_data *wrqu, char *extra)
4689{
4690 int ret;
4691
4692 cds_ssr_protect(__func__);
4693 ret = __iw_set_bitrate(dev, info, wrqu, extra);
4694 cds_ssr_unprotect(__func__);
4695
4696 return ret;
4697}
4698
4699/**
4700 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
4701 * @dev: device upon which the ioctl was received
4702 * @info: ioctl request information
4703 * @wrqu: ioctl request data
4704 * @extra: ioctl extra data
4705 *
4706 * Return: 0 on success, non-zero on error
4707 */
4708static int __iw_set_genie(struct net_device *dev,
4709 struct iw_request_info *info,
4710 union iwreq_data *wrqu, char *extra)
4711{
4712 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4713 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4714 uint8_t *genie = NULL;
4715 uint8_t *base_genie = NULL;
4716 uint16_t remLen;
4717 hdd_context_t *hdd_ctx;
4718 int ret;
4719
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004720 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721
4722 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4723 ret = wlan_hdd_validate_context(hdd_ctx);
4724 if (0 != ret)
4725 return ret;
4726
Jeff Johnson441e1f72017-02-07 08:50:49 -08004727 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4728 if (0 != ret)
4729 return ret;
4730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731 if (!wrqu->data.length) {
4732 hdd_clear_roam_profile_ie(pAdapter);
4733 EXIT();
4734 return 0;
4735 }
4736
4737 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
4738 wrqu->data.length);
4739 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004740 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004741 return -ENOMEM;
4742 }
4743
4744 genie = base_genie;
4745
4746 remLen = wrqu->data.length;
4747
Jeff Johnson99bac312016-06-28 10:38:18 -07004748 hdd_notice("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749 genie[1]);
4750
4751 /* clear any previous genIE before this call */
4752 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
4753
4754 while (remLen >= 2) {
4755 uint16_t eLen = 0;
4756 uint8_t elementId;
4757 elementId = *genie++;
4758 eLen = *genie++;
4759 remLen -= 2;
4760
Jeff Johnson99bac312016-06-28 10:38:18 -07004761 hdd_notice("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762
4763 switch (elementId) {
4764 case IE_EID_VENDOR:
4765 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 +05304766 ret = -EINVAL;
4767 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768 }
4769
4770 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
4771 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07004772 hdd_notice("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
4773 genie[0], genie[1], genie[2],
4774 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775
4776 if (SIR_MAC_MAX_IE_LENGTH <
4777 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004778 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304779 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304780 ret = -ENOMEM;
4781 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782 }
4783 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
4784 memcpy(pWextState->genIE.addIEdata +
4785 curGenIELen, genie - 2, eLen + 2);
4786 pWextState->genIE.length += eLen + 2;
4787 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004788 hdd_notice("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304789 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
4790 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
4791 ret = -EINVAL;
4792 QDF_ASSERT(0);
4793 goto exit;
4794 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004795 memset(pWextState->WPARSNIE, 0,
4796 MAX_WPA_RSN_IE_LEN);
4797 memcpy(pWextState->WPARSNIE, genie - 2,
4798 (eLen + 2));
4799 pWextState->roamProfile.pWPAReqIE =
4800 pWextState->WPARSNIE;
4801 pWextState->roamProfile.nWPAReqIELength =
4802 eLen + 2;
4803 } else { /* any vendorId except WPA IE should be accumulated to genIE */
4804
4805 uint16_t curGenIELen = pWextState->genIE.length;
Jeff Johnson99bac312016-06-28 10:38:18 -07004806 hdd_notice("Set OUI(%02x %02x %02x %02x) IE(len %d)",
4807 genie[0], genie[1], genie[2],
4808 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004809
4810 if (SIR_MAC_MAX_IE_LENGTH <
4811 (pWextState->genIE.length + eLen)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004812 hdd_alert("Cannot accommodate genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304813 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304814 ret = -ENOMEM;
4815 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004816 }
4817 /* save to Additional IE ; it should be accumulated to handle WPS IE + other IE */
4818 memcpy(pWextState->genIE.addIEdata +
4819 curGenIELen, genie - 2, eLen + 2);
4820 pWextState->genIE.length += eLen + 2;
4821 }
4822 break;
4823 case DOT11F_EID_RSN:
Jeff Johnson99bac312016-06-28 10:38:18 -07004824 hdd_notice("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304825 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
4826 hdd_warn("Cannot accommodate genIE, Need bigger buffer space");
4827 ret = -EINVAL;
4828 QDF_ASSERT(0);
4829 goto exit;
4830 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
4832 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
4833 pWextState->roamProfile.pRSNReqIE =
4834 pWextState->WPARSNIE;
4835 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
4836 break;
4837
4838 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004839 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304840 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004841 }
4842 genie += eLen;
4843 remLen -= eLen;
4844 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304845exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07004847 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05304848 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004849}
4850
4851/**
4852 * iw_set_genie() - SSR wrapper for __iw_set_genie()
4853 * @dev: pointer to net_device
4854 * @info: pointer to iw_request_info
4855 * @wrqu: pointer to iwreq_data
4856 * @extra: pointer to extra ioctl payload
4857 *
4858 * Return: 0 on success, error number otherwise
4859 */
4860static int iw_set_genie(struct net_device *dev,
4861 struct iw_request_info *info,
4862 union iwreq_data *wrqu, char *extra)
4863{
4864 int ret;
4865
4866 cds_ssr_protect(__func__);
4867 ret = __iw_set_genie(dev, info, wrqu, extra);
4868 cds_ssr_unprotect(__func__);
4869
4870 return ret;
4871}
4872
4873/**
4874 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
4875 * @dev: device upon which the ioctl was received
4876 * @info: ioctl request information
4877 * @wrqu: ioctl request data
4878 * @extra: ioctl extra data
4879 *
4880 * Return: 0 on success, non-zero on error
4881 */
4882static int __iw_get_genie(struct net_device *dev,
4883 struct iw_request_info *info,
4884 union iwreq_data *wrqu, char *extra)
4885{
4886 hdd_wext_state_t *pWextState;
4887 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4888 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304889 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
4891 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
4892 hdd_context_t *hdd_ctx;
4893 int ret;
4894
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004895 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896
4897 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4898 ret = wlan_hdd_validate_context(hdd_ctx);
4899 if (0 != ret)
4900 return ret;
4901
Jeff Johnson441e1f72017-02-07 08:50:49 -08004902 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4903 if (0 != ret)
4904 return ret;
4905
Jeff Johnson99bac312016-06-28 10:38:18 -07004906 hdd_notice("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907
4908 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4909
4910 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected) {
4911 return -ENXIO;
4912 }
4913
4914 /* Return something ONLY if we are associated with an RSN or
4915 * WPA network
4916 */
4917 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType)) {
4918 return -ENXIO;
4919 }
4920
4921 /* Actually retrieve the RSN IE from CSR. (We previously sent
4922 * it down in the CSR Roam Profile.)
4923 */
4924 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
4925 pAdapter->sessionId,
4926 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05304927 if (QDF_STATUS_SUCCESS != status) {
4928 hdd_notice("failed to get WPA-RSN IE data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 return -EFAULT;
4930 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05304932 if (length > DOT11F_IE_RSN_MAX_LEN) {
4933 hdd_notice("invalid buffer length length:%d", length);
4934 return -E2BIG;
4935 }
4936 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937
Jeff Johnson99bac312016-06-28 10:38:18 -07004938 hdd_notice("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939 wrqu->data.length);
4940
4941 EXIT();
4942
4943 return 0;
4944}
4945
4946/**
4947 * iw_get_genie() - SSR wrapper for __iw_get_genie()
4948 * @dev: pointer to net_device
4949 * @info: pointer to iw_request_info
4950 * @wrqu: pointer to iwreq_data
4951 * @extra: pointer to extra ioctl payload
4952 *
4953 * Return: 0 on success, error number otherwise
4954 */
4955static int iw_get_genie(struct net_device *dev,
4956 struct iw_request_info *info,
4957 union iwreq_data *wrqu, char *extra)
4958{
4959 int ret;
4960
4961 cds_ssr_protect(__func__);
4962 ret = __iw_get_genie(dev, info, wrqu, extra);
4963 cds_ssr_unprotect(__func__);
4964
4965 return ret;
4966}
4967
4968/**
4969 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
4970 * @dev: device upon which the ioctl was received
4971 * @info: ioctl request information
4972 * @wrqu: ioctl request data
4973 * @extra: ioctl extra data
4974 *
4975 * Return: 0 on success, non-zero on error
4976 */
4977static int __iw_get_encode(struct net_device *dev,
4978 struct iw_request_info *info,
4979 struct iw_point *dwrq, char *extra)
4980{
4981 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4982 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4983 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4984 int keyId;
4985 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
4986 int i;
4987 hdd_context_t *hdd_ctx;
4988 int ret;
4989
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004990 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004991
4992 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4993 ret = wlan_hdd_validate_context(hdd_ctx);
4994 if (0 != ret)
4995 return ret;
4996
Jeff Johnson441e1f72017-02-07 08:50:49 -08004997 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4998 if (0 != ret)
4999 return ret;
5000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001 keyId = pRoamProfile->Keys.defaultIndex;
5002
5003 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005004 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005005 return -EINVAL;
5006 }
5007
5008 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
5009 dwrq->flags |= IW_ENCODE_ENABLED;
5010 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305011 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005012 pRoamProfile->Keys.KeyLength[keyId]);
5013
5014 dwrq->flags |= (keyId + 1);
5015
5016 } else {
5017 dwrq->flags |= IW_ENCODE_DISABLED;
5018 }
5019
5020 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08005021 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022 continue;
5023 } else {
5024 break;
5025 }
5026 }
5027
5028 if (MAX_WEP_KEYS == i) {
5029 dwrq->flags |= IW_ENCODE_NOKEY;
5030 }
5031
5032 authType =
5033 ((hdd_station_ctx_t *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
5034 conn_info.authType;
5035
5036 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType) {
5037 dwrq->flags |= IW_ENCODE_OPEN;
5038 } else {
5039 dwrq->flags |= IW_ENCODE_RESTRICTED;
5040 }
5041 EXIT();
5042 return 0;
5043}
5044
5045/**
5046 * iw_get_encode() - SSR wrapper for __iw_get_encode()
5047 * @dev: pointer to net_device
5048 * @info: pointer to iw_request_info
5049 * @dwrq: pointer to encoding information
5050 * @extra: pointer to extra ioctl payload
5051 *
5052 * Return: 0 on success, error number otherwise
5053 */
5054static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
5055 struct iw_point *dwrq, char *extra)
5056{
5057 int ret;
5058
5059 cds_ssr_protect(__func__);
5060 ret = __iw_get_encode(dev, info, dwrq, extra);
5061 cds_ssr_unprotect(__func__);
5062
5063 return ret;
5064}
5065
5066/**
5067 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
5068 * @dev: device upon which the ioctl was received
5069 * @info: ioctl request information
5070 * @wrqu: ioctl request data
5071 * @extra: ioctl extra data
5072 *
5073 * Return: 0 on success, non-zero on error
5074 */
5075static int __iw_get_rts_threshold(struct net_device *dev,
5076 struct iw_request_info *info,
5077 union iwreq_data *wrqu, char *extra)
5078{
Jeff Johnson5b907622017-02-07 10:00:37 -08005079 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5080 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5081 uint32_t threshold = 0;
5082 hdd_context_t *hdd_ctx;
5083 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005085 ENTER_DEV(dev);
5086
Jeff Johnson5b907622017-02-07 10:00:37 -08005087 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5088 ret = wlan_hdd_validate_context(hdd_ctx);
5089 if (0 != ret)
5090 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091
Jeff Johnson441e1f72017-02-07 08:50:49 -08005092 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5093 if (0 != ret)
5094 return ret;
5095
Jeff Johnson5b907622017-02-07 10:00:37 -08005096 if (QDF_STATUS_SUCCESS !=
5097 sme_cfg_get_int(hal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
5098 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
5099 return -EIO;
5100 }
5101 wrqu->rts.value = threshold;
5102
5103 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
5104
5105 EXIT();
5106
5107 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005108}
5109
5110/**
5111 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
5112 * @dev: device upon which the ioctl was received
5113 * @info: ioctl request information
5114 * @wrqu: ioctl request data
5115 * @extra: ioctl extra data
5116 *
5117 * Return: 0 on success, non-zero on error
5118 */
5119static int __iw_set_rts_threshold(struct net_device *dev,
5120 struct iw_request_info *info,
5121 union iwreq_data *wrqu, char *extra)
5122{
5123 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5124 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5125 hdd_context_t *hdd_ctx;
5126 int ret;
5127
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005128 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129
5130 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5131 ret = wlan_hdd_validate_context(hdd_ctx);
5132 if (0 != ret)
5133 return ret;
5134
Jeff Johnson441e1f72017-02-07 08:50:49 -08005135 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5136 if (0 != ret)
5137 return ret;
5138
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005139 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
5140 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
5141 return -EINVAL;
5142 }
5143
5144 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305145 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005146 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 return -EIO;
5148 }
5149
5150 EXIT();
5151
5152 return 0;
5153}
5154
5155/**
5156 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
5157 * @dev: pointer to net_device
5158 * @info: pointer to iw_request_info
5159 * @wrqu: pointer to iwreq_data
5160 * @extra: pointer to extra ioctl payload
5161 *
5162 * Return: 0 on success, error number otherwise
5163 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005164int iw_get_rts_threshold(struct net_device *dev,
5165 struct iw_request_info *info,
5166 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167{
5168 int ret;
5169
5170 cds_ssr_protect(__func__);
5171 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
5172 cds_ssr_unprotect(__func__);
5173
5174 return ret;
5175}
5176
5177/**
5178 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
5179 * @dev: pointer to net_device
5180 * @info: pointer to iw_request_info
5181 * @wrqu: pointer to iwreq_data
5182 * @extra: pointer to extra ioctl payload
5183 *
5184 * Return: 0 on success, error number otherwise
5185 */
5186static int iw_set_rts_threshold(struct net_device *dev,
5187 struct iw_request_info *info,
5188 union iwreq_data *wrqu, char *extra)
5189{
5190 int ret;
5191
5192 cds_ssr_protect(__func__);
5193 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
5194 cds_ssr_unprotect(__func__);
5195
5196 return ret;
5197}
5198
5199/**
5200 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
5201 * @dev: device upon which the ioctl was received
5202 * @info: ioctl request information
5203 * @wrqu: ioctl request data
5204 * @extra: ioctl extra data
5205 *
5206 * Return: 0 on success, non-zero on error
5207 */
5208static int __iw_get_frag_threshold(struct net_device *dev,
5209 struct iw_request_info *info,
5210 union iwreq_data *wrqu, char *extra)
5211{
Jeff Johnson5b907622017-02-07 10:00:37 -08005212 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5213 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5214 uint32_t threshold = 0;
5215 hdd_context_t *hdd_ctx;
5216 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005218 ENTER_DEV(dev);
5219
Jeff Johnson5b907622017-02-07 10:00:37 -08005220 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5221 ret = wlan_hdd_validate_context(hdd_ctx);
5222 if (0 != ret)
5223 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224
Jeff Johnson441e1f72017-02-07 08:50:49 -08005225 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5226 if (0 != ret)
5227 return ret;
5228
Jeff Johnson5b907622017-02-07 10:00:37 -08005229 if (sme_cfg_get_int(hal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
5230 != QDF_STATUS_SUCCESS) {
5231 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
5232 return -EIO;
5233 }
5234 wrqu->frag.value = threshold;
5235
5236 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
5237
5238 EXIT();
5239
5240 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005241}
5242
5243/**
5244 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
5245 * @dev: pointer to net_device
5246 * @info: pointer to iw_request_info
5247 * @wrqu: pointer to iwreq_data
5248 * @extra: pointer to extra ioctl payload
5249 *
5250 * Return: 0 on success, error number otherwise
5251 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005252int iw_get_frag_threshold(struct net_device *dev,
5253 struct iw_request_info *info,
5254 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255{
5256 int ret;
5257
5258 cds_ssr_protect(__func__);
5259 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
5260 cds_ssr_unprotect(__func__);
5261
5262 return ret;
5263}
5264
5265/**
5266 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
5267 * @dev: device upon which the ioctl was received
5268 * @info: ioctl request information
5269 * @wrqu: ioctl request data
5270 * @extra: ioctl extra data
5271 *
5272 * Return: 0 on success, non-zero on error
5273 */
5274static int __iw_set_frag_threshold(struct net_device *dev,
5275 struct iw_request_info *info,
5276 union iwreq_data *wrqu, char *extra)
5277{
5278 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5279 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5280 hdd_context_t *hdd_ctx;
5281 int ret;
5282
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005283 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284
5285 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5286 ret = wlan_hdd_validate_context(hdd_ctx);
5287 if (0 != ret)
5288 return ret;
5289
Jeff Johnson441e1f72017-02-07 08:50:49 -08005290 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5291 if (0 != ret)
5292 return ret;
5293
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
5295 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
5296 return -EINVAL;
5297 }
5298
5299 if (sme_cfg_set_int
5300 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305301 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005302 hdd_err("failed to set ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303 return -EIO;
5304 }
5305
5306 EXIT();
5307
5308 return 0;
5309}
5310
5311/**
5312 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
5313 * @dev: pointer to net_device
5314 * @info: pointer to iw_request_info
5315 * @wrqu: pointer to iwreq_data
5316 * @extra: pointer to extra ioctl payload
5317 *
5318 * Return: 0 on success, error number otherwise
5319 */
5320static int iw_set_frag_threshold(struct net_device *dev,
5321 struct iw_request_info *info,
5322 union iwreq_data *wrqu, char *extra)
5323{
5324 int ret;
5325
5326 cds_ssr_protect(__func__);
5327 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
5328 cds_ssr_unprotect(__func__);
5329
5330 return ret;
5331}
5332
5333/**
5334 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
5335 * @dev: device upon which the ioctl was received
5336 * @info: ioctl request information
5337 * @wrqu: ioctl request data
5338 * @extra: ioctl extra data
5339 *
5340 * Return: 0 on success, non-zero on error
5341 */
5342static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005343 struct iw_request_info *info,
5344 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345{
5346 hdd_adapter_t *adapter;
5347 hdd_context_t *hdd_ctx;
5348 int ret;
5349
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005350 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005351
5352 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5353 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5354 ret = wlan_hdd_validate_context(hdd_ctx);
5355 if (0 != ret)
5356 return ret;
5357
Jeff Johnson441e1f72017-02-07 08:50:49 -08005358 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5359 if (0 != ret)
5360 return ret;
5361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005362 return -EOPNOTSUPP;
5363}
5364
5365/**
5366 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
5367 * @dev: pointer to net_device
5368 * @info: pointer to iw_request_info
5369 * @wrqu: pointer to iwreq_data
5370 * @extra: extra
5371 *
5372 * Return: 0 on success, error number otherwise
5373 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005374static int iw_get_power_mode(struct net_device *dev,
5375 struct iw_request_info *info,
5376 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005377{
5378 int ret;
5379
5380 cds_ssr_protect(__func__);
5381 ret = __iw_get_power_mode(dev, info, wrqu, extra);
5382 cds_ssr_unprotect(__func__);
5383
5384 return ret;
5385}
5386
5387/**
5388 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
5389 * @dev: device upon which the ioctl was received
5390 * @info: ioctl request information
5391 * @wrqu: ioctl request data
5392 * @extra: ioctl extra data
5393 *
5394 * Return: 0 on success, non-zero on error
5395 */
5396static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005397 struct iw_request_info *info,
5398 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399{
5400 hdd_adapter_t *adapter;
5401 hdd_context_t *hdd_ctx;
5402 int ret;
5403
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005404 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005405
5406 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5407 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5408 ret = wlan_hdd_validate_context(hdd_ctx);
5409 if (0 != ret)
5410 return ret;
5411
Jeff Johnson441e1f72017-02-07 08:50:49 -08005412 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5413 if (0 != ret)
5414 return ret;
5415
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416 return -EOPNOTSUPP;
5417}
5418
5419/**
5420 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
5421 * @dev: pointer to net_device
5422 * @info: pointer to iw_request_info
5423 * @wrqu: pointer to iwreq_data
5424 * @extra: extra
5425 *
5426 * Return: 0 on success, error number otherwise
5427 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07005428static int iw_set_power_mode(struct net_device *dev,
5429 struct iw_request_info *info,
5430 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005431{
5432 int ret;
5433
5434 cds_ssr_protect(__func__);
5435 ret = __iw_set_power_mode(dev, info, wrqu, extra);
5436 cds_ssr_unprotect(__func__);
5437
5438 return ret;
5439}
5440
5441/**
5442 * __iw_get_range() - SIOCGIWRANGE ioctl handler
5443 * @dev: device upon which the ioctl was received
5444 * @info: ioctl request information
5445 * @wrqu: ioctl request data
5446 * @extra: ioctl extra data
5447 *
5448 * Return: 0 on success, non-zero on error
5449 */
5450static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
5451 union iwreq_data *wrqu, char *extra)
5452{
5453 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5454 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5455 struct iw_range *range = (struct iw_range *)extra;
5456
5457 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5458
5459 uint32_t num_channels = sizeof(channels);
5460 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
5461 uint32_t a_len;
5462 uint32_t b_len;
5463 uint32_t active_phy_mode = 0;
5464 uint8_t index = 0, i;
5465 hdd_context_t *hdd_ctx;
5466 int ret;
5467
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005468 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005469
5470 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5471 ret = wlan_hdd_validate_context(hdd_ctx);
5472 if (0 != ret)
5473 return ret;
5474
Jeff Johnson441e1f72017-02-07 08:50:49 -08005475 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5476 if (0 != ret)
5477 return ret;
5478
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479 wrqu->data.length = sizeof(struct iw_range);
5480 memset(range, 0, sizeof(struct iw_range));
5481
5482
5483 /*Get the phy mode */
5484 if (sme_cfg_get_int(hHal,
5485 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305486 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005487 hdd_notice("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488
5489 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5490 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
5491 /*Get the supported rates for 11G band */
5492 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5493 if (sme_cfg_get_str(hHal,
5494 WNI_CFG_SUPPORTED_RATES_11A,
5495 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305496 &a_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN) {
5498 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5499 }
5500 for (i = 0; i < a_len; i++) {
5501 range->bitrate[i] =
5502 ((supp_rates[i] & 0x7F) / 2) *
5503 1000000;
5504 }
5505 range->num_bitrates = a_len;
5506 } else {
5507 return -EIO;
5508 }
5509 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
5510 /*Get the supported rates for 11B band */
5511 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5512 if (sme_cfg_get_str(hHal,
5513 WNI_CFG_SUPPORTED_RATES_11B,
5514 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305515 &b_len) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN) {
5517 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5518 }
5519 for (i = 0; i < b_len; i++) {
5520 range->bitrate[i] =
5521 ((supp_rates[i] & 0x7F) / 2) *
5522 1000000;
5523 }
5524 range->num_bitrates = b_len;
5525 } else {
5526 return -EIO;
5527 }
5528 }
5529 }
5530
5531 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
5532 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
5533 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
5534
5535 range->encoding_size[0] = 5;
5536 range->encoding_size[1] = 13;
5537 range->num_encoding_sizes = 2;
5538 range->max_encoding_tokens = MAX_WEP_KEYS;
5539
5540 /* we support through Wireless Extensions 22 */
5541 range->we_version_compiled = WIRELESS_EXT;
5542 range->we_version_source = 22;
5543
5544 /*Supported Channels and Frequencies */
5545 if (sme_cfg_get_str
5546 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305547 &num_channels) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005548 hdd_warn("failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549 return -EIO;
5550 }
5551 if (num_channels > IW_MAX_FREQUENCIES) {
5552 num_channels = IW_MAX_FREQUENCIES;
5553 }
5554
5555 range->num_channels = num_channels;
5556 range->num_frequency = num_channels;
5557
5558 for (index = 0; index < num_channels; index++) {
5559 uint32_t frq_indx = 0;
5560
5561 range->freq[index].i = channels[index];
5562 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
5563 if (channels[index] == freq_chan_map[frq_indx].chan) {
5564 range->freq[index].m =
5565 freq_chan_map[frq_indx].freq * 100000;
5566 range->freq[index].e = 1;
5567 break;
5568 }
5569 frq_indx++;
5570 }
5571 }
5572
5573 /* Event capability (kernel + driver) */
5574 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
5575 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
5576 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
5577 range->event_capa[1] = IW_EVENT_CAPA_K_1;
5578
5579 /*Encryption capability */
5580 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
5581 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
5582
5583 /* Txpower capability */
5584 range->txpower_capa = IW_TXPOW_MWATT;
5585
5586 /*Scanning capability */
5587#if WIRELESS_EXT >= 22
5588 range->scan_capa =
5589 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
5590#endif
5591
5592 EXIT();
5593 return 0;
5594}
5595
5596/**
5597 * iw_get_range() - SSR wrapper for __iw_get_range()
5598 * @dev: pointer to net_device
5599 * @info: pointer to iw_request_info
5600 * @wrqu: pointer to iwreq_data
5601 * @extra: pointer to extra ioctl payload
5602 *
5603 * Return: 0 on success, error number otherwise
5604 */
5605static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
5606 union iwreq_data *wrqu, char *extra)
5607{
5608 int ret;
5609
5610 cds_ssr_protect(__func__);
5611 ret = __iw_get_range(dev, info, wrqu, extra);
5612 cds_ssr_unprotect(__func__);
5613
5614 return ret;
5615}
5616
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005617struct class_a_stats {
5618 tCsrGlobalClassAStatsInfo class_a_stats;
5619};
5620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621/**
5622 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005623 * @stats: pointer to Class A stats
5624 * @context: user context originally registered with SME (always the
5625 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626 *
5627 * Return: None
5628 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005629static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005630{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005631 struct hdd_request *request;
5632 struct class_a_stats *priv;
5633 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005635 ENTER();
5636 if ((NULL == stats) || (NULL == context)) {
5637 hdd_err("Bad param, stats [%p] context [%p]",
5638 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 return;
5640 }
5641
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005642 request = hdd_request_get(context);
5643 if (!request) {
5644 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645 return;
5646 }
5647
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005648 returned_stats = stats;
5649 priv = hdd_request_priv(request);
5650 priv->class_a_stats = *returned_stats;
5651 hdd_request_complete(request);
5652 hdd_request_put(request);
5653 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654}
5655
5656/**
5657 * wlan_hdd_get_class_astats() - Get Class A statistics
5658 * @pAdapter: adapter for which statistics are desired
5659 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305660 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305662QDF_STATUS wlan_hdd_get_class_astats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663{
5664 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305665 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005666 int ret;
5667 void *cookie;
5668 struct hdd_request *request;
5669 struct class_a_stats *priv;
5670 static const struct hdd_request_params params = {
5671 .priv_size = sizeof(*priv),
5672 .timeout_ms = WLAN_WAIT_TIME_STATS,
5673 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005674
5675 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005676 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305677 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 }
Prashanth Bhatta9e143052015-12-04 11:56:47 -08005679 if (cds_is_driver_recovering()) {
5680 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
5681 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305682 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005683 }
5684
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005685 request = hdd_request_alloc(&params);
5686 if (!request) {
5687 hdd_err("Request allocation failure");
5688 return QDF_STATUS_E_NOMEM;
5689 }
5690 cookie = hdd_request_cookie(request);
5691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 /* query only for Class A statistics (which include link speed) */
5693 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
5694 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
5695 hdd_get_class_a_statistics_cb,
5696 0, /* not periodic */
5697 false, /* non-cached results */
5698 pHddStaCtx->conn_info.staId[0],
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005699 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305700 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07005701 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005702 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005703 }
5704
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005705 /* request was sent -- wait for the response */
5706 ret = hdd_request_wait_for_response(request);
5707 if (ret) {
5708 hdd_warn("SME timed out while retrieving Class A statistics");
5709 goto return_cached_results;
5710 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005711
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08005712 /* update the adapter with the fresh results */
5713 priv = hdd_request_priv(request);
5714 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
5715
5716return_cached_results:
5717 /*
5718 * either we never sent a request, we sent a request and
5719 * received a response or we sent a request and timed out.
5720 * regardless we are done with the request.
5721 */
5722 hdd_request_put(request);
5723
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305724 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725}
5726
Jeff Johnsondda167c2017-01-23 10:37:57 -08005727struct station_stats {
5728 tCsrSummaryStatsInfo summary_stats;
5729 tCsrGlobalClassAStatsInfo class_a_stats;
5730 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
5731};
5732
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005733/**
5734 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08005735 * @stats: pointer to combined station stats
5736 * @context: user context originally registered with SME (always the
5737 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005738 *
5739 * Return: None
5740 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08005741static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742{
Jeff Johnsondda167c2017-01-23 10:37:57 -08005743 struct hdd_request *request;
5744 struct station_stats *priv;
5745 tCsrSummaryStatsInfo *summary_stats;
5746 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05305747 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748
Jeff Johnsondda167c2017-01-23 10:37:57 -08005749 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005750 hdd_err("Bad param, pStats [%p] pContext [%p]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08005751 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752 return;
5753 }
5754
Jeff Johnsondda167c2017-01-23 10:37:57 -08005755 request = hdd_request_get(context);
5756 if (!request) {
5757 hdd_err("Obsolete request");
5758 return;
5759 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005760
Jeff Johnsondda167c2017-01-23 10:37:57 -08005761 summary_stats = (tCsrSummaryStatsInfo *) stats;
5762 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05305763 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08005764 (class_a_stats + 1);
5765 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005766
5767 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08005768 priv->summary_stats = *summary_stats;
5769 priv->class_a_stats = *class_a_stats;
5770 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771
Jeff Johnsondda167c2017-01-23 10:37:57 -08005772 hdd_request_complete(request);
5773 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005774}
5775
5776/**
5777 * wlan_hdd_get_station_stats() - Get station statistics
5778 * @pAdapter: adapter for which statistics are desired
5779 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305780 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305782QDF_STATUS wlan_hdd_get_station_stats(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783{
5784 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305785 QDF_STATUS hstatus;
Jeff Johnsondda167c2017-01-23 10:37:57 -08005786 int ret;
5787 void *cookie;
5788 struct hdd_request *request;
5789 struct station_stats *priv;
5790 static const struct hdd_request_params params = {
5791 .priv_size = sizeof(*priv),
5792 .timeout_ms = WLAN_WAIT_TIME_STATS,
5793 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794
5795 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005796 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305797 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005798 }
5799
Jeff Johnsondda167c2017-01-23 10:37:57 -08005800 request = hdd_request_alloc(&params);
5801 if (!request) {
5802 hdd_err("Request allocation failure");
5803 return QDF_STATUS_E_NOMEM;
5804 }
5805 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806
5807 /* query only for Summary & Class A statistics */
5808 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
5809 eCSR_HDD,
5810 SME_SUMMARY_STATS |
Himanshu Agarwal37e42412016-07-21 14:35:09 +05305811 SME_GLOBAL_CLASSA_STATS |
5812 SME_PER_CHAIN_RSSI_STATS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 hdd_get_station_statistics_cb,
5814 0, /* not periodic */
5815 false, /* non-cached results */
5816 pHddStaCtx->conn_info.staId[0],
Jeff Johnsondda167c2017-01-23 10:37:57 -08005817 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305818 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005819 hdd_err("Unable to retrieve statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820 /* we'll return with cached values */
5821 } else {
5822 /* request was sent -- wait for the response */
Jeff Johnsondda167c2017-01-23 10:37:57 -08005823 ret = hdd_request_wait_for_response(request);
5824 if (ret) {
5825 hdd_warn("SME timed out while retrieving statistics");
5826 /* we'll returned a cached value below */
5827 } else {
5828 /* update the adapter with the fresh results */
5829 priv = hdd_request_priv(request);
5830 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
5831 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
5832 pAdapter->hdd_stats.per_chain_rssi_stats =
5833 priv->per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005834 }
5835 }
5836
Jeff Johnsondda167c2017-01-23 10:37:57 -08005837 /*
5838 * either we never sent a request, we sent a request and
5839 * received a response or we sent a request and timed out.
5840 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08005842 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005843
5844 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305845 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005846}
5847
5848/**
5849 * iw_get_linkspeed() - Get current link speed ioctl
5850 * @dev: device upon which the ioctl was received
5851 * @info: ioctl request information
5852 * @wrqu: ioctl request data
5853 * @extra: extra ioctl buffer
5854 *
5855 * Return: 0 on success, non-zero on error
5856 */
5857static int __iw_get_linkspeed(struct net_device *dev,
5858 struct iw_request_info *info,
5859 union iwreq_data *wrqu, char *extra)
5860{
5861 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5862 char *pLinkSpeed = (char *)extra;
5863 int len = sizeof(uint32_t) + 1;
5864 uint32_t link_speed = 0;
5865 hdd_context_t *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08005866 int ret;
5867 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08005869 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305870
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08005872 ret = wlan_hdd_validate_context(hdd_ctx);
5873 if (0 != ret)
5874 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005875
Jeff Johnson441e1f72017-02-07 08:50:49 -08005876 ret = hdd_check_private_wext_control(hdd_ctx, info);
5877 if (0 != ret)
5878 return ret;
5879
5880 ret = wlan_hdd_get_link_speed(pAdapter, &link_speed);
5881 if (0 != ret) {
5882 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005883 }
5884
5885 wrqu->data.length = len;
5886 /* return the linkspeed as a string */
5887 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
5888 if ((rc < 0) || (rc >= len)) {
5889 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07005890 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 return -EIO;
5892 }
5893
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05305894 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005895 /* a value is being successfully returned */
5896 return 0;
5897}
5898
5899static int iw_get_linkspeed(struct net_device *dev,
5900 struct iw_request_info *info,
5901 union iwreq_data *wrqu, char *extra)
5902{
5903 int ret;
5904
5905 cds_ssr_protect(__func__);
5906 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
5907 cds_ssr_unprotect(__func__);
5908
5909 return ret;
5910}
5911
5912/**
5913 * wlan_hdd_change_country_code_callback() - Change country code callback
5914 * @context: opaque context originally passed to SME. All functions
5915 * which use this callback pass the adapter upon which the country
5916 * code change is active
5917 *
5918 * This function is registered as the callback function when
5919 * sme_change_country_code() is invoked. Callers of
5920 * sme_change_country_code() subsequently wait for the adapter's
5921 * @change_country_code completion variable, so all this function
5922 * needs to do is set that completion variable so that execution can
5923 * continue.
5924 *
5925 * Return: none
5926 */
5927void wlan_hdd_change_country_code_callback(void *context)
5928{
5929
5930 hdd_adapter_t *adapter = context;
5931
5932 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
5933 complete(&adapter->change_country_code);
5934
5935 return;
5936}
5937
5938/**
5939 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
5940 * @dev: device upon which the ioctl was received
5941 * @info: ioctl request information
5942 * @wrqu: ioctl request data
5943 * @extra: ioctl extra data
5944 *
5945 * Return: 0 on success, non-zero on error
5946 */
5947static int __iw_set_nick(struct net_device *dev,
5948 struct iw_request_info *info,
5949 union iwreq_data *wrqu, char *extra)
5950{
5951 hdd_adapter_t *adapter;
5952 hdd_context_t *hdd_ctx;
5953 int ret;
5954
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005955 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956
5957 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5958 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5959 ret = wlan_hdd_validate_context(hdd_ctx);
5960 if (0 != ret)
5961 return ret;
5962
Jeff Johnson441e1f72017-02-07 08:50:49 -08005963 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5964 if (0 != ret)
5965 return ret;
5966
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005967 return 0;
5968}
5969
5970/**
5971 * iw_set_nick() - SSR wrapper for __iw_set_nick
5972 * @dev: pointer to net_device
5973 * @info: pointer to iw_request_info
5974 * @wrqu: pointer to iwreq_data
5975 * @extra: extra
5976 *
5977 * Return: 0 on success, error number otherwise
5978 */
5979static int iw_set_nick(struct net_device *dev,
5980 struct iw_request_info *info,
5981 union iwreq_data *wrqu, char *extra)
5982{
5983 int ret;
5984
5985 cds_ssr_protect(__func__);
5986 ret = __iw_set_nick(dev, info, wrqu, extra);
5987 cds_ssr_unprotect(__func__);
5988
5989 return ret;
5990}
5991
5992/**
5993 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
5994 * @dev: device upon which the ioctl was received
5995 * @info: ioctl request information
5996 * @wrqu: ioctl request data
5997 * @extra: ioctl extra data
5998 *
5999 * Return: 0 on success, non-zero on error
6000 */
6001static int __iw_get_nick(struct net_device *dev,
6002 struct iw_request_info *info,
6003 union iwreq_data *wrqu, char *extra)
6004{
6005 hdd_adapter_t *adapter;
6006 hdd_context_t *hdd_ctx;
6007 int ret;
6008
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006009 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010
6011 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6012 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6013 ret = wlan_hdd_validate_context(hdd_ctx);
6014 if (0 != ret)
6015 return ret;
6016
Jeff Johnson441e1f72017-02-07 08:50:49 -08006017 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6018 if (0 != ret)
6019 return ret;
6020
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021 return 0;
6022}
6023
6024/**
6025 * iw_get_nick() - SSR wrapper for __iw_get_nick
6026 * @dev: pointer to net_device
6027 * @info: pointer to iw_request_info
6028 * @wrqu: pointer to iwreq_data
6029 * @extra: extra
6030 *
6031 * Return: 0 on success, error number otherwise
6032 */
6033static int iw_get_nick(struct net_device *dev,
6034 struct iw_request_info *info,
6035 union iwreq_data *wrqu, char *extra)
6036{
6037 int ret;
6038
6039 cds_ssr_protect(__func__);
6040 ret = __iw_get_nick(dev, info, wrqu, extra);
6041 cds_ssr_unprotect(__func__);
6042
6043 return ret;
6044}
6045
6046/**
6047 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
6048 * @dev: device upon which the ioctl was received
6049 * @info: ioctl request information
6050 * @wrqu: ioctl request data
6051 * @extra: ioctl extra data
6052 *
6053 * Return: 0 on success, non-zero on error
6054 */
6055static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6056 union iwreq_data *wrqu, char *extra)
6057{
6058 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6059 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6060 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6061 hdd_context_t *hdd_ctx;
6062 struct iw_point *encoderq = &(wrqu->encoding);
6063 uint32_t keyId;
6064 uint8_t key_length;
6065 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6066 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306067 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006068 int ret;
6069
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006070 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071
6072 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6073 ret = wlan_hdd_validate_context(hdd_ctx);
6074 if (0 != ret)
6075 return ret;
6076
Jeff Johnson441e1f72017-02-07 08:50:49 -08006077 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6078 if (0 != ret)
6079 return ret;
6080
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 keyId = encoderq->flags & IW_ENCODE_INDEX;
6082
6083 if (keyId) {
6084 if (keyId > MAX_WEP_KEYS) {
6085 return -EINVAL;
6086 }
6087
6088 fKeyPresent = 1;
6089 keyId--;
6090 } else {
6091 fKeyPresent = 0;
6092 }
6093
6094 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006095 hdd_notice("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006096 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006097 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
6098 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099 }
6100 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6101 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6102 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6103 eCSR_ENCRYPT_TYPE_NONE;
6104 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6105 eCSR_ENCRYPT_TYPE_NONE;
6106
6107 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6108 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6109
6110 if (eConnectionState_Associated ==
6111 pHddStaCtx->conn_info.connState) {
6112 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6113 status =
6114 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
6115 pAdapter->sessionId,
6116 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306117 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006118 unsigned long rc;
6119 rc = wait_for_completion_timeout(&pAdapter->
6120 disconnect_comp_var,
6121 msecs_to_jiffies
6122 (WLAN_WAIT_TIME_DISCONNECT));
6123 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07006124 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006125 }
6126 }
6127
6128 return status;
6129
6130 }
6131
6132 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006133 hdd_notice("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006134
6135 pHddStaCtx->conn_info.authType =
6136 (encoderq->
6137 flags & IW_ENCODE_RESTRICTED) ? eCSR_AUTH_TYPE_SHARED_KEY :
6138 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6139
6140 }
6141
6142 if (wrqu->data.length > 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006143 hdd_notice("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006144
6145 key_length = wrqu->data.length;
6146
6147 /* IW_ENCODING_TOKEN_MAX is the value that is set for wrqu->data.length by iwconfig.c when 'iwconfig wlan0 key on' is issued. */
6148
6149 if (5 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006150 hdd_notice("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006151 key_length);
6152
6153 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6154 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6155 pHddStaCtx->conn_info.authType)) {
6156 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
6157 } else {
6158 encryptionType =
6159 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6160 }
6161 } else if (13 == key_length) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006162 hdd_notice("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163 key_length);
6164
6165 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6166 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6167 pHddStaCtx->conn_info.authType)) {
6168 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
6169 } else {
6170 encryptionType =
6171 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6172 }
6173 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006174 hdd_warn("Invalid WEP key length :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006175 key_length);
6176 return -EINVAL;
6177 }
6178
6179 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6180 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
6181 pWextState->roamProfile.EncryptionType.numEntries = 1;
6182 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6183 encryptionType;
6184 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
6185 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6186 encryptionType;
6187
6188 if ((eConnectionState_NotConnected ==
6189 pHddStaCtx->conn_info.connState)
6190 &&
6191 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6192 pHddStaCtx->conn_info.authType)
6193 || (eCSR_AUTH_TYPE_SHARED_KEY ==
6194 pHddStaCtx->conn_info.authType))) {
6195
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306196 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006197 KeyMaterial[keyId][0], extra, key_length);
6198
6199 pWextState->roamProfile.Keys.KeyLength[keyId] =
6200 (uint8_t) key_length;
6201 pWextState->roamProfile.Keys.defaultIndex =
6202 (uint8_t) keyId;
6203
6204 return status;
6205 }
6206 }
6207
6208 return 0;
6209}
6210
6211/**
6212 * iw_set_encode() - SSR wrapper for __iw_set_encode()
6213 * @dev: pointer to net_device
6214 * @info: pointer to iw_request_info
6215 * @wrqu: pointer to iwreq_data
6216 * @extra: pointer to extra ioctl payload
6217 *
6218 * Return: 0 on success, error number otherwise
6219 */
6220static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6221 union iwreq_data *wrqu, char *extra)
6222{
6223 int ret;
6224
6225 cds_ssr_protect(__func__);
6226 ret = __iw_set_encode(dev, info, wrqu, extra);
6227 cds_ssr_unprotect(__func__);
6228
6229 return ret;
6230}
6231
6232/**
6233 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
6234 * @dev: device upon which the ioctl was received
6235 * @info: ioctl request information
6236 * @wrqu: ioctl request data
6237 * @extra: ioctl extra data
6238 *
6239 * Return: 0 on success, non-zero on error
6240 */
6241static int __iw_get_encodeext(struct net_device *dev,
6242 struct iw_request_info *info,
6243 struct iw_point *dwrq, char *extra)
6244{
6245 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6246 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6247 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
6248 int keyId;
6249 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6250 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
6251 int i, ret;
6252 hdd_context_t *hdd_ctx;
6253
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006254 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006255
6256 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6257 ret = wlan_hdd_validate_context(hdd_ctx);
6258 if (0 != ret)
6259 return ret;
6260
Jeff Johnson441e1f72017-02-07 08:50:49 -08006261 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6262 if (0 != ret)
6263 return ret;
6264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265 keyId = pRoamProfile->Keys.defaultIndex;
6266
6267 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006268 hdd_notice("Invalid keyId : %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006269 return -EINVAL;
6270 }
6271
6272 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
6273 dwrq->flags |= IW_ENCODE_ENABLED;
6274 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306275 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006276 pRoamProfile->Keys.KeyLength[keyId]);
6277 } else {
6278 dwrq->flags |= IW_ENCODE_DISABLED;
6279 }
6280
6281 for (i = 0; i < MAX_WEP_KEYS; i++) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006282 if (pRoamProfile->Keys.KeyLength[i] == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006283 continue;
6284 } else {
6285 break;
6286 }
6287 }
6288
6289 if (MAX_WEP_KEYS == i) {
6290 dwrq->flags |= IW_ENCODE_NOKEY;
6291 } else {
6292 dwrq->flags |= IW_ENCODE_ENABLED;
6293 }
6294
6295 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
6296
6297 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType) {
6298 dwrq->flags |= IW_ENCODE_DISABLED;
6299 }
6300
6301 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
6302
6303 if (IW_AUTH_ALG_OPEN_SYSTEM == authType) {
6304 dwrq->flags |= IW_ENCODE_OPEN;
6305 } else {
6306 dwrq->flags |= IW_ENCODE_RESTRICTED;
6307 }
6308 EXIT();
6309 return 0;
6310
6311}
6312
6313/**
6314 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
6315 * @dev: pointer to net_device
6316 * @info: pointer to iw_request_info
6317 * @dwrq: pointer to encoding information
6318 * @extra: pointer to extra ioctl payload
6319 *
6320 * Return: 0 on success, error number otherwise
6321 */
6322static int iw_get_encodeext(struct net_device *dev,
6323 struct iw_request_info *info,
6324 struct iw_point *dwrq, char *extra)
6325{
6326 int ret;
6327
6328 cds_ssr_protect(__func__);
6329 ret = __iw_get_encodeext(dev, info, dwrq, extra);
6330 cds_ssr_unprotect(__func__);
6331
6332 return ret;
6333}
6334
6335/**
6336 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
6337 * @dev: device upon which the ioctl was received
6338 * @info: ioctl request information
6339 * @wrqu: ioctl request data
6340 * @extra: ioctl extra data
6341 *
6342 * Return: 0 on success, non-zero on error
6343 */
6344static int __iw_set_encodeext(struct net_device *dev,
6345 struct iw_request_info *info,
6346 union iwreq_data *wrqu, char *extra)
6347{
6348 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6349 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6350 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6351 hdd_context_t *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306352 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006353 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6354 int ret;
6355 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
6356 int key_index;
6357 struct iw_point *encoding = &wrqu->encoding;
6358 tCsrRoamSetKey setKey;
6359 uint32_t roamId = 0xFF;
6360
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006361 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006362
6363 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6364 ret = wlan_hdd_validate_context(hdd_ctx);
6365 if (0 != ret)
6366 return ret;
6367
Jeff Johnson441e1f72017-02-07 08:50:49 -08006368 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6369 if (0 != ret)
6370 return ret;
6371
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006372 key_index = encoding->flags & IW_ENCODE_INDEX;
6373
6374 if (key_index > 0) {
6375
6376 /*Convert from 1-based to 0-based keying */
6377 key_index--;
6378 }
6379 if (!ext->key_len) {
6380
6381 /*Set the encrytion type to NONE */
6382 pRoamProfile->EncryptionType.encryptionType[0] =
6383 eCSR_ENCRYPT_TYPE_NONE;
6384 return ret;
6385 }
6386
6387 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
6388 (IW_ENCODE_ALG_WEP == ext->alg)) {
6389 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
6390
Jeff Johnson99bac312016-06-28 10:38:18 -07006391 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006392 return -EINVAL;
Jeff Johnson68755312017-02-10 11:46:55 -08006393 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006394
Jeff Johnson68755312017-02-10 11:46:55 -08006395 /*Static wep, update the roam profile with the keys */
6396 if (ext->key_len &&
6397 (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
6398 key_index < CSR_MAX_NUM_KEY) {
6399 qdf_mem_copy(&pRoamProfile->Keys.
6400 KeyMaterial[key_index][0],
6401 ext->key, ext->key_len);
6402 pRoamProfile->Keys.KeyLength[key_index] =
6403 (uint8_t) ext->key_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006404
Jeff Johnson68755312017-02-10 11:46:55 -08006405 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
6406 pRoamProfile->Keys.defaultIndex =
6407 (uint8_t) key_index;
6408
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006409 }
6410 return ret;
6411 }
6412
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306413 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006414
6415 setKey.keyId = key_index;
6416 setKey.keyLength = ext->key_len;
6417
6418 if (ext->key_len <= CSR_MAX_KEY_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306419 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006420 }
6421
6422 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
6423 /*Key direction for group is RX only */
6424 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05306425 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006426 } else {
6427
6428 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306429 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306430 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006431 }
6432
6433 /*For supplicant pae role is zero */
6434 setKey.paeRole = 0;
6435
6436 switch (ext->alg) {
6437 case IW_ENCODE_ALG_NONE:
6438 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6439 break;
6440
6441 case IW_ENCODE_ALG_WEP:
6442 setKey.encType =
6443 (ext->key_len ==
6444 5) ? eCSR_ENCRYPT_TYPE_WEP40 : eCSR_ENCRYPT_TYPE_WEP104;
6445 break;
6446
6447 case IW_ENCODE_ALG_TKIP:
6448 {
6449 uint8_t *pKey = &setKey.Key[0];
6450
6451 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
6452
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306453 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006454
6455 /* Supplicant sends the 32bytes key in this order
6456 * |--------------|----------|----------|
6457 * | Tk1 | TX MIC | RX MIC |
6458 * |--------------|----------|----------|
6459 * <---16bytes---><--8bytes--><--8bytes-->
6460 *
6461 *
6462 * Sme expects the 32 bytes key to be in the below order
6463 * |--------------|----------|----------|
6464 * | Tk1 | RX MIC | TX MIC |
6465 * |--------------|----------|----------|
6466 * <---16bytes---><--8bytes--><--8bytes-->
6467 */
6468
6469 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306470 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006471
6472 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306473 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006474
6475 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306476 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006477
6478 }
6479 break;
6480
6481 case IW_ENCODE_ALG_CCMP:
6482 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
6483 break;
6484
6485#ifdef FEATURE_WLAN_ESE
6486#define IW_ENCODE_ALG_KRK 6
6487 case IW_ENCODE_ALG_KRK:
6488 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
6489 break;
6490#endif /* FEATURE_WLAN_ESE */
6491
6492 default:
6493 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
6494 break;
6495 }
6496
Jeff Johnson99bac312016-06-28 10:38:18 -07006497 hdd_notice("cipher_alg:%d key_len:%d EncryptionType:%d",
6498 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006499
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006500 /* The supplicant may attempt to set the PTK once
6501 * pre-authentication is done. Save the key in the UMAC and
6502 * include it in the ADD BSS request
6503 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306504 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006505 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306506 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006507 hdd_info("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006508 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306509 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006510 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006511 return -EINVAL;
6512 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006513
6514 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6515
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306516 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006517 pAdapter->sessionId,
6518 &setKey, &roamId);
6519
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306520 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006521 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306522 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006523
6524 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6525 }
6526
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306527 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006528}
6529
6530/**
6531 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
6532 * @dev: pointer to net_device
6533 * @info: pointer to iw_request_info
6534 * @wrqu: pointer to iwreq_data
6535 * @extra: pointer to extra ioctl payload
6536 *
6537 * Return: 0 on success, error number otherwise
6538 */
6539static int iw_set_encodeext(struct net_device *dev,
6540 struct iw_request_info *info,
6541 union iwreq_data *wrqu, char *extra)
6542{
6543 int ret;
6544
6545 cds_ssr_protect(__func__);
6546 ret = __iw_set_encodeext(dev, info, wrqu, extra);
6547 cds_ssr_unprotect(__func__);
6548
6549 return ret;
6550}
6551
6552/**
6553 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
6554 * @dev: device upon which the ioctl was received
6555 * @info: ioctl request information
6556 * @wrqu: ioctl request data
6557 * @extra: ioctl extra data
6558 *
6559 * Return: 0 on success, non-zero on error
6560 */
6561static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
6562 union iwreq_data *wrqu, char *extra)
6563{
6564 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6565 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6566 hdd_context_t *hdd_ctx;
6567 int ret;
6568
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006569 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006570
6571 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6572 ret = wlan_hdd_validate_context(hdd_ctx);
6573 if (0 != ret)
6574 return ret;
6575
Jeff Johnson441e1f72017-02-07 08:50:49 -08006576 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6577 if (0 != ret)
6578 return ret;
6579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006580 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
6581 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
6582
Jeff Johnson99bac312016-06-28 10:38:18 -07006583 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006584
6585 return -EINVAL;
6586 }
6587
6588 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
6589
6590 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
6591 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
6592 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306593 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006594 hdd_err("failed to set ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006595 return -EIO;
6596 }
6597 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
6598 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6599 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306600 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05306601 hdd_err("failed to set ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006602 return -EIO;
6603 }
6604 }
6605 } else {
6606 return -EOPNOTSUPP;
6607 }
6608
Jeff Johnson99bac312016-06-28 10:38:18 -07006609 hdd_notice("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006610
6611 EXIT();
6612
6613 return 0;
6614
6615}
6616
6617/**
6618 * iw_set_retry() - SSR wrapper for __iw_set_retry()
6619 * @dev: pointer to net_device
6620 * @info: pointer to iw_request_info
6621 * @wrqu: pointer to iwreq_data
6622 * @extra: pointer to extra ioctl payload
6623 *
6624 * Return: 0 on success, error number otherwise
6625 */
6626static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
6627 union iwreq_data *wrqu, char *extra)
6628{
6629 int ret;
6630
6631 cds_ssr_protect(__func__);
6632 ret = __iw_set_retry(dev, info, wrqu, extra);
6633 cds_ssr_unprotect(__func__);
6634
6635 return ret;
6636}
6637
6638/**
6639 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
6640 * @dev: device upon which the ioctl was received
6641 * @info: ioctl request information
6642 * @wrqu: ioctl request data
6643 * @extra: ioctl extra data
6644 *
6645 * Return: 0 on success, non-zero on error
6646 */
6647static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
6648 union iwreq_data *wrqu, char *extra)
6649{
6650 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6651 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6652 uint32_t retry = 0;
6653 hdd_context_t *hdd_ctx;
6654 int ret;
6655
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006656 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006657
6658 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6659 ret = wlan_hdd_validate_context(hdd_ctx);
6660 if (0 != ret)
6661 return ret;
6662
Jeff Johnson441e1f72017-02-07 08:50:49 -08006663 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6664 if (0 != ret)
6665 return ret;
6666
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006667 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
6668 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
6669
6670 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306671 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006672 hdd_warn("failed to get ini parameter, WNI_CFG_LONG_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006673 return -EIO;
6674 }
6675
6676 wrqu->retry.value = retry;
6677 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
6678 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
6679
6680 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306681 QDF_STATUS_SUCCESS) {
Anurag Chouhand29e7602016-10-17 15:20:22 +05306682 hdd_warn("failed to get ini parameter, WNI_CFG_SHORT_RETRY_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006683 return -EIO;
6684 }
6685
6686 wrqu->retry.value = retry;
6687 } else {
6688 return -EOPNOTSUPP;
6689 }
6690
Jeff Johnson99bac312016-06-28 10:38:18 -07006691 hdd_notice("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006692
6693 EXIT();
6694
6695 return 0;
6696}
6697
6698/**
6699 * iw_get_retry() - SSR wrapper for __iw_get_retry()
6700 * @dev: pointer to net_device
6701 * @info: pointer to iw_request_info
6702 * @wrqu: pointer to iwreq_data
6703 * @extra: pointer to extra ioctl payload
6704 *
6705 * Return: 0 on success, error number otherwise
6706 */
6707static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
6708 union iwreq_data *wrqu, char *extra)
6709{
6710 int ret;
6711
6712 cds_ssr_protect(__func__);
6713 ret = __iw_get_retry(dev, info, wrqu, extra);
6714 cds_ssr_unprotect(__func__);
6715
6716 return ret;
6717}
6718
6719/**
6720 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
6721 * @dev: device upon which the ioctl was received
6722 * @info: ioctl request information
6723 * @wrqu: ioctl request data
6724 * @extra: ioctl extra data
6725 *
6726 * Return: 0 on success, non-zero on error
6727 */
6728static int __iw_set_mlme(struct net_device *dev,
6729 struct iw_request_info *info,
6730 union iwreq_data *wrqu, char *extra)
6731{
6732 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6733 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6734 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306735 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006736 hdd_context_t *hdd_ctx;
6737 int ret;
6738
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006739 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006740
6741 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6742 ret = wlan_hdd_validate_context(hdd_ctx);
6743 if (0 != ret)
6744 return ret;
6745
Jeff Johnson441e1f72017-02-07 08:50:49 -08006746 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6747 if (0 != ret)
6748 return ret;
6749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006750 /* reason_code is unused. By default it is set to
6751 * eCSR_DISCONNECT_REASON_UNSPECIFIED
6752 */
6753 switch (mlme->cmd) {
6754 case IW_MLME_DISASSOC:
6755 case IW_MLME_DEAUTH:
6756
6757 if (pHddStaCtx->conn_info.connState ==
6758 eConnectionState_Associated) {
6759 eCsrRoamDisconnectReason reason =
6760 eCSR_DISCONNECT_REASON_UNSPECIFIED;
6761
6762 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
6763 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
6764
6765 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6766 status =
6767 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
6768 pAdapter->sessionId, reason);
6769
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306770 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006771 unsigned long rc;
6772 rc = wait_for_completion_timeout(&pAdapter->
6773 disconnect_comp_var,
6774 msecs_to_jiffies
6775 (WLAN_WAIT_TIME_DISCONNECT));
6776 if (!rc)
Jeff Johnson99bac312016-06-28 10:38:18 -07006777 hdd_err("failed wait on disconnect_comp_var");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006778 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07006779 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
6780 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006781
6782 /* Resetting authKeyMgmt */
6783 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
6784 0;
6785
Jeff Johnson99bac312016-06-28 10:38:18 -07006786 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006787 wlan_hdd_netif_queue_control(pAdapter,
6788 WLAN_NETIF_TX_DISABLE_N_CARRIER,
6789 WLAN_CONTROL_PATH);
6790
6791 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07006792 hdd_err("%d Command Disassociate/Deauthenticate called but station is not in associated state",
6793 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006794 }
6795 break;
6796 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07006797 hdd_err("%d Command should be Disassociate/Deauthenticate",
6798 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006799 return -EINVAL;
6800 } /* end of switch */
6801
6802 EXIT();
6803
6804 return status;
6805
6806}
6807
6808/**
6809 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
6810 * @dev: pointer to net_device
6811 * @info: pointer to iw_request_info
6812 * @wrqu: pointer to iwreq_data
6813 * @extra: pointer to extra ioctl payload
6814 *
6815 * Return: 0 on success, error number otherwise
6816 */
6817static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
6818 union iwreq_data *wrqu, char *extra)
6819{
6820 int ret;
6821
6822 cds_ssr_protect(__func__);
6823 ret = __iw_set_mlme(dev, info, wrqu, extra);
6824 cds_ssr_unprotect(__func__);
6825
6826 return ret;
6827}
6828
6829/**
6830 * wlan_hdd_update_phymode() - handle change in PHY mode
6831 * @net: device upon which PHY mode change was received
6832 * @hal: umac handle for the driver
6833 * @new_phymode: new PHY mode for the device
6834 * @phddctx: pointer to the HDD context
6835 *
6836 * This function is called when the device is set to a new PHY mode.
6837 * It takes a holistic look at the desired PHY mode along with the
6838 * configured capabilities of the driver and the reported capabilities
6839 * of the hardware in order to correctly configure all PHY-related
6840 * parameters.
6841 *
6842 * Return: 0 on success, negative errno value on error
6843 */
6844int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
6845 int new_phymode, hdd_context_t *phddctx)
6846{
6847#ifdef QCA_HT_2040_COEX
6848 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306849 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006850#endif
6851 bool band_24 = false, band_5g = false;
6852 bool ch_bond24 = false, ch_bond5g = false;
6853 tSmeConfigParams smeconfig;
6854 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006855 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006856 eCsrPhyMode phymode = -EIO, old_phymode;
6857 eHddDot11Mode hdd_dot11mode = phddctx->config->dot11Mode;
6858 eCsrBand curr_band = eCSR_BAND_ALL;
6859
6860 old_phymode = sme_get_phy_mode(hal);
6861
6862 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
6863 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
6864 nChannelBondingMode24GHz))
6865 ch_bond24 = true;
6866
6867 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
6868 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
6869 nChannelBondingMode5GHz))
6870 ch_bond5g = true;
6871
6872 if (phddctx->config->nBandCapability == eCSR_BAND_ALL) {
6873 band_24 = band_5g = true;
6874 } else if (phddctx->config->nBandCapability == eCSR_BAND_24) {
6875 band_24 = true;
6876 } else if (phddctx->config->nBandCapability == eCSR_BAND_5G) {
6877 band_5g = true;
6878 }
6879
6880 vhtchanwidth = phddctx->config->vhtChannelWidth;
Jeff Johnson99bac312016-06-28 10:38:18 -07006881 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 -08006882 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
6883
6884 switch (new_phymode) {
6885 case IEEE80211_MODE_AUTO:
6886 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
6887 if (hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
6888 phymode = eCSR_DOT11_MODE_AUTO;
6889 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
6890 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
6891 curr_band = eCSR_BAND_ALL;
6892 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
6893 } else {
6894 sme_set_phy_mode(hal, old_phymode);
6895 return -EIO;
6896 }
6897 break;
6898 case IEEE80211_MODE_11A:
6899 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
6900 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
6901 phymode = eCSR_DOT11_MODE_11a;
6902 hdd_dot11mode = eHDD_DOT11_MODE_11a;
6903 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
6904 curr_band = eCSR_BAND_5G;
6905 } else {
6906 sme_set_phy_mode(hal, old_phymode);
6907 return -EIO;
6908 }
6909 break;
6910 case IEEE80211_MODE_11B:
6911 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
6912 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
6913 phymode = eCSR_DOT11_MODE_11b;
6914 hdd_dot11mode = eHDD_DOT11_MODE_11b;
6915 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
6916 curr_band = eCSR_BAND_24;
6917 } else {
6918 sme_set_phy_mode(hal, old_phymode);
6919 return -EIO;
6920 }
6921 break;
6922 case IEEE80211_MODE_11G:
6923 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
6924 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
6925 phymode = eCSR_DOT11_MODE_11g;
6926 hdd_dot11mode = eHDD_DOT11_MODE_11g;
6927 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
6928 curr_band = eCSR_BAND_24;
6929 } else {
6930 sme_set_phy_mode(hal, old_phymode);
6931 return -EIO;
6932 }
6933 break;
6934 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
6935 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
6936 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
6937 */
6938 case IEEE80211_MODE_11NA_HT20:
6939 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
6940 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
6941 phymode = eCSR_DOT11_MODE_11n;
6942 hdd_dot11mode = eHDD_DOT11_MODE_11n;
6943 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
6944 curr_band = eCSR_BAND_5G;
6945 } else {
6946 sme_set_phy_mode(hal, old_phymode);
6947 return -EIO;
6948 }
6949 break;
6950 case IEEE80211_MODE_11NA_HT40:
6951 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
6952 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
6953 phymode = eCSR_DOT11_MODE_11n;
6954 hdd_dot11mode = eHDD_DOT11_MODE_11n;
6955 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
6956 curr_band = eCSR_BAND_5G;
6957 } else {
6958 sme_set_phy_mode(hal, old_phymode);
6959 return -EIO;
6960 }
6961 break;
6962 case IEEE80211_MODE_11NG_HT20:
6963 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
6964 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
6965 phymode = eCSR_DOT11_MODE_11n;
6966 hdd_dot11mode = eHDD_DOT11_MODE_11n;
6967 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
6968 curr_band = eCSR_BAND_24;
6969 } else {
6970 sme_set_phy_mode(hal, old_phymode);
6971 return -EIO;
6972 }
6973 break;
6974 case IEEE80211_MODE_11NG_HT40:
6975 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
6976 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
6977 phymode = eCSR_DOT11_MODE_11n;
6978 hdd_dot11mode = eHDD_DOT11_MODE_11n;
6979 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
6980 curr_band = eCSR_BAND_24;
6981 } else {
6982 sme_set_phy_mode(hal, old_phymode);
6983 return -EIO;
6984 }
6985 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006986 case IEEE80211_MODE_11AC_VHT20:
6987 case IEEE80211_MODE_11AC_VHT40:
6988 case IEEE80211_MODE_11AC_VHT80:
6989 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
6990 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
6991 phymode = eCSR_DOT11_MODE_11ac;
6992 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
6993 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
6994 curr_band = eCSR_BAND_5G;
6995 } else {
6996 sme_set_phy_mode(hal, old_phymode);
6997 return -EIO;
6998 }
6999 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007000 case IEEE80211_MODE_2G_AUTO:
7001 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7002 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0)) {
7003 phymode = eCSR_DOT11_MODE_AUTO;
7004 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7005 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7006 curr_band = eCSR_BAND_24;
7007 } else {
7008 sme_set_phy_mode(hal, old_phymode);
7009 return -EIO;
7010 }
7011 break;
7012 case IEEE80211_MODE_5G_AUTO:
7013 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
7014 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0)) {
7015 phymode = eCSR_DOT11_MODE_AUTO;
7016 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7017 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7018 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7019 curr_band = eCSR_BAND_5G;
7020 } else {
7021 sme_set_phy_mode(hal, old_phymode);
7022 return -EIO;
7023 }
7024 break;
7025 case IEEE80211_MODE_11AGN:
7026 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
7027 if ((hdd_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0)) {
7028 phymode = eCSR_DOT11_MODE_11n;
7029 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7030 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7031 curr_band = eCSR_BAND_ALL;
7032 } else {
7033 sme_set_phy_mode(hal, old_phymode);
7034 return -EIO;
7035 }
7036 break;
7037 default:
7038 return -EIO;
7039 }
7040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007041 switch (new_phymode) {
7042 case IEEE80211_MODE_11AC_VHT20:
7043 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7044 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
7045 break;
7046 case IEEE80211_MODE_11AC_VHT40:
7047 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
7048 break;
7049 case IEEE80211_MODE_11AC_VHT80:
7050 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7051 break;
7052 default:
7053 vhtchanwidth = phddctx->config->vhtChannelWidth;
7054 break;
7055 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007056
7057 if (phymode != -EIO) {
7058 sme_get_config_param(hal, &smeconfig);
7059 smeconfig.csrConfig.phyMode = phymode;
7060#ifdef QCA_HT_2040_COEX
7061 if (phymode == eCSR_DOT11_MODE_11n &&
7062 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
7063 smeconfig.csrConfig.obssEnabled = false;
7064 halStatus = sme_set_ht2040_mode(hal,
7065 pAdapter->sessionId,
7066 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307067 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007068 hdd_err("Failed to disable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007069 return -EIO;
7070 }
7071 } else if (phymode == eCSR_DOT11_MODE_11n &&
7072 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
7073 smeconfig.csrConfig.obssEnabled = true;
7074 halStatus = sme_set_ht2040_mode(hal,
7075 pAdapter->sessionId,
7076 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307077 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007078 hdd_err("Failed to enable OBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007079 return -EIO;
7080 }
7081 }
7082#endif
7083 smeconfig.csrConfig.eBand = curr_band;
7084 smeconfig.csrConfig.bandCapability = curr_band;
7085 if (curr_band == eCSR_BAND_24)
7086 smeconfig.csrConfig.Is11hSupportEnabled = 0;
7087 else
7088 smeconfig.csrConfig.Is11hSupportEnabled =
7089 phddctx->config->Is11hSupportEnabled;
7090 if (curr_band == eCSR_BAND_24)
7091 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7092 else if (curr_band == eCSR_BAND_24)
7093 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7094 else {
7095 smeconfig.csrConfig.channelBondingMode24GHz = chwidth;
7096 smeconfig.csrConfig.channelBondingMode5GHz = chwidth;
7097 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007098 smeconfig.csrConfig.nVhtChannelWidth = vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007099 sme_update_config(hal, &smeconfig);
7100
7101 phddctx->config->dot11Mode = hdd_dot11mode;
7102 phddctx->config->nBandCapability = curr_band;
7103 phddctx->config->nChannelBondingMode24GHz =
7104 smeconfig.csrConfig.channelBondingMode24GHz;
7105 phddctx->config->nChannelBondingMode5GHz =
7106 smeconfig.csrConfig.channelBondingMode5GHz;
7107 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07007108 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007109 hdd_err("could not update config_dat");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007110 return -EIO;
7111 }
7112 if (phddctx->config->nChannelBondingMode5GHz)
Dustin Browna30892e2016-10-12 17:28:36 -07007113 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007114 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7115 else
Dustin Browna30892e2016-10-12 17:28:36 -07007116 phddctx->wiphy->bands[NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007117 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7118
Jeff Johnson99bac312016-06-28 10:38:18 -07007119 hdd_warn("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007120 phymode, chwidth, curr_band, vhtchanwidth);
7121 }
7122
7123 return 0;
7124}
7125
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007126struct temperature_priv {
7127 int temperature;
7128};
7129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007130/**
7131 * hdd_get_temperature_cb() - "Get Temperature" callback function
7132 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007133 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007134 *
7135 * This function is passed to sme_get_temperature() as the callback
7136 * function to be invoked when the temperature measurement is
7137 * available.
7138 *
7139 * Return: None
7140 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007141static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007142{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007143 struct hdd_request *request;
7144 struct temperature_priv *priv;
7145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007146 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007147
7148 request = hdd_request_get(context);
7149 if (!request) {
7150 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007151 return;
7152 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007153
7154 priv = hdd_request_priv(request);
7155 priv->temperature = temperature;
7156 hdd_request_complete(request);
7157 hdd_request_put(request);
7158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007159 EXIT();
7160}
7161
7162/**
7163 * wlan_hdd_get_temperature() - get current device temperature
7164 * @pAdapter: device upon which the request was made
7165 * @temperature: pointer to where the temperature is to be returned
7166 *
7167 * Return: 0 if a temperature value (either current or cached) was
7168 * returned, otherwise a negative errno is returned.
7169 *
7170 */
7171int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature)
7172{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307173 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007174 int ret;
7175 void *cookie;
7176 struct hdd_request *request;
7177 struct temperature_priv *priv;
7178 static const struct hdd_request_params params = {
7179 .priv_size = sizeof(*priv),
7180 .timeout_ms = WLAN_WAIT_TIME_STATS,
7181 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007182
7183 ENTER();
7184 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007185 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007186 return -EPERM;
7187 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007188
7189 request = hdd_request_alloc(&params);
7190 if (!request) {
7191 hdd_err("Request allocation failure");
7192 return -ENOMEM;
7193 }
7194 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007195 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007196 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307197 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007198 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007199 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007200 ret = hdd_request_wait_for_response(request);
7201 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007202 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007203 } else {
7204 /* update the adapter with the fresh results */
7205 priv = hdd_request_priv(request);
7206 if (priv->temperature)
7207 pAdapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007208 }
7209 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007210
7211 /*
7212 * either we never sent a request, we sent a request and
7213 * received a response or we sent a request and timed out.
7214 * regardless we are done with the request.
7215 */
7216 hdd_request_put(request);
7217
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007218 *temperature = pAdapter->temperature;
7219 EXIT();
7220 return 0;
7221}
7222
7223/**
7224 * iw_setint_getnone() - Generic "set integer" private ioctl handler
7225 * @dev: device upon which the ioctl was received
7226 * @info: ioctl request information
7227 * @wrqu: ioctl request data
7228 * @extra: ioctl extra data
7229 *
7230 * Return: 0 on success, non-zero on error
7231 */
7232static int __iw_setint_getnone(struct net_device *dev,
7233 struct iw_request_info *info,
7234 union iwreq_data *wrqu, char *extra)
7235{
7236 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7237 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7238 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7239 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7240 hdd_context_t *hdd_ctx;
7241 tSmeConfigParams smeConfig;
7242 int *value = (int *)extra;
7243 int sub_cmd = value[0];
7244 int set_value = value[1];
7245 int ret;
7246 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307247 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007248
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007249 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307250
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007251 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7252 ret = wlan_hdd_validate_context(hdd_ctx);
7253 if (0 != ret)
7254 return ret;
7255
Jeff Johnson441e1f72017-02-07 08:50:49 -08007256 ret = hdd_check_private_wext_control(hdd_ctx, info);
7257 if (0 != ret)
7258 return ret;
7259
7260 INIT_COMPLETION(pWextState->completion_var);
7261 memset(&smeConfig, 0x00, sizeof(smeConfig));
7262
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007263 switch (sub_cmd) {
7264 case WE_SET_11D_STATE:
7265 {
7266 if ((ENABLE_11D == set_value)
7267 || (DISABLE_11D == set_value)) {
7268
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007269 sme_get_config_param(hHal, &smeConfig);
7270 smeConfig.csrConfig.Is11dSupportEnabled =
7271 (bool) set_value;
7272
Jeff Johnson99bac312016-06-28 10:38:18 -07007273 hdd_notice("11D state=%d!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007274 smeConfig.csrConfig.
7275 Is11dSupportEnabled);
7276
7277 sme_update_config(hHal, &smeConfig);
7278 } else {
7279 return -EINVAL;
7280 }
7281 break;
7282 }
7283
7284 case WE_WOWL:
7285 {
7286 switch (set_value) {
7287 case 0x00:
7288 hdd_exit_wowl(pAdapter);
7289 break;
7290 case 0x01:
7291 case 0x02:
7292 case 0x03:
7293 enable_mp = (set_value & 0x01) ? 1 : 0;
7294 enable_pbm = (set_value & 0x02) ? 1 : 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07007295 hdd_err("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007296 (enable_mp ? "YES" : "NO"),
7297 (enable_pbm ? "YES" : "NO"));
7298 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
7299 break;
7300 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007301 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007302 set_value);
7303 ret = -EINVAL;
7304 break;
7305 }
7306
7307 break;
7308 }
7309 case WE_SET_POWER:
7310 {
7311 switch (set_value) {
7312 case 1:
7313 /* Enable PowerSave */
7314 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7315 SME_PS_ENABLE);
7316 break;
7317 case 2:
7318 /* Disable PowerSave */
7319 sme_ps_enable_disable(hHal, pAdapter->sessionId,
7320 SME_PS_DISABLE);
7321 break;
7322 case 3: /* Enable UASPD */
7323 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
7324 break;
7325 case 4: /* Disable UASPD */
7326 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
7327 break;
7328 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007329 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007330 set_value);
7331 ret = -EINVAL;
7332 break;
7333 }
7334 break;
7335 }
7336
7337 case WE_SET_MAX_ASSOC:
7338 {
7339 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
7340 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
7341 ret = -EINVAL;
7342 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
7343 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307344 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007345 hdd_err("failed to set ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007346 ret = -EIO;
7347 }
7348 break;
7349 }
7350
7351 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
7352 if (set_value == 0 || set_value == 1)
7353 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
7354 set_value;
7355 else
7356 ret = -EINVAL;
7357 break;
7358
7359 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007360 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
7361 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
7362 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
7363 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307364 set_value) == QDF_STATUS_E_FAILURE)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007365 hdd_err("Failure: Could not pass on WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT configuration info to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007366 ret = -EINVAL;
7367 }
7368 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007369 case WE_SET_MC_RATE:
7370 {
7371 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
7372 break;
7373 }
7374 case WE_SET_TX_POWER:
7375 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307376 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007377
Anurag Chouhanc5548422016-02-24 18:33:27 +05307378 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007379 if (sme_set_tx_power
7380 (hHal, pAdapter->sessionId, bssid,
7381 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307382 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007383 hdd_err("Setting tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007384 return -EIO;
7385 }
7386 break;
7387 }
7388 case WE_SET_MAX_TX_POWER:
7389 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307390 struct qdf_mac_addr bssid;
7391 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007392
Jeff Johnson99bac312016-06-28 10:38:18 -07007393 hdd_notice("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007394 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05307395 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
7396 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007397
7398 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307399 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007400 hdd_err("Setting maximum tx power failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007401 return -EIO;
7402 }
7403
7404 break;
7405 }
7406 case WE_SET_MAX_TX_POWER_2_4:
7407 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007408 hdd_notice("Setting maximum tx power %d dBm for 2.4 GHz band",
7409 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007410 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307411 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007412 hdd_err("Setting maximum tx power failed for 2.4 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007413 return -EIO;
7414 }
7415
7416 break;
7417 }
7418 case WE_SET_MAX_TX_POWER_5_0:
7419 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007420 hdd_notice("Setting maximum tx power %d dBm for 5.0 GHz band",
7421 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007422 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307423 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007424 hdd_err("Setting maximum tx power failed for 5.0 GHz band");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007425 return -EIO;
7426 }
7427
7428 break;
7429 }
7430 case WE_SET_HIGHER_DTIM_TRANSITION:
7431 {
7432 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007433 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007434 set_value);
7435 ret = -EINVAL;
7436 } else {
7437 if (pAdapter->higherDtimTransition != set_value) {
7438 pAdapter->higherDtimTransition =
7439 set_value;
Jeff Johnson99bac312016-06-28 10:38:18 -07007440 hdd_notice("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007441 pAdapter->higherDtimTransition);
7442 }
7443 }
7444
7445 break;
7446 }
7447
7448 case WE_SET_TM_LEVEL:
7449 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007450 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007451 (void)sme_set_thermal_level(hHal, set_value);
7452 break;
7453 }
7454
7455 case WE_SET_PHYMODE:
7456 {
7457 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
7458
7459 ret =
7460 wlan_hdd_update_phymode(dev, hHal, set_value,
7461 phddctx);
7462 break;
7463 }
7464
7465 case WE_SET_NSS:
7466 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007467 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007468 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007469 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007470 ret = -EINVAL;
7471 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307472 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007473 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
7474 set_value))
7475 ret = -EINVAL;
7476 }
7477 break;
7478 }
7479
7480 case WE_SET_GTX_HT_MCS:
7481 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007482 hdd_notice("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007483 ret = wma_cli_set_command(pAdapter->sessionId,
7484 WMI_VDEV_PARAM_GTX_HT_MCS,
7485 set_value, GTX_CMD);
7486 break;
7487 }
7488
7489 case WE_SET_GTX_VHT_MCS:
7490 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007491 hdd_notice("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007492 set_value);
7493 ret = wma_cli_set_command(pAdapter->sessionId,
7494 WMI_VDEV_PARAM_GTX_VHT_MCS,
7495 set_value, GTX_CMD);
7496 break;
7497 }
7498
7499 case WE_SET_GTX_USRCFG:
7500 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007501 hdd_notice("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007502 set_value);
7503 ret = wma_cli_set_command(pAdapter->sessionId,
7504 WMI_VDEV_PARAM_GTX_USR_CFG,
7505 set_value, GTX_CMD);
7506 break;
7507 }
7508
7509 case WE_SET_GTX_THRE:
7510 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007511 hdd_notice("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007512 ret = wma_cli_set_command(pAdapter->sessionId,
7513 WMI_VDEV_PARAM_GTX_THRE,
7514 set_value, GTX_CMD);
7515 break;
7516 }
7517
7518 case WE_SET_GTX_MARGIN:
7519 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007520 hdd_notice("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007521 ret = wma_cli_set_command(pAdapter->sessionId,
7522 WMI_VDEV_PARAM_GTX_MARGIN,
7523 set_value, GTX_CMD);
7524 break;
7525 }
7526
7527 case WE_SET_GTX_STEP:
7528 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007529 hdd_notice("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007530 ret = wma_cli_set_command(pAdapter->sessionId,
7531 WMI_VDEV_PARAM_GTX_STEP,
7532 set_value, GTX_CMD);
7533 break;
7534 }
7535
7536 case WE_SET_GTX_MINTPC:
7537 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007538 hdd_notice("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007539 ret = wma_cli_set_command(pAdapter->sessionId,
7540 WMI_VDEV_PARAM_GTX_MINTPC,
7541 set_value, GTX_CMD);
7542 break;
7543 }
7544
7545 case WE_SET_GTX_BWMASK:
7546 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007547 hdd_notice("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007548 ret = wma_cli_set_command(pAdapter->sessionId,
7549 WMI_VDEV_PARAM_GTX_BW_MASK,
7550 set_value, GTX_CMD);
7551 break;
7552 }
7553
7554 case WE_SET_LDPC:
7555 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307556 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007557 break;
7558 }
7559
7560 case WE_SET_TX_STBC:
7561 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307562 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007563 break;
7564 }
7565
7566 case WE_SET_RX_STBC:
7567 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05307568 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007569 break;
7570 }
7571
7572 case WE_SET_SHORT_GI:
7573 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007574 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007575 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
7576 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
7577 set_value);
7578 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07007579 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007580 break;
7581 }
7582
7583 case WE_SET_RTSCTS:
7584 {
7585 uint32_t value;
7586
Jeff Johnson99bac312016-06-28 10:38:18 -07007587 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007588 set_value);
7589
7590 if ((set_value & HDD_RTSCTS_EN_MASK) ==
7591 HDD_RTSCTS_ENABLE)
7592 value =
7593 (WLAN_HDD_GET_CTX(pAdapter))->config->
7594 RTSThreshold;
7595 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
7596 || ((set_value & HDD_RTSCTS_EN_MASK) ==
7597 HDD_CTS_ENABLE))
7598 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
7599 else
7600 return -EIO;
7601
7602 ret = wma_cli_set_command(pAdapter->sessionId,
7603 WMI_VDEV_PARAM_ENABLE_RTSCTS,
7604 set_value, VDEV_CMD);
7605 if (!ret) {
7606 if (sme_cfg_set_int
7607 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307608 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007609 hdd_err("FAILED TO SET RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007610 return -EIO;
7611 }
7612 }
7613
7614 break;
7615 }
7616
7617 case WE_SET_CHWIDTH:
7618 {
7619 bool chwidth = false;
7620 hdd_context_t *phddctx = WLAN_HDD_GET_CTX(pAdapter);
7621 /*updating channel bonding only on 5Ghz */
Jeff Johnson99bac312016-06-28 10:38:18 -07007622 hdd_notice("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007623 set_value);
7624 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007625 hdd_err("Invalid channel width 0->20 1->40 2->80");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007626 return -EINVAL;
7627 }
7628
7629 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7630 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
7631 nChannelBondingMode5GHz)))
7632 chwidth = true;
7633
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007634 sme_get_config_param(hHal, &smeConfig);
7635 switch (set_value) {
7636 case eHT_CHANNEL_WIDTH_20MHZ:
7637 smeConfig.csrConfig.channelBondingMode5GHz =
7638 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7639 break;
7640 case eHT_CHANNEL_WIDTH_40MHZ:
7641 if (chwidth)
7642 smeConfig.csrConfig.
7643 channelBondingMode5GHz =
7644 phddctx->config->
7645 nChannelBondingMode5GHz;
7646 else
7647 return -EINVAL;
7648
7649 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007650 case eHT_CHANNEL_WIDTH_80MHZ:
7651 if (chwidth)
7652 smeConfig.csrConfig.
7653 channelBondingMode5GHz =
7654 phddctx->config->
7655 nChannelBondingMode5GHz;
7656 else
7657 return -EINVAL;
7658
7659 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007660
7661 default:
7662 return -EINVAL;
7663 }
7664
7665 ret = wma_cli_set_command(pAdapter->sessionId,
7666 WMI_VDEV_PARAM_CHWIDTH,
7667 set_value, VDEV_CMD);
7668 if (!ret)
7669 sme_update_config(hHal, &smeConfig);
7670
7671 break;
7672 }
7673
7674 case WE_SET_ANI_EN_DIS:
7675 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007676 hdd_notice("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007677 set_value);
7678 ret = wma_cli_set_command(pAdapter->sessionId,
7679 WMI_PDEV_PARAM_ANI_ENABLE,
7680 set_value, PDEV_CMD);
7681 break;
7682 }
7683
7684 case WE_SET_ANI_POLL_PERIOD:
7685 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007686 hdd_notice("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007687 set_value);
7688 ret = wma_cli_set_command(pAdapter->sessionId,
7689 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
7690 set_value, PDEV_CMD);
7691 break;
7692 }
7693
7694 case WE_SET_ANI_LISTEN_PERIOD:
7695 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007696 hdd_notice("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007697 set_value);
7698 ret = wma_cli_set_command(pAdapter->sessionId,
7699 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
7700 set_value, PDEV_CMD);
7701 break;
7702 }
7703
7704 case WE_SET_ANI_OFDM_LEVEL:
7705 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007706 hdd_notice("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007707 set_value);
7708 ret = wma_cli_set_command(pAdapter->sessionId,
7709 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
7710 set_value, PDEV_CMD);
7711 break;
7712 }
7713
7714 case WE_SET_ANI_CCK_LEVEL:
7715 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007716 hdd_notice("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007717 set_value);
7718 ret = wma_cli_set_command(pAdapter->sessionId,
7719 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
7720 set_value, PDEV_CMD);
7721 break;
7722 }
7723
7724 case WE_SET_DYNAMIC_BW:
7725 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007726 hdd_notice("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007727 set_value);
7728 ret = wma_cli_set_command(pAdapter->sessionId,
7729 WMI_PDEV_PARAM_DYNAMIC_BW,
7730 set_value, PDEV_CMD);
7731 break;
7732 }
7733
7734 case WE_SET_CTS_CBW:
7735 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007736 hdd_notice("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007737 ret = wma_cli_set_command(pAdapter->sessionId,
7738 WMI_PDEV_PARAM_CTS_CBW,
7739 set_value, PDEV_CMD);
7740 break;
7741 }
7742
7743 case WE_SET_11N_RATE:
7744 {
7745 uint8_t preamble = 0, nss = 0, rix = 0;
Jeff Johnson99bac312016-06-28 10:38:18 -07007746 hdd_notice("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007747 set_value);
7748
7749 if (set_value != 0xff) {
7750 rix = RC_2_RATE_IDX(set_value);
7751 if (set_value & 0x80) {
7752 preamble = WMI_RATE_PREAMBLE_HT;
7753 nss = HT_RC_2_STREAMS(set_value) - 1;
7754 } else {
7755 nss = 0;
7756 rix = RC_2_RATE_IDX(set_value);
7757 if (set_value & 0x10) {
7758 preamble =
7759 WMI_RATE_PREAMBLE_CCK;
7760 if (rix != 0x3)
7761 /* Enable Short
7762 * preamble always for
7763 * CCK except 1mbps
7764 */
7765 rix |= 0x4;
7766 } else {
7767 preamble =
7768 WMI_RATE_PREAMBLE_OFDM;
7769 }
7770 }
7771 set_value = (preamble << 6) | (nss << 4) | rix;
7772 }
7773 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
7774 set_value, rix, preamble, nss);
7775
7776 ret = wma_cli_set_command(pAdapter->sessionId,
7777 WMI_VDEV_PARAM_FIXED_RATE,
7778 set_value, VDEV_CMD);
7779 break;
7780 }
7781
7782 case WE_SET_VHT_RATE:
7783 {
7784 uint8_t preamble = 0, nss = 0, rix = 0;
7785
7786 if (set_value != 0xff) {
7787 rix = RC_2_RATE_IDX_11AC(set_value);
7788 preamble = WMI_RATE_PREAMBLE_VHT;
7789 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
7790
7791 set_value = (preamble << 6) | (nss << 4) | rix;
7792 }
7793 hdd_info("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
7794 set_value, rix, preamble, nss);
7795 ret = wma_cli_set_command(pAdapter->sessionId,
7796 WMI_VDEV_PARAM_FIXED_RATE,
7797 set_value, VDEV_CMD);
7798 break;
7799 }
7800
7801 case WE_SET_AMPDU:
7802 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007803 hdd_notice("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007804 ret = wma_cli_set_command(pAdapter->sessionId,
7805 GEN_VDEV_PARAM_AMPDU,
7806 set_value, GEN_CMD);
7807 break;
7808 }
7809
7810 case WE_SET_AMSDU:
7811 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007812 hdd_notice("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007813 ret = wma_cli_set_command(pAdapter->sessionId,
7814 GEN_VDEV_PARAM_AMSDU,
7815 set_value, GEN_CMD);
7816 break;
7817 }
7818
7819 case WE_SET_BURST_ENABLE:
7820 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007821 hdd_notice("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007822 if ((set_value == 0) || (set_value == 1)) {
7823 ret = wma_cli_set_command(pAdapter->sessionId,
7824 WMI_PDEV_PARAM_BURST_ENABLE,
7825 set_value, PDEV_CMD);
7826 } else
7827 ret = -EINVAL;
7828 break;
7829 }
7830 case WE_SET_BURST_DUR:
7831 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007832 hdd_notice("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07007833 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007834 ret = wma_cli_set_command(pAdapter->sessionId,
7835 WMI_PDEV_PARAM_BURST_DUR,
7836 set_value, PDEV_CMD);
7837 else
7838 ret = -EINVAL;
7839 break;
7840 }
7841
7842 case WE_SET_TX_CHAINMASK:
7843 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007844 hdd_notice("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007845 set_value);
7846 ret = wma_cli_set_command(pAdapter->sessionId,
7847 WMI_PDEV_PARAM_TX_CHAIN_MASK,
7848 set_value, PDEV_CMD);
7849 break;
7850 }
7851
7852 case WE_SET_RX_CHAINMASK:
7853 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007854 hdd_notice("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007855 set_value);
7856 ret = wma_cli_set_command(pAdapter->sessionId,
7857 WMI_PDEV_PARAM_RX_CHAIN_MASK,
7858 set_value, PDEV_CMD);
7859 break;
7860 }
7861
7862 case WE_SET_TXPOW_2G:
7863 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007864 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007865 set_value);
7866 ret = wma_cli_set_command(pAdapter->sessionId,
7867 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
7868 set_value, PDEV_CMD);
7869 break;
7870 }
7871
7872 case WE_SET_TXPOW_5G:
7873 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007874 hdd_notice("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007875 set_value);
7876 ret = wma_cli_set_command(pAdapter->sessionId,
7877 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
7878 set_value, PDEV_CMD);
7879 break;
7880 }
7881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007882 /* Firmware debug log */
7883 case WE_DBGLOG_LOG_LEVEL:
7884 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007885 hdd_notice("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007886 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
7887 ret = wma_cli_set_command(pAdapter->sessionId,
7888 WMI_DBGLOG_LOG_LEVEL,
7889 set_value, DBG_CMD);
7890 break;
7891 }
7892
7893 case WE_DBGLOG_VAP_ENABLE:
7894 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007895 hdd_notice("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007896 ret = wma_cli_set_command(pAdapter->sessionId,
7897 WMI_DBGLOG_VAP_ENABLE,
7898 set_value, DBG_CMD);
7899 break;
7900 }
7901
7902 case WE_DBGLOG_VAP_DISABLE:
7903 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007904 hdd_notice("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007905 ret = wma_cli_set_command(pAdapter->sessionId,
7906 WMI_DBGLOG_VAP_DISABLE,
7907 set_value, DBG_CMD);
7908 break;
7909 }
7910
7911 case WE_DBGLOG_MODULE_ENABLE:
7912 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007913 hdd_notice("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007914 set_value);
7915 hdd_ctx->fw_log_settings.enable = set_value;
7916 ret = wma_cli_set_command(pAdapter->sessionId,
7917 WMI_DBGLOG_MODULE_ENABLE,
7918 set_value, DBG_CMD);
7919 break;
7920 }
7921
7922 case WE_DBGLOG_MODULE_DISABLE:
7923 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007924 hdd_notice("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007925 set_value);
7926 hdd_ctx->fw_log_settings.enable = set_value;
7927 ret = wma_cli_set_command(pAdapter->sessionId,
7928 WMI_DBGLOG_MODULE_DISABLE,
7929 set_value, DBG_CMD);
7930 break;
7931 }
7932 case WE_DBGLOG_MOD_LOG_LEVEL:
7933 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007934 hdd_notice("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007935 set_value);
7936
7937 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
7938 hdd_ctx->fw_log_settings.index = 0;
7939
7940 hdd_ctx->fw_log_settings.
7941 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
7942 set_value;
7943 hdd_ctx->fw_log_settings.index++;
7944
7945 ret = wma_cli_set_command(pAdapter->sessionId,
7946 WMI_DBGLOG_MOD_LOG_LEVEL,
7947 set_value, DBG_CMD);
7948 break;
7949 }
7950
7951 case WE_DBGLOG_TYPE:
7952 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007953 hdd_notice("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007954 hdd_ctx->fw_log_settings.dl_type = set_value;
7955 ret = wma_cli_set_command(pAdapter->sessionId,
7956 WMI_DBGLOG_TYPE,
7957 set_value, DBG_CMD);
7958 break;
7959 }
7960 case WE_DBGLOG_REPORT_ENABLE:
7961 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007962 hdd_notice("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963 set_value);
7964 hdd_ctx->fw_log_settings.dl_report = set_value;
7965 ret = wma_cli_set_command(pAdapter->sessionId,
7966 WMI_DBGLOG_REPORT_ENABLE,
7967 set_value, DBG_CMD);
7968 break;
7969 }
7970
7971 case WE_SET_TXRX_FWSTATS:
7972 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007973 hdd_notice("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007974 ret = wma_cli_set_command(pAdapter->sessionId,
7975 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
7976 set_value, VDEV_CMD);
7977 break;
7978 }
7979
7980 case WE_TXRX_FWSTATS_RESET:
7981 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007982 hdd_notice("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007983 ret = wma_cli_set_command(pAdapter->sessionId,
7984 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
7985 set_value, VDEV_CMD);
7986 break;
7987 }
7988
7989 case WE_DUMP_STATS:
7990 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007991 hdd_notice("WE_DUMP_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007992 hdd_wlan_dump_stats(pAdapter, set_value);
7993 break;
7994 }
7995
7996 case WE_CLEAR_STATS:
7997 {
Jeff Johnson99bac312016-06-28 10:38:18 -07007998 hdd_notice("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007999 switch (set_value) {
8000 case WLAN_HDD_STATS:
8001 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
8002 memset(&pAdapter->hdd_stats, 0,
8003 sizeof(pAdapter->hdd_stats));
8004 break;
8005 case WLAN_TXRX_HIST_STATS:
8006 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
8007 break;
8008 case WLAN_HDD_NETIF_OPER_HISTORY:
8009 wlan_hdd_clear_netif_queue_history(hdd_ctx);
8010 break;
Nirav Shahbf1b0332016-05-25 14:27:39 +05308011 case WLAN_HIF_STATS:
8012 hdd_clear_hif_stats();
8013 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008014 default:
Leo Changfdb45c32016-10-28 11:09:23 -07008015 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
8016 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008017 }
8018 break;
8019 }
8020
8021 case WE_PPS_PAID_MATCH:
8022 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008023 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008024 return EINVAL;
8025
Jeff Johnson99bac312016-06-28 10:38:18 -07008026 hdd_notice("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008027 set_value);
8028 ret = wma_cli_set_command(pAdapter->sessionId,
8029 WMI_VDEV_PPS_PAID_MATCH,
8030 set_value, PPS_CMD);
8031 break;
8032 }
8033
8034 case WE_PPS_GID_MATCH:
8035 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008036 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008037 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008038 hdd_notice("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008039 set_value);
8040 ret = wma_cli_set_command(pAdapter->sessionId,
8041 WMI_VDEV_PPS_GID_MATCH,
8042 set_value, PPS_CMD);
8043 break;
8044 }
8045
8046 case WE_PPS_EARLY_TIM_CLEAR:
8047 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008048 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008049 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008050 hdd_notice(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008051 set_value);
8052 ret = wma_cli_set_command(pAdapter->sessionId,
8053 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
8054 set_value, PPS_CMD);
8055 break;
8056 }
8057
8058 case WE_PPS_EARLY_DTIM_CLEAR:
8059 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008060 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008061 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008062 hdd_notice("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008063 set_value);
8064 ret = wma_cli_set_command(pAdapter->sessionId,
8065 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
8066 set_value, PPS_CMD);
8067 break;
8068 }
8069
8070 case WE_PPS_EOF_PAD_DELIM:
8071 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008072 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008073 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008074 hdd_notice("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008075 set_value);
8076 ret = wma_cli_set_command(pAdapter->sessionId,
8077 WMI_VDEV_PPS_EOF_PAD_DELIM,
8078 set_value, PPS_CMD);
8079 break;
8080 }
8081
8082 case WE_PPS_MACADDR_MISMATCH:
8083 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008084 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008085 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008086 hdd_notice("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008087 set_value);
8088 ret = wma_cli_set_command(pAdapter->sessionId,
8089 WMI_VDEV_PPS_MACADDR_MISMATCH,
8090 set_value, PPS_CMD);
8091 break;
8092 }
8093
8094 case WE_PPS_DELIM_CRC_FAIL:
8095 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008096 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008097 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008098 hdd_notice("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008099 set_value);
8100 ret = wma_cli_set_command(pAdapter->sessionId,
8101 WMI_VDEV_PPS_DELIM_CRC_FAIL,
8102 set_value, PPS_CMD);
8103 break;
8104 }
8105
8106 case WE_PPS_GID_NSTS_ZERO:
8107 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008108 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008109 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008110 hdd_notice("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008111 set_value);
8112 ret = wma_cli_set_command(pAdapter->sessionId,
8113 WMI_VDEV_PPS_GID_NSTS_ZERO,
8114 set_value, PPS_CMD);
8115 break;
8116 }
8117
8118 case WE_PPS_RSSI_CHECK:
8119 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008120 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008121 return EINVAL;
Jeff Johnson99bac312016-06-28 10:38:18 -07008122 hdd_notice("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008123 set_value);
8124 ret = wma_cli_set_command(pAdapter->sessionId,
8125 WMI_VDEV_PPS_RSSI_CHECK,
8126 set_value, PPS_CMD);
8127 break;
8128 }
8129
8130 case WE_PPS_5G_EBT:
8131 {
Krunal Sonif07bb382016-03-10 13:02:11 -08008132 if (pAdapter->device_mode != QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008133 return -EINVAL;
8134
Jeff Johnson99bac312016-06-28 10:38:18 -07008135 hdd_notice("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008136 ret = wma_cli_set_command(pAdapter->sessionId,
8137 WMI_VDEV_PPS_5G_EBT,
8138 set_value, PPS_CMD);
8139 break;
8140 }
8141
8142 case WE_SET_HTSMPS:
8143 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008144 hdd_notice("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008145 ret = wma_cli_set_command(pAdapter->sessionId,
8146 WMI_STA_SMPS_FORCE_MODE_CMDID,
8147 set_value, VDEV_CMD);
8148 break;
8149 }
8150
8151 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
8152 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008153 hdd_notice("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008154 set_value);
8155 ret = wma_cli_set_command(pAdapter->sessionId,
8156 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
8157 set_value, QPOWER_CMD);
8158 break;
8159 }
8160
8161 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
8162 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008163 hdd_notice("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008164 set_value);
8165 ret = wma_cli_set_command(
8166 pAdapter->sessionId,
8167 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
8168 set_value, QPOWER_CMD);
8169 break;
8170 }
8171
8172 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
8173 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008174 hdd_notice("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008175 set_value);
8176 ret = wma_cli_set_command(
8177 pAdapter->sessionId,
8178 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
8179 set_value, QPOWER_CMD);
8180 break;
8181 }
8182
8183 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
8184 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008185 hdd_notice("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008186 set_value);
8187 ret = wma_cli_set_command(
8188 pAdapter->sessionId,
8189 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
8190 set_value, QPOWER_CMD);
8191 break;
8192 }
8193
8194 case WE_MCC_CONFIG_LATENCY:
8195 {
8196 cds_set_mcc_latency(pAdapter, set_value);
8197 break;
8198 }
8199
8200 case WE_MCC_CONFIG_QUOTA:
8201 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008202 hdd_notice("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008203 set_value);
8204 ret = cds_set_mcc_p2p_quota(pAdapter, set_value);
8205 break;
8206 }
8207 case WE_SET_DEBUG_LOG:
8208 {
8209 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05308210
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008211 hdd_ctx->config->gEnableDebugLog = set_value;
8212 sme_update_connect_debug(hdd_ctx->hHal, set_value);
8213 break;
8214 }
8215 case WE_SET_EARLY_RX_ADJUST_ENABLE:
8216 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008217 hdd_notice("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008218 if ((set_value == 0) || (set_value == 1))
8219 ret = wma_cli_set_command(
8220 pAdapter->sessionId,
8221 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
8222 set_value, VDEV_CMD);
8223 else
8224 ret = -EINVAL;
8225 break;
8226 }
8227 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
8228 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008229 hdd_notice("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008230 ret = wma_cli_set_command(pAdapter->sessionId,
8231 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
8232 set_value, VDEV_CMD);
8233 break;
8234 }
8235 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
8236 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008237 hdd_notice("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008238 set_value);
8239 ret = wma_cli_set_command(
8240 pAdapter->sessionId,
8241 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
8242 set_value, VDEV_CMD);
8243 break;
8244 }
8245 case WE_SET_EARLY_RX_SLOP_STEP:
8246 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008247 hdd_notice("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008248 set_value);
8249 ret = wma_cli_set_command(pAdapter->sessionId,
8250 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
8251 set_value, VDEV_CMD);
8252 break;
8253 }
8254 case WE_SET_EARLY_RX_INIT_SLOP:
8255 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008256 hdd_notice("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008257 set_value);
8258 ret = wma_cli_set_command(pAdapter->sessionId,
8259 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
8260 set_value, VDEV_CMD);
8261 break;
8262 }
8263 case WE_SET_EARLY_RX_ADJUST_PAUSE:
8264 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008265 hdd_notice("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008266 if ((set_value == 0) || (set_value == 1))
8267 ret = wma_cli_set_command(
8268 pAdapter->sessionId,
8269 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
8270 set_value, VDEV_CMD);
8271 else
8272 ret = -EINVAL;
8273 break;
8274 }
8275 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
8276 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008277 hdd_notice("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008278 ret = wma_cli_set_command(pAdapter->sessionId,
8279 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
8280 set_value, VDEV_CMD);
8281 break;
8282 }
8283 case WE_SET_SCAN_DISABLE:
8284 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008285 hdd_notice("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008286 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
8287 break;
8288 }
Govind Singha471e5e2015-10-12 17:11:14 +05308289 case WE_START_FW_PROFILE:
8290 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008291 hdd_notice("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05308292 ret = wma_cli_set_command(pAdapter->sessionId,
8293 WMI_WLAN_PROFILE_TRIGGER_CMDID,
8294 set_value, DBG_CMD);
8295 break;
8296 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308297 case WE_SET_CHANNEL:
8298 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008299 hdd_notice("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308300 pAdapter->sessionId, pAdapter->device_mode);
8301
Krunal Sonif07bb382016-03-10 13:02:11 -08008302 if ((QDF_STA_MODE == pAdapter->device_mode) ||
8303 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308304
8305 status = sme_ext_change_channel(hHal,
8306 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308307 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008308 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308309 status);
8310 ret = -EINVAL;
8311 }
8312 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008313 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308314 pAdapter->device_mode);
8315 ret = -EINVAL;
8316 }
8317 break;
8318 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308319 case WE_SET_CONC_SYSTEM_PREF:
8320 {
8321 hdd_info("New preference: %d", set_value);
8322 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
8323 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
8324 hdd_err("Invalid system preference %d", set_value);
8325 return -EINVAL;
8326 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308327
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308328 /* hdd_ctx, hdd_ctx->config are already checked for null */
8329 hdd_ctx->config->conc_system_pref = set_value;
8330 break;
8331 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008332 default:
8333 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008334 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008335 sub_cmd);
8336 ret = -EINVAL;
8337 break;
8338 }
8339 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308340 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008341 return ret;
8342}
8343
8344static int iw_setint_getnone(struct net_device *dev,
8345 struct iw_request_info *info,
8346 union iwreq_data *wrqu,
8347 char *extra)
8348{
8349 int ret;
8350
8351 cds_ssr_protect(__func__);
8352 ret = __iw_setint_getnone(dev, info, wrqu, extra);
8353 cds_ssr_unprotect(__func__);
8354
8355 return ret;
8356}
8357
8358/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008359 * __iw_setnone_get_threeint() - return three value to up layer.
8360 *
8361 * @dev: pointer of net_device of this wireless card
8362 * @info: meta data about Request sent
8363 * @wrqu: include request info
8364 * @extra: buf used for in/Output
8365 *
8366 * Return: execute result
8367 */
8368static int __iw_setnone_get_threeint(struct net_device *dev,
8369 struct iw_request_info *info,
8370 union iwreq_data *wrqu, char *extra)
8371{
8372 int ret = 0; /* success */
8373 uint32_t *value = (int *)extra;
8374 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
8375 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
8376
8377 ENTER_DEV(dev);
8378 ret = wlan_hdd_validate_context(hdd_ctx);
8379 if (0 != ret)
8380 return ret;
8381
Jeff Johnson441e1f72017-02-07 08:50:49 -08008382 ret = hdd_check_private_wext_control(hdd_ctx, info);
8383 if (0 != ret)
8384 return ret;
8385
Jeff Johnson99bac312016-06-28 10:38:18 -07008386 hdd_info("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008387 switch (value[0]) {
8388 case WE_GET_TSF:
8389 ret = hdd_indicate_tsf(adapter, value, 3);
8390 break;
8391 default:
8392 hdd_err("Invalid IOCTL get_value command %d", value[0]);
8393 break;
8394 }
8395 return ret;
8396}
8397
8398/**
8399 * iw_setnone_get_threeint() - return three value to up layer.
8400 *
8401 * @dev: pointer of net_device of this wireless card
8402 * @info: meta data about Request sent
8403 * @wrqu: include request info
8404 * @extra: buf used for in/Output
8405 *
8406 * Return: execute result
8407 */
8408static int iw_setnone_get_threeint(struct net_device *dev,
8409 struct iw_request_info *info,
8410 union iwreq_data *wrqu, char *extra)
8411{
8412 int ret;
8413
8414 cds_ssr_protect(__func__);
8415 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
8416 cds_ssr_unprotect(__func__);
8417
8418 return ret;
8419}
8420
8421/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008422 * iw_setchar_getnone() - Generic "set string" private ioctl handler
8423 * @dev: device upon which the ioctl was received
8424 * @info: ioctl request information
8425 * @wrqu: ioctl request data
8426 * @extra: ioctl extra data
8427 *
8428 * Return: 0 on success, non-zero on error
8429 */
8430static int __iw_setchar_getnone(struct net_device *dev,
8431 struct iw_request_info *info,
8432 union iwreq_data *wrqu, char *extra)
8433{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308434 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008435 int sub_cmd;
8436 int ret;
8437 char *pBuffer = NULL;
8438 hdd_adapter_t *pAdapter = (netdev_priv(dev));
8439 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008440 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008441 struct iw_point s_priv_data;
8442
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008443 ENTER_DEV(dev);
8444
Mukul Sharma34777c62015-11-02 20:22:30 +05308445 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008446 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05308447 return -EPERM;
8448 }
8449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008450 ret = wlan_hdd_validate_context(hdd_ctx);
8451 if (0 != ret)
8452 return ret;
8453
Jeff Johnson441e1f72017-02-07 08:50:49 -08008454 ret = hdd_check_private_wext_control(hdd_ctx, info);
8455 if (0 != ret)
8456 return ret;
8457
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008458 /* helper function to get iwreq_data with compat handling. */
8459 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
8460 return -EINVAL;
8461 }
8462
8463 /* make sure all params are correctly passed to function */
8464 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length)) {
8465 return -EINVAL;
8466 }
8467
8468 sub_cmd = s_priv_data.flags;
8469
8470 /* ODD number is used for set, copy data using copy_from_user */
8471 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
8472 s_priv_data.length);
8473 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008474 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008475 return -ENOMEM;
8476 }
8477
Jeff Johnson99bac312016-06-28 10:38:18 -07008478 hdd_notice("Received length %d", s_priv_data.length);
8479 hdd_notice("Received data %s", pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008480
8481 switch (sub_cmd) {
8482 case WE_WOWL_ADD_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07008483 hdd_notice("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008484 hdd_add_wowl_ptrn(pAdapter, pBuffer);
8485 break;
8486 case WE_WOWL_DEL_PTRN:
Jeff Johnson99bac312016-06-28 10:38:18 -07008487 hdd_notice("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008488 hdd_del_wowl_ptrn(pAdapter, pBuffer);
8489 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008490 case WE_NEIGHBOR_REPORT_REQUEST:
8491 {
8492 tRrmNeighborReq neighborReq;
8493 tRrmNeighborRspCallbackInfo callbackInfo;
8494
8495 if (pConfig->fRrmEnable) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008496 hdd_notice("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008497 neighborReq.no_ssid =
8498 (s_priv_data.length - 1) ? false : true;
8499 if (!neighborReq.no_ssid) {
8500 neighborReq.ssid.length =
8501 (s_priv_data.length - 1) >
8502 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308503 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008504 pBuffer,
8505 neighborReq.ssid.length);
8506 }
8507
8508 callbackInfo.neighborRspCallback = NULL;
8509 callbackInfo.neighborRspCallbackContext = NULL;
8510 callbackInfo.timeout = 5000; /* 5 seconds */
8511 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
8512 (pAdapter),
8513 pAdapter->sessionId,
8514 &neighborReq,
8515 &callbackInfo);
8516 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008517 hdd_err("Ignoring neighbor request as RRM is not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008518 ret = -EINVAL;
8519 }
8520 }
8521 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008522 case WE_SET_AP_WPS_IE:
Jeff Johnson99bac312016-06-28 10:38:18 -07008523 hdd_err("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008524 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
8525 s_priv_data.length);
8526 break;
8527 case WE_SET_CONFIG:
8528 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308529 if (QDF_STATUS_SUCCESS != vstatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008530 ret = -EINVAL;
8531 }
8532 break;
8533 default:
8534 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008535 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008536 sub_cmd);
8537 ret = -EINVAL;
8538 break;
8539 }
8540 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07008541 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308542 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008543 return ret;
8544}
8545
8546static int iw_setchar_getnone(struct net_device *dev,
8547 struct iw_request_info *info,
8548 union iwreq_data *wrqu, char *extra)
8549{
8550 int ret;
8551
8552 cds_ssr_protect(__func__);
8553 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
8554 cds_ssr_unprotect(__func__);
8555
8556 return ret;
8557}
8558
8559/**
8560 * iw_setnone_getint() - Generic "get integer" private ioctl handler
8561 * @dev: device upon which the ioctl was received
8562 * @info: ioctl request information
8563 * @wrqu: ioctl request data
8564 * @extra: ioctl extra data
8565 *
8566 * Return: 0 on success, non-zero on error
8567 */
8568static int __iw_setnone_getint(struct net_device *dev,
8569 struct iw_request_info *info,
8570 union iwreq_data *wrqu, char *extra)
8571{
8572 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8573 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8574 int *value = (int *)extra;
8575 int ret;
8576 tSmeConfigParams smeConfig;
8577 hdd_context_t *hdd_ctx;
8578
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08008579 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308580
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008581 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
8582 ret = wlan_hdd_validate_context(hdd_ctx);
8583 if (0 != ret)
8584 return ret;
8585
Jeff Johnson441e1f72017-02-07 08:50:49 -08008586 ret = hdd_check_private_wext_control(hdd_ctx, info);
8587 if (0 != ret)
8588 return ret;
8589
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008590 switch (value[0]) {
8591 case WE_GET_11D_STATE:
8592 {
8593 sme_get_config_param(hHal, &smeConfig);
8594
8595 *value = smeConfig.csrConfig.Is11dSupportEnabled;
8596
Jeff Johnson99bac312016-06-28 10:38:18 -07008597 hdd_notice("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008598
8599 break;
8600 }
8601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008602 case WE_GET_WLAN_DBG:
8603 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308604 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008605 *value = 0;
8606 break;
8607 }
8608 case WE_GET_MAX_ASSOC:
8609 {
8610 if (sme_cfg_get_int
8611 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308612 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008613 hdd_warn("failed to get ini parameter, WNI_CFG_ASSOC_STA_LIMIT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008614 ret = -EIO;
8615 }
8616 break;
8617 }
8618 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
8619 *value = (WLAN_HDD_GET_CTX(
8620 pAdapter))->config->force_sap_acs;
8621 break;
8622
8623 case WE_GET_CONCURRENCY_MODE:
8624 {
8625 *value = cds_get_concurrency_mode();
8626
Jeff Johnson99bac312016-06-28 10:38:18 -07008627 hdd_notice("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008628 break;
8629 }
8630
8631 case WE_GET_NSS:
8632 {
8633 sme_get_config_param(hHal, &smeConfig);
8634 *value = (smeConfig.csrConfig.enable2x2 == 0) ? 1 : 2;
Jeff Johnson99bac312016-06-28 10:38:18 -07008635 hdd_notice("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008636 break;
8637 }
8638
8639 case WE_GET_GTX_HT_MCS:
8640 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008641 hdd_notice("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008642 *value = wma_cli_get_command(pAdapter->sessionId,
8643 WMI_VDEV_PARAM_GTX_HT_MCS,
8644 GTX_CMD);
8645 break;
8646 }
8647
8648 case WE_GET_GTX_VHT_MCS:
8649 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008650 hdd_notice("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008651 *value = wma_cli_get_command(pAdapter->sessionId,
8652 WMI_VDEV_PARAM_GTX_VHT_MCS,
8653 GTX_CMD);
8654 break;
8655 }
8656
8657 case WE_GET_GTX_USRCFG:
8658 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008659 hdd_notice("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008660 *value = wma_cli_get_command(pAdapter->sessionId,
8661 WMI_VDEV_PARAM_GTX_USR_CFG,
8662 GTX_CMD);
8663 break;
8664 }
8665
8666 case WE_GET_GTX_THRE:
8667 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008668 hdd_notice("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008669 *value = wma_cli_get_command(pAdapter->sessionId,
8670 WMI_VDEV_PARAM_GTX_THRE,
8671 GTX_CMD);
8672 break;
8673 }
8674
8675 case WE_GET_GTX_MARGIN:
8676 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008677 hdd_notice("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008678 *value = wma_cli_get_command(pAdapter->sessionId,
8679 WMI_VDEV_PARAM_GTX_MARGIN,
8680 GTX_CMD);
8681 break;
8682 }
8683
8684 case WE_GET_GTX_STEP:
8685 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008686 hdd_notice("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008687 *value = wma_cli_get_command(pAdapter->sessionId,
8688 WMI_VDEV_PARAM_GTX_STEP,
8689 GTX_CMD);
8690 break;
8691 }
8692
8693 case WE_GET_GTX_MINTPC:
8694 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008695 hdd_notice("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008696 *value = wma_cli_get_command(pAdapter->sessionId,
8697 WMI_VDEV_PARAM_GTX_MINTPC,
8698 GTX_CMD);
8699 break;
8700 }
8701
8702 case WE_GET_GTX_BWMASK:
8703 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008704 hdd_notice("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008705 *value = wma_cli_get_command(pAdapter->sessionId,
8706 WMI_VDEV_PARAM_GTX_BW_MASK,
8707 GTX_CMD);
8708 break;
8709 }
8710
8711 case WE_GET_LDPC:
8712 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308713 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008714 break;
8715 }
8716
8717 case WE_GET_TX_STBC:
8718 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308719 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008720 break;
8721 }
8722
8723 case WE_GET_RX_STBC:
8724 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308725 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008726 break;
8727 }
8728
8729 case WE_GET_SHORT_GI:
8730 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008731 hdd_notice("GET WMI_VDEV_PARAM_SGI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008732 *value = sme_get_ht_config(hHal, pAdapter->sessionId,
8733 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ);
8734 break;
8735 }
8736
8737 case WE_GET_RTSCTS:
8738 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008739 hdd_notice("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008740 *value = wma_cli_get_command(pAdapter->sessionId,
8741 WMI_VDEV_PARAM_ENABLE_RTSCTS,
8742 VDEV_CMD);
8743 break;
8744 }
8745
8746 case WE_GET_CHWIDTH:
8747 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008748 hdd_notice("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008749 *value = wma_cli_get_command(pAdapter->sessionId,
8750 WMI_VDEV_PARAM_CHWIDTH,
8751 VDEV_CMD);
8752 break;
8753 }
8754
8755 case WE_GET_ANI_EN_DIS:
8756 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008757 hdd_notice("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008758 *value = wma_cli_get_command(pAdapter->sessionId,
8759 WMI_PDEV_PARAM_ANI_ENABLE,
8760 PDEV_CMD);
8761 break;
8762 }
8763
8764 case WE_GET_ANI_POLL_PERIOD:
8765 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008766 hdd_notice("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008767 *value = wma_cli_get_command(pAdapter->sessionId,
8768 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
8769 PDEV_CMD);
8770 break;
8771 }
8772
8773 case WE_GET_ANI_LISTEN_PERIOD:
8774 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008775 hdd_notice("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008776 *value = wma_cli_get_command(pAdapter->sessionId,
8777 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
8778 PDEV_CMD);
8779 break;
8780 }
8781
8782 case WE_GET_ANI_OFDM_LEVEL:
8783 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008784 hdd_notice("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008785 *value = wma_cli_get_command(pAdapter->sessionId,
8786 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
8787 PDEV_CMD);
8788 break;
8789 }
8790
8791 case WE_GET_ANI_CCK_LEVEL:
8792 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008793 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008794 *value = wma_cli_get_command(pAdapter->sessionId,
8795 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
8796 PDEV_CMD);
8797 break;
8798 }
8799
8800 case WE_GET_DYNAMIC_BW:
8801 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008802 hdd_notice("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008803 *value = wma_cli_get_command(pAdapter->sessionId,
8804 WMI_PDEV_PARAM_DYNAMIC_BW,
8805 PDEV_CMD);
8806 break;
8807 }
8808
8809 case WE_GET_11N_RATE:
8810 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008811 hdd_notice("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008812 *value = wma_cli_get_command(pAdapter->sessionId,
8813 WMI_VDEV_PARAM_FIXED_RATE,
8814 VDEV_CMD);
8815 break;
8816 }
8817
8818 case WE_GET_AMPDU:
8819 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008820 hdd_notice("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008821 *value = wma_cli_get_command(pAdapter->sessionId,
8822 GEN_VDEV_PARAM_AMPDU,
8823 GEN_CMD);
8824 break;
8825 }
8826
8827 case WE_GET_AMSDU:
8828 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008829 hdd_notice("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008830 *value = wma_cli_get_command(pAdapter->sessionId,
8831 GEN_VDEV_PARAM_AMSDU,
8832 GEN_CMD);
8833 break;
8834 }
8835
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07008836 case WE_GET_ROAM_SYNCH_DELAY:
8837 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008838 hdd_notice("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07008839 *value = wma_cli_get_command(pAdapter->sessionId,
8840 GEN_VDEV_ROAM_SYNCH_DELAY,
8841 GEN_CMD);
8842 break;
8843 }
8844
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008845 case WE_GET_BURST_ENABLE:
8846 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008847 hdd_notice("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008848 *value = wma_cli_get_command(pAdapter->sessionId,
8849 WMI_PDEV_PARAM_BURST_ENABLE,
8850 PDEV_CMD);
8851 break;
8852 }
8853 case WE_GET_BURST_DUR:
8854 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008855 hdd_notice("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008856 *value = wma_cli_get_command(pAdapter->sessionId,
8857 WMI_PDEV_PARAM_BURST_DUR,
8858 PDEV_CMD);
8859 break;
8860 }
8861
8862 case WE_GET_TX_CHAINMASK:
8863 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008864 hdd_notice("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008865 *value = wma_cli_get_command(pAdapter->sessionId,
8866 WMI_PDEV_PARAM_TX_CHAIN_MASK,
8867 PDEV_CMD);
8868 break;
8869 }
8870
8871 case WE_GET_RX_CHAINMASK:
8872 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008873 hdd_notice("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008874 *value = wma_cli_get_command(pAdapter->sessionId,
8875 WMI_PDEV_PARAM_RX_CHAIN_MASK,
8876 PDEV_CMD);
8877 break;
8878 }
8879
8880 case WE_GET_TXPOW_2G:
8881 {
8882 uint32_t txpow2g = 0;
8883 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07008884 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008885 *value = wma_cli_get_command(pAdapter->sessionId,
8886 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
8887 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308888 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008889 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
8890 &txpow2g)) {
8891 return -EIO;
8892 }
Jeff Johnson99bac312016-06-28 10:38:18 -07008893 hdd_notice("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008894 break;
8895 }
8896
8897 case WE_GET_TXPOW_5G:
8898 {
8899 uint32_t txpow5g = 0;
8900 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson99bac312016-06-28 10:38:18 -07008901 hdd_notice("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008902 *value = wma_cli_get_command(pAdapter->sessionId,
8903 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
8904 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308905 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008906 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
8907 &txpow5g)) {
8908 return -EIO;
8909 }
Jeff Johnson99bac312016-06-28 10:38:18 -07008910 hdd_notice("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008911 break;
8912 }
8913
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008914 case WE_GET_PPS_PAID_MATCH:
8915 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008916 hdd_notice("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008917 *value = wma_cli_get_command(pAdapter->sessionId,
8918 WMI_VDEV_PPS_PAID_MATCH,
8919 PPS_CMD);
8920 break;
8921 }
8922
8923 case WE_GET_PPS_GID_MATCH:
8924 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008925 hdd_notice("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008926 *value = wma_cli_get_command(pAdapter->sessionId,
8927 WMI_VDEV_PPS_GID_MATCH,
8928 PPS_CMD);
8929 break;
8930 }
8931
8932 case WE_GET_PPS_EARLY_TIM_CLEAR:
8933 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008934 hdd_notice("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008935 *value = wma_cli_get_command(pAdapter->sessionId,
8936 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
8937 PPS_CMD);
8938 break;
8939 }
8940
8941 case WE_GET_PPS_EARLY_DTIM_CLEAR:
8942 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008943 hdd_notice("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008944 *value = wma_cli_get_command(pAdapter->sessionId,
8945 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
8946 PPS_CMD);
8947 break;
8948 }
8949
8950 case WE_GET_PPS_EOF_PAD_DELIM:
8951 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008952 hdd_notice("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008953 *value = wma_cli_get_command(pAdapter->sessionId,
8954 WMI_VDEV_PPS_EOF_PAD_DELIM,
8955 PPS_CMD);
8956 break;
8957 }
8958
8959 case WE_GET_PPS_MACADDR_MISMATCH:
8960 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008961 hdd_notice("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008962 *value = wma_cli_get_command(pAdapter->sessionId,
8963 WMI_VDEV_PPS_MACADDR_MISMATCH,
8964 PPS_CMD);
8965 break;
8966 }
8967
8968 case WE_GET_PPS_DELIM_CRC_FAIL:
8969 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008970 hdd_notice("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008971 *value = wma_cli_get_command(pAdapter->sessionId,
8972 WMI_VDEV_PPS_DELIM_CRC_FAIL,
8973 PPS_CMD);
8974 break;
8975 }
8976
8977 case WE_GET_PPS_GID_NSTS_ZERO:
8978 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008979 hdd_notice("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008980 *value = wma_cli_get_command(pAdapter->sessionId,
8981 WMI_VDEV_PPS_GID_NSTS_ZERO,
8982 PPS_CMD);
8983 break;
8984 }
8985
8986 case WE_GET_PPS_RSSI_CHECK:
8987 {
8988
Jeff Johnson99bac312016-06-28 10:38:18 -07008989 hdd_notice("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008990 *value = wma_cli_get_command(pAdapter->sessionId,
8991 WMI_VDEV_PPS_RSSI_CHECK,
8992 PPS_CMD);
8993 break;
8994 }
8995
8996 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
8997 {
Jeff Johnson99bac312016-06-28 10:38:18 -07008998 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008999 *value = wma_cli_get_command(pAdapter->sessionId,
9000 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
9001 QPOWER_CMD);
9002 break;
9003 }
9004
9005 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
9006 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009007 hdd_notice("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009008 *value = wma_cli_get_command(pAdapter->sessionId,
9009 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
9010 QPOWER_CMD);
9011 break;
9012 }
9013
9014 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
9015 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009016 hdd_notice("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009017 *value = wma_cli_get_command(pAdapter->sessionId,
9018 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
9019 QPOWER_CMD);
9020 break;
9021 }
9022
9023 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
9024 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009025 hdd_notice("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009026 *value = wma_cli_get_command(pAdapter->sessionId,
9027 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
9028 QPOWER_CMD);
9029 break;
9030 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009031 case WE_CAP_TSF:
9032 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
9033 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009034 case WE_GET_TEMPERATURE:
9035 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009036 hdd_notice("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009037 ret = wlan_hdd_get_temperature(pAdapter, value);
9038 break;
9039 }
9040 default:
9041 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009042 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009043 value[0]);
9044 break;
9045 }
9046 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309047 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009048 return ret;
9049}
9050
9051static int iw_setnone_getint(struct net_device *dev,
9052 struct iw_request_info *info,
9053 union iwreq_data *wrqu, char *extra)
9054{
9055 int ret;
9056
9057 cds_ssr_protect(__func__);
9058 ret = __iw_setnone_getint(dev, info, wrqu, extra);
9059 cds_ssr_unprotect(__func__);
9060
9061 return ret;
9062}
9063
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309064static int hdd_set_fwtest(int argc, int cmd, int value)
9065{
9066 struct set_fwtest_params *fw_test;
9067
9068 /* check for max number of arguments */
9069 if (argc > (WMA_MAX_NUM_ARGS) ||
9070 argc != HDD_FWTEST_PARAMS) {
9071 hdd_err("Too Many args %d", argc);
9072 return -EINVAL;
9073 }
9074 /*
9075 * check if number of arguments are 3 then, check
9076 * then set the default value for sounding interval.
9077 */
9078 if (HDD_FWTEST_PARAMS == argc) {
9079 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
9080 value = HDD_FWTEST_SU_DEFAULT_VALUE;
9081 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
9082 value = HDD_FWTEST_MU_DEFAULT_VALUE;
9083 }
9084 /* check sounding interval value should not exceed to max */
9085 if (value > HDD_FWTEST_MAX_VALUE) {
9086 hdd_err("Invalid arguments value should not exceed max: %d",
9087 value);
9088 return -EINVAL;
9089 }
9090 fw_test = qdf_mem_malloc(sizeof(*fw_test));
9091 if (NULL == fw_test) {
9092 hdd_err("qdf_mem_malloc failed for fw_test");
9093 return -ENOMEM;
9094 }
9095 fw_test->arg = cmd;
9096 fw_test->value = value;
9097 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
9098 qdf_mem_free(fw_test);
9099 hdd_err("Not able to post FW_TEST_CMD message to WMA");
9100 return -EINVAL;
9101 }
9102 return 0;
9103}
9104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009105/**
9106 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
9107 * @dev: device upon which the ioctl was received
9108 * @info: ioctl request information
9109 * @wrqu: ioctl request data
9110 * @extra: ioctl extra data
9111 *
9112 * Return: 0 on success, non-zero on error
9113 */
9114static int __iw_set_three_ints_getnone(struct net_device *dev,
9115 struct iw_request_info *info,
9116 union iwreq_data *wrqu, char *extra)
9117{
9118 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9119 int *value = (int *)extra;
9120 int sub_cmd = value[0];
9121 int ret;
9122 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9123
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009124 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309125
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009126 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009127 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009128 return -EPERM;
9129 }
9130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009131 ret = wlan_hdd_validate_context(hdd_ctx);
9132 if (0 != ret)
9133 return ret;
9134
Jeff Johnson441e1f72017-02-07 08:50:49 -08009135 ret = hdd_check_private_wext_control(hdd_ctx, info);
9136 if (0 != ret)
9137 return ret;
9138
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009139 switch (sub_cmd) {
9140
9141 case WE_SET_WLAN_DBG:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309142 qdf_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009143 break;
9144 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309145 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009146 break;
9147
9148 /* value[3] the acs band is not required as start and end channels are
9149 * enough but this cmd is maintained under set three ints for historic
9150 * reasons.
9151 */
9152 case WE_SET_SAP_CHANNELS:
9153 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309154 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009155 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309156 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009157 ret = -EINVAL;
9158 } else {
9159 hdd_ctx->config->force_sap_acs_st_ch = value[1];
9160 hdd_ctx->config->force_sap_acs_end_ch = value[2];
9161 }
9162 break;
9163 case WE_SET_DUAL_MAC_SCAN_CONFIG:
9164 hdd_debug("Ioctl to set dual mac scan config");
9165 if (hdd_ctx->config->dual_mac_feature_disable) {
9166 hdd_err("Dual mac feature is disabled from INI");
9167 return -EPERM;
9168 }
9169 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08009170 cds_set_dual_mac_scan_config(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009171 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309172 case WE_SET_FW_TEST:
9173 {
9174 ret = hdd_set_fwtest(value[1], value[2], value[3]);
9175 if (ret) {
9176 hdd_err("Not able to set fwtest %d", ret);
9177 return ret;
9178 }
9179 }
9180 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009181 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009182 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009183 break;
9184
9185 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309186 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009187 return ret;
9188}
9189
9190int iw_set_three_ints_getnone(struct net_device *dev,
9191 struct iw_request_info *info,
9192 union iwreq_data *wrqu, char *extra)
9193{
9194 int ret;
9195
9196 cds_ssr_protect(__func__);
9197 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
9198 cds_ssr_unprotect(__func__);
9199
9200 return ret;
9201}
9202
9203/**
9204 * hdd_connection_state_string() - Get connection state string
9205 * @connection_state: enum to be converted to a string
9206 *
9207 * Return: the string equivalent of @connection_state
9208 */
9209static const char *
9210hdd_connection_state_string(eConnectionState connection_state)
9211{
9212 switch (connection_state) {
9213 CASE_RETURN_STRING(eConnectionState_NotConnected);
9214 CASE_RETURN_STRING(eConnectionState_Connecting);
9215 CASE_RETURN_STRING(eConnectionState_Associated);
9216 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
9217 CASE_RETURN_STRING(eConnectionState_IbssConnected);
9218 CASE_RETURN_STRING(eConnectionState_Disconnecting);
9219 default:
9220 return "UNKNOWN";
9221 }
9222}
9223
9224/**
9225 * iw_get_char_setnone() - Generic "get string" private ioctl handler
9226 * @dev: device upon which the ioctl was received
9227 * @info: ioctl request information
9228 * @wrqu: ioctl request data
9229 * @extra: ioctl extra data
9230 *
9231 * Return: 0 on success, non-zero on error
9232 */
9233static int __iw_get_char_setnone(struct net_device *dev,
9234 struct iw_request_info *info,
9235 union iwreq_data *wrqu, char *extra)
9236{
9237 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9238 int sub_cmd = wrqu->data.flags;
9239 hdd_context_t *hdd_ctx;
9240 int ret;
9241#ifdef WLAN_FEATURE_11W
9242 hdd_wext_state_t *pWextState;
9243#endif
9244
9245#ifdef WLAN_FEATURE_11W
9246 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9247#endif
9248
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009249 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309250
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009251 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9252 ret = wlan_hdd_validate_context(hdd_ctx);
9253 if (0 != ret)
9254 return ret;
9255
Jeff Johnson441e1f72017-02-07 08:50:49 -08009256 ret = hdd_check_private_wext_control(hdd_ctx, info);
9257 if (0 != ret)
9258 return ret;
9259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009260 switch (sub_cmd) {
9261 case WE_WLAN_VERSION:
9262 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05309263 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009264 break;
9265 }
9266
9267 case WE_GET_STATS:
9268 {
9269 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
9270 extra, WE_MAX_STR_LEN);
9271 break;
9272 }
9273
Dustin Brownd9322482017-01-09 12:46:03 -08009274 case WE_GET_SUSPEND_RESUME_STATS:
9275 {
9276 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
9277 WE_MAX_STR_LEN);
9278 if (ret >= 0) {
9279 wrqu->data.length = ret;
9280 ret = 0;
9281 }
9282
9283 break;
9284 }
9285
Govind Singha471e5e2015-10-12 17:11:14 +05309286 case WE_LIST_FW_PROFILE:
9287 hdd_wlan_list_fw_profile(&(wrqu->data.length),
9288 extra, WE_MAX_STR_LEN);
9289 break;
9290
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009291 /* The case prints the current state of the HDD, SME, CSR, PE,
9292 * TL it can be extended for WDI Global State as well. And
9293 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
9294 * and P2P_GO have not been added as of now.
9295 */
9296 case WE_GET_STATES:
9297 {
9298 int buf = 0, len = 0;
9299 int adapter_num = 0;
9300 int count = 0, check = 1;
9301
9302 tHalHandle hHal = NULL;
9303 tpAniSirGlobal pMac = NULL;
9304 hdd_station_ctx_t *pHddStaCtx = NULL;
9305
9306 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9307 hdd_adapter_t *useAdapter = NULL;
9308
9309 /* Print wlan0 or p2p0 states based on the adapter_num
9310 * by using the correct adapter
9311 */
9312 while (adapter_num < 2) {
9313 if (WLAN_ADAPTER == adapter_num) {
9314 useAdapter = pAdapter;
9315 buf =
9316 scnprintf(extra + len,
9317 WE_MAX_STR_LEN - len,
9318 "\n\n wlan0 States:-");
9319 len += buf;
9320 } else if (P2P_ADAPTER == adapter_num) {
9321 buf =
9322 scnprintf(extra + len,
9323 WE_MAX_STR_LEN - len,
9324 "\n\n p2p0 States:-");
9325 len += buf;
9326
9327 if (!pHddCtx) {
9328 buf =
9329 scnprintf(extra + len,
9330 WE_MAX_STR_LEN -
9331 len,
9332 "\n pHddCtx is NULL");
9333 len += buf;
9334 break;
9335 }
9336
9337 /* Printing p2p0 states only in the
9338 * case when the device is configured
9339 * as a p2p_client
9340 */
9341 useAdapter =
9342 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -08009343 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009344 if (!useAdapter) {
9345 buf =
9346 scnprintf(extra + len,
9347 WE_MAX_STR_LEN -
9348 len,
9349 "\n Device not configured as P2P_CLIENT.");
9350 len += buf;
9351 break;
9352 }
9353 }
9354
9355 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
9356 if (!hHal) {
9357 buf =
9358 scnprintf(extra + len,
9359 WE_MAX_STR_LEN - len,
9360 "\n pMac is NULL");
9361 len += buf;
9362 break;
9363 }
9364 pMac = PMAC_STRUCT(hHal);
9365 if (!pMac) {
9366 buf =
9367 scnprintf(extra + len,
9368 WE_MAX_STR_LEN - len,
9369 "\n pMac is NULL");
9370 len += buf;
9371 break;
9372 }
9373 pHddStaCtx =
9374 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
9375
9376
9377 buf =
9378 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9379 "\n HDD Conn State - %s "
9380 "\n \n SME State:"
9381 "\n Neighbour Roam State - %s"
9382 "\n CSR State - %s"
9383 "\n CSR Substate - %s",
9384 hdd_connection_state_string
9385 (pHddStaCtx->conn_info.connState),
9386 mac_trace_get_neighbour_roam_state
9387 (sme_get_neighbor_roam_state
9388 (hHal, useAdapter->sessionId)),
9389 mac_trace_getcsr_roam_state
9390 (sme_get_current_roam_state
9391 (hHal, useAdapter->sessionId)),
9392 mac_trace_getcsr_roam_sub_state
9393 (sme_get_current_roam_sub_state
9394 (hHal, useAdapter->sessionId))
9395 );
9396 len += buf;
9397 adapter_num++;
9398 }
9399
Mukul Sharma81661ae2015-10-30 20:26:02 +05309400 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009401 /* Printing Lim State starting with global lim states */
9402 buf =
9403 scnprintf(extra + len, WE_MAX_STR_LEN - len,
9404 "\n \n LIM STATES:-"
9405 "\n Global Sme State - %s "
9406 "\n Global mlm State - %s " "\n",
9407 mac_trace_get_lim_sme_state
9408 (sme_get_lim_sme_state(hHal)),
9409 mac_trace_get_lim_mlm_state
9410 (sme_get_lim_sme_state(hHal))
9411 );
9412 len += buf;
9413
9414 /* Printing the PE Sme and Mlm states for valid lim sessions */
9415 while (check < 3 && count < 255) {
9416 if (sme_is_lim_session_valid(hHal, count)) {
9417 buf =
9418 scnprintf(extra + len,
9419 WE_MAX_STR_LEN -
9420 len,
9421 "\n Lim Valid Session %d:-"
9422 "\n PE Sme State - %s "
9423 "\n PE Mlm State - %s "
9424 "\n", check,
9425 mac_trace_get_lim_sme_state
9426 (sme_get_lim_sme_session_state
9427 (hHal, count)),
9428 mac_trace_get_lim_mlm_state
9429 (sme_get_lim_mlm_session_state
9430 (hHal, count))
9431 );
9432
9433 len += buf;
9434 check++;
9435 }
9436 count++;
9437 }
9438 }
9439
9440 wrqu->data.length = strlen(extra) + 1;
9441 break;
9442 }
9443
9444 case WE_GET_CFG:
9445 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009446 hdd_notice("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009447 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
9448 extra,
9449 QCSAP_IOCTL_MAX_STR_LEN);
9450 wrqu->data.length = strlen(extra) + 1;
9451 break;
9452 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009453 case WE_GET_RSSI:
9454 {
9455 int8_t s7Rssi = 0;
9456 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
9457 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
9458 wrqu->data.length = strlen(extra) + 1;
9459 break;
9460 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009461
9462 case WE_GET_WMM_STATUS:
9463 {
9464 snprintf(extra, WE_MAX_STR_LEN,
9465 "\nDir: 0=up, 1=down, 3=both\n"
9466 "|------------------------|\n"
9467 "|AC | ACM |Admitted| Dir |\n"
9468 "|------------------------|\n"
9469 "|VO | %d | %3s | %d |\n"
9470 "|VI | %d | %3s | %d |\n"
9471 "|BE | %d | %3s | %d |\n"
9472 "|BK | %d | %3s | %d |\n"
9473 "|------------------------|\n",
9474 pAdapter->hddWmmStatus.
9475 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
9476 pAdapter->hddWmmStatus.
9477 wmmAcStatus[SME_AC_VO].
9478 wmmAcAccessAllowed ? "YES" : "NO",
9479 pAdapter->hddWmmStatus.
9480 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
9481 ts_info.direction,
9482 pAdapter->hddWmmStatus.
9483 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
9484 pAdapter->hddWmmStatus.
9485 wmmAcStatus[SME_AC_VI].
9486 wmmAcAccessAllowed ? "YES" : "NO",
9487 pAdapter->hddWmmStatus.
9488 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
9489 ts_info.direction,
9490 pAdapter->hddWmmStatus.
9491 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
9492 pAdapter->hddWmmStatus.
9493 wmmAcStatus[SME_AC_BE].
9494 wmmAcAccessAllowed ? "YES" : "NO",
9495 pAdapter->hddWmmStatus.
9496 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
9497 ts_info.direction,
9498 pAdapter->hddWmmStatus.
9499 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
9500 pAdapter->hddWmmStatus.
9501 wmmAcStatus[SME_AC_BK].
9502 wmmAcAccessAllowed ? "YES" : "NO",
9503 pAdapter->hddWmmStatus.
9504 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
9505 ts_info.direction);
9506
9507 wrqu->data.length = strlen(extra) + 1;
9508 break;
9509 }
9510 case WE_GET_CHANNEL_LIST:
9511 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309512 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009513 uint8_t i, len;
9514 char *buf;
9515 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
9516 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
9517 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9518
9519 tChannelListInfo channel_list;
9520
9521 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +05309522 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009523 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309524 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009525 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009526 return -EINVAL;
9527 }
9528 buf = extra;
9529 /*
9530 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
9531 * Maximum buffer needed = 5 * number of channels.
9532 * Check ifsufficient buffer is available and then
9533 * proceed to fill the buffer.
9534 */
9535 if (WE_MAX_STR_LEN <
9536 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009537 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009538 return -EINVAL;
9539 }
9540 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
9541 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309542 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009543 ubuf, &ubuf_len)) {
9544 /* Printing Country code in getChannelList */
9545 for (i = 0; i < (ubuf_len - 1); i++)
9546 len += scnprintf(buf + len,
9547 WE_MAX_STR_LEN - len,
9548 "%c", ubuf[i]);
9549 }
9550 for (i = 0; i < channel_list.num_channels; i++) {
9551 len +=
9552 scnprintf(buf + len, WE_MAX_STR_LEN - len,
9553 " %u", channel_list.channels[i]);
9554 }
9555 wrqu->data.length = strlen(extra) + 1;
9556
9557 break;
9558 }
9559#ifdef FEATURE_WLAN_TDLS
9560 case WE_GET_TDLS_PEERS:
9561 {
9562 wrqu->data.length =
9563 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
9564 WE_MAX_STR_LEN) + 1;
9565 break;
9566 }
9567#endif
9568#ifdef WLAN_FEATURE_11W
9569 case WE_GET_11W_INFO:
9570 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009571 hdd_err("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009572 pWextState->roamProfile.MFPEnabled);
9573
9574 snprintf(extra, WE_MAX_STR_LEN,
9575 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
9576 "\n Number of Unprotected Disassocs %d"
9577 "\n Number of Unprotected Deauths %d",
9578 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
9579 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
9580 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
9581 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
9582 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
9583 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
9584 pWextState->roamProfile.MFPEnabled,
9585 pAdapter->hdd_stats.hddPmfStats.
9586 numUnprotDisassocRx,
9587 pAdapter->hdd_stats.hddPmfStats.
9588 numUnprotDeauthRx);
9589
9590 wrqu->data.length = strlen(extra) + 1;
9591 break;
9592 }
9593#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009594 case WE_GET_IBSS_STA_INFO:
9595 {
9596 hdd_station_ctx_t *pHddStaCtx =
9597 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9598 int idx = 0;
9599 int length = 0, buf = 0;
9600
Naveen Rawatc45d1622016-07-05 12:20:09 -07009601 for (idx = 0; idx < MAX_PEERS; idx++) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009602 if (0 != pHddStaCtx->conn_info.staId[idx]) {
9603 buf = snprintf
9604 ((extra + length),
9605 WE_MAX_STR_LEN - length,
9606 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
9607 pHddStaCtx->conn_info.staId[idx],
9608 pHddStaCtx->conn_info.
9609 peerMacAddress[idx].bytes[0],
9610 pHddStaCtx->conn_info.
9611 peerMacAddress[idx].bytes[1],
9612 pHddStaCtx->conn_info.
9613 peerMacAddress[idx].bytes[2],
9614 pHddStaCtx->conn_info.
9615 peerMacAddress[idx].bytes[3],
9616 pHddStaCtx->conn_info.
9617 peerMacAddress[idx].bytes[4],
9618 pHddStaCtx->conn_info.
9619 peerMacAddress[idx].bytes[5]
9620 );
9621 length += buf;
9622 }
9623 }
9624 wrqu->data.length = strlen(extra) + 1;
9625 break;
9626 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009627 case WE_GET_PHYMODE:
9628 {
9629 bool ch_bond24 = false, ch_bond5g = false;
9630 hdd_context_t *hddctx = WLAN_HDD_GET_CTX(pAdapter);
9631 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9632 eCsrPhyMode phymode;
9633 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -08009634 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009635
Dustin Browne9c6b3a2017-01-23 17:17:32 -08009636 sme_config = qdf_mem_malloc(sizeof(*sme_config));
9637 if (!sme_config) {
9638 hdd_err("Out of memory");
9639 ret = -ENOMEM;
9640 break;
9641 }
9642
9643 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009644 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08009645 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009646 ch_bond24 = true;
9647
9648 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -08009649 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009650 ch_bond5g = true;
9651
Dustin Browne9c6b3a2017-01-23 17:17:32 -08009652 qdf_mem_free(sme_config);
9653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009654 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309655 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009656 sme_get_freq_band(hal, &currBand))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009657 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009658 return -EIO;
9659 }
9660
9661 switch (phymode) {
9662 case eCSR_DOT11_MODE_AUTO:
9663 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
9664 break;
9665 case eCSR_DOT11_MODE_11n:
9666 case eCSR_DOT11_MODE_11n_ONLY:
9667 if (currBand == eCSR_BAND_24) {
9668 if (ch_bond24)
9669 snprintf(extra, WE_MAX_STR_LEN,
9670 "11NGHT40");
9671 else
9672 snprintf(extra, WE_MAX_STR_LEN,
9673 "11NGHT20");
9674 } else if (currBand == eCSR_BAND_5G) {
9675 if (ch_bond5g)
9676 snprintf(extra, WE_MAX_STR_LEN,
9677 "11NAHT40");
9678 else
9679 snprintf(extra, WE_MAX_STR_LEN,
9680 "11NAHT20");
9681 } else {
9682 snprintf(extra, WE_MAX_STR_LEN, "11N");
9683 }
9684 break;
9685 case eCSR_DOT11_MODE_abg:
9686 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
9687 break;
9688 case eCSR_DOT11_MODE_11a:
9689 snprintf(extra, WE_MAX_STR_LEN, "11A");
9690 break;
9691 case eCSR_DOT11_MODE_11b:
9692 case eCSR_DOT11_MODE_11b_ONLY:
9693 snprintf(extra, WE_MAX_STR_LEN, "11B");
9694 break;
9695 case eCSR_DOT11_MODE_11g:
9696 case eCSR_DOT11_MODE_11g_ONLY:
9697 snprintf(extra, WE_MAX_STR_LEN, "11G");
9698 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009699 case eCSR_DOT11_MODE_11ac:
9700 case eCSR_DOT11_MODE_11ac_ONLY:
9701 if (hddctx->config->vhtChannelWidth ==
9702 eHT_CHANNEL_WIDTH_20MHZ)
9703 snprintf(extra, WE_MAX_STR_LEN,
9704 "11ACVHT20");
9705 else if (hddctx->config->vhtChannelWidth ==
9706 eHT_CHANNEL_WIDTH_40MHZ)
9707 snprintf(extra, WE_MAX_STR_LEN,
9708 "11ACVHT40");
9709 else if (hddctx->config->vhtChannelWidth ==
9710 eHT_CHANNEL_WIDTH_80MHZ)
9711 snprintf(extra, WE_MAX_STR_LEN,
9712 "11ACVHT80");
9713 else if (hddctx->config->vhtChannelWidth ==
9714 eHT_CHANNEL_WIDTH_160MHZ)
9715 snprintf(extra, WE_MAX_STR_LEN,
9716 "11ACVHT160");
9717 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009718 }
9719
9720 wrqu->data.length = strlen(extra) + 1;
9721 break;
9722 }
9723
9724#ifdef FEATURE_OEM_DATA_SUPPORT
9725 case WE_GET_OEM_DATA_CAP:
9726 {
9727 return iw_get_oem_data_cap(dev, info, wrqu, extra);
9728 }
9729#endif /* FEATURE_OEM_DATA_SUPPORT */
9730 case WE_GET_SNR:
9731 {
9732 int8_t s7snr = 0;
9733 int status = 0;
9734 hdd_context_t *pHddCtx;
9735 hdd_station_ctx_t *pHddStaCtx;
9736 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9737 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05309738 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009739 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05309740
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009741 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9742 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
9743 eConnectionState_Associated !=
9744 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009745 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009746 pHddCtx->config->fEnableSNRMonitoring,
9747 pHddStaCtx->conn_info.connState);
9748 return -ENONET;
9749 }
9750 wlan_hdd_get_snr(pAdapter, &s7snr);
9751 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
9752 wrqu->data.length = strlen(extra) + 1;
9753 break;
9754 }
9755 default:
9756 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009757 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009758 sub_cmd);
9759 break;
9760 }
9761 }
Dustin Brownd9322482017-01-09 12:46:03 -08009762
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309763 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -08009764 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009765}
9766
9767static int iw_get_char_setnone(struct net_device *dev,
9768 struct iw_request_info *info,
9769 union iwreq_data *wrqu, char *extra)
9770{
9771 int ret;
9772
9773 cds_ssr_protect(__func__);
9774 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
9775 cds_ssr_unprotect(__func__);
9776
9777 return ret;
9778}
9779
9780/**
9781 * iw_setnone_getnone() - Generic "action" private ioctl handler
9782 * @dev: device upon which the ioctl was received
9783 * @info: ioctl request information
9784 * @wrqu: ioctl request data
9785 * @extra: ioctl extra data
9786 *
9787 * Return: 0 on success, non-zero on error
9788 */
9789static int __iw_setnone_getnone(struct net_device *dev,
9790 struct iw_request_info *info,
9791 union iwreq_data *wrqu, char *extra)
9792{
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009793 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009794 hdd_context_t *hdd_ctx;
9795 int ret;
9796 int sub_cmd;
9797
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009798 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309799
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009800 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009801 ret = wlan_hdd_validate_context(hdd_ctx);
9802 if (0 != ret)
9803 return ret;
9804
Jeff Johnson441e1f72017-02-07 08:50:49 -08009805 ret = hdd_check_private_wext_control(hdd_ctx, info);
9806 if (0 != ret)
9807 return ret;
9808
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009809#ifdef CONFIG_COMPAT
9810 /* this ioctl is a special case where a sub-ioctl is used and both
9811 * the number of get and set args is 0. in this specific case the
9812 * logic in iwpriv places the sub_cmd in the data.flags portion of
9813 * the iwreq. unfortunately the location of this field will be
9814 * different between 32-bit and 64-bit userspace, and the standard
9815 * compat support in the kernel does not handle this case. so we
9816 * need to explicitly handle it here.
9817 */
9818 if (is_compat_task()) {
9819 struct compat_iw_point *compat_iw_point =
9820 (struct compat_iw_point *)&wrqu->data;
9821 sub_cmd = compat_iw_point->flags;
9822 } else {
9823 sub_cmd = wrqu->data.flags;
9824 }
9825#else
9826 sub_cmd = wrqu->data.flags;
9827#endif
9828
9829 switch (sub_cmd) {
9830 case WE_GET_RECOVERY_STAT:
9831 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009832 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009833 sme_get_recovery_stats(hal);
9834 break;
9835 }
9836
Govind Singha471e5e2015-10-12 17:11:14 +05309837 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009838 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05309839 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
9840 0, DBG_CMD);
9841 break;
9842
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009843 case WE_IBSS_GET_PEER_INFO_ALL:
9844 {
9845 hdd_wlan_get_ibss_peer_info_all(adapter);
9846 break;
9847 }
9848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009849 case WE_SET_REASSOC_TRIGGER:
9850 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009851 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9852 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05309853 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009854 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05309855 uint8_t operating_ch =
9856 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009857 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009858
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009859 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009860 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05309861 if (roaming_offload_enabled(hdd_ctx)) {
9862 qdf_mem_copy(bssid,
9863 &adapter->sessionCtx.station.conn_info.bssId,
9864 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -08009865 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +05309866 bssid, operating_ch);
9867 } else {
9868 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
9869 NULL, modProfileFields, &roamId, 1);
9870 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009871 return 0;
9872 }
9873
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08009874 case WE_STOP_OBSS_SCAN:
9875 {
9876 /*
9877 * 1.OBSS Scan is mandatory while operating in 2.4GHz
9878 * 2.OBSS scan is stopped by Firmware during the disassociation
9879 * 3.OBSS stop comamnd is added for debugging purpose
9880 */
9881 tHalHandle hal;
9882
9883 hal = WLAN_HDD_GET_HAL_CTX(adapter);
9884 if (hal == NULL) {
9885 hdd_err("hal context is NULL");
9886 return -EINVAL;
9887 }
9888 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
9889 }
9890 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009891 default:
9892 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009893 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009894 break;
9895 }
9896 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309897 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009898 return ret;
9899}
9900
9901static int iw_setnone_getnone(struct net_device *dev,
9902 struct iw_request_info *info,
9903 union iwreq_data *wrqu, char *extra)
9904{
9905 int ret;
9906
9907 cds_ssr_protect(__func__);
9908 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
9909 cds_ssr_unprotect(__func__);
9910
9911 return ret;
9912}
9913
Krunal Sonia6e505b2017-01-12 12:25:18 -08009914#ifdef MPC_UT_FRAMEWORK
9915static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
9916 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
9917{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -08009918 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -08009919 case WE_POLICY_MANAGER_CLIST_CMD:
9920 {
9921 hdd_err("<iwpriv wlan0 pm_clist> is called");
9922 cds_incr_connection_count_utfw(apps_args[0],
9923 apps_args[1], apps_args[2], apps_args[3],
9924 apps_args[4], apps_args[5], apps_args[6],
9925 apps_args[7]);
9926 }
9927 break;
9928
9929 case WE_POLICY_MANAGER_DLIST_CMD:
9930 {
9931 hdd_err("<iwpriv wlan0 pm_dlist> is called");
9932 cds_decr_connection_count_utfw(apps_args[0],
9933 apps_args[1]);
9934 }
9935 break;
9936
9937 case WE_POLICY_MANAGER_ULIST_CMD:
9938 {
9939 hdd_err("<iwpriv wlan0 pm_ulist> is called");
9940 cds_update_connection_info_utfw(apps_args[0],
9941 apps_args[1], apps_args[2], apps_args[3],
9942 apps_args[4], apps_args[5], apps_args[6],
9943 apps_args[7]);
9944 }
9945 break;
9946
9947 case WE_POLICY_MANAGER_DBS_CMD:
9948 {
9949 hdd_err("<iwpriv wlan0 pm_dbs> is called");
9950 if (apps_args[0] == 0)
9951 wma_set_dbs_capability_ut(0);
9952 else
9953 wma_set_dbs_capability_ut(1);
9954
9955 if (apps_args[1] >= CDS_THROUGHPUT &&
9956 apps_args[1] <= CDS_LATENCY) {
9957 pr_info("setting system pref to [%d]\n", apps_args[1]);
9958 hdd_ctx->config->conc_system_pref = apps_args[1];
9959 }
9960 }
9961 break;
9962
9963 case WE_POLICY_MANAGER_PCL_CMD:
9964 {
9965 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
9966 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
9967 uint32_t pcl_len = 0, i = 0;
9968
9969 hdd_err("<iwpriv wlan0 pm_pcl> is called");
9970
9971 cds_get_pcl(apps_args[0],
9972 pcl, &pcl_len,
9973 weight_list, QDF_ARRAY_SIZE(weight_list));
9974 pr_info("PCL list for role[%d] is {", apps_args[0]);
9975 for (i = 0 ; i < pcl_len; i++)
9976 pr_info(" %d, ", pcl[i]);
9977 pr_info("}--------->\n");
9978 }
9979 break;
9980
9981 case WE_POLICY_SET_HW_MODE_CMD:
9982 {
9983 if (apps_args[0] == 0) {
9984 hdd_err("set hw mode for single mac");
9985 cds_pdev_set_hw_mode(
9986 adapter->sessionId,
9987 HW_MODE_SS_2x2,
9988 HW_MODE_80_MHZ,
9989 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
9990 HW_MODE_DBS_NONE,
9991 HW_MODE_AGILE_DFS_NONE,
9992 HW_MODE_SBS_NONE,
9993 SIR_UPDATE_REASON_UT);
9994 } else if (apps_args[0] == 1) {
9995 hdd_err("set hw mode for dual mac");
9996 cds_pdev_set_hw_mode(
9997 adapter->sessionId,
9998 HW_MODE_SS_1x1,
9999 HW_MODE_80_MHZ,
10000 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
10001 HW_MODE_DBS,
10002 HW_MODE_AGILE_DFS_NONE,
10003 HW_MODE_SBS_NONE,
10004 SIR_UPDATE_REASON_UT);
10005 }
10006 }
10007 break;
10008
10009 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10010 {
10011 enum cds_conc_next_action action;
10012 hdd_notice("<iwpriv wlan0 pm_query_action> is called");
10013 action = cds_current_connections_update(adapter->sessionId,
10014 apps_args[0],
10015 SIR_UPDATE_REASON_UT);
10016 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
10017 }
10018 break;
10019
10020 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10021 {
10022 bool allow;
10023 hdd_err("<iwpriv wlan0 pm_query_allow> is called");
10024 allow = cds_allow_concurrency(
10025 apps_args[0], apps_args[1], apps_args[2]);
10026 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
10027 }
10028 break;
10029
10030 case WE_POLICY_MANAGER_SCENARIO_CMD:
10031 {
10032 clean_report(hdd_ctx);
10033 if (apps_args[0] == 1) {
10034 wlan_hdd_one_connection_scenario(hdd_ctx);
10035 } else if (apps_args[0] == 2) {
10036 wlan_hdd_two_connections_scenario(hdd_ctx,
10037 6, CDS_TWO_TWO);
10038 wlan_hdd_two_connections_scenario(hdd_ctx,
10039 36, CDS_TWO_TWO);
10040 wlan_hdd_two_connections_scenario(hdd_ctx,
10041 6, CDS_ONE_ONE);
10042 wlan_hdd_two_connections_scenario(hdd_ctx,
10043 36, CDS_ONE_ONE);
10044 } else if (apps_args[0] == 3) {
10045 /* MCC on same band with 2x2 same mac*/
10046 wlan_hdd_three_connections_scenario(hdd_ctx,
10047 6, 11, CDS_TWO_TWO, 0);
10048 /* MCC on diff band with 2x2 same mac*/
10049 wlan_hdd_three_connections_scenario(hdd_ctx,
10050 6, 36, CDS_TWO_TWO, 0);
10051 /* MCC on diff band with 1x1 diff mac */
10052 wlan_hdd_three_connections_scenario(hdd_ctx,
10053 36, 6, CDS_ONE_ONE, 0);
10054 /* MCC on diff band with 1x1 same mac */
10055 wlan_hdd_three_connections_scenario(hdd_ctx,
10056 36, 6, CDS_ONE_ONE, 1);
10057 /* SCC on same band with 2x2 same mac */
10058 wlan_hdd_three_connections_scenario(hdd_ctx,
10059 36, 36, CDS_TWO_TWO, 0);
10060 /* SCC on same band with 1x1 same mac */
10061 wlan_hdd_three_connections_scenario(hdd_ctx,
10062 36, 36, CDS_ONE_ONE, 1);
10063 /* MCC on same band with 2x2 same mac */
10064 wlan_hdd_three_connections_scenario(hdd_ctx,
10065 36, 149, CDS_TWO_TWO, 0);
10066 /* MCC on same band with 1x1 same mac */
10067 wlan_hdd_three_connections_scenario(hdd_ctx,
10068 36, 149, CDS_ONE_ONE, 1);
10069 }
10070 print_report(hdd_ctx);
10071 }
10072 break;
10073 }
10074 return 0;
10075}
10076#else
10077static int iw_get_policy_manager_ut_ops(hdd_context_t *hdd_ctx,
10078 hdd_adapter_t *adapter, int sub_cmd, int *apps_args)
10079{
10080 return 0;
10081}
10082#endif
10083
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010084/**
10085 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10086 * @dev: device upon which the ioctl was received
10087 * @info: ioctl request information
10088 * @wrqu: ioctl request data
10089 * @extra: ioctl extra data
10090 *
10091 * This is an SSR-protected generic handler for private ioctls which
10092 * take multiple arguments. Note that this implementation is also
10093 * somewhat unique in that it is shared by both STA-mode and SAP-mode
10094 * interfaces.
10095 *
10096 * Return: 0 on success, non-zero on error
10097 */
10098static int __iw_set_var_ints_getnone(struct net_device *dev,
10099 struct iw_request_info *info,
10100 union iwreq_data *wrqu, char *extra)
10101{
10102 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10103 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10104 int sub_cmd;
10105 int *apps_args = (int *) extra;
10106 hdd_context_t *hdd_ctx;
10107 int ret, num_args;
10108
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010109 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010111 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10112 ret = wlan_hdd_validate_context(hdd_ctx);
10113 if (0 != ret)
10114 return ret;
10115
Jeff Johnson441e1f72017-02-07 08:50:49 -080010116 ret = hdd_check_private_wext_control(hdd_ctx, info);
10117 if (0 != ret)
10118 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010119
10120 sub_cmd = wrqu->data.flags;
10121 num_args = wrqu->data.length;
10122
Jeff Johnson99bac312016-06-28 10:38:18 -070010123 hdd_notice("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010124
10125 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010126 case WE_IBSS_GET_PEER_INFO:
10127 {
10128 pr_info("Station ID = %d\n", apps_args[0]);
10129 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
10130 }
10131 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010132
10133 case WE_P2P_NOA_CMD:
10134 {
10135 p2p_app_setP2pPs_t p2pNoA;
10136
Krunal Sonif07bb382016-03-10 13:02:11 -080010137 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -080010138 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
10139 hdd_device_mode_to_string(
10140 pAdapter->device_mode),
10141 pAdapter->device_mode);
10142 return -EINVAL;
10143 }
10144
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010145 p2pNoA.opp_ps = apps_args[0];
10146 p2pNoA.ctWindow = apps_args[1];
10147 p2pNoA.duration = apps_args[2];
10148 p2pNoA.interval = apps_args[3];
10149 p2pNoA.count = apps_args[4];
10150 p2pNoA.single_noa_duration = apps_args[5];
10151 p2pNoA.psSelection = apps_args[6];
10152
Jeff Johnson99bac312016-06-28 10:38:18 -070010153 hdd_notice("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
10154 apps_args[0], apps_args[1], apps_args[2],
10155 apps_args[3], apps_args[4],
10156 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010157
10158 hdd_set_p2p_ps(dev, &p2pNoA);
10159
10160 }
10161 break;
10162
10163 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
10164 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010165 hdd_notice("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
10166 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010167 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010168 }
10169 break;
10170
10171 case WE_MTRACE_DUMP_CMD:
10172 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010173 hdd_notice("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
10174 apps_args[0], apps_args[1],
10175 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010176 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010177 apps_args[1], apps_args[2],
10178 apps_args[3]);
10179
10180 }
10181 break;
10182
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010183 case WE_POLICY_MANAGER_CINFO_CMD:
10184 {
10185 struct cds_conc_connection_info *conn_info;
10186 uint32_t i = 0, len = 0;
10187
Krunal Sonia6e505b2017-01-12 12:25:18 -080010188 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -080010189 conn_info = cds_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010190 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010191 for (i = 0; i < len; i++) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010192 pr_info("|table_index[%d]\t\t\n", i);
10193 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
10194 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
10195 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
10196 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
10197 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
10198 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
10199 pr_info("+--------------------------+\n");
10200 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010201 }
10202 }
10203 break;
10204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010205
10206#ifdef FEATURE_WLAN_TDLS
10207 case WE_TDLS_CONFIG_PARAMS:
10208 {
10209 tdls_config_params_t tdlsParams;
10210
10211 tdlsParams.tdls = apps_args[0];
10212 tdlsParams.tx_period_t = apps_args[1];
10213 tdlsParams.tx_packet_n = apps_args[2];
10214 /* ignore args[3] as discovery_period is not used anymore */
10215 tdlsParams.discovery_tries_n = apps_args[4];
10216 /* ignore args[5] as idle_timeout is not used anymore */
10217 tdlsParams.idle_packet_n = apps_args[6];
10218 /* ignore args[7] as rssi_hysteresis is not used anymore */
10219 tdlsParams.rssi_trigger_threshold = apps_args[8];
10220 tdlsParams.rssi_teardown_threshold = apps_args[9];
10221 tdlsParams.rssi_delta = apps_args[10];
10222
10223 wlan_hdd_tdls_set_params(dev, &tdlsParams);
10224 }
10225 break;
10226#endif
10227 case WE_UNIT_TEST_CMD:
10228 {
10229 t_wma_unit_test_cmd *unitTestArgs;
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010230 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010231 int i, j;
10232 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
10233 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010234 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010235 apps_args[0]);
10236 return -EINVAL;
10237 }
Anurag Chouhan77564182016-09-03 16:38:01 +053010238 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
10239 (apps_args[1] < 0)) {
10240 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010241 apps_args[1]);
10242 return -EINVAL;
10243 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010244 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010245 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010246 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010247 return -ENOMEM;
10248 }
10249 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
10250 unitTestArgs->module_id = apps_args[0];
10251 unitTestArgs->num_args = apps_args[1];
10252 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++) {
10253 unitTestArgs->args[i] = apps_args[j];
10254 }
10255 msg.type = SIR_HAL_UNIT_TEST_CMD;
10256 msg.reserved = 0;
10257 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010258 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarea95edd2017-01-11 20:49:36 -080010259 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010260 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -070010261 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010262 return -EINVAL;
10263 }
10264 }
10265 break;
10266#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
10267 case WE_LED_FLASHING_PARAM:
10268 {
10269 int i;
10270 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010271 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010272 return -EINVAL;
10273 }
10274 for (i = 0; i < num_args; i++) {
10275 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010276 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010277 return -EINVAL;
10278 }
10279 }
10280 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10281 0, apps_args[0], apps_args[1]);
10282 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
10283 1, apps_args[2], apps_args[3]);
10284 }
10285 break;
10286#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010287 case WE_SET_PKTLOG:
10288 {
10289 int ret;
10290
10291 if (num_args < 1 || num_args > 2) {
10292 hdd_err("pktlog: either 1 or 2 parameters are required");
10293 return -EINVAL;
10294 }
10295
10296 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
10297 apps_args[1]);
10298 if (ret)
10299 return ret;
10300 break;
10301 }
10302
Manjeet Singhf82ed072016-07-08 11:40:00 +053010303 case WE_MAC_PWR_DEBUG_CMD:
10304 {
10305 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
10306 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10307 int i, j;
10308
10309 if (num_args < 3) {
10310 hdd_err("number of arguments can't be null %d",
10311 num_args);
10312 return -EINVAL;
10313 }
10314 if (num_args - 3 != apps_args[2]) {
10315 hdd_err("arg list of size %d doesn't match num_args %d",
10316 num_args-3, apps_args[2]);
10317 return -EINVAL;
10318 }
10319 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
10320 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
10321 hdd_err("Invalid MODULE ID %d", apps_args[1]);
10322 return -EINVAL;
10323 }
10324 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
10325 hdd_err("Too Many args %d", apps_args[2]);
10326 return -EINVAL;
10327 }
10328 mac_pwr_dbg_args.pdev_id = apps_args[0];
10329 mac_pwr_dbg_args.module_id = apps_args[1];
10330 mac_pwr_dbg_args.num_args = apps_args[2];
10331
10332 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
10333 mac_pwr_dbg_args.args[i] = apps_args[j];
10334
10335 if (QDF_STATUS_SUCCESS !=
10336 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
10337 &mac_pwr_dbg_args)) {
10338 return -EINVAL;
10339 }
10340 }
10341 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -080010342 case WE_POLICY_MANAGER_CLIST_CMD:
10343 case WE_POLICY_MANAGER_DLIST_CMD:
10344 case WE_POLICY_MANAGER_ULIST_CMD:
10345 case WE_POLICY_MANAGER_DBS_CMD:
10346 case WE_POLICY_MANAGER_PCL_CMD:
10347 case WE_POLICY_SET_HW_MODE_CMD:
10348 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10349 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10350 case WE_POLICY_MANAGER_SCENARIO_CMD:
10351 {
10352 iw_get_policy_manager_ut_ops(hdd_ctx, pAdapter,
10353 sub_cmd, apps_args);
10354 }
10355 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010356 default:
10357 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010358 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010359 }
10360 break;
10361 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010362 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010363 return 0;
10364}
10365
10366/**
10367 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
10368 * @dev: pointer to net_device structure
10369 * @info: pointer to iw_request_info structure
10370 * @wrqu: pointer to iwreq_data
10371 * @extra; extra
10372 *
10373 * Return: 0 on success, error number otherwise
10374 *
10375 */
10376static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
10377 struct iw_request_info *info,
10378 union iwreq_data *wrqu, char *extra)
10379{
10380 union iwreq_data u_priv_wrqu;
10381 int apps_args[MAX_VAR_ARGS] = {0};
10382 int ret, num_args;
10383
Mukul Sharma64a70e82015-11-02 20:05:09 +053010384 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010385 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +053010386 return -EPERM;
10387 }
10388
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010389 /* Helper function to get iwreq_data with compat handling. */
10390 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
10391 return -EINVAL;
10392
10393 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010394 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010395 return -EINVAL;
10396 }
10397
10398 num_args = u_priv_wrqu.data.length;
10399 if (num_args > MAX_VAR_ARGS)
10400 num_args = MAX_VAR_ARGS;
10401
10402 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
10403 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010404 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010405 return -EFAULT;
10406 }
10407
10408 cds_ssr_protect(__func__);
10409 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
10410 (char *)&apps_args);
10411 cds_ssr_unprotect(__func__);
10412 return ret;
10413}
10414
10415/**
10416 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10417 * @dev: device upon which the ioctl was received
10418 * @info: ioctl request information
10419 * @wrqu: ioctl request data
10420 * @extra: ioctl extra data
10421 *
10422 * This is a generic handler for private ioctls which take multiple
10423 * arguments. Note that this implementation is also somewhat unique
10424 * in that it is shared by both STA-mode and SAP-mode interfaces.
10425 *
10426 * Return: 0 on success, non-zero on error
10427 */
10428int iw_set_var_ints_getnone(struct net_device *dev,
10429 struct iw_request_info *info,
10430 union iwreq_data *wrqu, char *extra)
10431{
10432 int ret;
10433
10434 cds_ssr_protect(__func__);
10435 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
10436 cds_ssr_unprotect(__func__);
10437 return ret;
10438}
10439
10440/**
10441 * iw_add_tspec - Add TSpec private ioctl handler
10442 * @dev: device upon which the ioctl was received
10443 * @info: ioctl request information
10444 * @wrqu: ioctl request data
10445 * @extra: ioctl extra data
10446 *
10447 * Return: 0 on success, non-zero on error
10448 */
10449static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
10450 union iwreq_data *wrqu, char *extra)
10451{
10452 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10453 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10454 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
10455 int params[HDD_WLAN_WMM_PARAM_COUNT];
10456 sme_QosWmmTspecInfo tSpec;
10457 uint32_t handle;
10458 struct iw_point s_priv_data;
10459 hdd_context_t *hdd_ctx;
10460 int ret;
10461
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010462 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010464 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10465 ret = wlan_hdd_validate_context(hdd_ctx);
10466 if (0 != ret)
10467 return ret;
10468
Jeff Johnson441e1f72017-02-07 08:50:49 -080010469 ret = hdd_check_private_wext_control(hdd_ctx, info);
10470 if (0 != ret)
10471 return ret;
10472
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010473 /* make sure the application is sufficiently priviledged */
10474 /* note that the kernel will do this for "set" ioctls, but since */
10475 /* this ioctl wants to return status to user space it must be */
10476 /* defined as a "get" ioctl */
10477 if (!capable(CAP_NET_ADMIN)) {
10478 return -EPERM;
10479 }
10480
10481 /* we must be associated in order to add a tspec */
10482 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
10483 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10484 return 0;
10485 }
10486 /* since we are defined to be a "get" ioctl, and since the number */
10487 /* of params exceeds the number of params that wireless extensions */
10488 /* will pass down in the iwreq_data, we must copy the "set" params. */
10489 /* We must handle the compat for iwreq_data in 32U/64K environment. */
10490
10491 /* helper function to get iwreq_data with compat handling. */
10492 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
10493 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10494 return 0;
10495 }
10496 /* make sure all params are correctly passed to function */
10497 if ((NULL == s_priv_data.pointer) ||
10498 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
10499 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10500 return 0;
10501 }
10502 /* from user space ourselves */
10503 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
10504 /* hmmm, can't get them */
10505 return -EIO;
10506 }
10507 /* clear the tspec */
10508 memset(&tSpec, 0, sizeof(tSpec));
10509
10510 /* validate the handle */
10511 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
10512 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
10513 /* that one is reserved */
10514 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10515 return 0;
10516 }
10517 /* validate the TID */
10518 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
10519 /* out of range */
10520 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10521 return 0;
10522 }
10523 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
10524
10525 /* validate the direction */
10526 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
10527 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
10528 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
10529 break;
10530
10531 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
10532 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
10533 break;
10534
10535 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
10536 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
10537 break;
10538
10539 default:
10540 /* unknown */
10541 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10542 return 0;
10543 }
10544
10545 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
10546
10547 /* validate the user priority */
10548 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
10549 /* out of range */
10550 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10551 return 0;
10552 }
10553 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
10554 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010555 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010556 return 0;
10557 }
10558
Jeff Johnson99bac312016-06-28 10:38:18 -070010559 hdd_info("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010560 tSpec.ts_info.psb, tSpec.ts_info.up);
10561
10562 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
10563 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
10564 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
10565 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
10566 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
10567 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
10568 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
10569 tSpec.surplus_bw_allowance =
10570 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
10571 tSpec.min_service_interval =
10572 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
10573 tSpec.max_service_interval =
10574 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
10575 tSpec.suspension_interval =
10576 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
10577 tSpec.inactivity_interval =
10578 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
10579
10580 tSpec.ts_info.burst_size_defn =
10581 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
10582
10583 /* validate the ts info ack policy */
10584 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
10585 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
10586 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
10587 break;
10588
10589 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
10590 tSpec.ts_info.ack_policy =
10591 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
10592 break;
10593
10594 default:
10595 /* unknown */
10596 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10597 return 0;
10598 }
10599
10600 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010601 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010602 return 0;
10603}
10604
10605static int iw_add_tspec(struct net_device *dev,
10606 struct iw_request_info *info,
10607 union iwreq_data *wrqu, char *extra)
10608{
10609 int ret;
10610
10611 cds_ssr_protect(__func__);
10612 ret = __iw_add_tspec(dev, info, wrqu, extra);
10613 cds_ssr_unprotect(__func__);
10614
10615 return ret;
10616}
10617
10618/**
10619 * iw_del_tspec - Delete TSpec private ioctl handler
10620 * @dev: device upon which the ioctl was received
10621 * @info: ioctl request information
10622 * @wrqu: ioctl request data
10623 * @extra: ioctl extra data
10624 *
10625 * Return: 0 on success, non-zero on error
10626 */
10627static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
10628 union iwreq_data *wrqu, char *extra)
10629{
10630 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10631 hdd_context_t *hdd_ctx;
10632 int *params = (int *)extra;
10633 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
10634 uint32_t handle;
10635 int ret;
10636
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010637 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010638
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010639 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10640 ret = wlan_hdd_validate_context(hdd_ctx);
10641 if (0 != ret)
10642 return ret;
10643
Jeff Johnson441e1f72017-02-07 08:50:49 -080010644 ret = hdd_check_private_wext_control(hdd_ctx, info);
10645 if (0 != ret)
10646 return ret;
10647
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010648 /* make sure the application is sufficiently priviledged */
10649 /* note that the kernel will do this for "set" ioctls, but since */
10650 /* this ioctl wants to return status to user space it must be */
10651 /* defined as a "get" ioctl */
10652 if (!capable(CAP_NET_ADMIN)) {
10653 return -EPERM;
10654 }
10655
10656 /* although we are defined to be a "get" ioctl, the params we require */
10657 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
10658 /* is no need to copy the params from user space */
10659
10660 /* validate the handle */
10661 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
10662 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
10663 /* that one is reserved */
10664 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10665 return 0;
10666 }
10667
10668 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010669 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010670 return 0;
10671}
10672
10673static int iw_del_tspec(struct net_device *dev,
10674 struct iw_request_info *info,
10675 union iwreq_data *wrqu, char *extra)
10676{
10677 int ret;
10678
10679 cds_ssr_protect(__func__);
10680 ret = __iw_del_tspec(dev, info, wrqu, extra);
10681 cds_ssr_unprotect(__func__);
10682
10683 return ret;
10684}
10685
10686/**
10687 * iw_get_tspec - Get TSpec private ioctl handler
10688 * @dev: device upon which the ioctl was received
10689 * @info: ioctl request information
10690 * @wrqu: ioctl request data
10691 * @extra: ioctl extra data
10692 *
10693 * Return: 0 on success, non-zero on error
10694 */
10695static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
10696 union iwreq_data *wrqu, char *extra)
10697{
10698 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10699 hdd_context_t *hdd_ctx;
10700 int *params = (int *)extra;
10701 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
10702 uint32_t handle;
10703 int ret;
10704
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010705 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010707 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10708 ret = wlan_hdd_validate_context(hdd_ctx);
10709 if (0 != ret)
10710 return ret;
10711
Jeff Johnson441e1f72017-02-07 08:50:49 -080010712 ret = hdd_check_private_wext_control(hdd_ctx, info);
10713 if (0 != ret)
10714 return ret;
10715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010716 /* although we are defined to be a "get" ioctl, the params we require */
10717 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
10718 /* is no need to copy the params from user space */
10719
10720 /* validate the handle */
10721 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
10722 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
10723 /* that one is reserved */
10724 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
10725 return 0;
10726 }
10727
10728 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010729 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010730 return 0;
10731}
10732
10733static int iw_get_tspec(struct net_device *dev,
10734 struct iw_request_info *info,
10735 union iwreq_data *wrqu, char *extra)
10736{
10737 int ret;
10738
10739 cds_ssr_protect(__func__);
10740 ret = __iw_get_tspec(dev, info, wrqu, extra);
10741 cds_ssr_unprotect(__func__);
10742
10743 return ret;
10744}
10745
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010746/**
10747 * iw_set_fties - Set FT IEs private ioctl handler
10748 * @dev: device upon which the ioctl was received
10749 * @info: ioctl request information
10750 * @wrqu: ioctl request data
10751 * @extra: ioctl extra data
10752 *
10753 * Each time the supplicant has the auth_request or reassoc request
10754 * IEs ready they are pushed to the driver. The driver will in turn
10755 * use it to send out the auth req and reassoc req for 11r FT Assoc.
10756 *
10757 * Return: 0 on success, non-zero on error
10758 */
10759static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
10760 union iwreq_data *wrqu, char *extra)
10761{
10762 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10763 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10764 hdd_context_t *hdd_ctx;
10765 int ret;
10766
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010767 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010768
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010769 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10770 ret = wlan_hdd_validate_context(hdd_ctx);
10771 if (0 != ret)
10772 return ret;
10773
Jeff Johnson441e1f72017-02-07 08:50:49 -080010774 ret = hdd_check_private_wext_control(hdd_ctx, info);
10775 if (0 != ret)
10776 return ret;
10777
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010778 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010779 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010780 return -EINVAL;
10781 }
10782 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010783 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010784 return -EINVAL;
10785 }
10786 /* Added for debug on reception of Re-assoc Req. */
10787 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010788 hdd_err("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010789 wrqu->data.length);
Jeff Johnson99bac312016-06-28 10:38:18 -070010790 hdd_err("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010791 }
Jeff Johnson99bac312016-06-28 10:38:18 -070010792 hdd_notice("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010793
10794 /* Pass the received FT IEs to SME */
10795 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
10796 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010797 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010798 return 0;
10799}
10800
10801static int iw_set_fties(struct net_device *dev,
10802 struct iw_request_info *info,
10803 union iwreq_data *wrqu, char *extra)
10804{
10805 int ret;
10806
10807 cds_ssr_protect(__func__);
10808 ret = __iw_set_fties(dev, info, wrqu, extra);
10809 cds_ssr_unprotect(__func__);
10810
10811 return ret;
10812}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010813
Dustin Brown0cbc7572016-12-16 13:54:40 -080010814/**
10815 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
10816 * @dev: device upon which the ioctl was received
10817 * @info: ioctl request information
10818 * @wrqu: ioctl request data
10819 * @extra: ioctl extra data
10820 *
Dustin Brown860566f2017-01-31 15:24:43 -080010821 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
10822 * time being to provide guidance in migrating to standard APIs.
10823 *
Dustin Brown0cbc7572016-12-16 13:54:40 -080010824 * Return: 0 on success, non-zero on error
10825 */
10826static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
10827 struct iw_request_info *info,
10828 union iwreq_data *wrqu,
10829 char *extra)
10830{
Dustin Brown860566f2017-01-31 15:24:43 -080010831 hdd_err("\n"
10832 "setMCBCFilter is obsolete. Use the following instead:\n"
10833 "Configure multicast filtering via the ‘ip’ command.\n"
10834 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
10835 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
10836 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
10837 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
10838 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Dustin Brown0cbc7572016-12-16 13:54:40 -080010839
Dustin Brown860566f2017-01-31 15:24:43 -080010840 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -080010841}
10842
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010843/**
10844 * iw_set_host_offload - Set host offload ioctl handler
10845 * @dev: device upon which the ioctl was received
10846 * @info: ioctl request information
10847 * @wrqu: ioctl request data
10848 * @extra: ioctl extra data
10849 *
10850 * Return: 0 on success, non-zero on error
10851 */
10852static int __iw_set_host_offload(struct net_device *dev,
10853 struct iw_request_info *info,
10854 union iwreq_data *wrqu, char *extra)
10855{
10856 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10857 tpHostOffloadRequest pRequest = (tpHostOffloadRequest) extra;
10858 tSirHostOffloadReq offloadRequest;
10859 hdd_context_t *hdd_ctx;
10860 int ret;
10861
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010862 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010863
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010864 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10865 ret = wlan_hdd_validate_context(hdd_ctx);
10866 if (0 != ret)
10867 return ret;
10868
Jeff Johnson441e1f72017-02-07 08:50:49 -080010869 ret = hdd_check_private_wext_control(hdd_ctx, info);
10870 if (0 != ret)
10871 return ret;
10872
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010873 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010874 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010875 return -EINVAL;
10876 }
10877
10878 /* Debug display of request components. */
10879 switch (pRequest->offloadType) {
10880 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -070010881 hdd_warn("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010882 switch (pRequest->enableOrDisable) {
10883 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010884 hdd_warn(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010885 break;
10886 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010887 hdd_warn(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010888 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010889 hdd_warn(" ARP offload enable");
10890 hdd_warn(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010891 pRequest->params.hostIpv4Addr[0],
10892 pRequest->params.hostIpv4Addr[1],
10893 pRequest->params.hostIpv4Addr[2],
10894 pRequest->params.hostIpv4Addr[3]);
10895 }
10896 break;
10897
10898 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Jeff Johnson99bac312016-06-28 10:38:18 -070010899 hdd_info("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010900 switch (pRequest->enableOrDisable) {
10901 case WLAN_OFFLOAD_DISABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010902 hdd_info(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010903 break;
10904 case WLAN_OFFLOAD_ENABLE:
Jeff Johnson99bac312016-06-28 10:38:18 -070010905 hdd_info(" enable");
10906 hdd_info(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010907 *(uint16_t *) (pRequest->params.hostIpv6Addr),
10908 *(uint16_t *) (pRequest->params.hostIpv6Addr +
10909 2),
10910 *(uint16_t *) (pRequest->params.hostIpv6Addr +
10911 4),
10912 *(uint16_t *) (pRequest->params.hostIpv6Addr +
10913 6),
10914 *(uint16_t *) (pRequest->params.hostIpv6Addr +
10915 8),
10916 *(uint16_t *) (pRequest->params.hostIpv6Addr +
10917 10),
10918 *(uint16_t *) (pRequest->params.hostIpv6Addr +
10919 12),
10920 *(uint16_t *) (pRequest->params.hostIpv6Addr +
10921 14));
10922 }
10923 }
10924
10925 /* Execute offload request. The reason that we can copy the
10926 * request information from the ioctl structure to the SME
10927 * structure is that they are laid out exactly the same.
10928 * Otherwise, each piece of information would have to be
10929 * copied individually.
10930 */
10931 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010932 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010933 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
10934 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010935 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010936 return -EINVAL;
10937 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010938 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010939 return 0;
10940}
10941
10942static int iw_set_host_offload(struct net_device *dev,
10943 struct iw_request_info *info,
10944 union iwreq_data *wrqu, char *extra)
10945{
10946 int ret;
10947
10948 cds_ssr_protect(__func__);
10949 ret = __iw_set_host_offload(dev, info, wrqu, extra);
10950 cds_ssr_unprotect(__func__);
10951
10952 return ret;
10953}
10954
10955/**
10956 * iw_set_keepalive_params - Set keepalive params ioctl handler
10957 * @dev: device upon which the ioctl was received
10958 * @info: ioctl request information
10959 * @wrqu: ioctl request data
10960 * @extra: ioctl extra data
10961 *
10962 * Return: 0 on success, non-zero on error
10963 */
10964static int __iw_set_keepalive_params(struct net_device *dev,
10965 struct iw_request_info *info,
10966 union iwreq_data *wrqu, char *extra)
10967{
10968 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080010969 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010970 hdd_context_t *hdd_ctx;
10971 int ret;
10972
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010973 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010975 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10976 ret = wlan_hdd_validate_context(hdd_ctx);
10977 if (0 != ret)
10978 return ret;
10979
Jeff Johnson441e1f72017-02-07 08:50:49 -080010980 ret = hdd_check_private_wext_control(hdd_ctx, info);
10981 if (0 != ret)
10982 return ret;
10983
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080010984 if (wrqu->data.length != sizeof(*request)) {
10985 hdd_err("Invalid length %d", wrqu->data.length);
10986 return -EINVAL;
10987 }
10988
10989 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
10990 hdd_err("Value of timePeriod %d exceed Max limit %d",
10991 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010992 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
10993 return -EINVAL;
10994 }
10995
10996 /* Debug display of request components. */
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080010997 hdd_info("Set Keep Alive Request : TimePeriod %d size %zu",
10998 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010999
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011000 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011001 case WLAN_KEEP_ALIVE_NULL_PKT:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011002 hdd_info("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011003 break;
11004
11005 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011006 hdd_info("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011007
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011008 hdd_info("Host IP address: %d.%d.%d.%d",
11009 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
11010 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011011
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011012 hdd_info("Dest IP address: %d.%d.%d.%d",
11013 request->destIpv4Addr[0], request->destIpv4Addr[1],
11014 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011015
Srinivas Girigowda9c330a92015-11-24 12:28:25 -080011016 hdd_info("Dest MAC address: "MAC_ADDRESS_STR,
11017 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011018 break;
11019 }
11020
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011021 hdd_info("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011022
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011023 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011024 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011025 pAdapter->sessionId, request)) {
11026 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011027 return -EINVAL;
11028 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011029 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011030 return 0;
11031}
11032
11033static int iw_set_keepalive_params(struct net_device *dev,
11034 struct iw_request_info *info,
11035 union iwreq_data *wrqu,
11036 char *extra)
11037{
11038 int ret;
11039
11040 cds_ssr_protect(__func__);
11041 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
11042 cds_ssr_unprotect(__func__);
11043
11044 return ret;
11045}
11046
11047#ifdef WLAN_FEATURE_PACKET_FILTERING
11048/**
11049 * wlan_hdd_set_filter() - Set packet filter
11050 * @hdd_ctx: Global HDD context
11051 * @request: Packet filter request struct
11052 * @sessionId: Target session for the request
11053 *
11054 * Return: 0 on success, non-zero on error
11055 */
11056static int wlan_hdd_set_filter(hdd_context_t *hdd_ctx,
11057 struct pkt_filter_cfg *request,
11058 uint8_t sessionId)
11059{
11060 tSirRcvPktFilterCfgType packetFilterSetReq = {0};
11061 tSirRcvFltPktClearParam packetFilterClrReq = {0};
11062 int i = 0;
11063
11064 if (hdd_ctx->config->disablePacketFilter) {
11065 hdd_err("packet filtering disabled in ini returning");
11066 return 0;
11067 }
11068
11069 /* Debug display of request components. */
11070 hdd_info("Packet Filter Request : FA %d params %d",
11071 request->filter_action, request->num_params);
11072
11073 switch (request->filter_action) {
11074 case HDD_RCV_FILTER_SET:
11075 hdd_info("Set Packet Filter Request for Id: %d",
11076 request->filter_id);
11077
11078 packetFilterSetReq.filterId = request->filter_id;
11079 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
11080 hdd_err("Number of Params exceed Max limit %d",
11081 request->num_params);
11082 return -EINVAL;
11083 }
11084 packetFilterSetReq.numFieldParams = request->num_params;
11085 packetFilterSetReq.coalesceTime = 0;
11086 packetFilterSetReq.filterType = HDD_RCV_FILTER_SET;
11087 for (i = 0; i < request->num_params; i++) {
11088 packetFilterSetReq.paramsData[i].protocolLayer =
11089 request->params_data[i].protocol_layer;
11090 packetFilterSetReq.paramsData[i].cmpFlag =
11091 request->params_data[i].compare_flag;
11092 packetFilterSetReq.paramsData[i].dataOffset =
11093 request->params_data[i].data_offset;
11094 packetFilterSetReq.paramsData[i].dataLength =
11095 request->params_data[i].data_length;
11096 packetFilterSetReq.paramsData[i].reserved = 0;
11097
Dustin Brown4d1e8462016-12-14 12:12:24 -080011098 if (request->params_data[i].data_offset >
11099 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
11100 hdd_err("Invalid data offset %u for param %d (max = %d)",
11101 request->params_data[i].data_offset,
11102 i,
11103 SIR_MAX_FILTER_TEST_DATA_OFFSET);
11104 return -EINVAL;
11105 }
11106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011107 if (request->params_data[i].data_length >
11108 SIR_MAX_FILTER_TEST_DATA_LEN) {
11109 hdd_err("Error invalid data length %d",
11110 request->params_data[i].data_length);
11111 return -EINVAL;
11112 }
11113
11114 hdd_info("Proto %d Comp Flag %d Filter Type %d",
11115 request->params_data[i].protocol_layer,
11116 request->params_data[i].compare_flag,
11117 packetFilterSetReq.filterType);
11118
11119 hdd_info("Data Offset %d Data Len %d",
11120 request->params_data[i].data_offset,
11121 request->params_data[i].data_length);
11122
Rajeev Kumarf5b6da22016-04-15 13:24:03 -070011123 if (sizeof(packetFilterSetReq.paramsData[i].compareData)
11124 < (request->params_data[i].data_length)) {
11125 hdd_err("Error invalid data length %d",
11126 request->params_data[i].data_length);
11127 return -EINVAL;
11128 }
11129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011130 memcpy(&packetFilterSetReq.paramsData[i].compareData,
11131 request->params_data[i].compare_data,
11132 request->params_data[i].data_length);
11133 memcpy(&packetFilterSetReq.paramsData[i].dataMask,
11134 request->params_data[i].data_mask,
11135 request->params_data[i].data_length);
11136
11137 hdd_info("CData %d CData %d CData %d CData %d CData %d CData %d",
11138 request->params_data[i].compare_data[0],
11139 request->params_data[i].compare_data[1],
11140 request->params_data[i].compare_data[2],
11141 request->params_data[i].compare_data[3],
11142 request->params_data[i].compare_data[4],
11143 request->params_data[i].compare_data[5]);
11144
11145 hdd_info("MData %d MData %d MData %d MData %d MData %d MData %d",
11146 request->params_data[i].data_mask[0],
11147 request->params_data[i].data_mask[1],
11148 request->params_data[i].data_mask[2],
11149 request->params_data[i].data_mask[3],
11150 request->params_data[i].data_mask[4],
11151 request->params_data[i].data_mask[5]);
11152 }
11153
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011154 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011155 sme_receive_filter_set_filter(hdd_ctx->hHal,
11156 &packetFilterSetReq,
11157 sessionId)) {
11158 hdd_err("Failure to execute Set Filter");
11159 return -EINVAL;
11160 }
11161
11162 break;
11163
11164 case HDD_RCV_FILTER_CLEAR:
11165
11166 hdd_info("Clear Packet Filter Request for Id: %d",
11167 request->filter_id);
11168 packetFilterClrReq.filterId = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011169 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011170 sme_receive_filter_clear_filter(hdd_ctx->hHal,
11171 &packetFilterClrReq,
11172 sessionId)) {
11173 hdd_err("Failure to execute Clear Filter");
11174 return -EINVAL;
11175 }
11176 break;
11177
11178 default:
11179 hdd_err("Packet Filter Request: Invalid %d",
11180 request->filter_action);
11181 return -EINVAL;
11182 }
11183 return 0;
11184}
11185
11186/**
11187 * __iw_set_packet_filter_params() - set packet filter parameters in target
11188 * @dev: Pointer to netdev
11189 * @info: Pointer to iw request info
11190 * @wrqu: Pointer to data
11191 * @extra: Pointer to extra data
11192 *
11193 * Return: 0 on success, non-zero on error
11194 */
11195static int __iw_set_packet_filter_params(struct net_device *dev,
11196 struct iw_request_info *info,
11197 union iwreq_data *wrqu, char *extra)
11198{
11199 int ret;
11200 hdd_context_t *hdd_ctx;
11201 struct iw_point priv_data;
11202 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
11203 struct pkt_filter_cfg *request = NULL;
11204
Mukul Sharma472382f2015-11-02 20:16:31 +053011205 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011206 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +053011207 return -EPERM;
11208 }
11209
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011210 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011211
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011212 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11213 ret = wlan_hdd_validate_context(hdd_ctx);
11214 if (0 != ret)
11215 return ret;
11216
Jeff Johnson441e1f72017-02-07 08:50:49 -080011217 ret = hdd_check_private_wext_control(hdd_ctx, info);
11218 if (0 != ret)
11219 return ret;
11220
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011221 if (hdd_priv_get_data(&priv_data, wrqu)) {
11222 hdd_err("failed to get priv data");
11223 return -EINVAL;
11224 }
11225
11226 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
11227 hdd_err("invalid priv data %p or invalid priv data length %d",
11228 priv_data.pointer, priv_data.length);
11229 return -EINVAL;
11230 }
11231
11232 /* copy data using copy_from_user */
11233 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
11234 priv_data.length);
11235 if (NULL == request) {
11236 hdd_err("mem_alloc_copy_from_user_helper fail");
11237 return -ENOMEM;
11238 }
11239
11240 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
11241
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -070011242 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011243 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011244 return ret;
11245}
11246
11247/**
11248 * iw_set_packet_filter_params() - set packet filter parameters in target
11249 * @dev: Pointer to netdev
11250 * @info: Pointer to iw request info
11251 * @wrqu: Pointer to data
11252 * @extra: Pointer to extra data
11253 *
11254 * Return: 0 on success, non-zero on error
11255 */
11256static int iw_set_packet_filter_params(struct net_device *dev,
11257 struct iw_request_info *info,
11258 union iwreq_data *wrqu, char *extra)
11259{
11260 int ret;
11261
11262 cds_ssr_protect(__func__);
11263 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
11264 cds_ssr_unprotect(__func__);
11265
11266 return ret;
11267}
11268#endif
11269
11270
11271static int __iw_get_statistics(struct net_device *dev,
11272 struct iw_request_info *info,
11273 union iwreq_data *wrqu, char *extra)
11274{
11275
Anurag Chouhance0dc992016-02-16 18:18:03 +053011276 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011277 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011278 hdd_wext_state_t *pWextState;
11279 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11280 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11281 char *p = extra;
11282 int tlen = 0;
11283 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
11284 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
11285 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
11286 int ret;
11287
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011288 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011289
11290 ret = wlan_hdd_validate_context(hdd_ctx);
11291 if (0 != ret)
11292 return ret;
11293
Jeff Johnson441e1f72017-02-07 08:50:49 -080011294 ret = hdd_check_private_wext_control(hdd_ctx, info);
11295 if (0 != ret)
11296 return ret;
11297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011298 if (eConnectionState_Associated !=
11299 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
11300
11301 wrqu->txpower.value = 0;
11302 } else {
11303 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11304 SME_SUMMARY_STATS |
11305 SME_GLOBAL_CLASSA_STATS |
11306 SME_GLOBAL_CLASSB_STATS |
11307 SME_GLOBAL_CLASSC_STATS |
11308 SME_GLOBAL_CLASSD_STATS |
11309 SME_PER_STA_STATS,
11310 hdd_statistics_cb, 0, false,
11311 (WLAN_HDD_GET_STATION_CTX_PTR
11312 (pAdapter))->conn_info.staId[0],
11313 pAdapter, pAdapter->sessionId);
11314
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011315 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011316 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011317 return -EINVAL;
11318 }
11319
11320 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11321
Anurag Chouhance0dc992016-02-16 18:18:03 +053011322 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053011323 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011324 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +053011325 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011326 hdd_err("SME timeout while retrieving statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011327 /*Remove the SME statistics list by passing NULL in callback argument */
11328 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
11329 SME_SUMMARY_STATS |
11330 SME_GLOBAL_CLASSA_STATS |
11331 SME_GLOBAL_CLASSB_STATS |
11332 SME_GLOBAL_CLASSC_STATS |
11333 SME_GLOBAL_CLASSD_STATS |
11334 SME_PER_STA_STATS,
11335 NULL, 0, false,
11336 (WLAN_HDD_GET_STATION_CTX_PTR
11337 (pAdapter))->conn_info.
11338 staId[0], pAdapter,
11339 pAdapter->sessionId);
11340
11341 return -EINVAL;
11342 }
11343 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
11344 (uint8_t) sizeof(pStats->retry_cnt),
11345 (char *)&(pStats->retry_cnt[0]), tlen);
11346
11347 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
11348 (uint8_t) sizeof(pStats->multiple_retry_cnt),
11349 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
11350
11351 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
11352 (uint8_t) sizeof(pStats->tx_frm_cnt),
11353 (char *)&(pStats->tx_frm_cnt[0]), tlen);
11354
11355 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
11356 (uint8_t) sizeof(pStats->rx_frm_cnt),
11357 (char *)&(pStats->rx_frm_cnt), tlen);
11358
11359 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
11360 (uint8_t) sizeof(pStats->frm_dup_cnt),
11361 (char *)&(pStats->frm_dup_cnt), tlen);
11362
11363 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
11364 (uint8_t) sizeof(pStats->fail_cnt),
11365 (char *)&(pStats->fail_cnt[0]), tlen);
11366
11367 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
11368 (uint8_t) sizeof(pStats->rts_fail_cnt),
11369 (char *)&(pStats->rts_fail_cnt), tlen);
11370
11371 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
11372 (uint8_t) sizeof(pStats->ack_fail_cnt),
11373 (char *)&(pStats->ack_fail_cnt), tlen);
11374
11375 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
11376 (uint8_t) sizeof(pStats->rts_succ_cnt),
11377 (char *)&(pStats->rts_succ_cnt), tlen);
11378
11379 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
11380 (uint8_t) sizeof(pStats->rx_discard_cnt),
11381 (char *)&(pStats->rx_discard_cnt), tlen);
11382
11383 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
11384 (uint8_t) sizeof(pStats->rx_error_cnt),
11385 (char *)&(pStats->rx_error_cnt), tlen);
11386
11387 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
11388 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11389 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11390
11391 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
11392 (uint8_t) sizeof(dStats->rx_byte_cnt),
11393 (char *)&(dStats->rx_byte_cnt), tlen);
11394
11395 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
11396 (uint8_t) sizeof(dStats->rx_rate),
11397 (char *)&(dStats->rx_rate), tlen);
11398
11399 /* Transmit rate, in units of 500 kbit/sec */
11400 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
11401 (uint8_t) sizeof(aStats->tx_rate),
11402 (char *)&(aStats->tx_rate), tlen);
11403
11404 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
11405 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
11406 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
11407 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
11408 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
11409 (char *)&(dStats->rx_mc_byte_cnt), tlen);
11410 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
11411 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
11412 (char *)&(dStats->rx_bc_byte_cnt), tlen);
11413 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
11414 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
11415 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
11416 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
11417 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
11418 (char *)&(dStats->tx_mc_byte_cnt), tlen);
11419 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
11420 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
11421 (char *)&(dStats->tx_bc_byte_cnt), tlen);
11422
11423 wrqu->data.length = tlen;
11424
11425 }
11426
11427 EXIT();
11428
11429 return 0;
11430}
11431
11432static int iw_get_statistics(struct net_device *dev,
11433 struct iw_request_info *info,
11434 union iwreq_data *wrqu, char *extra)
11435{
11436 int ret;
11437
11438 cds_ssr_protect(__func__);
11439 ret = __iw_get_statistics(dev, info, wrqu, extra);
11440 cds_ssr_unprotect(__func__);
11441
11442 return ret;
11443}
11444
11445#ifdef FEATURE_WLAN_SCAN_PNO
11446
11447/*Max Len for PNO notification*/
11448#define MAX_PNO_NOTIFY_LEN 100
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070011449static void found_pref_network_cb(void *callbackContext,
11450 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011451{
11452 hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
11453 union iwreq_data wrqu;
11454 char buf[MAX_PNO_NOTIFY_LEN + 1];
11455
Jeff Johnson99bac312016-06-28 10:38:18 -070011456 hdd_warn("A preferred network was found: %s with rssi: -%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011457 pPrefNetworkFoundInd->ssId.ssId, pPrefNetworkFoundInd->rssi);
11458
11459 /* create the event */
11460 memset(&wrqu, 0, sizeof(wrqu));
11461 memset(buf, 0, sizeof(buf));
11462
11463 snprintf(buf, MAX_PNO_NOTIFY_LEN,
11464 "QCOM: Found preferred network: %s with RSSI of -%u",
11465 pPrefNetworkFoundInd->ssId.ssId,
11466 (unsigned int)pPrefNetworkFoundInd->rssi);
11467
11468 wrqu.data.pointer = buf;
11469 wrqu.data.length = strlen(buf);
11470
11471 /* send the event */
11472
11473 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
11474
11475}
11476
11477/**
11478 * __iw_set_pno() - Preferred Network Offload ioctl handler
11479 * @dev: device upon which the ioctl was received
11480 * @info: ioctl request information
11481 * @wrqu: ioctl request data
11482 * @extra: ioctl extra data
11483 *
11484 * This function parses a Preferred Network Offload command
11485 * Input is string based and expected to be of the form:
11486 *
11487 * <enable(1) | disable(0)>
11488 * when enabling:
11489 * <number of networks>
11490 * for each network:
11491 * <ssid_len> <ssid> <authentication> <encryption>
11492 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070011493 * <scan_time (seconds)>
11494 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011495 * <suspend mode>
11496 *
11497 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070011498 * 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 -080011499 *
11500 * this translates into:
11501 * -----------------------------
11502 * enable PNO
11503 * 2 networks
11504 * Network 1:
11505 * test - with authentication type 0 and encryption type 0,
11506 * search on 3 channels: 1 6 and 11,
11507 * SSID bcast type is unknown (directed probe will be sent if
11508 * AP not found) and must meet -40dBm RSSI
11509 * Network 2:
11510 * test2 - with authentication type 4 and encryption type 4,
11511 * search on 6 channels 1, 2, 3, 4, 5 and 6
11512 * bcast type is non-bcast (directed probe will be sent)
11513 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011514 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070011515 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011516 */
11517static int __iw_set_pno(struct net_device *dev,
11518 struct iw_request_info *info,
11519 union iwreq_data *wrqu, char *extra)
11520{
11521 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
11522 hdd_context_t *hdd_ctx;
11523 int ret;
11524 int offset;
11525 char *ptr;
11526 uint8_t i, j, params, mode;
11527
11528 /* request is a large struct, so we make it static to avoid
11529 * stack overflow. This API is only invoked via ioctl, so it
11530 * is serialized by the kernel rtnl_lock and hence does not
11531 * need to be reentrant
11532 */
11533 static tSirPNOScanReq request;
11534
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011535 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011536
11537 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11538 ret = wlan_hdd_validate_context(hdd_ctx);
11539 if (ret)
11540 return ret;
11541
Jeff Johnson441e1f72017-02-07 08:50:49 -080011542 ret = hdd_check_private_wext_control(hdd_ctx, info);
11543 if (0 != ret)
11544 return ret;
11545
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011546 hdd_notice("PNO data len %d data %s", wrqu->data.length, extra);
11547
11548 request.enable = 0;
11549 request.ucNetworksCount = 0;
11550
11551 ptr = extra;
11552
11553 if (1 != sscanf(ptr, "%hhu%n", &(request.enable), &offset)) {
11554 hdd_err("PNO enable input is not valid %s", ptr);
11555 return -EINVAL;
11556 }
11557
11558 if (0 == request.enable) {
11559 /* Disable PNO, ignore any other params */
11560 memset(&request, 0, sizeof(request));
11561 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
11562 &request, adapter->sessionId,
11563 found_pref_network_cb, adapter);
11564 return 0;
11565 }
11566
11567 ptr += offset;
11568
11569 if (1 !=
11570 sscanf(ptr, "%hhu %n", &(request.ucNetworksCount), &offset)) {
11571 hdd_err("PNO count input not valid %s", ptr);
11572 return -EINVAL;
11573
11574 }
11575
11576 hdd_info("PNO enable %d networks count %d offset %d",
11577 request.enable, request.ucNetworksCount, offset);
11578
11579 if ((0 == request.ucNetworksCount) ||
11580 (request.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS)) {
11581 hdd_err("Network count %d invalid",
11582 request.ucNetworksCount);
11583 return -EINVAL;
11584 }
11585
11586 ptr += offset;
11587
11588 for (i = 0; i < request.ucNetworksCount; i++) {
11589
11590 request.aNetworks[i].ssId.length = 0;
11591
11592 params = sscanf(ptr, "%hhu %n",
11593 &(request.aNetworks[i].ssId.length),
11594 &offset);
11595
11596 if (1 != params) {
11597 hdd_err("PNO ssid length input is not valid %s", ptr);
11598 return -EINVAL;
11599 }
11600
11601 if ((0 == request.aNetworks[i].ssId.length) ||
11602 (request.aNetworks[i].ssId.length > 32)) {
11603 hdd_err("SSID Len %d is not correct for network %d",
11604 request.aNetworks[i].ssId.length, i);
11605 return -EINVAL;
11606 }
11607
11608 /* Advance to SSID */
11609 ptr += offset;
11610
11611 memcpy(request.aNetworks[i].ssId.ssId, ptr,
11612 request.aNetworks[i].ssId.length);
11613 ptr += request.aNetworks[i].ssId.length;
11614
11615 params = sscanf(ptr, "%u %u %hhu %n",
11616 &(request.aNetworks[i].authentication),
11617 &(request.aNetworks[i].encryption),
11618 &(request.aNetworks[i].ucChannelCount),
11619 &offset);
11620
11621 if (3 != params) {
11622 hdd_warn("Incorrect cmd %s", ptr);
11623 return -EINVAL;
11624 }
11625
11626 hdd_notice("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
11627 request.aNetworks[i].ssId.length,
11628 request.aNetworks[i].ssId.length,
11629 request.aNetworks[i].ssId.ssId,
11630 request.aNetworks[i].authentication,
11631 request.aNetworks[i].encryption,
11632 request.aNetworks[i].ucChannelCount, offset);
11633
11634 /* Advance to channel list */
11635 ptr += offset;
11636
11637 if (SIR_PNO_MAX_NETW_CHANNELS <
11638 request.aNetworks[i].ucChannelCount) {
11639 hdd_warn("Incorrect number of channels");
11640 return -EINVAL;
11641 }
11642
11643 if (0 != request.aNetworks[i].ucChannelCount) {
11644 for (j = 0; j < request.aNetworks[i].ucChannelCount;
11645 j++) {
11646 if (1 !=
11647 sscanf(ptr, "%hhu %n",
11648 &(request.aNetworks[i].
11649 aChannels[j]), &offset)) {
11650 hdd_err("PNO network channel input is not valid %s",
11651 ptr);
11652 return -EINVAL;
11653 }
11654 /* Advance to next channel number */
11655 ptr += offset;
11656 }
11657 }
11658
11659 if (1 != sscanf(ptr, "%u %n",
11660 &(request.aNetworks[i].bcastNetwType),
11661 &offset)) {
11662 hdd_err("PNO broadcast network type input is not valid %s",
11663 ptr);
11664 return -EINVAL;
11665 }
11666
11667 hdd_notice("PNO bcastNetwType %d offset %d",
11668 request.aNetworks[i].bcastNetwType, offset);
11669
11670 /* Advance to rssi Threshold */
11671 ptr += offset;
11672 if (1 != sscanf(ptr, "%d %n",
11673 &(request.aNetworks[i].rssiThreshold),
11674 &offset)) {
11675 hdd_err("PNO rssi threshold input is not valid %s",
11676 ptr);
11677 return -EINVAL;
11678 }
11679 hdd_notice("PNO rssi %d offset %d",
11680 request.aNetworks[i].rssiThreshold, offset);
11681 /* Advance to next network */
11682 ptr += offset;
11683 } /* For ucNetworkCount */
11684
Dustin Brown43e87292016-10-10 10:38:25 -070011685 request.fast_scan_period = 0;
11686 if (sscanf(ptr, "%u %n", &(request.fast_scan_period), &offset) > 0) {
11687 request.fast_scan_period *= MSEC_PER_SEC;
11688 ptr += offset;
11689 }
11690
11691 request.fast_scan_max_cycles = 0;
11692 if (sscanf(ptr, "%hhu %n", &(request.fast_scan_max_cycles),
11693 &offset) > 0)
11694 ptr += offset;
11695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011696 params = sscanf(ptr, "%hhu %n", &(mode), &offset);
11697
11698 request.modePNO = mode;
11699 /* for LA we just expose suspend option */
11700 if ((1 != params) || (mode >= SIR_PNO_MODE_MAX)) {
11701 request.modePNO = SIR_PNO_MODE_ON_SUSPEND;
11702 }
11703
11704 sme_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(adapter),
11705 &request,
11706 adapter->sessionId,
11707 found_pref_network_cb, adapter);
11708
11709 return 0;
11710}
11711
11712static int iw_set_pno(struct net_device *dev,
11713 struct iw_request_info *info,
11714 union iwreq_data *wrqu, char *extra)
11715{
11716 int ret;
11717
11718 cds_ssr_protect(__func__);
11719 ret = __iw_set_pno(dev, info, wrqu, extra);
11720 cds_ssr_unprotect(__func__);
11721
11722 return ret;
11723}
11724#endif /* FEATURE_WLAN_SCAN_PNO */
11725
11726/* Common function to SetBand */
11727int hdd_set_band(struct net_device *dev, u8 ui_band)
11728{
11729 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11730 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11731 eCsrBand band;
11732
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011733 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011734 hdd_context_t *pHddCtx;
11735 hdd_adapter_list_node_t *pAdapterNode, *pNext;
11736 eCsrBand currBand = eCSR_BAND_MAX;
11737 eCsrBand connectedBand;
11738
11739 pAdapterNode = NULL;
11740 pNext = NULL;
11741 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11742
11743 switch (ui_band) {
11744 case WLAN_HDD_UI_BAND_AUTO:
11745 band = eCSR_BAND_ALL;
11746 break;
11747 case WLAN_HDD_UI_BAND_5_GHZ:
11748 band = eCSR_BAND_5G;
11749 break;
11750 case WLAN_HDD_UI_BAND_2_4_GHZ:
11751 band = eCSR_BAND_24;
11752 break;
11753 default:
11754 band = eCSR_BAND_MAX;
11755 }
11756
Jeff Johnson99bac312016-06-28 10:38:18 -070011757 hdd_notice("change band to %u", band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011758
11759 if (band == eCSR_BAND_MAX) {
11760 /* Received change band request with invalid band value */
Jeff Johnson99bac312016-06-28 10:38:18 -070011761 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011762 return -EINVAL;
11763 }
11764
11765 if ((band == eCSR_BAND_24 && pHddCtx->config->nBandCapability == 2) ||
11766 (band == eCSR_BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011767 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011768 band, pHddCtx->config->nBandCapability);
11769 return -EIO;
11770 }
11771
11772 if (band == eCSR_BAND_ALL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011773 hdd_notice("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011774 pHddCtx->config->nBandCapability);
11775 band = pHddCtx->config->nBandCapability;
11776 }
11777
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011778 if (QDF_STATUS_SUCCESS != sme_get_freq_band(hHal, &currBand)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011779 hdd_notice("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011780 return -EIO;
11781 }
11782
11783 if (currBand != band) {
11784 /* Change band request received.
11785 * Abort pending scan requests, flush the existing scan results,
11786 * and change the band capability
11787 */
Jeff Johnson99bac312016-06-28 10:38:18 -070011788 hdd_notice("Current band value = %u, new setting %u ",
11789 currBand, band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011790
11791 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011792 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011793 pAdapter = pAdapterNode->pAdapter;
11794 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11795 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053011796 INVALID_SCAN_ID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011797 eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE);
11798 connectedBand =
11799 hdd_conn_get_connected_band
11800 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
11801
11802 /* Handling is done only for STA and P2P */
11803 if (band != eCSR_BAND_ALL &&
Krunal Sonif07bb382016-03-10 13:02:11 -080011804 ((pAdapter->device_mode == QDF_STA_MODE)
11805 || (pAdapter->device_mode == QDF_P2P_CLIENT_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011806 &&
11807 (hdd_conn_is_connected
11808 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
11809 && (connectedBand != band)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011810 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011811 long lrc;
11812
Jeff Johnson3bb7c732017-01-12 08:40:17 -080011813 /* STA already connected on current
11814 * band, So issue disconnect first,
11815 * then change the band
11816 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011817
Jeff Johnson99bac312016-06-28 10:38:18 -070011818 hdd_notice("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011819 hdd_device_mode_to_string(pAdapter->device_mode),
11820 pAdapter->device_mode, currBand, band);
11821 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11822
11823 status =
11824 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX
11825 (pAdapter),
11826 pAdapter->sessionId,
11827 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11828
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011829 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011830 hdd_err("csr_roam_disconnect failure, returned %d",
11831 (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011832 return -EINVAL;
11833 }
11834
11835 lrc =
11836 wait_for_completion_timeout(&pAdapter->
11837 disconnect_comp_var,
11838 msecs_to_jiffies
11839 (WLAN_WAIT_TIME_DISCONNECT));
11840
11841 if (lrc == 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011842 hdd_err("Timeout while waiting for csr_roam_disconnect");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011843 return -ETIMEDOUT;
11844 }
11845 }
11846
11847 sme_scan_flush_result(hHal);
11848
11849 status =
11850 hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
11851 pAdapterNode = pNext;
11852 }
11853
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011854 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011855 sme_set_freq_band(hHal, pAdapter->sessionId, band)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011856 hdd_alert("Failed to set the band value to %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011857 band);
11858 return -EINVAL;
11859 }
11860 wlan_hdd_cfg80211_update_band(pHddCtx->wiphy, (eCsrBand) band);
11861 }
11862 return 0;
11863}
11864
11865int hdd_set_band_helper(struct net_device *dev, const char *command)
11866{
11867 uint8_t band;
11868 int ret;
11869
11870 /* Convert the band value from ascii to integer */
11871 command += WLAN_HDD_UI_SET_BAND_VALUE_OFFSET;
11872 ret = kstrtou8(command, 10, &band);
11873 if (ret < 0) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011874 hdd_err("kstrtou8 failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011875 return -EINVAL;
11876 }
11877
11878 return hdd_set_band(dev, band);
11879}
11880
11881static int __iw_set_band_config(struct net_device *dev,
11882 struct iw_request_info *info,
11883 union iwreq_data *wrqu, char *extra)
11884{
Jeff Johnson441e1f72017-02-07 08:50:49 -080011885 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
11886 hdd_context_t *hdd_ctx;
11887 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011888 int *value = (int *)extra;
11889
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011890 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011891
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053011892 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011893 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053011894 return -EPERM;
11895 }
11896
Jeff Johnson441e1f72017-02-07 08:50:49 -080011897 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11898 ret = hdd_check_private_wext_control(hdd_ctx, info);
11899 if (0 != ret)
11900 return ret;
11901
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011902 return hdd_set_band(dev, value[0]);
11903}
11904
11905static int iw_set_band_config(struct net_device *dev,
11906 struct iw_request_info *info,
11907 union iwreq_data *wrqu, char *extra)
11908{
11909 int ret;
11910
11911 cds_ssr_protect(__func__);
11912 ret = __iw_set_band_config(dev, info, wrqu, extra);
11913 cds_ssr_unprotect(__func__);
11914
11915 return ret;
11916}
11917
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011918/**
11919 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
11920 * @adapter: Handle to adapter
11921 * @chan: Monitor mode channel
11922 * @bandwidth: Capture channel bandwidth
11923 *
11924 * Return: 0 on success else error code.
11925 */
11926static int wlan_hdd_set_mon_chan(hdd_adapter_t *adapter, uint32_t chan,
11927 uint32_t bandwidth)
11928{
11929 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11930 hdd_station_ctx_t *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
11931 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
11932 QDF_STATUS status;
11933 tHalHandle hal_hdl = hdd_ctx->hHal;
11934 struct qdf_mac_addr bssid;
11935 tCsrRoamProfile roam_profile;
11936 struct ch_params_s ch_params;
11937
11938 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
11939 hdd_err("Not supported, device is not in monitor mode");
11940 return -EINVAL;
11941 }
11942
11943 hdd_info("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080011944 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011945 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
11946 roam_profile.ChannelInfo.numOfChannels = 1;
11947 roam_profile.phyMode = ch_info->phy_mode;
11948 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070011949 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011950
11951 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
11952 QDF_MAC_ADDR_SIZE);
11953
11954 ch_params.ch_width = bandwidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -070011955 cds_set_channel_params(chan, 0, &ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070011956 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
11957 &roam_profile);
11958 if (status) {
11959 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
11960 status);
11961 }
11962
11963 return qdf_status_to_os_return(status);
11964}
11965
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011966static int __iw_set_two_ints_getnone(struct net_device *dev,
11967 struct iw_request_info *info,
11968 union iwreq_data *wrqu, char *extra)
11969{
11970 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11971 int *value = (int *)extra;
11972 int sub_cmd = value[0];
11973 int ret;
11974 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11975
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011976 ENTER_DEV(dev);
11977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011978 ret = wlan_hdd_validate_context(hdd_ctx);
11979 if (0 != ret)
11980 return ret;
11981
Jeff Johnson441e1f72017-02-07 08:50:49 -080011982 ret = hdd_check_private_wext_control(hdd_ctx, info);
11983 if (0 != ret)
11984 return ret;
11985
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011986 switch (sub_cmd) {
11987 case WE_SET_SMPS_PARAM:
Jeff Johnson99bac312016-06-28 10:38:18 -070011988 hdd_notice("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011989 ret = wma_cli_set_command(pAdapter->sessionId,
11990 WMI_STA_SMPS_PARAM_CMDID,
11991 value[1] << WMA_SMPS_PARAM_VALUE_S
11992 | value[2],
11993 VDEV_CMD);
11994 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070011995#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011996 case WE_SET_FW_CRASH_INJECT:
Jeff Johnson99bac312016-06-28 10:38:18 -070011997 hdd_err("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011998 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053011999 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
12000 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012001 ret = wma_cli_set2_command(pAdapter->sessionId,
12002 GEN_PARAM_CRASH_INJECT,
12003 value[1], value[2], GEN_CMD);
12004 break;
12005#endif
Govind Singha471e5e2015-10-12 17:11:14 +053012006 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070012007 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012008 value[1], value[2]);
12009 ret = wma_cli_set2_command(pAdapter->sessionId,
12010 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
12011 value[1], value[2], DBG_CMD);
12012 break;
12013 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070012014 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012015 value[1], value[2]);
12016 ret = wma_cli_set2_command(pAdapter->sessionId,
12017 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
12018 value[1], value[2], DBG_CMD);
12019 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012020 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
12021 hdd_debug("Ioctl to set dual fw mode config");
12022 if (hdd_ctx->config->dual_mac_feature_disable) {
12023 hdd_err("Dual mac feature is disabled from INI");
12024 return -EPERM;
12025 }
12026 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -080012027 cds_set_dual_mac_fw_mode_config(value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012028 break;
12029 case WE_DUMP_DP_TRACE_LEVEL:
12030 hdd_info("WE_DUMP_DP_TRACE_LEVEL: %d %d",
12031 value[1], value[2]);
12032 if (value[1] == DUMP_DP_TRACE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012033 qdf_dp_trace_dump_all(value[2]);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053012034 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
12035 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053012036 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
12037 qdf_dp_trace_clear_buffer();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012038 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012039 case WE_SET_MON_MODE_CHAN:
12040 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
12041 break;
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012042 case WE_SET_WLAN_SUSPEND:
Dustin Brownbc81a472016-10-26 16:56:59 -070012043 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012044 break;
12045 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070012046 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012047 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012048 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070012049 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012050 break;
12051 }
12052
12053 return ret;
12054}
12055
12056static int iw_set_two_ints_getnone(struct net_device *dev,
12057 struct iw_request_info *info,
12058 union iwreq_data *wrqu, char *extra)
12059{
12060 int ret;
12061
12062 cds_ssr_protect(__func__);
12063 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
12064 cds_ssr_unprotect(__func__);
12065
12066 return ret;
12067}
12068
12069/* Define the Wireless Extensions to the Linux Network Device structure */
12070/* A number of these routines are NULL (meaning they are not implemented.) */
12071
12072static const iw_handler we_handler[] = {
12073 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
12074 (iw_handler) iw_get_name, /* SIOCGIWNAME */
12075 (iw_handler) NULL, /* SIOCSIWNWID */
12076 (iw_handler) NULL, /* SIOCGIWNWID */
12077 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
12078 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
12079 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
12080 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
12081 (iw_handler) NULL, /* SIOCSIWSENS */
12082 (iw_handler) NULL, /* SIOCGIWSENS */
12083 (iw_handler) NULL, /* SIOCSIWRANGE */
12084 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
12085 (iw_handler) NULL, /* SIOCSIWPRIV */
12086 (iw_handler) NULL, /* SIOCGIWPRIV */
12087 (iw_handler) NULL, /* SIOCSIWSTATS */
12088 (iw_handler) NULL, /* SIOCGIWSTATS */
12089 (iw_handler) NULL, /* SIOCSIWSPY */
12090 (iw_handler) NULL, /* SIOCGIWSPY */
12091 (iw_handler) NULL, /* SIOCSIWTHRSPY */
12092 (iw_handler) NULL, /* SIOCGIWTHRSPY */
12093 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
12094 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
12095 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
12096 (iw_handler) NULL, /* SIOCGIWAPLIST */
12097 (iw_handler) iw_set_scan, /* SIOCSIWSCAN */
12098 (iw_handler) iw_get_scan, /* SIOCGIWSCAN */
12099 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
12100 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
12101 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
12102 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
12103 (iw_handler) NULL, /* -- hole -- */
12104 (iw_handler) NULL, /* -- hole -- */
12105 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
12106 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
12107 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
12108 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
12109 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
12110 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
12111 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
12112 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
12113 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
12114 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
12115 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
12116 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
12117 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
12118 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
12119 (iw_handler) NULL, /* -- hole -- */
12120 (iw_handler) NULL, /* -- hole -- */
12121 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
12122 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
12123 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
12124 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
12125 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
12126 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
12127 (iw_handler) NULL, /* SIOCSIWPMKSA */
12128};
12129
12130static const iw_handler we_private[] = {
12131
12132 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone, /* set priv ioctl */
12133 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint, /* get priv ioctl */
12134 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone, /* get priv ioctl */
12135 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12136 iw_set_three_ints_getnone,
12137 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
12138 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone, /* action priv ioctl */
12139 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12140 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070012141 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
12142 iw_setnone_get_threeint,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012143 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
12144 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
12145 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012146 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012147 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
12148 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
12149 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
12150 iw_set_keepalive_params,
12151#ifdef WLAN_FEATURE_PACKET_FILTERING
12152 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
12153 iw_set_packet_filter_params,
12154#endif
12155#ifdef FEATURE_WLAN_SCAN_PNO
12156 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
12157#endif
12158 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080012159 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
12160 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012161 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
12162 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12163 iw_set_two_ints_getnone,
12164 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
12165 iw_set_dot11p_channel_sched,
12166};
12167
12168/*Maximum command length can be only 15 */
12169static const struct iw_priv_args we_private_args[] = {
12170
12171 /* handlers for main ioctl */
12172 {WLAN_PRIV_SET_INT_GET_NONE,
12173 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12174 0,
12175 ""},
12176
12177 /* handlers for sub-ioctl */
12178 {WE_SET_11D_STATE,
12179 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12180 0,
12181 "set11Dstate"},
12182
12183 {WE_WOWL,
12184 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12185 0,
12186 "wowl"},
12187
12188 {WE_SET_POWER,
12189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12190 0,
12191 "setPower"},
12192
12193 {WE_SET_MAX_ASSOC,
12194 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12195 0,
12196 "setMaxAssoc"},
12197
12198 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
12199 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
12200 "setAutoChannel" },
12201
12202 {WE_SET_SCAN_DISABLE,
12203 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12204 0,
12205 "scan_disable"},
12206
12207 {WE_SET_DATA_INACTIVITY_TO,
12208 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12209 0,
12210 "inactivityTO"},
12211
12212 {WE_SET_MAX_TX_POWER,
12213 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12214 0,
12215 "setMaxTxPower"},
12216
12217 {WE_SET_TX_POWER,
12218 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12219 0,
12220 "setTxPower"},
12221
12222 {WE_SET_MC_RATE,
12223 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12224 0,
12225 "setMcRate"},
12226
12227 {WE_SET_MAX_TX_POWER_2_4,
12228 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12229 0,
12230 "setTxMaxPower2G"},
12231
12232 {WE_SET_MAX_TX_POWER_5_0,
12233 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12234 0,
12235 "setTxMaxPower5G"},
12236
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012237 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012238 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012239 0,
12240 "pktlog"},
12241
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012242 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
12243 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012244 * will support both
12245 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012246 {WE_SET_MAX_TX_POWER,
12247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12248 0,
12249 "setTxMaxPower"},
12250
12251 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080012252 * 1 = enable and 0 = disable
12253 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012254 {
12255 WE_SET_HIGHER_DTIM_TRANSITION,
12256 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12257 0,
12258 "setHDtimTransn"
12259 },
12260
12261 {WE_SET_TM_LEVEL,
12262 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12263 0,
12264 "setTmLevel"},
12265
12266 {WE_SET_PHYMODE,
12267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12268 0,
12269 "setphymode"},
12270
12271 {WE_SET_NSS,
12272 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12273 0,
12274 "nss"},
12275
12276 {WE_SET_LDPC,
12277 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12278 0,
12279 "ldpc"},
12280
12281 {WE_SET_TX_STBC,
12282 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12283 0,
12284 "tx_stbc"},
12285
12286 {WE_SET_RX_STBC,
12287 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12288 0,
12289 "rx_stbc"},
12290
12291 {WE_SET_SHORT_GI,
12292 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12293 0,
12294 "shortgi"},
12295
12296 {WE_SET_RTSCTS,
12297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12298 0,
12299 "enablertscts"},
12300
12301 {WE_SET_CHWIDTH,
12302 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12303 0,
12304 "chwidth"},
12305
12306 {WE_SET_ANI_EN_DIS,
12307 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12308 0,
12309 "anienable"},
12310
12311 {WE_SET_ANI_POLL_PERIOD,
12312 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12313 0,
12314 "aniplen"},
12315
12316 {WE_SET_ANI_LISTEN_PERIOD,
12317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12318 0,
12319 "anilislen"},
12320
12321 {WE_SET_ANI_OFDM_LEVEL,
12322 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12323 0,
12324 "aniofdmlvl"},
12325
12326 {WE_SET_ANI_CCK_LEVEL,
12327 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12328 0,
12329 "aniccklvl"},
12330
12331 {WE_SET_DYNAMIC_BW,
12332 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12333 0,
12334 "cwmenable"},
12335
12336 {WE_SET_CTS_CBW,
12337 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12338 0,
12339 "cts_cbw" },
12340
12341 {WE_SET_GTX_HT_MCS,
12342 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12343 0,
12344 "gtxHTMcs"},
12345
12346 {WE_SET_GTX_VHT_MCS,
12347 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12348 0,
12349 "gtxVHTMcs"},
12350
12351 {WE_SET_GTX_USRCFG,
12352 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12353 0,
12354 "gtxUsrCfg"},
12355
12356 {WE_SET_GTX_THRE,
12357 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12358 0,
12359 "gtxThre"},
12360
12361 {WE_SET_GTX_MARGIN,
12362 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12363 0,
12364 "gtxMargin"},
12365
12366 {WE_SET_GTX_STEP,
12367 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12368 0,
12369 "gtxStep"},
12370
12371 {WE_SET_GTX_MINTPC,
12372 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12373 0,
12374 "gtxMinTpc"},
12375
12376 {WE_SET_GTX_BWMASK,
12377 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12378 0,
12379 "gtxBWMask"},
12380
12381 {WE_SET_TX_CHAINMASK,
12382 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12383 0,
12384 "txchainmask"},
12385
12386 {WE_SET_RX_CHAINMASK,
12387 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12388 0,
12389 "rxchainmask"},
12390
12391 {WE_SET_11N_RATE,
12392 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12393 0,
12394 "set11NRates"},
12395
12396 {WE_SET_VHT_RATE,
12397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12398 0,
12399 "set11ACRates"},
12400
12401 {WE_SET_AMPDU,
12402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12403 0,
12404 "ampdu"},
12405
12406 {WE_SET_AMSDU,
12407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12408 0,
12409 "amsdu"},
12410
12411 {WE_SET_BURST_ENABLE,
12412 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12413 0,
12414 "burst_enable"},
12415
12416 {WE_SET_BURST_DUR,
12417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12418 0,
12419 "burst_dur"},
12420
12421 {WE_SET_TXPOW_2G,
12422 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12423 0,
12424 "txpow2g"},
12425
12426 {WE_SET_TXPOW_5G,
12427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12428 0,
12429 "txpow5g"},
12430
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012431 /* Sub-cmds DBGLOG specific commands */
12432 {WE_DBGLOG_LOG_LEVEL,
12433 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12434 0,
12435 "dl_loglevel"},
12436
12437 {WE_DBGLOG_VAP_ENABLE,
12438 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12439 0,
12440 "dl_vapon"},
12441
12442 {WE_DBGLOG_VAP_DISABLE,
12443 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12444 0,
12445 "dl_vapoff"},
12446
12447 {WE_DBGLOG_MODULE_ENABLE,
12448 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12449 0,
12450 "dl_modon"},
12451
12452 {WE_DBGLOG_MODULE_DISABLE,
12453 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12454 0,
12455 "dl_modoff"},
12456
12457 {WE_DBGLOG_MOD_LOG_LEVEL,
12458 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12459 0,
12460 "dl_mod_loglevel"},
12461
12462 {WE_DBGLOG_TYPE,
12463 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12464 0,
12465 "dl_type"},
12466 {WE_DBGLOG_REPORT_ENABLE,
12467 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12468 0,
12469 "dl_report"},
12470
12471 {WE_SET_TXRX_FWSTATS,
12472 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12473 0,
12474 "txrx_fw_stats"},
12475
12476 {WE_TXRX_FWSTATS_RESET,
12477 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12478 0,
12479 "txrx_fw_st_rst"},
12480
12481 {WE_PPS_PAID_MATCH,
12482 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12483 0, "paid_match"},
12484
12485 {WE_PPS_GID_MATCH,
12486 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12487 0, "gid_match"},
12488
12489 {WE_PPS_EARLY_TIM_CLEAR,
12490 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12491 0, "tim_clear"},
12492
12493 {WE_PPS_EARLY_DTIM_CLEAR,
12494 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12495 0, "dtim_clear"},
12496
12497 {WE_PPS_EOF_PAD_DELIM,
12498 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12499 0, "eof_delim"},
12500
12501 {WE_PPS_MACADDR_MISMATCH,
12502 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12503 0, "mac_match"},
12504
12505 {WE_PPS_DELIM_CRC_FAIL,
12506 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12507 0, "delim_fail"},
12508
12509 {WE_PPS_GID_NSTS_ZERO,
12510 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12511 0, "nsts_zero"},
12512
12513 {WE_PPS_RSSI_CHECK,
12514 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12515 0, "rssi_chk"},
12516
12517 {WE_PPS_5G_EBT,
12518 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12519 0, "5g_ebt"},
12520
12521 {WE_SET_HTSMPS,
12522 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12523 0, "htsmps"},
12524
12525 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
12526 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12527 0, "set_qpspollcnt"},
12528
12529 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
12530 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12531 0, "set_qtxwake"},
12532
12533 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
12534 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12535 0, "set_qwakeintv"},
12536
12537 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
12538 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12539 0, "set_qnodatapoll"},
12540
12541 /* handlers for MCC time quota and latency sub ioctls */
12542 {WE_MCC_CONFIG_LATENCY,
12543 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12544 0, "setMccLatency"},
12545
12546 {WE_MCC_CONFIG_QUOTA,
12547 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12548 0, "setMccQuota"},
12549
12550 {WE_SET_DEBUG_LOG,
12551 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12552 0, "setDbgLvl"},
12553
12554 /* handlers for early_rx power save */
12555 {WE_SET_EARLY_RX_ADJUST_ENABLE,
12556 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12557 0, "erx_enable"},
12558
12559 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
12560 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12561 0, "erx_bmiss_val"},
12562
12563 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
12564 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12565 0, "erx_bmiss_smpl"},
12566
12567 {WE_SET_EARLY_RX_SLOP_STEP,
12568 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12569 0, "erx_slop_step"},
12570
12571 {WE_SET_EARLY_RX_INIT_SLOP,
12572 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12573 0, "erx_init_slop"},
12574
12575 {WE_SET_EARLY_RX_ADJUST_PAUSE,
12576 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12577 0, "erx_adj_pause"},
12578
12579 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
12580 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12581 0, "erx_dri_sample"},
12582
12583 {WE_DUMP_STATS,
12584 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12585 0, "dumpStats"},
12586
12587 {WE_CLEAR_STATS,
12588 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12589 0, "clearStats"},
12590
Govind Singha471e5e2015-10-12 17:11:14 +053012591 {WE_START_FW_PROFILE,
12592 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12593 0, "startProfile"},
12594
Abhishek Singh1bdb1572015-10-16 16:24:19 +053012595 {WE_SET_CHANNEL,
12596 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12597 0, "setChanChange" },
12598
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053012599 {WE_SET_CONC_SYSTEM_PREF,
12600 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12601 0, "setConcSysPref" },
12602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012603 {WLAN_PRIV_SET_NONE_GET_INT,
12604 0,
12605 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12606 ""},
12607
12608 /* handlers for sub-ioctl */
12609 {WE_GET_11D_STATE,
12610 0,
12611 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12612 "get11Dstate"},
12613
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012614 {WE_GET_WLAN_DBG,
12615 0,
12616 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12617 "getwlandbg"},
12618
12619 {WE_GET_MAX_ASSOC,
12620 0,
12621 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12622 "getMaxAssoc"},
12623
12624 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
12625 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12626 "getAutoChannel" },
12627
12628 {WE_GET_CONCURRENCY_MODE,
12629 0,
12630 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12631 "getconcurrency"},
12632
12633 {WE_GET_NSS,
12634 0,
12635 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12636 "get_nss"},
12637
12638 {WE_GET_LDPC,
12639 0,
12640 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12641 "get_ldpc"},
12642
12643 {WE_GET_TX_STBC,
12644 0,
12645 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12646 "get_tx_stbc"},
12647
12648 {WE_GET_RX_STBC,
12649 0,
12650 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12651 "get_rx_stbc"},
12652
12653 {WE_GET_SHORT_GI,
12654 0,
12655 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12656 "get_shortgi"},
12657
12658 {WE_GET_RTSCTS,
12659 0,
12660 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12661 "get_rtscts"},
12662
12663 {WE_GET_CHWIDTH,
12664 0,
12665 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12666 "get_chwidth"},
12667
12668 {WE_GET_ANI_EN_DIS,
12669 0,
12670 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12671 "get_anienable"},
12672
12673 {WE_GET_ANI_POLL_PERIOD,
12674 0,
12675 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12676 "get_aniplen"},
12677
12678 {WE_GET_ANI_LISTEN_PERIOD,
12679 0,
12680 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12681 "get_anilislen"},
12682
12683 {WE_GET_ANI_OFDM_LEVEL,
12684 0,
12685 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12686 "get_aniofdmlvl"},
12687
12688 {WE_GET_ANI_CCK_LEVEL,
12689 0,
12690 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12691 "get_aniccklvl"},
12692
12693 {WE_GET_DYNAMIC_BW,
12694 0,
12695 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12696 "get_cwmenable"},
12697
12698 {WE_GET_GTX_HT_MCS,
12699 0,
12700 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12701 "get_gtxHTMcs"},
12702
12703 {WE_GET_GTX_VHT_MCS,
12704 0,
12705 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12706 "get_gtxVHTMcs"},
12707
12708 {WE_GET_GTX_USRCFG,
12709 0,
12710 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12711 "get_gtxUsrCfg"},
12712
12713 {WE_GET_GTX_THRE,
12714 0,
12715 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12716 "get_gtxThre"},
12717
12718 {WE_GET_GTX_MARGIN,
12719 0,
12720 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12721 "get_gtxMargin"},
12722
12723 {WE_GET_GTX_STEP,
12724 0,
12725 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12726 "get_gtxStep"},
12727
12728 {WE_GET_GTX_MINTPC,
12729 0,
12730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12731 "get_gtxMinTpc"},
12732
12733 {WE_GET_GTX_BWMASK,
12734 0,
12735 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12736 "get_gtxBWMask"},
12737
12738 {WE_GET_TX_CHAINMASK,
12739 0,
12740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12741 "get_txchainmask"},
12742
12743 {WE_GET_RX_CHAINMASK,
12744 0,
12745 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12746 "get_rxchainmask"},
12747
12748 {WE_GET_11N_RATE,
12749 0,
12750 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12751 "get_11nrate"},
12752
12753 {WE_GET_AMPDU,
12754 0,
12755 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12756 "get_ampdu"},
12757
12758 {WE_GET_AMSDU,
12759 0,
12760 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12761 "get_amsdu"},
12762
12763 {WE_GET_BURST_ENABLE,
12764 0,
12765 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12766 "get_burst_en"},
12767
12768 {WE_GET_BURST_DUR,
12769 0,
12770 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12771 "get_burst_dur"},
12772
12773 {WE_GET_TXPOW_2G,
12774 0,
12775 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12776 "get_txpow2g"},
12777
12778 {WE_GET_TXPOW_5G,
12779 0,
12780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12781 "get_txpow5g"},
12782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012783 {WE_GET_PPS_PAID_MATCH,
12784 0,
12785 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12786 "get_paid_match"},
12787
12788 {WE_GET_PPS_GID_MATCH,
12789 0,
12790 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12791 "get_gid_match"},
12792
12793 {WE_GET_PPS_EARLY_TIM_CLEAR,
12794 0,
12795 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12796 "get_tim_clear"},
12797
12798 {WE_GET_PPS_EARLY_DTIM_CLEAR,
12799 0,
12800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12801 "get_dtim_clear"},
12802
12803 {WE_GET_PPS_EOF_PAD_DELIM,
12804 0,
12805 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12806 "get_eof_delim"},
12807
12808 {WE_GET_PPS_MACADDR_MISMATCH,
12809 0,
12810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12811 "get_mac_match"},
12812
12813 {WE_GET_PPS_DELIM_CRC_FAIL,
12814 0,
12815 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12816 "get_delim_fail"},
12817
12818 {WE_GET_PPS_GID_NSTS_ZERO,
12819 0,
12820 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12821 "get_nsts_zero"},
12822
12823 {WE_GET_PPS_RSSI_CHECK,
12824 0,
12825 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12826 "get_rssi_chk"},
12827
12828 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
12829 0,
12830 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12831 "get_qpspollcnt"},
12832
12833 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
12834 0,
12835 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12836 "get_qtxwake"},
12837
12838 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
12839 0,
12840 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12841 "get_qwakeintv"},
12842
12843 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
12844 0,
12845 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12846 "get_qnodatapoll"},
12847
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070012848 {WE_CAP_TSF,
12849 0,
12850 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12851 "cap_tsf"},
12852
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012853 {WE_GET_TEMPERATURE,
12854 0,
12855 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
12856 "get_temp"},
12857 /* handlers for main ioctl */
12858 {WLAN_PRIV_SET_CHAR_GET_NONE,
12859 IW_PRIV_TYPE_CHAR | 512,
12860 0,
12861 ""},
12862
12863 /* handlers for sub-ioctl */
12864 {WE_WOWL_ADD_PTRN,
12865 IW_PRIV_TYPE_CHAR | 512,
12866 0,
12867 "wowlAddPtrn"},
12868
12869 {WE_WOWL_DEL_PTRN,
12870 IW_PRIV_TYPE_CHAR | 512,
12871 0,
12872 "wowlDelPtrn"},
12873
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012874 /* handlers for sub-ioctl */
12875 {WE_NEIGHBOR_REPORT_REQUEST,
12876 IW_PRIV_TYPE_CHAR | 512,
12877 0,
12878 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080012879
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012880 {WE_SET_AP_WPS_IE,
12881 IW_PRIV_TYPE_CHAR | 512,
12882 0,
12883 "set_ap_wps_ie"},
12884
12885 {WE_SET_CONFIG,
12886 IW_PRIV_TYPE_CHAR | 512,
12887 0,
12888 "setConfig"},
12889
12890 /* handlers for main ioctl */
12891 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
12892 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
12893 0,
12894 ""},
12895
12896 /* handlers for sub-ioctl */
12897 {WE_SET_WLAN_DBG,
12898 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
12899 0,
12900 "setwlandbg"},
12901
12902 /* handlers for sub-ioctl */
12903 {WE_SET_DP_TRACE,
12904 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
12905 0,
12906 "set_dp_trace"},
12907
12908 {WE_SET_SAP_CHANNELS,
12909 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
12910 0,
12911 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053012912
12913 {WE_SET_FW_TEST,
12914 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
12915 0, "fw_test"},
12916
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070012917 /* handlers for main ioctl */
12918 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
12919 0,
12920 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
12921 "" },
12922 {WE_GET_TSF,
12923 0,
12924 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
12925 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012926
12927 {WE_SET_DUAL_MAC_SCAN_CONFIG,
12928 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
12929 0,
12930 "set_scan_cfg"},
12931
12932 /* handlers for main ioctl */
12933 {WLAN_PRIV_GET_CHAR_SET_NONE,
12934 0,
12935 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12936 ""},
12937
12938 /* handlers for sub-ioctl */
12939 {WE_WLAN_VERSION,
12940 0,
12941 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12942 "version"},
12943 {WE_GET_STATS,
12944 0,
12945 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12946 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080012947 {WE_GET_SUSPEND_RESUME_STATS,
12948 0,
12949 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12950 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053012951 {WE_LIST_FW_PROFILE,
12952 0,
12953 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12954 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012955 {WE_GET_STATES,
12956 0,
12957 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12958 "getHostStates"},
12959 {WE_GET_CFG,
12960 0,
12961 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12962 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012963 {WE_GET_RSSI,
12964 0,
12965 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12966 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012967 {WE_GET_WMM_STATUS,
12968 0,
12969 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12970 "getWmmStatus"},
12971 {
12972 WE_GET_CHANNEL_LIST,
12973 0,
12974 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12975 "getChannelList"
12976 },
12977#ifdef FEATURE_WLAN_TDLS
12978 {
12979 WE_GET_TDLS_PEERS,
12980 0,
12981 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12982 "getTdlsPeers"
12983 },
12984#endif
12985#ifdef WLAN_FEATURE_11W
12986 {
12987 WE_GET_11W_INFO,
12988 0,
12989 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12990 "getPMFInfo"
12991 },
12992#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080012993 {
12994 WE_GET_IBSS_STA_INFO,
12995 0,
12996 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
12997 "getIbssSTAs"
12998 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012999 {WE_GET_PHYMODE,
13000 0,
13001 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13002 "getphymode"},
13003#ifdef FEATURE_OEM_DATA_SUPPORT
13004 {WE_GET_OEM_DATA_CAP,
13005 0,
13006 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13007 "getOemDataCap"},
13008#endif /* FEATURE_OEM_DATA_SUPPORT */
13009 {WE_GET_SNR,
13010 0,
13011 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13012 "getSNR"},
13013
13014 /* handlers for main ioctl */
13015 {WLAN_PRIV_SET_NONE_GET_NONE,
13016 0,
13017 0,
13018 ""},
13019
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013020 /* handlers for sub-ioctl */
13021 {
13022 WE_IBSS_GET_PEER_INFO_ALL,
13023 0,
13024 0,
13025 "ibssPeerInfoAll"
13026 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013027 {WE_GET_RECOVERY_STAT,
13028 0,
13029 0,
13030 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053013031
13032 {WE_GET_FW_PROFILE_DATA,
13033 0,
13034 0,
13035 "getProfileData"},
13036
13037 {WE_SET_REASSOC_TRIGGER,
13038 0,
13039 0,
13040 "reassoc"},
13041
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080013042 {WE_STOP_OBSS_SCAN,
13043 0,
13044 0,
13045 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013046 /* handlers for main ioctl */
13047 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
13048 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13049 0,
13050 ""},
13051
13052 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013053 {WE_IBSS_GET_PEER_INFO,
13054 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13055 0,
13056 "ibssPeerInfo"},
13057
13058 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013059 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
13060 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13061 0,
13062 "setdumplog"},
13063
13064 {WE_MTRACE_DUMP_CMD,
13065 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13066 0,
13067 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080013068
13069 {WE_POLICY_MANAGER_CINFO_CMD,
13070 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13071 0,
13072 "pm_cinfo"},
13073
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013074#ifdef MPC_UT_FRAMEWORK
13075 {WE_POLICY_MANAGER_CLIST_CMD,
13076 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13077 0,
13078 "pm_clist"},
13079
13080 {WE_POLICY_MANAGER_DLIST_CMD,
13081 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13082 0,
13083 "pm_dlist"},
13084
13085 {WE_POLICY_MANAGER_DBS_CMD,
13086 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13087 0,
13088 "pm_dbs"},
13089
13090 {WE_POLICY_MANAGER_PCL_CMD,
13091 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13092 0,
13093 "pm_pcl"},
13094
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013095 {WE_POLICY_MANAGER_ULIST_CMD,
13096 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13097 0,
13098 "pm_ulist"},
13099
13100 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
13101 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13102 0,
13103 "pm_query_action"},
13104
13105 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
13106 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13107 0,
13108 "pm_query_allow"},
13109
13110 {WE_POLICY_MANAGER_SCENARIO_CMD,
13111 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13112 0,
13113 "pm_run_scenario"},
13114
13115 {WE_POLICY_SET_HW_MODE_CMD,
13116 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13117 0,
13118 "pm_set_hw_mode"},
13119#endif
13120#ifdef FEATURE_WLAN_TDLS
13121 /* handlers for sub ioctl */
13122 {
13123 WE_TDLS_CONFIG_PARAMS,
13124 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13125 0,
13126 "setTdlsConfig"
13127 },
13128#endif
13129 {
13130 WE_UNIT_TEST_CMD,
13131 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13132 0,
13133 "setUnitTestCmd"
13134 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053013135 {
13136 WE_MAC_PWR_DEBUG_CMD,
13137 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13138 0,
13139 "halPwrDebug"
13140 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013141
13142#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
13143 {WE_LED_FLASHING_PARAM,
13144 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13145 0,
13146 "gpio_control"},
13147#endif
13148 /* handlers for main ioctl */
13149 {WLAN_PRIV_ADD_TSPEC,
13150 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
13151 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13152 "addTspec"},
13153
13154 /* handlers for main ioctl */
13155 {WLAN_PRIV_DEL_TSPEC,
13156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13157 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13158 "delTspec"},
13159
13160 /* handlers for main ioctl */
13161 {WLAN_PRIV_GET_TSPEC,
13162 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13163 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13164 "getTspec"},
13165
13166 /* handlers for main ioctl - host offload */
13167 {
13168 WLAN_PRIV_SET_HOST_OFFLOAD,
13169 IW_PRIV_TYPE_BYTE | sizeof(tHostOffloadRequest),
13170 0,
13171 "setHostOffload"
13172 }
13173 ,
13174
13175 {
13176 WLAN_GET_WLAN_STATISTICS,
13177 0,
13178 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
13179 "getWlanStats"
13180 }
13181 ,
13182
13183 {
13184 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053013185 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
13186 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013187 0,
13188 "setKeepAlive"
13189 }
13190 ,
13191#ifdef WLAN_FEATURE_PACKET_FILTERING
13192 {
13193 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053013194 IW_PRIV_TYPE_BYTE |
13195 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013196 0,
13197 "setPktFilter"
13198 }
13199 ,
13200#endif
13201#ifdef FEATURE_WLAN_SCAN_PNO
13202 {
13203 WLAN_SET_PNO,
13204 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13205 0,
13206 "setpno"
13207 }
13208 ,
13209#endif
13210 {
13211 WLAN_SET_BAND_CONFIG,
13212 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13213 0,
13214 "SETBAND"
13215 }
13216 ,
13217 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080013218 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080013219 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013220 0,
13221 "setMCBCFilter"
13222 }
13223 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013224
13225 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013226 WLAN_GET_LINK_SPEED,
13227 IW_PRIV_TYPE_CHAR | 18,
13228 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
13229 }
13230 ,
13231
13232 /* handlers for main ioctl */
13233 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
13234 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13235 0,
13236 ""}
13237 ,
13238 {WE_SET_SMPS_PARAM,
13239 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13240 0, "set_smps_param"}
13241 ,
13242 {WLAN_SET_DOT11P_CHANNEL_SCHED,
13243 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
13244 0, "set_dot11p" }
13245 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070013246#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013247 {WE_SET_FW_CRASH_INJECT,
13248 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13249 0, "crash_inject"}
13250 ,
13251#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070013252#ifdef WLAN_SUSPEND_RESUME_TEST
13253 {WE_SET_WLAN_SUSPEND,
13254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13255 0, "wlan_suspend"}
13256 ,
13257 {WE_SET_WLAN_RESUME,
13258 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13259 0, "wlan_resume"}
13260 ,
13261#endif
Govind Singha471e5e2015-10-12 17:11:14 +053013262 {WE_ENABLE_FW_PROFILE,
13263 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13264 0, "enableProfile"}
13265 ,
13266 {WE_SET_FW_PROFILE_HIST_INTVL,
13267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13268 0, "set_hist_intvl"}
13269 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013270 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
13271 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13272 0, "set_fw_mode_cfg"}
13273 ,
13274 {WE_DUMP_DP_TRACE_LEVEL,
13275 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13276 0, "dump_dp_trace"}
13277 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070013278 {WE_SET_MON_MODE_CHAN,
13279 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
13280 0, "setMonChan"}
13281 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070013282
13283 {WE_GET_ROAM_SYNCH_DELAY,
13284 0,
13285 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13286 "hostroamdelay"}
13287 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013288};
13289
13290const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053013291 .num_standard = QDF_ARRAY_SIZE(we_handler),
13292 .num_private = QDF_ARRAY_SIZE(we_private),
13293 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013294
13295 .standard = (iw_handler *) we_handler,
13296 .private = (iw_handler *) we_private,
13297 .private_args = we_private_args,
13298 .get_wireless_stats = NULL,
13299};
13300
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013301/* hdd_set_wext() - configures bss parameters
13302 * @pAdapter: handle to adapter context
13303 *
13304 * Returns: none
13305 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -070013306static int hdd_set_wext(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013307{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013308 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
13309 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013310
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013311 ENTER();
13312
13313 if (!pwextBuf) {
13314 hdd_err("ERROR: pwextBuf is NULL");
13315 return QDF_STATUS_E_FAILURE;
13316 }
13317
13318 if (!pHddStaCtx) {
13319 hdd_err("ERROR: pHddStaCtx is NULL");
13320 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013321 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013322
13323 /* Now configure the roaming profile links. To SSID and bssid. */
13324 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013325 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013326
13327 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013328 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013329
13330 /*Set the numOfChannels to zero to scan all the channels */
13331 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
13332 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
13333
13334 /* Default is no encryption */
13335 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
13336 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
13337 eCSR_ENCRYPT_TYPE_NONE;
13338
13339 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
13340 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
13341 eCSR_ENCRYPT_TYPE_NONE;
13342
13343 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
13344
13345 /* Default is no authentication */
13346 pwextBuf->roamProfile.AuthType.numEntries = 1;
13347 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
13348
13349 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
13350 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
13351
13352 /*Set the default scan mode */
13353 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
13354
13355 hdd_clear_roam_profile_ie(pAdapter);
13356
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013357 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013358 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013359
13360}
13361
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013362/**
13363 * hdd_register_wext() - register wext context
13364 * @dev: net device handle
13365 *
13366 * Registers wext interface context for a given net device
13367 *
13368 * Returns: 0 on success, errno on failure
13369 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013370int hdd_register_wext(struct net_device *dev)
13371{
13372 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013373 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053013374 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013375
13376 ENTER();
13377
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070013378 if (!pwextBuf) {
13379 hdd_err(FL("ERROR: pwextBuf is NULL"));
13380 return QDF_STATUS_E_FAILURE;
13381 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070013382
13383 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013384 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
13385
13386 init_completion(&(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->
13387 completion_var);
13388
13389 status = hdd_set_wext(pAdapter);
13390
Anurag Chouhance0dc992016-02-16 18:18:03 +053013391 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013392
Jeff Johnson99bac312016-06-28 10:38:18 -070013393 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013394 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013395 }
13396
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013397 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->hdd_qdf_event))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070013398 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013399 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013400 }
13401
Anurag Chouhance0dc992016-02-16 18:18:03 +053013402 if (!QDF_IS_STATUS_SUCCESS(qdf_event_create(&pwextBuf->scanevent))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070013403 hdd_err("ERROR: HDD scan event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013404 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013405 }
13406 /* Register as a wireless device */
13407 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
13408
13409 EXIT();
13410 return 0;
13411}
13412
13413int hdd_unregister_wext(struct net_device *dev)
13414{
Jeff Johnson99bac312016-06-28 10:38:18 -070013415 hdd_notice("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013416
13417 if (dev != NULL) {
13418 rtnl_lock();
13419 dev->wireless_handlers = NULL;
13420 rtnl_unlock();
13421 }
13422
13423 return 0;
13424}