blob: b73a5b023d6f131621a65f46ad8ededcb2749514 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Dustin Brownd9322482017-01-09 12:46:03 -08002 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_wext.c
30 *
31 * Linux Wireless Extensions Implementation
32 */
33
34#include <linux/version.h>
35#include <linux/module.h>
36#include <linux/kernel.h>
37#include <linux/init.h>
38#include <linux/wireless.h>
39#include <mac_trace.h>
40#include <wlan_hdd_includes.h>
41#include <cds_api.h>
Rajeev Kumarea95edd2017-01-11 20:49:36 -080042#include "scheduler_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043#include <net/arp.h>
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080044#include <cdp_txrx_cmn.h>
Manjunathappa Prakash3454fd62016-04-01 08:52:06 -070045#include <cdp_txrx_stats.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "sir_params.h"
47#include "csr_api.h"
48#include "csr_inside_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include "sme_rrm_internal.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include <ani_global.h>
51#include "dot11f.h"
52#include <wlan_hdd_wowl.h>
53#include <wlan_hdd_cfg.h>
54#include <wlan_hdd_wmm.h>
55#include "utils_api.h"
56#include "wlan_hdd_p2p.h"
57#ifdef FEATURE_WLAN_TDLS
58#include "wlan_hdd_tdls.h"
59#endif
60
61#include "cds_ieee80211_common.h"
62#include "ol_if_athvar.h"
63#include "dbglog_host.h"
64#include "wma.h"
65
66#include "wlan_hdd_power.h"
67#include "qwlan_version.h"
68#include "wlan_hdd_host_offload.h"
69
70#include <linux/wireless.h>
71#include <net/cfg80211.h>
72
73#include "wlan_hdd_misc.h"
74
75#include "qc_sap_ioctl.h"
76#include "sme_api.h"
77#include "wma_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053078#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079#include "wlan_hdd_assoc.h"
80#include "wlan_hdd_ioctl.h"
81#include "wlan_hdd_scan.h"
82#include "sme_power_save_api.h"
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080083#include "wlan_policy_mgr_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084#include "wlan_hdd_conc_ut.h"
Jeff Johnson6fa1e012017-04-05 06:40:53 -070085#include "wlan_hdd_fips.h"
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070086#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087#include "wlan_hdd_ocb.h"
88#include "wlan_hdd_napi.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080089#include "cdp_txrx_flow_ctrl_legacy.h"
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070090#include "wlan_hdd_nan_datapath.h"
Nirav Shahbf1b0332016-05-25 14:27:39 +053091#include "wlan_hdd_stats.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070092#ifdef WLAN_SUSPEND_RESUME_TEST
93#include "wlan_hdd_driver_ops.h"
94#include "hif.h"
Rajeev Kumar9bb2e852016-09-24 12:29:25 -070095#include "pld_common.h"
Rajeev Kumara78a0a42016-07-13 19:28:20 -070096#endif
Dhanashri Atree7d442a2016-07-14 18:20:29 -070097#include "wlan_hdd_lro.h"
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053098#include "cds_utils.h"
Jeff Johnsona6ace5b2017-01-23 07:11:02 -080099#include "wlan_hdd_request_manager.h"
Naveen Rawat910726a2017-03-06 11:42:51 -0800100#include "os_if_wifi_pos.h"
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -0800101#include <cdp_txrx_stats.h>
102#include <cds_api.h>
Abhishek Singh0481d662017-04-11 18:20:11 +0530103#include <wlan_osif_priv.h>
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700104#include "wlan_hdd_regulatory.h"
105#include "wlan_reg_ucfg_api.h"
Abhishek Singh0481d662017-04-11 18:20:11 +0530106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107#define HDD_FINISH_ULA_TIME_OUT 800
108#define HDD_SET_MCBC_FILTERS_TO_FW 1
109#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111/* To Validate Channel against the Frequency and Vice-Versa */
Srinivas Girigowda48592672017-03-25 14:58:44 -0700112static const struct ccp_freq_chan_map freq_chan_map[] = {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
114 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
115 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
116 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
117 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
118 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
119 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
120 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
121 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
122 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
123 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
124 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
125
Srinivas Girigowdafba82a02017-03-24 21:26:35 -0700126#define FREQ_CHAN_MAP_TABLE_SIZE QDF_ARRAY_SIZE(freq_chan_map)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127
128/* Private ioctls and their sub-ioctls */
129#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
130#define WE_SET_11D_STATE 1
131#define WE_WOWL 2
132#define WE_SET_POWER 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530133/*
134 * <ioctl>
135 * setMaxAssoc - Sets the maximum number of associated stations
136 *
137 * @INPUT: 1 to 32
138 *
139 * @OUTPUT: None
140 *
141 * This IOTCL sets the maximum number of associated stations
142 *
143 * @E.g: iwpriv wlan0 setMaxAssoc <value>
144 *
145 * Supported Feature: STA
146 *
147 * Usage: Internal/External
148 *
149 * </ioctl>
150 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151#define WE_SET_MAX_ASSOC 4
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +0530152/*
153 * <ioctl>
154 * scan_diable - Disable scan
155 *
156 * @INPUT: set_value
157 *
158 * @OUTPUT: None
159 *
160 * This IOCTL is used to set disable scan
161 *
162 * @E.g: iwpriv wlan0 scan_disable 1
163 *
164 * Supported Feature: Scan
165 *
166 * Usage: Internal/External
167 *
168 * </ioctl>
169 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170#define WE_SET_SCAN_DISABLE 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530171/*
172 * <ioctl>
173 * inactivityTO - sets the timeout value for inactivity data while
174 * in power save mode
175 *
176 * @INPUT: int1…..int255
177 *
178 * @OUTPUT: None
179 *
180 * This IOCTL set the timeout value for inactivity data in power save mode
181 *
182 * @E.g: iwpriv wlan0 inactivityTO 20
183 *
184 * Supported Feature: STA
185 *
186 * Usage: Internal/External
187 *
188 * </ioctl>
189 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800190#define WE_SET_DATA_INACTIVITY_TO 6
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530191/*
192 * <ioctl>
193 * setMaxTxPower - Dynamically sets the maximum transmission power
194 *
195 * @INPUT: Transmission power in dBm
196 *
197 * @OUTPUT: None
198 *
199 * This IOCTL dynamically sets the maximum transmission power
200 * This setting does not persist over reboots
201 *
202 * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
203 *
204 * Supported Feature: STA
205 *
206 * Usage: Internal/External
207 *
208 * </ioctl>
209 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210#define WE_SET_MAX_TX_POWER 7
211#define WE_SET_HIGHER_DTIM_TRANSITION 8
212#define WE_SET_TM_LEVEL 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530213/*
214 * <ioctl>
215 * setphymode - Set the phymode dynamically
216 *
217 * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
218 *
219 * @OUTPUT: None
220 *
221 * This IOCTL sets the phymode dynamically
222 *
223 * @E.g: iwpriv wlan0 setphymode 10
224 *
225 * Supported Feature: STA
226 *
227 * Usage: Internal/External
228 *
229 * </ioctl>
230 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231#define WE_SET_PHYMODE 10
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530232/*
233 * <ioctl>
234 * nss - Set the number of spatial streams
235 *
236 * @INPUT: int1…..int3
237 *
238 * @OUTPUT: None
239 *
240 * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
241 *
242 * @E.g: iwpriv wlan0 nss 2
243 *
244 * Supported Feature: STA
245 *
246 * Usage: Internal/External
247 *
248 * </ioctl>
249 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250#define WE_SET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530251/*
252 * <ioctl>
253 * ldpc - Enables or disables LDPC
254 *
255 * @INPUT: 0 – Disable, 1 - Enable
256 *
257 * @OUTPUT: None
258 *
259 * This IOCTL enables or disables LDPC
260 *
261 * @E.g: iwpriv wlan0 ldpc 1
262 *
263 * Supported Feature: STA
264 *
265 * Usage: Internal/External
266 *
267 * </ioctl>
268 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269#define WE_SET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530270/*
271 * <ioctl>
272 * tx_stbc - Enables or disables tx_stbc
273 *
274 * @INPUT: Int 0 – Disable, 1 - Enable
275 *
276 * @OUTPUT: None
277 *
278 * This IOTCL used to enables or disables tx_stbc
279 *
280 * @E.g: iwpriv wlan0 tx_stbc <value>
281 *
282 * Supported Feature: STA
283 *
284 * Usage: Internal/External
285 *
286 * </ioctl>
287 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288#define WE_SET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530289/*
290 * <ioctl>
291 * rx_stbc - Set the rx_stbc parameter
292 *
293 * @INPUT: Int 0 – Disable, 1 - Enable
294 *
295 * @OUTPUT: None
296 *
297 * This IOTCL used to set rx_stbc parameter
298 *
299 * @E.g: iwpriv wlan0 rx_stbc <value>
300 *
301 * Supported Feature: STA
302 *
303 * Usage: Internal/External
304 *
305 * </ioctl>
306 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307#define WE_SET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530308/*
309 * <ioctl>
310 * shortgi - Enables or disables a short-guard interval
311 *
312 * @INPUT: Int 0 – Disable, 1 - Enable
313 *
314 * @OUTPUT: None
315 *
316 * This IOCTL enables or disables a short-guard interval.
317 *
318 * @E.g: iwpriv wlan0 shortgi <value>
319 *
320 * Supported Feature: STA
321 *
322 * Usage: Internal/External
323 *
324 * </ioctl>
325 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326#define WE_SET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530327/*
328 * <ioctl>
329 * enablertscts - enables or disables rts/cts.
330 *
331 * @INPUT: 1-Enable , 0-Disable
332 *
333 * @OUTPUT: None
334 *
335 * This IOCTL enables or disables rts/cts.
336 *
337 * @E.g: iwpriv wlan0 enablertscts <value>
338 *
339 * Supported Feature: STA
340 *
341 * Usage: Internal/External
342 *
343 * </ioctl>
344 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345#define WE_SET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530346/*
347 * <ioctl>
348 * chwidth - Set the channel bandwidth
349 *
350 * @INPUT: 0-20mhz to 3-160mhz
351 *
352 * @OUTPUT: None
353 *
354 * This IOTCL used to set the channel bandwidth
355 *
356 * @E.g: iwpriv wlan0 chwidth 1
357 *
358 * Supported Feature: STA
359 *
360 * Usage: Internal/External
361 *
362 * </ioctl>
363 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364#define WE_SET_CHWIDTH 17
365#define WE_SET_ANI_EN_DIS 18
366#define WE_SET_ANI_POLL_PERIOD 19
367#define WE_SET_ANI_LISTEN_PERIOD 20
368#define WE_SET_ANI_OFDM_LEVEL 21
369#define WE_SET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530370/*
371 * <ioctl>
372 * cwmenable - Enables or disables the dynamic channel bandwidth
373 *
374 * @INPUT: 0-Disable, 1-Enable
375 *
376 * @OUTPUT: None
377 *
378 * This IOTCL used to enables or disables the dynamic channel bandwidth
379 *
380 * @E.g: iwpriv wlan0 cwmenable <value>
381 *
382 * Supported Feature: STA
383 *
384 * Usage: Internal/External
385 *
386 * </ioctl>
387 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388#define WE_SET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530389/*
390 * <ioctl>
391 * txchainmask - This IOCTL sets the current Tx chain mask
392 *
393 * @INPUT: Mask Value
394 *
395 * @OUTPUT: None
396 *
397 * This IOCTL sets the current Tx chain mask
398 *
399 * @E.g: iwpriv wlan0 txchainmask 1
400 *
401 * Supported Feature: STA
402 *
403 * Usage: Internal/External
404 *
405 * </ioctl>
406 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407#define WE_SET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530408/*
409 * <ioctl>
410 * rxchainmask - Sets the current Rx chain mask
411 *
412 * @INPUT: Mask Value
413 *
414 * @OUTPUT: None
415 *
416 * This IOCTL sets the current Rx chain mask. This command is the
417 * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
418 *
419 * @E.g: iwpriv wlan0 rxchainmask <value>
420 *
421 * Supported Feature: STA
422 *
423 * Usage: Internal/External
424 *
425 * </ioctl>
426 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427#define WE_SET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530428/*
429 * <ioctl>
430 * set11NRates - Fixes the Tx data rate of the 11N mode.
431 *
432 * @INPUT: 0x1b to 0x8f
433 *
434 * @OUTPUT: None
435 *
436 * This IOCTL fixes the Tx data rate of the 11N mode.
437 *
438 * @E.g: iwpriv wlan0 set11NRates 0x85
439 *
440 * Supported Feature: STA
441 *
442 * Usage: Internal/External
443 *
444 * </ioctl>
445 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446#define WE_SET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530447/*
448 * <ioctl>
449 * ampdu - Set the the maximum subframe of ampdu
450 *
451 * @INPUT: int 1 to int 63
452 *
453 * @OUTPUT: None
454 *
455 * This IOCTL sets the maximum subframe of ampdu.
456 *
457 * @E.g: iwpriv wlan0 ampdu 9
458 *
459 * Supported Feature: STA
460 *
461 * Usage: Internal/External
462 *
463 * </ioctl>
464 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465#define WE_SET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530466/*
467 * <ioctl>
468 * amsdu - Sets the maximum subframe of amsdu.
469 *
470 * @INPUT: int 1 to int 31
471 *
472 * @OUTPUT: None
473 *
474 * This IOCTL sets the maximum subframe of amsdu.
475 *
476 * @E.g: iwpriv wlan0 amsdu 9
477 *
478 * Supported Feature: STA
479 *
480 * Usage: Internal/External
481 *
482 * </ioctl>
483 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484#define WE_SET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530485/*
486 * <ioctl>
487 * txpow2g - current 2 GHz Tx power setting
488 *
489 * @INPUT: Tx power in dBm
490 *
491 * @OUTPUT: None
492 *
493 * This IOTCL used to set 2 ghz tx power
494 *
495 * @E.g: iwpriv wlan0 txpow2g
496 *
497 * Supported Feature: STA
498 *
499 * Usage: Internal/External
500 *
501 * </ioctl>
502 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503#define WE_SET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530504/*
505 * <ioctl>
506 * txpow5g - Current 5 GHz tx power setting
507 *
508 * @INPUT: Tx power in dBm
509 *
510 * @OUTPUT: None
511 *
512 * This IOTCL used to set the 5 ghz txpower
513 *
514 * @E.g: iwpriv wlan0 txpow5g
515 *
516 * Supported Feature: STA
517 *
518 * Usage: Internal/External
519 *
520 * </ioctl>
521 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522#define WE_SET_TXPOW_5G 30
523/* Private ioctl for firmware debug log */
524#define WE_DBGLOG_LOG_LEVEL 31
525#define WE_DBGLOG_VAP_ENABLE 32
526#define WE_DBGLOG_VAP_DISABLE 33
527#define WE_DBGLOG_MODULE_ENABLE 34
528#define WE_DBGLOG_MODULE_DISABLE 35
529#define WE_DBGLOG_MOD_LOG_LEVEL 36
530#define WE_DBGLOG_TYPE 37
531#define WE_SET_TXRX_FWSTATS 38
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530532/*
533 * <ioctl>
534 * set11ACRates - Fixes the Tx data rate of 11AC
535 *
536 * @INPUT: 0x1 to 0x9
537 *
538 * @OUTPUT: None
539 *
540 * This IOCTL fixes the Tx data rate of 11AC.
541 *
542 * @E.g: iwpriv wlan0 set11ACRates 0x9
543 *
544 * Supported Feature: STA
545 *
546 * Usage: Internal/External
547 *
548 * </ioctl>
549 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550#define WE_SET_VHT_RATE 39
551#define WE_DBGLOG_REPORT_ENABLE 40
552#define WE_TXRX_FWSTATS_RESET 41
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530553/*
554 * <ioctl>
555 * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
556 *
557 * @INPUT: Transmission power in dBm
558 *
559 * @OUTPUT: None
560 *
561 * This IOCTL sets the maximum transmit power for the 2.4-GHz band
562 * This setting does not persist over reboots
563 *
564 * @E.g: iwpriv wlan0 setTxMaxPower2G 10
565 *
566 * Supported Feature: STA
567 *
568 * Usage: Internal/External
569 *
570 * </ioctl>
571 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800572#define WE_SET_MAX_TX_POWER_2_4 42
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530573/*
574 * <ioctl>
575 * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
576 *
577 * @INPUT: Transmission power in dBm
578 *
579 * @OUTPUT: None
580 *
581 * This IOCTL sets the maximum transmit power for the 5-GHz band
582 * This setting does not persist over reboots
583 *
584 * @E.g: iwpriv wlan0 setTxMaxPower5G 10
585 *
586 * Supported Feature: STA
587 *
588 * Usage: Internal/External
589 *
590 * </ioctl>
591 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800593#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594/* Private ioctl for packet powe save */
595#define WE_PPS_PAID_MATCH 45
596#define WE_PPS_GID_MATCH 46
597#define WE_PPS_EARLY_TIM_CLEAR 47
598#define WE_PPS_EARLY_DTIM_CLEAR 48
599#define WE_PPS_EOF_PAD_DELIM 49
600#define WE_PPS_MACADDR_MISMATCH 50
601#define WE_PPS_DELIM_CRC_FAIL 51
602#define WE_PPS_GID_NSTS_ZERO 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530603/*
604 * <ioctl>
605 * rssi_chk - Chek the rssi
606 *
607 * @INPUT: One argument as input
608 *
609 * @OUTPUT: rssi
610 * wlan0 rssi_chk:56
611 *
612 * This IOTCL used to chek rssi
613 *
614 * @E.g: iwpriv wlan0 rssi_chk <value>
615 *
616 * Supported Feature: STA
617 *
618 * Usage: Internal/External
619 *
620 * </ioctl>
621 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622#define WE_PPS_RSSI_CHECK 53
Agrawal Ashishbafaff12016-12-27 17:43:08 +0530623/*
624 * <ioctl>
625 * setAutoChannel - set ACS enable/disable
626 *
627 * @INPUT: None
628 *
629 * @OUTPUT: None
630 *
631 * This IOCTL is used to set SAP ACS eanble/disable
632 *
633 * @E.g: iwpriv wlan0 setAutoChannel 0
634 *
635 * Supported Feature: SAP
636 *
637 * Usage: Internal/External
638 *
639 * </ioctl>
640 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530642/*
643 * <ioctl>
644 * htsmps - Sets the htsmps
645 *
646 * @INPUT: Atleast one int argument
647 *
648 * @OUTPUT: None
649 *
650 * This IOTCL used to set htsmps
651 *
652 * @E.g: iwpriv wlan0 htsmps <value>
653 *
654 * Supported Feature: STA
655 *
656 * Usage: Internal/External
657 *
658 * </ioctl>
659 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660#define WE_SET_HTSMPS 55
661/* Private ioctl for QPower */
662#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
663#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
664#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
665#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530666/*
667 * <ioctl>
668 * burst_enable - Enables or disables the burst feature
669 *
670 * @INPUT: 0-Disable, 1-Enable
671 *
672 * @OUTPUT: None
673 *
674 * This IOCTL enables or disables the burst feature.
675 *
676 * @E.g: iwpriv wlan0 burst_enable 0
677 *
678 * Supported Feature: STA
679 *
680 * Usage: Internal/External
681 *
682 * </ioctl>
683 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684#define WE_SET_BURST_ENABLE 60
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530685/*
686 * <ioctl>
687 * burst_dur - Enables or disables the burst feature
688 *
689 * @INPUT: int 1…..int 8191 in microseconds
690 *
691 * @OUTPUT: None
692 *
693 * This IOCTL sets the burst duration.
694 *
695 * @E.g: iwpriv wlan0 burst_dur <value>
696 *
697 * Supported Feature: STA
698 *
699 * Usage: Internal/External
700 *
701 * </ioctl>
702 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800703#define WE_SET_BURST_DUR 61
704/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530705/*
706 * <ioctl>
707 * gtxHTMcs - Set the tx HTM value
708 *
709 * @INPUT: Atleast one int orgument
710 *
711 * @OUTPUT: None
712 *
713 * This IOTCL sets htm tx value
714 *
715 * @E.g: iwpriv wlan0 gtxHTMcs <value>
716 *
717 * Supported Feature: STA
718 *
719 * Usage: Internal/External
720 *
721 * </ioctl>
722 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723#define WE_SET_GTX_HT_MCS 62
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530724/*
725 * <ioctl>
726 * gtxVHTMcs - Set gtxVHTMcs value
727 *
728 * @INPUT: Atleast one int argument
729 *
730 * @OUTPUT: None
731 *
732 * This IOTCL used to set gtxVHTMcs value
733 *
734 * @E.g: iwpriv wlan0 gtxVHTMcs <value>
735 *
736 * Supported Feature: STA
737 *
738 * Usage: Internal/External
739 *
740 * </ioctl>
741 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742#define WE_SET_GTX_VHT_MCS 63
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530743/*
744 * <ioctl>
745 * gtxUsrCfg - Host request for GTX mask
746 *
747 * @INPUT: Atleast one int orgument
748 *
749 * @OUTPUT: None
750 *
751 * This IOTCL used send the host request for GTX mask
752 *
753 * @E.g: iwpriv wlan0 gtxUsrCfg <value>
754 *
755 * Supported Feature: STA
756 *
757 * Usage: Internal/External
758 *
759 * </ioctl>
760 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761#define WE_SET_GTX_USRCFG 64
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530762/*
763 * <ioctl>
764 * gtxThre - Set the tx threshold
765 *
766 * @INPUT: Atleast one int argument
767 *
768 * @OUTPUT: None
769 *
770 * This IOTCL used to set tx threshold
771 *
772 * @E.g: iwpriv wlan0 gtxThre <value>
773 *
774 * Supported Feature: STA
775 *
776 * Usage: Internal/External
777 *
778 * </ioctl>
779 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780#define WE_SET_GTX_THRE 65
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530781/*
782 * <ioctl>
783 * gtxMargin - Set the gtxMargin
784 *
785 * @INPUT: 1 to 32
786 *
787 * @OUTPUT: None
788 *
789 * This IOTCL use dto set gtxMargin
790 *
791 * @E.g: iwpriv wlan0 gtxMargini <value>
792 *
793 * Supported Feature: STA
794 *
795 * Usage: Internal/External
796 *
797 * </ioctl>
798 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799#define WE_SET_GTX_MARGIN 66
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530800/*
801 * <ioctl>
802 * gtxStep - Set the gtxStep
803 *
804 * @INPUT: None
805 *
806 * @OUTPUT: None
807 *
808 * This IOTCL used to sets gtxStep
809 *
810 * @E.g: iwpriv wlan0 gtxStep <value>
811 *
812 * Supported Feature: STA
813 *
814 * Usage: Internal/External
815 *
816 * </ioctl>
817 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818#define WE_SET_GTX_STEP 67
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530819/*
820 * <ioctl>
821 * gtxMinTpc - Sets the gtxMinTpc
822 *
823 * @INPUT: Atleast one int argument
824 *
825 * @OUTPUT: None
826 *
827 * This IOTCL sets the tx MinTpc
828 *
829 * @E.g: iwpriv wlan0 gtxMinTpc <value>
830 *
831 * Supported Feature: STA
832 *
833 * Usage: Internal/External
834 *
835 * </ioctl>
836 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837#define WE_SET_GTX_MINTPC 68
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530838/*
839 * <ioctl>
840 * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
841 *
842 * @INPUT: Mask value
843 *
844 * @OUTPUT: None
845 *
846 * This IOTCL used to set gtxBWMask
847 *
848 * @E.g: iwpriv wlan0 gtxBWMask <value>
849 *
850 * Supported Feature: STA
851 *
852 * Usage: Internal/External
853 *
854 * </ioctl>
855 */
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530856
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530857#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530858/*
859 * <ioctl>
860 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
861 *
862 * @INPUT: set_value
863 *
864 * @OUTPUT: None
865 *
866 * This IOCTL is used to set the MCC latency value in milliseconds
867 * during STA-P2P concurrency.
868 *
869 * If 0ms latency is provided, then FW will set to a default.
870 * Otherwise, latency must be at least 30ms.
871 *
872 * @E.g: iwpriv wlan0 setMccLatency 40
873 *
874 *
875 * Supported Feature: Concurrency
876 *
877 * Usage: Internal/External
878 *
879 * </ioctl>
880 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530882
883/*
884 * <ioctl>
885 * setMccQuota- Set the quota for P2P cases
886 *
887 * @INPUT: set_value [0,100]
888 *
889 * @OUTPUT: None
890 *
891 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
892 *
893 * Currently used to set time quota for 2 MCC vdevs/adapters using
894 * (operating channel, quota) for each mode.
895 * The info is provided run time using iwpriv command:
896 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
897 * Note: the quota provided in command is for the same mode in cmd.
898 * HDD checks if MCC mode is active, gets the second mode and its
899 * operating chan.
900 * Quota for the 2nd role is calculated as 100 - quota of first mode.
901 *
902 * @E.g: iwpriv wlan0 setMccQuota 50
903 * iwpriv p2p0 setMccQuota 50
904 *
905 * Supported Feature: Concurrency
906 *
907 * Usage: Internal/External
908 *
909 * </ioctl>
910 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911#define WE_MCC_CONFIG_QUOTA 71
912/* Private IOCTL for debug connection issues */
913#define WE_SET_DEBUG_LOG 72
914#ifdef WE_SET_TX_POWER
915#undef WE_SET_TX_POWER
916#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530917/*
918 * <ioctl>
919 * setTxPower - Set the current transmit power
920 *
921 * @INPUT: Transmission power in dBm
922 *
923 * @OUTPUT: None
924 *
925 * This IOCTL sets the current transmit power.
926 * This setting does not persist over reboots.
927 *
928 * @E.g: iwpriv wlan0 setTxPower 10
929 *
930 * Supported Feature: STA
931 *
932 * Usage: Internal/External
933 *
934 * </ioctl>
935 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936#define WE_SET_TX_POWER 74
937/* Private ioctl for earlyrx power save feature */
938#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
939#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
940#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
941#define WE_SET_EARLY_RX_SLOP_STEP 78
942#define WE_SET_EARLY_RX_INIT_SLOP 79
943#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530944/*
945 * <ioctl>
946 * setMcRate - Set the data rate for multicast data
947 *
948 * @INPUT: 1 to 32
949 *
950 * @OUTPUT: None
951 *
952 * This IOCTL sets the data rate for multicast data. Note that this command
953 * is allowed only in STA, IBSS, or QCMobileAP mode
954 *
955 * @E.g: iwpriv wlan0 setMcRate <value>
956 *
957 * Supported Feature: STA
958 *
959 * Usage: Internal/External
960 *
961 * </ioctl>
962 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963#define WE_SET_MC_RATE 81
964#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
965/* Private ioctl for packet power save */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530966/*
967 * <ioctl>
968 * 5g_ebt - Sets the 5g_ebt
969 *
970 * @INPUT: <value>
971 *
972 * @OUTPUT: None
973 *
974 * This IOTCL used to set 5g_ebt
975 *
976 * @E.g: iwpriv wlan0 5g_ebt <value>
977 *
978 * Supported Feature: STA
979 *
980 * Usage: Internal/External
981 *
982 * </ioctl>
983 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984#define WE_PPS_5G_EBT 83
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530985/*
986 * <ioctl>
987 * cts_cbw - Set CTS channel BW for dynamic BW adjustment
988 *
989 * @INPUT: 20 t0 160
990 *
991 * @OUTPUT: None
992 *
993 * This IOTCL used to set CTS channel BW for dynamic BW adjustment
994 *
995 * @E.g: iwpriv wlan0 cts_cbw <value>
996 *
997 * Supported Feature: STA
998 *
999 * Usage: Internal/External
1000 *
1001 * </ioctl>
1002 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003#define WE_SET_CTS_CBW 84
1004#define WE_DUMP_STATS 85
1005#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +05301006/* Private sub ioctl for starting/stopping the profiling */
1007#define WE_START_FW_PROFILE 87
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301008
Abhishek Singh3c507012016-12-01 11:15:42 +05301009/*
1010 * <ioctl>
1011 * setChanChange - Initiate channel change
1012 *
1013 * @INPUT: channel number to switch to.
1014 *
1015 * @OUTPUT: None
1016 *
1017 * This IOCTL is used to initiate a channel change.
1018 * If called on STA/CLI interface it will send the
1019 * ECSA action frame to the connected SAP/GO asking to
1020 * initiate the ECSA, if supported.
1021 * If called on SAP/GO interface it will initiate
1022 * ECSA and ask connected peers to move to new channel.
1023 *
1024 * @E.g: iwpriv wlan0 setChanChange <channel>
1025 * iwpriv wlan0 setChanChange 1
1026 *
1027 * Supported Feature: ECSA
1028 *
1029 * Usage: Internal/External
1030 *
1031 * </ioctl>
1032 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +05301033#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05301034#define WE_SET_CONC_SYSTEM_PREF 89
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08001035#define WE_SET_TXRX_STATS 90
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08001037/*
1038 * <ioctl>
1039 * set_11ax_rate - set 11ax rates to FW
1040 *
1041 * @INPUT: rate code
1042 *
1043 * @OUTPUT: None
1044 *
1045 * This IOCTL fixes the Tx data rate of 11AX.
1046 *
1047 * @E.g: iwpriv wlan0 set_11ax_rate <rate code>
1048 *
1049 * Supported Feature: STA/SAP
1050 *
1051 * Usage: Internal
1052 *
1053 * </ioctl>
1054 */
1055#define WE_SET_11AX_RATE 91
1056
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001057/*
1058 * <ioctl>
1059 * enable_dcm - enable Dual Carrier Modulation(DCM)
1060 *
1061 * @INPUT: 0/1
1062 *
1063 * @OUTPUT: None
1064 *
1065 * This IOCTL enables/disables DCM.
1066 *
1067 * @E.g: iwpriv wlan0 enable_dcm <0/1>
1068 *
1069 * Supported Feature: STA/SAP
1070 *
1071 * Usage: Internal
1072 *
1073 * </ioctl>
1074 */
1075#define WE_SET_DCM 92
1076
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001077/*
1078 * <ioctl>
1079 * enable_range_ext - enable Range extension
1080 *
1081 * @INPUT: 0/1
1082 *
1083 * @OUTPUT: None
1084 *
1085 * This IOCTL enables/disables Range extension.
1086 *
1087 * @E.g: iwpriv wlan0 enable_range_ext <0/1>
1088 *
1089 * Supported Feature: STA/SAP
1090 *
1091 * Usage: Internal
1092 *
1093 * </ioctl>
1094 */
1095#define WE_SET_RANGE_EXT 93
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001096
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301097/*
1098 * <ioctl>
1099 * wow_ito - sets the timeout value for inactivity data while
1100 * in power save mode during wow
1101 *
1102 * @INPUT: int
1103 *
1104 * @OUTPUT: None
1105 *
1106 * This IOCTL set the timeout value for inactivity data in power save mode
1107 *
1108 * @E.g: iwpriv wlan0 wow_ito 20
1109 *
1110 * Supported Feature: STA
1111 *
1112 * Usage: External
1113 *
1114 * </ioctl>
1115*/
1116#define WE_SET_WOW_DATA_INACTIVITY_TO 94
1117
1118
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119/* Private ioctls and their sub-ioctls */
1120#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
1121#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122#define WE_SET_SAP_CHANNELS 3
1123#define WE_GET_WLAN_DBG 4
1124#define WE_GET_MAX_ASSOC 6
1125/* 7 is unused */
1126#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +05301127
1128/*
1129 * <ioctl>
1130 * getconcurrency - Get concurrency mode
1131 *
1132 * @INPUT: None
1133 *
1134 * @OUTPUT: It shows concurrency value
1135 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
1136 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
1137 * 8:OCB 9:EPPING 10:QVIT 11:NDI
1138 *
1139 * This IOCTL is used to retrieve concurrency mode.
1140 *
1141 * @E.g: iwpriv wlan0 getconcurrency
1142 * wlan0 getconcurrency:5
1143 * Above value shows STA+P2P_Client
1144 *
1145 * Supported Feature: Concurrency
1146 *
1147 * Usage: Internal/External
1148 *
1149 * </ioctl>
1150 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151#define WE_GET_CONCURRENCY_MODE 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301152/*
1153 * <ioctl>
1154 * get_nss - Get the number of spatial STBC streams (NSS)
1155 *
1156 * @INPUT: None
1157 *
1158 * @OUTPUT: NSS
1159 * wlan0 get_nss:2
1160 *
1161 * This IOTCL used to get the number of spatial STBC streams
1162 *
1163 * @E.g: iwpriv wlan0 get_nss
1164 *
1165 * Supported Feature: STA
1166 *
1167 * Usage: Internal/External
1168 *
1169 * </ioctl>
1170 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171#define WE_GET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301172/*
1173 * <ioctl>
1174 * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1175 *
1176 * @INPUT: None
1177 *
1178 * @OUTPUT: ldpc
1179 * wlan0 get_ldpc:1
1180 *
1181 * This IOTCL used to gets the low density parity check (LDPC)
1182 *
1183 * @E.g: iwpriv wlan0 get_ldpc
1184 *
1185 * Supported Feature: STA
1186 *
1187 * Usage: Internal/External
1188 *
1189 * </ioctl>
1190 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191#define WE_GET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301192/*
1193 * <ioctl>
1194 * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1195 *
1196 * @INPUT: None
1197 *
1198 * @OUTPUT: TXSTBC
1199 * wlan0 get_tx_stbc:1
1200 *
1201 * This IOTCL get the value of the current Tx space time block code (STBC)
1202 *
1203 * @E.g: iwpriv wlan0 get_tx_stbc
1204 *
1205 * Supported Feature: STA
1206 *
1207 * Usage: Internal/External
1208 *
1209 * </ioctl>
1210 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211#define WE_GET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301212/*
1213 * <ioctl>
1214 * get_rx_stbc - Gets the value of the current Rx STBC
1215 *
1216 * @INPUT: None
1217 *
1218 * @OUTPUT: Rx STBC
1219 * wlan0 get_rx_stbc:1
1220 *
1221 * This IOTCL used to get the value of the current Rx STBC
1222 *
1223 * @E.g: iwpriv wlan0 get_rx_stbc
1224 *
1225 * Supported Feature: STA
1226 *
1227 * Usage: Internal/External
1228 *
1229 * </ioctl>
1230 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231#define WE_GET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301232/*
1233 * <ioctl>
1234 * get_shortgi - Get the value of the current short GI setting
1235 *
1236 * @INPUT: None
1237 *
1238 * @OUTPUT: Enable/disable of shortgi
1239 * wlan0 get_shortgi:1
1240 *
1241 * This IOCTL gets the value of the current short GI setting
1242 *
1243 * @E.g: iwpriv wlan0 get_shortgi
1244 *
1245 * Supported Feature: STA
1246 *
1247 * Usage: Internal/External
1248 *
1249 * </ioctl>
1250 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251#define WE_GET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301252/*
1253 * <ioctl>
1254 * get_rtscts - Get the value of the current RTS/CTS setting.
1255 *
1256 * @INPUT: None
1257 *
1258 * @OUTPUT: Enable/disable of RTS/CTS
1259 * wlan0 get_rtscts:33
1260 *
1261 * This IOTCL get the value of the current RTS/CTS setting.
1262 *
1263 * @E.g: iwpriv wlan0 get_rtscts
1264 *
1265 * Supported Feature: STA
1266 *
1267 * Usage: Internal/External
1268 *
1269 * </ioctl>
1270 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271#define WE_GET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301272/*
1273 * <ioctl>
1274 * get_chwidth - Get the current channel width setting
1275 *
1276 * @INPUT: None
1277 *
1278 * @OUTPUT: channel width
1279 * wlan0 get_chwidth:0
1280 *
1281 * This IOTCL get the current channel width setting.
1282 *
1283 * @E.g: iwpriv wlan0 get_chwidth
1284 *
1285 * Supported Feature: STA
1286 *
1287 * Usage: Internal/External
1288 *
1289 * </ioctl>
1290 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291#define WE_GET_CHWIDTH 17
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301292/*
1293 * <ioctl>
1294 * get_anienable - Get the anienable
1295 *
1296 * @INPUT: None
1297 *
1298 * @OUTPUT:
1299 * wlan0 get_anienable:0
1300 *
1301 * This IOTCL get the anienable
1302 *
1303 * @E.g: iwpriv wlan0 get_anienable
1304 *
1305 * Supported Feature: STA
1306 *
1307 * Usage: Internal/External
1308 *
1309 * </ioctl>
1310 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311#define WE_GET_ANI_EN_DIS 18
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301312/*
1313 * <ioctl>
1314 * get_aniplen - Get the aniplen
1315 *
1316 * @INPUT: None
1317 *
1318 * @OUTPUT:
1319 * wlan0 get_aniplen:0
1320 *
1321 * This IOTCL get the aniplen
1322 *
1323 * @E.g: iwpriv wlan0 get_aniplen
1324 *
1325 * Supported Feature: STA
1326 *
1327 * Usage: Internal/External
1328 *
1329 * </ioctl>
1330 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331#define WE_GET_ANI_POLL_PERIOD 19
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301332/*
1333 * <ioctl>
1334 * get_anilislen- Get the anilislen
1335 *
1336 * @INPUT: None
1337 *
1338 * @OUTPUT:
1339 * wlan0 get_anilislen:0
1340 *
1341 * This IOTCL used to get anilislen
1342 *
1343 * @E.g: iwpriv wlan0 get_anilislen
1344 *
1345 * Supported Feature: STA
1346 *
1347 * Usage: Internal/External
1348 *
1349 * </ioctl>
1350 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351#define WE_GET_ANI_LISTEN_PERIOD 20
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301352/*
1353 * <ioctl>
1354 * get_aniofdmlvl - Get the OFDM level
1355 *
1356 * @INPUT: None
1357 *
1358 * @OUTPUT: OFDM
1359 * wlan0 get_aniofdmlvl:0
1360 *
1361 * This IOTCL used to get ofdm level
1362 *
1363 * @E.g: iwpriv wlan0 get_aniofdmlvl
1364 *
1365 * Supported Feature: STA
1366 *
1367 * Usage: Internal/External
1368 *
1369 * </ioctl>
1370 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371#define WE_GET_ANI_OFDM_LEVEL 21
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301372/*
1373 * <ioctl>
1374 * get_aniccklvl - Get the cck level
1375 *
1376 * @INPUT: None
1377 *
1378 * @OUTPUT:
1379 * wlan0 get_aniccklvl:0
1380 *
1381 * This IOTCL used to get cck level
1382 *
1383 * @E.g: iwpriv wlan0 get_aniccklvl
1384 *
1385 * Supported Feature: STA
1386 *
1387 * Usage: Internal/External
1388 *
1389 * </ioctl>
1390 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001391#define WE_GET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301392/*
1393 * <ioctl>
1394 * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1395 *
1396 * @INPUT: None
1397 *
1398 * @OUTPUT: Enable/disable dynamic channel bandwidth
1399 * wlan0 get_cwmenable:0
1400 *
1401 * This IOTCL get the value of the dynamic channel bandwidth setting
1402 *
1403 * @E.g: iwpriv wlan0 get_cwmenable
1404 *
1405 * Supported Feature: STA
1406 *
1407 * Usage: Internal/External
1408 *
1409 * </ioctl>
1410 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411#define WE_GET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301412/*
1413 * <ioctl>
1414 * get_txchainmask - Get the txchainmask that was set
1415 *
1416 * @INPUT: None
1417 *
1418 * @OUTPUT: txchainmask
1419 * wlan0 get_txchainmask:1
1420 *
1421 * This IOCTL gets the txchainmask that was set
1422 * This command is useful if it was previously set
1423 *
1424 * @E.g: iwpriv wlan0 get_txchainmask
1425 *
1426 * Supported Feature: STA
1427 *
1428 * Usage: Internal/External
1429 *
1430 * </ioctl>
1431 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432#define WE_GET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301433/*
1434 * <ioctl>
1435 * get_rxchainmask - Get the rxchainmask that was set
1436 *
1437 * @INPUT: None
1438 *
1439 * @OUTPUT: rxchainmask
1440 * wlan0 get_rxchainmask:1
1441 *
1442 * This IOCTL gets the rxchainmask that was set
1443 * This command is useful only if it was previously set.
1444 *
1445 * @E.g: iwpriv wlan0 get_rxchainmask
1446 *
1447 * Supported Feature: STA
1448 *
1449 * Usage: Internal/External
1450 *
1451 * </ioctl>
1452 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453#define WE_GET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301454/*
1455 * <ioctl>
1456 * get_11nrate - Get the fixed Tx data rate
1457 *
1458 * @INPUT: None
1459 *
1460 * @OUTPUT: Using this command does not return the same value as set
1461 * wlan0 get_11nrate:0
1462 *
1463 * This IOCTL gets the fixed Tx data rate
1464 * This command is useful only if setting the fixed Tx rate.
1465 *
1466 * @E.g: iwpriv wlan0 get_11nrate
1467 *
1468 * Supported Feature: STA
1469 *
1470 * Usage: Internal/External
1471 *
1472 * </ioctl>
1473 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474#define WE_GET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301475/*
1476 * <ioctl>
1477 * get_ampdu - Get the maximum subframe of ampdu
1478 *
1479 * @INPUT: None
1480 *
1481 * @OUTPUT: Maximum subframe of ampdu
1482 * wlan0 get_ampdu:1
1483 *
1484 * This IOCTL gets the maximum subframe of ampdu
1485 * This command is useful only if setting ampdu.
1486 *
1487 * @E.g: iwpriv wlan0 get_ampdu
1488 *
1489 * Supported Feature: STA
1490 *
1491 * Usage: Internal/External
1492 *
1493 * </ioctl>
1494 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495#define WE_GET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301496/*
1497 * <ioctl>
1498 * get_amsdu - Get the maximum subframe of amsdu
1499 *
1500 * @INPUT: None
1501 *
1502 * @OUTPUT: Maximum subframe of amsdu
1503 * wlan0 get_amsdu:1
1504 *
1505 * This IOCTL gets the maximum subframe of amsdu.
1506 * This command is useful only if setting amsdu
1507 *
1508 * @E.g: iwpriv wlan0 get_amsdu
1509 *
1510 * Supported Feature: STA
1511 *
1512 * Usage: Internal/External
1513 *
1514 * </ioctl>
1515 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516#define WE_GET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301517/*
1518 * <ioctl>
1519 * get_txpow2g - Get the current 2 GHz Tx power setting
1520 *
1521 * @INPUT: None
1522 *
1523 * @OUTPUT: Tx Power in dbm
1524 * wlan0 get_txpow2g:0
1525 *
1526 * This IOCTL gets the current 2 GHz Tx power setting
1527 * This command is useful if setting Tx power
1528 *
1529 * @E.g: iwpriv wlan0 get_txpow2g
1530 *
1531 * Supported Feature: STA
1532 *
1533 * Usage: Internal/External
1534 *
1535 * </ioctl>
1536 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537#define WE_GET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301538/*
1539 * <ioctl>
1540 * get_txpow5g - Get the current 5 GHz Tx power setting
1541 *
1542 * @INPUT: None
1543 *
1544 * @OUTPUT: Tx Power in dbm
1545 * wlan0 get_txpow5g:0
1546 *
1547 * This IOCTL gets the current 5 GHz Tx power setting
1548 * This command is useful if setting Tx power
1549 *
1550 * @E.g: iwpriv wlan0 get_txpow5g
1551 *
1552 * Supported Feature: STA
1553 *
1554 * Usage: Internal/External
1555 *
1556 * </ioctl>
1557 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -08001559/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560#define WE_GET_PPS_PAID_MATCH 32
1561#define WE_GET_PPS_GID_MATCH 33
1562#define WE_GET_PPS_EARLY_TIM_CLEAR 34
1563#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
1564#define WE_GET_PPS_EOF_PAD_DELIM 36
1565#define WE_GET_PPS_MACADDR_MISMATCH 37
1566#define WE_GET_PPS_DELIM_CRC_FAIL 38
1567#define WE_GET_PPS_GID_NSTS_ZERO 39
1568#define WE_GET_PPS_RSSI_CHECK 40
1569/* Private ioctl for QPower */
1570#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
1571#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
1572#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
1573#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301574/*
1575 * <ioctl>
1576 * get_burst_en - Enables or disables the burst feature
1577 *
1578 * @INPUT: None
1579 *
1580 * @OUTPUT: Enable/disable of burst feature
1581 * wlan0 get_burst_en:1
1582 *
1583 * This IOCTL enables or disables the burst feature
1584 *
1585 * @E.g: iwpriv wlan0 get_burst_en
1586 *
1587 * Supported Feature:STA
1588 *
1589 * Usage: Internal/External
1590 *
1591 * </ioctl>
1592 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593#define WE_GET_BURST_ENABLE 45
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301594/*
1595 * <ioctl>
1596 * get_burst_dur - Get the burst duration
1597 *
1598 * @INPUT: None
1599 *
1600 * @OUTPUT: Duration in microseconds
1601 * wlan0 get_burst_dur:8160
1602 *
1603 * This IOCTL gets the burst duration
1604 * This command is useful if setting burst enable
1605 *
1606 * @E.g: iwpriv wlan0 get_burst_dur
1607 *
1608 * Supported Feature: STA
1609 *
1610 * Usage: Internal/External
1611 *
1612 * </ioctl>
1613 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614#define WE_GET_BURST_DUR 46
1615/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301616/*
1617 * <ioctl>
1618 * get_gtxHTMcs - Get the tx HTM
1619 *
1620 * @INPUT: None
1621 *
1622 * @OUTPUT: HTM
1623 * wlan0 get_gtxHTMcs:32896
1624 *
1625 * This IOTCL used to get HTM
1626 *
1627 * @E.g: iwpriv wlan0 get_gtxHTMcs
1628 *
1629 * Supported Feature: STA
1630 *
1631 * Usage: Internal/External
1632 *
1633 * </ioctl>
1634 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635#define WE_GET_GTX_HT_MCS 47
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301636/*
1637 * <ioctl>
1638 * get_gtxVHTMcs - Get the VHTM
1639 *
1640 * @INPUT: None
1641 *
1642 * @OUTPUT: VHTM
1643 * wlan0 get_gtxVHTMcs:524800
1644 *
1645 * This IOTCL used to get the VHTM
1646 *
1647 * @E.g: iwpriv wlan0 get_gtxVHTMcs
1648 *
1649 * Supported Feature: STA
1650 *
1651 * Usage: Internal/External
1652 *
1653 * </ioctl>
1654 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655#define WE_GET_GTX_VHT_MCS 48
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301656/*
1657 * <ioctl>
1658 * get_gtxUsrCfg - Get the tx cfg
1659 *
1660 * @INPUT: None
1661 *
1662 * @OUTPUT: TXCFG
1663 * wlan0 get_gtxUsrCfg:32
1664 *
1665 * This IOTCL used to get the tx cfg
1666 *
1667 * @E.g: iwpriv wlan0 get_gtxUsrCfg
1668 *
1669 * Supported Feature: STA
1670 *
1671 * Usage: Internal/External
1672 *
1673 * </ioctl>
1674 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675#define WE_GET_GTX_USRCFG 49
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301676/*
1677 * <ioctl>
1678 * get_gtxThre - Get the tx threshold
1679 *
1680 * @INPUT: None
1681 *
1682 * @OUTPUT: Threshold
1683 * wlan0 get_gtxThre:3
1684 *
1685 * This IOCTL is used to get tx threshold
1686 *
1687 * @E.g: iwpriv wlan0 get_gtxThre
1688 *
1689 * Supported Feature: STA
1690 *
1691 * Usage: Internal/External
1692 *
1693 * </ioctl>
1694 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695#define WE_GET_GTX_THRE 50
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301696/*
1697 * <ioctl>
1698 * get_gtxMargin - Get the tx margin
1699 *
1700 * @INPUT: None
1701 *
1702 * @OUTPUT: GTXMARGIN
1703 * wlan0 get_gtxMargin:2
1704 *
1705 * This IOCTL is used to set tx margin
1706 *
1707 * @E.g: iwpriv wlan0 get_gtxMargin
1708 *
1709 * Supported Feature: STA
1710 *
1711 * Usage: Internal/External
1712 *
1713 * </ioctl>
1714 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715#define WE_GET_GTX_MARGIN 51
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301716/*
1717 * <ioctl>
1718 * get_gtxStep - Get the tx step
1719 *
1720 * @INPUT: None
1721 *
1722 * @OUTPUT: GTXSTEP
1723 * wlan0 get_gtxStep:0
1724 *
1725 * This IOCTL is used to get the gtx step
1726 *
1727 * @E.g: iwpriv wlan0 get_gtxStep
1728 *
1729 * Supported Feature: STA
1730 *
1731 * Usage: Internal/External
1732 *
1733 * </ioctl>
1734 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735#define WE_GET_GTX_STEP 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301736/*
1737 * <ioctl>
1738 * get_gtxMinTpc - Get the tx miminum tpc
1739 *
1740 * @INPUT: None
1741 *
1742 * @OUTPUT: TPC
1743 * wlan0 get_gtxMinTpc:0
1744 *
1745 * This IOCTL is used to get tx miminum tpc
1746 *
1747 * @E.g: iwpriv wlan0 get_gtxMinTpc
1748 *
1749 * Supported Feature: STA
1750 *
1751 * Usage: Internal/External
1752 *
1753 * </ioctl>
1754 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755#define WE_GET_GTX_MINTPC 53
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301756/*
1757 * <ioctl>
1758 * get_gtxBWMask - Get the tx BW MASK
1759 *
1760 * @INPUT: None
1761 *
1762 * @OUTPUT: MASK
1763 * wlan0 get_gtxBWMask:15
1764 *
1765 * This IOCTL is used get gtx bw mask
1766 *
1767 * @E.g: iwpriv wlan0 get_gtxBWMask
1768 *
1769 * Supported Feature: STA
1770 *
1771 * Usage: Internal/External
1772 *
1773 * </ioctl>
1774 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775#define WE_GET_GTX_BWMASK 54
1776#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001777#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07001778#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001780/*
1781 * <ioctl>
1782 * get_dcm - Get dcm enablement value
1783 *
1784 * @INPUT: None
1785 *
1786 * @OUTPUT: 0/1
1787 * wlan0 get_dcm
1788 *
1789 * This IOCTL is used get dcm value
1790 *
1791 * Supported Feature: STA/SAP
1792 *
1793 * Usage: Internal
1794 *
1795 * </ioctl>
1796 */
1797#define WE_GET_DCM 60
1798
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001799/*
1800 * <ioctl>
1801 * get_dcm - Get range extension enablement value
1802 *
1803 * @INPUT: None
1804 *
1805 * @OUTPUT: 0/1
1806 * wlan0 get_range_ext
1807 *
1808 * This IOCTL is used get range_extension value
1809 *
1810 * Supported Feature: STA/SAP
1811 *
1812 * Usage: Internal
1813 *
1814 * </ioctl>
1815 */
1816#define WE_GET_RANGE_EXT 61
1817
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818/* Private ioctls and their sub-ioctls */
1819#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
1820
1821/* Private ioctls and their sub-ioctls */
1822#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
1823#define WE_WOWL_ADD_PTRN 1
1824#define WE_WOWL_DEL_PTRN 2
Sreelakshmi Konamkided64d72017-02-23 10:39:26 +05301825/*
1826 * <ioctl>
1827 * neighbor - Send neighbor report request
1828 *
1829 * @INPUT: string
1830 *
1831 * @OUTPUT: None
1832 *
1833 * This IOCTL create a Neighbor report request and send it to peer
1834 *
1835 * @E.g: iwpriv wlan0 neighbor "SSID"
1836 *
1837 * Supported Feature: 11k
1838 *
1839 * Usage: Internal/External
1840 *
1841 * </ioctl>
1842 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843#define WE_NEIGHBOR_REPORT_REQUEST 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301844/*
1845 * <ioctl>
1846 * set_ap_wps_ie - Set the P2P IE of the probe response
1847 *
1848 * @INPUT: string
1849 *
1850 * @OUTPUT: None
1851 *
1852 * This IOCTL sets the P2P IE of the probe response
1853 *
1854 * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1855 *
1856 * Supported Feature: STA
1857 *
1858 * Usage: Internal/External
1859 *
1860 * </ioctl>
1861 */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07001862#define WE_SET_AP_WPS_IE 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863#define WE_SET_CONFIG 5
1864
1865/* Private ioctls and their sub-ioctls */
1866#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
1867#define WE_SET_WLAN_DBG 1
1868#define WE_SET_DP_TRACE 2
1869#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05301870#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871
1872/* Private ioctls and their sub-ioctls */
1873#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
1874#define WE_WLAN_VERSION 1
1875#define WE_GET_STATS 2
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301876/*
1877 * <ioctl>
1878 * getConfig - gets the values of all configurations listed in WCNSS
1879 *
1880 * @INPUT: None
1881 *
1882 * @OUTPUT: Current configuration to the sys log
1883 * wlan0 getConfig: WLAN configuration written to system log
1884 *
1885 * This IOCTL gets the values of all configurations listed in WCNSS
1886 *
1887 * @E.g: iwpriv wlan0 getConfig
1888 *
1889 * Supported Feature: STA
1890 *
1891 * Usage: Internal/External
1892 *
1893 * </ioctl>
1894 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895#define WE_GET_CFG 3
1896#define WE_GET_WMM_STATUS 4
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301897/*
1898 * <ioctl>
1899 * getChannelList - Get the available channel list while in QCMobileAP
1900 *
1901 * @INPUT: None
1902 *
1903 * @OUTPUT: Channel list
1904 * wlan0 getChannelList:36 US 1..165
1905 *
1906 * This IOCTL gets the available channel list while in QCMobileAP
1907 *
1908 * @E.g: iwpriv wlan0 getChannelList
1909 *
1910 * Supported Feature: STA
1911 *
1912 * Usage: Internal/External
1913 *
1914 * </ioctl>
1915 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916#define WE_GET_CHANNEL_LIST 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301917/*
1918 * <ioctl>
1919 * getRSSI - Get the Received Signal Strength Indicator
1920 *
1921 * @INPUT: None
1922 *
1923 * @OUTPUT: RSSI
1924 * wlan0 getRSSI:rsssi=-32
1925 *
1926 * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1927 *
1928 * @E.g: iwpriv wlan0 getRSSI
1929 *
1930 * Supported Feature: STA
1931 *
1932 * Usage: Internal/External
1933 *
1934 * </ioctl>
1935 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -08001937
1938/*
1939 * <ioctl>
1940 * getSuspendStats - Get suspend/resume stats
1941 *
1942 * @INPUT: None
1943 *
1944 * @OUTPUT: character string containing formatted suspend/resume stats
1945 *
1946 * This ioctl is used to get suspend/resume stats formatted for display.
1947 * Currently it includes suspend/resume counts, wow wake up reasons, and
1948 * suspend fail reasons.
1949 *
1950 * @E.g: iwpriv wlan0 getSuspendStats
1951 * iwpriv wlan0 getSuspendStats
1952 *
1953 * Supported Feature: suspend/resume
1954 *
1955 * Usage: Internal
1956 *
1957 * </ioctl>
1958 */
1959#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05301961/*
1962 * <ioctl>
1963 * getTdlsPeers - Get all TDLS peers.
1964 *
1965 * @INPUT: None
1966 *
1967 * @OUTPUT: Returns the MAC address of all the TDLS peers
1968 * wlan0 getTdlsPeers:
1969 * MAC Id cap up RSSI
1970 * ---------------------------------
1971 * 00:0a:f5:0e:bd:18 2 Y Y -44
1972 * 00:0a:f5:bf:0e:12 0 N N 0
1973 *
1974 * This IOCTL is used to get all TDLS peers.
1975 *
1976 * @E.g: iwpriv wlan0 getTdlsPeers
1977 *
1978 * Supported Feature: TDLS
1979 *
1980 * Usage: Internal/External
1981 *
1982 * </ioctl>
1983 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984#define WE_GET_TDLS_PEERS 8
1985#endif
1986#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +05301987/*
1988 * <ioctl>
1989 * getPMFInfo - get the PMF info of the connected session
1990 *
1991 * @INPUT: None
1992 *
1993 * @OUTPUT:
1994 * wlan0 getPMFInfo:
1995 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
1996 * Number of Unprotected Disassocs 0
1997 * Number of Unprotected Deauths 0
1998 *
1999 * This IOCTL is used to get the PMF stats/status of the current
2000 * connection.
2001 *
2002 * @e.g:iwpriv wlan0 getPMFInfo
2003 *
2004 * Supported Feature: PMF
2005 *
2006 * Usage: Internal/External
2007 *
2008 * </ioctl>
2009 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010#define WE_GET_11W_INFO 9
2011#endif
2012#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +05302013/*
2014 * <ioctl>
2015 * getIbssSTAs - get ibss sta info
2016 *
2017 * @INPUT: None
2018 *
2019 * @OUTPUT: Give the MAC of the IBSS STA
2020 * wlan0 getIbssSTAs:
2021 * 1 .8c:fd:f0:01:9c:bf
2022 *
2023 * This IOCTL is used to get ibss sta info
2024 *
2025 * @E.g: iwpriv wlan0 getIbssSTAs
2026 *
2027 * Supported Feature: IBSS
2028 *
2029 * Usage: Internal/External
2030 *
2031 * </ioctl>
2032 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002033#define WE_GET_IBSS_STA_INFO 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302034/*
2035 * <ioctl>
2036 * getphymode - Get the current phymode.
2037 *
2038 * @INPUT: None
2039 *
2040 * @OUTPUT: In phymode
2041 * wlan0 getphymode:AUTO MODE
2042 *
2043 * This IOCTL used to gets the current phymode.
2044 *
2045 * @E.g: iwpriv wlan0 getphymode
2046 *
2047 * Supported Feature: STA
2048 *
2049 * Usage: Internal/External
2050 *
2051 * </ioctl>
2052 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053#define WE_GET_PHYMODE 12
Naveen Rawat910726a2017-03-06 11:42:51 -08002054
2055/*
2056 * <ioctl>
2057 * getOemDataCap - Get the oem data caps.
2058 *
2059 * @INPUT: None
2060 *
2061 * @OUTPUT: oem data capability
2062 *
2063 * This IOCTL used to gets the current oem data cap.
2064 *
2065 * @E.g: iwpriv wlan0 getOemDataCap
2066 *
2067 * Usage: Internal/External
2068 *
2069 * </ioctl>
2070 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071#define WE_GET_OEM_DATA_CAP 13
Naveen Rawat910726a2017-03-06 11:42:51 -08002072
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302073/*
2074 * <ioctl>
2075 * getSNR - Enable SNR Monitoring
2076 *
2077 * @INPUT: None
2078 *
2079 * @OUTPUT: Signal strength/ratio
2080 * wlan0 getSNR:1
2081 *
2082 * This IOCTL is used to get ibss sta info
2083 *
2084 * @E.g: iwpriv wlan0 getSNR
2085 *
2086 * Supported Feature: STA
2087 *
2088 * Usage: Internal/External
2089 *
2090 * </ioctl>
2091 */
Naveen Rawat910726a2017-03-06 11:42:51 -08002092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +05302094#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095
2096/* Private ioctls and their sub-ioctls */
2097#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
Selvaraj, Sridharf7939832017-03-25 16:59:50 +05302098
2099/*
2100 * <ioctl>
2101 * reassoc - Trigger STA re-association to the connected AP
2102 *
2103 * @INPUT: None
2104 *
2105 * @OUTPUT: None
2106 *
2107 * This IOCTL is used to trigger STA reassociation to the connected AP.
2108 *
2109 * @E.g: iwpriv wlan0 reassoc
2110 *
2111 * Supported Feature: Roaming
2112 *
2113 * Usage: Internal
2114 *
2115 * </ioctl>
2116 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +05302118/*
2119 * <ioctl>
2120 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
2121 *
2122 * @INPUT: None
2123 *
2124 * @OUTPUT: print ibss peer in info logs
2125 * pPeerInfo->numIBSSPeers = 1
2126 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2127 *
2128 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
2129 * in info logs
2130 *
2131 * @E.g: iwpriv wlan0 ibssPeerInfoAll
2132 *
2133 * Supported Feature: IBSS
2134 *
2135 * Usage: Internal/External
2136 *
2137 * </ioctl>
2138 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002139#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -08002140/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002142#define WE_GET_FW_PROFILE_DATA 18
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +05302143/*
2144 * <ioctl>
2145 * stop_obss_scan - Stop obss scan
2146 *
2147 * @INPUT: None
2148 *
2149 * @OUTPUT: None
2150 *
2151 * This IOCTL is used to stop obss scan
2152 *
2153 * @E.g: iwpriv wlan0 stop_obss_scan
2154 *
2155 * Supported Feature: Scan
2156 *
2157 * Usage: Internal/External
2158 *
2159 * </ioctl>
2160 */
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002161#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002162
2163/* Private ioctls and their sub-ioctls */
2164#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
2165
2166#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +05302167/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168
Manjeet Singhf82ed072016-07-08 11:40:00 +05302169#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170
2171#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302172/*
2173 * <ioctl>
2174 * setTdlsConfig - Set TDLS configuration parameters.
2175 *
2176 * @INPUT: 11 TDLS configuration parameters
2177 * @args[0]: tdls: [0..2]
2178 * @args[1]: tx_period_t: [1000..4294967295UL]
2179 * @args[2]: tx_packet_n: [0..4294967295UL]
2180 * @args[3]: [discovery_period is not used anymore]
2181 * @args[4]: discovery_tries_n: [1..100]
2182 * @args[5]: [idle_timeout is not used anymore]
2183 * @args[6]: idle_packet_n: [0..40000]
2184 * @args[7]: [rssi_hysteresis is not used anymore]
2185 * @args[8]: rssi_trigger_threshold: [-120..0]
2186 * @args[9]: rssi_teardown_threshold: [-120..0]
2187 * @args[10]: rssi_delta: [-30..0]
2188 *
2189 * @OUTPUT: None
2190 *
2191 * This IOCTL is used to set the TDLS configuration parameters.
2192 *
2193 * @E.g: iwpriv wlan0 setTdlsConfig tdls tx_period_t tx_packet_n
2194 * discovery_period discovery_tries_n idle_timeout
2195 * idle_packet_n rssi_hysteresis rssi_trigger_threshold
2196 * rssi_teardown_threshold rssi_delta
2197 * iwpriv wlan0 setTdlsConfig 1 1500 40 1 5 1 5 0 -70 -70 -10
2198 *
2199 * Supported Feature: TDLS
2200 *
2201 * Usage: Internal/External
2202 *
2203 * </ioctl>
2204 */
2205
2206
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207#define WE_TDLS_CONFIG_PARAMS 5
2208#endif
Abhishek Singh49b654e2016-12-01 16:11:17 +05302209/*
2210 * <ioctl>
2211 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
2212 *
2213 * @INPUT: staid
2214 *
2215 * @OUTPUT: print ibss peer corresponding to staid in info logs
2216 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2217 *
2218 * This IOCTL is used to print the specific ibss peers's MAC,
2219 * rate and RSSI in info logs
2220 *
2221 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
2222 * iwpriv wlan0 ibssPeerInfo 0
2223 *
2224 * Supported Feature: IBSS
2225 *
2226 * Usage: Internal/External
2227 *
2228 * </ioctl>
2229 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002230#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231#define WE_UNIT_TEST_CMD 7
2232
2233#define WE_MTRACE_DUMP_CMD 8
2234#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
2235
2236
2237#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2238#define WE_LED_FLASHING_PARAM 10
2239#endif
2240
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302241/*
2242 * <ioctl>
2243 * pm_clist - Increments the index value of the concurrent connection list
2244 * and update with the input parameters provided.
2245 *
2246 * @INPUT: Following 8 arguments:
2247 * @vdev_id: vdev id
2248 * @tx_streams: TX streams
2249 * @rx_streams: RX streams
2250 * @chain_mask: Chain mask
2251 * @type: vdev_type
2252 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2253 * @sub_type: vdev_subtype
2254 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2255 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2256 * @channel: Channel
2257 * @mac: Mac id
2258 *
2259 * @OUTPUT: None
2260 *
2261 * This IOCTL is used to increments the index value of the concurrent connection
2262 * list and update with the input parameters provided.
2263 *
2264 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
2265 * sub_type channel mac
2266 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 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_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302275
2276/*
2277 * <ioctl>
2278 * pm_dlist - Delete the index from the concurrent connection list that is
2279 * present in the given vdev_id.
2280 *
2281 * @INPUT: delete_all, vdev_id
2282 * @delete_all: delete all indices
2283 * @vdev_id: vdev id
2284 *
2285 * @OUTPUT: None
2286 *
2287 * This IOCTL is used to delete the index from the concurrent connection list
2288 * that is present in the given vdev_id.
2289 *
2290 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
2291 * iwpriv wlan0 pm_dlist 0 1
2292 *
2293 * Supported Feature: DBS
2294 *
2295 * Usage: Internal/External
2296 *
2297 * </ioctl>
2298 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302300
2301/*
2302 * <ioctl>
2303 * pm_dbs - Set dbs capability and system preference
2304 *
2305 * @INPUT: dbs, system_pref
2306 * @dbs: Value of DBS capability to be set
2307 * @system_pref: System preference
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002308 * 0:PM_THROUGHPUT 1: PM_POWERSAVE 2: PM_LATENCY
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302309 *
2310 * @OUTPUT: None
2311 *
2312 * This IOCTL is used to set dbs capability and system preference.
2313 *
2314 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
2315 * iwpriv wlan0 pm_dbs 1 0
2316 *
2317 * Supported Feature: DBS
2318 *
2319 * Usage: Internal/External
2320 *
2321 * </ioctl>
2322 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302324
2325/*
2326 * <ioctl>
2327 * pm_pcl - Set pcl for concurrency mode.
2328 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002329 * @INPUT: policy_mgr_con_mode
2330 * @policy_mgr_con_mode: concurrency mode for PCL table
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302331 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2332 *
2333 * @OUTPUT: None
2334 *
2335 * This IOCTL is used to set pcl for concurrency mode.
2336 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002337 * @E.g: iwpriv wlan0 pm_pcl policy_mgr_con_mode
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302338 * iwpriv wlan0 pm_pcl 0
2339 *
2340 * Supported Feature: DBS
2341 *
2342 * Usage: Internal/External
2343 *
2344 * </ioctl>
2345 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302347
2348/*
2349 * <ioctl>
2350 * pm_cinfo - Shows the concurrent connection list.
2351 *
2352 * @INPUT: None
2353 *
2354 * @OUTPUT: None
2355 *
2356 * This IOCTL is used to show the concurrent connection list.
2357 *
2358 * @E.g: iwpriv wlan0 pm_cinfo
2359 *
2360 * Supported Feature: DBS
2361 *
2362 * Usage: Internal/External
2363 *
2364 * </ioctl>
2365 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302367
2368/*
2369 * <ioctl>
2370 * pm_ulist - Updates the index value of the concurrent connection list
2371 * with the input parameters provided.
2372 *
2373 * @INPUT: Following 8 arguments:
2374 * @vdev_id: vdev id
2375 * @tx_streams: TX streams
2376 * @rx_streams: RX streams
2377 * @chain_mask: Chain mask
2378 * @type: vdev_type
2379 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2380 * @sub_type: vdev_subtype
2381 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2382 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2383 * @channel: Channel
2384 * @mac: Mac id
2385 *
2386 * @OUTPUT: None
2387 *
2388 * This IOCTL is used to updates the index value of the concurrent
2389 * connection list with the input parameters provided.
2390 *
2391 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
2392 * sub_type channel mac
2393 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
2394 *
2395 * Supported Feature: DBS
2396 *
2397 * Usage: Internal/External
2398 *
2399 * </ioctl>
2400 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302402
2403/*
2404 * <ioctl>
2405 * pm_query_action - Initiate actions needed on current connections as
2406 * per the channel provided.
2407 *
2408 * @INPUT: channel
2409 * @channel: Channel on which new connection will be.
2410 *
2411 * @OUTPUT: None
2412 *
2413 * This IOCTL is used to initiate actions needed on current connections
2414 * as per the channel provided.
2415 *
2416 * @E.g: iwpriv wlan0 pm_query_action channel
2417 * iwpriv wlan0 pm_query_action 6
2418 *
2419 * Supported Feature: DBS
2420 *
2421 * Usage: Internal/External
2422 *
2423 * </ioctl>
2424 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425#define WE_POLICY_MANAGER_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302426
2427/*
2428 * <ioctl>
2429 * pm_query_allow - Checks for allowed concurrency combination
2430 *
2431 * @INPUT: mode, channel, bandwidth
2432 * @mode: new connection mode
2433 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2434 * @channel: channel on which new connection is coming up
2435 * @bandwidth: Bandwidth requested by the connection
2436 * 0:None 1:5MHz 2:10MHz 3:20MHz
2437 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
2438 *
2439 * @OUTPUT: None
2440 *
2441 * This IOCTL is used to checks for allowed concurrency combination.
2442 *
2443 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
2444 * iwpriv wlan0 pm_query_allow 0 6 4
2445 *
2446 * Supported Feature: DBS
2447 *
2448 * Usage: Internal/External
2449 *
2450 * </ioctl>
2451 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302453
2454/*
2455 * <ioctl>
2456 * pm_run_scenario - Create scenario with number of connections provided.
2457 *
2458 * @INPUT: num_of_conn
2459 * @num_of_conn: the number of connections (values: 1~3)
2460 *
2461 * @OUTPUT: None
2462 *
2463 * This IOCTL is used to create scenario with the number of connections
2464 * provided.
2465 *
2466 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
2467 * iwpriv wlan0 pm_run_scenario 1
2468 *
2469 * Supported Feature: DBS
2470 *
2471 * Usage: Internal/External
2472 *
2473 * </ioctl>
2474 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302476
2477/*
2478 * <ioctl>
2479 * pm_set_hw_mode - Set hardware for single/dual mac.
2480 *
2481 * @INPUT: hw_mode
2482 * 0:single mac 1:dual mac
2483 *
2484 * @OUTPUT: None
2485 *
2486 * This IOCTL is used to set hardware for single/dual mac.
2487 *
2488 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
2489 * iwpriv wlan0 pm_set_hw_mode 1
2490 *
2491 * Supported Feature: DBS
2492 *
2493 * Usage: Internal/External
2494 *
2495 * </ioctl>
2496 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497#define WE_POLICY_SET_HW_MODE_CMD 20
2498
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302499/*
2500 * <ioctl>
2501 * set_scan_cfg - Set dual MAC scan config parameters.
2502 *
2503 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2504 * @dbs: Value of DBS bit
2505 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2506 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2507 *
2508 * @OUTPUT: None
2509 *
2510 * This IOCTL is used to set the dual MAC scan config.
2511 *
2512 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2513 * single_mac_scan_with_dbs
2514 * iwpriv wlan0 set_scan_cfg 1 0 1
2515 *
2516 * Supported Feature: DBS
2517 *
2518 * Usage: Internal/External
2519 *
2520 * </ioctl>
2521 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302523
2524/*
2525 * <ioctl>
2526 * set_fw_mode_cfg - Sets the dual mac FW mode config
2527 *
2528 * @INPUT: dbs, dfs
2529 * @dbs: DBS bit
2530 * @dfs: Agile DFS bit
2531 *
2532 * @OUTPUT: None
2533 *
2534 * This IOCTL is used to set the dual mac FW mode config.
2535 *
2536 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2537 * iwpriv wlan0 set_fw_mode_cfg 1 1
2538 *
2539 * Supported Feature: DBS
2540 *
2541 * Usage: Internal/External
2542 *
2543 * </ioctl>
2544 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07002546#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547
2548#ifdef FEATURE_WLAN_TDLS
2549#undef MAX_VAR_ARGS
2550#define MAX_VAR_ARGS 11
2551#else
2552#undef MAX_VAR_ARGS
2553#define MAX_VAR_ARGS 9
2554#endif
2555
Jeff Johnson6fa1e012017-04-05 06:40:53 -07002556/*
2557 * <ioctl>
2558 * fips_test - Perform a FIPS test
2559 *
2560 * @INPUT: Binary representation of the following packed structure
2561 *
2562 * @OUTPUT: Binary representation of the following packed structure
2563 *
2564 * This IOCTL is used to perform FIPS certification testing
2565 *
2566 * @E.g: iwpriv wlan0 fips_test <test vector>
2567 *
2568 * iwpriv wlan0 fips_test <tbd>
2569 *
2570 * Supported Feature: FIPS
2571 *
2572 * Usage: Internal
2573 *
2574 * </ioctl>
2575 */
2576#define WLAN_PRIV_FIPS_TEST (SIOCIWFIRSTPRIV + 8)
2577
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578/* Private ioctls (with no sub-ioctls) */
2579/* note that they must be odd so that they have "get" semantics */
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302580/*
2581 * <ioctl>
2582 * addTspec - Add TSPEC for each AC
2583 *
2584 * @INPUT: 19 TSPEC params
2585 * @[arg0]: handle
2586 * @[arg1]: tid
2587 * @[arg2]: dir
2588 * @[arg3]: psb
2589 * @[arg4]: up
2590 * @[arg5]: nomMsduSize
2591 * @[arg6]: maxMsduSize
2592 * @[arg7]: minDataRate
2593 * @[arg8]: meanDataRate
2594 * @[arg9]: peakDataRate
2595 * @[arg10]: maxBurstSize
2596 * @[arg11]: minPhyRate
2597 * @[arg12]: sba
2598 * @[arg13]: minServiceIntv
2599 * @[arg14]: suspendIntv
2600 * @[arg15]: burstSizeDefn
2601 * @[arg16]: ackPolicy
2602 * @[arg17]: inactivityPeriod
2603 * @[arg18]: maxServiceIntv
2604 *
2605 * @OUTPUT: Success/Failure
2606 *
2607 * This IOCTL is used to add TSPEC for each AC.
2608 *
2609 * @E.g: iwpriv wlan0 addTspec <handle> <tid> <dir> <psb> <up> <nomMsduSize>
2610 * <maxMsduSize> <minDataRate> <meanDataRate>
2611 * <peakDataRate> <maxBurstSize> <minPhyRate>
2612 * <sba> <minServiceIntv> <suspendIntv>
2613 * <burstSizeDefn> <ackPolicy> <inactivityPeriod>
2614 * <maxServiceIntv>
2615 * iwpriv wlan0 addTspec 7001 6 2 1 6 0x80D0 0x80D0 0x14500 0x14500 0x14500
2616 * 0 0x5B8D80 0x2001 20 2000 0 0 0 2000
2617 * wlan0 addTspec:3
2618 *
2619 * Supported Feature: WMM
2620 *
2621 * Usage: Internal/External
2622 *
2623 * </ioctl>
2624 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302626/*
2627 * <ioctl>
2628 * delTspec - Delete TSPEC entry for each AC
2629 *
2630 * @INPUT: 1 TSPEC param
2631 * @[arg0]: handle
2632 *
2633 * @OUTPUT: Success/Failure
2634 *
2635 * This IOCTL is used to delete TSPEC entry for each AC.
2636 *
2637 * @E.g: iwpriv wlan0 delTspec <handle>
2638 * iwpriv wlan0 delTspec 7001
2639 * wlan0 delTspec:16
2640 *
2641 * Supported Feature: WMM
2642 *
2643 * Usage: Internal/External
2644 *
2645 * </ioctl>
2646 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302648/*
2649 * <ioctl>
2650 * getTspec - Get TSPEC entry for each AC
2651 *
2652 * @INPUT: 1 TSPEC param
2653 * @[arg0]: handle
2654 *
2655 * @OUTPUT: Success/Failure
2656 *
2657 * This IOCTL is used to get TSPEC entry for each AC.
2658 *
2659 * @E.g: iwpriv wlan0 getTspec <handle>
2660 * iwpriv wlan0 getTspec 7001
2661 * wlan0 delTspec:18
2662 *
2663 * Supported Feature: WMM
2664 *
2665 * Usage: Internal/External
2666 *
2667 * </ioctl>
2668 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2670
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671/* (SIOCIWFIRSTPRIV + 10) is currently unused */
2672/* (SIOCIWFIRSTPRIV + 12) is currently unused */
2673/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002674#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
2675#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676/* (SIOCIWFIRSTPRIV + 16) is currently unused */
2677/* (SIOCIWFIRSTPRIV + 17) is currently unused */
2678/* (SIOCIWFIRSTPRIV + 19) is currently unused */
2679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681
2682/* Private ioctl for setting the host offload feature */
2683#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2684
2685/* Private ioctl to get the statistics */
2686#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2687
2688/* Private ioctl to set the Keep Alive Params */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302689/*
2690 * <ioctl>
2691 * setKeepAlive - Set the keep alive feature
2692 *
2693 * @INPUT: 28 bytes of information in the order of packet type, time period
2694 * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2695 *
2696 * @OUTPUT: None
2697 *
2698 * This IOCTL sets the keep alive feature to send either NULL
2699 * or unsolicited ARP response packets
2700 *
2701 * @E.g: iwpriv wlan0 setKeepAlive
2702 *
2703 * Supported Feature: STA
2704 *
2705 * Usage: Internal/External
2706 *
2707 * </ioctl>
2708 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2710
2711#ifdef WLAN_FEATURE_PACKET_FILTERING
2712/* Private ioctl to set the packet filtering params */
2713#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2714#endif
2715
2716
2717#ifdef FEATURE_WLAN_SCAN_PNO
2718/* Private ioctl to get the statistics */
2719#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2720#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302721/*
2722 * <ioctl>
2723 * SETBAND - Set the operational band
2724 *
2725 * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2726 *
2727 * @OUTPUT: None
2728 *
2729 * This IOCTL Set the operational band If the new band is different from the
2730 * current operational band, it aborts the pending scan requests, flushes
2731 * the existing scan results, and then change * the band capability
2732 *
2733 * @E.g: iwpriv wlan0 SETBAND <value>
2734 *
2735 * Supported Feature: STA
2736 *
2737 * Usage: Internal/External
2738 *
2739 * </ioctl>
2740 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
2742
Dustin Brown0cbc7572016-12-16 13:54:40 -08002743#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -08002744/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745
2746/* Private ioctls and their sub-ioctls */
2747#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
2748#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -07002749#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750#define WE_SET_FW_CRASH_INJECT 2
2751#endif
2752#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +05302753/* Private sub ioctl for enabling and setting histogram interval of profiling */
2754#define WE_ENABLE_FW_PROFILE 4
2755#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07002757/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002758#define WE_SET_WLAN_SUSPEND 6
2759#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002760
Dustin Brown8d2d0f52017-04-03 17:02:08 -07002761/*
2762 * <ioctl>
2763 * log_buffer - prints host/target related communication logs via dmesg
2764 *
2765 * @INPUT: Log Id, Count
2766 *
2767 * Log Id:
2768 * 0) HTC_CREDIT_HISTORY_LOG
2769 * 1) COMMAND_LOG,
2770 * 2) COMMAND_TX_CMP_LOG,
2771 * 3) MGMT_COMMAND_LOG,
2772 * 4) MGMT_COMMAND_TX_CMP_LOG,
2773 * 5) EVENT_LOG,
2774 * 6) RX_EVENT_LOG,
2775 * 7) MGMT_EVENT_LOG
2776 *
2777 * @OUTPUT: None
2778 *
2779 * @E.g:
2780 * # print up to 10 of the most recent records from HTC Credit History
2781 * iwpriv wlan0 log_buffer 0 10
2782 * # print up to 3 of the most recent records from Event Log
2783 * iwpriv wlan0 log_buffer 5 3
2784 *
2785 * Supported Feature: WLAN Trace
2786 *
2787 * Usage: Internal/External
2788 *
2789 * </ioctl>
2790 */
2791#define WE_LOG_BUFFER 8
2792
2793enum host_target_comm_log {
2794 HTC_CREDIT_HISTORY_LOG = 0,
2795 COMMAND_LOG,
2796 COMMAND_TX_CMP_LOG,
2797 MGMT_COMMAND_LOG,
2798 MGMT_COMMAND_TX_CMP_LOG,
2799 EVENT_LOG,
2800 RX_EVENT_LOG,
2801 MGMT_EVENT_LOG
2802};
2803
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804/* (SIOCIWFIRSTPRIV + 29) is currently unused */
2805
2806/* 802.11p IOCTL */
2807#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
2808
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302809/*
2810 * <ioctl>
2811 * getLinkSpeed - Gets the current link speed in Mbps
2812 *
2813 * @INPUT: None
2814 *
2815 * @OUTPUT: linkspeed in mbps
2816 * wlan0 getLinkSpeed:7
2817 *
2818 * This IOCTL is used get the current link speed in Mbps
2819 *
2820 * @E.g: iwpriv wlan0 getLinkSpeed
2821 *
2822 * Supported Feature: STA
2823 *
2824 * Usage: Internal/External
2825 *
2826 * </ioctl>
2827 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
2829
2830#define WLAN_STATS_INVALID 0
2831#define WLAN_STATS_RETRY_CNT 1
2832#define WLAN_STATS_MUL_RETRY_CNT 2
2833#define WLAN_STATS_TX_FRM_CNT 3
2834#define WLAN_STATS_RX_FRM_CNT 4
2835#define WLAN_STATS_FRM_DUP_CNT 5
2836#define WLAN_STATS_FAIL_CNT 6
2837#define WLAN_STATS_RTS_FAIL_CNT 7
2838#define WLAN_STATS_ACK_FAIL_CNT 8
2839#define WLAN_STATS_RTS_SUC_CNT 9
2840#define WLAN_STATS_RX_DISCARD_CNT 10
2841#define WLAN_STATS_RX_ERROR_CNT 11
2842#define WLAN_STATS_TX_BYTE_CNT 12
2843
2844#define WLAN_STATS_RX_BYTE_CNT 13
2845#define WLAN_STATS_RX_RATE 14
2846#define WLAN_STATS_TX_RATE 15
2847
2848#define WLAN_STATS_RX_UC_BYTE_CNT 16
2849#define WLAN_STATS_RX_MC_BYTE_CNT 17
2850#define WLAN_STATS_RX_BC_BYTE_CNT 18
2851#define WLAN_STATS_TX_UC_BYTE_CNT 19
2852#define WLAN_STATS_TX_MC_BYTE_CNT 20
2853#define WLAN_STATS_TX_BC_BYTE_CNT 21
2854
2855#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
2856 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
2857 *__p++ = __type; \
2858 *__p++ = __size; \
2859 memcpy(__p, __val, __size); \
2860 __p += __size; \
2861 __tlen += __size + 2; \
2862 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07002863 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 } \
2865 } while (0)
2866
2867#define VERSION_VALUE_MAX_LEN 32
2868
2869#define TX_PER_TRACKING_DEFAULT_RATIO 5
2870#define TX_PER_TRACKING_MAX_RATIO 10
2871#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
2872
2873#define WLAN_ADAPTER 0
2874#define P2P_ADAPTER 1
2875
2876/**
2877 * mem_alloc_copy_from_user_helper - copy from user helper
2878 * @wrqu_data: wireless extensions request data
2879 * @len: length of @wrqu_data
2880 *
2881 * Helper function to allocate buffer and copy user data.
2882 *
2883 * Return: On success return a pointer to a kernel buffer containing a
2884 * copy of the userspace data (with an additional NUL character
2885 * appended for safety). On failure return %NULL.
2886 */
2887void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2888{
2889 u8 *ptr = NULL;
2890
2891 /* in order to protect the code, an extra byte is post
2892 * appended to the buffer and the null termination is added.
2893 * However, when allocating (len+1) byte of memory, we need to
2894 * make sure that there is no uint overflow when doing
2895 * addition. In theory check len < UINT_MAX protects the uint
2896 * overflow. For wlan private ioctl, the buffer size is much
2897 * less than UINT_MAX, as a good guess, now, it is assumed
2898 * that the private command buffer size is no greater than 4K
2899 * (4096 bytes). So we use 4096 as the upper boundary for now.
2900 */
2901 if (len > MAX_USER_COMMAND_SIZE) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08002902 hdd_err("Invalid length: %zu max: %u",
2903 len, MAX_USER_COMMAND_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 return NULL;
2905 }
2906
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002907 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002909 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910 return NULL;
2911 }
2912
2913 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002914 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002915 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 return NULL;
2917 }
2918 ptr[len] = '\0';
2919 return ptr;
2920}
2921
2922/**
2923 * hdd_priv_get_data() - Get pointer to ioctl private data
2924 * @p_priv_data: pointer to iw_point struct to be filled
2925 * @wrqu: Pointer to IOCTL Data received from userspace
2926 *
2927 * Helper function to get compatible struct iw_point passed to ioctl
2928 *
2929 * Return - 0 if p_priv_data successfully filled, error otherwise
2930 */
2931int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2932{
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002933 if ((NULL == p_priv_data) || (NULL == wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002935
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936#ifdef CONFIG_COMPAT
2937 if (is_compat_task()) {
2938 struct compat_iw_point *p_compat_priv_data;
2939
2940 /* Compat task:
2941 * typecast to compat structure and copy the members.
2942 */
2943 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2944
2945 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2946 p_priv_data->length = p_compat_priv_data->length;
2947 p_priv_data->flags = p_compat_priv_data->flags;
2948 } else {
2949#endif /* #ifdef CONFIG_COMPAT */
2950
2951 /* Non compat task: directly copy the structure. */
2952 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
2953
2954#ifdef CONFIG_COMPAT
2955 }
2956#endif /* #ifdef CONFIG_COMPAT */
2957
2958 return 0;
2959}
2960
Jeff Johnson441e1f72017-02-07 08:50:49 -08002961static int hdd_check_wext_control(enum hdd_wext_control wext_control,
2962 struct iw_request_info *info)
2963{
2964 switch (wext_control) {
2965 default:
2966 case hdd_wext_disabled:
2967 hdd_err("Rejecting disabled ioctl %x", info->cmd);
2968 return -ENOTSUPP;
2969 case hdd_wext_deprecated:
2970 hdd_warn("Using deprecated ioctl %x", info->cmd);
2971 return 0;
2972 case hdd_wext_enabled:
2973 return 0;
2974 }
2975}
2976
Jeff Johnson82797b62017-08-11 15:31:27 -07002977int hdd_check_standard_wext_control(struct hdd_context *hdd_ctx,
Jeff Johnson441e1f72017-02-07 08:50:49 -08002978 struct iw_request_info *info)
2979{
2980 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
2981 info);
2982}
2983
Jeff Johnson82797b62017-08-11 15:31:27 -07002984int hdd_check_private_wext_control(struct hdd_context *hdd_ctx,
Jeff Johnson441e1f72017-02-07 08:50:49 -08002985 struct iw_request_info *info)
2986{
2987 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
2988 info);
2989}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990
2991/**
2992 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
2993 * @pAdapter: Pointer to the hdd adapter.
2994 * @length: Size of the data copied
2995 * @buffer: Pointer to char buffer.
2996 * @buf_len: Length of the char buffer.
2997 *
2998 * This function called when the "iwpriv wlan0 get_stats" command is given.
2999 * It used to collect the txrx stats when the device is configured in SAP mode.
3000 *
3001 * Return - none
3002 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07003003void hdd_wlan_get_stats(struct hdd_adapter *pAdapter, uint16_t *length,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 char *buffer, uint16_t buf_len)
3005{
3006 hdd_tx_rx_stats_t *pStats = &pAdapter->hdd_stats.hddTxRxStats;
3007 uint32_t len = 0;
3008 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
3009 uint32_t total_rx_delv = 0, total_rx_refused = 0;
3010 int i = 0;
3011
3012 for (; i < NUM_CPUS; i++) {
3013 total_rx_pkt += pStats->rxPackets[i];
3014 total_rx_dropped += pStats->rxDropped[i];
3015 total_rx_delv += pStats->rxDelivered[i];
3016 total_rx_refused += pStats->rxRefused[i];
3017 }
3018
3019 len = scnprintf(buffer, buf_len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003020 "\nTransmit[%lu] - "
Mohit Khannad0b63f52017-02-18 18:05:52 -08003021 "called %u, dropped %u orphan %u,"
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003022 "\n[dropped] BK %u, BE %u, VI %u, VO %u"
3023 "\n[classified] BK %u, BE %u, VI %u, VO %u"
3024 "\n\nReceive[%lu] - "
3025 "packets %u, dropped %u, delivered %u, refused %u"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 "\n",
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003027 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 pStats->txXmitCalled,
3029 pStats->txXmitDropped,
Mohit Khannad0b63f52017-02-18 18:05:52 -08003030 pStats->txXmitOrphaned,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031
3032 pStats->txXmitDroppedAC[SME_AC_BK],
3033 pStats->txXmitDroppedAC[SME_AC_BE],
3034 pStats->txXmitDroppedAC[SME_AC_VI],
3035 pStats->txXmitDroppedAC[SME_AC_VO],
3036
3037 pStats->txXmitClassifiedAC[SME_AC_BK],
3038 pStats->txXmitClassifiedAC[SME_AC_BE],
3039 pStats->txXmitClassifiedAC[SME_AC_VI],
3040 pStats->txXmitClassifiedAC[SME_AC_VO],
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003041 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
3043 );
3044
3045 for (i = 0; i < NUM_CPUS; i++) {
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003046 if (pStats->rxPackets[i] == 0)
3047 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003049 "Rx CPU[%d]:"
3050 "packets %u, dropped %u, delivered %u, refused %u\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003051 i, pStats->rxPackets[i], pStats->rxDropped[i],
3052 pStats->rxDelivered[i], pStats->rxRefused[i]);
3053 }
3054
3055 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003056 "\nTX_FLOW"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057 "\nCurrent status: %s"
3058 "\ntx-flow timer start count %u"
3059 "\npause count %u, unpause count %u",
3060 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
3061 pStats->txflow_timer_cnt,
3062 pStats->txflow_pause_cnt,
3063 pStats->txflow_unpause_cnt);
3064
Leo Changfdb45c32016-10-28 11:09:23 -07003065 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
3066 pAdapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067 *length = len + 1;
3068}
3069
3070/**
Dustin Brownd9322482017-01-09 12:46:03 -08003071 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
3072 * @hdd_ctx: The Hdd context owning the stats to be written
3073 * @buffer: The char buffer to write to
3074 * @max_len: The maximum number of chars to write
3075 *
3076 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
3077 *
3078 * Return - length of written content, negative number on error
3079 */
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003080static int wlan_hdd_write_suspend_resume_stats(struct hdd_context *hdd_ctx,
Dustin Brownd9322482017-01-09 12:46:03 -08003081 char *buffer, uint16_t max_len)
3082{
3083 QDF_STATUS status;
3084 struct suspend_resume_stats *sr_stats;
3085 struct sir_wake_lock_stats wow_stats;
3086
3087 sr_stats = &hdd_ctx->suspend_resume_stats;
3088
3089 status = wma_get_wakelock_stats(&wow_stats);
3090 if (QDF_IS_STATUS_ERROR(status)) {
3091 hdd_err("Failed to get WoW stats");
3092 return qdf_status_to_os_return(status);
3093 }
3094
3095 return scnprintf(buffer, max_len,
3096 "\n"
3097 "Suspends: %u\n"
3098 "Resumes: %u\n"
3099 "\n"
3100 "Suspend Fail Reasons\n"
3101 "\tIPA: %u\n"
3102 "\tRadar: %u\n"
3103 "\tRoam: %u\n"
3104 "\tScan: %u\n"
3105 "\tInitial Wakeup: %u\n"
3106 "\n"
3107 "WoW Wake Reasons\n"
3108 "\tunicast: %u\n"
3109 "\tbroadcast: %u\n"
3110 "\tIPv4 multicast: %u\n"
3111 "\tIPv6 multicast: %u\n"
3112 "\tIPv6 multicast RA: %u\n"
3113 "\tIPv6 multicast NS: %u\n"
3114 "\tIPv6 multicast NA: %u\n"
3115 "\tICMPv4: %u\n"
3116 "\tICMPv6: %u\n"
3117 "\tRSSI Breach: %u\n"
3118 "\tLow RSSI: %u\n"
3119 "\tG-Scan: %u\n"
3120 "\tPNO Complete: %u\n"
3121 "\tPNO Match: %u\n",
3122 sr_stats->suspends,
3123 sr_stats->resumes,
3124 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
3125 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
3126 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
3127 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
3128 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
3129 wow_stats.wow_ucast_wake_up_count,
3130 wow_stats.wow_bcast_wake_up_count,
3131 wow_stats.wow_ipv4_mcast_wake_up_count,
3132 wow_stats.wow_ipv6_mcast_wake_up_count,
3133 wow_stats.wow_ipv6_mcast_ra_stats,
3134 wow_stats.wow_ipv6_mcast_ns_stats,
3135 wow_stats.wow_ipv6_mcast_na_stats,
3136 wow_stats.wow_icmpv4_count,
3137 wow_stats.wow_icmpv6_count,
3138 wow_stats.wow_rssi_breach_wake_up_count,
3139 wow_stats.wow_low_rssi_wake_up_count,
3140 wow_stats.wow_gscan_wake_up_count,
3141 wow_stats.wow_pno_complete_wake_up_count,
3142 wow_stats.wow_pno_match_wake_up_count);
3143}
3144
3145/**
Govind Singha471e5e2015-10-12 17:11:14 +05303146 * hdd_wlan_list_fw_profile() - Get fw profiling points
3147 * @length: Size of the data copied
3148 * @buffer: Pointer to char buffer.
3149 * @buf_len: Length of the char buffer.
3150 *
3151 * This function called when the "iwpriv wlan0 listProfile" command is given.
3152 * It is used to get the supported profiling points in FW.
3153 *
3154 * Return - none
3155 */
3156void hdd_wlan_list_fw_profile(uint16_t *length,
3157 char *buffer, uint16_t buf_len)
3158{
3159 uint32_t len = 0;
3160
3161 len = scnprintf(buffer, buf_len,
3162 "PROF_CPU_IDLE: %u\n"
3163 "PROF_PPDU_PROC: %u\n"
3164 "PROF_PPDU_POST: %u\n"
3165 "PROF_HTT_TX_INPUT: %u\n"
3166 "PROF_MSDU_ENQ: %u\n"
3167 "PROF_PPDU_POST_HAL: %u\n"
3168 "PROF_COMPUTE_TX_TIME: %u\n",
3169 PROF_CPU_IDLE,
3170 PROF_PPDU_PROC,
3171 PROF_PPDU_POST,
3172 PROF_HTT_TX_INPUT,
3173 PROF_MSDU_ENQ,
3174 PROF_PPDU_POST_HAL,
3175 PROF_COMPUTE_TX_TIME);
3176
3177 *length = len + 1;
3178}
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003179/**
3180 * hdd_display_stats_help() - print statistics help
3181 *
3182 * Return: none
3183 */
3184void hdd_display_stats_help(void)
3185{
3186 hdd_err("iwpriv wlan0 dumpStats [option] - dump statistics");
3187 hdd_err("iwpriv wlan0 clearStats [option] - clear statistics");
3188 hdd_err("options:");
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003189 hdd_err(" 1 -- TXRX PATH statistics");
3190 hdd_err(" 2 -- TXRX HIST statistics");
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003191 hdd_err(" 3 -- TSO statistics");
3192 hdd_err(" 4 -- Network queue statistics");
3193 hdd_err(" 5 -- Flow control statistics");
3194 hdd_err(" 6 -- Per Layer statistics");
3195 hdd_err(" 7 -- Copy engine interrupt statistics");
3196 hdd_err(" 8 -- LRO statistics");
3197 hdd_err(" 9 -- NAPI statistics");
3198}
Govind Singha471e5e2015-10-12 17:11:14 +05303199
3200/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 * hdd_wlan_dump_stats() - display dump Stats
3202 * @adapter: adapter handle
3203 * @value: value from user
3204 *
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003205 * Return: 0 => success, error code on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07003207int hdd_wlan_dump_stats(struct hdd_adapter *adapter, int value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208{
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003209 int ret = 0;
3210 QDF_STATUS status;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003211 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212
3213 switch (value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003214 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
3216 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003217 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 wlan_hdd_display_netif_queue_history(hdd_ctx);
3219 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003220 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05303221 hdd_display_hif_stats();
3222 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003223 case CDP_LRO_STATS:
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003224 hdd_lro_display_stats(hdd_ctx);
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003225 case CDP_NAPI_STATS:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003226 if (hdd_display_napi_stats()) {
3227 hdd_err("error displaying napi stats");
3228 ret = EFAULT;
3229 }
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003230 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 default:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003232 status = cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC),
3233 value);
3234 if (status == QDF_STATUS_E_INVAL) {
3235 hdd_display_stats_help();
3236 ret = EINVAL;
3237 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 break;
3239 }
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003240 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241}
3242
3243/**
3244 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303245 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246 * @wrqu: Pointer to IOCTL REQUEST Data.
3247 * @extra: Pointer to destination buffer
3248 *
3249 * This function is used to get Wlan Driver, Firmware, & Hardware
3250 * Version information. If @wrqu and @extra are specified, then the
3251 * version string is returned. Otherwise it is simply printed to the
3252 * kernel log.
3253 *
3254 * Return: none
3255 */
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003256void hdd_wlan_get_version(struct hdd_context *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 char *extra)
3258{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303259 tSirVersionString wcnss_sw_version;
3260 const char *swversion;
3261 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003262 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303264 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003265 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 goto error;
3267 }
3268
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303269 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
3270 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303272 swversion = wcnss_sw_version;
3273 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
3274 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
3275 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
3276 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003277 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303279 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280
3281 if (wrqu && extra) {
3282 wrqu->data.length =
3283 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003284 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003286 msp_id, mspid, siid, crmid,
3287 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003289 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003291 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 }
3293error:
3294 return;
3295}
3296
3297/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003298 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
3299 * @pAdapter: Adapter upon which the IBSS client is active
3300 * @staIdx: Station index of the IBSS peer
3301 *
3302 * Return: a pointer to the MAC address of the IBSS peer if the peer is
3303 * found, otherwise %NULL.
3304 */
3305struct qdf_mac_addr *
Jeff Johnson3d278b02017-08-29 14:17:47 -07003306hdd_wlan_get_ibss_mac_addr_from_staid(struct hdd_adapter *pAdapter,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003307 uint8_t staIdx)
3308{
3309 uint8_t idx;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003310 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003311
Naveen Rawatc45d1622016-07-05 12:20:09 -07003312 for (idx = 0; idx < MAX_PEERS; idx++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003313 if (HDD_WLAN_INVALID_STA_ID !=
3314 pHddStaCtx->conn_info.staId[idx] &&
3315 staIdx == pHddStaCtx->conn_info.staId[idx]) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003316 return &pHddStaCtx->conn_info.peerMacAddress[idx];
3317 }
3318 }
3319 return NULL;
3320}
3321
3322/**
3323 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
3324 * @pAdapter: Adapter upon which the IBSS client is active
3325 * @staIdx: Station index of the IBSS peer
3326 *
3327 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
3328 * otherwise an appropriate QDF_STATUS_E_* failure code.
3329 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07003330static QDF_STATUS hdd_wlan_get_ibss_peer_info(struct hdd_adapter *pAdapter,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003331 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003332{
3333 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3334 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003335 struct hdd_station_ctx *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003336 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003337
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003338 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003339 status = sme_request_ibss_peer_info(hHal, pAdapter,
3340 hdd_get_ibss_peer_info_cb,
3341 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003342
3343 if (QDF_STATUS_SUCCESS == status) {
3344 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003345
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003346 rc = wait_for_completion_timeout
3347 (&pAdapter->ibss_peer_info_comp,
3348 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3349 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003350 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003351 return QDF_STATUS_E_FAILURE;
3352 }
3353
3354 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003355 hdd_debug("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003356 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003357 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3358 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003359
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003360 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
3361 mac_addr, sizeof(mac_addr));
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003362 hdd_debug("PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003363 mac_addr, (int)tx_rate,
3364 (int)pPeerInfo->peerInfoParams[0].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003365 }
3366 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003367 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003368 }
3369
3370 return status;
3371}
3372
3373/**
3374 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
3375 * @pAdapter: Adapter upon which the IBSS clients are active
3376 *
3377 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
3378 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
3379 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07003380static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(struct hdd_adapter *pAdapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003381{
3382 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3383 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003384 struct hdd_station_ctx *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003385 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003386 int i;
3387
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003388 INIT_COMPLETION(pAdapter->ibss_peer_info_comp);
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003389 status = sme_request_ibss_peer_info(hHal, pAdapter,
3390 hdd_get_ibss_peer_info_cb,
3391 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003392
3393 if (QDF_STATUS_SUCCESS == status) {
3394 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003395
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003396 rc = wait_for_completion_timeout
3397 (&pAdapter->ibss_peer_info_comp,
3398 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3399 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003400 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003401 return QDF_STATUS_E_FAILURE;
3402 }
3403
3404 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003405 hdd_debug("pPeerInfo->numIBSSPeers = %d ",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003406 (int)pPeerInfo->numPeers);
3407 for (i = 0; i < pPeerInfo->numPeers; i++) {
3408 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3409 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003410
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003411 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
3412 qdf_mem_copy(mac_addr,
3413 pPeerInfo->peerInfoParams[i].mac_addr,
3414 sizeof(mac_addr));
3415
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003416 hdd_debug(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003417 mac_addr, (int)tx_rate,
3418 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003419 }
3420 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003421 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003422 }
3423
3424 return status;
3425}
3426
3427/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 * hdd_wlan_get_freq() - Convert channel to frequency
3429 * @channel: channel to be converted
3430 * @pfreq: where to store the frequency
3431 *
3432 * Return: 1 on success, otherwise a negative errno
3433 */
3434int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
3435{
3436 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 if (channel > 0) {
3439 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
3440 if (channel == freq_chan_map[i].chan) {
3441 *pfreq = freq_chan_map[i].freq;
3442 return 1;
3443 }
3444 }
3445 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003446 hdd_err("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 return -EINVAL;
3448}
3449
3450/**
3451 * hdd_is_auth_type_rsn() - RSN authentication type check
3452 * @authType: authentication type to be checked
3453 *
3454 * Return: true if @authType is an RSN authentication type,
3455 * false if it is not
3456 */
3457static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
3458{
3459 bool rsnType = false;
3460 /* is the authType supported? */
3461 switch (authType) {
3462 case eCSR_AUTH_TYPE_NONE: /* never used */
3463 rsnType = false;
3464 break;
3465 /* MAC layer authentication types */
3466 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3467 rsnType = false;
3468 break;
3469 case eCSR_AUTH_TYPE_SHARED_KEY:
3470 rsnType = false;
3471 break;
3472 case eCSR_AUTH_TYPE_AUTOSWITCH:
3473 rsnType = false;
3474 break;
3475
3476 /* Upper layer authentication types */
3477 case eCSR_AUTH_TYPE_WPA:
3478 rsnType = true;
3479 break;
3480 case eCSR_AUTH_TYPE_WPA_PSK:
3481 rsnType = true;
3482 break;
3483 case eCSR_AUTH_TYPE_WPA_NONE:
3484 rsnType = true;
3485 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 case eCSR_AUTH_TYPE_RSN:
3488 rsnType = true;
3489 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 case eCSR_AUTH_TYPE_RSN_PSK:
3492#ifdef WLAN_FEATURE_11W
3493 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3494 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
3495#endif
3496 rsnType = true;
3497 break;
3498 /* case eCSR_AUTH_TYPE_FAILED: */
3499 case eCSR_AUTH_TYPE_UNKNOWN:
3500 rsnType = false;
3501 break;
3502 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003503 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 authType);
3505 rsnType = false;
3506 break;
3507 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003508 hdd_debug("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509 authType, rsnType);
3510 return rsnType;
3511}
3512
Jeff Johnsona5444942017-01-23 13:11:08 -08003513struct rssi_priv {
3514 int8_t rssi;
3515};
3516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517/**
3518 * hdd_get_rssi_cb() - "Get RSSI" callback function
3519 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08003520 * @sta_id: ID of the station
3521 * @context: opaque context originally passed to SME. HDD always passes
3522 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 *
3524 * Return: None
3525 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003526static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527{
Jeff Johnsona5444942017-01-23 13:11:08 -08003528 struct hdd_request *request;
3529 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530
Jeff Johnsona5444942017-01-23 13:11:08 -08003531 request = hdd_request_get(context);
3532 if (!request) {
3533 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 return;
3535 }
3536
Jeff Johnsona5444942017-01-23 13:11:08 -08003537 priv = hdd_request_priv(request);
3538 priv->rssi = rssi;
3539 hdd_request_complete(request);
3540 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541}
3542
3543/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 * wlan_hdd_get_rssi() - Get the current RSSI
3545 * @pAdapter: adapter upon which the measurement is requested
3546 * @rssi_value: pointer to where the RSSI should be returned
3547 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303548 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07003550QDF_STATUS wlan_hdd_get_rssi(struct hdd_adapter *pAdapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551{
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003552 struct hdd_context *pHddCtx;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003553 struct hdd_station_ctx *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303554 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08003555 int ret;
3556 void *cookie;
3557 struct hdd_request *request;
3558 struct rssi_priv *priv;
3559 static const struct hdd_request_params params = {
3560 .priv_size = sizeof(*priv),
3561 .timeout_ms = WLAN_WAIT_TIME_STATS,
3562 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563
3564 if (NULL == pAdapter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003565 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303566 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 }
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +05303568 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003569 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3570 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571 /* return a cached value */
3572 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303573 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 }
3575
3576 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3577 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3578
3579 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003580 hdd_debug("Not associated!, rssi on disconnect %d",
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05303581 pAdapter->rssi_on_disconnect);
3582 *rssi_value = pAdapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303583 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 }
3585
3586 if (pHddStaCtx->hdd_ReassocScenario) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003587 hdd_debug("Roaming in progress, return cached RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 *rssi_value = pAdapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303589 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 }
3591
Jeff Johnsona5444942017-01-23 13:11:08 -08003592 request = hdd_request_alloc(&params);
3593 if (!request) {
3594 hdd_err("Request allocation failure, return cached RSSI");
3595 *rssi_value = pAdapter->rssi;
3596 return QDF_STATUS_SUCCESS;
3597 }
3598 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003599
3600 hstatus = sme_get_rssi(pHddCtx->hHal, hdd_get_rssi_cb,
3601 pHddStaCtx->conn_info.staId[0],
3602 pHddStaCtx->conn_info.bssId, pAdapter->rssi,
Jeff Johnsona5444942017-01-23 13:11:08 -08003603 cookie, pHddCtx->pcds_context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303604 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003605 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 /* we'll returned a cached value below */
3607 } else {
3608 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08003609 ret = hdd_request_wait_for_response(request);
3610 if (ret) {
3611 hdd_warn("SME timed out while retrieving RSSI");
3612 /* we'll returned a cached value below */
3613 } else {
3614 /* update the adapter with the fresh results */
3615 priv = hdd_request_priv(request);
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +05303616 /*
3617 * update rssi only if its valid else return previous
3618 * valid rssi.
3619 */
3620 if (priv->rssi)
3621 pAdapter->rssi = priv->rssi;
3622
3623 /*
3624 * for new connection there might be no valid previous
3625 * RSSI.
3626 */
3627 if (!pAdapter->rssi) {
3628 hdd_get_rssi_snr_by_bssid(pAdapter,
3629 pHddStaCtx->conn_info.bssId.bytes,
3630 &pAdapter->rssi, NULL);
3631 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632 }
3633 }
3634
Jeff Johnsona5444942017-01-23 13:11:08 -08003635 /*
3636 * either we never sent a request, we sent a request and
3637 * received a response or we sent a request and timed out.
3638 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003640 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641
3642 *rssi_value = pAdapter->rssi;
Rajeev Kumar Sirasanagandla5bacf7f2017-05-10 15:31:40 +05303643 hdd_debug("RSSI = %d", *rssi_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303645 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646}
3647
Jeff Johnson002cb972017-01-23 14:59:07 -08003648struct snr_priv {
3649 int8_t snr;
3650};
3651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08003653 * hdd_get_snr_cb() - "Get SNR" callback function
3654 * @snr: Current SNR of the station
Jeff Johnson002cb972017-01-23 14:59:07 -08003655 * @sta_id: ID of the station
3656 * @context: opaque context originally passed to SME. HDD always passes
3657 * a cookie for the request context
Jeff Johnson8eaff302017-01-23 11:03:31 -08003658 *
3659 * Return: None
3660 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003661static void hdd_get_snr_cb(int8_t snr, uint32_t sta_id, void *context)
Jeff Johnson8eaff302017-01-23 11:03:31 -08003662{
Jeff Johnson002cb972017-01-23 14:59:07 -08003663 struct hdd_request *request;
3664 struct snr_priv *priv;
Jeff Johnson8eaff302017-01-23 11:03:31 -08003665
Jeff Johnson002cb972017-01-23 14:59:07 -08003666 request = hdd_request_get(context);
3667 if (!request) {
3668 hdd_err("Obsolete request");
Jeff Johnson8eaff302017-01-23 11:03:31 -08003669 return;
3670 }
3671
Jeff Johnson002cb972017-01-23 14:59:07 -08003672 /* propagate response back to requesting thread */
3673 priv = hdd_request_priv(request);
3674 priv->snr = snr;
3675 hdd_request_complete(request);
3676 hdd_request_put(request);
Jeff Johnson8eaff302017-01-23 11:03:31 -08003677}
3678
3679/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680 * wlan_hdd_get_snr() - Get the current SNR
3681 * @pAdapter: adapter upon which the measurement is requested
3682 * @snr: pointer to where the SNR should be returned
3683 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303684 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07003686QDF_STATUS wlan_hdd_get_snr(struct hdd_adapter *pAdapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687{
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003688 struct hdd_context *pHddCtx;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003689 struct hdd_station_ctx *pHddStaCtx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303690 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691 int valid;
Jeff Johnson002cb972017-01-23 14:59:07 -08003692 int ret;
3693 void *cookie;
3694 struct hdd_request *request;
3695 struct snr_priv *priv;
3696 static const struct hdd_request_params params = {
3697 .priv_size = sizeof(*priv),
3698 .timeout_ms = WLAN_WAIT_TIME_STATS,
3699 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303701 ENTER();
3702
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003704 hdd_err("Invalid context, pAdapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303705 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706 }
3707
3708 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3709
3710 valid = wlan_hdd_validate_context(pHddCtx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303711 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303712 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713
3714 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3715
Jeff Johnson002cb972017-01-23 14:59:07 -08003716 request = hdd_request_alloc(&params);
3717 if (!request) {
3718 hdd_err("Request allocation failure");
3719 return QDF_STATUS_E_FAULT;
3720 }
3721 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722
3723 hstatus = sme_get_snr(pHddCtx->hHal, hdd_get_snr_cb,
3724 pHddStaCtx->conn_info.staId[0],
Jeff Johnson002cb972017-01-23 14:59:07 -08003725 pHddStaCtx->conn_info.bssId, cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303726 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003727 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728 /* we'll returned a cached value below */
3729 } else {
3730 /* request was sent -- wait for the response */
Jeff Johnson002cb972017-01-23 14:59:07 -08003731 ret = hdd_request_wait_for_response(request);
3732 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003733 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734 /* we'll now returned a cached value below */
Jeff Johnson002cb972017-01-23 14:59:07 -08003735 } else {
3736 /* update the adapter with the fresh results */
3737 priv = hdd_request_priv(request);
3738 pAdapter->snr = priv->snr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 }
3740 }
3741
Jeff Johnson002cb972017-01-23 14:59:07 -08003742 /*
3743 * either we never sent a request, we sent a request and
3744 * received a response or we sent a request and timed out.
3745 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003746 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003747 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748
3749 *snr = pAdapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303750 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303751 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003752}
3753
Jeff Johnsone50427c2017-01-26 10:54:49 -08003754struct linkspeed_priv {
3755 tSirLinkSpeedInfo linkspeed_info;
3756};
3757
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758static void
Jeff Johnsone50427c2017-01-26 10:54:49 -08003759hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003760{
Jeff Johnsone50427c2017-01-26 10:54:49 -08003761 struct hdd_request *request;
3762 struct linkspeed_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003763
Jeff Johnsone50427c2017-01-26 10:54:49 -08003764 if (!linkspeed_info) {
3765 hdd_err("NULL linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003766 return;
3767 }
3768
Jeff Johnsone50427c2017-01-26 10:54:49 -08003769 request = hdd_request_get(context);
3770 if (!request) {
3771 hdd_err("Obsolete request");
3772 return;
3773 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774
Jeff Johnsone50427c2017-01-26 10:54:49 -08003775 priv = hdd_request_priv(request);
3776 priv->linkspeed_info = *linkspeed_info;
3777 hdd_request_complete(request);
3778 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779}
3780
Jeff Johnson3d278b02017-08-29 14:17:47 -07003781int wlan_hdd_get_linkspeed_for_peermac(struct hdd_adapter *adapter,
Jeff Johnsone50427c2017-01-26 10:54:49 -08003782 struct qdf_mac_addr *mac_address,
3783 uint32_t *linkspeed)
3784{
3785 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303786 QDF_STATUS status;
Jeff Johnsone50427c2017-01-26 10:54:49 -08003787 void *cookie;
3788 tSirLinkSpeedInfo *linkspeed_info;
3789 struct hdd_request *request;
3790 struct linkspeed_priv *priv;
3791 static const struct hdd_request_params params = {
3792 .priv_size = sizeof(*priv),
3793 .timeout_ms = WLAN_WAIT_TIME_STATS,
3794 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795
Jeff Johnsone50427c2017-01-26 10:54:49 -08003796 if ((!adapter) || (!linkspeed)) {
3797 hdd_err("NULL argument");
3798 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800
Jeff Johnsone50427c2017-01-26 10:54:49 -08003801 request = hdd_request_alloc(&params);
3802 if (!request) {
3803 hdd_err("Request allocation failure");
3804 ret = -ENOMEM;
3805 goto return_cached_value;
3806 }
3807
3808 cookie = hdd_request_cookie(request);
3809 priv = hdd_request_priv(request);
3810
3811 linkspeed_info = &priv->linkspeed_info;
3812 qdf_copy_macaddr(&linkspeed_info->peer_macaddr, mac_address);
3813 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(adapter),
3814 linkspeed_info,
3815 cookie, hdd_get_link_speed_cb);
3816 if (QDF_IS_STATUS_ERROR(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003817 hdd_err("Unable to retrieve statistics for link speed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003818 ret = qdf_status_to_os_return(status);
3819 goto cleanup;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 }
Jeff Johnsone50427c2017-01-26 10:54:49 -08003821 ret = hdd_request_wait_for_response(request);
3822 if (ret) {
3823 hdd_err("SME timed out while retrieving link speed");
3824 goto cleanup;
3825 }
3826 adapter->estimated_linkspeed = linkspeed_info->estLinkSpeed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827
Jeff Johnsone50427c2017-01-26 10:54:49 -08003828cleanup:
3829 /*
3830 * either we never sent a request, we sent a request and
3831 * received a response or we sent a request and timed out.
3832 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833 */
Jeff Johnsone50427c2017-01-26 10:54:49 -08003834 hdd_request_put(request);
3835
3836return_cached_value:
3837 *linkspeed = adapter->estimated_linkspeed;
3838
3839 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840}
3841
3842/**
3843 * wlan_hdd_get_link_speed() - get link speed
3844 * @pAdapter: pointer to the adapter
3845 * @link_speed: pointer to link speed
3846 *
3847 * This function fetches per bssid link speed.
3848 *
3849 * Return: if associated, link speed shall be returned.
3850 * if not associated, link speed of 0 is returned.
3851 * On error, error number will be returned.
3852 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07003853int wlan_hdd_get_link_speed(struct hdd_adapter *sta_adapter, uint32_t *link_speed)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854{
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003855 struct hdd_context *hddctx = WLAN_HDD_GET_CTX(sta_adapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003856 struct hdd_station_ctx *hdd_stactx =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003857 WLAN_HDD_GET_STATION_CTX_PTR(sta_adapter);
3858 int ret;
3859
3860 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05303861 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303864 /* Linkspeed is allowed only for P2P mode */
3865 if (sta_adapter->device_mode != QDF_P2P_CLIENT_MODE) {
3866 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
3867 hdd_device_mode_to_string(sta_adapter->device_mode),
3868 sta_adapter->device_mode);
3869 return -ENOTSUPP;
3870 }
3871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
3873 /* we are not connected so we don't have a classAstats */
3874 *link_speed = 0;
3875 } else {
Anurag Chouhan6d760662016-02-20 16:05:43 +05303876 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877
Anurag Chouhanc5548422016-02-24 18:33:27 +05303878 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003879
Jeff Johnsone50427c2017-01-26 10:54:49 -08003880 ret = wlan_hdd_get_linkspeed_for_peermac(sta_adapter, &bssid,
3881 link_speed);
3882 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003883 hdd_err("Unable to retrieve SME linkspeed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003884 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003886 /* linkspeed in units of 500 kbps */
3887 *link_speed = (*link_speed) / 500;
3888 }
3889 return 0;
3890}
3891
Will Huang496b36c2017-07-11 16:38:50 +08003892struct peer_rssi_priv {
3893 struct sir_peer_sta_info peer_sta_info;
3894};
3895
3896/**
3897 * hdd_get_peer_rssi_cb() - get peer station's rssi callback
3898 * @sta_rssi: pointer of peer information
3899 * @context: get rssi callback context
3900 *
3901 * This function will fill rssi information to rssi priv
3902 * adapter
3903 *
3904 */
3905static void hdd_get_peer_rssi_cb(struct sir_peer_info_resp *sta_rssi,
3906 void *context)
3907{
3908 struct hdd_request *request;
3909 struct peer_rssi_priv *priv;
3910 struct sir_peer_info *rssi_info;
3911 uint8_t peer_num;
3912
3913 if ((!sta_rssi) || (!context)) {
3914 hdd_err("Bad param, sta_rssi [%p] context [%p]",
3915 sta_rssi, context);
3916 return;
3917 }
3918
3919 request = hdd_request_get(context);
3920 if (!request) {
3921 hdd_err("Obsolete request");
3922 return;
3923 }
3924
3925 priv = hdd_request_priv(request);
3926
3927 peer_num = sta_rssi->count;
3928 rssi_info = sta_rssi->info;
3929
3930 hdd_debug("%d peers", peer_num);
3931
3932 if (peer_num > MAX_PEER_STA) {
3933 hdd_warn("Exceed max peer sta to handle one time %d", peer_num);
3934 peer_num = MAX_PEER_STA;
3935 }
3936
3937 qdf_mem_copy(priv->peer_sta_info.info, rssi_info,
3938 peer_num * sizeof(*rssi_info));
3939 priv->peer_sta_info.sta_num = peer_num;
3940
3941 hdd_request_complete(request);
3942 hdd_request_put(request);
3943}
3944
Jeff Johnson3d278b02017-08-29 14:17:47 -07003945int wlan_hdd_get_peer_rssi(struct hdd_adapter *adapter,
Will Huang496b36c2017-07-11 16:38:50 +08003946 struct qdf_mac_addr *macaddress,
3947 struct sir_peer_sta_info *peer_sta_info)
3948{
3949 QDF_STATUS status;
3950 void *cookie;
3951 int ret;
3952 struct sir_peer_info_req rssi_req;
3953 struct hdd_request *request;
3954 struct peer_rssi_priv *priv;
3955 static const struct hdd_request_params params = {
3956 .priv_size = sizeof(*priv),
3957 .timeout_ms = WLAN_WAIT_TIME_STATS,
3958 };
3959
3960 if (!adapter || !macaddress || !peer_sta_info) {
3961 hdd_err("pAdapter [%p], macaddress [%p], peer_sta_info[%p]",
3962 adapter, macaddress, peer_sta_info);
3963 return -EFAULT;
3964 }
3965
3966 request = hdd_request_alloc(&params);
3967 if (!request) {
3968 hdd_err("Request allocation failure");
3969 return -ENOMEM;
3970 }
3971
3972 cookie = hdd_request_cookie(request);
3973 priv = hdd_request_priv(request);
3974
3975 qdf_mem_copy(&rssi_req.peer_macaddr, macaddress,
3976 QDF_MAC_ADDR_SIZE);
3977 rssi_req.sessionid = adapter->sessionId;
3978 status = sme_get_peer_info(WLAN_HDD_GET_HAL_CTX(adapter),
3979 rssi_req,
3980 cookie,
3981 hdd_get_peer_rssi_cb);
3982 if (status != QDF_STATUS_SUCCESS) {
3983 hdd_err("Unable to retrieve statistics for rssi");
3984 ret = -EFAULT;
3985 } else {
3986 ret = hdd_request_wait_for_response(request);
3987 if (ret) {
3988 hdd_err("SME timed out while retrieving rssi");
3989 ret = -EFAULT;
3990 } else {
3991 *peer_sta_info = priv->peer_sta_info;
3992 ret = 0;
3993 }
3994 }
3995
3996 hdd_request_put(request);
3997
3998 return ret;
3999}
4000
4001struct peer_info_priv {
4002 struct sir_peer_sta_ext_info peer_sta_ext_info;
4003};
4004
4005/**
4006 * wlan_hdd_get_peer_info_cb() - get peer info callback
4007 * @sta_info: pointer of peer information
4008 * @context: get peer info callback context
4009 *
4010 * This function will fill stats info to peer info priv
4011 *
4012 */
4013static void wlan_hdd_get_peer_info_cb(struct sir_peer_info_ext_resp *sta_info,
4014 void *context)
4015{
4016 struct hdd_request *request;
4017 struct peer_info_priv *priv;
4018 uint8_t sta_num;
4019
4020 if ((!sta_info) || (!context)) {
4021 hdd_err("Bad param, sta_info [%p] context [%p]",
4022 sta_info, context);
4023 return;
4024 }
4025
4026 if (!sta_info->count) {
4027 hdd_err("Fail to get remote peer info");
4028 return;
4029 }
4030
4031 if (sta_info->count > MAX_PEER_STA) {
4032 hdd_warn("Exceed max peer number %d", sta_info->count);
4033 sta_num = MAX_PEER_STA;
4034 } else {
4035 sta_num = sta_info->count;
4036 }
4037
4038 request = hdd_request_get(context);
4039 if (!request) {
4040 hdd_err("Obsolete request");
4041 return;
4042 }
4043
4044 priv = hdd_request_priv(request);
4045
4046 priv->peer_sta_ext_info.sta_num = sta_num;
4047 qdf_mem_copy(&priv->peer_sta_ext_info.info,
4048 sta_info->info,
4049 sta_num * sizeof(sta_info->info[0]));
4050
4051 hdd_request_complete(request);
4052 hdd_request_put(request);
4053}
4054
Jeff Johnson3d278b02017-08-29 14:17:47 -07004055int wlan_hdd_get_peer_info(struct hdd_adapter *adapter,
Will Huang496b36c2017-07-11 16:38:50 +08004056 struct qdf_mac_addr macaddress,
4057 struct sir_peer_info_ext *peer_info_ext)
4058{
4059 QDF_STATUS status;
4060 void *cookie;
4061 int ret;
4062 struct sir_peer_info_ext_req peer_info_req;
4063 struct hdd_request *request;
4064 struct peer_info_priv *priv;
4065 static const struct hdd_request_params params = {
4066 .priv_size = sizeof(*priv),
4067 .timeout_ms = WLAN_WAIT_TIME_STATS,
4068 };
4069
4070 if (!adapter) {
4071 hdd_err("pAdapter is NULL");
4072 return -EFAULT;
4073 }
4074
4075 request = hdd_request_alloc(&params);
4076 if (!request) {
4077 hdd_err("Request allocation failure");
4078 return -ENOMEM;
4079 }
4080
4081 cookie = hdd_request_cookie(request);
4082 priv = hdd_request_priv(request);
4083
4084 qdf_mem_copy(&peer_info_req.peer_macaddr, &macaddress,
4085 QDF_MAC_ADDR_SIZE);
4086 peer_info_req.sessionid = adapter->sessionId;
4087 peer_info_req.reset_after_request = 0;
4088 status = sme_get_peer_info_ext(WLAN_HDD_GET_HAL_CTX(adapter),
4089 &peer_info_req,
4090 cookie,
4091 wlan_hdd_get_peer_info_cb);
4092 if (status != QDF_STATUS_SUCCESS) {
4093 hdd_err("Unable to retrieve statistics for peer info");
4094 ret = -EFAULT;
4095 } else {
4096 ret = hdd_request_wait_for_response(request);
4097 if (ret) {
4098 hdd_err("SME timed out while retrieving peer info");
4099 ret = -EFAULT;
4100 } else {
4101 /* only support one peer by now */
4102 *peer_info_ext = priv->peer_sta_ext_info.info[0];
4103 ret = 0;
4104 }
4105 }
4106
4107 hdd_request_put(request);
4108
4109 return ret;
4110}
4111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112/**
4113 * hdd_statistics_cb() - "Get statistics" callback function
4114 * @pStats: statistics payload
4115 * @pContext: opaque context originally passed to SME. HDD always passes
4116 * a pointer to an adapter
4117 *
4118 * Return: None
4119 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004120static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004122 struct hdd_adapter *pAdapter = (struct hdd_adapter *) pContext;
Jeff Johnson07f94742017-08-14 15:55:40 -07004123 struct hdd_stats *pStatsCache = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004124 hdd_wext_state_t *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05304125 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126
4127 tCsrSummaryStatsInfo *pSummaryStats = NULL;
4128 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130
4131 if (pAdapter != NULL)
4132 pStatsCache = &pAdapter->hdd_stats;
4133
4134 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
4135 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Jeff Johnsonf2dac4f2017-03-16 11:41:31 -07004136 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137
4138 if (pStatsCache != NULL) {
4139 /* copy the stats into the cache we keep in the
4140 * adapter instance structure
4141 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304142 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304144 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304146 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 sizeof(pStatsCache->ClassD_stat));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 }
4149
4150 if (pAdapter) {
4151 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304152 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05304153 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004154 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 return;
4156 }
4157 }
4158}
4159
4160/**
4161 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
4162 * @pAdapter: adapter who's IEs are to be cleared
4163 *
4164 * Return: None
4165 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004166void hdd_clear_roam_profile_ie(struct hdd_adapter *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004168 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004169
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004170 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171
4172 /* clear WPA/RSN/WSC IE information in the profile */
4173 pWextState->roamProfile.nWPAReqIELength = 0;
4174 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
4175 pWextState->roamProfile.nRSNReqIELength = 0;
4176 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
4177
4178#ifdef FEATURE_WLAN_WAPI
4179 pWextState->roamProfile.nWAPIReqIELength = 0;
4180 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
4181#endif
4182
4183 pWextState->roamProfile.bWPSAssociation = false;
4184 pWextState->roamProfile.bOSENAssociation = false;
4185 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
4186 pWextState->roamProfile.nAddIEScanLength = 0;
4187 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
4188 pWextState->roamProfile.nAddIEAssocLength = 0;
4189
4190 pWextState->roamProfile.EncryptionType.numEntries = 1;
4191 pWextState->roamProfile.EncryptionType.encryptionType[0]
4192 = eCSR_ENCRYPT_TYPE_NONE;
4193
4194 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4195 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
4196 = eCSR_ENCRYPT_TYPE_NONE;
4197
4198 pWextState->roamProfile.AuthType.numEntries = 1;
4199 pWextState->roamProfile.AuthType.authType[0] =
4200 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4201
Abhishek Singh3c9910e2017-01-06 17:56:47 +05304202 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
4203 QDF_MAC_ADDR_SIZE);
4204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205#ifdef WLAN_FEATURE_11W
4206 pWextState->roamProfile.MFPEnabled = false;
4207 pWextState->roamProfile.MFPRequired = 0;
4208 pWextState->roamProfile.MFPCapable = 0;
4209#endif
4210
4211 pWextState->authKeyMgmt = 0;
4212
Yingying Tang3cc6b792016-10-20 17:00:37 +08004213 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
4214
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215#ifdef FEATURE_WLAN_WAPI
4216 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
4217 pAdapter->wapi_info.nWapiMode = 0;
4218#endif
4219
Anurag Chouhanc5548422016-02-24 18:33:27 +05304220 qdf_zero_macaddr(&pWextState->req_bssId);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004221 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222}
4223
4224/**
4225 * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
4226 * @oui: The OUI that is being searched for
4227 * @oui_size: The length of @oui
4228 * @ie: The set of IEs within which we're trying to find @oui
4229 * @ie_len: The length of @ie
4230 *
4231 * This function will scan the IEs contained within @ie looking for @oui.
4232 *
4233 * Return: Pointer to @oui embedded within @ie if it is present, NULL
4234 * if @oui is not present within @ie.
4235 */
4236uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
4237 uint8_t *ie, int ie_len)
4238{
4239 int left = ie_len;
4240 uint8_t *ptr = ie;
4241 uint8_t elem_id, elem_len;
4242 uint8_t eid = 0xDD;
4243
4244 if (NULL == ie || 0 == ie_len)
4245 return NULL;
4246
4247 while (left >= 2) {
4248 elem_id = ptr[0];
4249 elem_len = ptr[1];
4250 left -= 2;
4251 if (elem_len > left) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004252 hdd_err("Invalid IEs eid: %d elem_len: %d left: %d",
4253 eid, elem_len, left);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 return NULL;
4255 }
SaidiReddy Yenugaecb273b2017-05-26 18:34:23 +05304256 if ((elem_id == eid) && (elem_len >= oui_size)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 if (memcmp(&ptr[2], oui, oui_size) == 0)
4258 return ptr;
4259 }
4260
4261 left -= elem_len;
4262 ptr += (elem_len + 2);
4263 }
4264 return NULL;
4265}
4266
4267/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304268 * hdd_get_ldpc() - Get adapter LDPC
4269 * @adapter: adapter being queried
4270 * @value: where to store the value
4271 *
4272 * Return: 0 on success, negative errno on failure
4273 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004274int hdd_get_ldpc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304275{
4276 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4277 int ret;
4278
4279 ENTER();
4280 ret = sme_get_ht_config(hal, adapter->sessionId,
4281 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
4282 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004283 hdd_err("Failed to get LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304284 } else {
4285 *value = ret;
4286 ret = 0;
4287 }
4288 return ret;
4289}
4290
4291/**
4292 * hdd_set_ldpc() - Set adapter LDPC
4293 * @adapter: adapter being modified
4294 * @value: new LDPC value
4295 *
4296 * Return: 0 on success, negative errno on failure
4297 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004298int hdd_set_ldpc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304299{
4300 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4301 int ret;
4302
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004303 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304304 if (value) {
4305 /* make sure HT capabilities allow this */
4306 QDF_STATUS status;
4307 uint32_t cfg_value;
4308 union {
4309 uint16_t cfg_value16;
4310 tSirMacHTCapabilityInfo ht_cap_info;
4311 } u;
4312
4313 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4314 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004315 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304316 return -EIO;
4317 }
4318 u.cfg_value16 = cfg_value & 0xFFFF;
4319 if (!u.ht_cap_info.advCodingCap) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004320 hdd_err("LDCP not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304321 return -EINVAL;
4322 }
4323 }
4324
4325 ret = sme_update_ht_config(hal, adapter->sessionId,
4326 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
4327 value);
4328 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004329 hdd_err("Failed to set LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304330
4331 return ret;
4332}
4333
4334/**
4335 * hdd_get_tx_stbc() - Get adapter TX STBC
4336 * @adapter: adapter being queried
4337 * @value: where to store the value
4338 *
4339 * Return: 0 on success, negative errno on failure
4340 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004341int hdd_get_tx_stbc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304342{
4343 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4344 int ret;
4345
4346 ENTER();
4347 ret = sme_get_ht_config(hal, adapter->sessionId,
4348 WNI_CFG_HT_CAP_INFO_TX_STBC);
4349 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004350 hdd_err("Failed to get TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304351 } else {
4352 *value = ret;
4353 ret = 0;
4354 }
4355
4356 return ret;
4357}
4358
4359/**
4360 * hdd_set_tx_stbc() - Set adapter TX STBC
4361 * @adapter: adapter being modified
4362 * @value: new TX STBC value
4363 *
4364 * Return: 0 on success, negative errno on failure
4365 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004366int hdd_set_tx_stbc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304367{
4368 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4369 int ret;
4370
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004371 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304372 if (value) {
4373 /* make sure HT capabilities allow this */
4374 QDF_STATUS status;
4375 uint32_t cfg_value;
4376 union {
4377 uint16_t cfg_value16;
4378 tSirMacHTCapabilityInfo ht_cap_info;
4379 } u;
4380
4381 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4382 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004383 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304384 return -EIO;
4385 }
4386 u.cfg_value16 = cfg_value & 0xFFFF;
4387 if (!u.ht_cap_info.txSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004388 hdd_err("TX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304389 return -EINVAL;
4390 }
4391 }
4392 ret = sme_update_ht_config(hal, adapter->sessionId,
4393 WNI_CFG_HT_CAP_INFO_TX_STBC,
4394 value);
4395 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004396 hdd_err("Failed to set TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304397
4398 return ret;
4399}
4400
4401/**
4402 * hdd_get_rx_stbc() - Get adapter RX STBC
4403 * @adapter: adapter being queried
4404 * @value: where to store the value
4405 *
4406 * Return: 0 on success, negative errno on failure
4407 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004408int hdd_get_rx_stbc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304409{
4410 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4411 int ret;
4412
4413 ENTER();
4414 ret = sme_get_ht_config(hal, adapter->sessionId,
4415 WNI_CFG_HT_CAP_INFO_RX_STBC);
4416 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004417 hdd_err("Failed to get RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304418 } else {
4419 *value = ret;
4420 ret = 0;
4421 }
4422
4423 return ret;
4424}
4425
4426/**
4427 * hdd_set_rx_stbc() - Set adapter RX STBC
4428 * @adapter: adapter being modified
4429 * @value: new RX STBC value
4430 *
4431 * Return: 0 on success, negative errno on failure
4432 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004433int hdd_set_rx_stbc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304434{
4435 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4436 int ret;
4437
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004438 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304439 if (value) {
4440 /* make sure HT capabilities allow this */
4441 QDF_STATUS status;
4442 uint32_t cfg_value;
4443 union {
4444 uint16_t cfg_value16;
4445 tSirMacHTCapabilityInfo ht_cap_info;
4446 } u;
4447
4448 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4449 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004450 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304451 return -EIO;
4452 }
4453 u.cfg_value16 = cfg_value & 0xFFFF;
4454 if (!u.ht_cap_info.rxSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004455 hdd_warn("RX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304456 return -EINVAL;
4457 }
4458 }
4459 ret = sme_update_ht_config(hal, adapter->sessionId,
4460 WNI_CFG_HT_CAP_INFO_RX_STBC,
4461 value);
4462 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004463 hdd_err("Failed to set RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304464
4465 return ret;
4466}
4467
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004468int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate)
4469{
4470 int set_value;
4471
4472 if (sme_is_feature_supported_by_fw(DOT11AX))
4473 set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble);
4474 else
4475 set_value = (preamble << 6) | (nss << 4) | rate;
4476
4477 return set_value;
4478}
4479
Jeff Johnson3d278b02017-08-29 14:17:47 -07004480int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004481 struct sap_Config *sap_config)
4482{
4483 uint8_t preamble = 0, nss = 0, rix = 0;
4484 int ret;
4485
4486 if (!sap_config) {
4487 if (!sme_is_feature_supported_by_fw(DOT11AX)) {
4488 hdd_err("Target does not support 11ax");
4489 return -EIO;
4490 }
4491 } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax &&
4492 sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) {
4493 hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d",
4494 sap_config->SapHw_mode, sap_config->channel);
4495 return -EIO;
4496 }
4497
4498 if (set_value != 0xff) {
4499 rix = RC_2_RATE_IDX_11AX(set_value);
4500 preamble = WMI_RATE_PREAMBLE_HE;
4501 nss = HT_RC_2_STREAMS_11AX(set_value);
4502
4503 set_value = hdd_assemble_rate_code(preamble, nss, rix);
4504 }
4505
4506 hdd_notice("SET_11AX_RATE val %d rix %d preamble %x nss %d",
4507 set_value, rix, preamble, nss);
4508
4509 ret = wma_cli_set_command(adapter->sessionId,
4510 WMI_VDEV_PARAM_FIXED_RATE,
4511 set_value, VDEV_CMD);
4512
4513 return ret;
4514}
4515
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304516/**
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004517 * hdd_get_aid_rc() - Get AID and rate code passed from user
4518 * @aid: pointer to AID
4519 * @rc: pointer to rate code
4520 * @set_value: value passed from user
4521 *
4522 * If target is 11ax capable, set_value will have AID left shifted 16 bits
4523 * and 16 bits for rate code. If the target is not 11ax capable, rate code
4524 * will only be 8 bits.
4525 *
4526 * Return: None
4527 */
4528static void hdd_get_aid_rc(uint8_t *aid, uint16_t *rc, int set_value)
4529{
4530 uint8_t rc_bits;
4531
4532 if (sme_is_feature_supported_by_fw(DOT11AX))
4533 rc_bits = 16;
4534 else
4535 rc_bits = 8;
4536
4537 *aid = set_value >> rc_bits;
4538 *rc = set_value & ((1 << (rc_bits + 1)) - 1);
4539}
4540
Jeff Johnson3d278b02017-08-29 14:17:47 -07004541int hdd_set_peer_rate(struct hdd_adapter *adapter, int set_value)
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004542{
4543 uint8_t aid, *peer_mac;
4544 uint16_t rc;
4545 QDF_STATUS status;
4546
4547 if (adapter->device_mode != QDF_SAP_MODE) {
4548 hdd_err("Invalid devicde mode - %d", adapter->device_mode);
4549 return -EINVAL;
4550 }
4551
4552 hdd_get_aid_rc(&aid, &rc, set_value);
4553
4554 if ((adapter->aStaInfo[aid].isUsed) &&
4555 (OL_TXRX_PEER_STATE_CONN == adapter->aStaInfo[aid].tlSTAState)) {
4556 peer_mac =
4557 (uint8_t *)&(adapter->aStaInfo[aid].macAddrSTA.bytes[0]);
4558 hdd_info("Peer AID: %d MAC_ADDR: "MAC_ADDRESS_STR,
4559 aid, MAC_ADDR_ARRAY(peer_mac));
4560 } else {
4561 hdd_err("No matching peer found for AID: %d", aid);
4562 return -EINVAL;
4563 }
4564
4565 status = sme_set_peer_param(peer_mac, WMI_PEER_PARAM_FIXED_RATE,
4566 rc, adapter->sessionId);
4567 if (status != QDF_STATUS_SUCCESS) {
4568 hdd_err("Failed to set peer fixed rate - status: %d", status);
4569 return -EIO;
4570 }
4571
4572 return 0;
4573}
4574
4575/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
4577 * @dev: device upon which the ioctl was received
4578 * @info: ioctl request information
4579 * @wrqu: ioctl request data
4580 * @extra: ioctl extra data
4581 *
4582 * Return: 0 on success, non-zero on error
4583 */
4584static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
4585 union iwreq_data *wrqu, char *extra)
4586{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004587 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004588 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 int ret;
4590
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004591 ENTER_DEV(dev);
4592
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4594 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4595 ret = wlan_hdd_validate_context(hdd_ctx);
4596 if (0 != ret)
4597 return ret;
4598
Jeff Johnson441e1f72017-02-07 08:50:49 -08004599 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4600 if (0 != ret)
4601 return ret;
4602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603 /* Do nothing for now */
4604 return 0;
4605}
4606
4607/**
4608 * iw_set_commit() - SSR wrapper function for __iw_set_commit
4609 * @dev: pointer to net_device
4610 * @info: pointer to iw_request_info
4611 * @wrqu: pointer to iwreq_data
4612 * @extra: extra
4613 *
4614 * Return: 0 on success, error number otherwise
4615 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004616static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 union iwreq_data *wrqu, char *extra)
4618{
4619 int ret;
4620
4621 cds_ssr_protect(__func__);
4622 ret = __iw_set_commit(dev, info, wrqu, extra);
4623 cds_ssr_unprotect(__func__);
4624
4625 return ret;
4626}
4627
4628/**
4629 * __iw_get_name() - SIOCGIWNAME ioctl handler
4630 * @dev: device upon which the ioctl was received
4631 * @info: ioctl request information
4632 * @wrqu: ioctl request data
4633 * @extra: ioctl extra data
4634 *
4635 * Return: 0 on success, non-zero on error
4636 */
4637static int __iw_get_name(struct net_device *dev,
4638 struct iw_request_info *info, char *wrqu, char *extra)
4639{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004640 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004641 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642 int ret;
4643
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004644 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645
4646 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4647 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4648 ret = wlan_hdd_validate_context(hdd_ctx);
4649 if (0 != ret)
4650 return ret;
4651
Jeff Johnson441e1f72017-02-07 08:50:49 -08004652 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4653 if (0 != ret)
4654 return ret;
4655
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
4657 EXIT();
4658 return 0;
4659}
4660
4661/**
4662 * __iw_get_name() - SSR wrapper for __iw_get_name
4663 * @dev: pointer to net_device
4664 * @info: pointer to iw_request_info
4665 * @wrqu: pointer to iwreq_data
4666 * @extra: extra
4667 *
4668 * Return: 0 on success, error number otherwise
4669 */
4670static int iw_get_name(struct net_device *dev,
4671 struct iw_request_info *info,
4672 char *wrqu, char *extra)
4673{
4674 int ret;
4675
4676 cds_ssr_protect(__func__);
4677 ret = __iw_get_name(dev, info, wrqu, extra);
4678 cds_ssr_unprotect(__func__);
4679
4680 return ret;
4681}
4682
4683/**
4684 * __iw_set_mode() - ioctl handler
4685 * @dev: device upon which the ioctl was received
4686 * @info: ioctl request information
4687 * @wrqu: ioctl request data
4688 * @extra: ioctl extra data
4689 *
4690 * Return: 0 on success, non-zero on error
4691 */
4692static int __iw_set_mode(struct net_device *dev,
4693 struct iw_request_info *info,
4694 union iwreq_data *wrqu, char *extra)
4695{
4696 hdd_wext_state_t *pWextState;
Jeff Johnson3d278b02017-08-29 14:17:47 -07004697 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004698 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 tCsrRoamProfile *pRoamProfile;
4700 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004701 struct hdd_config *pConfig;
4702 struct wireless_dev *wdev;
4703 int ret;
4704
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004705 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004706
4707 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4708 ret = wlan_hdd_validate_context(hdd_ctx);
4709 if (0 != ret)
4710 return ret;
4711
Jeff Johnson441e1f72017-02-07 08:50:49 -08004712 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4713 if (0 != ret)
4714 return ret;
4715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4717 wdev = dev->ieee80211_ptr;
4718 pRoamProfile = &pWextState->roamProfile;
4719 LastBSSType = pRoamProfile->BSSType;
4720
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004721 hdd_debug("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722
4723 switch (wrqu->mode) {
4724 case IW_MODE_ADHOC:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004725 hdd_debug("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
4727 /* Set the phymode correctly for IBSS. */
4728 pConfig = (WLAN_HDD_GET_CTX(pAdapter))->config;
4729 pWextState->roamProfile.phyMode =
4730 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Krunal Sonif07bb382016-03-10 13:02:11 -08004731 pAdapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732 wdev->iftype = NL80211_IFTYPE_ADHOC;
4733 break;
4734 case IW_MODE_INFRA:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004735 hdd_debug("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004736 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
4737 wdev->iftype = NL80211_IFTYPE_STATION;
4738 break;
4739 case IW_MODE_AUTO:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004740 hdd_debug("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004741 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
4742 break;
4743 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004744 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 return -EOPNOTSUPP;
4746 }
4747
4748 if (LastBSSType != pRoamProfile->BSSType) {
4749 /* the BSS mode changed. We need to issue disconnect
4750 * if connected or in IBSS disconnect state
4751 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07004752 if (hdd_conn_is_connected
4753 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304755 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004756 /* need to issue a disconnect to CSR. */
4757 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304758 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
4760 pAdapter->sessionId,
4761 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304762 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004765 rc = wait_for_completion_timeout(&pAdapter->
4766 disconnect_comp_var,
4767 msecs_to_jiffies
4768 (WLAN_WAIT_TIME_DISCONNECT));
4769 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004770 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004771 }
4772 }
4773 }
4774
4775 EXIT();
4776 return 0;
4777}
4778
4779/**
4780 * iw_set_mode() - SSR wrapper for __iw_set_mode()
4781 * @dev: pointer to net_device
4782 * @info: pointer to iw_request_info
4783 * @wrqu: pointer to iwreq_data
4784 * @extra: pointer to extra ioctl payload
4785 *
4786 * Return: 0 on success, error number otherwise
4787 */
4788static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
4789 union iwreq_data *wrqu, char *extra)
4790{
4791 int ret;
4792
4793 cds_ssr_protect(__func__);
4794 ret = __iw_set_mode(dev, info, wrqu, extra);
4795 cds_ssr_unprotect(__func__);
4796
4797 return ret;
4798}
4799
4800/**
4801 * __iw_get_mode() - SIOCGIWMODE ioctl handler
4802 * @dev: device upon which the ioctl was received
4803 * @info: ioctl request information
4804 * @wrqu: ioctl request data
4805 * @extra: ioctl extra data
4806 *
4807 * Return: 0 on success, non-zero on error
4808 */
4809static int
4810__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4811 union iwreq_data *wrqu, char *extra)
4812{
4813 hdd_wext_state_t *pWextState;
Jeff Johnson3d278b02017-08-29 14:17:47 -07004814 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004815 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004816 int ret;
4817
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004818 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004819
4820 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4821 ret = wlan_hdd_validate_context(hdd_ctx);
4822 if (0 != ret)
4823 return ret;
4824
Jeff Johnson441e1f72017-02-07 08:50:49 -08004825 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4826 if (0 != ret)
4827 return ret;
4828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4830
4831 switch (pWextState->roamProfile.BSSType) {
4832 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004833 hdd_debug("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004834 wrqu->mode = IW_MODE_INFRA;
4835 break;
4836 case eCSR_BSS_TYPE_IBSS:
4837 case eCSR_BSS_TYPE_START_IBSS:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004838 hdd_debug("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839 wrqu->mode = IW_MODE_ADHOC;
4840 break;
4841 case eCSR_BSS_TYPE_ANY:
4842 default:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004843 hdd_debug("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004844 wrqu->mode = IW_MODE_AUTO;
4845 break;
4846 }
4847
4848 EXIT();
4849 return 0;
4850}
4851
4852/**
4853 * iw_get_mode() - SSR wrapper for __iw_get_mode()
4854 * @dev: pointer to net_device
4855 * @info: pointer to iw_request_info
4856 * @wrqu: pointer to iwreq_data
4857 * @extra: pointer to extra ioctl payload
4858 *
4859 * Return: 0 on success, error number otherwise
4860 */
4861static int iw_get_mode(struct net_device *dev, 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_get_mode(dev, info, wrqu, extra);
4868 cds_ssr_unprotect(__func__);
4869
4870 return ret;
4871}
4872
4873/**
4874 * __iw_set_freq() - SIOCSIWFREQ 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_set_freq(struct net_device *dev, struct iw_request_info *info,
4883 union iwreq_data *wrqu, char *extra)
4884{
4885 uint32_t numChans = 0;
4886 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4887 uint32_t indx = 0;
4888 int ret;
4889 hdd_wext_state_t *pWextState;
Jeff Johnson3d278b02017-08-29 14:17:47 -07004890 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004891 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004892 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07004893 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004894 tCsrRoamProfile *pRoamProfile;
4895
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004896 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004897
4898 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4899 ret = wlan_hdd_validate_context(hdd_ctx);
4900 if (0 != ret)
4901 return ret;
4902
Jeff Johnson441e1f72017-02-07 08:50:49 -08004903 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4904 if (0 != ret)
4905 return ret;
4906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4908
4909 pRoamProfile = &pWextState->roamProfile;
4910
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 /* Link is up then return cant set channel */
4912 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState ||
4913 eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004914 hdd_debug("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004915 return -EOPNOTSUPP;
4916 }
4917
4918 /* Settings by Frequency as input */
4919 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
4920 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
4921 uint32_t freq = wrqu->freq.m / 100000;
4922
4923 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
4924 && (freq != freq_chan_map[indx].freq))
4925 indx++;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004926 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004928
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 wrqu->freq.e = 0;
4930 wrqu->freq.m = freq_chan_map[indx].chan;
4931
4932 }
4933
4934 if (wrqu->freq.e == 0) {
4935 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
4936 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004937 hdd_debug("Channel %d is not in range[%d to %d]",
Jeff Johnson99bac312016-06-28 10:38:18 -07004938 wrqu->freq.m,
4939 WNI_CFG_CURRENT_CHANNEL_STAMIN,
4940 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 return -EINVAL;
4942 }
4943
4944 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4945
4946 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
4947 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304948 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004949 hdd_err("WNI_CFG_VALID_CHANNEL_LIST failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 return -EIO;
4951 }
4952
4953 for (indx = 0; indx < numChans; indx++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004954 if (wrqu->freq.m == validChan[indx])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004956 }
4957 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958 return -EINVAL;
4959 }
4960
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004961 if (indx >= numChans)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004963
4964 /* Set the Operational Channel */
4965 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
4966 pHddStaCtx->conn_info.operationChannel = wrqu->freq.m;
4967 pRoamProfile->ChannelInfo.ChannelList =
4968 &pHddStaCtx->conn_info.operationChannel;
4969
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004970 hdd_debug("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971
4972 EXIT();
4973
4974 return ret;
4975}
4976
4977/**
4978 * iw_set_freq() - SSR wrapper for __iw_set_freq()
4979 * @dev: pointer to net_device
4980 * @info: pointer to iw_request_info
4981 * @wrqu: pointer to iwreq_data
4982 * @extra: pointer to extra ioctl payload
4983 *
4984 * Return: 0 on success, error number otherwise
4985 */
4986static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4987 union iwreq_data *wrqu, char *extra)
4988{
4989 int ret;
4990
4991 cds_ssr_protect(__func__);
4992 ret = __iw_set_freq(dev, info, wrqu, extra);
4993 cds_ssr_unprotect(__func__);
4994
4995 return ret;
4996}
4997
4998/**
4999 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
5000 * @dev: device upon which the ioctl was received
5001 * @info: ioctl request information
5002 * @wrqu: ioctl request data
5003 * @extra: ioctl extra data
5004 *
5005 * Return: 0 on success, non-zero on error
5006 */
5007static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
5008 struct iw_freq *fwrq, char *extra)
5009{
5010 uint32_t status = false, channel = 0, freq = 0;
Jeff Johnson3d278b02017-08-29 14:17:47 -07005011 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005012 tHalHandle hHal;
5013 hdd_wext_state_t *pWextState;
5014 tCsrRoamProfile *pRoamProfile;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07005015 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005016 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 int ret;
5018
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005019 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005020
5021 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5022 ret = wlan_hdd_validate_context(hdd_ctx);
5023 if (0 != ret)
5024 return ret;
5025
Jeff Johnson441e1f72017-02-07 08:50:49 -08005026 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5027 if (0 != ret)
5028 return ret;
5029
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5031 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5032
5033 pRoamProfile = &pWextState->roamProfile;
5034
5035 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005036 if (sme_get_operation_channel(hHal, &channel,
5037 pAdapter->sessionId) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005038 hdd_err("failed to get operating channel %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005039 pAdapter->sessionId);
5040 return -EIO;
Jeff Johnson68755312017-02-10 11:46:55 -08005041 }
Jeff Johnson68755312017-02-10 11:46:55 -08005042 status = hdd_wlan_get_freq(channel, &freq);
5043 if (true == status) {
5044 /* Set Exponent parameter as 6 (MHZ)
5045 * in struct iw_freq iwlist & iwconfig
5046 * command shows frequency into proper
5047 * format (2.412 GHz instead of 246.2
5048 * MHz)
5049 */
5050 fwrq->m = freq;
5051 fwrq->e = MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005052 }
5053 } else {
5054 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
5055 * iwlist & iwconfig command shows frequency into proper
5056 * format (2.412 GHz instead of 246.2 MHz)
5057 */
5058 fwrq->m = 0;
5059 fwrq->e = MHZ;
5060 }
5061 return 0;
5062}
5063
5064/**
5065 * iw_get_freq() - SSR wrapper for __iw_get_freq()
5066 * @dev: pointer to net_device
5067 * @info: pointer to iw_request_info
5068 * @fwrq: pointer to frequency data
5069 * @extra: pointer to extra ioctl payload
5070 *
5071 * Return: 0 on success, error number otherwise
5072 */
5073static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
5074 struct iw_freq *fwrq, char *extra)
5075{
5076 int ret;
5077
5078 cds_ssr_protect(__func__);
5079 ret = __iw_get_freq(dev, info, fwrq, extra);
5080 cds_ssr_unprotect(__func__);
5081
5082 return ret;
5083}
5084
5085/**
5086 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
5087 * @dev: device upon which the ioctl was received
5088 * @info: ioctl request information
5089 * @wrqu: ioctl request data
5090 * @extra: ioctl extra data
5091 *
5092 * Return: 0 on success, non-zero on error
5093 */
5094static int __iw_get_tx_power(struct net_device *dev,
5095 struct iw_request_info *info,
5096 union iwreq_data *wrqu, char *extra)
5097{
5098
Jeff Johnson3d278b02017-08-29 14:17:47 -07005099 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005100 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07005101 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005102 int ret;
5103
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005104 ENTER_DEV(dev);
5105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106 ret = wlan_hdd_validate_context(hdd_ctx);
5107 if (0 != ret)
5108 return ret;
5109
Jeff Johnson441e1f72017-02-07 08:50:49 -08005110 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5111 if (0 != ret)
5112 return ret;
5113
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005114 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
5115 wrqu->txpower.value = 0;
5116 return 0;
5117 }
5118 wlan_hdd_get_class_astats(pAdapter);
5119 wrqu->txpower.value = pAdapter->hdd_stats.ClassA_stat.max_pwr;
5120
5121 return 0;
5122}
5123
5124/**
5125 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
5126 * @dev: pointer to net_device
5127 * @info: pointer to iw_request_info
5128 * @wrqu: pointer to iwreq_data
5129 * @extra: pointer to extra ioctl payload
5130 *
5131 * Return: 0 on success, error number otherwise
5132 */
5133static int iw_get_tx_power(struct net_device *dev,
5134 struct iw_request_info *info,
5135 union iwreq_data *wrqu, char *extra)
5136{
5137 int ret;
5138
5139 cds_ssr_protect(__func__);
5140 ret = __iw_get_tx_power(dev, info, wrqu, extra);
5141 cds_ssr_unprotect(__func__);
5142
5143 return ret;
5144}
5145
5146/**
5147 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
5148 * @dev: device upon which the ioctl was received
5149 * @info: ioctl request information
5150 * @wrqu: ioctl request data
5151 * @extra: ioctl extra data
5152 *
5153 * Return: 0 on success, non-zero on error
5154 */
5155static int __iw_set_tx_power(struct net_device *dev,
5156 struct iw_request_info *info,
5157 union iwreq_data *wrqu, char *extra)
5158{
Jeff Johnson3d278b02017-08-29 14:17:47 -07005159 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005161 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162 int ret;
5163
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005164 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165
5166 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5167 ret = wlan_hdd_validate_context(hdd_ctx);
5168 if (0 != ret)
5169 return ret;
5170
Jeff Johnson441e1f72017-02-07 08:50:49 -08005171 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5172 if (0 != ret)
5173 return ret;
5174
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305176 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005177 hdd_err("WNI_CFG_CURRENT_TX_POWER_LEVEL failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005178 return -EIO;
5179 }
5180
5181 EXIT();
5182
5183 return 0;
5184}
5185
5186/**
5187 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
5188 * @dev: pointer to net_device
5189 * @info: pointer to iw_request_info
5190 * @wrqu: pointer to iwreq_data
5191 * @extra: pointer to extra ioctl payload
5192 *
5193 * Return: 0 on success, error number otherwise
5194 */
5195static int iw_set_tx_power(struct net_device *dev,
5196 struct iw_request_info *info,
5197 union iwreq_data *wrqu, char *extra)
5198{
5199 int ret;
5200
5201 cds_ssr_protect(__func__);
5202 ret = __iw_set_tx_power(dev, info, wrqu, extra);
5203 cds_ssr_unprotect(__func__);
5204
5205 return ret;
5206}
5207
5208/**
5209 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
5210 * @dev: device upon which the ioctl was received
5211 * @info: ioctl request information
5212 * @wrqu: ioctl request data
5213 * @extra: ioctl extra data
5214 *
5215 * Return: 0 on success, non-zero on error
5216 */
5217static int __iw_get_bitrate(struct net_device *dev,
5218 struct iw_request_info *info,
5219 union iwreq_data *wrqu, char *extra)
5220{
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005221 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222 hdd_wext_state_t *pWextState;
Jeff Johnson3d278b02017-08-29 14:17:47 -07005223 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07005224 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005225 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 int ret;
5227
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005228 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229
5230 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5231 ret = wlan_hdd_validate_context(hdd_ctx);
5232 if (0 != ret)
5233 return ret;
5234
Jeff Johnson441e1f72017-02-07 08:50:49 -08005235 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5236 if (0 != ret)
5237 return ret;
5238
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
5240 wrqu->bitrate.value = 0;
5241 } else {
5242 status =
5243 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
5244 eCSR_HDD,
5245 SME_SUMMARY_STATS |
5246 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -08005247 SME_GLOBAL_CLASSD_STATS,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07005248 hdd_statistics_cb,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 pHddStaCtx->conn_info.staId[0],
5250 pAdapter, pAdapter->sessionId);
5251
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305252 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005253 hdd_err("Unable to retrieve statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005254 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 }
5256
5257 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5258
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005259 status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305260 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005261 WLAN_WAIT_TIME_STATS);
5262
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005263 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005264 hdd_err("SME timeout while retrieving statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005265 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005266 }
5267
5268 wrqu->bitrate.value =
5269 pAdapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
5270 }
5271
5272 EXIT();
5273
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005274 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275}
5276
5277/**
5278 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
5279 * @dev: pointer to net_device
5280 * @info: pointer to iw_request_info
5281 * @wrqu: pointer to iwreq_data
5282 * @extra: pointer to extra ioctl payload
5283 *
5284 * Return: 0 on success, error number otherwise
5285 */
5286static int iw_get_bitrate(struct net_device *dev,
5287 struct iw_request_info *info,
5288 union iwreq_data *wrqu, char *extra)
5289{
5290 int ret;
5291
5292 cds_ssr_protect(__func__);
5293 ret = __iw_get_bitrate(dev, info, wrqu, extra);
5294 cds_ssr_unprotect(__func__);
5295
5296 return ret;
5297}
5298
5299/**
5300 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
5301 * @dev: device upon which the ioctl was received
5302 * @info: ioctl request information
5303 * @wrqu: ioctl request data
5304 * @extra: ioctl extra data
5305 *
5306 * Return: 0 on success, non-zero on error
5307 */
5308static int __iw_set_bitrate(struct net_device *dev,
5309 struct iw_request_info *info,
5310 union iwreq_data *wrqu, char *extra)
5311{
Jeff Johnson3d278b02017-08-29 14:17:47 -07005312 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005313 hdd_wext_state_t *pWextState;
Jeff Johnson40dae4e2017-08-29 14:00:25 -07005314 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
5316 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5317 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5318 uint32_t i, rate;
5319 uint32_t valid_rate = false, active_phy_mode = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005320 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 int ret;
5322
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005323 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324
5325 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5326 ret = wlan_hdd_validate_context(hdd_ctx);
5327 if (0 != ret)
5328 return ret;
5329
Jeff Johnson441e1f72017-02-07 08:50:49 -08005330 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5331 if (0 != ret)
5332 return ret;
5333
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005334 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5335
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005336 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338
5339 rate = wrqu->bitrate.value;
5340
5341 if (rate == -1) {
5342 rate = WNI_CFG_FIXED_RATE_AUTO;
5343 valid_rate = true;
5344 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
5345 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305346 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5348 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
5349 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
5350 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
5351 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305352 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 &&
5354 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(pAdapter),
5355 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305356 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357 for (i = 0; i < (b_len + a_len); ++i) {
5358 /* supported rates returned is double
5359 * the actual rate so we divide it by 2
5360 */
5361 if ((supp_rates[i] & 0x7F) / 2 ==
5362 rate) {
5363 valid_rate = true;
5364 rate = i +
5365 WNI_CFG_FIXED_RATE_1MBPS;
5366 break;
5367 }
5368 }
5369 }
5370 }
5371 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005372 if (valid_rate != true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005373 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005374
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005375 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(pAdapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305376 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005377 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378 return -EIO;
5379 }
5380 return 0;
5381}
5382
5383/**
5384 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
5385 * @dev: pointer to net_device
5386 * @info: pointer to iw_request_info
5387 * @wrqu: pointer to iwreq_data
5388 * @extra: pointer to extra ioctl payload
5389 *
5390 * Return: 0 on success, error number otherwise
5391 */
5392static int iw_set_bitrate(struct net_device *dev,
5393 struct iw_request_info *info,
5394 union iwreq_data *wrqu, char *extra)
5395{
5396 int ret;
5397
5398 cds_ssr_protect(__func__);
5399 ret = __iw_set_bitrate(dev, info, wrqu, extra);
5400 cds_ssr_unprotect(__func__);
5401
5402 return ret;
5403}
5404
5405/**
5406 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
5407 * @dev: device upon which the ioctl was received
5408 * @info: ioctl request information
5409 * @wrqu: ioctl request data
5410 * @extra: ioctl extra data
5411 *
5412 * Return: 0 on success, non-zero on error
5413 */
5414static int __iw_set_genie(struct net_device *dev,
5415 struct iw_request_info *info,
5416 union iwreq_data *wrqu, char *extra)
5417{
Jeff Johnson3d278b02017-08-29 14:17:47 -07005418 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5420 uint8_t *genie = NULL;
5421 uint8_t *base_genie = NULL;
5422 uint16_t remLen;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005423 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424 int ret;
5425
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005426 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005427
5428 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5429 ret = wlan_hdd_validate_context(hdd_ctx);
5430 if (0 != ret)
5431 return ret;
5432
Jeff Johnson441e1f72017-02-07 08:50:49 -08005433 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5434 if (0 != ret)
5435 return ret;
5436
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005437 if (!wrqu->data.length) {
5438 hdd_clear_roam_profile_ie(pAdapter);
5439 EXIT();
5440 return 0;
5441 }
5442
5443 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
5444 wrqu->data.length);
5445 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005446 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 return -ENOMEM;
5448 }
5449
5450 genie = base_genie;
5451
5452 remLen = wrqu->data.length;
5453
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005454 hdd_debug("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455 genie[1]);
5456
5457 /* clear any previous genIE before this call */
5458 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5459
5460 while (remLen >= 2) {
5461 uint16_t eLen = 0;
5462 uint8_t elementId;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005464 elementId = *genie++;
5465 eLen = *genie++;
5466 remLen -= 2;
5467
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005468 hdd_debug("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005469
Srinivas Girigowda9eb807b2017-01-06 11:08:28 -08005470 if (remLen < eLen) {
5471 hdd_err("Remaining len: %u less than ie len: %u",
5472 remLen, eLen);
5473 ret = -EINVAL;
5474 goto exit;
5475 }
5476
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477 switch (elementId) {
5478 case IE_EID_VENDOR:
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005479 /* should have at least OUI */
5480 if ((IE_LEN_SIZE + IE_EID_SIZE + IE_VENDOR_OUI_SIZE) > eLen) {
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305481 ret = -EINVAL;
5482 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483 }
5484
5485 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
5486 uint16_t curGenIELen = pWextState->genIE.length;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005487
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005488 hdd_debug("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
Jeff Johnson99bac312016-06-28 10:38:18 -07005489 genie[0], genie[1], genie[2],
5490 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491
5492 if (SIR_MAC_MAX_IE_LENGTH <
5493 (pWextState->genIE.length + eLen)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005494 hdd_err("genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305495 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305496 ret = -ENOMEM;
5497 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005498 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005499 /* save to Additional IE; it should be
5500 * accumulated to handle WPS IE + other IE
5501 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 memcpy(pWextState->genIE.addIEdata +
5503 curGenIELen, genie - 2, eLen + 2);
5504 pWextState->genIE.length += eLen + 2;
5505 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005506 hdd_debug("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305507 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005508 hdd_err("genIE, Need bigger buffer space");
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305509 ret = -EINVAL;
5510 QDF_ASSERT(0);
5511 goto exit;
5512 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005513 memset(pWextState->WPARSNIE, 0,
5514 MAX_WPA_RSN_IE_LEN);
5515 memcpy(pWextState->WPARSNIE, genie - 2,
5516 (eLen + 2));
5517 pWextState->roamProfile.pWPAReqIE =
5518 pWextState->WPARSNIE;
5519 pWextState->roamProfile.nWPAReqIELength =
5520 eLen + 2;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005521 } else {
5522 /* any vendorId except WPA IE should
5523 * be accumulated to genIE
5524 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005525 uint16_t curGenIELen = pWextState->genIE.length;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005526
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005527 hdd_debug("Set OUI(%02x %02x %02x %02x) IE(len %d)",
Jeff Johnson99bac312016-06-28 10:38:18 -07005528 genie[0], genie[1], genie[2],
5529 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530
5531 if (SIR_MAC_MAX_IE_LENGTH <
5532 (pWextState->genIE.length + eLen)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005533 hdd_err("genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305534 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305535 ret = -ENOMEM;
5536 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005537 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005538 /* save to Additional IE; it should be
5539 * accumulated to handle WPS IE + other IE
5540 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541 memcpy(pWextState->genIE.addIEdata +
5542 curGenIELen, genie - 2, eLen + 2);
5543 pWextState->genIE.length += eLen + 2;
5544 }
5545 break;
5546 case DOT11F_EID_RSN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005547 hdd_debug("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305548 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005549 hdd_err("genIE, Need bigger buffer space");
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305550 ret = -EINVAL;
5551 QDF_ASSERT(0);
5552 goto exit;
5553 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
5555 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
5556 pWextState->roamProfile.pRSNReqIE =
5557 pWextState->WPARSNIE;
5558 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
5559 break;
5560
5561 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005562 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305563 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005564 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 remLen -= eLen;
Srinivas Girigowda9eb807b2017-01-06 11:08:28 -08005566
5567 /* Move genie only if next element is present */
5568 if (remLen >= 2)
5569 genie += eLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305571exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07005573 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305574 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575}
5576
5577/**
5578 * iw_set_genie() - SSR wrapper for __iw_set_genie()
5579 * @dev: pointer to net_device
5580 * @info: pointer to iw_request_info
5581 * @wrqu: pointer to iwreq_data
5582 * @extra: pointer to extra ioctl payload
5583 *
5584 * Return: 0 on success, error number otherwise
5585 */
5586static int iw_set_genie(struct net_device *dev,
5587 struct iw_request_info *info,
5588 union iwreq_data *wrqu, char *extra)
5589{
5590 int ret;
5591
5592 cds_ssr_protect(__func__);
5593 ret = __iw_set_genie(dev, info, wrqu, extra);
5594 cds_ssr_unprotect(__func__);
5595
5596 return ret;
5597}
5598
5599/**
5600 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
5601 * @dev: device upon which the ioctl was received
5602 * @info: ioctl request information
5603 * @wrqu: ioctl request data
5604 * @extra: ioctl extra data
5605 *
5606 * Return: 0 on success, non-zero on error
5607 */
5608static int __iw_get_genie(struct net_device *dev,
5609 struct iw_request_info *info,
5610 union iwreq_data *wrqu, char *extra)
5611{
5612 hdd_wext_state_t *pWextState;
Jeff Johnson3d278b02017-08-29 14:17:47 -07005613 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07005614 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305615 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
5617 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005618 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 int ret;
5620
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005621 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005622
5623 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5624 ret = wlan_hdd_validate_context(hdd_ctx);
5625 if (0 != ret)
5626 return ret;
5627
Jeff Johnson441e1f72017-02-07 08:50:49 -08005628 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5629 if (0 != ret)
5630 return ret;
5631
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005632 hdd_debug("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005633
5634 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5635
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005636 if (pHddStaCtx->conn_info.connState == eConnectionState_NotConnected)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005638
5639 /* Return something ONLY if we are associated with an RSN or
5640 * WPA network
5641 */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005642 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644
5645 /* Actually retrieve the RSN IE from CSR. (We previously sent
5646 * it down in the CSR Roam Profile.)
5647 */
5648 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(pAdapter),
5649 pAdapter->sessionId,
5650 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305651 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005652 hdd_err("Failed to get WPA-RSN IE data status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653 return -EFAULT;
5654 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005655 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05305656 if (length > DOT11F_IE_RSN_MAX_LEN) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005657 hdd_err("Invalid buffer length: %d", length);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305658 return -E2BIG;
5659 }
5660 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005662 hdd_debug("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 wrqu->data.length);
5664
5665 EXIT();
5666
5667 return 0;
5668}
5669
5670/**
5671 * iw_get_genie() - SSR wrapper for __iw_get_genie()
5672 * @dev: pointer to net_device
5673 * @info: pointer to iw_request_info
5674 * @wrqu: pointer to iwreq_data
5675 * @extra: pointer to extra ioctl payload
5676 *
5677 * Return: 0 on success, error number otherwise
5678 */
5679static int iw_get_genie(struct net_device *dev,
5680 struct iw_request_info *info,
5681 union iwreq_data *wrqu, char *extra)
5682{
5683 int ret;
5684
5685 cds_ssr_protect(__func__);
5686 ret = __iw_get_genie(dev, info, wrqu, extra);
5687 cds_ssr_unprotect(__func__);
5688
5689 return ret;
5690}
5691
5692/**
5693 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
5694 * @dev: device upon which the ioctl was received
5695 * @info: ioctl request information
5696 * @wrqu: ioctl request data
5697 * @extra: ioctl extra data
5698 *
5699 * Return: 0 on success, non-zero on error
5700 */
5701static int __iw_get_encode(struct net_device *dev,
5702 struct iw_request_info *info,
5703 struct iw_point *dwrq, char *extra)
5704{
Jeff Johnson3d278b02017-08-29 14:17:47 -07005705 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5707 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5708 int keyId;
5709 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
5710 int i;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005711 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005712 int ret;
5713
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005714 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005715
5716 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5717 ret = wlan_hdd_validate_context(hdd_ctx);
5718 if (0 != ret)
5719 return ret;
5720
Jeff Johnson441e1f72017-02-07 08:50:49 -08005721 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5722 if (0 != ret)
5723 return ret;
5724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725 keyId = pRoamProfile->Keys.defaultIndex;
5726
5727 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005728 hdd_err("Invalid keyId: %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729 return -EINVAL;
5730 }
5731
5732 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
5733 dwrq->flags |= IW_ENCODE_ENABLED;
5734 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305735 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736 pRoamProfile->Keys.KeyLength[keyId]);
5737
5738 dwrq->flags |= (keyId + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005739 } else {
5740 dwrq->flags |= IW_ENCODE_DISABLED;
5741 }
5742
5743 for (i = 0; i < MAX_WEP_KEYS; i++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005744 if (pRoamProfile->Keys.KeyLength[i] == 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005745 continue;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005746 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 }
5749
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005750 if (MAX_WEP_KEYS == i)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005751 dwrq->flags |= IW_ENCODE_NOKEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752
5753 authType =
Jeff Johnson40dae4e2017-08-29 14:00:25 -07005754 ((struct hdd_station_ctx *) WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 conn_info.authType;
5756
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005757 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 dwrq->flags |= IW_ENCODE_OPEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005759 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005760 dwrq->flags |= IW_ENCODE_RESTRICTED;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005761
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762 EXIT();
5763 return 0;
5764}
5765
5766/**
5767 * iw_get_encode() - SSR wrapper for __iw_get_encode()
5768 * @dev: pointer to net_device
5769 * @info: pointer to iw_request_info
5770 * @dwrq: pointer to encoding information
5771 * @extra: pointer to extra ioctl payload
5772 *
5773 * Return: 0 on success, error number otherwise
5774 */
5775static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
5776 struct iw_point *dwrq, char *extra)
5777{
5778 int ret;
5779
5780 cds_ssr_protect(__func__);
5781 ret = __iw_get_encode(dev, info, dwrq, extra);
5782 cds_ssr_unprotect(__func__);
5783
5784 return ret;
5785}
5786
5787/**
5788 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
5789 * @dev: device upon which the ioctl was received
5790 * @info: ioctl request information
5791 * @wrqu: ioctl request data
5792 * @extra: ioctl extra data
5793 *
5794 * Return: 0 on success, non-zero on error
5795 */
5796static int __iw_get_rts_threshold(struct net_device *dev,
5797 struct iw_request_info *info,
5798 union iwreq_data *wrqu, char *extra)
5799{
Jeff Johnson3d278b02017-08-29 14:17:47 -07005800 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson5b907622017-02-07 10:00:37 -08005801 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5802 uint32_t threshold = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005803 struct hdd_context *hdd_ctx;
Jeff Johnson5b907622017-02-07 10:00:37 -08005804 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005805
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005806 ENTER_DEV(dev);
5807
Jeff Johnson5b907622017-02-07 10:00:37 -08005808 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5809 ret = wlan_hdd_validate_context(hdd_ctx);
5810 if (0 != ret)
5811 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812
Jeff Johnson441e1f72017-02-07 08:50:49 -08005813 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5814 if (0 != ret)
5815 return ret;
5816
Jeff Johnson5b907622017-02-07 10:00:37 -08005817 if (QDF_STATUS_SUCCESS !=
5818 sme_cfg_get_int(hal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
5819 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
5820 return -EIO;
5821 }
5822 wrqu->rts.value = threshold;
5823
5824 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
5825
5826 EXIT();
5827
5828 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005829}
5830
5831/**
5832 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
5833 * @dev: device upon which the ioctl was received
5834 * @info: ioctl request information
5835 * @wrqu: ioctl request data
5836 * @extra: ioctl extra data
5837 *
5838 * Return: 0 on success, non-zero on error
5839 */
5840static int __iw_set_rts_threshold(struct net_device *dev,
5841 struct iw_request_info *info,
5842 union iwreq_data *wrqu, char *extra)
5843{
Jeff Johnson3d278b02017-08-29 14:17:47 -07005844 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005845 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005846 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005847 int ret;
5848
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005849 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850
5851 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5852 ret = wlan_hdd_validate_context(hdd_ctx);
5853 if (0 != ret)
5854 return ret;
5855
Jeff Johnson441e1f72017-02-07 08:50:49 -08005856 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5857 if (0 != ret)
5858 return ret;
5859
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
5861 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
5862 return -EINVAL;
5863 }
5864
5865 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305866 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005867 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868 return -EIO;
5869 }
5870
5871 EXIT();
5872
5873 return 0;
5874}
5875
5876/**
5877 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
5878 * @dev: pointer to net_device
5879 * @info: pointer to iw_request_info
5880 * @wrqu: pointer to iwreq_data
5881 * @extra: pointer to extra ioctl payload
5882 *
5883 * Return: 0 on success, error number otherwise
5884 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005885int iw_get_rts_threshold(struct net_device *dev,
5886 struct iw_request_info *info,
5887 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005888{
5889 int ret;
5890
5891 cds_ssr_protect(__func__);
5892 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
5893 cds_ssr_unprotect(__func__);
5894
5895 return ret;
5896}
5897
5898/**
5899 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
5900 * @dev: pointer to net_device
5901 * @info: pointer to iw_request_info
5902 * @wrqu: pointer to iwreq_data
5903 * @extra: pointer to extra ioctl payload
5904 *
5905 * Return: 0 on success, error number otherwise
5906 */
5907static int iw_set_rts_threshold(struct net_device *dev,
5908 struct iw_request_info *info,
5909 union iwreq_data *wrqu, char *extra)
5910{
5911 int ret;
5912
5913 cds_ssr_protect(__func__);
5914 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
5915 cds_ssr_unprotect(__func__);
5916
5917 return ret;
5918}
5919
5920/**
5921 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
5922 * @dev: device upon which the ioctl was received
5923 * @info: ioctl request information
5924 * @wrqu: ioctl request data
5925 * @extra: ioctl extra data
5926 *
5927 * Return: 0 on success, non-zero on error
5928 */
5929static int __iw_get_frag_threshold(struct net_device *dev,
5930 struct iw_request_info *info,
5931 union iwreq_data *wrqu, char *extra)
5932{
Jeff Johnson3d278b02017-08-29 14:17:47 -07005933 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson5b907622017-02-07 10:00:37 -08005934 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5935 uint32_t threshold = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005936 struct hdd_context *hdd_ctx;
Jeff Johnson5b907622017-02-07 10:00:37 -08005937 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005939 ENTER_DEV(dev);
5940
Jeff Johnson5b907622017-02-07 10:00:37 -08005941 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5942 ret = wlan_hdd_validate_context(hdd_ctx);
5943 if (0 != ret)
5944 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945
Jeff Johnson441e1f72017-02-07 08:50:49 -08005946 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5947 if (0 != ret)
5948 return ret;
5949
Jeff Johnson5b907622017-02-07 10:00:37 -08005950 if (sme_cfg_get_int(hal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
5951 != QDF_STATUS_SUCCESS) {
5952 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
5953 return -EIO;
5954 }
5955 wrqu->frag.value = threshold;
5956
5957 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
5958
5959 EXIT();
5960
5961 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005962}
5963
5964/**
5965 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
5966 * @dev: pointer to net_device
5967 * @info: pointer to iw_request_info
5968 * @wrqu: pointer to iwreq_data
5969 * @extra: pointer to extra ioctl payload
5970 *
5971 * Return: 0 on success, error number otherwise
5972 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005973int iw_get_frag_threshold(struct net_device *dev,
5974 struct iw_request_info *info,
5975 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005976{
5977 int ret;
5978
5979 cds_ssr_protect(__func__);
5980 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
5981 cds_ssr_unprotect(__func__);
5982
5983 return ret;
5984}
5985
5986/**
5987 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
5988 * @dev: device upon which the ioctl was received
5989 * @info: ioctl request information
5990 * @wrqu: ioctl request data
5991 * @extra: ioctl extra data
5992 *
5993 * Return: 0 on success, non-zero on error
5994 */
5995static int __iw_set_frag_threshold(struct net_device *dev,
5996 struct iw_request_info *info,
5997 union iwreq_data *wrqu, char *extra)
5998{
Jeff Johnson3d278b02017-08-29 14:17:47 -07005999 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006000 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006001 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006002 int ret;
6003
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006004 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006005
6006 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6007 ret = wlan_hdd_validate_context(hdd_ctx);
6008 if (0 != ret)
6009 return ret;
6010
Jeff Johnson441e1f72017-02-07 08:50:49 -08006011 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6012 if (0 != ret)
6013 return ret;
6014
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
6016 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
6017 return -EINVAL;
6018 }
6019
6020 if (sme_cfg_set_int
6021 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306022 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006023 hdd_err("WNI_CFG_FRAGMENTATION_THRESHOLD failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006024 return -EIO;
6025 }
6026
6027 EXIT();
6028
6029 return 0;
6030}
6031
6032/**
6033 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
6034 * @dev: pointer to net_device
6035 * @info: pointer to iw_request_info
6036 * @wrqu: pointer to iwreq_data
6037 * @extra: pointer to extra ioctl payload
6038 *
6039 * Return: 0 on success, error number otherwise
6040 */
6041static int iw_set_frag_threshold(struct net_device *dev,
6042 struct iw_request_info *info,
6043 union iwreq_data *wrqu, char *extra)
6044{
6045 int ret;
6046
6047 cds_ssr_protect(__func__);
6048 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
6049 cds_ssr_unprotect(__func__);
6050
6051 return ret;
6052}
6053
6054/**
6055 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
6056 * @dev: device upon which the ioctl was received
6057 * @info: ioctl request information
6058 * @wrqu: ioctl request data
6059 * @extra: ioctl extra data
6060 *
6061 * Return: 0 on success, non-zero on error
6062 */
6063static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07006064 struct iw_request_info *info,
6065 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006066{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006067 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006068 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006069 int ret;
6070
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006071 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006072
6073 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6074 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6075 ret = wlan_hdd_validate_context(hdd_ctx);
6076 if (0 != ret)
6077 return ret;
6078
Jeff Johnson441e1f72017-02-07 08:50:49 -08006079 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6080 if (0 != ret)
6081 return ret;
6082
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006083 return -EOPNOTSUPP;
6084}
6085
6086/**
6087 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
6088 * @dev: pointer to net_device
6089 * @info: pointer to iw_request_info
6090 * @wrqu: pointer to iwreq_data
6091 * @extra: extra
6092 *
6093 * Return: 0 on success, error number otherwise
6094 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07006095static int iw_get_power_mode(struct net_device *dev,
6096 struct iw_request_info *info,
6097 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098{
6099 int ret;
6100
6101 cds_ssr_protect(__func__);
6102 ret = __iw_get_power_mode(dev, info, wrqu, extra);
6103 cds_ssr_unprotect(__func__);
6104
6105 return ret;
6106}
6107
6108/**
6109 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
6110 * @dev: device upon which the ioctl was received
6111 * @info: ioctl request information
6112 * @wrqu: ioctl request data
6113 * @extra: ioctl extra data
6114 *
6115 * Return: 0 on success, non-zero on error
6116 */
6117static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07006118 struct iw_request_info *info,
6119 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006121 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006122 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123 int ret;
6124
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006125 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126
6127 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6128 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6129 ret = wlan_hdd_validate_context(hdd_ctx);
6130 if (0 != ret)
6131 return ret;
6132
Jeff Johnson441e1f72017-02-07 08:50:49 -08006133 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6134 if (0 != ret)
6135 return ret;
6136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006137 return -EOPNOTSUPP;
6138}
6139
6140/**
6141 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
6142 * @dev: pointer to net_device
6143 * @info: pointer to iw_request_info
6144 * @wrqu: pointer to iwreq_data
6145 * @extra: extra
6146 *
6147 * Return: 0 on success, error number otherwise
6148 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07006149static int iw_set_power_mode(struct net_device *dev,
6150 struct iw_request_info *info,
6151 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006152{
6153 int ret;
6154
6155 cds_ssr_protect(__func__);
6156 ret = __iw_set_power_mode(dev, info, wrqu, extra);
6157 cds_ssr_unprotect(__func__);
6158
6159 return ret;
6160}
6161
6162/**
6163 * __iw_get_range() - SIOCGIWRANGE ioctl handler
6164 * @dev: device upon which the ioctl was received
6165 * @info: ioctl request information
6166 * @wrqu: ioctl request data
6167 * @extra: ioctl extra data
6168 *
6169 * Return: 0 on success, non-zero on error
6170 */
6171static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
6172 union iwreq_data *wrqu, char *extra)
6173{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006174 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006175 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6176 struct iw_range *range = (struct iw_range *)extra;
6177
6178 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6179
6180 uint32_t num_channels = sizeof(channels);
6181 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
6182 uint32_t a_len;
6183 uint32_t b_len;
6184 uint32_t active_phy_mode = 0;
6185 uint8_t index = 0, i;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006186 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006187 int ret;
6188
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006189 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006190
6191 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6192 ret = wlan_hdd_validate_context(hdd_ctx);
6193 if (0 != ret)
6194 return ret;
6195
Jeff Johnson441e1f72017-02-07 08:50:49 -08006196 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6197 if (0 != ret)
6198 return ret;
6199
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006200 wrqu->data.length = sizeof(struct iw_range);
6201 memset(range, 0, sizeof(struct iw_range));
6202
6203
6204 /*Get the phy mode */
6205 if (sme_cfg_get_int(hHal,
6206 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306207 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006208 hdd_debug("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006209
6210 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
6211 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
6212 /*Get the supported rates for 11G band */
6213 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
6214 if (sme_cfg_get_str(hHal,
6215 WNI_CFG_SUPPORTED_RATES_11A,
6216 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306217 &a_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006218 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006219 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006220
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006221 for (i = 0; i < a_len; i++) {
6222 range->bitrate[i] =
6223 ((supp_rates[i] & 0x7F) / 2) *
6224 1000000;
6225 }
6226 range->num_bitrates = a_len;
6227 } else {
6228 return -EIO;
6229 }
6230 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
6231 /*Get the supported rates for 11B band */
6232 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
6233 if (sme_cfg_get_str(hHal,
6234 WNI_CFG_SUPPORTED_RATES_11B,
6235 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306236 &b_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006237 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006238 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006239
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006240 for (i = 0; i < b_len; i++) {
6241 range->bitrate[i] =
6242 ((supp_rates[i] & 0x7F) / 2) *
6243 1000000;
6244 }
6245 range->num_bitrates = b_len;
6246 } else {
6247 return -EIO;
6248 }
6249 }
6250 }
6251
6252 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
6253 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
6254 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
6255
6256 range->encoding_size[0] = 5;
6257 range->encoding_size[1] = 13;
6258 range->num_encoding_sizes = 2;
6259 range->max_encoding_tokens = MAX_WEP_KEYS;
6260
6261 /* we support through Wireless Extensions 22 */
6262 range->we_version_compiled = WIRELESS_EXT;
6263 range->we_version_source = 22;
6264
6265 /*Supported Channels and Frequencies */
6266 if (sme_cfg_get_str
6267 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306268 &num_channels) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006269 hdd_err("Failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006270 return -EIO;
6271 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006272 if (num_channels > IW_MAX_FREQUENCIES)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006273 num_channels = IW_MAX_FREQUENCIES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006274
6275 range->num_channels = num_channels;
6276 range->num_frequency = num_channels;
6277
6278 for (index = 0; index < num_channels; index++) {
6279 uint32_t frq_indx = 0;
6280
6281 range->freq[index].i = channels[index];
6282 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
6283 if (channels[index] == freq_chan_map[frq_indx].chan) {
6284 range->freq[index].m =
6285 freq_chan_map[frq_indx].freq * 100000;
6286 range->freq[index].e = 1;
6287 break;
6288 }
6289 frq_indx++;
6290 }
6291 }
6292
6293 /* Event capability (kernel + driver) */
6294 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
6295 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
6296 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
6297 range->event_capa[1] = IW_EVENT_CAPA_K_1;
6298
6299 /*Encryption capability */
6300 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
6301 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
6302
6303 /* Txpower capability */
6304 range->txpower_capa = IW_TXPOW_MWATT;
6305
6306 /*Scanning capability */
6307#if WIRELESS_EXT >= 22
6308 range->scan_capa =
6309 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
6310#endif
6311
6312 EXIT();
6313 return 0;
6314}
6315
6316/**
6317 * iw_get_range() - SSR wrapper for __iw_get_range()
6318 * @dev: pointer to net_device
6319 * @info: pointer to iw_request_info
6320 * @wrqu: pointer to iwreq_data
6321 * @extra: pointer to extra ioctl payload
6322 *
6323 * Return: 0 on success, error number otherwise
6324 */
6325static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
6326 union iwreq_data *wrqu, char *extra)
6327{
6328 int ret;
6329
6330 cds_ssr_protect(__func__);
6331 ret = __iw_get_range(dev, info, wrqu, extra);
6332 cds_ssr_unprotect(__func__);
6333
6334 return ret;
6335}
6336
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006337struct class_a_stats {
6338 tCsrGlobalClassAStatsInfo class_a_stats;
6339};
6340
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006341/**
6342 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006343 * @stats: pointer to Class A stats
6344 * @context: user context originally registered with SME (always the
6345 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006346 *
6347 * Return: None
6348 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006349static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006350{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006351 struct hdd_request *request;
6352 struct class_a_stats *priv;
6353 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006354
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006355 ENTER();
6356 if ((NULL == stats) || (NULL == context)) {
6357 hdd_err("Bad param, stats [%p] context [%p]",
6358 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006359 return;
6360 }
6361
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006362 request = hdd_request_get(context);
6363 if (!request) {
6364 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006365 return;
6366 }
6367
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006368 returned_stats = stats;
6369 priv = hdd_request_priv(request);
6370 priv->class_a_stats = *returned_stats;
6371 hdd_request_complete(request);
6372 hdd_request_put(request);
6373 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006374}
6375
6376/**
6377 * wlan_hdd_get_class_astats() - Get Class A statistics
6378 * @pAdapter: adapter for which statistics are desired
6379 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306380 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006381 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07006382QDF_STATUS wlan_hdd_get_class_astats(struct hdd_adapter *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006383{
Jeff Johnson40dae4e2017-08-29 14:00:25 -07006384 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306385 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006386 int ret;
6387 void *cookie;
6388 struct hdd_request *request;
6389 struct class_a_stats *priv;
6390 static const struct hdd_request_params params = {
6391 .priv_size = sizeof(*priv),
6392 .timeout_ms = WLAN_WAIT_TIME_STATS,
6393 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006394
6395 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006396 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306397 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006398 }
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +05306399 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006400 hdd_debug("Recovery in Progress. State: 0x%x Ignore!!!",
Prashanth Bhatta9e143052015-12-04 11:56:47 -08006401 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306402 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006403 }
6404
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006405 request = hdd_request_alloc(&params);
6406 if (!request) {
6407 hdd_err("Request allocation failure");
6408 return QDF_STATUS_E_NOMEM;
6409 }
6410 cookie = hdd_request_cookie(request);
6411
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006412 /* query only for Class A statistics (which include link speed) */
6413 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
6414 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
6415 hdd_get_class_a_statistics_cb,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006416 pHddStaCtx->conn_info.staId[0],
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006417 cookie, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306418 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07006419 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006420 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006421 }
6422
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006423 /* request was sent -- wait for the response */
6424 ret = hdd_request_wait_for_response(request);
6425 if (ret) {
6426 hdd_warn("SME timed out while retrieving Class A statistics");
6427 goto return_cached_results;
6428 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006429
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006430 /* update the adapter with the fresh results */
6431 priv = hdd_request_priv(request);
6432 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6433
6434return_cached_results:
6435 /*
6436 * either we never sent a request, we sent a request and
6437 * received a response or we sent a request and timed out.
6438 * regardless we are done with the request.
6439 */
6440 hdd_request_put(request);
6441
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306442 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006443}
6444
Jeff Johnsondda167c2017-01-23 10:37:57 -08006445struct station_stats {
6446 tCsrSummaryStatsInfo summary_stats;
6447 tCsrGlobalClassAStatsInfo class_a_stats;
6448 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
6449};
6450
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006451/**
6452 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08006453 * @stats: pointer to combined station stats
6454 * @context: user context originally registered with SME (always the
6455 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006456 *
6457 * Return: None
6458 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006459static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006460{
Jeff Johnsondda167c2017-01-23 10:37:57 -08006461 struct hdd_request *request;
6462 struct station_stats *priv;
6463 tCsrSummaryStatsInfo *summary_stats;
6464 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306465 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006466
Jeff Johnsondda167c2017-01-23 10:37:57 -08006467 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006468 hdd_err("Bad param, pStats [%p] pContext [%p]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08006469 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006470 return;
6471 }
6472
Jeff Johnsondda167c2017-01-23 10:37:57 -08006473 request = hdd_request_get(context);
6474 if (!request) {
6475 hdd_err("Obsolete request");
6476 return;
6477 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006478
Jeff Johnsondda167c2017-01-23 10:37:57 -08006479 summary_stats = (tCsrSummaryStatsInfo *) stats;
6480 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306481 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08006482 (class_a_stats + 1);
6483 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006484
6485 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006486 priv->summary_stats = *summary_stats;
6487 priv->class_a_stats = *class_a_stats;
6488 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489
Jeff Johnsondda167c2017-01-23 10:37:57 -08006490 hdd_request_complete(request);
6491 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006492}
6493
6494/**
6495 * wlan_hdd_get_station_stats() - Get station statistics
6496 * @pAdapter: adapter for which statistics are desired
6497 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306498 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006499 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07006500QDF_STATUS wlan_hdd_get_station_stats(struct hdd_adapter *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006501{
Jeff Johnson40dae4e2017-08-29 14:00:25 -07006502 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dustin Brown0f5260d2017-06-12 16:17:38 -07006503 QDF_STATUS status;
6504 int errno;
Jeff Johnsondda167c2017-01-23 10:37:57 -08006505 void *cookie;
6506 struct hdd_request *request;
6507 struct station_stats *priv;
6508 static const struct hdd_request_params params = {
6509 .priv_size = sizeof(*priv),
6510 .timeout_ms = WLAN_WAIT_TIME_STATS,
6511 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006512
6513 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07006514 hdd_err("pAdapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306515 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006516 }
6517
Jeff Johnsondda167c2017-01-23 10:37:57 -08006518 request = hdd_request_alloc(&params);
6519 if (!request) {
6520 hdd_err("Request allocation failure");
6521 return QDF_STATUS_E_NOMEM;
6522 }
6523 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006524
6525 /* query only for Summary & Class A statistics */
Dustin Brown0f5260d2017-06-12 16:17:38 -07006526 status = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(pAdapter),
6527 eCSR_HDD,
6528 SME_SUMMARY_STATS |
6529 SME_GLOBAL_CLASSA_STATS |
6530 SME_PER_CHAIN_RSSI_STATS,
6531 hdd_get_station_statistics_cb,
Dustin Brown0f5260d2017-06-12 16:17:38 -07006532 pHddStaCtx->conn_info.staId[0],
6533 cookie,
6534 pAdapter->sessionId);
6535 if (QDF_IS_STATUS_ERROR(status)) {
6536 hdd_err("Failed to retrieve statistics, status %d", status);
6537 goto put_request;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006538 }
6539
Dustin Brown0f5260d2017-06-12 16:17:38 -07006540 /* request was sent -- wait for the response */
6541 errno = hdd_request_wait_for_response(request);
6542 if (errno) {
6543 hdd_err("Failed to wait for statistics, errno %d", errno);
6544 goto put_request;
6545 }
6546
6547 /* update the adapter with the fresh results */
6548 priv = hdd_request_priv(request);
6549 pAdapter->hdd_stats.summary_stat = priv->summary_stats;
6550 pAdapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6551 pAdapter->hdd_stats.per_chain_rssi_stats = priv->per_chain_rssi_stats;
6552
6553put_request:
Jeff Johnsondda167c2017-01-23 10:37:57 -08006554 /*
6555 * either we never sent a request, we sent a request and
6556 * received a response or we sent a request and timed out.
6557 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006558 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006559 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006560
6561 /* either callback updated pAdapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306562 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006563}
6564
6565/**
6566 * iw_get_linkspeed() - Get current link speed ioctl
6567 * @dev: device upon which the ioctl was received
6568 * @info: ioctl request information
6569 * @wrqu: ioctl request data
6570 * @extra: extra ioctl buffer
6571 *
6572 * Return: 0 on success, non-zero on error
6573 */
6574static int __iw_get_linkspeed(struct net_device *dev,
6575 struct iw_request_info *info,
6576 union iwreq_data *wrqu, char *extra)
6577{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006578 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006579 char *pLinkSpeed = (char *)extra;
6580 int len = sizeof(uint32_t) + 1;
6581 uint32_t link_speed = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006582 struct hdd_context *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08006583 int ret;
6584 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006585
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006586 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306587
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006588 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08006589 ret = wlan_hdd_validate_context(hdd_ctx);
6590 if (0 != ret)
6591 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006592
Jeff Johnson441e1f72017-02-07 08:50:49 -08006593 ret = hdd_check_private_wext_control(hdd_ctx, info);
6594 if (0 != ret)
6595 return ret;
6596
6597 ret = wlan_hdd_get_link_speed(pAdapter, &link_speed);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006598 if (0 != ret)
Jeff Johnson441e1f72017-02-07 08:50:49 -08006599 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006600
6601 wrqu->data.length = len;
6602 /* return the linkspeed as a string */
6603 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
6604 if ((rc < 0) || (rc >= len)) {
6605 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07006606 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006607 return -EIO;
6608 }
6609
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306610 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006611 /* a value is being successfully returned */
6612 return 0;
6613}
6614
6615static int iw_get_linkspeed(struct net_device *dev,
6616 struct iw_request_info *info,
6617 union iwreq_data *wrqu, char *extra)
6618{
6619 int ret;
6620
6621 cds_ssr_protect(__func__);
6622 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
6623 cds_ssr_unprotect(__func__);
6624
6625 return ret;
6626}
6627
6628/**
6629 * wlan_hdd_change_country_code_callback() - Change country code callback
6630 * @context: opaque context originally passed to SME. All functions
6631 * which use this callback pass the adapter upon which the country
6632 * code change is active
6633 *
6634 * This function is registered as the callback function when
6635 * sme_change_country_code() is invoked. Callers of
6636 * sme_change_country_code() subsequently wait for the adapter's
6637 * @change_country_code completion variable, so all this function
6638 * needs to do is set that completion variable so that execution can
6639 * continue.
6640 *
6641 * Return: none
6642 */
6643void wlan_hdd_change_country_code_callback(void *context)
6644{
6645
Jeff Johnson3d278b02017-08-29 14:17:47 -07006646 struct hdd_adapter *adapter = context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006647
6648 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
6649 complete(&adapter->change_country_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006650}
6651
6652/**
6653 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
6654 * @dev: device upon which the ioctl was received
6655 * @info: ioctl request information
6656 * @wrqu: ioctl request data
6657 * @extra: ioctl extra data
6658 *
6659 * Return: 0 on success, non-zero on error
6660 */
6661static int __iw_set_nick(struct net_device *dev,
6662 struct iw_request_info *info,
6663 union iwreq_data *wrqu, char *extra)
6664{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006665 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006666 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006667 int ret;
6668
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006669 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006670
6671 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6672 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6673 ret = wlan_hdd_validate_context(hdd_ctx);
6674 if (0 != ret)
6675 return ret;
6676
Jeff Johnson441e1f72017-02-07 08:50:49 -08006677 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6678 if (0 != ret)
6679 return ret;
6680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006681 return 0;
6682}
6683
6684/**
6685 * iw_set_nick() - SSR wrapper for __iw_set_nick
6686 * @dev: pointer to net_device
6687 * @info: pointer to iw_request_info
6688 * @wrqu: pointer to iwreq_data
6689 * @extra: extra
6690 *
6691 * Return: 0 on success, error number otherwise
6692 */
6693static int iw_set_nick(struct net_device *dev,
6694 struct iw_request_info *info,
6695 union iwreq_data *wrqu, char *extra)
6696{
6697 int ret;
6698
6699 cds_ssr_protect(__func__);
6700 ret = __iw_set_nick(dev, info, wrqu, extra);
6701 cds_ssr_unprotect(__func__);
6702
6703 return ret;
6704}
6705
6706/**
6707 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
6708 * @dev: device upon which the ioctl was received
6709 * @info: ioctl request information
6710 * @wrqu: ioctl request data
6711 * @extra: ioctl extra data
6712 *
6713 * Return: 0 on success, non-zero on error
6714 */
6715static int __iw_get_nick(struct net_device *dev,
6716 struct iw_request_info *info,
6717 union iwreq_data *wrqu, char *extra)
6718{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006719 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006720 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006721 int ret;
6722
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006723 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006724
6725 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6726 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6727 ret = wlan_hdd_validate_context(hdd_ctx);
6728 if (0 != ret)
6729 return ret;
6730
Jeff Johnson441e1f72017-02-07 08:50:49 -08006731 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6732 if (0 != ret)
6733 return ret;
6734
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006735 return 0;
6736}
6737
6738/**
6739 * iw_get_nick() - SSR wrapper for __iw_get_nick
6740 * @dev: pointer to net_device
6741 * @info: pointer to iw_request_info
6742 * @wrqu: pointer to iwreq_data
6743 * @extra: extra
6744 *
6745 * Return: 0 on success, error number otherwise
6746 */
6747static int iw_get_nick(struct net_device *dev,
6748 struct iw_request_info *info,
6749 union iwreq_data *wrqu, char *extra)
6750{
6751 int ret;
6752
6753 cds_ssr_protect(__func__);
6754 ret = __iw_get_nick(dev, info, wrqu, extra);
6755 cds_ssr_unprotect(__func__);
6756
6757 return ret;
6758}
6759
6760/**
6761 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
6762 * @dev: device upon which the ioctl was received
6763 * @info: ioctl request information
6764 * @wrqu: ioctl request data
6765 * @extra: ioctl extra data
6766 *
6767 * Return: 0 on success, non-zero on error
6768 */
6769static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6770 union iwreq_data *wrqu, char *extra)
6771{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006772 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07006773 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006774 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006775 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006776 struct iw_point *encoderq = &(wrqu->encoding);
6777 uint32_t keyId;
6778 uint8_t key_length;
6779 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6780 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306781 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006782 int ret;
6783
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006784 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006785
6786 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6787 ret = wlan_hdd_validate_context(hdd_ctx);
6788 if (0 != ret)
6789 return ret;
6790
Jeff Johnson441e1f72017-02-07 08:50:49 -08006791 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6792 if (0 != ret)
6793 return ret;
6794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006795 keyId = encoderq->flags & IW_ENCODE_INDEX;
6796
6797 if (keyId) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006798 if (keyId > MAX_WEP_KEYS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006799 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006800
6801 fKeyPresent = 1;
6802 keyId--;
6803 } else {
6804 fKeyPresent = 0;
6805 }
6806
6807 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006808 hdd_debug("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006810 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
6811 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006812 }
6813 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6814 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6815 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6816 eCSR_ENCRYPT_TYPE_NONE;
6817 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6818 eCSR_ENCRYPT_TYPE_NONE;
6819
6820 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6821 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6822
6823 if (eConnectionState_Associated ==
6824 pHddStaCtx->conn_info.connState) {
6825 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6826 status =
6827 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
6828 pAdapter->sessionId,
6829 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306830 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006831 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006833 rc = wait_for_completion_timeout(&pAdapter->
6834 disconnect_comp_var,
6835 msecs_to_jiffies
6836 (WLAN_WAIT_TIME_DISCONNECT));
6837 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006838 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006839 }
6840 }
6841
6842 return status;
6843
6844 }
6845
6846 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006847 hdd_debug("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006848
6849 pHddStaCtx->conn_info.authType =
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006850 (encoderq->flags & IW_ENCODE_RESTRICTED) ?
6851 eCSR_AUTH_TYPE_SHARED_KEY :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006852 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6853
6854 }
6855
6856 if (wrqu->data.length > 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006857 hdd_debug("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006858
6859 key_length = wrqu->data.length;
6860
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006861 /* IW_ENCODING_TOKEN_MAX is the value that is set
6862 * for wrqu->data.length by iwconfig.c
6863 * when 'iwconfig wlan0 key on' is issued.
6864 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006865
6866 if (5 == key_length) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006867 hdd_debug("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006868 key_length);
6869
6870 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6871 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6872 pHddStaCtx->conn_info.authType)) {
6873 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
6874 } else {
6875 encryptionType =
6876 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6877 }
6878 } else if (13 == key_length) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006879 hdd_debug("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006880 key_length);
6881
6882 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6883 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6884 pHddStaCtx->conn_info.authType)) {
6885 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
6886 } else {
6887 encryptionType =
6888 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6889 }
6890 } else {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006891 hdd_err("Invalid WEP key length :%d", key_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006892 return -EINVAL;
6893 }
6894
6895 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6896 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
6897 pWextState->roamProfile.EncryptionType.numEntries = 1;
6898 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6899 encryptionType;
6900 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
6901 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6902 encryptionType;
6903
6904 if ((eConnectionState_NotConnected ==
6905 pHddStaCtx->conn_info.connState)
6906 &&
6907 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6908 pHddStaCtx->conn_info.authType)
6909 || (eCSR_AUTH_TYPE_SHARED_KEY ==
6910 pHddStaCtx->conn_info.authType))) {
6911
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306912 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006913 KeyMaterial[keyId][0], extra, key_length);
6914
6915 pWextState->roamProfile.Keys.KeyLength[keyId] =
6916 (uint8_t) key_length;
6917 pWextState->roamProfile.Keys.defaultIndex =
6918 (uint8_t) keyId;
6919
6920 return status;
6921 }
6922 }
6923
6924 return 0;
6925}
6926
6927/**
6928 * iw_set_encode() - SSR wrapper for __iw_set_encode()
6929 * @dev: pointer to net_device
6930 * @info: pointer to iw_request_info
6931 * @wrqu: pointer to iwreq_data
6932 * @extra: pointer to extra ioctl payload
6933 *
6934 * Return: 0 on success, error number otherwise
6935 */
6936static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6937 union iwreq_data *wrqu, char *extra)
6938{
6939 int ret;
6940
6941 cds_ssr_protect(__func__);
6942 ret = __iw_set_encode(dev, info, wrqu, extra);
6943 cds_ssr_unprotect(__func__);
6944
6945 return ret;
6946}
6947
6948/**
6949 * __iw_get_encodeext() - SIOCGIWENCODEEXT ioctl handler
6950 * @dev: device upon which the ioctl was received
6951 * @info: ioctl request information
6952 * @wrqu: ioctl request data
6953 * @extra: ioctl extra data
6954 *
6955 * Return: 0 on success, non-zero on error
6956 */
6957static int __iw_get_encodeext(struct net_device *dev,
6958 struct iw_request_info *info,
6959 struct iw_point *dwrq, char *extra)
6960{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006961 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006962 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6963 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
6964 int keyId;
6965 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6966 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
6967 int i, ret;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006968 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006969
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006970 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006971
6972 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6973 ret = wlan_hdd_validate_context(hdd_ctx);
6974 if (0 != ret)
6975 return ret;
6976
Jeff Johnson441e1f72017-02-07 08:50:49 -08006977 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6978 if (0 != ret)
6979 return ret;
6980
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006981 keyId = pRoamProfile->Keys.defaultIndex;
6982
6983 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006984 hdd_err("Invalid keyId: %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006985 return -EINVAL;
6986 }
6987
6988 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
6989 dwrq->flags |= IW_ENCODE_ENABLED;
6990 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306991 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006992 pRoamProfile->Keys.KeyLength[keyId]);
6993 } else {
6994 dwrq->flags |= IW_ENCODE_DISABLED;
6995 }
6996
6997 for (i = 0; i < MAX_WEP_KEYS; i++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006998 if (pRoamProfile->Keys.KeyLength[i] == 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006999 continue;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007000 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007001 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007002 }
7003
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007004 if (MAX_WEP_KEYS == i)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007005 dwrq->flags |= IW_ENCODE_NOKEY;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007006 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007007 dwrq->flags |= IW_ENCODE_ENABLED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007008
7009 encryptionType = pRoamProfile->EncryptionType.encryptionType[0];
7010
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007011 if (eCSR_ENCRYPT_TYPE_NONE == encryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007012 dwrq->flags |= IW_ENCODE_DISABLED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007013
7014 authType = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
7015
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007016 if (IW_AUTH_ALG_OPEN_SYSTEM == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007017 dwrq->flags |= IW_ENCODE_OPEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007018 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007019 dwrq->flags |= IW_ENCODE_RESTRICTED;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007020
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007021 EXIT();
7022 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007023}
7024
7025/**
7026 * iw_get_encodeext() - SSR wrapper for __iw_get_encodeext()
7027 * @dev: pointer to net_device
7028 * @info: pointer to iw_request_info
7029 * @dwrq: pointer to encoding information
7030 * @extra: pointer to extra ioctl payload
7031 *
7032 * Return: 0 on success, error number otherwise
7033 */
7034static int iw_get_encodeext(struct net_device *dev,
7035 struct iw_request_info *info,
7036 struct iw_point *dwrq, char *extra)
7037{
7038 int ret;
7039
7040 cds_ssr_protect(__func__);
7041 ret = __iw_get_encodeext(dev, info, dwrq, extra);
7042 cds_ssr_unprotect(__func__);
7043
7044 return ret;
7045}
7046
7047/**
7048 * __iw_set_encodeext() - SIOCSIWENCODEEXT ioctl handler
7049 * @dev: device upon which the ioctl was received
7050 * @info: ioctl request information
7051 * @wrqu: ioctl request data
7052 * @extra: ioctl extra data
7053 *
7054 * Return: 0 on success, non-zero on error
7055 */
7056static int __iw_set_encodeext(struct net_device *dev,
7057 struct iw_request_info *info,
7058 union iwreq_data *wrqu, char *extra)
7059{
Jeff Johnson3d278b02017-08-29 14:17:47 -07007060 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07007061 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007062 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007063 struct hdd_context *hdd_ctx;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307064 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007065 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
7066 int ret;
7067 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
7068 int key_index;
7069 struct iw_point *encoding = &wrqu->encoding;
7070 tCsrRoamSetKey setKey;
7071 uint32_t roamId = 0xFF;
7072
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007073 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007074
7075 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7076 ret = wlan_hdd_validate_context(hdd_ctx);
7077 if (0 != ret)
7078 return ret;
7079
Jeff Johnson441e1f72017-02-07 08:50:49 -08007080 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7081 if (0 != ret)
7082 return ret;
7083
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007084 key_index = encoding->flags & IW_ENCODE_INDEX;
7085
7086 if (key_index > 0) {
7087
7088 /*Convert from 1-based to 0-based keying */
7089 key_index--;
7090 }
7091 if (!ext->key_len) {
7092
7093 /*Set the encrytion type to NONE */
7094 pRoamProfile->EncryptionType.encryptionType[0] =
7095 eCSR_ENCRYPT_TYPE_NONE;
7096 return ret;
7097 }
7098
7099 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState &&
7100 (IW_ENCODE_ALG_WEP == ext->alg)) {
7101 if (IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) {
7102
Jeff Johnson99bac312016-06-28 10:38:18 -07007103 hdd_err("Invalid Configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007104 return -EINVAL;
Jeff Johnson68755312017-02-10 11:46:55 -08007105 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007106
Jeff Johnson68755312017-02-10 11:46:55 -08007107 /*Static wep, update the roam profile with the keys */
7108 if (ext->key_len &&
7109 (ext->key_len <= eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES) &&
7110 key_index < CSR_MAX_NUM_KEY) {
7111 qdf_mem_copy(&pRoamProfile->Keys.
7112 KeyMaterial[key_index][0],
7113 ext->key, ext->key_len);
7114 pRoamProfile->Keys.KeyLength[key_index] =
7115 (uint8_t) ext->key_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007116
Jeff Johnson68755312017-02-10 11:46:55 -08007117 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
7118 pRoamProfile->Keys.defaultIndex =
7119 (uint8_t) key_index;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007120 }
7121 return ret;
7122 }
7123
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307124 qdf_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007125
7126 setKey.keyId = key_index;
7127 setKey.keyLength = ext->key_len;
7128
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007129 if (ext->key_len <= CSR_MAX_KEY_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307130 qdf_mem_copy(&setKey.Key[0], ext->key, ext->key_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007131
7132 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
7133 /*Key direction for group is RX only */
7134 setKey.keyDirection = eSIR_RX_ONLY;
Anurag Chouhanc5548422016-02-24 18:33:27 +05307135 qdf_set_macaddr_broadcast(&setKey.peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007136 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007137 setKey.keyDirection = eSIR_TX_RX;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307138 qdf_mem_copy(setKey.peerMac.bytes, ext->addr.sa_data,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307139 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007140 }
7141
7142 /*For supplicant pae role is zero */
7143 setKey.paeRole = 0;
7144
7145 switch (ext->alg) {
7146 case IW_ENCODE_ALG_NONE:
7147 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
7148 break;
7149
7150 case IW_ENCODE_ALG_WEP:
7151 setKey.encType =
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007152 (ext->key_len == 5) ? eCSR_ENCRYPT_TYPE_WEP40 :
7153 eCSR_ENCRYPT_TYPE_WEP104;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007154 break;
7155
7156 case IW_ENCODE_ALG_TKIP:
7157 {
7158 uint8_t *pKey = &setKey.Key[0];
7159
7160 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
7161
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307162 qdf_mem_zero(pKey, CSR_MAX_KEY_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007163
7164 /* Supplicant sends the 32bytes key in this order
7165 * |--------------|----------|----------|
7166 * | Tk1 | TX MIC | RX MIC |
7167 * |--------------|----------|----------|
7168 * <---16bytes---><--8bytes--><--8bytes-->
7169 *
7170 *
7171 * Sme expects the 32 bytes key to be in the below order
7172 * |--------------|----------|----------|
7173 * | Tk1 | RX MIC | TX MIC |
7174 * |--------------|----------|----------|
7175 * <---16bytes---><--8bytes--><--8bytes-->
7176 */
7177
7178 /* Copy the Temporal Key 1 (TK1) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307179 qdf_mem_copy(pKey, ext->key, 16);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007180
7181 /* Copy the rx mic first */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307182 qdf_mem_copy(&pKey[16], &ext->key[24], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007183
7184 /* Copy the tx mic */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307185 qdf_mem_copy(&pKey[24], &ext->key[16], 8);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007186
7187 }
7188 break;
7189
7190 case IW_ENCODE_ALG_CCMP:
7191 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
7192 break;
7193
7194#ifdef FEATURE_WLAN_ESE
7195#define IW_ENCODE_ALG_KRK 6
7196 case IW_ENCODE_ALG_KRK:
7197 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
7198 break;
7199#endif /* FEATURE_WLAN_ESE */
7200
7201 default:
7202 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
7203 break;
7204 }
7205
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007206 hdd_debug("cipher_alg:%d key_len:%d EncryptionType:%d",
Jeff Johnson99bac312016-06-28 10:38:18 -07007207 (int)ext->alg, (int)ext->key_len, setKey.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007209 /* The supplicant may attempt to set the PTK once
7210 * pre-authentication is done. Save the key in the UMAC and
7211 * include it in the ADD BSS request
7212 */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307213 qdf_ret_status = sme_ft_update_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007214 pAdapter->sessionId, &setKey);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307215 if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007216 hdd_debug("Update PreAuth Key success");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007217 return 0;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307218 } else if (qdf_ret_status == QDF_STATUS_FT_PREAUTH_KEY_FAILED) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007219 hdd_err("Update PreAuth Key failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007220 return -EINVAL;
7221 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007222
7223 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
7224
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307225 qdf_ret_status = sme_roam_set_key(WLAN_HDD_GET_HAL_CTX(pAdapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007226 pAdapter->sessionId,
7227 &setKey, &roamId);
7228
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307229 if (qdf_ret_status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007230 hdd_err("[%4d] sme_roam_set_key returned ERROR status= %d",
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307231 __LINE__, qdf_ret_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007232
7233 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
7234 }
7235
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307236 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007237}
7238
7239/**
7240 * iw_set_encodeext() - SSR wrapper for __iw_set_encodeext()
7241 * @dev: pointer to net_device
7242 * @info: pointer to iw_request_info
7243 * @wrqu: pointer to iwreq_data
7244 * @extra: pointer to extra ioctl payload
7245 *
7246 * Return: 0 on success, error number otherwise
7247 */
7248static int iw_set_encodeext(struct net_device *dev,
7249 struct iw_request_info *info,
7250 union iwreq_data *wrqu, char *extra)
7251{
7252 int ret;
7253
7254 cds_ssr_protect(__func__);
7255 ret = __iw_set_encodeext(dev, info, wrqu, extra);
7256 cds_ssr_unprotect(__func__);
7257
7258 return ret;
7259}
7260
7261/**
7262 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
7263 * @dev: device upon which the ioctl was received
7264 * @info: ioctl request information
7265 * @wrqu: ioctl request data
7266 * @extra: ioctl extra data
7267 *
7268 * Return: 0 on success, non-zero on error
7269 */
7270static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
7271 union iwreq_data *wrqu, char *extra)
7272{
Jeff Johnson3d278b02017-08-29 14:17:47 -07007273 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007274 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007275 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007276 int ret;
7277
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007278 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007279
7280 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7281 ret = wlan_hdd_validate_context(hdd_ctx);
7282 if (0 != ret)
7283 return ret;
7284
Jeff Johnson441e1f72017-02-07 08:50:49 -08007285 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7286 if (0 != ret)
7287 return ret;
7288
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007289 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
7290 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
7291
Jeff Johnson99bac312016-06-28 10:38:18 -07007292 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007293
7294 return -EINVAL;
7295 }
7296
7297 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
7298
7299 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
7300 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
7301 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307302 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007303 hdd_err("WNI_CFG_LONG_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007304 return -EIO;
7305 }
7306 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
7307 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
7308 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307309 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007310 hdd_err("WNI_CFG_SHORT_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007311 return -EIO;
7312 }
7313 }
7314 } else {
7315 return -EOPNOTSUPP;
7316 }
7317
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007318 hdd_debug("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007319
7320 EXIT();
7321
7322 return 0;
7323
7324}
7325
7326/**
7327 * iw_set_retry() - SSR wrapper for __iw_set_retry()
7328 * @dev: pointer to net_device
7329 * @info: pointer to iw_request_info
7330 * @wrqu: pointer to iwreq_data
7331 * @extra: pointer to extra ioctl payload
7332 *
7333 * Return: 0 on success, error number otherwise
7334 */
7335static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
7336 union iwreq_data *wrqu, char *extra)
7337{
7338 int ret;
7339
7340 cds_ssr_protect(__func__);
7341 ret = __iw_set_retry(dev, info, wrqu, extra);
7342 cds_ssr_unprotect(__func__);
7343
7344 return ret;
7345}
7346
7347/**
7348 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
7349 * @dev: device upon which the ioctl was received
7350 * @info: ioctl request information
7351 * @wrqu: ioctl request data
7352 * @extra: ioctl extra data
7353 *
7354 * Return: 0 on success, non-zero on error
7355 */
7356static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7357 union iwreq_data *wrqu, char *extra)
7358{
Jeff Johnson3d278b02017-08-29 14:17:47 -07007359 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007360 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7361 uint32_t retry = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007362 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007363 int ret;
7364
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007365 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007366
7367 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7368 ret = wlan_hdd_validate_context(hdd_ctx);
7369 if (0 != ret)
7370 return ret;
7371
Jeff Johnson441e1f72017-02-07 08:50:49 -08007372 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7373 if (0 != ret)
7374 return ret;
7375
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007376 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
7377 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
7378
7379 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307380 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007381 hdd_err("WNI_CFG_LONG_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007382 return -EIO;
7383 }
7384
7385 wrqu->retry.value = retry;
7386 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
7387 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
7388
7389 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307390 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007391 hdd_err("WNI_CFG_SHORT_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007392 return -EIO;
7393 }
7394
7395 wrqu->retry.value = retry;
7396 } else {
7397 return -EOPNOTSUPP;
7398 }
7399
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007400 hdd_debug("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007401
7402 EXIT();
7403
7404 return 0;
7405}
7406
7407/**
7408 * iw_get_retry() - SSR wrapper for __iw_get_retry()
7409 * @dev: pointer to net_device
7410 * @info: pointer to iw_request_info
7411 * @wrqu: pointer to iwreq_data
7412 * @extra: pointer to extra ioctl payload
7413 *
7414 * Return: 0 on success, error number otherwise
7415 */
7416static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7417 union iwreq_data *wrqu, char *extra)
7418{
7419 int ret;
7420
7421 cds_ssr_protect(__func__);
7422 ret = __iw_get_retry(dev, info, wrqu, extra);
7423 cds_ssr_unprotect(__func__);
7424
7425 return ret;
7426}
7427
7428/**
7429 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
7430 * @dev: device upon which the ioctl was received
7431 * @info: ioctl request information
7432 * @wrqu: ioctl request data
7433 * @extra: ioctl extra data
7434 *
7435 * Return: 0 on success, non-zero on error
7436 */
7437static int __iw_set_mlme(struct net_device *dev,
7438 struct iw_request_info *info,
7439 union iwreq_data *wrqu, char *extra)
7440{
Jeff Johnson3d278b02017-08-29 14:17:47 -07007441 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07007442 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007443 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307444 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007445 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007446 int ret;
7447
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007448 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007449
7450 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7451 ret = wlan_hdd_validate_context(hdd_ctx);
7452 if (0 != ret)
7453 return ret;
7454
Jeff Johnson441e1f72017-02-07 08:50:49 -08007455 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7456 if (0 != ret)
7457 return ret;
7458
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007459 /* reason_code is unused. By default it is set to
7460 * eCSR_DISCONNECT_REASON_UNSPECIFIED
7461 */
7462 switch (mlme->cmd) {
7463 case IW_MLME_DISASSOC:
7464 case IW_MLME_DEAUTH:
7465
7466 if (pHddStaCtx->conn_info.connState ==
7467 eConnectionState_Associated) {
7468 eCsrRoamDisconnectReason reason =
7469 eCSR_DISCONNECT_REASON_UNSPECIFIED;
7470
7471 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
7472 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
7473
7474 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7475 status =
7476 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(pAdapter),
7477 pAdapter->sessionId, reason);
7478
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307479 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007480 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007482 rc = wait_for_completion_timeout(&pAdapter->
7483 disconnect_comp_var,
7484 msecs_to_jiffies
7485 (WLAN_WAIT_TIME_DISCONNECT));
7486 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007487 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007488 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07007489 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
7490 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007491
7492 /* Resetting authKeyMgmt */
7493 (WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->authKeyMgmt =
7494 0;
7495
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07007496 hdd_debug("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007497 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05307498 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007499 WLAN_CONTROL_PATH);
7500
7501 } else {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007502 hdd_warn("%d Command Disassociate/Deauthenticate called but station is not in associated state",
Jeff Johnson99bac312016-06-28 10:38:18 -07007503 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007504 }
7505 break;
7506 default:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007507 hdd_err("Unexpected cmd: %d", (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007508 return -EINVAL;
7509 } /* end of switch */
7510
7511 EXIT();
7512
7513 return status;
7514
7515}
7516
7517/**
7518 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
7519 * @dev: pointer to net_device
7520 * @info: pointer to iw_request_info
7521 * @wrqu: pointer to iwreq_data
7522 * @extra: pointer to extra ioctl payload
7523 *
7524 * Return: 0 on success, error number otherwise
7525 */
7526static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
7527 union iwreq_data *wrqu, char *extra)
7528{
7529 int ret;
7530
7531 cds_ssr_protect(__func__);
7532 ret = __iw_set_mlme(dev, info, wrqu, extra);
7533 cds_ssr_unprotect(__func__);
7534
7535 return ret;
7536}
7537
7538/**
7539 * wlan_hdd_update_phymode() - handle change in PHY mode
7540 * @net: device upon which PHY mode change was received
7541 * @hal: umac handle for the driver
7542 * @new_phymode: new PHY mode for the device
7543 * @phddctx: pointer to the HDD context
7544 *
7545 * This function is called when the device is set to a new PHY mode.
7546 * It takes a holistic look at the desired PHY mode along with the
7547 * configured capabilities of the driver and the reported capabilities
7548 * of the hardware in order to correctly configure all PHY-related
7549 * parameters.
7550 *
7551 * Return: 0 on success, negative errno value on error
7552 */
7553int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007554 int new_phymode, struct hdd_context *phddctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007555{
7556#ifdef QCA_HT_2040_COEX
Jeff Johnson3d278b02017-08-29 14:17:47 -07007557 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307558 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007559#endif
7560 bool band_24 = false, band_5g = false;
7561 bool ch_bond24 = false, ch_bond5g = false;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307562 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007563 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007564 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007565 eCsrPhyMode phymode = -EIO, old_phymode;
Srinivas Girigowda2fb677c2017-03-25 15:35:34 -07007566 enum hdd_dot11_mode hdd_dot11mode = phddctx->config->dot11Mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007567 eCsrBand curr_band = eCSR_BAND_ALL;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307568 int retval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007569
7570 old_phymode = sme_get_phy_mode(hal);
7571
7572 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7573 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7574 nChannelBondingMode24GHz))
7575 ch_bond24 = true;
7576
7577 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7578 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7579 nChannelBondingMode5GHz))
7580 ch_bond5g = true;
7581
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007582 if (phddctx->config->nBandCapability == eCSR_BAND_ALL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007583 band_24 = band_5g = true;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007584 else if (phddctx->config->nBandCapability == eCSR_BAND_24)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007585 band_24 = true;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007586 else if (phddctx->config->nBandCapability == eCSR_BAND_5G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007587 band_5g = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007588
7589 vhtchanwidth = phddctx->config->vhtChannelWidth;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007590 hdd_debug("ch_bond24=%d ch_bond5g=%d band_24=%d band_5g=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007591 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
7592
7593 switch (new_phymode) {
7594 case IEEE80211_MODE_AUTO:
7595 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007596 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007597 phymode = eCSR_DOT11_MODE_AUTO;
7598 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7599 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7600 curr_band = eCSR_BAND_ALL;
7601 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7602 } else {
7603 sme_set_phy_mode(hal, old_phymode);
7604 return -EIO;
7605 }
7606 break;
7607 case IEEE80211_MODE_11A:
7608 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007609 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007610 phymode = eCSR_DOT11_MODE_11a;
7611 hdd_dot11mode = eHDD_DOT11_MODE_11a;
7612 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7613 curr_band = eCSR_BAND_5G;
7614 } else {
7615 sme_set_phy_mode(hal, old_phymode);
7616 return -EIO;
7617 }
7618 break;
7619 case IEEE80211_MODE_11B:
7620 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007621 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007622 phymode = eCSR_DOT11_MODE_11b;
7623 hdd_dot11mode = eHDD_DOT11_MODE_11b;
7624 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7625 curr_band = eCSR_BAND_24;
7626 } else {
7627 sme_set_phy_mode(hal, old_phymode);
7628 return -EIO;
7629 }
7630 break;
7631 case IEEE80211_MODE_11G:
7632 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007633 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007634 phymode = eCSR_DOT11_MODE_11g;
7635 hdd_dot11mode = eHDD_DOT11_MODE_11g;
7636 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7637 curr_band = eCSR_BAND_24;
7638 } else {
7639 sme_set_phy_mode(hal, old_phymode);
7640 return -EIO;
7641 }
7642 break;
7643 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
7644 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
7645 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
7646 */
7647 case IEEE80211_MODE_11NA_HT20:
7648 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007649 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007650 phymode = eCSR_DOT11_MODE_11n;
7651 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7652 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7653 curr_band = eCSR_BAND_5G;
7654 } else {
7655 sme_set_phy_mode(hal, old_phymode);
7656 return -EIO;
7657 }
7658 break;
7659 case IEEE80211_MODE_11NA_HT40:
7660 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007661 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007662 phymode = eCSR_DOT11_MODE_11n;
7663 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7664 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7665 curr_band = eCSR_BAND_5G;
7666 } else {
7667 sme_set_phy_mode(hal, old_phymode);
7668 return -EIO;
7669 }
7670 break;
7671 case IEEE80211_MODE_11NG_HT20:
7672 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007673 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007674 phymode = eCSR_DOT11_MODE_11n;
7675 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7676 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7677 curr_band = eCSR_BAND_24;
7678 } else {
7679 sme_set_phy_mode(hal, old_phymode);
7680 return -EIO;
7681 }
7682 break;
7683 case IEEE80211_MODE_11NG_HT40:
7684 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007685 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007686 phymode = eCSR_DOT11_MODE_11n;
7687 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7688 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7689 curr_band = eCSR_BAND_24;
7690 } else {
7691 sme_set_phy_mode(hal, old_phymode);
7692 return -EIO;
7693 }
7694 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007695 case IEEE80211_MODE_11AC_VHT20:
7696 case IEEE80211_MODE_11AC_VHT40:
7697 case IEEE80211_MODE_11AC_VHT80:
7698 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007699 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007700 phymode = eCSR_DOT11_MODE_11ac;
7701 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
7702 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7703 curr_band = eCSR_BAND_5G;
7704 } else {
7705 sme_set_phy_mode(hal, old_phymode);
7706 return -EIO;
7707 }
7708 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007709 case IEEE80211_MODE_2G_AUTO:
7710 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007711 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007712 phymode = eCSR_DOT11_MODE_AUTO;
7713 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7714 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7715 curr_band = eCSR_BAND_24;
7716 } else {
7717 sme_set_phy_mode(hal, old_phymode);
7718 return -EIO;
7719 }
7720 break;
7721 case IEEE80211_MODE_5G_AUTO:
7722 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007723 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007724 phymode = eCSR_DOT11_MODE_AUTO;
7725 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7726 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7727 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7728 curr_band = eCSR_BAND_5G;
7729 } else {
7730 sme_set_phy_mode(hal, old_phymode);
7731 return -EIO;
7732 }
7733 break;
7734 case IEEE80211_MODE_11AGN:
7735 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007736 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007737 phymode = eCSR_DOT11_MODE_11n;
7738 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7739 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7740 curr_band = eCSR_BAND_ALL;
7741 } else {
7742 sme_set_phy_mode(hal, old_phymode);
7743 return -EIO;
7744 }
7745 break;
7746 default:
7747 return -EIO;
7748 }
7749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007750 switch (new_phymode) {
7751 case IEEE80211_MODE_11AC_VHT20:
7752 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7753 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
7754 break;
7755 case IEEE80211_MODE_11AC_VHT40:
7756 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
7757 break;
7758 case IEEE80211_MODE_11AC_VHT80:
7759 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7760 break;
7761 default:
7762 vhtchanwidth = phddctx->config->vhtChannelWidth;
7763 break;
7764 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007765
7766 if (phymode != -EIO) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307767 sme_config = qdf_mem_malloc(sizeof(*sme_config));
7768 if (!sme_config) {
7769 hdd_err("Failed to allocate memory for sme_config");
7770 return -ENOMEM;
7771 }
7772 qdf_mem_zero(sme_config, sizeof(*sme_config));
7773 sme_get_config_param(hal, sme_config);
7774 sme_config->csrConfig.phyMode = phymode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007775#ifdef QCA_HT_2040_COEX
7776 if (phymode == eCSR_DOT11_MODE_11n &&
7777 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307778 sme_config->csrConfig.obssEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007779 halStatus = sme_set_ht2040_mode(hal,
7780 pAdapter->sessionId,
7781 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307782 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007783 hdd_err("Failed to disable OBSS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307784 retval = -EIO;
7785 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007786 }
7787 } else if (phymode == eCSR_DOT11_MODE_11n &&
7788 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307789 sme_config->csrConfig.obssEnabled = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007790 halStatus = sme_set_ht2040_mode(hal,
7791 pAdapter->sessionId,
7792 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307793 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007794 hdd_err("Failed to enable OBSS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307795 retval = -EIO;
7796 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007797 }
7798 }
7799#endif
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307800 sme_config->csrConfig.eBand = curr_band;
7801 sme_config->csrConfig.bandCapability = curr_band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007802 if (curr_band == eCSR_BAND_24)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307803 sme_config->csrConfig.Is11hSupportEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007804 else
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307805 sme_config->csrConfig.Is11hSupportEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007806 phddctx->config->Is11hSupportEnabled;
7807 if (curr_band == eCSR_BAND_24)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307808 sme_config->csrConfig.channelBondingMode24GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007809 else if (curr_band == eCSR_BAND_24)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307810 sme_config->csrConfig.channelBondingMode5GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007811 else {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307812 sme_config->csrConfig.channelBondingMode24GHz = chwidth;
7813 sme_config->csrConfig.channelBondingMode5GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007814 }
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307815 sme_config->csrConfig.nVhtChannelWidth = vhtchanwidth;
7816 sme_update_config(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007817
7818 phddctx->config->dot11Mode = hdd_dot11mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007819 phddctx->config->nChannelBondingMode24GHz =
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307820 sme_config->csrConfig.channelBondingMode24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007821 phddctx->config->nChannelBondingMode5GHz =
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307822 sme_config->csrConfig.channelBondingMode5GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007823 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07007824 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007825 hdd_err("could not update config_dat");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307826 retval = -EIO;
7827 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007828 }
7829 if (phddctx->config->nChannelBondingMode5GHz)
Srinivas Girigowda11c28e02017-06-27 20:06:21 -07007830 phddctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007831 |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7832 else
Srinivas Girigowda11c28e02017-06-27 20:06:21 -07007833 phddctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]->ht_cap.cap
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007834 &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7835
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007836 hdd_debug("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007837 phymode, chwidth, curr_band, vhtchanwidth);
7838 }
7839
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307840free:
7841 if (sme_config)
7842 qdf_mem_free(sme_config);
7843 return retval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007844}
7845
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007846struct temperature_priv {
7847 int temperature;
7848};
7849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007850/**
7851 * hdd_get_temperature_cb() - "Get Temperature" callback function
7852 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007853 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007854 *
7855 * This function is passed to sme_get_temperature() as the callback
7856 * function to be invoked when the temperature measurement is
7857 * available.
7858 *
7859 * Return: None
7860 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007861static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007862{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007863 struct hdd_request *request;
7864 struct temperature_priv *priv;
7865
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007866 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007867
7868 request = hdd_request_get(context);
7869 if (!request) {
7870 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007871 return;
7872 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007873
7874 priv = hdd_request_priv(request);
7875 priv->temperature = temperature;
7876 hdd_request_complete(request);
7877 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007878 EXIT();
7879}
7880
7881/**
7882 * wlan_hdd_get_temperature() - get current device temperature
7883 * @pAdapter: device upon which the request was made
7884 * @temperature: pointer to where the temperature is to be returned
7885 *
7886 * Return: 0 if a temperature value (either current or cached) was
7887 * returned, otherwise a negative errno is returned.
7888 *
7889 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07007890int wlan_hdd_get_temperature(struct hdd_adapter *pAdapter, int *temperature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007891{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307892 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007893 int ret;
7894 void *cookie;
7895 struct hdd_request *request;
7896 struct temperature_priv *priv;
7897 static const struct hdd_request_params params = {
7898 .priv_size = sizeof(*priv),
7899 .timeout_ms = WLAN_WAIT_TIME_STATS,
7900 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007901
7902 ENTER();
7903 if (NULL == pAdapter) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007904 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007905 return -EPERM;
7906 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007907
7908 request = hdd_request_alloc(&params);
7909 if (!request) {
7910 hdd_err("Request allocation failure");
7911 return -ENOMEM;
7912 }
7913 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007914 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007915 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307916 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007917 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007918 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007919 ret = hdd_request_wait_for_response(request);
7920 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007921 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007922 } else {
7923 /* update the adapter with the fresh results */
7924 priv = hdd_request_priv(request);
7925 if (priv->temperature)
7926 pAdapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007927 }
7928 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007929
7930 /*
7931 * either we never sent a request, we sent a request and
7932 * received a response or we sent a request and timed out.
7933 * regardless we are done with the request.
7934 */
7935 hdd_request_put(request);
7936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007937 *temperature = pAdapter->temperature;
7938 EXIT();
7939 return 0;
7940}
7941
7942/**
7943 * iw_setint_getnone() - Generic "set integer" private ioctl handler
7944 * @dev: device upon which the ioctl was received
7945 * @info: ioctl request information
7946 * @wrqu: ioctl request data
7947 * @extra: ioctl extra data
7948 *
7949 * Return: 0 on success, non-zero on error
7950 */
7951static int __iw_setint_getnone(struct net_device *dev,
7952 struct iw_request_info *info,
7953 union iwreq_data *wrqu, char *extra)
7954{
Jeff Johnson3d278b02017-08-29 14:17:47 -07007955 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07007957 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007958 struct hdd_context *hdd_ctx;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307959 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007960 int *value = (int *)extra;
7961 int sub_cmd = value[0];
7962 int set_value = value[1];
7963 int ret;
7964 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307965 QDF_STATUS status;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08007966 void *soc = NULL;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08007967 struct cdp_pdev *pdev = NULL;
7968 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007969
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007970 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307971
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007972 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
7973 ret = wlan_hdd_validate_context(hdd_ctx);
7974 if (0 != ret)
7975 return ret;
7976
Jeff Johnson441e1f72017-02-07 08:50:49 -08007977 ret = hdd_check_private_wext_control(hdd_ctx, info);
7978 if (0 != ret)
7979 return ret;
7980
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307981 sme_config = qdf_mem_malloc(sizeof(*sme_config));
7982 if (!sme_config) {
7983 hdd_err("failed to allocate memory for sme_config");
7984 return -ENOMEM;
7985 }
7986 qdf_mem_zero(sme_config, sizeof(*sme_config));
Jeff Johnson441e1f72017-02-07 08:50:49 -08007987
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007988 switch (sub_cmd) {
7989 case WE_SET_11D_STATE:
7990 {
7991 if ((ENABLE_11D == set_value)
7992 || (DISABLE_11D == set_value)) {
7993
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307994 sme_get_config_param(hHal, sme_config);
7995 sme_config->csrConfig.Is11dSupportEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007996 (bool) set_value;
7997
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007998 hdd_debug("11D state=%d!!",
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307999 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008000 Is11dSupportEnabled);
8001
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308002 sme_update_config(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008003 } else {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308004 ret = -EINVAL;
8005 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008006 }
8007 break;
8008 }
8009
8010 case WE_WOWL:
8011 {
8012 switch (set_value) {
8013 case 0x00:
8014 hdd_exit_wowl(pAdapter);
8015 break;
8016 case 0x01:
8017 case 0x02:
8018 case 0x03:
8019 enable_mp = (set_value & 0x01) ? 1 : 0;
8020 enable_pbm = (set_value & 0x02) ? 1 : 0;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008021 hdd_debug("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008022 (enable_mp ? "YES" : "NO"),
8023 (enable_pbm ? "YES" : "NO"));
8024 hdd_enter_wowl(pAdapter, enable_mp, enable_pbm);
8025 break;
8026 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07008027 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008028 set_value);
8029 ret = -EINVAL;
8030 break;
8031 }
8032
8033 break;
8034 }
8035 case WE_SET_POWER:
8036 {
8037 switch (set_value) {
8038 case 1:
8039 /* Enable PowerSave */
8040 sme_ps_enable_disable(hHal, pAdapter->sessionId,
8041 SME_PS_ENABLE);
8042 break;
8043 case 2:
8044 /* Disable PowerSave */
8045 sme_ps_enable_disable(hHal, pAdapter->sessionId,
8046 SME_PS_DISABLE);
8047 break;
8048 case 3: /* Enable UASPD */
8049 sme_ps_uapsd_enable(hHal, pAdapter->sessionId);
8050 break;
8051 case 4: /* Disable UASPD */
8052 sme_ps_uapsd_disable(hHal, pAdapter->sessionId);
8053 break;
8054 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07008055 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008056 set_value);
8057 ret = -EINVAL;
8058 break;
8059 }
8060 break;
8061 }
8062
8063 case WE_SET_MAX_ASSOC:
8064 {
8065 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
8066 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
8067 ret = -EINVAL;
8068 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
8069 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308070 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008071 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008072 ret = -EIO;
8073 }
8074 break;
8075 }
8076
8077 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
8078 if (set_value == 0 || set_value == 1)
8079 (WLAN_HDD_GET_CTX(pAdapter))->config->force_sap_acs =
8080 set_value;
8081 else
8082 ret = -EINVAL;
8083 break;
8084
8085 case WE_SET_DATA_INACTIVITY_TO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008086 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
8087 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
8088 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
8089 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308090 set_value) == QDF_STATUS_E_FAILURE)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008091 hdd_err("WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008092 ret = -EINVAL;
8093 }
8094 break;
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05308095 case WE_SET_WOW_DATA_INACTIVITY_TO:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308096 if (!hHal) {
8097 ret = -EINVAL;
8098 goto free;
8099 }
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05308100
8101 if ((set_value < CFG_WOW_DATA_INACTIVITY_TIMEOUT_MIN) ||
8102 (set_value > CFG_WOW_DATA_INACTIVITY_TIMEOUT_MAX) ||
8103 (sme_cfg_set_int((WLAN_HDD_GET_CTX(pAdapter))->hHal,
8104 WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT,
8105 set_value) == QDF_STATUS_E_FAILURE)) {
8106 hdd_err("WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT fail");
8107 ret = -EINVAL;
8108 }
8109 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008110 case WE_SET_MC_RATE:
8111 {
8112 ret = wlan_hdd_set_mc_rate(pAdapter, set_value);
8113 break;
8114 }
8115 case WE_SET_TX_POWER:
8116 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05308117 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008118
Anurag Chouhanc5548422016-02-24 18:33:27 +05308119 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008120 if (sme_set_tx_power
8121 (hHal, pAdapter->sessionId, bssid,
8122 pAdapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308123 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008124 hdd_err("Setting tx power failed");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308125 ret = -EIO;
8126 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008127 }
8128 break;
8129 }
8130 case WE_SET_MAX_TX_POWER:
8131 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05308132 struct qdf_mac_addr bssid;
8133 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008134
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008135
8136 hdd_debug("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008137 set_value);
Anurag Chouhanc5548422016-02-24 18:33:27 +05308138 qdf_copy_macaddr(&bssid, &pHddStaCtx->conn_info.bssId);
8139 qdf_copy_macaddr(&selfMac, &pHddStaCtx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008140
8141 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308142 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008143 hdd_err("Setting maximum tx power failed");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308144 ret = -EIO;
8145 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008146 }
8147
8148 break;
8149 }
8150 case WE_SET_MAX_TX_POWER_2_4:
8151 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008152 hdd_debug("Setting maximum tx power %d dBm for 2.4 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07008153 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008154 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308155 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008156 hdd_err("Setting max tx power failed for 2.4 GHz band");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308157 ret = -EIO;
8158 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008159 }
8160
8161 break;
8162 }
8163 case WE_SET_MAX_TX_POWER_5_0:
8164 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008165 hdd_debug("Setting maximum tx power %d dBm for 5.0 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07008166 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008167 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308168 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008169 hdd_err("Setting max tx power failed for 5.0 GHz band");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308170 ret = -EIO;
8171 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008172 }
8173
8174 break;
8175 }
8176 case WE_SET_HIGHER_DTIM_TRANSITION:
8177 {
8178 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008179 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008180 set_value);
8181 ret = -EINVAL;
8182 } else {
8183 if (pAdapter->higherDtimTransition != set_value) {
8184 pAdapter->higherDtimTransition =
8185 set_value;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008186 hdd_debug("higherDtimTransition set to :%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008187 pAdapter->higherDtimTransition);
8188 }
8189 }
8190
8191 break;
8192 }
8193
8194 case WE_SET_TM_LEVEL:
8195 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008196 hdd_debug("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008197 (void)sme_set_thermal_level(hHal, set_value);
8198 break;
8199 }
8200
8201 case WE_SET_PHYMODE:
8202 {
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008203 struct hdd_context *phddctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008204
8205 ret =
8206 wlan_hdd_update_phymode(dev, hHal, set_value,
8207 phddctx);
8208 break;
8209 }
8210
8211 case WE_SET_NSS:
8212 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008213 hdd_debug("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008214 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008215 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008216 ret = -EINVAL;
8217 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308218 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008219 hdd_update_nss(WLAN_HDD_GET_CTX(pAdapter),
8220 set_value))
8221 ret = -EINVAL;
8222 }
8223 break;
8224 }
8225
8226 case WE_SET_GTX_HT_MCS:
8227 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008228 hdd_debug("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008229 ret = wma_cli_set_command(pAdapter->sessionId,
8230 WMI_VDEV_PARAM_GTX_HT_MCS,
8231 set_value, GTX_CMD);
8232 break;
8233 }
8234
8235 case WE_SET_GTX_VHT_MCS:
8236 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008237 hdd_debug("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008238 set_value);
8239 ret = wma_cli_set_command(pAdapter->sessionId,
8240 WMI_VDEV_PARAM_GTX_VHT_MCS,
8241 set_value, GTX_CMD);
8242 break;
8243 }
8244
8245 case WE_SET_GTX_USRCFG:
8246 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008247 hdd_debug("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008248 set_value);
8249 ret = wma_cli_set_command(pAdapter->sessionId,
8250 WMI_VDEV_PARAM_GTX_USR_CFG,
8251 set_value, GTX_CMD);
8252 break;
8253 }
8254
8255 case WE_SET_GTX_THRE:
8256 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008257 hdd_debug("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008258 ret = wma_cli_set_command(pAdapter->sessionId,
8259 WMI_VDEV_PARAM_GTX_THRE,
8260 set_value, GTX_CMD);
8261 break;
8262 }
8263
8264 case WE_SET_GTX_MARGIN:
8265 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008266 hdd_debug("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008267 ret = wma_cli_set_command(pAdapter->sessionId,
8268 WMI_VDEV_PARAM_GTX_MARGIN,
8269 set_value, GTX_CMD);
8270 break;
8271 }
8272
8273 case WE_SET_GTX_STEP:
8274 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008275 hdd_debug("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008276 ret = wma_cli_set_command(pAdapter->sessionId,
8277 WMI_VDEV_PARAM_GTX_STEP,
8278 set_value, GTX_CMD);
8279 break;
8280 }
8281
8282 case WE_SET_GTX_MINTPC:
8283 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008284 hdd_debug("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008285 ret = wma_cli_set_command(pAdapter->sessionId,
8286 WMI_VDEV_PARAM_GTX_MINTPC,
8287 set_value, GTX_CMD);
8288 break;
8289 }
8290
8291 case WE_SET_GTX_BWMASK:
8292 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008293 hdd_debug("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008294 ret = wma_cli_set_command(pAdapter->sessionId,
8295 WMI_VDEV_PARAM_GTX_BW_MASK,
8296 set_value, GTX_CMD);
8297 break;
8298 }
8299
8300 case WE_SET_LDPC:
8301 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308302 ret = hdd_set_ldpc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008303 break;
8304 }
8305
8306 case WE_SET_TX_STBC:
8307 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308308 ret = hdd_set_tx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008309 break;
8310 }
8311
8312 case WE_SET_RX_STBC:
8313 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05308314 ret = hdd_set_rx_stbc(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008315 break;
8316 }
8317
8318 case WE_SET_SHORT_GI:
8319 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008320 hdd_debug("WMI_VDEV_PARAM_SGI val %d", set_value);
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08008321 /*
8322 * wma_cli_set_command should be called instead of
8323 * sme_update_ht_config since SGI is used for HT/HE.
8324 * This should be refactored.
8325 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008326 ret = sme_update_ht_config(hHal, pAdapter->sessionId,
8327 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
8328 set_value);
8329 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07008330 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008331 break;
8332 }
8333
8334 case WE_SET_RTSCTS:
8335 {
8336 uint32_t value;
8337
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008338 hdd_debug("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008339 set_value);
8340
8341 if ((set_value & HDD_RTSCTS_EN_MASK) ==
8342 HDD_RTSCTS_ENABLE)
8343 value =
8344 (WLAN_HDD_GET_CTX(pAdapter))->config->
8345 RTSThreshold;
8346 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
8347 || ((set_value & HDD_RTSCTS_EN_MASK) ==
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308348 HDD_CTS_ENABLE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008349 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308350 } else {
8351 ret = -EIO;
8352 goto free;
8353 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008354
8355 ret = wma_cli_set_command(pAdapter->sessionId,
8356 WMI_VDEV_PARAM_ENABLE_RTSCTS,
8357 set_value, VDEV_CMD);
8358 if (!ret) {
8359 if (sme_cfg_set_int
8360 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308361 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008362 hdd_err("FAILED TO SET RTSCTS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308363 ret = -EIO;
8364 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008365 }
8366 }
8367
8368 break;
8369 }
8370
8371 case WE_SET_CHWIDTH:
8372 {
8373 bool chwidth = false;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008374 struct hdd_context *phddctx = WLAN_HDD_GET_CTX(pAdapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008375
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008376 /*updating channel bonding only on 5Ghz */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008377 hdd_debug("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008378 set_value);
8379 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008380 hdd_err("Invalid channel width 0->20 1->40 2->80");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308381 ret = -EINVAL;
8382 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008383 }
8384
8385 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
8386 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
8387 nChannelBondingMode5GHz)))
8388 chwidth = true;
8389
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308390 sme_get_config_param(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008391 switch (set_value) {
8392 case eHT_CHANNEL_WIDTH_20MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308393 sme_config->csrConfig.channelBondingMode5GHz =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008394 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
8395 break;
8396 case eHT_CHANNEL_WIDTH_40MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308397 if (chwidth) {
8398 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008399 channelBondingMode5GHz =
8400 phddctx->config->
8401 nChannelBondingMode5GHz;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308402 } else {
8403 ret = -EINVAL;
8404 goto free;
8405 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008406
8407 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008408 case eHT_CHANNEL_WIDTH_80MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308409 if (chwidth) {
8410 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008411 channelBondingMode5GHz =
8412 phddctx->config->
8413 nChannelBondingMode5GHz;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308414 } else {
8415 ret = -EINVAL;
8416 goto free;
8417 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008418
8419 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008420
8421 default:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308422 ret = -EINVAL;
8423 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008424 }
8425
8426 ret = wma_cli_set_command(pAdapter->sessionId,
8427 WMI_VDEV_PARAM_CHWIDTH,
8428 set_value, VDEV_CMD);
8429 if (!ret)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308430 sme_update_config(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008431
8432 break;
8433 }
8434
8435 case WE_SET_ANI_EN_DIS:
8436 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008437 hdd_debug("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008438 set_value);
8439 ret = wma_cli_set_command(pAdapter->sessionId,
8440 WMI_PDEV_PARAM_ANI_ENABLE,
8441 set_value, PDEV_CMD);
8442 break;
8443 }
8444
8445 case WE_SET_ANI_POLL_PERIOD:
8446 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008447 hdd_debug("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008448 set_value);
8449 ret = wma_cli_set_command(pAdapter->sessionId,
8450 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
8451 set_value, PDEV_CMD);
8452 break;
8453 }
8454
8455 case WE_SET_ANI_LISTEN_PERIOD:
8456 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008457 hdd_debug("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008458 set_value);
8459 ret = wma_cli_set_command(pAdapter->sessionId,
8460 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
8461 set_value, PDEV_CMD);
8462 break;
8463 }
8464
8465 case WE_SET_ANI_OFDM_LEVEL:
8466 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008467 hdd_debug("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008468 set_value);
8469 ret = wma_cli_set_command(pAdapter->sessionId,
8470 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
8471 set_value, PDEV_CMD);
8472 break;
8473 }
8474
8475 case WE_SET_ANI_CCK_LEVEL:
8476 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008477 hdd_debug("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008478 set_value);
8479 ret = wma_cli_set_command(pAdapter->sessionId,
8480 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
8481 set_value, PDEV_CMD);
8482 break;
8483 }
8484
8485 case WE_SET_DYNAMIC_BW:
8486 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008487 hdd_debug("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008488 set_value);
8489 ret = wma_cli_set_command(pAdapter->sessionId,
8490 WMI_PDEV_PARAM_DYNAMIC_BW,
8491 set_value, PDEV_CMD);
8492 break;
8493 }
8494
8495 case WE_SET_CTS_CBW:
8496 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008497 hdd_debug("WE_SET_CTS_CBW val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008498 ret = wma_cli_set_command(pAdapter->sessionId,
8499 WMI_PDEV_PARAM_CTS_CBW,
8500 set_value, PDEV_CMD);
8501 break;
8502 }
8503
8504 case WE_SET_11N_RATE:
8505 {
8506 uint8_t preamble = 0, nss = 0, rix = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008507
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008508 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008509 set_value);
8510
8511 if (set_value != 0xff) {
8512 rix = RC_2_RATE_IDX(set_value);
8513 if (set_value & 0x80) {
8514 preamble = WMI_RATE_PREAMBLE_HT;
8515 nss = HT_RC_2_STREAMS(set_value) - 1;
8516 } else {
8517 nss = 0;
8518 rix = RC_2_RATE_IDX(set_value);
8519 if (set_value & 0x10) {
8520 preamble =
8521 WMI_RATE_PREAMBLE_CCK;
8522 if (rix != 0x3)
8523 /* Enable Short
8524 * preamble always for
8525 * CCK except 1mbps
8526 */
8527 rix |= 0x4;
8528 } else {
8529 preamble =
8530 WMI_RATE_PREAMBLE_OFDM;
8531 }
8532 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008533 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008534 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008535 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008536 set_value, rix, preamble, nss);
8537
8538 ret = wma_cli_set_command(pAdapter->sessionId,
8539 WMI_VDEV_PARAM_FIXED_RATE,
8540 set_value, VDEV_CMD);
8541 break;
8542 }
8543
8544 case WE_SET_VHT_RATE:
8545 {
8546 uint8_t preamble = 0, nss = 0, rix = 0;
8547
8548 if (set_value != 0xff) {
8549 rix = RC_2_RATE_IDX_11AC(set_value);
8550 preamble = WMI_RATE_PREAMBLE_VHT;
8551 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
8552
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008553 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008554 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008555 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008556 set_value, rix, preamble, nss);
8557 ret = wma_cli_set_command(pAdapter->sessionId,
8558 WMI_VDEV_PARAM_FIXED_RATE,
8559 set_value, VDEV_CMD);
8560 break;
8561 }
8562
8563 case WE_SET_AMPDU:
8564 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008565 hdd_debug("SET AMPDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008566 ret = wma_cli_set_command(pAdapter->sessionId,
8567 GEN_VDEV_PARAM_AMPDU,
8568 set_value, GEN_CMD);
8569 break;
8570 }
8571
8572 case WE_SET_AMSDU:
8573 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008574 hdd_debug("SET AMSDU val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008575 ret = wma_cli_set_command(pAdapter->sessionId,
8576 GEN_VDEV_PARAM_AMSDU,
8577 set_value, GEN_CMD);
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07008578 /* Update the stored ini value */
8579 if (!ret)
8580 hdd_ctx->config->max_amsdu_num = set_value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008581 break;
8582 }
8583
8584 case WE_SET_BURST_ENABLE:
8585 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008586 hdd_debug("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008587 if ((set_value == 0) || (set_value == 1)) {
8588 ret = wma_cli_set_command(pAdapter->sessionId,
8589 WMI_PDEV_PARAM_BURST_ENABLE,
8590 set_value, PDEV_CMD);
8591 } else
8592 ret = -EINVAL;
8593 break;
8594 }
8595 case WE_SET_BURST_DUR:
8596 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008597 hdd_debug("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07008598 if ((set_value > 0) && (set_value <= 102400))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008599 ret = wma_cli_set_command(pAdapter->sessionId,
8600 WMI_PDEV_PARAM_BURST_DUR,
8601 set_value, PDEV_CMD);
8602 else
8603 ret = -EINVAL;
8604 break;
8605 }
8606
8607 case WE_SET_TX_CHAINMASK:
8608 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008609 hdd_debug("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008610 set_value);
8611 ret = wma_cli_set_command(pAdapter->sessionId,
8612 WMI_PDEV_PARAM_TX_CHAIN_MASK,
8613 set_value, PDEV_CMD);
8614 break;
8615 }
8616
8617 case WE_SET_RX_CHAINMASK:
8618 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008619 hdd_debug("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008620 set_value);
8621 ret = wma_cli_set_command(pAdapter->sessionId,
8622 WMI_PDEV_PARAM_RX_CHAIN_MASK,
8623 set_value, PDEV_CMD);
8624 break;
8625 }
8626
8627 case WE_SET_TXPOW_2G:
8628 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008629 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008630 set_value);
8631 ret = wma_cli_set_command(pAdapter->sessionId,
8632 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
8633 set_value, PDEV_CMD);
8634 break;
8635 }
8636
8637 case WE_SET_TXPOW_5G:
8638 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008639 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008640 set_value);
8641 ret = wma_cli_set_command(pAdapter->sessionId,
8642 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
8643 set_value, PDEV_CMD);
8644 break;
8645 }
8646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008647 /* Firmware debug log */
8648 case WE_DBGLOG_LOG_LEVEL:
8649 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008650 hdd_debug("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008651 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
8652 ret = wma_cli_set_command(pAdapter->sessionId,
8653 WMI_DBGLOG_LOG_LEVEL,
8654 set_value, DBG_CMD);
8655 break;
8656 }
8657
8658 case WE_DBGLOG_VAP_ENABLE:
8659 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008660 hdd_debug("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008661 ret = wma_cli_set_command(pAdapter->sessionId,
8662 WMI_DBGLOG_VAP_ENABLE,
8663 set_value, DBG_CMD);
8664 break;
8665 }
8666
8667 case WE_DBGLOG_VAP_DISABLE:
8668 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008669 hdd_debug("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008670 ret = wma_cli_set_command(pAdapter->sessionId,
8671 WMI_DBGLOG_VAP_DISABLE,
8672 set_value, DBG_CMD);
8673 break;
8674 }
8675
8676 case WE_DBGLOG_MODULE_ENABLE:
8677 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008678 hdd_debug("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008679 set_value);
8680 hdd_ctx->fw_log_settings.enable = set_value;
8681 ret = wma_cli_set_command(pAdapter->sessionId,
8682 WMI_DBGLOG_MODULE_ENABLE,
8683 set_value, DBG_CMD);
8684 break;
8685 }
8686
8687 case WE_DBGLOG_MODULE_DISABLE:
8688 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008689 hdd_debug("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008690 set_value);
8691 hdd_ctx->fw_log_settings.enable = set_value;
8692 ret = wma_cli_set_command(pAdapter->sessionId,
8693 WMI_DBGLOG_MODULE_DISABLE,
8694 set_value, DBG_CMD);
8695 break;
8696 }
8697 case WE_DBGLOG_MOD_LOG_LEVEL:
8698 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008699 hdd_debug("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008700 set_value);
8701
8702 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
8703 hdd_ctx->fw_log_settings.index = 0;
8704
8705 hdd_ctx->fw_log_settings.
8706 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
8707 set_value;
8708 hdd_ctx->fw_log_settings.index++;
8709
8710 ret = wma_cli_set_command(pAdapter->sessionId,
8711 WMI_DBGLOG_MOD_LOG_LEVEL,
8712 set_value, DBG_CMD);
8713 break;
8714 }
8715
8716 case WE_DBGLOG_TYPE:
8717 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008718 hdd_debug("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008719 hdd_ctx->fw_log_settings.dl_type = set_value;
8720 ret = wma_cli_set_command(pAdapter->sessionId,
8721 WMI_DBGLOG_TYPE,
8722 set_value, DBG_CMD);
8723 break;
8724 }
8725 case WE_DBGLOG_REPORT_ENABLE:
8726 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008727 hdd_debug("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008728 set_value);
8729 hdd_ctx->fw_log_settings.dl_report = set_value;
8730 ret = wma_cli_set_command(pAdapter->sessionId,
8731 WMI_DBGLOG_REPORT_ENABLE,
8732 set_value, DBG_CMD);
8733 break;
8734 }
8735
8736 case WE_SET_TXRX_FWSTATS:
8737 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008738 hdd_debug("WE_SET_TXRX_FWSTATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008739 ret = wma_cli_set_command(pAdapter->sessionId,
8740 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
8741 set_value, VDEV_CMD);
8742 break;
8743 }
8744
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008745 case WE_SET_TXRX_STATS:
8746 {
8747 hdd_notice("WE_SET_TXRX_STATS val %d", set_value);
8748 ret = cds_get_datapath_handles(&soc, &pdev, &vdev,
8749 pAdapter->sessionId);
8750
Venkata Sharath Chandra Manchalabcdfdb12017-03-29 19:25:45 -07008751 if (ret != 0) {
8752 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
8753 "Invalid handles");
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008754 break;
Venkata Sharath Chandra Manchalabcdfdb12017-03-29 19:25:45 -07008755 }
8756 ret = cdp_txrx_stats(soc, vdev, set_value);
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008757 break;
8758 }
8759
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008760 case WE_TXRX_FWSTATS_RESET:
8761 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008762 hdd_debug("WE_TXRX_FWSTATS_RESET val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008763 ret = wma_cli_set_command(pAdapter->sessionId,
8764 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
8765 set_value, VDEV_CMD);
8766 break;
8767 }
8768
8769 case WE_DUMP_STATS:
8770 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008771 hdd_debug("WE_DUMP_STATS val %d", set_value);
Mohit Khanna3e2115b2016-10-11 13:18:29 -07008772 ret = hdd_wlan_dump_stats(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008773 break;
8774 }
8775
8776 case WE_CLEAR_STATS:
8777 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008778 hdd_debug("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008779 switch (set_value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008780 case CDP_HDD_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008781 memset(&pAdapter->stats, 0, sizeof(pAdapter->stats));
8782 memset(&pAdapter->hdd_stats, 0,
8783 sizeof(pAdapter->hdd_stats));
8784 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008785 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008786 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
8787 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008788 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008789 wlan_hdd_clear_netif_queue_history(hdd_ctx);
8790 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008791 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05308792 hdd_clear_hif_stats();
8793 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008794 default:
Leo Changfdb45c32016-10-28 11:09:23 -07008795 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
8796 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008797 }
8798 break;
8799 }
8800
8801 case WE_PPS_PAID_MATCH:
8802 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308803 if (pAdapter->device_mode != QDF_STA_MODE) {
8804 ret = -EINVAL;
8805 goto free;
8806 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008807
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008808 hdd_debug("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008809 set_value);
8810 ret = wma_cli_set_command(pAdapter->sessionId,
8811 WMI_VDEV_PPS_PAID_MATCH,
8812 set_value, PPS_CMD);
8813 break;
8814 }
8815
8816 case WE_PPS_GID_MATCH:
8817 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308818 if (pAdapter->device_mode != QDF_STA_MODE) {
8819 ret = -EINVAL;
8820 goto free;
8821 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008822 hdd_debug("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008823 set_value);
8824 ret = wma_cli_set_command(pAdapter->sessionId,
8825 WMI_VDEV_PPS_GID_MATCH,
8826 set_value, PPS_CMD);
8827 break;
8828 }
8829
8830 case WE_PPS_EARLY_TIM_CLEAR:
8831 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308832 if (pAdapter->device_mode != QDF_STA_MODE) {
8833 ret = -EINVAL;
8834 goto free;
8835 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008836 hdd_debug(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008837 set_value);
8838 ret = wma_cli_set_command(pAdapter->sessionId,
8839 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
8840 set_value, PPS_CMD);
8841 break;
8842 }
8843
8844 case WE_PPS_EARLY_DTIM_CLEAR:
8845 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308846 if (pAdapter->device_mode != QDF_STA_MODE) {
8847 ret = -EINVAL;
8848 goto free;
8849 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008850 hdd_debug("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008851 set_value);
8852 ret = wma_cli_set_command(pAdapter->sessionId,
8853 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
8854 set_value, PPS_CMD);
8855 break;
8856 }
8857
8858 case WE_PPS_EOF_PAD_DELIM:
8859 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308860 if (pAdapter->device_mode != QDF_STA_MODE) {
8861 ret = -EINVAL;
8862 goto free;
8863 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008864 hdd_debug("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008865 set_value);
8866 ret = wma_cli_set_command(pAdapter->sessionId,
8867 WMI_VDEV_PPS_EOF_PAD_DELIM,
8868 set_value, PPS_CMD);
8869 break;
8870 }
8871
8872 case WE_PPS_MACADDR_MISMATCH:
8873 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308874 if (pAdapter->device_mode != QDF_STA_MODE) {
8875 ret = -EINVAL;
8876 goto free;
8877 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008878 hdd_debug("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008879 set_value);
8880 ret = wma_cli_set_command(pAdapter->sessionId,
8881 WMI_VDEV_PPS_MACADDR_MISMATCH,
8882 set_value, PPS_CMD);
8883 break;
8884 }
8885
8886 case WE_PPS_DELIM_CRC_FAIL:
8887 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308888 if (pAdapter->device_mode != QDF_STA_MODE) {
8889 ret = -EINVAL;
8890 goto free;
8891 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008892 hdd_debug("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008893 set_value);
8894 ret = wma_cli_set_command(pAdapter->sessionId,
8895 WMI_VDEV_PPS_DELIM_CRC_FAIL,
8896 set_value, PPS_CMD);
8897 break;
8898 }
8899
8900 case WE_PPS_GID_NSTS_ZERO:
8901 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308902 if (pAdapter->device_mode != QDF_STA_MODE) {
8903 ret = -EINVAL;
8904 goto free;
8905 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008906 hdd_debug("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008907 set_value);
8908 ret = wma_cli_set_command(pAdapter->sessionId,
8909 WMI_VDEV_PPS_GID_NSTS_ZERO,
8910 set_value, PPS_CMD);
8911 break;
8912 }
8913
8914 case WE_PPS_RSSI_CHECK:
8915 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308916 if (pAdapter->device_mode != QDF_STA_MODE) {
8917 ret = -EINVAL;
8918 goto free;
8919 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008920 hdd_debug("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008921 set_value);
8922 ret = wma_cli_set_command(pAdapter->sessionId,
8923 WMI_VDEV_PPS_RSSI_CHECK,
8924 set_value, PPS_CMD);
8925 break;
8926 }
8927
8928 case WE_PPS_5G_EBT:
8929 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308930 if (pAdapter->device_mode != QDF_STA_MODE) {
8931 ret = -EINVAL;
8932 goto free;
8933 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008934
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008935 hdd_debug("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008936 ret = wma_cli_set_command(pAdapter->sessionId,
8937 WMI_VDEV_PPS_5G_EBT,
8938 set_value, PPS_CMD);
8939 break;
8940 }
8941
8942 case WE_SET_HTSMPS:
8943 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008944 hdd_debug("WE_SET_HTSMPS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008945 ret = wma_cli_set_command(pAdapter->sessionId,
8946 WMI_STA_SMPS_FORCE_MODE_CMDID,
8947 set_value, VDEV_CMD);
8948 break;
8949 }
8950
8951 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
8952 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008953 hdd_debug("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008954 set_value);
8955 ret = wma_cli_set_command(pAdapter->sessionId,
8956 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
8957 set_value, QPOWER_CMD);
8958 break;
8959 }
8960
8961 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
8962 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008963 hdd_debug("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008964 set_value);
8965 ret = wma_cli_set_command(
8966 pAdapter->sessionId,
8967 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
8968 set_value, QPOWER_CMD);
8969 break;
8970 }
8971
8972 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
8973 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008974 hdd_debug("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008975 set_value);
8976 ret = wma_cli_set_command(
8977 pAdapter->sessionId,
8978 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
8979 set_value, QPOWER_CMD);
8980 break;
8981 }
8982
8983 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
8984 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008985 hdd_debug("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008986 set_value);
8987 ret = wma_cli_set_command(
8988 pAdapter->sessionId,
8989 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
8990 set_value, QPOWER_CMD);
8991 break;
8992 }
8993
8994 case WE_MCC_CONFIG_LATENCY:
8995 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008996 wlan_hdd_set_mcc_latency(pAdapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008997 break;
8998 }
8999
9000 case WE_MCC_CONFIG_QUOTA:
9001 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009002 hdd_debug("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009003 set_value);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08009004 ret = wlan_hdd_set_mcc_p2p_quota(pAdapter,
9005 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009006 break;
9007 }
9008 case WE_SET_DEBUG_LOG:
9009 {
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009010 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Nirav Shah1da77682016-05-03 20:16:39 +05309011
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009012 hdd_ctx->config->gEnableDebugLog = set_value;
9013 sme_update_connect_debug(hdd_ctx->hHal, set_value);
9014 break;
9015 }
9016 case WE_SET_EARLY_RX_ADJUST_ENABLE:
9017 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009018 hdd_debug("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009019 if ((set_value == 0) || (set_value == 1))
9020 ret = wma_cli_set_command(
9021 pAdapter->sessionId,
9022 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
9023 set_value, VDEV_CMD);
9024 else
9025 ret = -EINVAL;
9026 break;
9027 }
9028 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
9029 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009030 hdd_debug("SET early_rx bmiss val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009031 ret = wma_cli_set_command(pAdapter->sessionId,
9032 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
9033 set_value, VDEV_CMD);
9034 break;
9035 }
9036 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
9037 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009038 hdd_debug("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009039 set_value);
9040 ret = wma_cli_set_command(
9041 pAdapter->sessionId,
9042 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
9043 set_value, VDEV_CMD);
9044 break;
9045 }
9046 case WE_SET_EARLY_RX_SLOP_STEP:
9047 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009048 hdd_debug("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009049 set_value);
9050 ret = wma_cli_set_command(pAdapter->sessionId,
9051 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
9052 set_value, VDEV_CMD);
9053 break;
9054 }
9055 case WE_SET_EARLY_RX_INIT_SLOP:
9056 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009057 hdd_debug("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009058 set_value);
9059 ret = wma_cli_set_command(pAdapter->sessionId,
9060 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
9061 set_value, VDEV_CMD);
9062 break;
9063 }
9064 case WE_SET_EARLY_RX_ADJUST_PAUSE:
9065 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009066 hdd_debug("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009067 if ((set_value == 0) || (set_value == 1))
9068 ret = wma_cli_set_command(
9069 pAdapter->sessionId,
9070 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
9071 set_value, VDEV_CMD);
9072 else
9073 ret = -EINVAL;
9074 break;
9075 }
9076 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
9077 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009078 hdd_debug("SET early_rx drift sample %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009079 ret = wma_cli_set_command(pAdapter->sessionId,
9080 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
9081 set_value, VDEV_CMD);
9082 break;
9083 }
9084 case WE_SET_SCAN_DISABLE:
9085 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009086 hdd_debug("SET SCAN DISABLE %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009087 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(pAdapter), set_value);
9088 break;
9089 }
Govind Singha471e5e2015-10-12 17:11:14 +05309090 case WE_START_FW_PROFILE:
9091 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009092 hdd_debug("WE_START_FW_PROFILE %d", set_value);
Govind Singha471e5e2015-10-12 17:11:14 +05309093 ret = wma_cli_set_command(pAdapter->sessionId,
9094 WMI_WLAN_PROFILE_TRIGGER_CMDID,
9095 set_value, DBG_CMD);
9096 break;
9097 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05309098 case WE_SET_CHANNEL:
9099 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009100 hdd_debug("Set Channel %d Session ID %d mode %d", set_value,
Abhishek Singh1bdb1572015-10-16 16:24:19 +05309101 pAdapter->sessionId, pAdapter->device_mode);
9102
Krunal Sonif07bb382016-03-10 13:02:11 -08009103 if ((QDF_STA_MODE == pAdapter->device_mode) ||
9104 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05309105
9106 status = sme_ext_change_channel(hHal,
9107 set_value, pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309108 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009109 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05309110 status);
9111 ret = -EINVAL;
9112 }
9113 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07009114 hdd_err("change channel not supported for device mode %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05309115 pAdapter->device_mode);
9116 ret = -EINVAL;
9117 }
9118 break;
9119 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05309120 case WE_SET_CONC_SYSTEM_PREF:
9121 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009122 hdd_debug("New preference: %d", set_value);
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05309123 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
9124 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
9125 hdd_err("Invalid system preference %d", set_value);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309126 ret = -EINVAL;
9127 goto free;
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05309128 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05309129
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05309130 /* hdd_ctx, hdd_ctx->config are already checked for null */
9131 hdd_ctx->config->conc_system_pref = set_value;
9132 break;
9133 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08009134 case WE_SET_11AX_RATE:
9135 ret = hdd_set_11ax_rate(pAdapter, set_value, NULL);
9136 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07009137 case WE_SET_DCM:
9138 hdd_notice("Set WMI_VDEV_PARAM_HE_DCM: %d", set_value);
9139 ret = wma_cli_set_command(pAdapter->sessionId,
9140 WMI_VDEV_PARAM_HE_DCM, set_value,
9141 VDEV_CMD);
9142 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07009143 case WE_SET_RANGE_EXT:
9144 hdd_notice("Set WMI_VDEV_PARAM_HE_RANGE_EXT: %d", set_value);
9145 ret = wma_cli_set_command(pAdapter->sessionId,
9146 WMI_VDEV_PARAM_HE_RANGE_EXT,
9147 set_value, VDEV_CMD);
9148 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009149 default:
9150 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009151 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009152 sub_cmd);
9153 ret = -EINVAL;
9154 break;
9155 }
9156 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309157 EXIT();
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309158free:
9159 qdf_mem_free(sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009160 return ret;
9161}
9162
9163static int iw_setint_getnone(struct net_device *dev,
9164 struct iw_request_info *info,
9165 union iwreq_data *wrqu,
9166 char *extra)
9167{
9168 int ret;
9169
9170 cds_ssr_protect(__func__);
9171 ret = __iw_setint_getnone(dev, info, wrqu, extra);
9172 cds_ssr_unprotect(__func__);
9173
9174 return ret;
9175}
9176
9177/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009178 * __iw_setnone_get_threeint() - return three value to up layer.
9179 *
9180 * @dev: pointer of net_device of this wireless card
9181 * @info: meta data about Request sent
9182 * @wrqu: include request info
9183 * @extra: buf used for in/Output
9184 *
9185 * Return: execute result
9186 */
9187static int __iw_setnone_get_threeint(struct net_device *dev,
9188 struct iw_request_info *info,
9189 union iwreq_data *wrqu, char *extra)
9190{
9191 int ret = 0; /* success */
9192 uint32_t *value = (int *)extra;
Jeff Johnson3d278b02017-08-29 14:17:47 -07009193 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009194 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009195
9196 ENTER_DEV(dev);
9197 ret = wlan_hdd_validate_context(hdd_ctx);
9198 if (0 != ret)
9199 return ret;
9200
Jeff Johnson441e1f72017-02-07 08:50:49 -08009201 ret = hdd_check_private_wext_control(hdd_ctx, info);
9202 if (0 != ret)
9203 return ret;
9204
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009205 hdd_debug("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009206 switch (value[0]) {
9207 case WE_GET_TSF:
9208 ret = hdd_indicate_tsf(adapter, value, 3);
9209 break;
9210 default:
9211 hdd_err("Invalid IOCTL get_value command %d", value[0]);
9212 break;
9213 }
9214 return ret;
9215}
9216
9217/**
9218 * iw_setnone_get_threeint() - return three value to up layer.
9219 *
9220 * @dev: pointer of net_device of this wireless card
9221 * @info: meta data about Request sent
9222 * @wrqu: include request info
9223 * @extra: buf used for in/Output
9224 *
9225 * Return: execute result
9226 */
9227static int iw_setnone_get_threeint(struct net_device *dev,
9228 struct iw_request_info *info,
9229 union iwreq_data *wrqu, char *extra)
9230{
9231 int ret;
9232
9233 cds_ssr_protect(__func__);
9234 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
9235 cds_ssr_unprotect(__func__);
9236
9237 return ret;
9238}
9239
9240/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009241 * iw_setchar_getnone() - Generic "set string" private ioctl handler
9242 * @dev: device upon which the ioctl was received
9243 * @info: ioctl request information
9244 * @wrqu: ioctl request data
9245 * @extra: ioctl extra data
9246 *
9247 * Return: 0 on success, non-zero on error
9248 */
9249static int __iw_setchar_getnone(struct net_device *dev,
9250 struct iw_request_info *info,
9251 union iwreq_data *wrqu, char *extra)
9252{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309253 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009254 int sub_cmd;
9255 int ret;
9256 char *pBuffer = NULL;
Jeff Johnson3d278b02017-08-29 14:17:47 -07009257 struct hdd_adapter *pAdapter = (netdev_priv(dev));
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009258 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009259 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009260 struct iw_point s_priv_data;
9261
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009262 ENTER_DEV(dev);
9263
Mukul Sharma34777c62015-11-02 20:22:30 +05309264 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009265 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05309266 return -EPERM;
9267 }
9268
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009269 ret = wlan_hdd_validate_context(hdd_ctx);
9270 if (0 != ret)
9271 return ret;
9272
Jeff Johnson441e1f72017-02-07 08:50:49 -08009273 ret = hdd_check_private_wext_control(hdd_ctx, info);
9274 if (0 != ret)
9275 return ret;
9276
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009277 /* helper function to get iwreq_data with compat handling. */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009278 if (hdd_priv_get_data(&s_priv_data, wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009279 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009280
9281 /* make sure all params are correctly passed to function */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009282 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009283 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009284
9285 sub_cmd = s_priv_data.flags;
9286
9287 /* ODD number is used for set, copy data using copy_from_user */
9288 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9289 s_priv_data.length);
9290 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009291 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009292 return -ENOMEM;
9293 }
9294
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009295 hdd_debug("Received length: %d data: %s",
9296 s_priv_data.length, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009297
9298 switch (sub_cmd) {
9299 case WE_WOWL_ADD_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009300 hdd_debug("ADD_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009301 hdd_add_wowl_ptrn(pAdapter, pBuffer);
9302 break;
9303 case WE_WOWL_DEL_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009304 hdd_debug("DEL_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009305 hdd_del_wowl_ptrn(pAdapter, pBuffer);
9306 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009307 case WE_NEIGHBOR_REPORT_REQUEST:
9308 {
9309 tRrmNeighborReq neighborReq;
9310 tRrmNeighborRspCallbackInfo callbackInfo;
9311
9312 if (pConfig->fRrmEnable) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009313 hdd_debug("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009314 neighborReq.no_ssid =
9315 (s_priv_data.length - 1) ? false : true;
9316 if (!neighborReq.no_ssid) {
9317 neighborReq.ssid.length =
9318 (s_priv_data.length - 1) >
9319 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309320 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009321 pBuffer,
9322 neighborReq.ssid.length);
9323 }
9324
9325 callbackInfo.neighborRspCallback = NULL;
9326 callbackInfo.neighborRspCallbackContext = NULL;
9327 callbackInfo.timeout = 5000; /* 5 seconds */
9328 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
9329 (pAdapter),
9330 pAdapter->sessionId,
9331 &neighborReq,
9332 &callbackInfo);
9333 } else {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009334 hdd_err("Ignoring neighbor request as RRM not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009335 ret = -EINVAL;
9336 }
9337 }
9338 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009339 case WE_SET_AP_WPS_IE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009340 hdd_debug("Received WE_SET_AP_WPS_IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009341 sme_update_p2p_ie(WLAN_HDD_GET_HAL_CTX(pAdapter), pBuffer,
9342 s_priv_data.length);
9343 break;
9344 case WE_SET_CONFIG:
9345 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009346 if (QDF_STATUS_SUCCESS != vstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009347 ret = -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009348
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009349 break;
9350 default:
9351 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009352 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009353 sub_cmd);
9354 ret = -EINVAL;
9355 break;
9356 }
9357 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07009358 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309359 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009360 return ret;
9361}
9362
9363static int iw_setchar_getnone(struct net_device *dev,
9364 struct iw_request_info *info,
9365 union iwreq_data *wrqu, char *extra)
9366{
9367 int ret;
9368
9369 cds_ssr_protect(__func__);
9370 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
9371 cds_ssr_unprotect(__func__);
9372
9373 return ret;
9374}
9375
9376/**
9377 * iw_setnone_getint() - Generic "get integer" private ioctl handler
9378 * @dev: device upon which the ioctl was received
9379 * @info: ioctl request information
9380 * @wrqu: ioctl request data
9381 * @extra: ioctl extra data
9382 *
9383 * Return: 0 on success, non-zero on error
9384 */
9385static int __iw_setnone_getint(struct net_device *dev,
9386 struct iw_request_info *info,
9387 union iwreq_data *wrqu, char *extra)
9388{
Jeff Johnson3d278b02017-08-29 14:17:47 -07009389 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009390 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9391 int *value = (int *)extra;
9392 int ret;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309393 tSmeConfigParams *sme_config;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009394 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009395
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309396 sme_config = qdf_mem_malloc(sizeof(*sme_config));
9397 if (!sme_config) {
9398 hdd_err("failed to allocate memory for sme_config");
9399 return -ENOMEM;
9400 }
9401 qdf_mem_zero(sme_config, sizeof(*sme_config));
9402
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009403 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309404
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009405 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
9406 ret = wlan_hdd_validate_context(hdd_ctx);
9407 if (0 != ret)
9408 return ret;
9409
Jeff Johnson441e1f72017-02-07 08:50:49 -08009410 ret = hdd_check_private_wext_control(hdd_ctx, info);
9411 if (0 != ret)
9412 return ret;
9413
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009414 switch (value[0]) {
9415 case WE_GET_11D_STATE:
9416 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309417 sme_get_config_param(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009418
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309419 *value = sme_config->csrConfig.Is11dSupportEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009420
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009421 hdd_debug("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009422
9423 break;
9424 }
9425
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009426 case WE_GET_WLAN_DBG:
9427 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309428 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009429 *value = 0;
9430 break;
9431 }
9432 case WE_GET_MAX_ASSOC:
9433 {
9434 if (sme_cfg_get_int
9435 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309436 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009437 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009438 ret = -EIO;
9439 }
9440 break;
9441 }
9442 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
9443 *value = (WLAN_HDD_GET_CTX(
9444 pAdapter))->config->force_sap_acs;
9445 break;
9446
9447 case WE_GET_CONCURRENCY_MODE:
9448 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08009449 *value = policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009450
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009451 hdd_debug("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009452 break;
9453 }
9454
9455 case WE_GET_NSS:
9456 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309457 sme_get_config_param(hHal, sme_config);
9458 *value = (sme_config->csrConfig.enable2x2 == 0) ? 1 : 2;
Srinivas Girigowda576b2352017-08-25 14:44:26 -07009459 if (policy_mgr_is_current_hwmode_dbs(hdd_ctx->hdd_psoc))
9460 *value = *value - 1;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009461 hdd_debug("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009462 break;
9463 }
9464
9465 case WE_GET_GTX_HT_MCS:
9466 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009467 hdd_debug("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009468 *value = wma_cli_get_command(pAdapter->sessionId,
9469 WMI_VDEV_PARAM_GTX_HT_MCS,
9470 GTX_CMD);
9471 break;
9472 }
9473
9474 case WE_GET_GTX_VHT_MCS:
9475 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009476 hdd_debug("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009477 *value = wma_cli_get_command(pAdapter->sessionId,
9478 WMI_VDEV_PARAM_GTX_VHT_MCS,
9479 GTX_CMD);
9480 break;
9481 }
9482
9483 case WE_GET_GTX_USRCFG:
9484 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009485 hdd_debug("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009486 *value = wma_cli_get_command(pAdapter->sessionId,
9487 WMI_VDEV_PARAM_GTX_USR_CFG,
9488 GTX_CMD);
9489 break;
9490 }
9491
9492 case WE_GET_GTX_THRE:
9493 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009494 hdd_debug("GET WMI_VDEV_PARAM_GTX_THRE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009495 *value = wma_cli_get_command(pAdapter->sessionId,
9496 WMI_VDEV_PARAM_GTX_THRE,
9497 GTX_CMD);
9498 break;
9499 }
9500
9501 case WE_GET_GTX_MARGIN:
9502 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009503 hdd_debug("GET WMI_VDEV_PARAM_GTX_MARGIN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009504 *value = wma_cli_get_command(pAdapter->sessionId,
9505 WMI_VDEV_PARAM_GTX_MARGIN,
9506 GTX_CMD);
9507 break;
9508 }
9509
9510 case WE_GET_GTX_STEP:
9511 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009512 hdd_debug("GET WMI_VDEV_PARAM_GTX_STEP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009513 *value = wma_cli_get_command(pAdapter->sessionId,
9514 WMI_VDEV_PARAM_GTX_STEP,
9515 GTX_CMD);
9516 break;
9517 }
9518
9519 case WE_GET_GTX_MINTPC:
9520 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009521 hdd_debug("GET WMI_VDEV_PARAM_GTX_MINTPC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009522 *value = wma_cli_get_command(pAdapter->sessionId,
9523 WMI_VDEV_PARAM_GTX_MINTPC,
9524 GTX_CMD);
9525 break;
9526 }
9527
9528 case WE_GET_GTX_BWMASK:
9529 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009530 hdd_debug("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009531 *value = wma_cli_get_command(pAdapter->sessionId,
9532 WMI_VDEV_PARAM_GTX_BW_MASK,
9533 GTX_CMD);
9534 break;
9535 }
9536
9537 case WE_GET_LDPC:
9538 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309539 ret = hdd_get_ldpc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009540 break;
9541 }
9542
9543 case WE_GET_TX_STBC:
9544 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309545 ret = hdd_get_tx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009546 break;
9547 }
9548
9549 case WE_GET_RX_STBC:
9550 {
Manjeet Singhe80d6d82016-09-02 19:04:41 +05309551 ret = hdd_get_rx_stbc(pAdapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009552 break;
9553 }
9554
9555 case WE_GET_SHORT_GI:
9556 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009557 hdd_debug("GET WMI_VDEV_PARAM_SGI");
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009558 *value = wma_cli_get_command(pAdapter->sessionId,
9559 WMI_VDEV_PARAM_SGI,
9560 VDEV_CMD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009561 break;
9562 }
9563
9564 case WE_GET_RTSCTS:
9565 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009566 hdd_debug("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009567 *value = wma_cli_get_command(pAdapter->sessionId,
9568 WMI_VDEV_PARAM_ENABLE_RTSCTS,
9569 VDEV_CMD);
9570 break;
9571 }
9572
9573 case WE_GET_CHWIDTH:
9574 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009575 hdd_debug("GET WMI_VDEV_PARAM_CHWIDTH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009576 *value = wma_cli_get_command(pAdapter->sessionId,
9577 WMI_VDEV_PARAM_CHWIDTH,
9578 VDEV_CMD);
9579 break;
9580 }
9581
9582 case WE_GET_ANI_EN_DIS:
9583 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009584 hdd_debug("GET WMI_PDEV_PARAM_ANI_ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009585 *value = wma_cli_get_command(pAdapter->sessionId,
9586 WMI_PDEV_PARAM_ANI_ENABLE,
9587 PDEV_CMD);
9588 break;
9589 }
9590
9591 case WE_GET_ANI_POLL_PERIOD:
9592 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009593 hdd_debug("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009594 *value = wma_cli_get_command(pAdapter->sessionId,
9595 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
9596 PDEV_CMD);
9597 break;
9598 }
9599
9600 case WE_GET_ANI_LISTEN_PERIOD:
9601 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009602 hdd_debug("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009603 *value = wma_cli_get_command(pAdapter->sessionId,
9604 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
9605 PDEV_CMD);
9606 break;
9607 }
9608
9609 case WE_GET_ANI_OFDM_LEVEL:
9610 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009611 hdd_debug("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009612 *value = wma_cli_get_command(pAdapter->sessionId,
9613 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
9614 PDEV_CMD);
9615 break;
9616 }
9617
9618 case WE_GET_ANI_CCK_LEVEL:
9619 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009620 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009621 *value = wma_cli_get_command(pAdapter->sessionId,
9622 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
9623 PDEV_CMD);
9624 break;
9625 }
9626
9627 case WE_GET_DYNAMIC_BW:
9628 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009629 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009630 *value = wma_cli_get_command(pAdapter->sessionId,
9631 WMI_PDEV_PARAM_DYNAMIC_BW,
9632 PDEV_CMD);
9633 break;
9634 }
9635
9636 case WE_GET_11N_RATE:
9637 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009638 hdd_debug("GET WMI_VDEV_PARAM_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009639 *value = wma_cli_get_command(pAdapter->sessionId,
9640 WMI_VDEV_PARAM_FIXED_RATE,
9641 VDEV_CMD);
9642 break;
9643 }
9644
9645 case WE_GET_AMPDU:
9646 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009647 hdd_debug("GET AMPDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009648 *value = wma_cli_get_command(pAdapter->sessionId,
9649 GEN_VDEV_PARAM_AMPDU,
9650 GEN_CMD);
9651 break;
9652 }
9653
9654 case WE_GET_AMSDU:
9655 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009656 hdd_debug("GET AMSDU");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009657 *value = wma_cli_get_command(pAdapter->sessionId,
9658 GEN_VDEV_PARAM_AMSDU,
9659 GEN_CMD);
9660 break;
9661 }
9662
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009663 case WE_GET_ROAM_SYNCH_DELAY:
9664 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009665 hdd_debug("GET ROAM SYNCH DELAY");
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009666 *value = wma_cli_get_command(pAdapter->sessionId,
9667 GEN_VDEV_ROAM_SYNCH_DELAY,
9668 GEN_CMD);
9669 break;
9670 }
9671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009672 case WE_GET_BURST_ENABLE:
9673 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009674 hdd_debug("GET Burst enable value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009675 *value = wma_cli_get_command(pAdapter->sessionId,
9676 WMI_PDEV_PARAM_BURST_ENABLE,
9677 PDEV_CMD);
9678 break;
9679 }
9680 case WE_GET_BURST_DUR:
9681 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009682 hdd_debug("GET Burst Duration value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009683 *value = wma_cli_get_command(pAdapter->sessionId,
9684 WMI_PDEV_PARAM_BURST_DUR,
9685 PDEV_CMD);
9686 break;
9687 }
9688
9689 case WE_GET_TX_CHAINMASK:
9690 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009691 hdd_debug("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009692 *value = wma_cli_get_command(pAdapter->sessionId,
9693 WMI_PDEV_PARAM_TX_CHAIN_MASK,
9694 PDEV_CMD);
9695 break;
9696 }
9697
9698 case WE_GET_RX_CHAINMASK:
9699 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009700 hdd_debug("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009701 *value = wma_cli_get_command(pAdapter->sessionId,
9702 WMI_PDEV_PARAM_RX_CHAIN_MASK,
9703 PDEV_CMD);
9704 break;
9705 }
9706
9707 case WE_GET_TXPOW_2G:
9708 {
9709 uint32_t txpow2g = 0;
9710 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009711
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009712 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009713 *value = wma_cli_get_command(pAdapter->sessionId,
9714 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
9715 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309716 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009717 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9718 &txpow2g)) {
9719 return -EIO;
9720 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009721 hdd_debug("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009722 break;
9723 }
9724
9725 case WE_GET_TXPOW_5G:
9726 {
9727 uint32_t txpow5g = 0;
9728 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009729
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009730 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009731 *value = wma_cli_get_command(pAdapter->sessionId,
9732 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
9733 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309734 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009735 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9736 &txpow5g)) {
9737 return -EIO;
9738 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009739 hdd_debug("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009740 break;
9741 }
9742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009743 case WE_GET_PPS_PAID_MATCH:
9744 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009745 hdd_debug("GET WMI_VDEV_PPS_PAID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009746 *value = wma_cli_get_command(pAdapter->sessionId,
9747 WMI_VDEV_PPS_PAID_MATCH,
9748 PPS_CMD);
9749 break;
9750 }
9751
9752 case WE_GET_PPS_GID_MATCH:
9753 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009754 hdd_debug("GET WMI_VDEV_PPS_GID_MATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009755 *value = wma_cli_get_command(pAdapter->sessionId,
9756 WMI_VDEV_PPS_GID_MATCH,
9757 PPS_CMD);
9758 break;
9759 }
9760
9761 case WE_GET_PPS_EARLY_TIM_CLEAR:
9762 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009763 hdd_debug("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009764 *value = wma_cli_get_command(pAdapter->sessionId,
9765 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
9766 PPS_CMD);
9767 break;
9768 }
9769
9770 case WE_GET_PPS_EARLY_DTIM_CLEAR:
9771 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009772 hdd_debug("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009773 *value = wma_cli_get_command(pAdapter->sessionId,
9774 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
9775 PPS_CMD);
9776 break;
9777 }
9778
9779 case WE_GET_PPS_EOF_PAD_DELIM:
9780 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009781 hdd_debug("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009782 *value = wma_cli_get_command(pAdapter->sessionId,
9783 WMI_VDEV_PPS_EOF_PAD_DELIM,
9784 PPS_CMD);
9785 break;
9786 }
9787
9788 case WE_GET_PPS_MACADDR_MISMATCH:
9789 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009790 hdd_debug("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009791 *value = wma_cli_get_command(pAdapter->sessionId,
9792 WMI_VDEV_PPS_MACADDR_MISMATCH,
9793 PPS_CMD);
9794 break;
9795 }
9796
9797 case WE_GET_PPS_DELIM_CRC_FAIL:
9798 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009799 hdd_debug("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009800 *value = wma_cli_get_command(pAdapter->sessionId,
9801 WMI_VDEV_PPS_DELIM_CRC_FAIL,
9802 PPS_CMD);
9803 break;
9804 }
9805
9806 case WE_GET_PPS_GID_NSTS_ZERO:
9807 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009808 hdd_debug("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009809 *value = wma_cli_get_command(pAdapter->sessionId,
9810 WMI_VDEV_PPS_GID_NSTS_ZERO,
9811 PPS_CMD);
9812 break;
9813 }
9814
9815 case WE_GET_PPS_RSSI_CHECK:
9816 {
9817
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009818 hdd_debug("GET WMI_VDEV_PPS_RSSI_CHECK");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009819 *value = wma_cli_get_command(pAdapter->sessionId,
9820 WMI_VDEV_PPS_RSSI_CHECK,
9821 PPS_CMD);
9822 break;
9823 }
9824
9825 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
9826 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009827 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009828 *value = wma_cli_get_command(pAdapter->sessionId,
9829 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
9830 QPOWER_CMD);
9831 break;
9832 }
9833
9834 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
9835 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009836 hdd_debug("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009837 *value = wma_cli_get_command(pAdapter->sessionId,
9838 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
9839 QPOWER_CMD);
9840 break;
9841 }
9842
9843 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
9844 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009845 hdd_debug("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009846 *value = wma_cli_get_command(pAdapter->sessionId,
9847 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
9848 QPOWER_CMD);
9849 break;
9850 }
9851
9852 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
9853 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009854 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009855 *value = wma_cli_get_command(pAdapter->sessionId,
9856 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
9857 QPOWER_CMD);
9858 break;
9859 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009860 case WE_CAP_TSF:
9861 ret = hdd_capture_tsf(pAdapter, (uint32_t *)value, 1);
9862 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009863 case WE_GET_TEMPERATURE:
9864 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009865 hdd_debug("WE_GET_TEMPERATURE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009866 ret = wlan_hdd_get_temperature(pAdapter, value);
9867 break;
9868 }
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07009869 case WE_GET_DCM:
9870 hdd_notice("GET WMI_VDEV_PARAM_HE_DCM");
9871 *value = wma_cli_get_command(pAdapter->sessionId,
9872 WMI_VDEV_PARAM_HE_DCM,
9873 VDEV_CMD);
9874 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07009875 case WE_GET_RANGE_EXT:
9876 hdd_notice("GET WMI_VDEV_PARAM_HE_RANGE_EXT");
9877 *value = wma_cli_get_command(pAdapter->sessionId,
9878 WMI_VDEV_PARAM_HE_RANGE_EXT,
9879 VDEV_CMD);
9880 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009881 default:
9882 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009883 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009884 value[0]);
9885 break;
9886 }
9887 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309888 EXIT();
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309889 qdf_mem_free(sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009890 return ret;
9891}
9892
9893static int iw_setnone_getint(struct net_device *dev,
9894 struct iw_request_info *info,
9895 union iwreq_data *wrqu, char *extra)
9896{
9897 int ret;
9898
9899 cds_ssr_protect(__func__);
9900 ret = __iw_setnone_getint(dev, info, wrqu, extra);
9901 cds_ssr_unprotect(__func__);
9902
9903 return ret;
9904}
9905
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309906static int hdd_set_fwtest(int argc, int cmd, int value)
9907{
9908 struct set_fwtest_params *fw_test;
9909
9910 /* check for max number of arguments */
9911 if (argc > (WMA_MAX_NUM_ARGS) ||
9912 argc != HDD_FWTEST_PARAMS) {
9913 hdd_err("Too Many args %d", argc);
9914 return -EINVAL;
9915 }
9916 /*
9917 * check if number of arguments are 3 then, check
9918 * then set the default value for sounding interval.
9919 */
9920 if (HDD_FWTEST_PARAMS == argc) {
9921 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
9922 value = HDD_FWTEST_SU_DEFAULT_VALUE;
9923 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
9924 value = HDD_FWTEST_MU_DEFAULT_VALUE;
9925 }
9926 /* check sounding interval value should not exceed to max */
9927 if (value > HDD_FWTEST_MAX_VALUE) {
9928 hdd_err("Invalid arguments value should not exceed max: %d",
9929 value);
9930 return -EINVAL;
9931 }
9932 fw_test = qdf_mem_malloc(sizeof(*fw_test));
9933 if (NULL == fw_test) {
9934 hdd_err("qdf_mem_malloc failed for fw_test");
9935 return -ENOMEM;
9936 }
9937 fw_test->arg = cmd;
9938 fw_test->value = value;
9939 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
9940 qdf_mem_free(fw_test);
9941 hdd_err("Not able to post FW_TEST_CMD message to WMA");
9942 return -EINVAL;
9943 }
9944 return 0;
9945}
9946
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009947/**
9948 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
9949 * @dev: device upon which the ioctl was received
9950 * @info: ioctl request information
9951 * @wrqu: ioctl request data
9952 * @extra: ioctl extra data
9953 *
9954 * Return: 0 on success, non-zero on error
9955 */
9956static int __iw_set_three_ints_getnone(struct net_device *dev,
9957 struct iw_request_info *info,
9958 union iwreq_data *wrqu, char *extra)
9959{
Jeff Johnson3d278b02017-08-29 14:17:47 -07009960 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009961 int *value = (int *)extra;
9962 int sub_cmd = value[0];
9963 int ret;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009964 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009965
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009966 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309967
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009968 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009969 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009970 return -EPERM;
9971 }
9972
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009973 ret = wlan_hdd_validate_context(hdd_ctx);
9974 if (0 != ret)
9975 return ret;
9976
Jeff Johnson441e1f72017-02-07 08:50:49 -08009977 ret = hdd_check_private_wext_control(hdd_ctx, info);
9978 if (0 != ret)
9979 return ret;
9980
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009981 switch (sub_cmd) {
9982
9983 case WE_SET_WLAN_DBG:
Dustin Brown36e2e5c2017-05-16 15:41:37 -07009984 qdf_print_set_category_verbose(qdf_get_pidx(), value[1],
9985 value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009986 break;
9987 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309988 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009989 break;
9990
9991 /* value[3] the acs band is not required as start and end channels are
9992 * enough but this cmd is maintained under set three ints for historic
9993 * reasons.
9994 */
9995 case WE_SET_SAP_CHANNELS:
9996 if (wlan_hdd_validate_operation_channel(pAdapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309997 QDF_STATUS_SUCCESS ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009998 wlan_hdd_validate_operation_channel(pAdapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309999 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010000 ret = -EINVAL;
10001 } else {
10002 hdd_ctx->config->force_sap_acs_st_ch = value[1];
10003 hdd_ctx->config->force_sap_acs_end_ch = value[2];
10004 }
10005 break;
10006 case WE_SET_DUAL_MAC_SCAN_CONFIG:
10007 hdd_debug("Ioctl to set dual mac scan config");
Tushnim Bhattacharyya49ed8ab2017-05-26 18:20:10 -070010008 if (hdd_ctx->config->dual_mac_feature_disable ==
10009 DISABLE_DBS_CXN_AND_SCAN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010010 hdd_err("Dual mac feature is disabled from INI");
10011 return -EPERM;
10012 }
10013 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010014 policy_mgr_set_dual_mac_scan_config(hdd_ctx->hdd_psoc,
10015 value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010016 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053010017 case WE_SET_FW_TEST:
10018 {
10019 ret = hdd_set_fwtest(value[1], value[2], value[3]);
10020 if (ret) {
10021 hdd_err("Not able to set fwtest %d", ret);
10022 return ret;
10023 }
10024 }
10025 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010026 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070010027 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010028 break;
10029
10030 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010031 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010032 return ret;
10033}
10034
10035int iw_set_three_ints_getnone(struct net_device *dev,
10036 struct iw_request_info *info,
10037 union iwreq_data *wrqu, char *extra)
10038{
10039 int ret;
10040
10041 cds_ssr_protect(__func__);
10042 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
10043 cds_ssr_unprotect(__func__);
10044
10045 return ret;
10046}
10047
10048/**
10049 * hdd_connection_state_string() - Get connection state string
10050 * @connection_state: enum to be converted to a string
10051 *
10052 * Return: the string equivalent of @connection_state
10053 */
10054static const char *
10055hdd_connection_state_string(eConnectionState connection_state)
10056{
10057 switch (connection_state) {
10058 CASE_RETURN_STRING(eConnectionState_NotConnected);
10059 CASE_RETURN_STRING(eConnectionState_Connecting);
10060 CASE_RETURN_STRING(eConnectionState_Associated);
10061 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
10062 CASE_RETURN_STRING(eConnectionState_IbssConnected);
10063 CASE_RETURN_STRING(eConnectionState_Disconnecting);
10064 default:
10065 return "UNKNOWN";
10066 }
10067}
10068
Naveen Rawat910726a2017-03-06 11:42:51 -080010069#if defined(FEATURE_OEM_DATA_SUPPORT)
10070/**
10071 * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
10072 * wifi_pos api to get oem data caps
10073 * @dev: net device upon which the request was received
10074 * @info: ioctl request information
10075 * @wrqu: ioctl request data
10076 * @extra: ioctl data payload
10077 *
10078 * Return: 0 for success, negative errno value on failure
10079 */
10080static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
10081 struct iw_request_info *info,
10082 union iwreq_data *wrqu, char *extra)
10083{
10084 return iw_get_oem_data_cap(dev, info, wrqu, extra);
10085}
10086#elif defined(WIFI_POS_CONVERGED)
10087static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
10088 struct iw_request_info *info,
10089 union iwreq_data *wrqu, char *extra)
10090{
Jeff Johnson3d278b02017-08-29 14:17:47 -070010091 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010092 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Naveen Rawat910726a2017-03-06 11:42:51 -080010093
10094 return os_if_wifi_pos_populate_caps(hdd_ctx->hdd_psoc,
10095 (struct wifi_pos_driver_caps *)extra);
10096}
10097#else
10098static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
10099 struct iw_request_info *info,
10100 union iwreq_data *wrqu, char *extra)
10101{
10102 return -ENOTSUPP;
10103}
10104#endif
10105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010106/**
10107 * iw_get_char_setnone() - Generic "get string" private ioctl handler
10108 * @dev: device upon which the ioctl was received
10109 * @info: ioctl request information
10110 * @wrqu: ioctl request data
10111 * @extra: ioctl extra data
10112 *
10113 * Return: 0 on success, non-zero on error
10114 */
10115static int __iw_get_char_setnone(struct net_device *dev,
10116 struct iw_request_info *info,
10117 union iwreq_data *wrqu, char *extra)
10118{
Jeff Johnson3d278b02017-08-29 14:17:47 -070010119 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010120 int sub_cmd = wrqu->data.flags;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010121 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010122 int ret;
10123#ifdef WLAN_FEATURE_11W
10124 hdd_wext_state_t *pWextState;
10125#endif
10126
10127#ifdef WLAN_FEATURE_11W
10128 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10129#endif
10130
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010131 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010132
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010133 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
10134 ret = wlan_hdd_validate_context(hdd_ctx);
10135 if (0 != ret)
10136 return ret;
10137
Jeff Johnson441e1f72017-02-07 08:50:49 -080010138 ret = hdd_check_private_wext_control(hdd_ctx, info);
10139 if (0 != ret)
10140 return ret;
10141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010142 switch (sub_cmd) {
10143 case WE_WLAN_VERSION:
10144 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +053010145 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010146 break;
10147 }
10148
10149 case WE_GET_STATS:
10150 {
10151 hdd_wlan_get_stats(pAdapter, &(wrqu->data.length),
10152 extra, WE_MAX_STR_LEN);
10153 break;
10154 }
10155
Dustin Brownd9322482017-01-09 12:46:03 -080010156 case WE_GET_SUSPEND_RESUME_STATS:
10157 {
10158 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
10159 WE_MAX_STR_LEN);
10160 if (ret >= 0) {
10161 wrqu->data.length = ret;
10162 ret = 0;
10163 }
10164
10165 break;
10166 }
10167
Govind Singha471e5e2015-10-12 17:11:14 +053010168 case WE_LIST_FW_PROFILE:
10169 hdd_wlan_list_fw_profile(&(wrqu->data.length),
10170 extra, WE_MAX_STR_LEN);
10171 break;
10172
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010173 /* The case prints the current state of the HDD, SME, CSR, PE,
10174 * TL it can be extended for WDI Global State as well. And
10175 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
10176 * and P2P_GO have not been added as of now.
10177 */
10178 case WE_GET_STATES:
10179 {
10180 int buf = 0, len = 0;
10181 int adapter_num = 0;
10182 int count = 0, check = 1;
10183
10184 tHalHandle hHal = NULL;
10185 tpAniSirGlobal pMac = NULL;
Jeff Johnson40dae4e2017-08-29 14:00:25 -070010186 struct hdd_station_ctx *pHddStaCtx = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010187
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010188 struct hdd_context *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson3d278b02017-08-29 14:17:47 -070010189 struct hdd_adapter *useAdapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010190
10191 /* Print wlan0 or p2p0 states based on the adapter_num
10192 * by using the correct adapter
10193 */
10194 while (adapter_num < 2) {
10195 if (WLAN_ADAPTER == adapter_num) {
10196 useAdapter = pAdapter;
10197 buf =
10198 scnprintf(extra + len,
10199 WE_MAX_STR_LEN - len,
10200 "\n\n wlan0 States:-");
10201 len += buf;
10202 } else if (P2P_ADAPTER == adapter_num) {
10203 buf =
10204 scnprintf(extra + len,
10205 WE_MAX_STR_LEN - len,
10206 "\n\n p2p0 States:-");
10207 len += buf;
10208
10209 if (!pHddCtx) {
10210 buf =
10211 scnprintf(extra + len,
10212 WE_MAX_STR_LEN -
10213 len,
10214 "\n pHddCtx is NULL");
10215 len += buf;
10216 break;
10217 }
10218
10219 /* Printing p2p0 states only in the
10220 * case when the device is configured
10221 * as a p2p_client
10222 */
10223 useAdapter =
10224 hdd_get_adapter(pHddCtx,
Krunal Sonif07bb382016-03-10 13:02:11 -080010225 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010226 if (!useAdapter) {
10227 buf =
10228 scnprintf(extra + len,
10229 WE_MAX_STR_LEN -
10230 len,
10231 "\n Device not configured as P2P_CLIENT.");
10232 len += buf;
10233 break;
10234 }
10235 }
10236
10237 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
10238 if (!hHal) {
10239 buf =
10240 scnprintf(extra + len,
10241 WE_MAX_STR_LEN - len,
10242 "\n pMac is NULL");
10243 len += buf;
10244 break;
10245 }
10246 pMac = PMAC_STRUCT(hHal);
10247 if (!pMac) {
10248 buf =
10249 scnprintf(extra + len,
10250 WE_MAX_STR_LEN - len,
10251 "\n pMac is NULL");
10252 len += buf;
10253 break;
10254 }
10255 pHddStaCtx =
10256 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
10257
10258
10259 buf =
10260 scnprintf(extra + len, WE_MAX_STR_LEN - len,
10261 "\n HDD Conn State - %s "
10262 "\n \n SME State:"
10263 "\n Neighbour Roam State - %s"
10264 "\n CSR State - %s"
10265 "\n CSR Substate - %s",
10266 hdd_connection_state_string
10267 (pHddStaCtx->conn_info.connState),
10268 mac_trace_get_neighbour_roam_state
10269 (sme_get_neighbor_roam_state
10270 (hHal, useAdapter->sessionId)),
10271 mac_trace_getcsr_roam_state
10272 (sme_get_current_roam_state
10273 (hHal, useAdapter->sessionId)),
10274 mac_trace_getcsr_roam_sub_state
10275 (sme_get_current_roam_sub_state
10276 (hHal, useAdapter->sessionId))
10277 );
10278 len += buf;
10279 adapter_num++;
10280 }
10281
Mukul Sharma81661ae2015-10-30 20:26:02 +053010282 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010283 /* Printing Lim State starting with global lim states */
10284 buf =
10285 scnprintf(extra + len, WE_MAX_STR_LEN - len,
10286 "\n \n LIM STATES:-"
10287 "\n Global Sme State - %s "
10288 "\n Global mlm State - %s " "\n",
10289 mac_trace_get_lim_sme_state
10290 (sme_get_lim_sme_state(hHal)),
10291 mac_trace_get_lim_mlm_state
10292 (sme_get_lim_sme_state(hHal))
10293 );
10294 len += buf;
10295
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010296 while (check < 3 && count < 255) {
10297 if (sme_is_lim_session_valid(hHal, count)) {
10298 buf =
10299 scnprintf(extra + len,
10300 WE_MAX_STR_LEN -
10301 len,
10302 "\n Lim Valid Session %d:-"
10303 "\n PE Sme State - %s "
10304 "\n PE Mlm State - %s "
10305 "\n", check,
10306 mac_trace_get_lim_sme_state
10307 (sme_get_lim_sme_session_state
10308 (hHal, count)),
10309 mac_trace_get_lim_mlm_state
10310 (sme_get_lim_mlm_session_state
10311 (hHal, count))
10312 );
10313
10314 len += buf;
10315 check++;
10316 }
10317 count++;
10318 }
10319 }
10320
10321 wrqu->data.length = strlen(extra) + 1;
10322 break;
10323 }
10324
10325 case WE_GET_CFG:
10326 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010327 hdd_debug("Printing CLD global INI Config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010328 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(pAdapter),
10329 extra,
10330 QCSAP_IOCTL_MAX_STR_LEN);
10331 wrqu->data.length = strlen(extra) + 1;
10332 break;
10333 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010334 case WE_GET_RSSI:
10335 {
10336 int8_t s7Rssi = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010337
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010338 wlan_hdd_get_rssi(pAdapter, &s7Rssi);
10339 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
10340 wrqu->data.length = strlen(extra) + 1;
10341 break;
10342 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010343
10344 case WE_GET_WMM_STATUS:
10345 {
10346 snprintf(extra, WE_MAX_STR_LEN,
10347 "\nDir: 0=up, 1=down, 3=both\n"
10348 "|------------------------|\n"
10349 "|AC | ACM |Admitted| Dir |\n"
10350 "|------------------------|\n"
10351 "|VO | %d | %3s | %d |\n"
10352 "|VI | %d | %3s | %d |\n"
10353 "|BE | %d | %3s | %d |\n"
10354 "|BK | %d | %3s | %d |\n"
10355 "|------------------------|\n",
10356 pAdapter->hddWmmStatus.
10357 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
10358 pAdapter->hddWmmStatus.
10359 wmmAcStatus[SME_AC_VO].
10360 wmmAcAccessAllowed ? "YES" : "NO",
10361 pAdapter->hddWmmStatus.
10362 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
10363 ts_info.direction,
10364 pAdapter->hddWmmStatus.
10365 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
10366 pAdapter->hddWmmStatus.
10367 wmmAcStatus[SME_AC_VI].
10368 wmmAcAccessAllowed ? "YES" : "NO",
10369 pAdapter->hddWmmStatus.
10370 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
10371 ts_info.direction,
10372 pAdapter->hddWmmStatus.
10373 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
10374 pAdapter->hddWmmStatus.
10375 wmmAcStatus[SME_AC_BE].
10376 wmmAcAccessAllowed ? "YES" : "NO",
10377 pAdapter->hddWmmStatus.
10378 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
10379 ts_info.direction,
10380 pAdapter->hddWmmStatus.
10381 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
10382 pAdapter->hddWmmStatus.
10383 wmmAcStatus[SME_AC_BK].
10384 wmmAcAccessAllowed ? "YES" : "NO",
10385 pAdapter->hddWmmStatus.
10386 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
10387 ts_info.direction);
10388
10389 wrqu->data.length = strlen(extra) + 1;
10390 break;
10391 }
10392 case WE_GET_CHANNEL_LIST:
10393 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010394 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010395 uint8_t i, len;
10396 char *buf;
10397 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
10398 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010399 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010400
Srinivas Girigowdac231df62017-03-24 18:27:57 -070010401 struct channel_list_info channel_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010402
10403 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +053010404 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010405 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010406 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010407 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010408 return -EINVAL;
10409 }
10410 buf = extra;
10411 /*
10412 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
10413 * Maximum buffer needed = 5 * number of channels.
10414 * Check ifsufficient buffer is available and then
10415 * proceed to fill the buffer.
10416 */
10417 if (WE_MAX_STR_LEN <
10418 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010419 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010420 return -EINVAL;
10421 }
10422 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
10423 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010424 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010425 ubuf, &ubuf_len)) {
10426 /* Printing Country code in getChannelList */
10427 for (i = 0; i < (ubuf_len - 1); i++)
10428 len += scnprintf(buf + len,
10429 WE_MAX_STR_LEN - len,
10430 "%c", ubuf[i]);
10431 }
10432 for (i = 0; i < channel_list.num_channels; i++) {
10433 len +=
10434 scnprintf(buf + len, WE_MAX_STR_LEN - len,
10435 " %u", channel_list.channels[i]);
10436 }
10437 wrqu->data.length = strlen(extra) + 1;
10438
10439 break;
10440 }
10441#ifdef FEATURE_WLAN_TDLS
10442 case WE_GET_TDLS_PEERS:
10443 {
10444 wrqu->data.length =
10445 wlan_hdd_tdls_get_all_peers(pAdapter, extra,
10446 WE_MAX_STR_LEN) + 1;
10447 break;
10448 }
10449#endif
10450#ifdef WLAN_FEATURE_11W
10451 case WE_GET_11W_INFO:
10452 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010453 hdd_debug("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010454 pWextState->roamProfile.MFPEnabled);
10455
10456 snprintf(extra, WE_MAX_STR_LEN,
10457 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
10458 "\n Number of Unprotected Disassocs %d"
10459 "\n Number of Unprotected Deauths %d",
10460 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
10461 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
10462 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
10463 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
10464 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
10465 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
10466 pWextState->roamProfile.MFPEnabled,
10467 pAdapter->hdd_stats.hddPmfStats.
10468 numUnprotDisassocRx,
10469 pAdapter->hdd_stats.hddPmfStats.
10470 numUnprotDeauthRx);
10471
10472 wrqu->data.length = strlen(extra) + 1;
10473 break;
10474 }
10475#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010476 case WE_GET_IBSS_STA_INFO:
10477 {
Jeff Johnson40dae4e2017-08-29 14:00:25 -070010478 struct hdd_station_ctx *pHddStaCtx =
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010479 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10480 int idx = 0;
10481 int length = 0, buf = 0;
10482
Naveen Rawatc45d1622016-07-05 12:20:09 -070010483 for (idx = 0; idx < MAX_PEERS; idx++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -070010484 if (HDD_WLAN_INVALID_STA_ID !=
10485 pHddStaCtx->conn_info.staId[idx]) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010486 buf = snprintf
10487 ((extra + length),
10488 WE_MAX_STR_LEN - length,
10489 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
10490 pHddStaCtx->conn_info.staId[idx],
10491 pHddStaCtx->conn_info.
10492 peerMacAddress[idx].bytes[0],
10493 pHddStaCtx->conn_info.
10494 peerMacAddress[idx].bytes[1],
10495 pHddStaCtx->conn_info.
10496 peerMacAddress[idx].bytes[2],
10497 pHddStaCtx->conn_info.
10498 peerMacAddress[idx].bytes[3],
10499 pHddStaCtx->conn_info.
10500 peerMacAddress[idx].bytes[4],
10501 pHddStaCtx->conn_info.
10502 peerMacAddress[idx].bytes[5]
10503 );
10504 length += buf;
10505 }
10506 }
10507 wrqu->data.length = strlen(extra) + 1;
10508 break;
10509 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010510 case WE_GET_PHYMODE:
10511 {
10512 bool ch_bond24 = false, ch_bond5g = false;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010513 struct hdd_context *hddctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010514 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10515 eCsrPhyMode phymode;
10516 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010517 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010518
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010519 sme_config = qdf_mem_malloc(sizeof(*sme_config));
10520 if (!sme_config) {
10521 hdd_err("Out of memory");
10522 ret = -ENOMEM;
10523 break;
10524 }
10525
10526 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010527 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010528 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010529 ch_bond24 = true;
10530
10531 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010532 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010533 ch_bond5g = true;
10534
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010535 qdf_mem_free(sme_config);
10536
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010537 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010538 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010539 sme_get_freq_band(hal, &currBand))) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010540 hdd_err("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010541 return -EIO;
10542 }
10543
10544 switch (phymode) {
10545 case eCSR_DOT11_MODE_AUTO:
10546 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
10547 break;
10548 case eCSR_DOT11_MODE_11n:
10549 case eCSR_DOT11_MODE_11n_ONLY:
10550 if (currBand == eCSR_BAND_24) {
10551 if (ch_bond24)
10552 snprintf(extra, WE_MAX_STR_LEN,
10553 "11NGHT40");
10554 else
10555 snprintf(extra, WE_MAX_STR_LEN,
10556 "11NGHT20");
10557 } else if (currBand == eCSR_BAND_5G) {
10558 if (ch_bond5g)
10559 snprintf(extra, WE_MAX_STR_LEN,
10560 "11NAHT40");
10561 else
10562 snprintf(extra, WE_MAX_STR_LEN,
10563 "11NAHT20");
10564 } else {
10565 snprintf(extra, WE_MAX_STR_LEN, "11N");
10566 }
10567 break;
10568 case eCSR_DOT11_MODE_abg:
10569 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
10570 break;
10571 case eCSR_DOT11_MODE_11a:
10572 snprintf(extra, WE_MAX_STR_LEN, "11A");
10573 break;
10574 case eCSR_DOT11_MODE_11b:
10575 case eCSR_DOT11_MODE_11b_ONLY:
10576 snprintf(extra, WE_MAX_STR_LEN, "11B");
10577 break;
10578 case eCSR_DOT11_MODE_11g:
10579 case eCSR_DOT11_MODE_11g_ONLY:
10580 snprintf(extra, WE_MAX_STR_LEN, "11G");
10581 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010582 case eCSR_DOT11_MODE_11ac:
10583 case eCSR_DOT11_MODE_11ac_ONLY:
10584 if (hddctx->config->vhtChannelWidth ==
10585 eHT_CHANNEL_WIDTH_20MHZ)
10586 snprintf(extra, WE_MAX_STR_LEN,
10587 "11ACVHT20");
10588 else if (hddctx->config->vhtChannelWidth ==
10589 eHT_CHANNEL_WIDTH_40MHZ)
10590 snprintf(extra, WE_MAX_STR_LEN,
10591 "11ACVHT40");
10592 else if (hddctx->config->vhtChannelWidth ==
10593 eHT_CHANNEL_WIDTH_80MHZ)
10594 snprintf(extra, WE_MAX_STR_LEN,
10595 "11ACVHT80");
10596 else if (hddctx->config->vhtChannelWidth ==
10597 eHT_CHANNEL_WIDTH_160MHZ)
10598 snprintf(extra, WE_MAX_STR_LEN,
10599 "11ACVHT160");
10600 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080010601 case eCSR_DOT11_MODE_11ax:
10602 case eCSR_DOT11_MODE_11ax_ONLY:
10603 /* currently using vhtChannelWidth */
10604 if (hddctx->config->vhtChannelWidth ==
10605 eHT_CHANNEL_WIDTH_20MHZ)
10606 snprintf(extra, WE_MAX_STR_LEN,
10607 "11AX_HE_20");
10608 else if (hddctx->config->vhtChannelWidth ==
10609 eHT_CHANNEL_WIDTH_40MHZ)
10610 snprintf(extra, WE_MAX_STR_LEN,
10611 "11AX_HE_40");
10612 else if (hddctx->config->vhtChannelWidth ==
10613 eHT_CHANNEL_WIDTH_80MHZ)
10614 snprintf(extra, WE_MAX_STR_LEN,
10615 "11AX_HE_80");
10616 else if (hddctx->config->vhtChannelWidth ==
10617 eHT_CHANNEL_WIDTH_160MHZ)
10618 snprintf(extra, WE_MAX_STR_LEN,
10619 "11AX_HE_160");
10620 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010621 }
10622
10623 wrqu->data.length = strlen(extra) + 1;
10624 break;
10625 }
10626
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010627 case WE_GET_OEM_DATA_CAP:
Naveen Rawat910726a2017-03-06 11:42:51 -080010628 return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010629 case WE_GET_SNR:
10630 {
10631 int8_t s7snr = 0;
10632 int status = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010633 struct hdd_context *pHddCtx;
Jeff Johnson40dae4e2017-08-29 14:00:25 -070010634 struct hdd_station_ctx *pHddStaCtx;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010636 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10637 status = wlan_hdd_validate_context(pHddCtx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010638 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010639 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010640
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010641 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10642 if (0 == pHddCtx->config->fEnableSNRMonitoring ||
10643 eConnectionState_Associated !=
10644 pHddStaCtx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010645 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010646 pHddCtx->config->fEnableSNRMonitoring,
10647 pHddStaCtx->conn_info.connState);
10648 return -ENONET;
10649 }
10650 wlan_hdd_get_snr(pAdapter, &s7snr);
10651 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
10652 wrqu->data.length = strlen(extra) + 1;
10653 break;
10654 }
10655 default:
10656 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010657 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010658 sub_cmd);
10659 break;
10660 }
10661 }
Dustin Brownd9322482017-01-09 12:46:03 -080010662
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010663 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -080010664 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010665}
10666
10667static int iw_get_char_setnone(struct net_device *dev,
10668 struct iw_request_info *info,
10669 union iwreq_data *wrqu, char *extra)
10670{
10671 int ret;
10672
10673 cds_ssr_protect(__func__);
10674 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
10675 cds_ssr_unprotect(__func__);
10676
10677 return ret;
10678}
10679
10680/**
10681 * iw_setnone_getnone() - Generic "action" private ioctl handler
10682 * @dev: device upon which the ioctl was received
10683 * @info: ioctl request information
10684 * @wrqu: ioctl request data
10685 * @extra: ioctl extra data
10686 *
10687 * Return: 0 on success, non-zero on error
10688 */
10689static int __iw_setnone_getnone(struct net_device *dev,
10690 struct iw_request_info *info,
10691 union iwreq_data *wrqu, char *extra)
10692{
Jeff Johnson3d278b02017-08-29 14:17:47 -070010693 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010694 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010695 int ret;
10696 int sub_cmd;
10697
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010698 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010699
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010700 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010701 ret = wlan_hdd_validate_context(hdd_ctx);
10702 if (0 != ret)
10703 return ret;
10704
Jeff Johnson441e1f72017-02-07 08:50:49 -080010705 ret = hdd_check_private_wext_control(hdd_ctx, info);
10706 if (0 != ret)
10707 return ret;
10708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010709#ifdef CONFIG_COMPAT
10710 /* this ioctl is a special case where a sub-ioctl is used and both
10711 * the number of get and set args is 0. in this specific case the
10712 * logic in iwpriv places the sub_cmd in the data.flags portion of
10713 * the iwreq. unfortunately the location of this field will be
10714 * different between 32-bit and 64-bit userspace, and the standard
10715 * compat support in the kernel does not handle this case. so we
10716 * need to explicitly handle it here.
10717 */
10718 if (is_compat_task()) {
10719 struct compat_iw_point *compat_iw_point =
10720 (struct compat_iw_point *)&wrqu->data;
10721 sub_cmd = compat_iw_point->flags;
10722 } else {
10723 sub_cmd = wrqu->data.flags;
10724 }
10725#else
10726 sub_cmd = wrqu->data.flags;
10727#endif
10728
10729 switch (sub_cmd) {
10730 case WE_GET_RECOVERY_STAT:
10731 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010732 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010734 sme_get_recovery_stats(hal);
10735 break;
10736 }
10737
Govind Singha471e5e2015-10-12 17:11:14 +053010738 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010739 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +053010740 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
10741 0, DBG_CMD);
10742 break;
10743
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010744 case WE_IBSS_GET_PEER_INFO_ALL:
10745 {
10746 hdd_wlan_get_ibss_peer_info_all(adapter);
10747 break;
10748 }
10749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010750 case WE_SET_REASSOC_TRIGGER:
10751 {
Jeff Johnson3d278b02017-08-29 14:17:47 -070010752 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010753
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010754 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010755 tSirMacAddr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010756 uint32_t roamId = 0;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010757 uint8_t operating_ch =
10758 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010759 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010760
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010761 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010762 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010763 if (roaming_offload_enabled(hdd_ctx)) {
10764 qdf_mem_copy(bssid,
10765 &adapter->sessionCtx.station.conn_info.bssId,
10766 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -080010767 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010768 bssid, operating_ch);
10769 } else {
10770 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
10771 NULL, modProfileFields, &roamId, 1);
10772 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010773 return 0;
10774 }
10775
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010776 case WE_STOP_OBSS_SCAN:
10777 {
10778 /*
10779 * 1.OBSS Scan is mandatory while operating in 2.4GHz
10780 * 2.OBSS scan is stopped by Firmware during the disassociation
10781 * 3.OBSS stop comamnd is added for debugging purpose
10782 */
10783 tHalHandle hal;
10784
10785 hal = WLAN_HDD_GET_HAL_CTX(adapter);
10786 if (hal == NULL) {
10787 hdd_err("hal context is NULL");
10788 return -EINVAL;
10789 }
10790 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
10791 }
10792 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010793 default:
10794 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010795 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010796 break;
10797 }
10798 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010799 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010800 return ret;
10801}
10802
10803static int iw_setnone_getnone(struct net_device *dev,
10804 struct iw_request_info *info,
10805 union iwreq_data *wrqu, char *extra)
10806{
10807 int ret;
10808
10809 cds_ssr_protect(__func__);
10810 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
10811 cds_ssr_unprotect(__func__);
10812
10813 return ret;
10814}
10815
Krunal Sonia6e505b2017-01-12 12:25:18 -080010816#ifdef MPC_UT_FRAMEWORK
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010817static int iw_get_policy_manager_ut_ops(struct hdd_context *hdd_ctx,
Jeff Johnson3d278b02017-08-29 14:17:47 -070010818 struct hdd_adapter *adapter, int sub_cmd, int *apps_args)
Krunal Sonia6e505b2017-01-12 12:25:18 -080010819{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -080010820 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010821 case WE_POLICY_MANAGER_CLIST_CMD:
10822 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010823 hdd_debug("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010824 policy_mgr_incr_connection_count_utfw(hdd_ctx->hdd_psoc,
10825 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
10826 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010827 }
10828 break;
10829
10830 case WE_POLICY_MANAGER_DLIST_CMD:
10831 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010832 hdd_debug("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010833 policy_mgr_decr_connection_count_utfw(hdd_ctx->hdd_psoc,
10834 apps_args[0], apps_args[1]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010835 }
10836 break;
10837
10838 case WE_POLICY_MANAGER_ULIST_CMD:
10839 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010840 hdd_debug("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010841 policy_mgr_update_connection_info_utfw(hdd_ctx->hdd_psoc,
10842 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
10843 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010844 }
10845 break;
10846
10847 case WE_POLICY_MANAGER_DBS_CMD:
10848 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010849 hdd_debug("<iwpriv wlan0 pm_dbs> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -080010850 if (apps_args[0] == 0)
10851 wma_set_dbs_capability_ut(0);
10852 else
10853 wma_set_dbs_capability_ut(1);
10854
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010855 if (apps_args[1] >= PM_THROUGHPUT &&
10856 apps_args[1] <= PM_LATENCY) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010857 pr_info("setting system pref to [%d]\n", apps_args[1]);
10858 hdd_ctx->config->conc_system_pref = apps_args[1];
10859 }
10860 }
10861 break;
10862
10863 case WE_POLICY_MANAGER_PCL_CMD:
10864 {
10865 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
10866 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
10867 uint32_t pcl_len = 0, i = 0;
10868
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -070010869 hdd_debug("<iwpriv wlan0 pm_pcl> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -080010870
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010871 policy_mgr_get_pcl(hdd_ctx->hdd_psoc, apps_args[0],
Krunal Sonia6e505b2017-01-12 12:25:18 -080010872 pcl, &pcl_len,
10873 weight_list, QDF_ARRAY_SIZE(weight_list));
10874 pr_info("PCL list for role[%d] is {", apps_args[0]);
10875 for (i = 0 ; i < pcl_len; i++)
10876 pr_info(" %d, ", pcl[i]);
10877 pr_info("}--------->\n");
10878 }
10879 break;
10880
10881 case WE_POLICY_SET_HW_MODE_CMD:
10882 {
10883 if (apps_args[0] == 0) {
10884 hdd_err("set hw mode for single mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010885 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010886 adapter->sessionId,
10887 HW_MODE_SS_2x2,
10888 HW_MODE_80_MHZ,
10889 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
10890 HW_MODE_DBS_NONE,
10891 HW_MODE_AGILE_DFS_NONE,
10892 HW_MODE_SBS_NONE,
10893 SIR_UPDATE_REASON_UT);
10894 } else if (apps_args[0] == 1) {
10895 hdd_err("set hw mode for dual mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010896 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010897 adapter->sessionId,
10898 HW_MODE_SS_1x1,
10899 HW_MODE_80_MHZ,
10900 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
10901 HW_MODE_DBS,
10902 HW_MODE_AGILE_DFS_NONE,
10903 HW_MODE_SBS_NONE,
10904 SIR_UPDATE_REASON_UT);
10905 }
10906 }
10907 break;
10908
10909 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10910 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010911 enum policy_mgr_conc_next_action action;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010912
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -070010913 hdd_debug("<iwpriv wlan0 pm_query_action> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010914 action = policy_mgr_current_connections_update(
10915 hdd_ctx->hdd_psoc,
10916 adapter->sessionId, apps_args[0],
10917 SIR_UPDATE_REASON_UT);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010918 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
10919 }
10920 break;
10921
10922 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10923 {
10924 bool allow;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010925
10926 hdd_notice("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010927 allow = policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010928 apps_args[0], apps_args[1], apps_args[2]);
10929 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
10930 }
10931 break;
10932
10933 case WE_POLICY_MANAGER_SCENARIO_CMD:
10934 {
10935 clean_report(hdd_ctx);
10936 if (apps_args[0] == 1) {
10937 wlan_hdd_one_connection_scenario(hdd_ctx);
10938 } else if (apps_args[0] == 2) {
10939 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010940 6, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010941 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010942 36, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010943 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010944 6, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010945 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010946 36, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010947 } else if (apps_args[0] == 3) {
10948 /* MCC on same band with 2x2 same mac*/
10949 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010950 6, 11, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010951 /* MCC on diff band with 2x2 same mac*/
10952 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010953 6, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010954 /* MCC on diff band with 1x1 diff mac */
10955 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010956 36, 6, POLICY_MGR_ONE_ONE, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010957 /* MCC on diff band with 1x1 same mac */
10958 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010959 36, 6, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010960 /* SCC on same band with 2x2 same mac */
10961 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010962 36, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010963 /* SCC on same band with 1x1 same mac */
10964 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010965 36, 36, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010966 /* MCC on same band with 2x2 same mac */
10967 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010968 36, 149, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010969 /* MCC on same band with 1x1 same mac */
10970 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010971 36, 149, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010972 }
10973 print_report(hdd_ctx);
10974 }
10975 break;
10976 }
10977 return 0;
10978}
10979#else
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010980static int iw_get_policy_manager_ut_ops(struct hdd_context *hdd_ctx,
Jeff Johnson3d278b02017-08-29 14:17:47 -070010981 struct hdd_adapter *adapter, int sub_cmd, int *apps_args)
Krunal Sonia6e505b2017-01-12 12:25:18 -080010982{
10983 return 0;
10984}
10985#endif
10986
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010987/**
10988 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10989 * @dev: device upon which the ioctl was received
10990 * @info: ioctl request information
10991 * @wrqu: ioctl request data
10992 * @extra: ioctl extra data
10993 *
10994 * This is an SSR-protected generic handler for private ioctls which
10995 * take multiple arguments. Note that this implementation is also
10996 * somewhat unique in that it is shared by both STA-mode and SAP-mode
10997 * interfaces.
10998 *
10999 * Return: 0 on success, non-zero on error
11000 */
11001static int __iw_set_var_ints_getnone(struct net_device *dev,
11002 struct iw_request_info *info,
11003 union iwreq_data *wrqu, char *extra)
11004{
Jeff Johnson3d278b02017-08-29 14:17:47 -070011005 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011006 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11007 int sub_cmd;
11008 int *apps_args = (int *) extra;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011009 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011010 int ret, num_args;
11011
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011012 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011013
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011014 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11015 ret = wlan_hdd_validate_context(hdd_ctx);
11016 if (0 != ret)
11017 return ret;
11018
Jeff Johnson441e1f72017-02-07 08:50:49 -080011019 ret = hdd_check_private_wext_control(hdd_ctx, info);
11020 if (0 != ret)
11021 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011022
11023 sub_cmd = wrqu->data.flags;
11024 num_args = wrqu->data.length;
11025
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011026 hdd_debug("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011027
11028 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080011029 case WE_IBSS_GET_PEER_INFO:
11030 {
11031 pr_info("Station ID = %d\n", apps_args[0]);
11032 hdd_wlan_get_ibss_peer_info(pAdapter, apps_args[0]);
11033 }
11034 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011035
11036 case WE_P2P_NOA_CMD:
11037 {
Srinivas Girigowda5d5fdc52017-03-24 22:30:57 -070011038 struct p2p_app_set_ps p2pNoA;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011039
Krunal Sonif07bb382016-03-10 13:02:11 -080011040 if (pAdapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -080011041 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
11042 hdd_device_mode_to_string(
11043 pAdapter->device_mode),
11044 pAdapter->device_mode);
11045 return -EINVAL;
11046 }
11047
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011048 p2pNoA.opp_ps = apps_args[0];
11049 p2pNoA.ctWindow = apps_args[1];
11050 p2pNoA.duration = apps_args[2];
11051 p2pNoA.interval = apps_args[3];
11052 p2pNoA.count = apps_args[4];
11053 p2pNoA.single_noa_duration = apps_args[5];
11054 p2pNoA.psSelection = apps_args[6];
11055
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011056 hdd_debug("P2P_NOA_ATTR:oppPS %d ctWindow %d duration %d interval %d count %d single noa duration %d PsSelection %x",
Jeff Johnson99bac312016-06-28 10:38:18 -070011057 apps_args[0], apps_args[1], apps_args[2],
11058 apps_args[3], apps_args[4],
11059 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011060
11061 hdd_set_p2p_ps(dev, &p2pNoA);
11062
11063 }
11064 break;
11065
11066 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
11067 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011068 hdd_debug("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
Jeff Johnson99bac312016-06-28 10:38:18 -070011069 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011070 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011071 }
11072 break;
11073
11074 case WE_MTRACE_DUMP_CMD:
11075 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011076 hdd_debug("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
Jeff Johnson99bac312016-06-28 10:38:18 -070011077 apps_args[0], apps_args[1],
11078 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011079 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011080 apps_args[1], apps_args[2],
11081 apps_args[3]);
11082
11083 }
11084 break;
11085
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011086 case WE_POLICY_MANAGER_CINFO_CMD:
11087 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080011088 struct policy_mgr_conc_connection_info *conn_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011089 uint32_t i = 0, len = 0;
11090
Krunal Sonia6e505b2017-01-12 12:25:18 -080011091 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080011092 conn_info = policy_mgr_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -080011093 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011094 for (i = 0; i < len; i++) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080011095 pr_info("|table_index[%d]\t\t\n", i);
11096 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
11097 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
11098 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
11099 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
11100 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
11101 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
11102 pr_info("+--------------------------+\n");
11103 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011104 }
11105 }
11106 break;
11107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011108
11109#ifdef FEATURE_WLAN_TDLS
11110 case WE_TDLS_CONFIG_PARAMS:
11111 {
11112 tdls_config_params_t tdlsParams;
11113
11114 tdlsParams.tdls = apps_args[0];
11115 tdlsParams.tx_period_t = apps_args[1];
11116 tdlsParams.tx_packet_n = apps_args[2];
11117 /* ignore args[3] as discovery_period is not used anymore */
11118 tdlsParams.discovery_tries_n = apps_args[4];
11119 /* ignore args[5] as idle_timeout is not used anymore */
11120 tdlsParams.idle_packet_n = apps_args[6];
11121 /* ignore args[7] as rssi_hysteresis is not used anymore */
11122 tdlsParams.rssi_trigger_threshold = apps_args[8];
11123 tdlsParams.rssi_teardown_threshold = apps_args[9];
11124 tdlsParams.rssi_delta = apps_args[10];
11125
11126 wlan_hdd_tdls_set_params(dev, &tdlsParams);
11127 }
11128 break;
11129#endif
11130 case WE_UNIT_TEST_CMD:
11131 {
11132 t_wma_unit_test_cmd *unitTestArgs;
Rajeev Kumarea95edd2017-01-11 20:49:36 -080011133 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011134 int i, j;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011135
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011136 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
11137 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011138 hdd_err("Invalid MODULE ID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011139 apps_args[0]);
11140 return -EINVAL;
11141 }
Anurag Chouhan77564182016-09-03 16:38:01 +053011142 if ((apps_args[1] > (WMA_MAX_NUM_ARGS)) ||
11143 (apps_args[1] < 0)) {
11144 hdd_err("Too Many/Few args %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011145 apps_args[1]);
11146 return -EINVAL;
11147 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011148 unitTestArgs = qdf_mem_malloc(sizeof(*unitTestArgs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011149 if (NULL == unitTestArgs) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011150 hdd_err("qdf_mem_malloc failed for unitTestArgs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011151 return -ENOMEM;
11152 }
11153 unitTestArgs->vdev_id = (int)pAdapter->sessionId;
11154 unitTestArgs->module_id = apps_args[0];
11155 unitTestArgs->num_args = apps_args[1];
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011156 for (i = 0, j = 2; i < unitTestArgs->num_args; i++, j++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011157 unitTestArgs->args[i] = apps_args[j];
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011159 msg.type = SIR_HAL_UNIT_TEST_CMD;
11160 msg.reserved = 0;
11161 msg.bodyptr = unitTestArgs;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011162 if (QDF_STATUS_SUCCESS !=
Rajeev Kumarea95edd2017-01-11 20:49:36 -080011163 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011164 qdf_mem_free(unitTestArgs);
Jeff Johnson99bac312016-06-28 10:38:18 -070011165 hdd_err("Not able to post UNIT_TEST_CMD message to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011166 return -EINVAL;
11167 }
11168 }
11169 break;
11170#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
11171 case WE_LED_FLASHING_PARAM:
11172 {
11173 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011174
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011175 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011176 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011177 return -EINVAL;
11178 }
11179 for (i = 0; i < num_args; i++) {
11180 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011181 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011182 return -EINVAL;
11183 }
11184 }
11185 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
11186 0, apps_args[0], apps_args[1]);
11187 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(pAdapter),
11188 1, apps_args[2], apps_args[3]);
11189 }
11190 break;
11191#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +053011192 case WE_SET_PKTLOG:
11193 {
11194 int ret;
11195
11196 if (num_args < 1 || num_args > 2) {
11197 hdd_err("pktlog: either 1 or 2 parameters are required");
11198 return -EINVAL;
11199 }
11200
11201 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
11202 apps_args[1]);
11203 if (ret)
11204 return ret;
11205 break;
11206 }
11207
Manjeet Singhf82ed072016-07-08 11:40:00 +053011208 case WE_MAC_PWR_DEBUG_CMD:
11209 {
11210 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
11211 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11212 int i, j;
11213
11214 if (num_args < 3) {
11215 hdd_err("number of arguments can't be null %d",
11216 num_args);
11217 return -EINVAL;
11218 }
11219 if (num_args - 3 != apps_args[2]) {
11220 hdd_err("arg list of size %d doesn't match num_args %d",
11221 num_args-3, apps_args[2]);
11222 return -EINVAL;
11223 }
11224 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
11225 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
11226 hdd_err("Invalid MODULE ID %d", apps_args[1]);
11227 return -EINVAL;
11228 }
11229 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
11230 hdd_err("Too Many args %d", apps_args[2]);
11231 return -EINVAL;
11232 }
11233 mac_pwr_dbg_args.pdev_id = apps_args[0];
11234 mac_pwr_dbg_args.module_id = apps_args[1];
11235 mac_pwr_dbg_args.num_args = apps_args[2];
11236
11237 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
11238 mac_pwr_dbg_args.args[i] = apps_args[j];
11239
11240 if (QDF_STATUS_SUCCESS !=
11241 sme_process_mac_pwr_dbg_cmd(hal, pAdapter->sessionId,
11242 &mac_pwr_dbg_args)) {
11243 return -EINVAL;
11244 }
11245 }
11246 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -080011247 case WE_POLICY_MANAGER_CLIST_CMD:
11248 case WE_POLICY_MANAGER_DLIST_CMD:
11249 case WE_POLICY_MANAGER_ULIST_CMD:
11250 case WE_POLICY_MANAGER_DBS_CMD:
11251 case WE_POLICY_MANAGER_PCL_CMD:
11252 case WE_POLICY_SET_HW_MODE_CMD:
11253 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
11254 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
11255 case WE_POLICY_MANAGER_SCENARIO_CMD:
11256 {
11257 iw_get_policy_manager_ut_ops(hdd_ctx, pAdapter,
11258 sub_cmd, apps_args);
11259 }
11260 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011261 default:
11262 {
Jeff Johnson99bac312016-06-28 10:38:18 -070011263 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011264 }
11265 break;
11266 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011267 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011268 return 0;
11269}
11270
11271/**
11272 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
11273 * @dev: pointer to net_device structure
11274 * @info: pointer to iw_request_info structure
11275 * @wrqu: pointer to iwreq_data
11276 * @extra; extra
11277 *
11278 * Return: 0 on success, error number otherwise
11279 *
11280 */
11281static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
11282 struct iw_request_info *info,
11283 union iwreq_data *wrqu, char *extra)
11284{
11285 union iwreq_data u_priv_wrqu;
11286 int apps_args[MAX_VAR_ARGS] = {0};
11287 int ret, num_args;
11288
Mukul Sharma64a70e82015-11-02 20:05:09 +053011289 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011290 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +053011291 return -EPERM;
11292 }
11293
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011294 /* Helper function to get iwreq_data with compat handling. */
11295 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
11296 return -EINVAL;
11297
11298 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011299 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011300 return -EINVAL;
11301 }
11302
11303 num_args = u_priv_wrqu.data.length;
11304 if (num_args > MAX_VAR_ARGS)
11305 num_args = MAX_VAR_ARGS;
11306
11307 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
11308 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011309 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011310 return -EFAULT;
11311 }
11312
11313 cds_ssr_protect(__func__);
11314 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
11315 (char *)&apps_args);
11316 cds_ssr_unprotect(__func__);
11317 return ret;
11318}
11319
11320/**
11321 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
11322 * @dev: device upon which the ioctl was received
11323 * @info: ioctl request information
11324 * @wrqu: ioctl request data
11325 * @extra: ioctl extra data
11326 *
11327 * This is a generic handler for private ioctls which take multiple
11328 * arguments. Note that this implementation is also somewhat unique
11329 * in that it is shared by both STA-mode and SAP-mode interfaces.
11330 *
11331 * Return: 0 on success, non-zero on error
11332 */
11333int iw_set_var_ints_getnone(struct net_device *dev,
11334 struct iw_request_info *info,
11335 union iwreq_data *wrqu, char *extra)
11336{
11337 int ret;
11338
11339 cds_ssr_protect(__func__);
11340 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
11341 cds_ssr_unprotect(__func__);
11342 return ret;
11343}
11344
11345/**
11346 * iw_add_tspec - Add TSpec private ioctl handler
11347 * @dev: device upon which the ioctl was received
11348 * @info: ioctl request information
11349 * @wrqu: ioctl request data
11350 * @extra: ioctl extra data
11351 *
11352 * Return: 0 on success, non-zero on error
11353 */
11354static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
11355 union iwreq_data *wrqu, char *extra)
11356{
Jeff Johnson3d278b02017-08-29 14:17:47 -070011357 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson40dae4e2017-08-29 14:00:25 -070011358 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011359 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11360 int params[HDD_WLAN_WMM_PARAM_COUNT];
Abhishek Singh12be60f2017-08-11 13:52:42 +053011361 struct sme_qos_wmmtspecinfo tSpec;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011362 uint32_t handle;
11363 struct iw_point s_priv_data;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011364 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011365 int ret;
11366
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011367 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011368
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011369 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11370 ret = wlan_hdd_validate_context(hdd_ctx);
11371 if (0 != ret)
11372 return ret;
11373
Jeff Johnson441e1f72017-02-07 08:50:49 -080011374 ret = hdd_check_private_wext_control(hdd_ctx, info);
11375 if (0 != ret)
11376 return ret;
11377
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011378 /* make sure the application is sufficiently priviledged */
11379 /* note that the kernel will do this for "set" ioctls, but since */
11380 /* this ioctl wants to return status to user space it must be */
11381 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011382 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011383 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011384
11385 /* we must be associated in order to add a tspec */
11386 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
11387 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11388 return 0;
11389 }
11390 /* since we are defined to be a "get" ioctl, and since the number */
11391 /* of params exceeds the number of params that wireless extensions */
11392 /* will pass down in the iwreq_data, we must copy the "set" params. */
11393 /* We must handle the compat for iwreq_data in 32U/64K environment. */
11394
11395 /* helper function to get iwreq_data with compat handling. */
11396 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
11397 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11398 return 0;
11399 }
11400 /* make sure all params are correctly passed to function */
11401 if ((NULL == s_priv_data.pointer) ||
11402 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
11403 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11404 return 0;
11405 }
11406 /* from user space ourselves */
11407 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
11408 /* hmmm, can't get them */
11409 return -EIO;
11410 }
11411 /* clear the tspec */
11412 memset(&tSpec, 0, sizeof(tSpec));
11413
11414 /* validate the handle */
11415 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11416 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11417 /* that one is reserved */
11418 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11419 return 0;
11420 }
11421 /* validate the TID */
11422 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
11423 /* out of range */
11424 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11425 return 0;
11426 }
11427 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
11428
11429 /* validate the direction */
11430 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
11431 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
11432 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
11433 break;
11434
11435 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
11436 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
11437 break;
11438
11439 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
11440 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
11441 break;
11442
11443 default:
11444 /* unknown */
11445 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11446 return 0;
11447 }
11448
11449 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
11450
11451 /* validate the user priority */
11452 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
11453 /* out of range */
11454 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11455 return 0;
11456 }
11457 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
11458 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011459 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011460 return 0;
11461 }
11462
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011463 hdd_debug("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011464 tSpec.ts_info.psb, tSpec.ts_info.up);
11465
11466 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
11467 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
11468 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
11469 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
11470 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
11471 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
11472 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
11473 tSpec.surplus_bw_allowance =
11474 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
11475 tSpec.min_service_interval =
11476 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
11477 tSpec.max_service_interval =
11478 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
11479 tSpec.suspension_interval =
11480 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
11481 tSpec.inactivity_interval =
11482 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
11483
11484 tSpec.ts_info.burst_size_defn =
11485 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
11486
11487 /* validate the ts info ack policy */
11488 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
11489 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
11490 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
11491 break;
11492
11493 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
11494 tSpec.ts_info.ack_policy =
11495 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
11496 break;
11497
11498 default:
11499 /* unknown */
11500 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11501 return 0;
11502 }
11503
11504 *pStatus = hdd_wmm_addts(pAdapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011505 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011506 return 0;
11507}
11508
11509static int iw_add_tspec(struct net_device *dev,
11510 struct iw_request_info *info,
11511 union iwreq_data *wrqu, char *extra)
11512{
11513 int ret;
11514
11515 cds_ssr_protect(__func__);
11516 ret = __iw_add_tspec(dev, info, wrqu, extra);
11517 cds_ssr_unprotect(__func__);
11518
11519 return ret;
11520}
11521
11522/**
11523 * iw_del_tspec - Delete TSpec private ioctl handler
11524 * @dev: device upon which the ioctl was received
11525 * @info: ioctl request information
11526 * @wrqu: ioctl request data
11527 * @extra: ioctl extra data
11528 *
11529 * Return: 0 on success, non-zero on error
11530 */
11531static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
11532 union iwreq_data *wrqu, char *extra)
11533{
Jeff Johnson3d278b02017-08-29 14:17:47 -070011534 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011535 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011536 int *params = (int *)extra;
11537 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11538 uint32_t handle;
11539 int ret;
11540
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011541 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011542
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011543 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11544 ret = wlan_hdd_validate_context(hdd_ctx);
11545 if (0 != ret)
11546 return ret;
11547
Jeff Johnson441e1f72017-02-07 08:50:49 -080011548 ret = hdd_check_private_wext_control(hdd_ctx, info);
11549 if (0 != ret)
11550 return ret;
11551
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011552 /* make sure the application is sufficiently priviledged */
11553 /* note that the kernel will do this for "set" ioctls, but since */
11554 /* this ioctl wants to return status to user space it must be */
11555 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011556 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011557 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011558
11559 /* although we are defined to be a "get" ioctl, the params we require */
11560 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11561 /* is no need to copy the params from user space */
11562
11563 /* validate the handle */
11564 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11565 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11566 /* that one is reserved */
11567 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11568 return 0;
11569 }
11570
11571 *pStatus = hdd_wmm_delts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011572 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011573 return 0;
11574}
11575
11576static int iw_del_tspec(struct net_device *dev,
11577 struct iw_request_info *info,
11578 union iwreq_data *wrqu, char *extra)
11579{
11580 int ret;
11581
11582 cds_ssr_protect(__func__);
11583 ret = __iw_del_tspec(dev, info, wrqu, extra);
11584 cds_ssr_unprotect(__func__);
11585
11586 return ret;
11587}
11588
11589/**
11590 * iw_get_tspec - Get TSpec private ioctl handler
11591 * @dev: device upon which the ioctl was received
11592 * @info: ioctl request information
11593 * @wrqu: ioctl request data
11594 * @extra: ioctl extra data
11595 *
11596 * Return: 0 on success, non-zero on error
11597 */
11598static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
11599 union iwreq_data *wrqu, char *extra)
11600{
Jeff Johnson3d278b02017-08-29 14:17:47 -070011601 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011602 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011603 int *params = (int *)extra;
11604 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11605 uint32_t handle;
11606 int ret;
11607
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011608 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011609
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011610 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11611 ret = wlan_hdd_validate_context(hdd_ctx);
11612 if (0 != ret)
11613 return ret;
11614
Jeff Johnson441e1f72017-02-07 08:50:49 -080011615 ret = hdd_check_private_wext_control(hdd_ctx, info);
11616 if (0 != ret)
11617 return ret;
11618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011619 /* although we are defined to be a "get" ioctl, the params we require */
11620 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11621 /* is no need to copy the params from user space */
11622
11623 /* validate the handle */
11624 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11625 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11626 /* that one is reserved */
11627 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11628 return 0;
11629 }
11630
11631 *pStatus = hdd_wmm_checkts(pAdapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011632 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011633 return 0;
11634}
11635
11636static int iw_get_tspec(struct net_device *dev,
11637 struct iw_request_info *info,
11638 union iwreq_data *wrqu, char *extra)
11639{
11640 int ret;
11641
11642 cds_ssr_protect(__func__);
11643 ret = __iw_get_tspec(dev, info, wrqu, extra);
11644 cds_ssr_unprotect(__func__);
11645
11646 return ret;
11647}
11648
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011649/**
11650 * iw_set_fties - Set FT IEs private ioctl handler
11651 * @dev: device upon which the ioctl was received
11652 * @info: ioctl request information
11653 * @wrqu: ioctl request data
11654 * @extra: ioctl extra data
11655 *
11656 * Each time the supplicant has the auth_request or reassoc request
11657 * IEs ready they are pushed to the driver. The driver will in turn
11658 * use it to send out the auth req and reassoc req for 11r FT Assoc.
11659 *
11660 * Return: 0 on success, non-zero on error
11661 */
11662static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
11663 union iwreq_data *wrqu, char *extra)
11664{
Jeff Johnson3d278b02017-08-29 14:17:47 -070011665 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson40dae4e2017-08-29 14:00:25 -070011666 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011667 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011668 int ret;
11669
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011670 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011672 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11673 ret = wlan_hdd_validate_context(hdd_ctx);
11674 if (0 != ret)
11675 return ret;
11676
Jeff Johnson441e1f72017-02-07 08:50:49 -080011677 ret = hdd_check_private_wext_control(hdd_ctx, info);
11678 if (0 != ret)
11679 return ret;
11680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011681 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011682 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011683 return -EINVAL;
11684 }
11685 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011686 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011687 return -EINVAL;
11688 }
11689 /* Added for debug on reception of Re-assoc Req. */
11690 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011691 hdd_debug("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011692 wrqu->data.length);
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011693 hdd_debug("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011694 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011695 hdd_debug("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011696
11697 /* Pass the received FT IEs to SME */
11698 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
11699 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011700 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011701 return 0;
11702}
11703
11704static int iw_set_fties(struct net_device *dev,
11705 struct iw_request_info *info,
11706 union iwreq_data *wrqu, char *extra)
11707{
11708 int ret;
11709
11710 cds_ssr_protect(__func__);
11711 ret = __iw_set_fties(dev, info, wrqu, extra);
11712 cds_ssr_unprotect(__func__);
11713
11714 return ret;
11715}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011716
Dustin Brown0cbc7572016-12-16 13:54:40 -080011717/**
11718 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
11719 * @dev: device upon which the ioctl was received
11720 * @info: ioctl request information
11721 * @wrqu: ioctl request data
11722 * @extra: ioctl extra data
11723 *
Dustin Brown860566f2017-01-31 15:24:43 -080011724 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
11725 * time being to provide guidance in migrating to standard APIs.
11726 *
Dustin Brown0cbc7572016-12-16 13:54:40 -080011727 * Return: 0 on success, non-zero on error
11728 */
11729static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
11730 struct iw_request_info *info,
11731 union iwreq_data *wrqu,
11732 char *extra)
11733{
Dustin Brown860566f2017-01-31 15:24:43 -080011734 hdd_err("\n"
11735 "setMCBCFilter is obsolete. Use the following instead:\n"
11736 "Configure multicast filtering via the ‘ip’ command.\n"
11737 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
11738 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
11739 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
11740 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
11741 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Mukul Sharma3ba26b82017-01-12 21:59:41 +053011742 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -080011743}
11744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011745/**
11746 * iw_set_host_offload - Set host offload ioctl handler
11747 * @dev: device upon which the ioctl was received
11748 * @info: ioctl request information
11749 * @wrqu: ioctl request data
11750 * @extra: ioctl extra data
11751 *
11752 * Return: 0 on success, non-zero on error
11753 */
11754static int __iw_set_host_offload(struct net_device *dev,
11755 struct iw_request_info *info,
11756 union iwreq_data *wrqu, char *extra)
11757{
Jeff Johnson3d278b02017-08-29 14:17:47 -070011758 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowda077143e2017-03-25 10:47:27 -070011759 struct host_offload_req *pRequest = (struct host_offload_req *) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011760 tSirHostOffloadReq offloadRequest;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011761 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011762 int ret;
11763
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011764 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011765
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011766 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11767 ret = wlan_hdd_validate_context(hdd_ctx);
11768 if (0 != ret)
11769 return ret;
11770
Jeff Johnson441e1f72017-02-07 08:50:49 -080011771 ret = hdd_check_private_wext_control(hdd_ctx, info);
11772 if (0 != ret)
11773 return ret;
11774
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011775 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011776 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011777 return -EINVAL;
11778 }
11779
11780 /* Debug display of request components. */
11781 switch (pRequest->offloadType) {
11782 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011783 hdd_debug("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011784 switch (pRequest->enableOrDisable) {
11785 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011786 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011787 break;
11788 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011789 hdd_debug(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011790 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011791 hdd_debug(" ARP offload enable");
11792 hdd_debug(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011793 pRequest->params.hostIpv4Addr[0],
11794 pRequest->params.hostIpv4Addr[1],
11795 pRequest->params.hostIpv4Addr[2],
11796 pRequest->params.hostIpv4Addr[3]);
11797 }
11798 break;
11799
11800 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011801 hdd_debug("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011802 switch (pRequest->enableOrDisable) {
11803 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011804 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011805 break;
11806 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011807 hdd_debug(" enable");
11808 hdd_debug(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011809 *(uint16_t *) (pRequest->params.hostIpv6Addr),
11810 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11811 2),
11812 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11813 4),
11814 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11815 6),
11816 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11817 8),
11818 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11819 10),
11820 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11821 12),
11822 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11823 14));
11824 }
11825 }
11826
11827 /* Execute offload request. The reason that we can copy the
11828 * request information from the ioctl structure to the SME
11829 * structure is that they are laid out exactly the same.
11830 * Otherwise, each piece of information would have to be
11831 * copied individually.
11832 */
11833 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011834 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011835 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
11836 pAdapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011837 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011838 return -EINVAL;
11839 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011840 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011841 return 0;
11842}
11843
11844static int iw_set_host_offload(struct net_device *dev,
11845 struct iw_request_info *info,
11846 union iwreq_data *wrqu, char *extra)
11847{
11848 int ret;
11849
11850 cds_ssr_protect(__func__);
11851 ret = __iw_set_host_offload(dev, info, wrqu, extra);
11852 cds_ssr_unprotect(__func__);
11853
11854 return ret;
11855}
11856
11857/**
11858 * iw_set_keepalive_params - Set keepalive params ioctl handler
11859 * @dev: device upon which the ioctl was received
11860 * @info: ioctl request information
11861 * @wrqu: ioctl request data
11862 * @extra: ioctl extra data
11863 *
11864 * Return: 0 on success, non-zero on error
11865 */
11866static int __iw_set_keepalive_params(struct net_device *dev,
11867 struct iw_request_info *info,
11868 union iwreq_data *wrqu, char *extra)
11869{
Jeff Johnson3d278b02017-08-29 14:17:47 -070011870 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011871 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011872 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011873 int ret;
11874
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011875 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011877 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
11878 ret = wlan_hdd_validate_context(hdd_ctx);
11879 if (0 != ret)
11880 return ret;
11881
Jeff Johnson441e1f72017-02-07 08:50:49 -080011882 ret = hdd_check_private_wext_control(hdd_ctx, info);
11883 if (0 != ret)
11884 return ret;
11885
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011886 if (wrqu->data.length != sizeof(*request)) {
11887 hdd_err("Invalid length %d", wrqu->data.length);
11888 return -EINVAL;
11889 }
11890
11891 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
11892 hdd_err("Value of timePeriod %d exceed Max limit %d",
11893 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011894 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
11895 return -EINVAL;
11896 }
11897
11898 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011899 hdd_debug("Set Keep Alive Request : TimePeriod %d size %zu",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011900 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011901
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011902 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011903 case WLAN_KEEP_ALIVE_NULL_PKT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011904 hdd_debug("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011905 break;
11906
11907 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011908 hdd_debug("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011909
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011910 hdd_debug("Host IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011911 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
11912 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011913
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011914 hdd_debug("Dest IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011915 request->destIpv4Addr[0], request->destIpv4Addr[1],
11916 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011917
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011918 hdd_debug("Dest MAC address: "MAC_ADDRESS_STR,
Srinivas Girigowda9c330a92015-11-24 12:28:25 -080011919 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011920 break;
11921 }
11922
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011923 hdd_debug("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011924
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011925 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011926 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(pAdapter),
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011927 pAdapter->sessionId, request)) {
11928 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011929 return -EINVAL;
11930 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011931 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011932 return 0;
11933}
11934
11935static int iw_set_keepalive_params(struct net_device *dev,
11936 struct iw_request_info *info,
11937 union iwreq_data *wrqu,
11938 char *extra)
11939{
11940 int ret;
11941
11942 cds_ssr_protect(__func__);
11943 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
11944 cds_ssr_unprotect(__func__);
11945
11946 return ret;
11947}
11948
11949#ifdef WLAN_FEATURE_PACKET_FILTERING
11950/**
11951 * wlan_hdd_set_filter() - Set packet filter
11952 * @hdd_ctx: Global HDD context
11953 * @request: Packet filter request struct
11954 * @sessionId: Target session for the request
11955 *
11956 * Return: 0 on success, non-zero on error
11957 */
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011958static int wlan_hdd_set_filter(struct hdd_context *hdd_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011959 struct pkt_filter_cfg *request,
11960 uint8_t sessionId)
11961{
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011962 struct pmo_rcv_pkt_fltr_cfg *pmo_set_pkt_fltr_req = NULL;
11963 struct pmo_rcv_pkt_fltr_clear_param *pmo_clr_pkt_fltr_param = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011964 int i = 0;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011965 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011966
11967 if (hdd_ctx->config->disablePacketFilter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011968 hdd_warn("Packet filtering disabled in ini");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011969 return 0;
11970 }
11971
11972 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011973 hdd_debug("Packet Filter Request : FA %d params %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011974 request->filter_action, request->num_params);
11975
11976 switch (request->filter_action) {
11977 case HDD_RCV_FILTER_SET:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011978 hdd_debug("Set Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011979 request->filter_id);
11980
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011981 pmo_set_pkt_fltr_req =
11982 qdf_mem_malloc(sizeof(*pmo_set_pkt_fltr_req));
11983 if (!pmo_set_pkt_fltr_req) {
Mukul Sharmad75a6672017-06-22 15:40:53 +053011984 hdd_err("unable to allocate pmo_set_pkt_fltr_req");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011985 return QDF_STATUS_E_NOMEM;
11986 }
11987
11988 pmo_set_pkt_fltr_req->filter_id = request->filter_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011989 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
11990 hdd_err("Number of Params exceed Max limit %d",
11991 request->num_params);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011992 status = QDF_STATUS_E_INVAL;
11993 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011994 }
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011995 pmo_set_pkt_fltr_req->num_params = request->num_params;
11996 pmo_set_pkt_fltr_req->coalesce_time = 0;
Srinivas Girigowdabbbecad2017-06-28 16:01:48 -070011997 pmo_set_pkt_fltr_req->filter_type = PMO_RCV_FILTER_TYPE_FILTER_PKT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011998 for (i = 0; i < request->num_params; i++) {
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011999 pmo_set_pkt_fltr_req->params_data[i].protocol_layer =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012000 request->params_data[i].protocol_layer;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012001 pmo_set_pkt_fltr_req->params_data[i].compare_flag =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012002 request->params_data[i].compare_flag;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012003 pmo_set_pkt_fltr_req->params_data[i].data_offset =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012004 request->params_data[i].data_offset;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012005 pmo_set_pkt_fltr_req->params_data[i].data_length =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012006 request->params_data[i].data_length;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012007 pmo_set_pkt_fltr_req->params_data[i].reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012008
Dustin Brown4d1e8462016-12-14 12:12:24 -080012009 if (request->params_data[i].data_offset >
12010 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
12011 hdd_err("Invalid data offset %u for param %d (max = %d)",
12012 request->params_data[i].data_offset,
12013 i,
12014 SIR_MAX_FILTER_TEST_DATA_OFFSET);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012015 status = QDF_STATUS_E_INVAL;
12016 goto out;
Dustin Brown4d1e8462016-12-14 12:12:24 -080012017 }
12018
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012019 if (request->params_data[i].data_length >
12020 SIR_MAX_FILTER_TEST_DATA_LEN) {
12021 hdd_err("Error invalid data length %d",
12022 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012023 status = QDF_STATUS_E_INVAL;
12024 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012025 }
12026
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012027 hdd_debug("Proto %d Comp Flag %d Filter Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012028 request->params_data[i].protocol_layer,
12029 request->params_data[i].compare_flag,
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012030 pmo_set_pkt_fltr_req->filter_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012031
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012032 hdd_debug("Data Offset %d Data Len %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012033 request->params_data[i].data_offset,
12034 request->params_data[i].data_length);
12035
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012036 if (sizeof(
12037 pmo_set_pkt_fltr_req->params_data[i].compare_data)
Rajeev Kumarf5b6da22016-04-15 13:24:03 -070012038 < (request->params_data[i].data_length)) {
12039 hdd_err("Error invalid data length %d",
12040 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012041 status = QDF_STATUS_E_INVAL;
12042 goto out;
Rajeev Kumarf5b6da22016-04-15 13:24:03 -070012043 }
12044
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012045 memcpy(
12046 &pmo_set_pkt_fltr_req->params_data[i].compare_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012047 request->params_data[i].compare_data,
12048 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012049 memcpy(&pmo_set_pkt_fltr_req->params_data[i].data_mask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012050 request->params_data[i].data_mask,
12051 request->params_data[i].data_length);
12052
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012053 hdd_debug("CData %d CData %d CData %d CData %d CData %d CData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012054 request->params_data[i].compare_data[0],
12055 request->params_data[i].compare_data[1],
12056 request->params_data[i].compare_data[2],
12057 request->params_data[i].compare_data[3],
12058 request->params_data[i].compare_data[4],
12059 request->params_data[i].compare_data[5]);
12060
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012061 hdd_debug("MData %d MData %d MData %d MData %d MData %d MData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012062 request->params_data[i].data_mask[0],
12063 request->params_data[i].data_mask[1],
12064 request->params_data[i].data_mask[2],
12065 request->params_data[i].data_mask[3],
12066 request->params_data[i].data_mask[4],
12067 request->params_data[i].data_mask[5]);
12068 }
12069
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012070 if (QDF_STATUS_SUCCESS !=
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012071 pmo_ucfg_set_pkt_filter(hdd_ctx->hdd_psoc,
12072 pmo_set_pkt_fltr_req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012073 sessionId)) {
12074 hdd_err("Failure to execute Set Filter");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012075 status = QDF_STATUS_E_INVAL;
12076 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012077 }
12078
12079 break;
12080
12081 case HDD_RCV_FILTER_CLEAR:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012082 hdd_debug("Clear Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012083 request->filter_id);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012084
12085 pmo_clr_pkt_fltr_param = qdf_mem_malloc(
12086 sizeof(*pmo_clr_pkt_fltr_param));
12087 if (!pmo_clr_pkt_fltr_param) {
12088 hdd_err("unable to allocate pmo_clr_pkt_fltr_param");
12089 return QDF_STATUS_E_NOMEM;
12090 }
12091
12092 pmo_clr_pkt_fltr_param->filter_id = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012093 if (QDF_STATUS_SUCCESS !=
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012094 pmo_ucfg_clear_pkt_filter(hdd_ctx->hdd_psoc,
12095 pmo_clr_pkt_fltr_param,
12096 sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012097 hdd_err("Failure to execute Clear Filter");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012098 status = QDF_STATUS_E_INVAL;
12099 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012100 }
12101 break;
12102
12103 default:
12104 hdd_err("Packet Filter Request: Invalid %d",
12105 request->filter_action);
12106 return -EINVAL;
12107 }
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053012108
12109out:
12110 if (pmo_set_pkt_fltr_req)
12111 qdf_mem_free(pmo_set_pkt_fltr_req);
12112 if (pmo_clr_pkt_fltr_param)
12113 qdf_mem_free(pmo_clr_pkt_fltr_param);
12114
12115 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012116}
12117
12118/**
12119 * __iw_set_packet_filter_params() - set packet filter parameters in target
12120 * @dev: Pointer to netdev
12121 * @info: Pointer to iw request info
12122 * @wrqu: Pointer to data
12123 * @extra: Pointer to extra data
12124 *
12125 * Return: 0 on success, non-zero on error
12126 */
12127static int __iw_set_packet_filter_params(struct net_device *dev,
12128 struct iw_request_info *info,
12129 union iwreq_data *wrqu, char *extra)
12130{
12131 int ret;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070012132 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012133 struct iw_point priv_data;
Jeff Johnson3d278b02017-08-29 14:17:47 -070012134 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012135 struct pkt_filter_cfg *request = NULL;
12136
Mukul Sharma472382f2015-11-02 20:16:31 +053012137 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012138 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +053012139 return -EPERM;
12140 }
12141
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012142 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053012143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012144 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12145 ret = wlan_hdd_validate_context(hdd_ctx);
12146 if (0 != ret)
12147 return ret;
12148
Jeff Johnson441e1f72017-02-07 08:50:49 -080012149 ret = hdd_check_private_wext_control(hdd_ctx, info);
12150 if (0 != ret)
12151 return ret;
12152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012153 if (hdd_priv_get_data(&priv_data, wrqu)) {
12154 hdd_err("failed to get priv data");
12155 return -EINVAL;
12156 }
12157
12158 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
12159 hdd_err("invalid priv data %p or invalid priv data length %d",
12160 priv_data.pointer, priv_data.length);
12161 return -EINVAL;
12162 }
12163
Mukul Sharmabe846bb2017-05-09 17:41:52 +053012164 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) {
12165 hdd_err("Packet filter not supported in disconnected state");
12166 return -ENOTSUPP;
12167 }
12168
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012169 /* copy data using copy_from_user */
12170 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
12171 priv_data.length);
12172 if (NULL == request) {
12173 hdd_err("mem_alloc_copy_from_user_helper fail");
12174 return -ENOMEM;
12175 }
12176
12177 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
12178
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -070012179 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053012180 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012181 return ret;
12182}
12183
12184/**
12185 * iw_set_packet_filter_params() - set packet filter parameters in target
12186 * @dev: Pointer to netdev
12187 * @info: Pointer to iw request info
12188 * @wrqu: Pointer to data
12189 * @extra: Pointer to extra data
12190 *
12191 * Return: 0 on success, non-zero on error
12192 */
12193static int iw_set_packet_filter_params(struct net_device *dev,
12194 struct iw_request_info *info,
12195 union iwreq_data *wrqu, char *extra)
12196{
12197 int ret;
12198
12199 cds_ssr_protect(__func__);
12200 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
12201 cds_ssr_unprotect(__func__);
12202
12203 return ret;
12204}
12205#endif
12206
12207
12208static int __iw_get_statistics(struct net_device *dev,
12209 struct iw_request_info *info,
12210 union iwreq_data *wrqu, char *extra)
12211{
12212
Anurag Chouhance0dc992016-02-16 18:18:03 +053012213 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012214 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012215 hdd_wext_state_t *pWextState;
Jeff Johnson3d278b02017-08-29 14:17:47 -070012216 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070012217 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012218 char *p = extra;
12219 int tlen = 0;
12220 tCsrSummaryStatsInfo *pStats = &(pAdapter->hdd_stats.summary_stat);
12221 tCsrGlobalClassAStatsInfo *aStats = &(pAdapter->hdd_stats.ClassA_stat);
12222 tCsrGlobalClassDStatsInfo *dStats = &(pAdapter->hdd_stats.ClassD_stat);
12223 int ret;
12224
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012225 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012226
12227 ret = wlan_hdd_validate_context(hdd_ctx);
12228 if (0 != ret)
12229 return ret;
12230
Jeff Johnson441e1f72017-02-07 08:50:49 -080012231 ret = hdd_check_private_wext_control(hdd_ctx, info);
12232 if (0 != ret)
12233 return ret;
12234
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012235 if (eConnectionState_Associated !=
12236 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState) {
12237
12238 wrqu->txpower.value = 0;
12239 } else {
12240 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
12241 SME_SUMMARY_STATS |
12242 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080012243 SME_GLOBAL_CLASSD_STATS,
Naveen Rawatd0ca4412017-06-16 14:19:19 -070012244 hdd_statistics_cb,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012245 (WLAN_HDD_GET_STATION_CTX_PTR
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012246 (pAdapter))->conn_info.staId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012247 pAdapter, pAdapter->sessionId);
12248
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012249 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012250 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012251 return -EINVAL;
12252 }
12253
12254 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12255
Anurag Chouhance0dc992016-02-16 18:18:03 +053012256 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053012257 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012258 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +053012259 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012260 hdd_err("SME timeout while retrieving statistics");
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012261 /* Remove the SME statistics list by
12262 * passing NULL in callback argument
12263 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012264 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
12265 SME_SUMMARY_STATS |
12266 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080012267 SME_GLOBAL_CLASSD_STATS,
Naveen Rawatd0ca4412017-06-16 14:19:19 -070012268 NULL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012269 (WLAN_HDD_GET_STATION_CTX_PTR
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012270 (pAdapter))->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012271 staId[0], pAdapter,
12272 pAdapter->sessionId);
12273
12274 return -EINVAL;
12275 }
12276 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
12277 (uint8_t) sizeof(pStats->retry_cnt),
12278 (char *)&(pStats->retry_cnt[0]), tlen);
12279
12280 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
12281 (uint8_t) sizeof(pStats->multiple_retry_cnt),
12282 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
12283
12284 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
12285 (uint8_t) sizeof(pStats->tx_frm_cnt),
12286 (char *)&(pStats->tx_frm_cnt[0]), tlen);
12287
12288 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
12289 (uint8_t) sizeof(pStats->rx_frm_cnt),
12290 (char *)&(pStats->rx_frm_cnt), tlen);
12291
12292 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
12293 (uint8_t) sizeof(pStats->frm_dup_cnt),
12294 (char *)&(pStats->frm_dup_cnt), tlen);
12295
12296 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
12297 (uint8_t) sizeof(pStats->fail_cnt),
12298 (char *)&(pStats->fail_cnt[0]), tlen);
12299
12300 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
12301 (uint8_t) sizeof(pStats->rts_fail_cnt),
12302 (char *)&(pStats->rts_fail_cnt), tlen);
12303
12304 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
12305 (uint8_t) sizeof(pStats->ack_fail_cnt),
12306 (char *)&(pStats->ack_fail_cnt), tlen);
12307
12308 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
12309 (uint8_t) sizeof(pStats->rts_succ_cnt),
12310 (char *)&(pStats->rts_succ_cnt), tlen);
12311
12312 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
12313 (uint8_t) sizeof(pStats->rx_discard_cnt),
12314 (char *)&(pStats->rx_discard_cnt), tlen);
12315
12316 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
12317 (uint8_t) sizeof(pStats->rx_error_cnt),
12318 (char *)&(pStats->rx_error_cnt), tlen);
12319
12320 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
12321 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
12322 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
12323
12324 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
12325 (uint8_t) sizeof(dStats->rx_byte_cnt),
12326 (char *)&(dStats->rx_byte_cnt), tlen);
12327
12328 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
12329 (uint8_t) sizeof(dStats->rx_rate),
12330 (char *)&(dStats->rx_rate), tlen);
12331
12332 /* Transmit rate, in units of 500 kbit/sec */
12333 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
12334 (uint8_t) sizeof(aStats->tx_rate),
12335 (char *)&(aStats->tx_rate), tlen);
12336
12337 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
12338 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
12339 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
12340 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
12341 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
12342 (char *)&(dStats->rx_mc_byte_cnt), tlen);
12343 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
12344 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
12345 (char *)&(dStats->rx_bc_byte_cnt), tlen);
12346 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
12347 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
12348 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
12349 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
12350 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
12351 (char *)&(dStats->tx_mc_byte_cnt), tlen);
12352 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
12353 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
12354 (char *)&(dStats->tx_bc_byte_cnt), tlen);
12355
12356 wrqu->data.length = tlen;
12357
12358 }
12359
12360 EXIT();
12361
12362 return 0;
12363}
12364
12365static int iw_get_statistics(struct net_device *dev,
12366 struct iw_request_info *info,
12367 union iwreq_data *wrqu, char *extra)
12368{
12369 int ret;
12370
12371 cds_ssr_protect(__func__);
12372 ret = __iw_get_statistics(dev, info, wrqu, extra);
12373 cds_ssr_unprotect(__func__);
12374
12375 return ret;
12376}
12377
12378#ifdef FEATURE_WLAN_SCAN_PNO
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012379/*Max Len for PNO notification*/
12380#define MAX_PNO_NOTIFY_LEN 100
Abhishek Singh0481d662017-04-11 18:20:11 +053012381static void found_pref_network_cb(struct wlan_objmgr_vdev *vdev,
12382 struct scan_event *event, void *args)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012383{
Abhishek Singh0481d662017-04-11 18:20:11 +053012384 struct vdev_osif_priv *osif_priv;
12385 struct wireless_dev *wdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012386 union iwreq_data wrqu;
12387 char buf[MAX_PNO_NOTIFY_LEN + 1];
12388
Abhishek Singh0481d662017-04-11 18:20:11 +053012389 wlan_vdev_obj_lock(vdev);
12390 osif_priv = wlan_vdev_get_ospriv(vdev);
12391 wlan_vdev_obj_unlock(vdev);
12392 if (!osif_priv) {
12393 hdd_err("osif_priv is null");
12394 return;
12395 }
12396
12397 wdev = osif_priv->wdev;
12398 if (!wdev) {
12399 hdd_err("wdev is null");
12400 return;
12401 }
12402
12403 hdd_debug("A preferred network was found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012404
12405 /* create the event */
Abhishek Singh0481d662017-04-11 18:20:11 +053012406 qdf_mem_zero(&wrqu, sizeof(wrqu));
12407 qdf_mem_zero(buf, sizeof(buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012408
12409 snprintf(buf, MAX_PNO_NOTIFY_LEN,
Abhishek Singh0481d662017-04-11 18:20:11 +053012410 "QCOM: Found preferred network:");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012411
12412 wrqu.data.pointer = buf;
12413 wrqu.data.length = strlen(buf);
12414
12415 /* send the event */
12416
Abhishek Singh0481d662017-04-11 18:20:11 +053012417 wireless_send_event(wdev->netdev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012418}
12419
12420/**
12421 * __iw_set_pno() - Preferred Network Offload ioctl handler
12422 * @dev: device upon which the ioctl was received
12423 * @info: ioctl request information
12424 * @wrqu: ioctl request data
12425 * @extra: ioctl extra data
12426 *
12427 * This function parses a Preferred Network Offload command
12428 * Input is string based and expected to be of the form:
12429 *
12430 * <enable(1) | disable(0)>
12431 * when enabling:
12432 * <number of networks>
12433 * for each network:
12434 * <ssid_len> <ssid> <authentication> <encryption>
12435 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070012436 * <scan_time (seconds)>
12437 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012438 * <suspend mode>
12439 *
12440 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070012441 * 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 -080012442 *
12443 * this translates into:
12444 * -----------------------------
12445 * enable PNO
12446 * 2 networks
12447 * Network 1:
12448 * test - with authentication type 0 and encryption type 0,
12449 * search on 3 channels: 1 6 and 11,
12450 * SSID bcast type is unknown (directed probe will be sent if
12451 * AP not found) and must meet -40dBm RSSI
12452 * Network 2:
12453 * test2 - with authentication type 4 and encryption type 4,
12454 * search on 6 channels 1, 2, 3, 4, 5 and 6
12455 * bcast type is non-bcast (directed probe will be sent)
12456 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012457 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070012458 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012459 */
12460static int __iw_set_pno(struct net_device *dev,
12461 struct iw_request_info *info,
12462 union iwreq_data *wrqu, char *extra)
12463{
Jeff Johnson3d278b02017-08-29 14:17:47 -070012464 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070012465 struct hdd_context *hdd_ctx;
Abhishek Singh0481d662017-04-11 18:20:11 +053012466 uint8_t value;
12467 struct wlan_objmgr_vdev *vdev;
12468 struct wlan_objmgr_psoc *psoc;
12469 int ret = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012470 int offset;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012471 char *ptr, *data;
Abhishek Singh0481d662017-04-11 18:20:11 +053012472 uint8_t i, j, params;
12473 QDF_STATUS status;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012474 size_t len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012475
12476 /* request is a large struct, so we make it static to avoid
12477 * stack overflow. This API is only invoked via ioctl, so it
12478 * is serialized by the kernel rtnl_lock and hence does not
12479 * need to be reentrant
12480 */
Abhishek Singh0481d662017-04-11 18:20:11 +053012481 static struct pno_scan_req_params req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012482
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012483 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012484
12485 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12486 ret = wlan_hdd_validate_context(hdd_ctx);
12487 if (ret)
12488 return ret;
12489
Jeff Johnson441e1f72017-02-07 08:50:49 -080012490 ret = hdd_check_private_wext_control(hdd_ctx, info);
12491 if (0 != ret)
12492 return ret;
12493
Abhishek Singh0481d662017-04-11 18:20:11 +053012494 vdev = wlan_objmgr_get_vdev_by_macaddr_from_pdev(hdd_ctx->hdd_pdev,
12495 dev->dev_addr, WLAN_LEGACY_MAC_ID);
12496 if (!vdev) {
12497 hdd_err("vdev object is NULL");
12498 return -EIO;
12499 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012500
Abhishek Singh0481d662017-04-11 18:20:11 +053012501 hdd_debug("PNO data len %d data %s", wrqu->data.length, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012502
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012503 /* making sure argument string ends with '\0' */
12504 len = (wrqu->data.length + 1);
12505 data = qdf_mem_malloc(len);
12506 if (!data) {
12507 hdd_err("fail to allocate memory %zu", len);
12508 return -EINVAL;
12509 }
12510 qdf_mem_copy(data, extra, (len-1));
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012511 ptr = data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012512
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012513 if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012514 hdd_err("PNO enable input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012515 ret = -EINVAL;
12516 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012517 }
12518
Abhishek Singh0481d662017-04-11 18:20:11 +053012519 if (!value) {
12520 status = ucfg_scan_pno_stop(vdev);
12521 if (QDF_IS_STATUS_ERROR(status)) {
12522 hdd_err("Failed to disabled PNO");
12523 ret = -EINVAL;
12524 } else {
12525 hdd_debug("PNO scan disabled");
12526 }
12527 goto exit;
12528 }
12529
12530 if (ucfg_scan_get_pno_in_progress(vdev)) {
12531 hdd_debug("pno is already in progress");
12532 ret = -EBUSY;
12533 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012534 }
12535
12536 ptr += offset;
12537
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012538 if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012539 hdd_err("PNO count input not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012540 ret = -EINVAL;
12541 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012542 }
Abhishek Singh0481d662017-04-11 18:20:11 +053012543 req.networks_cnt = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012544
Abhishek Singh0481d662017-04-11 18:20:11 +053012545 hdd_debug("PNO enable networks count %d offset %d",
12546 req.networks_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012547
Abhishek Singh0481d662017-04-11 18:20:11 +053012548 if ((0 == req.networks_cnt) ||
12549 (req.networks_cnt > SCAN_PNO_MAX_SUPP_NETWORKS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012550 hdd_err("Network count %d invalid",
Abhishek Singh0481d662017-04-11 18:20:11 +053012551 req.networks_cnt);
12552 ret = -EINVAL;
12553 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012554 }
12555
12556 ptr += offset;
12557
Abhishek Singh0481d662017-04-11 18:20:11 +053012558 for (i = 0; i < req.networks_cnt; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012559
Abhishek Singh0481d662017-04-11 18:20:11 +053012560 req.networks_list[i].ssid.length = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012561
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012562 params = sscanf(ptr, " %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012563 &(req.networks_list[i].ssid.length),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012564 &offset);
12565
12566 if (1 != params) {
12567 hdd_err("PNO ssid length input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012568 ret = -EINVAL;
12569 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012570 }
12571
Abhishek Singh0481d662017-04-11 18:20:11 +053012572 if ((0 == req.networks_list[i].ssid.length) ||
12573 (req.networks_list[i].ssid.length > 32)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012574 hdd_err("SSID Len %d is not correct for network %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012575 req.networks_list[i].ssid.length, i);
12576 ret = -EINVAL;
12577 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012578 }
12579
12580 /* Advance to SSID */
12581 ptr += offset;
12582
Abhishek Singh0481d662017-04-11 18:20:11 +053012583 memcpy(req.networks_list[i].ssid.ssid, ptr,
12584 req.networks_list[i].ssid.length);
12585 ptr += req.networks_list[i].ssid.length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012586
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012587 params = sscanf(ptr, " %u %u %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012588 &(req.networks_list[i].authentication),
12589 &(req.networks_list[i].encryption),
12590 &(req.networks_list[i].channel_cnt),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012591 &offset);
12592
12593 if (3 != params) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012594 hdd_err("Incorrect cmd %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012595 ret = -EINVAL;
12596 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012597 }
12598
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012599 hdd_debug("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012600 req.networks_list[i].ssid.length,
12601 req.networks_list[i].ssid.length,
12602 req.networks_list[i].ssid.ssid,
12603 req.networks_list[i].authentication,
12604 req.networks_list[i].encryption,
12605 req.networks_list[i].channel_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012606
12607 /* Advance to channel list */
12608 ptr += offset;
12609
Abhishek Singh0481d662017-04-11 18:20:11 +053012610 if (SCAN_PNO_MAX_NETW_CHANNELS_EX <
12611 req.networks_list[i].channel_cnt) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012612 hdd_err("Incorrect number of channels");
Abhishek Singh0481d662017-04-11 18:20:11 +053012613 ret = -EINVAL;
12614 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012615 }
12616
Abhishek Singh0481d662017-04-11 18:20:11 +053012617 if (0 != req.networks_list[i].channel_cnt) {
12618 for (j = 0; j < req.networks_list[i].channel_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012619 j++) {
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012620 if (1 != sscanf(ptr, " %hhu %n", &value,
Abhishek Singh0481d662017-04-11 18:20:11 +053012621 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012622 hdd_err("PNO network channel is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012623 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012624 ret = -EINVAL;
12625 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012626 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012627 if (!IS_CHANNEL_VALID(value)) {
12628 hdd_err("invalid channel: %hhu", value);
12629 ret = -EINVAL;
12630 goto exit;
12631 }
Abhishek Singh0481d662017-04-11 18:20:11 +053012632 req.networks_list[i].channels[j] =
12633 cds_chan_to_freq(value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012634 /* Advance to next channel number */
12635 ptr += offset;
12636 }
12637 }
12638
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012639 if (1 != sscanf(ptr, " %u %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012640 &(req.networks_list[i].bc_new_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012641 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012642 hdd_err("PNO broadcast network type is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012643 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012644 ret = -EINVAL;
12645 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012646 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012647 if (req.networks_list[i].bc_new_type > 2) {
12648 hdd_err("invalid bcast nw type: %u",
12649 req.networks_list[i].bc_new_type);
12650 ret = -EINVAL;
12651 goto exit;
12652 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012653
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012654 hdd_debug("PNO bcastNetwType %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012655 req.networks_list[i].bc_new_type, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012656
12657 /* Advance to rssi Threshold */
12658 ptr += offset;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012659 if (1 != sscanf(ptr, " %d %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012660 &(req.networks_list[i].rssi_thresh),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012661 &offset)) {
12662 hdd_err("PNO rssi threshold input is not valid %s",
12663 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012664 ret = -EINVAL;
12665 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012666 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012667 hdd_debug("PNO rssi %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012668 req.networks_list[i].rssi_thresh, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012669 /* Advance to next network */
12670 ptr += offset;
12671 } /* For ucNetworkCount */
12672
Abhishek Singh0481d662017-04-11 18:20:11 +053012673 req.fast_scan_period = 0;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012674 if (sscanf(ptr, " %u %n", &(req.fast_scan_period), &offset) > 0) {
Abhishek Singh0481d662017-04-11 18:20:11 +053012675 req.fast_scan_period *= MSEC_PER_SEC;
Dustin Brown43e87292016-10-10 10:38:25 -070012676 ptr += offset;
12677 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012678 if (req.fast_scan_period == 0) {
12679 hdd_err("invalid fast scan period %u",
12680 req.fast_scan_period);
12681 ret = -EINVAL;
12682 goto exit;
12683 }
Dustin Brown43e87292016-10-10 10:38:25 -070012684
Abhishek Singh0481d662017-04-11 18:20:11 +053012685 req.fast_scan_max_cycles = 0;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012686 if (sscanf(ptr, " %hhu %n", &value,
Dustin Brown43e87292016-10-10 10:38:25 -070012687 &offset) > 0)
12688 ptr += offset;
Abhishek Singh0481d662017-04-11 18:20:11 +053012689 req.fast_scan_max_cycles = value;
Dustin Brown43e87292016-10-10 10:38:25 -070012690
Abhishek Singh0481d662017-04-11 18:20:11 +053012691 wlan_pdev_obj_lock(hdd_ctx->hdd_pdev);
12692 psoc = wlan_pdev_get_psoc(hdd_ctx->hdd_pdev);
12693 wlan_pdev_obj_unlock(hdd_ctx->hdd_pdev);
12694 ucfg_scan_register_pno_cb(psoc,
12695 found_pref_network_cb, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012696
Abhishek Singh0481d662017-04-11 18:20:11 +053012697 ucfg_scan_get_pno_def_params(vdev, &req);
12698 status = ucfg_scan_pno_start(vdev, &req);
12699 if (QDF_IS_STATUS_ERROR(status)) {
12700 hdd_err("Failed to enable PNO");
12701 ret = -EINVAL;
12702 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012703
Abhishek Singh0481d662017-04-11 18:20:11 +053012704exit:
12705 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012706
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012707 qdf_mem_free(data);
Abhishek Singh0481d662017-04-11 18:20:11 +053012708 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012709}
12710
12711static int iw_set_pno(struct net_device *dev,
12712 struct iw_request_info *info,
12713 union iwreq_data *wrqu, char *extra)
12714{
12715 int ret;
12716
12717 cds_ssr_protect(__func__);
12718 ret = __iw_set_pno(dev, info, wrqu, extra);
12719 cds_ssr_unprotect(__func__);
12720
12721 return ret;
12722}
12723#endif /* FEATURE_WLAN_SCAN_PNO */
12724
12725/* Common function to SetBand */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012726int hdd_reg_set_band(struct net_device *dev, u8 ui_band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012727{
Jeff Johnson3d278b02017-08-29 14:17:47 -070012728 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012729 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012730 enum band_info band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012731
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012732 QDF_STATUS status;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070012733 struct hdd_context *pHddCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012734 hdd_adapter_list_node_t *pAdapterNode, *pNext;
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012735 enum band_info currBand;
12736 enum band_info connectedBand;
12737 long lrc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012738
12739 pAdapterNode = NULL;
12740 pNext = NULL;
12741 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12742
12743 switch (ui_band) {
12744 case WLAN_HDD_UI_BAND_AUTO:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012745 band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012746 break;
12747 case WLAN_HDD_UI_BAND_5_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012748 band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012749 break;
12750 case WLAN_HDD_UI_BAND_2_4_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012751 band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012752 break;
12753 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070012754 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012755 return -EINVAL;
12756 }
12757
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012758 hdd_debug("change band to %u", band);
12759
12760 if ((band == BAND_2G && pHddCtx->config->nBandCapability == 2) ||
12761 (band == BAND_5G && pHddCtx->config->nBandCapability == 1)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012762 hdd_err("band value %u violate INI settings %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012763 band, pHddCtx->config->nBandCapability);
12764 return -EIO;
12765 }
12766
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012767 if (band == BAND_ALL) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012768 hdd_debug("Auto band received. Setting band same as ini value %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012769 pHddCtx->config->nBandCapability);
12770 band = pHddCtx->config->nBandCapability;
12771 }
12772
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012773 if (QDF_STATUS_SUCCESS != ucfg_reg_get_curr_band(pHddCtx->hdd_pdev,
Amar Singhal58b45ef2017-08-01 13:43:54 -070012774 &currBand)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012775 hdd_debug("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012776 return -EIO;
12777 }
12778
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012779 if (currBand == band)
12780 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012781
Amar Singhal58b45ef2017-08-01 13:43:54 -070012782 pHddCtx->curr_band = band;
12783
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012784 /* Change band request received.
12785 * Abort pending scan requests, flush the existing scan results,
12786 * and change the band capability
12787 */
12788 hdd_debug("Current band value = %u, new setting %u ",
12789 currBand, band);
12790
12791 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
12792 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
12793 pAdapter = pAdapterNode->pAdapter;
12794 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12795 wlan_abort_scan(pHddCtx->hdd_pdev, INVAL_PDEV_ID,
Abhishek Singh69ccb512017-04-25 11:58:16 +053012796 pAdapter->sessionId, INVALID_SCAN_ID, false);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012797 connectedBand = hdd_conn_get_connected_band(
12798 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012799
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012800 /* Handling is done only for STA and P2P */
12801 if (band != BAND_ALL &&
12802 ((pAdapter->device_mode == QDF_STA_MODE) ||
12803 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) &&
12804 (hdd_conn_is_connected(
12805 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter)))
12806 && (connectedBand != band)) {
12807 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012808
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012809 /* STA already connected on current
12810 * band, So issue disconnect first,
12811 * then change the band
12812 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012813
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012814 hdd_debug("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012815 hdd_device_mode_to_string(pAdapter->device_mode),
12816 pAdapter->device_mode, currBand, band);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012817 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012818
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012819 status = sme_roam_disconnect(
12820 WLAN_HDD_GET_HAL_CTX(pAdapter),
12821 pAdapter->sessionId,
12822 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012823
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012824 if (QDF_STATUS_SUCCESS != status) {
12825 hdd_err("sme_roam_disconnect failure, status: %d",
Jeff Johnson99bac312016-06-28 10:38:18 -070012826 (int)status);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012827 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012828 }
12829
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012830 lrc = wait_for_completion_timeout(
12831 &pAdapter->disconnect_comp_var,
12832 msecs_to_jiffies(
12833 WLAN_WAIT_TIME_DISCONNECT));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012834
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012835 if (lrc == 0) {
12836 hdd_err("Timeout while waiting for csr_roam_disconnect");
12837 return -ETIMEDOUT;
12838 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012839 }
12840
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012841 sme_scan_flush_result(hHal);
12842
12843 status = hdd_get_next_adapter(pHddCtx, pAdapterNode, &pNext);
12844 pAdapterNode = pNext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012845 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012846
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012847 if (QDF_STATUS_SUCCESS !=
12848 ucfg_reg_set_band(pHddCtx->hdd_pdev, band)) {
12849 hdd_err("Failed to set the band value to %u",
12850 band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012851 return -EINVAL;
12852 }
12853
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012854 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012855}
12856
12857static int __iw_set_band_config(struct net_device *dev,
12858 struct iw_request_info *info,
12859 union iwreq_data *wrqu, char *extra)
12860{
Jeff Johnson3d278b02017-08-29 14:17:47 -070012861 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070012862 struct hdd_context *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -080012863 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012864 int *value = (int *)extra;
12865
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012866 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012867
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012868 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012869 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012870 return -EPERM;
12871 }
12872
Jeff Johnson441e1f72017-02-07 08:50:49 -080012873 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12874 ret = hdd_check_private_wext_control(hdd_ctx, info);
12875 if (0 != ret)
12876 return ret;
12877
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012878 return hdd_reg_set_band(dev, value[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012879}
12880
12881static int iw_set_band_config(struct net_device *dev,
12882 struct iw_request_info *info,
12883 union iwreq_data *wrqu, char *extra)
12884{
12885 int ret;
12886
12887 cds_ssr_protect(__func__);
12888 ret = __iw_set_band_config(dev, info, wrqu, extra);
12889 cds_ssr_unprotect(__func__);
12890
12891 return ret;
12892}
12893
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012894/**
12895 * wlan_hdd_set_mon_chan() - Set capture channel on the monitor mode interface.
12896 * @adapter: Handle to adapter
12897 * @chan: Monitor mode channel
12898 * @bandwidth: Capture channel bandwidth
12899 *
12900 * Return: 0 on success else error code.
12901 */
Jeff Johnson3d278b02017-08-29 14:17:47 -070012902static int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012903 uint32_t bandwidth)
12904{
Jeff Johnson6d38ab82017-08-28 11:36:27 -070012905 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -070012906 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012907 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
12908 QDF_STATUS status;
12909 tHalHandle hal_hdl = hdd_ctx->hHal;
12910 struct qdf_mac_addr bssid;
12911 tCsrRoamProfile roam_profile;
Amar Singhal5cccafe2017-02-15 12:42:58 -080012912 struct ch_params ch_params;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012913
12914 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
12915 hdd_err("Not supported, device is not in monitor mode");
12916 return -EINVAL;
12917 }
12918
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012919 hdd_debug("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080012920 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012921 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
12922 roam_profile.ChannelInfo.numOfChannels = 1;
12923 roam_profile.phyMode = ch_info->phy_mode;
12924 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070012925 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012926
12927 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
12928 QDF_MAC_ADDR_SIZE);
12929
12930 ch_params.ch_width = bandwidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012931 wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params);
Manjunathappa Prakashc4dc9382017-03-07 18:50:33 -080012932 if (ch_params.ch_width == CH_WIDTH_INVALID) {
12933 hdd_err("Invalid capture channel or bandwidth for a country");
12934 return -EINVAL;
12935 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012936
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012937 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
12938 &roam_profile);
12939 if (status) {
12940 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
12941 status);
12942 }
12943
12944 return qdf_status_to_os_return(status);
12945}
12946
Dustin Brown8d2d0f52017-04-03 17:02:08 -070012947static int printk_adapter(void *priv, const char *fmt, ...)
12948{
12949 int ret;
12950 va_list args;
12951
12952 va_start(args, fmt);
12953 ret = vprintk(fmt, args);
12954 ret += printk("\n");
12955 va_end(args);
12956
12957 return ret;
12958}
12959
12960#ifdef WMI_INTERFACE_EVENT_LOGGING
12961static void hdd_ioctl_log_buffer(int log_id, uint32_t count)
12962{
12963 qdf_abstract_print *print = &printk_adapter;
12964
12965 switch (log_id) {
12966 case HTC_CREDIT_HISTORY_LOG:
12967 print(NULL, "HTC Credit History (count %u)", count);
12968 cds_print_htc_credit_history(count, print, NULL);
12969 break;
12970 case COMMAND_LOG:
12971 print(NULL, "Command Log (count %u)", count);
12972 wma_print_wmi_cmd_log(count, print, NULL);
12973 break;
12974 case COMMAND_TX_CMP_LOG:
12975 print(NULL, "Command Tx Complete Log (count %u)", count);
12976 wma_print_wmi_cmd_tx_cmp_log(count, print, NULL);
12977 break;
12978 case MGMT_COMMAND_LOG:
12979 print(NULL, "Management Command Log (count %u)", count);
12980 wma_print_wmi_mgmt_cmd_log(count, print, NULL);
12981 break;
12982 case MGMT_COMMAND_TX_CMP_LOG:
12983 print(NULL, "Management Command Tx Complete Log (count %u)",
12984 count);
12985 wma_print_wmi_mgmt_cmd_tx_cmp_log(count, print, NULL);
12986 break;
12987 case EVENT_LOG:
12988 print(NULL, "Event Log (count %u)", count);
12989 wma_print_wmi_event_log(count, print, NULL);
12990 break;
12991 case RX_EVENT_LOG:
12992 print(NULL, "Rx Event Log (count %u)", count);
12993 wma_print_wmi_rx_event_log(count, print, NULL);
12994 break;
12995 case MGMT_EVENT_LOG:
12996 print(NULL, "Management Event Log (count %u)", count);
12997 wma_print_wmi_mgmt_event_log(count, print, NULL);
12998 break;
12999 default:
13000 print(NULL, "Invalid Log Id %d", log_id);
13001 break;
13002 }
13003}
13004#else
13005static inline void hdd_ioctl_log_buffer(int log_id, uint32_t count)
13006{
13007}
13008#endif /* WMI_INTERFACE_EVENT_LOGGING */
13009
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013010static int __iw_set_two_ints_getnone(struct net_device *dev,
13011 struct iw_request_info *info,
13012 union iwreq_data *wrqu, char *extra)
13013{
Jeff Johnson3d278b02017-08-29 14:17:47 -070013014 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013015 int *value = (int *)extra;
13016 int sub_cmd = value[0];
13017 int ret;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070013018 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013019
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080013020 ENTER_DEV(dev);
13021
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013022 ret = wlan_hdd_validate_context(hdd_ctx);
13023 if (0 != ret)
13024 return ret;
13025
Jeff Johnson441e1f72017-02-07 08:50:49 -080013026 ret = hdd_check_private_wext_control(hdd_ctx, info);
13027 if (0 != ret)
13028 return ret;
13029
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013030 switch (sub_cmd) {
13031 case WE_SET_SMPS_PARAM:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080013032 hdd_debug("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013033 ret = wma_cli_set_command(pAdapter->sessionId,
13034 WMI_STA_SMPS_PARAM_CMDID,
13035 value[1] << WMA_SMPS_PARAM_VALUE_S
13036 | value[2],
13037 VDEV_CMD);
13038 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070013039#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013040 case WE_SET_FW_CRASH_INJECT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080013041 hdd_debug("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013042 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053013043 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
13044 value[1], value[2]);
Yue Ma06152352017-06-20 18:08:58 -070013045 if (value[1] == 3) {
Dustin Brown100201e2017-07-10 11:48:40 -070013046 cds_trigger_recovery();
Yue Ma06152352017-06-20 18:08:58 -070013047 return 0;
13048 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013049 ret = wma_cli_set2_command(pAdapter->sessionId,
13050 GEN_PARAM_CRASH_INJECT,
13051 value[1], value[2], GEN_CMD);
13052 break;
13053#endif
Govind Singha471e5e2015-10-12 17:11:14 +053013054 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070013055 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053013056 value[1], value[2]);
13057 ret = wma_cli_set2_command(pAdapter->sessionId,
13058 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
13059 value[1], value[2], DBG_CMD);
13060 break;
13061 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070013062 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053013063 value[1], value[2]);
13064 ret = wma_cli_set2_command(pAdapter->sessionId,
13065 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
13066 value[1], value[2], DBG_CMD);
13067 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013068 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
13069 hdd_debug("Ioctl to set dual fw mode config");
Tushnim Bhattacharyya49ed8ab2017-05-26 18:20:10 -070013070 if (hdd_ctx->config->dual_mac_feature_disable ==
13071 DISABLE_DBS_CXN_AND_SCAN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013072 hdd_err("Dual mac feature is disabled from INI");
13073 return -EPERM;
13074 }
13075 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080013076 policy_mgr_set_dual_mac_fw_mode_config(hdd_ctx->hdd_psoc,
13077 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013078 break;
13079 case WE_DUMP_DP_TRACE_LEVEL:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080013080 hdd_debug("WE_DUMP_DP_TRACE_LEVEL: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013081 value[1], value[2]);
13082 if (value[1] == DUMP_DP_TRACE)
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -070013083 qdf_dp_trace_dump_all(value[2],
13084 QDF_TRACE_DEFAULT_PDEV_ID);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053013085 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
13086 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053013087 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
13088 qdf_dp_trace_clear_buffer();
Mohit Khannaf8f96822017-05-17 17:11:59 -070013089 else if (value[1] == DISABLE_DP_TRACE_LIVE_MODE)
13090 qdf_dp_trace_disable_live_mode();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013091 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070013092 case WE_SET_MON_MODE_CHAN:
13093 ret = wlan_hdd_set_mon_chan(pAdapter, value[1], value[2]);
13094 break;
Dustin Brown54096432017-02-23 13:00:44 -080013095 case WE_SET_WLAN_SUSPEND: {
Dustin Brown3ed3e9b2017-03-23 12:57:58 -070013096 hdd_info("STA unit-test suspend(%d, %d)", value[1], value[2]);
Dustin Brown54096432017-02-23 13:00:44 -080013097 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
13098 value[1], value[2]);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070013099 break;
Dustin Brown54096432017-02-23 13:00:44 -080013100 }
Rajeev Kumara78a0a42016-07-13 19:28:20 -070013101 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070013102 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070013103 break;
Dustin Brown8d2d0f52017-04-03 17:02:08 -070013104 case WE_LOG_BUFFER: {
13105 int log_id = value[1];
13106 uint32_t count = value[2] < 0 ? 0 : value[2];
13107
13108 hdd_ioctl_log_buffer(log_id, count);
13109
13110 break;
13111 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013112 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070013113 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013114 break;
13115 }
13116
13117 return ret;
13118}
13119
13120static int iw_set_two_ints_getnone(struct net_device *dev,
13121 struct iw_request_info *info,
13122 union iwreq_data *wrqu, char *extra)
13123{
13124 int ret;
13125
13126 cds_ssr_protect(__func__);
13127 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
13128 cds_ssr_unprotect(__func__);
13129
13130 return ret;
13131}
13132
13133/* Define the Wireless Extensions to the Linux Network Device structure */
13134/* A number of these routines are NULL (meaning they are not implemented.) */
13135
13136static const iw_handler we_handler[] = {
13137 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
13138 (iw_handler) iw_get_name, /* SIOCGIWNAME */
13139 (iw_handler) NULL, /* SIOCSIWNWID */
13140 (iw_handler) NULL, /* SIOCGIWNWID */
13141 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
13142 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
13143 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
13144 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
13145 (iw_handler) NULL, /* SIOCSIWSENS */
13146 (iw_handler) NULL, /* SIOCGIWSENS */
13147 (iw_handler) NULL, /* SIOCSIWRANGE */
13148 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
13149 (iw_handler) NULL, /* SIOCSIWPRIV */
13150 (iw_handler) NULL, /* SIOCGIWPRIV */
13151 (iw_handler) NULL, /* SIOCSIWSTATS */
13152 (iw_handler) NULL, /* SIOCGIWSTATS */
13153 (iw_handler) NULL, /* SIOCSIWSPY */
13154 (iw_handler) NULL, /* SIOCGIWSPY */
13155 (iw_handler) NULL, /* SIOCSIWTHRSPY */
13156 (iw_handler) NULL, /* SIOCGIWTHRSPY */
13157 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
13158 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
13159 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
13160 (iw_handler) NULL, /* SIOCGIWAPLIST */
Sandeep Puligillad0004212017-02-26 18:34:56 -080013161 (iw_handler) NULL, /* SIOCSIWSCAN */
13162 (iw_handler) NULL, /* SIOCGIWSCAN */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013163 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
13164 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
13165 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
13166 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
13167 (iw_handler) NULL, /* -- hole -- */
13168 (iw_handler) NULL, /* -- hole -- */
13169 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
13170 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
13171 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
13172 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
13173 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
13174 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
13175 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
13176 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
13177 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
13178 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
13179 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
13180 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
13181 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
13182 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
13183 (iw_handler) NULL, /* -- hole -- */
13184 (iw_handler) NULL, /* -- hole -- */
13185 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
13186 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
13187 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
13188 (iw_handler) iw_get_auth, /* SIOCGIWAUTH */
13189 (iw_handler) iw_set_encodeext, /* SIOCSIWENCODEEXT */
13190 (iw_handler) iw_get_encodeext, /* SIOCGIWENCODEEXT */
13191 (iw_handler) NULL, /* SIOCSIWPMKSA */
13192};
13193
13194static const iw_handler we_private[] = {
13195
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070013196 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone,
13197 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint,
13198 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013199 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
13200 iw_set_three_ints_getnone,
13201 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070013202 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013203 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
13204 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013205 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
13206 iw_setnone_get_threeint,
Jeff Johnson6fa1e012017-04-05 06:40:53 -070013207 [WLAN_PRIV_FIPS_TEST - SIOCIWFIRSTPRIV] = hdd_fips_test,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013208 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
13209 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
13210 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013211 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013212 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
13213 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
13214 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
13215 iw_set_keepalive_params,
13216#ifdef WLAN_FEATURE_PACKET_FILTERING
13217 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
13218 iw_set_packet_filter_params,
13219#endif
13220#ifdef FEATURE_WLAN_SCAN_PNO
13221 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
13222#endif
13223 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013224 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
13225 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013226 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
13227 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
13228 iw_set_two_ints_getnone,
13229 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
13230 iw_set_dot11p_channel_sched,
13231};
13232
13233/*Maximum command length can be only 15 */
13234static const struct iw_priv_args we_private_args[] = {
13235
13236 /* handlers for main ioctl */
13237 {WLAN_PRIV_SET_INT_GET_NONE,
13238 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13239 0,
13240 ""},
13241
13242 /* handlers for sub-ioctl */
13243 {WE_SET_11D_STATE,
13244 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13245 0,
13246 "set11Dstate"},
13247
13248 {WE_WOWL,
13249 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13250 0,
13251 "wowl"},
13252
13253 {WE_SET_POWER,
13254 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13255 0,
13256 "setPower"},
13257
13258 {WE_SET_MAX_ASSOC,
13259 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13260 0,
13261 "setMaxAssoc"},
13262
13263 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
13264 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
13265 "setAutoChannel" },
13266
13267 {WE_SET_SCAN_DISABLE,
13268 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13269 0,
13270 "scan_disable"},
13271
13272 {WE_SET_DATA_INACTIVITY_TO,
13273 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13274 0,
13275 "inactivityTO"},
13276
Mukul Sharmaed92f2f2017-04-20 00:06:28 +053013277 {WE_SET_WOW_DATA_INACTIVITY_TO,
13278 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13279 0,
13280 "wow_ito"},
13281
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013282 {WE_SET_MAX_TX_POWER,
13283 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13284 0,
13285 "setMaxTxPower"},
13286
13287 {WE_SET_TX_POWER,
13288 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13289 0,
13290 "setTxPower"},
13291
13292 {WE_SET_MC_RATE,
13293 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13294 0,
13295 "setMcRate"},
13296
13297 {WE_SET_MAX_TX_POWER_2_4,
13298 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13299 0,
13300 "setTxMaxPower2G"},
13301
13302 {WE_SET_MAX_TX_POWER_5_0,
13303 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13304 0,
13305 "setTxMaxPower5G"},
13306
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080013307 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053013308 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080013309 0,
13310 "pktlog"},
13311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013312 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
13313 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080013314 * will support both
13315 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013316 {WE_SET_MAX_TX_POWER,
13317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13318 0,
13319 "setTxMaxPower"},
13320
13321 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080013322 * 1 = enable and 0 = disable
13323 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013324 {
13325 WE_SET_HIGHER_DTIM_TRANSITION,
13326 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13327 0,
13328 "setHDtimTransn"
13329 },
13330
13331 {WE_SET_TM_LEVEL,
13332 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13333 0,
13334 "setTmLevel"},
13335
13336 {WE_SET_PHYMODE,
13337 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13338 0,
13339 "setphymode"},
13340
13341 {WE_SET_NSS,
13342 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13343 0,
13344 "nss"},
13345
13346 {WE_SET_LDPC,
13347 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13348 0,
13349 "ldpc"},
13350
13351 {WE_SET_TX_STBC,
13352 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13353 0,
13354 "tx_stbc"},
13355
13356 {WE_SET_RX_STBC,
13357 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13358 0,
13359 "rx_stbc"},
13360
13361 {WE_SET_SHORT_GI,
13362 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13363 0,
13364 "shortgi"},
13365
13366 {WE_SET_RTSCTS,
13367 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13368 0,
13369 "enablertscts"},
13370
13371 {WE_SET_CHWIDTH,
13372 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13373 0,
13374 "chwidth"},
13375
13376 {WE_SET_ANI_EN_DIS,
13377 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13378 0,
13379 "anienable"},
13380
13381 {WE_SET_ANI_POLL_PERIOD,
13382 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13383 0,
13384 "aniplen"},
13385
13386 {WE_SET_ANI_LISTEN_PERIOD,
13387 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13388 0,
13389 "anilislen"},
13390
13391 {WE_SET_ANI_OFDM_LEVEL,
13392 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13393 0,
13394 "aniofdmlvl"},
13395
13396 {WE_SET_ANI_CCK_LEVEL,
13397 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13398 0,
13399 "aniccklvl"},
13400
13401 {WE_SET_DYNAMIC_BW,
13402 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13403 0,
13404 "cwmenable"},
13405
13406 {WE_SET_CTS_CBW,
13407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13408 0,
13409 "cts_cbw" },
13410
13411 {WE_SET_GTX_HT_MCS,
13412 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13413 0,
13414 "gtxHTMcs"},
13415
13416 {WE_SET_GTX_VHT_MCS,
13417 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13418 0,
13419 "gtxVHTMcs"},
13420
13421 {WE_SET_GTX_USRCFG,
13422 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13423 0,
13424 "gtxUsrCfg"},
13425
13426 {WE_SET_GTX_THRE,
13427 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13428 0,
13429 "gtxThre"},
13430
13431 {WE_SET_GTX_MARGIN,
13432 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13433 0,
13434 "gtxMargin"},
13435
13436 {WE_SET_GTX_STEP,
13437 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13438 0,
13439 "gtxStep"},
13440
13441 {WE_SET_GTX_MINTPC,
13442 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13443 0,
13444 "gtxMinTpc"},
13445
13446 {WE_SET_GTX_BWMASK,
13447 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13448 0,
13449 "gtxBWMask"},
13450
13451 {WE_SET_TX_CHAINMASK,
13452 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13453 0,
13454 "txchainmask"},
13455
13456 {WE_SET_RX_CHAINMASK,
13457 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13458 0,
13459 "rxchainmask"},
13460
13461 {WE_SET_11N_RATE,
13462 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13463 0,
13464 "set11NRates"},
13465
13466 {WE_SET_VHT_RATE,
13467 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13468 0,
13469 "set11ACRates"},
13470
13471 {WE_SET_AMPDU,
13472 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13473 0,
13474 "ampdu"},
13475
13476 {WE_SET_AMSDU,
13477 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13478 0,
13479 "amsdu"},
13480
13481 {WE_SET_BURST_ENABLE,
13482 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13483 0,
13484 "burst_enable"},
13485
13486 {WE_SET_BURST_DUR,
13487 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13488 0,
13489 "burst_dur"},
13490
13491 {WE_SET_TXPOW_2G,
13492 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13493 0,
13494 "txpow2g"},
13495
13496 {WE_SET_TXPOW_5G,
13497 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13498 0,
13499 "txpow5g"},
13500
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013501 /* Sub-cmds DBGLOG specific commands */
13502 {WE_DBGLOG_LOG_LEVEL,
13503 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13504 0,
13505 "dl_loglevel"},
13506
13507 {WE_DBGLOG_VAP_ENABLE,
13508 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13509 0,
13510 "dl_vapon"},
13511
13512 {WE_DBGLOG_VAP_DISABLE,
13513 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13514 0,
13515 "dl_vapoff"},
13516
13517 {WE_DBGLOG_MODULE_ENABLE,
13518 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13519 0,
13520 "dl_modon"},
13521
13522 {WE_DBGLOG_MODULE_DISABLE,
13523 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13524 0,
13525 "dl_modoff"},
13526
13527 {WE_DBGLOG_MOD_LOG_LEVEL,
13528 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13529 0,
13530 "dl_mod_loglevel"},
13531
13532 {WE_DBGLOG_TYPE,
13533 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13534 0,
13535 "dl_type"},
13536 {WE_DBGLOG_REPORT_ENABLE,
13537 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13538 0,
13539 "dl_report"},
13540
13541 {WE_SET_TXRX_FWSTATS,
13542 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13543 0,
13544 "txrx_fw_stats"},
13545
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080013546 {WE_SET_TXRX_STATS,
13547 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13548 0,
13549 "txrx_stats"},
13550
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013551 {WE_TXRX_FWSTATS_RESET,
13552 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13553 0,
13554 "txrx_fw_st_rst"},
13555
13556 {WE_PPS_PAID_MATCH,
13557 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13558 0, "paid_match"},
13559
13560 {WE_PPS_GID_MATCH,
13561 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13562 0, "gid_match"},
13563
13564 {WE_PPS_EARLY_TIM_CLEAR,
13565 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13566 0, "tim_clear"},
13567
13568 {WE_PPS_EARLY_DTIM_CLEAR,
13569 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13570 0, "dtim_clear"},
13571
13572 {WE_PPS_EOF_PAD_DELIM,
13573 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13574 0, "eof_delim"},
13575
13576 {WE_PPS_MACADDR_MISMATCH,
13577 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13578 0, "mac_match"},
13579
13580 {WE_PPS_DELIM_CRC_FAIL,
13581 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13582 0, "delim_fail"},
13583
13584 {WE_PPS_GID_NSTS_ZERO,
13585 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13586 0, "nsts_zero"},
13587
13588 {WE_PPS_RSSI_CHECK,
13589 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13590 0, "rssi_chk"},
13591
13592 {WE_PPS_5G_EBT,
13593 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13594 0, "5g_ebt"},
13595
13596 {WE_SET_HTSMPS,
13597 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13598 0, "htsmps"},
13599
13600 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
13601 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13602 0, "set_qpspollcnt"},
13603
13604 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
13605 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13606 0, "set_qtxwake"},
13607
13608 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13609 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13610 0, "set_qwakeintv"},
13611
13612 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13613 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13614 0, "set_qnodatapoll"},
13615
13616 /* handlers for MCC time quota and latency sub ioctls */
13617 {WE_MCC_CONFIG_LATENCY,
13618 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13619 0, "setMccLatency"},
13620
13621 {WE_MCC_CONFIG_QUOTA,
13622 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13623 0, "setMccQuota"},
13624
13625 {WE_SET_DEBUG_LOG,
13626 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13627 0, "setDbgLvl"},
13628
13629 /* handlers for early_rx power save */
13630 {WE_SET_EARLY_RX_ADJUST_ENABLE,
13631 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13632 0, "erx_enable"},
13633
13634 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
13635 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13636 0, "erx_bmiss_val"},
13637
13638 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
13639 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13640 0, "erx_bmiss_smpl"},
13641
13642 {WE_SET_EARLY_RX_SLOP_STEP,
13643 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13644 0, "erx_slop_step"},
13645
13646 {WE_SET_EARLY_RX_INIT_SLOP,
13647 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13648 0, "erx_init_slop"},
13649
13650 {WE_SET_EARLY_RX_ADJUST_PAUSE,
13651 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13652 0, "erx_adj_pause"},
13653
13654 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
13655 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13656 0, "erx_dri_sample"},
13657
13658 {WE_DUMP_STATS,
13659 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13660 0, "dumpStats"},
13661
13662 {WE_CLEAR_STATS,
13663 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13664 0, "clearStats"},
13665
Govind Singha471e5e2015-10-12 17:11:14 +053013666 {WE_START_FW_PROFILE,
13667 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13668 0, "startProfile"},
13669
Abhishek Singh1bdb1572015-10-16 16:24:19 +053013670 {WE_SET_CHANNEL,
13671 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13672 0, "setChanChange" },
13673
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053013674 {WE_SET_CONC_SYSTEM_PREF,
13675 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13676 0, "setConcSysPref" },
13677
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013678 {WLAN_PRIV_SET_NONE_GET_INT,
13679 0,
13680 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13681 ""},
13682
13683 /* handlers for sub-ioctl */
13684 {WE_GET_11D_STATE,
13685 0,
13686 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13687 "get11Dstate"},
13688
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013689 {WE_GET_WLAN_DBG,
13690 0,
13691 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13692 "getwlandbg"},
13693
13694 {WE_GET_MAX_ASSOC,
13695 0,
13696 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13697 "getMaxAssoc"},
13698
13699 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
13700 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13701 "getAutoChannel" },
13702
13703 {WE_GET_CONCURRENCY_MODE,
13704 0,
13705 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13706 "getconcurrency"},
13707
13708 {WE_GET_NSS,
13709 0,
13710 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13711 "get_nss"},
13712
13713 {WE_GET_LDPC,
13714 0,
13715 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13716 "get_ldpc"},
13717
13718 {WE_GET_TX_STBC,
13719 0,
13720 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13721 "get_tx_stbc"},
13722
13723 {WE_GET_RX_STBC,
13724 0,
13725 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13726 "get_rx_stbc"},
13727
13728 {WE_GET_SHORT_GI,
13729 0,
13730 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13731 "get_shortgi"},
13732
13733 {WE_GET_RTSCTS,
13734 0,
13735 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13736 "get_rtscts"},
13737
13738 {WE_GET_CHWIDTH,
13739 0,
13740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13741 "get_chwidth"},
13742
13743 {WE_GET_ANI_EN_DIS,
13744 0,
13745 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13746 "get_anienable"},
13747
13748 {WE_GET_ANI_POLL_PERIOD,
13749 0,
13750 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13751 "get_aniplen"},
13752
13753 {WE_GET_ANI_LISTEN_PERIOD,
13754 0,
13755 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13756 "get_anilislen"},
13757
13758 {WE_GET_ANI_OFDM_LEVEL,
13759 0,
13760 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13761 "get_aniofdmlvl"},
13762
13763 {WE_GET_ANI_CCK_LEVEL,
13764 0,
13765 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13766 "get_aniccklvl"},
13767
13768 {WE_GET_DYNAMIC_BW,
13769 0,
13770 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13771 "get_cwmenable"},
13772
13773 {WE_GET_GTX_HT_MCS,
13774 0,
13775 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13776 "get_gtxHTMcs"},
13777
13778 {WE_GET_GTX_VHT_MCS,
13779 0,
13780 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13781 "get_gtxVHTMcs"},
13782
13783 {WE_GET_GTX_USRCFG,
13784 0,
13785 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13786 "get_gtxUsrCfg"},
13787
13788 {WE_GET_GTX_THRE,
13789 0,
13790 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13791 "get_gtxThre"},
13792
13793 {WE_GET_GTX_MARGIN,
13794 0,
13795 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13796 "get_gtxMargin"},
13797
13798 {WE_GET_GTX_STEP,
13799 0,
13800 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13801 "get_gtxStep"},
13802
13803 {WE_GET_GTX_MINTPC,
13804 0,
13805 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13806 "get_gtxMinTpc"},
13807
13808 {WE_GET_GTX_BWMASK,
13809 0,
13810 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13811 "get_gtxBWMask"},
13812
13813 {WE_GET_TX_CHAINMASK,
13814 0,
13815 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13816 "get_txchainmask"},
13817
13818 {WE_GET_RX_CHAINMASK,
13819 0,
13820 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13821 "get_rxchainmask"},
13822
13823 {WE_GET_11N_RATE,
13824 0,
13825 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13826 "get_11nrate"},
13827
13828 {WE_GET_AMPDU,
13829 0,
13830 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13831 "get_ampdu"},
13832
13833 {WE_GET_AMSDU,
13834 0,
13835 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13836 "get_amsdu"},
13837
13838 {WE_GET_BURST_ENABLE,
13839 0,
13840 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13841 "get_burst_en"},
13842
13843 {WE_GET_BURST_DUR,
13844 0,
13845 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13846 "get_burst_dur"},
13847
13848 {WE_GET_TXPOW_2G,
13849 0,
13850 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13851 "get_txpow2g"},
13852
13853 {WE_GET_TXPOW_5G,
13854 0,
13855 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13856 "get_txpow5g"},
13857
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013858 {WE_GET_PPS_PAID_MATCH,
13859 0,
13860 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13861 "get_paid_match"},
13862
13863 {WE_GET_PPS_GID_MATCH,
13864 0,
13865 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13866 "get_gid_match"},
13867
13868 {WE_GET_PPS_EARLY_TIM_CLEAR,
13869 0,
13870 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13871 "get_tim_clear"},
13872
13873 {WE_GET_PPS_EARLY_DTIM_CLEAR,
13874 0,
13875 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13876 "get_dtim_clear"},
13877
13878 {WE_GET_PPS_EOF_PAD_DELIM,
13879 0,
13880 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13881 "get_eof_delim"},
13882
13883 {WE_GET_PPS_MACADDR_MISMATCH,
13884 0,
13885 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13886 "get_mac_match"},
13887
13888 {WE_GET_PPS_DELIM_CRC_FAIL,
13889 0,
13890 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13891 "get_delim_fail"},
13892
13893 {WE_GET_PPS_GID_NSTS_ZERO,
13894 0,
13895 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13896 "get_nsts_zero"},
13897
13898 {WE_GET_PPS_RSSI_CHECK,
13899 0,
13900 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13901 "get_rssi_chk"},
13902
13903 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
13904 0,
13905 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13906 "get_qpspollcnt"},
13907
13908 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
13909 0,
13910 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13911 "get_qtxwake"},
13912
13913 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13914 0,
13915 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13916 "get_qwakeintv"},
13917
13918 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13919 0,
13920 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13921 "get_qnodatapoll"},
13922
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013923 {WE_CAP_TSF,
13924 0,
13925 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13926 "cap_tsf"},
13927
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013928 {WE_GET_TEMPERATURE,
13929 0,
13930 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13931 "get_temp"},
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070013932 {WE_GET_DCM,
13933 0,
13934 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13935 "get_dcm"},
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070013936 {WE_GET_RANGE_EXT,
13937 0,
13938 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13939 "get_range_ext"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013940 /* handlers for main ioctl */
13941 {WLAN_PRIV_SET_CHAR_GET_NONE,
13942 IW_PRIV_TYPE_CHAR | 512,
13943 0,
13944 ""},
13945
13946 /* handlers for sub-ioctl */
13947 {WE_WOWL_ADD_PTRN,
13948 IW_PRIV_TYPE_CHAR | 512,
13949 0,
13950 "wowlAddPtrn"},
13951
13952 {WE_WOWL_DEL_PTRN,
13953 IW_PRIV_TYPE_CHAR | 512,
13954 0,
13955 "wowlDelPtrn"},
13956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013957 /* handlers for sub-ioctl */
13958 {WE_NEIGHBOR_REPORT_REQUEST,
13959 IW_PRIV_TYPE_CHAR | 512,
13960 0,
13961 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080013962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013963 {WE_SET_AP_WPS_IE,
13964 IW_PRIV_TYPE_CHAR | 512,
13965 0,
13966 "set_ap_wps_ie"},
13967
13968 {WE_SET_CONFIG,
13969 IW_PRIV_TYPE_CHAR | 512,
13970 0,
13971 "setConfig"},
13972
13973 /* handlers for main ioctl */
13974 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
13975 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13976 0,
13977 ""},
13978
13979 /* handlers for sub-ioctl */
13980 {WE_SET_WLAN_DBG,
13981 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13982 0,
13983 "setwlandbg"},
13984
13985 /* handlers for sub-ioctl */
13986 {WE_SET_DP_TRACE,
13987 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13988 0,
13989 "set_dp_trace"},
13990
13991 {WE_SET_SAP_CHANNELS,
13992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13993 0,
13994 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013995
13996 {WE_SET_FW_TEST,
13997 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13998 0, "fw_test"},
13999
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070014000 /* handlers for main ioctl */
14001 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
14002 0,
14003 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
14004 "" },
14005 {WE_GET_TSF,
14006 0,
14007 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
14008 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014009
14010 {WE_SET_DUAL_MAC_SCAN_CONFIG,
14011 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
14012 0,
14013 "set_scan_cfg"},
14014
14015 /* handlers for main ioctl */
14016 {WLAN_PRIV_GET_CHAR_SET_NONE,
14017 0,
14018 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14019 ""},
14020
14021 /* handlers for sub-ioctl */
14022 {WE_WLAN_VERSION,
14023 0,
14024 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14025 "version"},
14026 {WE_GET_STATS,
14027 0,
14028 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14029 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080014030 {WE_GET_SUSPEND_RESUME_STATS,
14031 0,
14032 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14033 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053014034 {WE_LIST_FW_PROFILE,
14035 0,
14036 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14037 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014038 {WE_GET_STATES,
14039 0,
14040 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14041 "getHostStates"},
14042 {WE_GET_CFG,
14043 0,
14044 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14045 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014046 {WE_GET_RSSI,
14047 0,
14048 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14049 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014050 {WE_GET_WMM_STATUS,
14051 0,
14052 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14053 "getWmmStatus"},
14054 {
14055 WE_GET_CHANNEL_LIST,
14056 0,
14057 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14058 "getChannelList"
14059 },
14060#ifdef FEATURE_WLAN_TDLS
14061 {
14062 WE_GET_TDLS_PEERS,
14063 0,
14064 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14065 "getTdlsPeers"
14066 },
14067#endif
14068#ifdef WLAN_FEATURE_11W
14069 {
14070 WE_GET_11W_INFO,
14071 0,
14072 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14073 "getPMFInfo"
14074 },
14075#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080014076 {
14077 WE_GET_IBSS_STA_INFO,
14078 0,
14079 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14080 "getIbssSTAs"
14081 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014082 {WE_GET_PHYMODE,
14083 0,
14084 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14085 "getphymode"},
Naveen Rawat910726a2017-03-06 11:42:51 -080014086#if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014087 {WE_GET_OEM_DATA_CAP,
14088 0,
14089 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14090 "getOemDataCap"},
Naveen Rawat910726a2017-03-06 11:42:51 -080014091#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014092 {WE_GET_SNR,
14093 0,
14094 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14095 "getSNR"},
14096
14097 /* handlers for main ioctl */
14098 {WLAN_PRIV_SET_NONE_GET_NONE,
14099 0,
14100 0,
14101 ""},
14102
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080014103 /* handlers for sub-ioctl */
14104 {
14105 WE_IBSS_GET_PEER_INFO_ALL,
14106 0,
14107 0,
14108 "ibssPeerInfoAll"
14109 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014110 {WE_GET_RECOVERY_STAT,
14111 0,
14112 0,
14113 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053014114
14115 {WE_GET_FW_PROFILE_DATA,
14116 0,
14117 0,
14118 "getProfileData"},
14119
14120 {WE_SET_REASSOC_TRIGGER,
14121 0,
14122 0,
14123 "reassoc"},
14124
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080014125 {WE_STOP_OBSS_SCAN,
14126 0,
14127 0,
14128 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014129 /* handlers for main ioctl */
14130 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
14131 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14132 0,
14133 ""},
14134
14135 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080014136 {WE_IBSS_GET_PEER_INFO,
14137 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14138 0,
14139 "ibssPeerInfo"},
14140
14141 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014142 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
14143 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14144 0,
14145 "setdumplog"},
14146
14147 {WE_MTRACE_DUMP_CMD,
14148 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14149 0,
14150 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080014151
14152 {WE_POLICY_MANAGER_CINFO_CMD,
14153 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14154 0,
14155 "pm_cinfo"},
14156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014157#ifdef MPC_UT_FRAMEWORK
14158 {WE_POLICY_MANAGER_CLIST_CMD,
14159 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14160 0,
14161 "pm_clist"},
14162
14163 {WE_POLICY_MANAGER_DLIST_CMD,
14164 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14165 0,
14166 "pm_dlist"},
14167
14168 {WE_POLICY_MANAGER_DBS_CMD,
14169 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14170 0,
14171 "pm_dbs"},
14172
14173 {WE_POLICY_MANAGER_PCL_CMD,
14174 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14175 0,
14176 "pm_pcl"},
14177
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014178 {WE_POLICY_MANAGER_ULIST_CMD,
14179 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14180 0,
14181 "pm_ulist"},
14182
14183 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
14184 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14185 0,
14186 "pm_query_action"},
14187
14188 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
14189 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14190 0,
14191 "pm_query_allow"},
14192
14193 {WE_POLICY_MANAGER_SCENARIO_CMD,
14194 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14195 0,
14196 "pm_run_scenario"},
14197
14198 {WE_POLICY_SET_HW_MODE_CMD,
14199 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14200 0,
14201 "pm_set_hw_mode"},
14202#endif
14203#ifdef FEATURE_WLAN_TDLS
14204 /* handlers for sub ioctl */
14205 {
14206 WE_TDLS_CONFIG_PARAMS,
14207 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14208 0,
14209 "setTdlsConfig"
14210 },
14211#endif
14212 {
14213 WE_UNIT_TEST_CMD,
14214 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14215 0,
14216 "setUnitTestCmd"
14217 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053014218 {
14219 WE_MAC_PWR_DEBUG_CMD,
14220 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14221 0,
14222 "halPwrDebug"
14223 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014224
14225#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
14226 {WE_LED_FLASHING_PARAM,
14227 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14228 0,
14229 "gpio_control"},
14230#endif
14231 /* handlers for main ioctl */
Jeff Johnson6fa1e012017-04-05 06:40:53 -070014232 {WLAN_PRIV_FIPS_TEST,
14233 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
14234 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
14235 "fips_test"},
14236
14237 /* handlers for main ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014238 {WLAN_PRIV_ADD_TSPEC,
14239 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
14240 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14241 "addTspec"},
14242
14243 /* handlers for main ioctl */
14244 {WLAN_PRIV_DEL_TSPEC,
14245 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14247 "delTspec"},
14248
14249 /* handlers for main ioctl */
14250 {WLAN_PRIV_GET_TSPEC,
14251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14252 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14253 "getTspec"},
14254
14255 /* handlers for main ioctl - host offload */
14256 {
14257 WLAN_PRIV_SET_HOST_OFFLOAD,
Srinivas Girigowda077143e2017-03-25 10:47:27 -070014258 IW_PRIV_TYPE_BYTE | sizeof(struct host_offload_req),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014259 0,
14260 "setHostOffload"
14261 }
14262 ,
14263
14264 {
14265 WLAN_GET_WLAN_STATISTICS,
14266 0,
14267 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
14268 "getWlanStats"
14269 }
14270 ,
14271
14272 {
14273 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053014274 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
14275 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014276 0,
14277 "setKeepAlive"
14278 }
14279 ,
14280#ifdef WLAN_FEATURE_PACKET_FILTERING
14281 {
14282 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053014283 IW_PRIV_TYPE_BYTE |
14284 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014285 0,
14286 "setPktFilter"
14287 }
14288 ,
14289#endif
14290#ifdef FEATURE_WLAN_SCAN_PNO
14291 {
14292 WLAN_SET_PNO,
14293 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14294 0,
14295 "setpno"
14296 }
14297 ,
14298#endif
14299 {
14300 WLAN_SET_BAND_CONFIG,
14301 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14302 0,
14303 "SETBAND"
14304 }
14305 ,
14306 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080014307 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080014308 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080014309 0,
14310 "setMCBCFilter"
14311 }
14312 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080014313
14314 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014315 WLAN_GET_LINK_SPEED,
14316 IW_PRIV_TYPE_CHAR | 18,
14317 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
14318 }
14319 ,
14320
14321 /* handlers for main ioctl */
14322 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
14323 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14324 0,
14325 ""}
14326 ,
14327 {WE_SET_SMPS_PARAM,
14328 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14329 0, "set_smps_param"}
14330 ,
14331 {WLAN_SET_DOT11P_CHANNEL_SCHED,
14332 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
14333 0, "set_dot11p" }
14334 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070014335#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014336 {WE_SET_FW_CRASH_INJECT,
14337 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14338 0, "crash_inject"}
14339 ,
Dustin Brown8d2d0f52017-04-03 17:02:08 -070014340 {WE_LOG_BUFFER,
14341 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14342 0, "log_buffer"}
14343 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014344#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070014345#ifdef WLAN_SUSPEND_RESUME_TEST
14346 {WE_SET_WLAN_SUSPEND,
14347 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14348 0, "wlan_suspend"}
14349 ,
14350 {WE_SET_WLAN_RESUME,
14351 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14352 0, "wlan_resume"}
14353 ,
14354#endif
Govind Singha471e5e2015-10-12 17:11:14 +053014355 {WE_ENABLE_FW_PROFILE,
14356 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14357 0, "enableProfile"}
14358 ,
14359 {WE_SET_FW_PROFILE_HIST_INTVL,
14360 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14361 0, "set_hist_intvl"}
14362 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014363 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
14364 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14365 0, "set_fw_mode_cfg"}
14366 ,
14367 {WE_DUMP_DP_TRACE_LEVEL,
14368 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14369 0, "dump_dp_trace"}
14370 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014371 {WE_SET_MON_MODE_CHAN,
14372 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14373 0, "setMonChan"}
14374 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070014375
14376 {WE_GET_ROAM_SYNCH_DELAY,
14377 0,
14378 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14379 "hostroamdelay"}
14380 ,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -080014381 {WE_SET_11AX_RATE,
14382 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14383 0,
14384 "set_11ax_rate"}
14385 ,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070014386 {WE_SET_DCM,
14387 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14388 0,
14389 "enable_dcm"}
14390 ,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070014391 {WE_SET_RANGE_EXT,
14392 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14393 0,
14394 "enable_range_ext"}
14395 ,
Naveen Rawatc921c7b2017-06-13 17:29:51 -070014396
14397 {WLAN_PRIV_SET_FTIES,
14398 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
14399 0,
14400 "set_ft_ies"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014401};
14402
14403const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053014404 .num_standard = QDF_ARRAY_SIZE(we_handler),
14405 .num_private = QDF_ARRAY_SIZE(we_private),
14406 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014407
14408 .standard = (iw_handler *) we_handler,
14409 .private = (iw_handler *) we_private,
14410 .private_args = we_private_args,
14411 .get_wireless_stats = NULL,
14412};
14413
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014414/* hdd_set_wext() - configures bss parameters
14415 * @pAdapter: handle to adapter context
14416 *
14417 * Returns: none
14418 */
Jeff Johnson3d278b02017-08-29 14:17:47 -070014419static int hdd_set_wext(struct hdd_adapter *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014420{
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014421 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -070014422 struct hdd_station_ctx *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014423
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014424 ENTER();
14425
14426 if (!pwextBuf) {
14427 hdd_err("ERROR: pwextBuf is NULL");
14428 return QDF_STATUS_E_FAILURE;
14429 }
14430
14431 if (!pHddStaCtx) {
14432 hdd_err("ERROR: pHddStaCtx is NULL");
14433 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070014434 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014435
14436 /* Now configure the roaming profile links. To SSID and bssid. */
14437 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014438 pwextBuf->roamProfile.SSIDs.SSIDList = &pHddStaCtx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014439
14440 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014441 pwextBuf->roamProfile.BSSIDs.bssid = &pHddStaCtx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014442
14443 /*Set the numOfChannels to zero to scan all the channels */
14444 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
14445 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
14446
14447 /* Default is no encryption */
14448 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
14449 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
14450 eCSR_ENCRYPT_TYPE_NONE;
14451
14452 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
14453 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
14454 eCSR_ENCRYPT_TYPE_NONE;
14455
14456 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
14457
14458 /* Default is no authentication */
14459 pwextBuf->roamProfile.AuthType.numEntries = 1;
14460 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
14461
14462 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
14463 pwextBuf->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
14464
14465 /*Set the default scan mode */
14466 pAdapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
14467
14468 hdd_clear_roam_profile_ie(pAdapter);
14469
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014470 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014471 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014472
14473}
14474
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014475#ifdef WLAN_FEATURE_FILS_SK
14476static void hdd_initialize_fils_info(hdd_wext_state_t *pwextBuf)
14477{
14478 pwextBuf->roamProfile.fils_con_info = NULL;
14479}
14480#else
14481static void hdd_initialize_fils_info(hdd_wext_state_t *pwextBuf)
14482{ }
14483#endif
14484
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070014485/**
14486 * hdd_register_wext() - register wext context
14487 * @dev: net device handle
14488 *
14489 * Registers wext interface context for a given net device
14490 *
14491 * Returns: 0 on success, errno on failure
14492 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014493int hdd_register_wext(struct net_device *dev)
14494{
Jeff Johnson3d278b02017-08-29 14:17:47 -070014495 struct hdd_adapter *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014496 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053014497 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014498
14499 ENTER();
14500
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014501 if (!pwextBuf) {
14502 hdd_err(FL("ERROR: pwextBuf is NULL"));
14503 return QDF_STATUS_E_FAILURE;
14504 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070014505
14506 /* Zero the memory. This zeros the profile structure */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014507 memset(pwextBuf, 0, sizeof(hdd_wext_state_t));
14508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014509 status = hdd_set_wext(pAdapter);
14510
Anurag Chouhance0dc992016-02-16 18:18:03 +053014511 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070014512 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014513 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014514 }
14515
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070014516 status = qdf_event_create(&pwextBuf->hdd_qdf_event);
14517 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070014518 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014519 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014520 }
14521
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014522 hdd_initialize_fils_info(pwextBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014523 /* Register as a wireless device */
14524 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
14525
14526 EXIT();
14527 return 0;
14528}
14529
14530int hdd_unregister_wext(struct net_device *dev)
14531{
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080014532 hdd_debug("dev(%p)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014533
14534 if (dev != NULL) {
14535 rtnl_lock();
14536 dev->wireless_handlers = NULL;
14537 rtnl_unlock();
14538 }
14539
14540 return 0;
14541}