blob: bb657adaaa3070dbd21f9bdc43b96b138017e40e [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"
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +0530106#include "wlan_hdd_packet_filter_api.h"
Abhishek Singh0481d662017-04-11 18:20:11 +0530107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108#define HDD_FINISH_ULA_TIME_OUT 800
109#define HDD_SET_MCBC_FILTERS_TO_FW 1
110#define HDD_DELETE_MCBC_FILTERS_FROM_FW 0
111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112/* To Validate Channel against the Frequency and Vice-Versa */
Srinivas Girigowda48592672017-03-25 14:58:44 -0700113static const struct ccp_freq_chan_map freq_chan_map[] = {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114 {2412, 1}, {2417, 2}, {2422, 3}, {2427, 4}, {2432, 5}, {2437, 6},
115 {2442, 7}, {2447, 8}, {2452, 9}, {2457, 10}, {2462, 11}, {2467, 12},
116 {2472, 13}, {2484, 14}, {4920, 240}, {4940, 244}, {4960, 248},
117 {4980, 252}, {5040, 208}, {5060, 212}, {5080, 216}, {5180, 36},
118 {5200, 40}, {5220, 44}, {5240, 48}, {5260, 52}, {5280, 56},
119 {5300, 60}, {5320, 64}, {5500, 100}, {5520, 104}, {5540, 108},
120 {5560, 112}, {5580, 116}, {5600, 120}, {5620, 124}, {5640, 128},
121 {5660, 132}, {5680, 136}, {5700, 140}, {5720, 144}, {5745, 149},
122 {5765, 153}, {5785, 157}, {5805, 161}, {5825, 165}, {5852, 170},
123 {5855, 171}, {5860, 172}, {5865, 173}, {5870, 174}, {5875, 175},
124 {5880, 176}, {5885, 177}, {5890, 178}, {5895, 179}, {5900, 180},
125 {5905, 181}, {5910, 182}, {5915, 183}, {5920, 184} };
126
Srinivas Girigowdafba82a02017-03-24 21:26:35 -0700127#define FREQ_CHAN_MAP_TABLE_SIZE QDF_ARRAY_SIZE(freq_chan_map)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128
129/* Private ioctls and their sub-ioctls */
130#define WLAN_PRIV_SET_INT_GET_NONE (SIOCIWFIRSTPRIV + 0)
131#define WE_SET_11D_STATE 1
132#define WE_WOWL 2
133#define WE_SET_POWER 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530134/*
135 * <ioctl>
136 * setMaxAssoc - Sets the maximum number of associated stations
137 *
138 * @INPUT: 1 to 32
139 *
140 * @OUTPUT: None
141 *
142 * This IOTCL sets the maximum number of associated stations
143 *
144 * @E.g: iwpriv wlan0 setMaxAssoc <value>
145 *
146 * Supported Feature: STA
147 *
148 * Usage: Internal/External
149 *
150 * </ioctl>
151 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152#define WE_SET_MAX_ASSOC 4
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +0530153/*
154 * <ioctl>
155 * scan_diable - Disable scan
156 *
157 * @INPUT: set_value
158 *
159 * @OUTPUT: None
160 *
161 * This IOCTL is used to set disable scan
162 *
163 * @E.g: iwpriv wlan0 scan_disable 1
164 *
165 * Supported Feature: Scan
166 *
167 * Usage: Internal/External
168 *
169 * </ioctl>
170 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171#define WE_SET_SCAN_DISABLE 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530172/*
173 * <ioctl>
174 * inactivityTO - sets the timeout value for inactivity data while
175 * in power save mode
176 *
177 * @INPUT: int1…..int255
178 *
179 * @OUTPUT: None
180 *
181 * This IOCTL set the timeout value for inactivity data in power save mode
182 *
183 * @E.g: iwpriv wlan0 inactivityTO 20
184 *
185 * Supported Feature: STA
186 *
187 * Usage: Internal/External
188 *
189 * </ioctl>
190 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191#define WE_SET_DATA_INACTIVITY_TO 6
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530192/*
193 * <ioctl>
194 * setMaxTxPower - Dynamically sets the maximum transmission power
195 *
196 * @INPUT: Transmission power in dBm
197 *
198 * @OUTPUT: None
199 *
200 * This IOCTL dynamically sets the maximum transmission power
201 * This setting does not persist over reboots
202 *
203 * @E.g: iwpriv wlan0 setMaxTxPower <value in db)
204 *
205 * Supported Feature: STA
206 *
207 * Usage: Internal/External
208 *
209 * </ioctl>
210 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211#define WE_SET_MAX_TX_POWER 7
212#define WE_SET_HIGHER_DTIM_TRANSITION 8
213#define WE_SET_TM_LEVEL 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530214/*
215 * <ioctl>
216 * setphymode - Set the phymode dynamically
217 *
218 * @INPUT: 0 IEEE80211_MODE_AUTO to 22 IEEE80211_MODE_11AGN
219 *
220 * @OUTPUT: None
221 *
222 * This IOCTL sets the phymode dynamically
223 *
224 * @E.g: iwpriv wlan0 setphymode 10
225 *
226 * Supported Feature: STA
227 *
228 * Usage: Internal/External
229 *
230 * </ioctl>
231 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232#define WE_SET_PHYMODE 10
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530233/*
234 * <ioctl>
235 * nss - Set the number of spatial streams
236 *
237 * @INPUT: int1…..int3
238 *
239 * @OUTPUT: None
240 *
241 * This IOCTL sets the number of spatial streams. Supported values are 1 and 2
242 *
243 * @E.g: iwpriv wlan0 nss 2
244 *
245 * Supported Feature: STA
246 *
247 * Usage: Internal/External
248 *
249 * </ioctl>
250 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251#define WE_SET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530252/*
253 * <ioctl>
254 * ldpc - Enables or disables LDPC
255 *
256 * @INPUT: 0 – Disable, 1 - Enable
257 *
258 * @OUTPUT: None
259 *
260 * This IOCTL enables or disables LDPC
261 *
262 * @E.g: iwpriv wlan0 ldpc 1
263 *
264 * Supported Feature: STA
265 *
266 * Usage: Internal/External
267 *
268 * </ioctl>
269 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270#define WE_SET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530271/*
272 * <ioctl>
273 * tx_stbc - Enables or disables tx_stbc
274 *
275 * @INPUT: Int 0 – Disable, 1 - Enable
276 *
277 * @OUTPUT: None
278 *
279 * This IOTCL used to enables or disables tx_stbc
280 *
281 * @E.g: iwpriv wlan0 tx_stbc <value>
282 *
283 * Supported Feature: STA
284 *
285 * Usage: Internal/External
286 *
287 * </ioctl>
288 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289#define WE_SET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530290/*
291 * <ioctl>
292 * rx_stbc - Set the rx_stbc parameter
293 *
294 * @INPUT: Int 0 – Disable, 1 - Enable
295 *
296 * @OUTPUT: None
297 *
298 * This IOTCL used to set rx_stbc parameter
299 *
300 * @E.g: iwpriv wlan0 rx_stbc <value>
301 *
302 * Supported Feature: STA
303 *
304 * Usage: Internal/External
305 *
306 * </ioctl>
307 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308#define WE_SET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530309/*
310 * <ioctl>
311 * shortgi - Enables or disables a short-guard interval
312 *
313 * @INPUT: Int 0 – Disable, 1 - Enable
314 *
315 * @OUTPUT: None
316 *
317 * This IOCTL enables or disables a short-guard interval.
318 *
319 * @E.g: iwpriv wlan0 shortgi <value>
320 *
321 * Supported Feature: STA
322 *
323 * Usage: Internal/External
324 *
325 * </ioctl>
326 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327#define WE_SET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530328/*
329 * <ioctl>
330 * enablertscts - enables or disables rts/cts.
331 *
332 * @INPUT: 1-Enable , 0-Disable
333 *
334 * @OUTPUT: None
335 *
336 * This IOCTL enables or disables rts/cts.
337 *
338 * @E.g: iwpriv wlan0 enablertscts <value>
339 *
340 * Supported Feature: STA
341 *
342 * Usage: Internal/External
343 *
344 * </ioctl>
345 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346#define WE_SET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530347/*
348 * <ioctl>
349 * chwidth - Set the channel bandwidth
350 *
351 * @INPUT: 0-20mhz to 3-160mhz
352 *
353 * @OUTPUT: None
354 *
355 * This IOTCL used to set the channel bandwidth
356 *
357 * @E.g: iwpriv wlan0 chwidth 1
358 *
359 * Supported Feature: STA
360 *
361 * Usage: Internal/External
362 *
363 * </ioctl>
364 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365#define WE_SET_CHWIDTH 17
366#define WE_SET_ANI_EN_DIS 18
367#define WE_SET_ANI_POLL_PERIOD 19
368#define WE_SET_ANI_LISTEN_PERIOD 20
369#define WE_SET_ANI_OFDM_LEVEL 21
370#define WE_SET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530371/*
372 * <ioctl>
373 * cwmenable - Enables or disables the dynamic channel bandwidth
374 *
375 * @INPUT: 0-Disable, 1-Enable
376 *
377 * @OUTPUT: None
378 *
379 * This IOTCL used to enables or disables the dynamic channel bandwidth
380 *
381 * @E.g: iwpriv wlan0 cwmenable <value>
382 *
383 * Supported Feature: STA
384 *
385 * Usage: Internal/External
386 *
387 * </ioctl>
388 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389#define WE_SET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530390/*
391 * <ioctl>
392 * txchainmask - This IOCTL sets the current Tx chain mask
393 *
394 * @INPUT: Mask Value
395 *
396 * @OUTPUT: None
397 *
398 * This IOCTL sets the current Tx chain mask
399 *
400 * @E.g: iwpriv wlan0 txchainmask 1
401 *
402 * Supported Feature: STA
403 *
404 * Usage: Internal/External
405 *
406 * </ioctl>
407 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408#define WE_SET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530409/*
410 * <ioctl>
411 * rxchainmask - Sets the current Rx chain mask
412 *
413 * @INPUT: Mask Value
414 *
415 * @OUTPUT: None
416 *
417 * This IOCTL sets the current Rx chain mask. This command is the
418 * equivalent to setting in gSetRxChainmask1x1 in WCNSS_qcom_cfg.ini.
419 *
420 * @E.g: iwpriv wlan0 rxchainmask <value>
421 *
422 * Supported Feature: STA
423 *
424 * Usage: Internal/External
425 *
426 * </ioctl>
427 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428#define WE_SET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530429/*
430 * <ioctl>
431 * set11NRates - Fixes the Tx data rate of the 11N mode.
432 *
433 * @INPUT: 0x1b to 0x8f
434 *
435 * @OUTPUT: None
436 *
437 * This IOCTL fixes the Tx data rate of the 11N mode.
438 *
439 * @E.g: iwpriv wlan0 set11NRates 0x85
440 *
441 * Supported Feature: STA
442 *
443 * Usage: Internal/External
444 *
445 * </ioctl>
446 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447#define WE_SET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530448/*
449 * <ioctl>
450 * ampdu - Set the the maximum subframe of ampdu
451 *
452 * @INPUT: int 1 to int 63
453 *
454 * @OUTPUT: None
455 *
456 * This IOCTL sets the maximum subframe of ampdu.
457 *
458 * @E.g: iwpriv wlan0 ampdu 9
459 *
460 * Supported Feature: STA
461 *
462 * Usage: Internal/External
463 *
464 * </ioctl>
465 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466#define WE_SET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530467/*
468 * <ioctl>
469 * amsdu - Sets the maximum subframe of amsdu.
470 *
471 * @INPUT: int 1 to int 31
472 *
473 * @OUTPUT: None
474 *
475 * This IOCTL sets the maximum subframe of amsdu.
476 *
477 * @E.g: iwpriv wlan0 amsdu 9
478 *
479 * Supported Feature: STA
480 *
481 * Usage: Internal/External
482 *
483 * </ioctl>
484 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485#define WE_SET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530486/*
487 * <ioctl>
488 * txpow2g - current 2 GHz Tx power setting
489 *
490 * @INPUT: Tx power in dBm
491 *
492 * @OUTPUT: None
493 *
494 * This IOTCL used to set 2 ghz tx power
495 *
496 * @E.g: iwpriv wlan0 txpow2g
497 *
498 * Supported Feature: STA
499 *
500 * Usage: Internal/External
501 *
502 * </ioctl>
503 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800504#define WE_SET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530505/*
506 * <ioctl>
507 * txpow5g - Current 5 GHz tx power setting
508 *
509 * @INPUT: Tx power in dBm
510 *
511 * @OUTPUT: None
512 *
513 * This IOTCL used to set the 5 ghz txpower
514 *
515 * @E.g: iwpriv wlan0 txpow5g
516 *
517 * Supported Feature: STA
518 *
519 * Usage: Internal/External
520 *
521 * </ioctl>
522 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523#define WE_SET_TXPOW_5G 30
524/* Private ioctl for firmware debug log */
525#define WE_DBGLOG_LOG_LEVEL 31
526#define WE_DBGLOG_VAP_ENABLE 32
527#define WE_DBGLOG_VAP_DISABLE 33
528#define WE_DBGLOG_MODULE_ENABLE 34
529#define WE_DBGLOG_MODULE_DISABLE 35
530#define WE_DBGLOG_MOD_LOG_LEVEL 36
531#define WE_DBGLOG_TYPE 37
532#define WE_SET_TXRX_FWSTATS 38
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530533/*
534 * <ioctl>
535 * set11ACRates - Fixes the Tx data rate of 11AC
536 *
537 * @INPUT: 0x1 to 0x9
538 *
539 * @OUTPUT: None
540 *
541 * This IOCTL fixes the Tx data rate of 11AC.
542 *
543 * @E.g: iwpriv wlan0 set11ACRates 0x9
544 *
545 * Supported Feature: STA
546 *
547 * Usage: Internal/External
548 *
549 * </ioctl>
550 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551#define WE_SET_VHT_RATE 39
552#define WE_DBGLOG_REPORT_ENABLE 40
553#define WE_TXRX_FWSTATS_RESET 41
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530554/*
555 * <ioctl>
556 * setTxMaxPower2G - Set the maximum transmit power for the 2.4-GHz band
557 *
558 * @INPUT: Transmission power in dBm
559 *
560 * @OUTPUT: None
561 *
562 * This IOCTL sets the maximum transmit power for the 2.4-GHz band
563 * This setting does not persist over reboots
564 *
565 * @E.g: iwpriv wlan0 setTxMaxPower2G 10
566 *
567 * Supported Feature: STA
568 *
569 * Usage: Internal/External
570 *
571 * </ioctl>
572 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573#define WE_SET_MAX_TX_POWER_2_4 42
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530574/*
575 * <ioctl>
576 * setTxMaxPower5G - Set the maximum transmit power for the 5-GHz band
577 *
578 * @INPUT: Transmission power in dBm
579 *
580 * @OUTPUT: None
581 *
582 * This IOCTL sets the maximum transmit power for the 5-GHz band
583 * This setting does not persist over reboots
584 *
585 * @E.g: iwpriv wlan0 setTxMaxPower5G 10
586 *
587 * Supported Feature: STA
588 *
589 * Usage: Internal/External
590 *
591 * </ioctl>
592 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593#define WE_SET_MAX_TX_POWER_5_0 43
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -0800594#define WE_SET_PKTLOG 44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595/* Private ioctl for packet powe save */
596#define WE_PPS_PAID_MATCH 45
597#define WE_PPS_GID_MATCH 46
598#define WE_PPS_EARLY_TIM_CLEAR 47
599#define WE_PPS_EARLY_DTIM_CLEAR 48
600#define WE_PPS_EOF_PAD_DELIM 49
601#define WE_PPS_MACADDR_MISMATCH 50
602#define WE_PPS_DELIM_CRC_FAIL 51
603#define WE_PPS_GID_NSTS_ZERO 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530604/*
605 * <ioctl>
606 * rssi_chk - Chek the rssi
607 *
608 * @INPUT: One argument as input
609 *
610 * @OUTPUT: rssi
611 * wlan0 rssi_chk:56
612 *
613 * This IOTCL used to chek rssi
614 *
615 * @E.g: iwpriv wlan0 rssi_chk <value>
616 *
617 * Supported Feature: STA
618 *
619 * Usage: Internal/External
620 *
621 * </ioctl>
622 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623#define WE_PPS_RSSI_CHECK 53
Agrawal Ashishbafaff12016-12-27 17:43:08 +0530624/*
625 * <ioctl>
626 * setAutoChannel - set ACS enable/disable
627 *
628 * @INPUT: None
629 *
630 * @OUTPUT: None
631 *
632 * This IOCTL is used to set SAP ACS eanble/disable
633 *
634 * @E.g: iwpriv wlan0 setAutoChannel 0
635 *
636 * Supported Feature: SAP
637 *
638 * Usage: Internal/External
639 *
640 * </ioctl>
641 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642#define WE_SET_SAP_AUTO_CHANNEL_SELECTION 54
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530643/*
644 * <ioctl>
645 * htsmps - Sets the htsmps
646 *
647 * @INPUT: Atleast one int argument
648 *
649 * @OUTPUT: None
650 *
651 * This IOTCL used to set htsmps
652 *
653 * @E.g: iwpriv wlan0 htsmps <value>
654 *
655 * Supported Feature: STA
656 *
657 * Usage: Internal/External
658 *
659 * </ioctl>
660 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661#define WE_SET_HTSMPS 55
662/* Private ioctl for QPower */
663#define WE_SET_QPOWER_MAX_PSPOLL_COUNT 56
664#define WE_SET_QPOWER_MAX_TX_BEFORE_WAKE 57
665#define WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 58
666#define WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 59
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530667/*
668 * <ioctl>
669 * burst_enable - Enables or disables the burst feature
670 *
671 * @INPUT: 0-Disable, 1-Enable
672 *
673 * @OUTPUT: None
674 *
675 * This IOCTL enables or disables the burst feature.
676 *
677 * @E.g: iwpriv wlan0 burst_enable 0
678 *
679 * Supported Feature: STA
680 *
681 * Usage: Internal/External
682 *
683 * </ioctl>
684 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685#define WE_SET_BURST_ENABLE 60
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530686/*
687 * <ioctl>
688 * burst_dur - Enables or disables the burst feature
689 *
690 * @INPUT: int 1…..int 8191 in microseconds
691 *
692 * @OUTPUT: None
693 *
694 * This IOCTL sets the burst duration.
695 *
696 * @E.g: iwpriv wlan0 burst_dur <value>
697 *
698 * Supported Feature: STA
699 *
700 * Usage: Internal/External
701 *
702 * </ioctl>
703 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704#define WE_SET_BURST_DUR 61
705/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530706/*
707 * <ioctl>
708 * gtxHTMcs - Set the tx HTM value
709 *
710 * @INPUT: Atleast one int orgument
711 *
712 * @OUTPUT: None
713 *
714 * This IOTCL sets htm tx value
715 *
716 * @E.g: iwpriv wlan0 gtxHTMcs <value>
717 *
718 * Supported Feature: STA
719 *
720 * Usage: Internal/External
721 *
722 * </ioctl>
723 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724#define WE_SET_GTX_HT_MCS 62
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530725/*
726 * <ioctl>
727 * gtxVHTMcs - Set gtxVHTMcs value
728 *
729 * @INPUT: Atleast one int argument
730 *
731 * @OUTPUT: None
732 *
733 * This IOTCL used to set gtxVHTMcs value
734 *
735 * @E.g: iwpriv wlan0 gtxVHTMcs <value>
736 *
737 * Supported Feature: STA
738 *
739 * Usage: Internal/External
740 *
741 * </ioctl>
742 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743#define WE_SET_GTX_VHT_MCS 63
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530744/*
745 * <ioctl>
746 * gtxUsrCfg - Host request for GTX mask
747 *
748 * @INPUT: Atleast one int orgument
749 *
750 * @OUTPUT: None
751 *
752 * This IOTCL used send the host request for GTX mask
753 *
754 * @E.g: iwpriv wlan0 gtxUsrCfg <value>
755 *
756 * Supported Feature: STA
757 *
758 * Usage: Internal/External
759 *
760 * </ioctl>
761 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762#define WE_SET_GTX_USRCFG 64
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530763/*
764 * <ioctl>
765 * gtxThre - Set the tx threshold
766 *
767 * @INPUT: Atleast one int argument
768 *
769 * @OUTPUT: None
770 *
771 * This IOTCL used to set tx threshold
772 *
773 * @E.g: iwpriv wlan0 gtxThre <value>
774 *
775 * Supported Feature: STA
776 *
777 * Usage: Internal/External
778 *
779 * </ioctl>
780 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781#define WE_SET_GTX_THRE 65
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530782/*
783 * <ioctl>
784 * gtxMargin - Set the gtxMargin
785 *
786 * @INPUT: 1 to 32
787 *
788 * @OUTPUT: None
789 *
790 * This IOTCL use dto set gtxMargin
791 *
792 * @E.g: iwpriv wlan0 gtxMargini <value>
793 *
794 * Supported Feature: STA
795 *
796 * Usage: Internal/External
797 *
798 * </ioctl>
799 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800#define WE_SET_GTX_MARGIN 66
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530801/*
802 * <ioctl>
803 * gtxStep - Set the gtxStep
804 *
805 * @INPUT: None
806 *
807 * @OUTPUT: None
808 *
809 * This IOTCL used to sets gtxStep
810 *
811 * @E.g: iwpriv wlan0 gtxStep <value>
812 *
813 * Supported Feature: STA
814 *
815 * Usage: Internal/External
816 *
817 * </ioctl>
818 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819#define WE_SET_GTX_STEP 67
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530820/*
821 * <ioctl>
822 * gtxMinTpc - Sets the gtxMinTpc
823 *
824 * @INPUT: Atleast one int argument
825 *
826 * @OUTPUT: None
827 *
828 * This IOTCL sets the tx MinTpc
829 *
830 * @E.g: iwpriv wlan0 gtxMinTpc <value>
831 *
832 * Supported Feature: STA
833 *
834 * Usage: Internal/External
835 *
836 * </ioctl>
837 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838#define WE_SET_GTX_MINTPC 68
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530839/*
840 * <ioctl>
841 * gtxBWMask - Sets the BW mask (20/40/80/160 Mhz)
842 *
843 * @INPUT: Mask value
844 *
845 * @OUTPUT: None
846 *
847 * This IOTCL used to set gtxBWMask
848 *
849 * @E.g: iwpriv wlan0 gtxBWMask <value>
850 *
851 * Supported Feature: STA
852 *
853 * Usage: Internal/External
854 *
855 * </ioctl>
856 */
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530857
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530858#define WE_SET_GTX_BWMASK 69
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530859/*
860 * <ioctl>
861 * setMccLatency - Sets the MCC latency value during STA-P2P concurrency
862 *
863 * @INPUT: set_value
864 *
865 * @OUTPUT: None
866 *
867 * This IOCTL is used to set the MCC latency value in milliseconds
868 * during STA-P2P concurrency.
869 *
870 * If 0ms latency is provided, then FW will set to a default.
871 * Otherwise, latency must be at least 30ms.
872 *
873 * @E.g: iwpriv wlan0 setMccLatency 40
874 *
875 *
876 * Supported Feature: Concurrency
877 *
878 * Usage: Internal/External
879 *
880 * </ioctl>
881 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882#define WE_MCC_CONFIG_LATENCY 70
Nitesh Shahc87a7a82016-12-14 11:37:55 +0530883
884/*
885 * <ioctl>
886 * setMccQuota- Set the quota for P2P cases
887 *
888 * @INPUT: set_value [0,100]
889 *
890 * @OUTPUT: None
891 *
892 * This IOCTL is used to set the quota in milliseconds for P2P_GO/STA.
893 *
894 * Currently used to set time quota for 2 MCC vdevs/adapters using
895 * (operating channel, quota) for each mode.
896 * The info is provided run time using iwpriv command:
897 * iwpriv <wlan0 | p2p0> setMccQuota <quota in ms>.
898 * Note: the quota provided in command is for the same mode in cmd.
899 * HDD checks if MCC mode is active, gets the second mode and its
900 * operating chan.
901 * Quota for the 2nd role is calculated as 100 - quota of first mode.
902 *
903 * @E.g: iwpriv wlan0 setMccQuota 50
904 * iwpriv p2p0 setMccQuota 50
905 *
906 * Supported Feature: Concurrency
907 *
908 * Usage: Internal/External
909 *
910 * </ioctl>
911 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912#define WE_MCC_CONFIG_QUOTA 71
913/* Private IOCTL for debug connection issues */
914#define WE_SET_DEBUG_LOG 72
915#ifdef WE_SET_TX_POWER
916#undef WE_SET_TX_POWER
917#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530918/*
919 * <ioctl>
920 * setTxPower - Set the current transmit power
921 *
922 * @INPUT: Transmission power in dBm
923 *
924 * @OUTPUT: None
925 *
926 * This IOCTL sets the current transmit power.
927 * This setting does not persist over reboots.
928 *
929 * @E.g: iwpriv wlan0 setTxPower 10
930 *
931 * Supported Feature: STA
932 *
933 * Usage: Internal/External
934 *
935 * </ioctl>
936 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937#define WE_SET_TX_POWER 74
938/* Private ioctl for earlyrx power save feature */
939#define WE_SET_EARLY_RX_ADJUST_ENABLE 75
940#define WE_SET_EARLY_RX_TGT_BMISS_NUM 76
941#define WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE 77
942#define WE_SET_EARLY_RX_SLOP_STEP 78
943#define WE_SET_EARLY_RX_INIT_SLOP 79
944#define WE_SET_EARLY_RX_ADJUST_PAUSE 80
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530945/*
946 * <ioctl>
947 * setMcRate - Set the data rate for multicast data
948 *
949 * @INPUT: 1 to 32
950 *
951 * @OUTPUT: None
952 *
953 * This IOCTL sets the data rate for multicast data. Note that this command
954 * is allowed only in STA, IBSS, or QCMobileAP mode
955 *
956 * @E.g: iwpriv wlan0 setMcRate <value>
957 *
958 * Supported Feature: STA
959 *
960 * Usage: Internal/External
961 *
962 * </ioctl>
963 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964#define WE_SET_MC_RATE 81
965#define WE_SET_EARLY_RX_DRIFT_SAMPLE 82
966/* Private ioctl for packet power save */
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530967/*
968 * <ioctl>
969 * 5g_ebt - Sets the 5g_ebt
970 *
971 * @INPUT: <value>
972 *
973 * @OUTPUT: None
974 *
975 * This IOTCL used to set 5g_ebt
976 *
977 * @E.g: iwpriv wlan0 5g_ebt <value>
978 *
979 * Supported Feature: STA
980 *
981 * Usage: Internal/External
982 *
983 * </ioctl>
984 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985#define WE_PPS_5G_EBT 83
Sen, Devendra9ca8c432017-02-23 15:10:26 +0530986/*
987 * <ioctl>
988 * cts_cbw - Set CTS channel BW for dynamic BW adjustment
989 *
990 * @INPUT: 20 t0 160
991 *
992 * @OUTPUT: None
993 *
994 * This IOTCL used to set CTS channel BW for dynamic BW adjustment
995 *
996 * @E.g: iwpriv wlan0 cts_cbw <value>
997 *
998 * Supported Feature: STA
999 *
1000 * Usage: Internal/External
1001 *
1002 * </ioctl>
1003 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004#define WE_SET_CTS_CBW 84
1005#define WE_DUMP_STATS 85
1006#define WE_CLEAR_STATS 86
Govind Singha471e5e2015-10-12 17:11:14 +05301007/* Private sub ioctl for starting/stopping the profiling */
1008#define WE_START_FW_PROFILE 87
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301009
Abhishek Singh3c507012016-12-01 11:15:42 +05301010/*
1011 * <ioctl>
1012 * setChanChange - Initiate channel change
1013 *
1014 * @INPUT: channel number to switch to.
1015 *
1016 * @OUTPUT: None
1017 *
1018 * This IOCTL is used to initiate a channel change.
1019 * If called on STA/CLI interface it will send the
1020 * ECSA action frame to the connected SAP/GO asking to
1021 * initiate the ECSA, if supported.
1022 * If called on SAP/GO interface it will initiate
1023 * ECSA and ask connected peers to move to new channel.
1024 *
1025 * @E.g: iwpriv wlan0 setChanChange <channel>
1026 * iwpriv wlan0 setChanChange 1
1027 *
1028 * Supported Feature: ECSA
1029 *
1030 * Usage: Internal/External
1031 *
1032 * </ioctl>
1033 */
Abhishek Singh1bdb1572015-10-16 16:24:19 +05301034#define WE_SET_CHANNEL 88
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05301035#define WE_SET_CONC_SYSTEM_PREF 89
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08001036#define WE_SET_TXRX_STATS 90
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08001038/*
1039 * <ioctl>
1040 * set_11ax_rate - set 11ax rates to FW
1041 *
1042 * @INPUT: rate code
1043 *
1044 * @OUTPUT: None
1045 *
1046 * This IOCTL fixes the Tx data rate of 11AX.
1047 *
1048 * @E.g: iwpriv wlan0 set_11ax_rate <rate code>
1049 *
1050 * Supported Feature: STA/SAP
1051 *
1052 * Usage: Internal
1053 *
1054 * </ioctl>
1055 */
1056#define WE_SET_11AX_RATE 91
1057
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001058/*
1059 * <ioctl>
1060 * enable_dcm - enable Dual Carrier Modulation(DCM)
1061 *
1062 * @INPUT: 0/1
1063 *
1064 * @OUTPUT: None
1065 *
1066 * This IOCTL enables/disables DCM.
1067 *
1068 * @E.g: iwpriv wlan0 enable_dcm <0/1>
1069 *
1070 * Supported Feature: STA/SAP
1071 *
1072 * Usage: Internal
1073 *
1074 * </ioctl>
1075 */
1076#define WE_SET_DCM 92
1077
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001078/*
1079 * <ioctl>
1080 * enable_range_ext - enable Range extension
1081 *
1082 * @INPUT: 0/1
1083 *
1084 * @OUTPUT: None
1085 *
1086 * This IOCTL enables/disables Range extension.
1087 *
1088 * @E.g: iwpriv wlan0 enable_range_ext <0/1>
1089 *
1090 * Supported Feature: STA/SAP
1091 *
1092 * Usage: Internal
1093 *
1094 * </ioctl>
1095 */
1096#define WE_SET_RANGE_EXT 93
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001097
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301098/*
1099 * <ioctl>
1100 * wow_ito - sets the timeout value for inactivity data while
1101 * in power save mode during wow
1102 *
1103 * @INPUT: int
1104 *
1105 * @OUTPUT: None
1106 *
1107 * This IOCTL set the timeout value for inactivity data in power save mode
1108 *
1109 * @E.g: iwpriv wlan0 wow_ito 20
1110 *
1111 * Supported Feature: STA
1112 *
1113 * Usage: External
1114 *
1115 * </ioctl>
Jeff Johnsondcf84ce2017-10-05 09:26:24 -07001116 */
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301117#define WE_SET_WOW_DATA_INACTIVITY_TO 94
1118
Jeff Johnson011c4502017-10-05 15:25:56 -07001119/*
1120 * <ioctl>
1121 * pdev_reset - reset the pdev
1122 *
1123 * @INPUT: Reset command to initiate:
1124 * TX_FLUSH = 1
1125 * WARM_RESET = 2
1126 * COLD_RESET = 3
1127 * WARM_RESET_RESTORE_CAL = 4
1128 * COLD_RESET_RESTORE_CAL = 5
1129 *
1130 * @OUTPUT: None
1131 *
1132 * This IOCTL is used to reset the pdev. The primary use is
1133 * for internal testing. It is not expected that this will
1134 * be used on a production device.
1135 *
1136 * @E.g: iwpriv wlan0 pdev_reset <command>
1137 * iwpriv wlan0 pdev_reset 1
1138 *
1139 * Supported Feature: None
1140 *
1141 * Usage: Internal
1142 *
1143 * </ioctl>
1144 */
1145#define WE_SET_PDEV_RESET 95
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05301146
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05301147/*
1148 * setModDTIM - Change Modulated DTIM
1149 *
1150 * @INPUT: set_value.
1151 *
1152 * @OUTPUT: None
1153 *
1154 * This IOCTL is used to change modulated DTIM
1155 * value without WIFI OFF/ON.
1156 *
1157 * @E.g: iwpriv wlan0 setModDTIM <value>
1158 * iwpriv wlan0 setModDTIM 2
1159 *
1160 * Supported Feature: N/A
1161 *
1162 * Usage: Internal/External
1163 *
1164 * </ioctl>
1165 */
1166#define WE_SET_MODULATED_DTIM 96
1167
1168
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169/* Private ioctls and their sub-ioctls */
1170#define WLAN_PRIV_SET_NONE_GET_INT (SIOCIWFIRSTPRIV + 1)
1171#define WE_GET_11D_STATE 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172#define WE_SET_SAP_CHANNELS 3
1173#define WE_GET_WLAN_DBG 4
1174#define WE_GET_MAX_ASSOC 6
1175/* 7 is unused */
1176#define WE_GET_SAP_AUTO_CHANNEL_SELECTION 8
Nitesh Shahc87a7a82016-12-14 11:37:55 +05301177
1178/*
1179 * <ioctl>
1180 * getconcurrency - Get concurrency mode
1181 *
1182 * @INPUT: None
1183 *
1184 * @OUTPUT: It shows concurrency value
1185 * Bit 0:STA 1:SAP 2:P2P_Client 3:P2P_GO
1186 * 4:FTM 5:IBSS 6:Monitor 7:P2P_Device
1187 * 8:OCB 9:EPPING 10:QVIT 11:NDI
1188 *
1189 * This IOCTL is used to retrieve concurrency mode.
1190 *
1191 * @E.g: iwpriv wlan0 getconcurrency
1192 * wlan0 getconcurrency:5
1193 * Above value shows STA+P2P_Client
1194 *
1195 * Supported Feature: Concurrency
1196 *
1197 * Usage: Internal/External
1198 *
1199 * </ioctl>
1200 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201#define WE_GET_CONCURRENCY_MODE 9
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301202/*
1203 * <ioctl>
1204 * get_nss - Get the number of spatial STBC streams (NSS)
1205 *
1206 * @INPUT: None
1207 *
1208 * @OUTPUT: NSS
1209 * wlan0 get_nss:2
1210 *
1211 * This IOTCL used to get the number of spatial STBC streams
1212 *
1213 * @E.g: iwpriv wlan0 get_nss
1214 *
1215 * Supported Feature: STA
1216 *
1217 * Usage: Internal/External
1218 *
1219 * </ioctl>
1220 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221#define WE_GET_NSS 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301222/*
1223 * <ioctl>
1224 * get_ldpc - This IOCTL gets the low density parity check (LDPC)
1225 *
1226 * @INPUT: None
1227 *
1228 * @OUTPUT: ldpc
1229 * wlan0 get_ldpc:1
1230 *
1231 * This IOTCL used to gets the low density parity check (LDPC)
1232 *
1233 * @E.g: iwpriv wlan0 get_ldpc
1234 *
1235 * Supported Feature: STA
1236 *
1237 * Usage: Internal/External
1238 *
1239 * </ioctl>
1240 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241#define WE_GET_LDPC 12
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301242/*
1243 * <ioctl>
1244 * get_tx_stbc - Get the value of the current Tx space time block code (STBC)
1245 *
1246 * @INPUT: None
1247 *
1248 * @OUTPUT: TXSTBC
1249 * wlan0 get_tx_stbc:1
1250 *
1251 * This IOTCL get the value of the current Tx space time block code (STBC)
1252 *
1253 * @E.g: iwpriv wlan0 get_tx_stbc
1254 *
1255 * Supported Feature: STA
1256 *
1257 * Usage: Internal/External
1258 *
1259 * </ioctl>
1260 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261#define WE_GET_TX_STBC 13
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301262/*
1263 * <ioctl>
1264 * get_rx_stbc - Gets the value of the current Rx STBC
1265 *
1266 * @INPUT: None
1267 *
1268 * @OUTPUT: Rx STBC
1269 * wlan0 get_rx_stbc:1
1270 *
1271 * This IOTCL used to get the value of the current Rx STBC
1272 *
1273 * @E.g: iwpriv wlan0 get_rx_stbc
1274 *
1275 * Supported Feature: STA
1276 *
1277 * Usage: Internal/External
1278 *
1279 * </ioctl>
1280 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281#define WE_GET_RX_STBC 14
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301282/*
1283 * <ioctl>
1284 * get_shortgi - Get the value of the current short GI setting
1285 *
1286 * @INPUT: None
1287 *
1288 * @OUTPUT: Enable/disable of shortgi
1289 * wlan0 get_shortgi:1
1290 *
1291 * This IOCTL gets the value of the current short GI setting
1292 *
1293 * @E.g: iwpriv wlan0 get_shortgi
1294 *
1295 * Supported Feature: STA
1296 *
1297 * Usage: Internal/External
1298 *
1299 * </ioctl>
1300 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301#define WE_GET_SHORT_GI 15
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301302/*
1303 * <ioctl>
1304 * get_rtscts - Get the value of the current RTS/CTS setting.
1305 *
1306 * @INPUT: None
1307 *
1308 * @OUTPUT: Enable/disable of RTS/CTS
1309 * wlan0 get_rtscts:33
1310 *
1311 * This IOTCL get the value of the current RTS/CTS setting.
1312 *
1313 * @E.g: iwpriv wlan0 get_rtscts
1314 *
1315 * Supported Feature: STA
1316 *
1317 * Usage: Internal/External
1318 *
1319 * </ioctl>
1320 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321#define WE_GET_RTSCTS 16
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301322/*
1323 * <ioctl>
1324 * get_chwidth - Get the current channel width setting
1325 *
1326 * @INPUT: None
1327 *
1328 * @OUTPUT: channel width
1329 * wlan0 get_chwidth:0
1330 *
1331 * This IOTCL get the current channel width setting.
1332 *
1333 * @E.g: iwpriv wlan0 get_chwidth
1334 *
1335 * Supported Feature: STA
1336 *
1337 * Usage: Internal/External
1338 *
1339 * </ioctl>
1340 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341#define WE_GET_CHWIDTH 17
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301342/*
1343 * <ioctl>
1344 * get_anienable - Get the anienable
1345 *
1346 * @INPUT: None
1347 *
1348 * @OUTPUT:
1349 * wlan0 get_anienable:0
1350 *
1351 * This IOTCL get the anienable
1352 *
1353 * @E.g: iwpriv wlan0 get_anienable
1354 *
1355 * Supported Feature: STA
1356 *
1357 * Usage: Internal/External
1358 *
1359 * </ioctl>
1360 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361#define WE_GET_ANI_EN_DIS 18
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301362/*
1363 * <ioctl>
1364 * get_aniplen - Get the aniplen
1365 *
1366 * @INPUT: None
1367 *
1368 * @OUTPUT:
1369 * wlan0 get_aniplen:0
1370 *
1371 * This IOTCL get the aniplen
1372 *
1373 * @E.g: iwpriv wlan0 get_aniplen
1374 *
1375 * Supported Feature: STA
1376 *
1377 * Usage: Internal/External
1378 *
1379 * </ioctl>
1380 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381#define WE_GET_ANI_POLL_PERIOD 19
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301382/*
1383 * <ioctl>
1384 * get_anilislen- Get the anilislen
1385 *
1386 * @INPUT: None
1387 *
1388 * @OUTPUT:
1389 * wlan0 get_anilislen:0
1390 *
1391 * This IOTCL used to get anilislen
1392 *
1393 * @E.g: iwpriv wlan0 get_anilislen
1394 *
1395 * Supported Feature: STA
1396 *
1397 * Usage: Internal/External
1398 *
1399 * </ioctl>
1400 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401#define WE_GET_ANI_LISTEN_PERIOD 20
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301402/*
1403 * <ioctl>
1404 * get_aniofdmlvl - Get the OFDM level
1405 *
1406 * @INPUT: None
1407 *
1408 * @OUTPUT: OFDM
1409 * wlan0 get_aniofdmlvl:0
1410 *
1411 * This IOTCL used to get ofdm level
1412 *
1413 * @E.g: iwpriv wlan0 get_aniofdmlvl
1414 *
1415 * Supported Feature: STA
1416 *
1417 * Usage: Internal/External
1418 *
1419 * </ioctl>
1420 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421#define WE_GET_ANI_OFDM_LEVEL 21
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301422/*
1423 * <ioctl>
1424 * get_aniccklvl - Get the cck level
1425 *
1426 * @INPUT: None
1427 *
1428 * @OUTPUT:
1429 * wlan0 get_aniccklvl:0
1430 *
1431 * This IOTCL used to get cck level
1432 *
1433 * @E.g: iwpriv wlan0 get_aniccklvl
1434 *
1435 * Supported Feature: STA
1436 *
1437 * Usage: Internal/External
1438 *
1439 * </ioctl>
1440 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441#define WE_GET_ANI_CCK_LEVEL 22
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301442/*
1443 * <ioctl>
1444 * get_cwmenable - Get the value of the dynamic channel bandwidth setting
1445 *
1446 * @INPUT: None
1447 *
1448 * @OUTPUT: Enable/disable dynamic channel bandwidth
1449 * wlan0 get_cwmenable:0
1450 *
1451 * This IOTCL get the value of the dynamic channel bandwidth setting
1452 *
1453 * @E.g: iwpriv wlan0 get_cwmenable
1454 *
1455 * Supported Feature: STA
1456 *
1457 * Usage: Internal/External
1458 *
1459 * </ioctl>
1460 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461#define WE_GET_DYNAMIC_BW 23
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301462/*
1463 * <ioctl>
1464 * get_txchainmask - Get the txchainmask that was set
1465 *
1466 * @INPUT: None
1467 *
1468 * @OUTPUT: txchainmask
1469 * wlan0 get_txchainmask:1
1470 *
1471 * This IOCTL gets the txchainmask that was set
1472 * This command is useful if it was previously set
1473 *
1474 * @E.g: iwpriv wlan0 get_txchainmask
1475 *
1476 * Supported Feature: STA
1477 *
1478 * Usage: Internal/External
1479 *
1480 * </ioctl>
1481 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482#define WE_GET_TX_CHAINMASK 24
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301483/*
1484 * <ioctl>
1485 * get_rxchainmask - Get the rxchainmask that was set
1486 *
1487 * @INPUT: None
1488 *
1489 * @OUTPUT: rxchainmask
1490 * wlan0 get_rxchainmask:1
1491 *
1492 * This IOCTL gets the rxchainmask that was set
1493 * This command is useful only if it was previously set.
1494 *
1495 * @E.g: iwpriv wlan0 get_rxchainmask
1496 *
1497 * Supported Feature: STA
1498 *
1499 * Usage: Internal/External
1500 *
1501 * </ioctl>
1502 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503#define WE_GET_RX_CHAINMASK 25
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301504/*
1505 * <ioctl>
1506 * get_11nrate - Get the fixed Tx data rate
1507 *
1508 * @INPUT: None
1509 *
1510 * @OUTPUT: Using this command does not return the same value as set
1511 * wlan0 get_11nrate:0
1512 *
1513 * This IOCTL gets the fixed Tx data rate
1514 * This command is useful only if setting the fixed Tx rate.
1515 *
1516 * @E.g: iwpriv wlan0 get_11nrate
1517 *
1518 * Supported Feature: STA
1519 *
1520 * Usage: Internal/External
1521 *
1522 * </ioctl>
1523 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524#define WE_GET_11N_RATE 26
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301525/*
1526 * <ioctl>
1527 * get_ampdu - Get the maximum subframe of ampdu
1528 *
1529 * @INPUT: None
1530 *
1531 * @OUTPUT: Maximum subframe of ampdu
1532 * wlan0 get_ampdu:1
1533 *
1534 * This IOCTL gets the maximum subframe of ampdu
1535 * This command is useful only if setting ampdu.
1536 *
1537 * @E.g: iwpriv wlan0 get_ampdu
1538 *
1539 * Supported Feature: STA
1540 *
1541 * Usage: Internal/External
1542 *
1543 * </ioctl>
1544 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545#define WE_GET_AMPDU 27
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301546/*
1547 * <ioctl>
1548 * get_amsdu - Get the maximum subframe of amsdu
1549 *
1550 * @INPUT: None
1551 *
1552 * @OUTPUT: Maximum subframe of amsdu
1553 * wlan0 get_amsdu:1
1554 *
1555 * This IOCTL gets the maximum subframe of amsdu.
1556 * This command is useful only if setting amsdu
1557 *
1558 * @E.g: iwpriv wlan0 get_amsdu
1559 *
1560 * Supported Feature: STA
1561 *
1562 * Usage: Internal/External
1563 *
1564 * </ioctl>
1565 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566#define WE_GET_AMSDU 28
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301567/*
1568 * <ioctl>
1569 * get_txpow2g - Get the current 2 GHz Tx power setting
1570 *
1571 * @INPUT: None
1572 *
1573 * @OUTPUT: Tx Power in dbm
1574 * wlan0 get_txpow2g:0
1575 *
1576 * This IOCTL gets the current 2 GHz Tx power setting
1577 * This command is useful if setting Tx power
1578 *
1579 * @E.g: iwpriv wlan0 get_txpow2g
1580 *
1581 * Supported Feature: STA
1582 *
1583 * Usage: Internal/External
1584 *
1585 * </ioctl>
1586 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587#define WE_GET_TXPOW_2G 29
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301588/*
1589 * <ioctl>
1590 * get_txpow5g - Get the current 5 GHz Tx power setting
1591 *
1592 * @INPUT: None
1593 *
1594 * @OUTPUT: Tx Power in dbm
1595 * wlan0 get_txpow5g:0
1596 *
1597 * This IOCTL gets the current 5 GHz Tx power setting
1598 * This command is useful if setting Tx power
1599 *
1600 * @E.g: iwpriv wlan0 get_txpow5g
1601 *
1602 * Supported Feature: STA
1603 *
1604 * Usage: Internal/External
1605 *
1606 * </ioctl>
1607 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608#define WE_GET_TXPOW_5G 30
Rajeev Kumar1bcfd632015-12-07 11:38:51 -08001609/* 31 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610#define WE_GET_PPS_PAID_MATCH 32
1611#define WE_GET_PPS_GID_MATCH 33
1612#define WE_GET_PPS_EARLY_TIM_CLEAR 34
1613#define WE_GET_PPS_EARLY_DTIM_CLEAR 35
1614#define WE_GET_PPS_EOF_PAD_DELIM 36
1615#define WE_GET_PPS_MACADDR_MISMATCH 37
1616#define WE_GET_PPS_DELIM_CRC_FAIL 38
1617#define WE_GET_PPS_GID_NSTS_ZERO 39
1618#define WE_GET_PPS_RSSI_CHECK 40
1619/* Private ioctl for QPower */
1620#define WE_GET_QPOWER_MAX_PSPOLL_COUNT 41
1621#define WE_GET_QPOWER_MAX_TX_BEFORE_WAKE 42
1622#define WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL 43
1623#define WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL 44
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301624/*
1625 * <ioctl>
1626 * get_burst_en - Enables or disables the burst feature
1627 *
1628 * @INPUT: None
1629 *
1630 * @OUTPUT: Enable/disable of burst feature
1631 * wlan0 get_burst_en:1
1632 *
1633 * This IOCTL enables or disables the burst feature
1634 *
1635 * @E.g: iwpriv wlan0 get_burst_en
1636 *
1637 * Supported Feature:STA
1638 *
1639 * Usage: Internal/External
1640 *
1641 * </ioctl>
1642 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643#define WE_GET_BURST_ENABLE 45
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301644/*
1645 * <ioctl>
1646 * get_burst_dur - Get the burst duration
1647 *
1648 * @INPUT: None
1649 *
1650 * @OUTPUT: Duration in microseconds
1651 * wlan0 get_burst_dur:8160
1652 *
1653 * This IOCTL gets the burst duration
1654 * This command is useful if setting burst enable
1655 *
1656 * @E.g: iwpriv wlan0 get_burst_dur
1657 *
1658 * Supported Feature: STA
1659 *
1660 * Usage: Internal/External
1661 *
1662 * </ioctl>
1663 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664#define WE_GET_BURST_DUR 46
1665/* GTX Commands */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301666/*
1667 * <ioctl>
1668 * get_gtxHTMcs - Get the tx HTM
1669 *
1670 * @INPUT: None
1671 *
1672 * @OUTPUT: HTM
1673 * wlan0 get_gtxHTMcs:32896
1674 *
1675 * This IOTCL used to get HTM
1676 *
1677 * @E.g: iwpriv wlan0 get_gtxHTMcs
1678 *
1679 * Supported Feature: STA
1680 *
1681 * Usage: Internal/External
1682 *
1683 * </ioctl>
1684 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685#define WE_GET_GTX_HT_MCS 47
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301686/*
1687 * <ioctl>
1688 * get_gtxVHTMcs - Get the VHTM
1689 *
1690 * @INPUT: None
1691 *
1692 * @OUTPUT: VHTM
1693 * wlan0 get_gtxVHTMcs:524800
1694 *
1695 * This IOTCL used to get the VHTM
1696 *
1697 * @E.g: iwpriv wlan0 get_gtxVHTMcs
1698 *
1699 * Supported Feature: STA
1700 *
1701 * Usage: Internal/External
1702 *
1703 * </ioctl>
1704 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705#define WE_GET_GTX_VHT_MCS 48
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301706/*
1707 * <ioctl>
1708 * get_gtxUsrCfg - Get the tx cfg
1709 *
1710 * @INPUT: None
1711 *
1712 * @OUTPUT: TXCFG
1713 * wlan0 get_gtxUsrCfg:32
1714 *
1715 * This IOTCL used to get the tx cfg
1716 *
1717 * @E.g: iwpriv wlan0 get_gtxUsrCfg
1718 *
1719 * Supported Feature: STA
1720 *
1721 * Usage: Internal/External
1722 *
1723 * </ioctl>
1724 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725#define WE_GET_GTX_USRCFG 49
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301726/*
1727 * <ioctl>
1728 * get_gtxThre - Get the tx threshold
1729 *
1730 * @INPUT: None
1731 *
1732 * @OUTPUT: Threshold
1733 * wlan0 get_gtxThre:3
1734 *
1735 * This IOCTL is used to get tx threshold
1736 *
1737 * @E.g: iwpriv wlan0 get_gtxThre
1738 *
1739 * Supported Feature: STA
1740 *
1741 * Usage: Internal/External
1742 *
1743 * </ioctl>
1744 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745#define WE_GET_GTX_THRE 50
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301746/*
1747 * <ioctl>
1748 * get_gtxMargin - Get the tx margin
1749 *
1750 * @INPUT: None
1751 *
1752 * @OUTPUT: GTXMARGIN
1753 * wlan0 get_gtxMargin:2
1754 *
1755 * This IOCTL is used to set tx margin
1756 *
1757 * @E.g: iwpriv wlan0 get_gtxMargin
1758 *
1759 * Supported Feature: STA
1760 *
1761 * Usage: Internal/External
1762 *
1763 * </ioctl>
1764 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765#define WE_GET_GTX_MARGIN 51
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301766/*
1767 * <ioctl>
1768 * get_gtxStep - Get the tx step
1769 *
1770 * @INPUT: None
1771 *
1772 * @OUTPUT: GTXSTEP
1773 * wlan0 get_gtxStep:0
1774 *
1775 * This IOCTL is used to get the gtx step
1776 *
1777 * @E.g: iwpriv wlan0 get_gtxStep
1778 *
1779 * Supported Feature: STA
1780 *
1781 * Usage: Internal/External
1782 *
1783 * </ioctl>
1784 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785#define WE_GET_GTX_STEP 52
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301786/*
1787 * <ioctl>
1788 * get_gtxMinTpc - Get the tx miminum tpc
1789 *
1790 * @INPUT: None
1791 *
1792 * @OUTPUT: TPC
1793 * wlan0 get_gtxMinTpc:0
1794 *
1795 * This IOCTL is used to get tx miminum tpc
1796 *
1797 * @E.g: iwpriv wlan0 get_gtxMinTpc
1798 *
1799 * Supported Feature: STA
1800 *
1801 * Usage: Internal/External
1802 *
1803 * </ioctl>
1804 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805#define WE_GET_GTX_MINTPC 53
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301806/*
1807 * <ioctl>
1808 * get_gtxBWMask - Get the tx BW MASK
1809 *
1810 * @INPUT: None
1811 *
1812 * @OUTPUT: MASK
1813 * wlan0 get_gtxBWMask:15
1814 *
1815 * This IOCTL is used get gtx bw mask
1816 *
1817 * @E.g: iwpriv wlan0 get_gtxBWMask
1818 *
1819 * Supported Feature: STA
1820 *
1821 * Usage: Internal/External
1822 *
1823 * </ioctl>
1824 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825#define WE_GET_GTX_BWMASK 54
1826#define WE_GET_TEMPERATURE 56
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07001827#define WE_CAP_TSF 58
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07001828#define WE_GET_ROAM_SYNCH_DELAY 59
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07001830/*
1831 * <ioctl>
1832 * get_dcm - Get dcm enablement value
1833 *
1834 * @INPUT: None
1835 *
1836 * @OUTPUT: 0/1
1837 * wlan0 get_dcm
1838 *
1839 * This IOCTL is used get dcm value
1840 *
1841 * Supported Feature: STA/SAP
1842 *
1843 * Usage: Internal
1844 *
1845 * </ioctl>
1846 */
1847#define WE_GET_DCM 60
1848
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07001849/*
1850 * <ioctl>
1851 * get_dcm - Get range extension enablement value
1852 *
1853 * @INPUT: None
1854 *
1855 * @OUTPUT: 0/1
1856 * wlan0 get_range_ext
1857 *
1858 * This IOCTL is used get range_extension value
1859 *
1860 * Supported Feature: STA/SAP
1861 *
1862 * Usage: Internal
1863 *
1864 * </ioctl>
1865 */
1866#define WE_GET_RANGE_EXT 61
1867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868/* Private ioctls and their sub-ioctls */
1869#define WLAN_PRIV_SET_INT_GET_INT (SIOCIWFIRSTPRIV + 2)
1870
1871/* Private ioctls and their sub-ioctls */
1872#define WLAN_PRIV_SET_CHAR_GET_NONE (SIOCIWFIRSTPRIV + 3)
1873#define WE_WOWL_ADD_PTRN 1
1874#define WE_WOWL_DEL_PTRN 2
Sreelakshmi Konamkided64d72017-02-23 10:39:26 +05301875/*
1876 * <ioctl>
1877 * neighbor - Send neighbor report request
1878 *
1879 * @INPUT: string
1880 *
1881 * @OUTPUT: None
1882 *
1883 * This IOCTL create a Neighbor report request and send it to peer
1884 *
1885 * @E.g: iwpriv wlan0 neighbor "SSID"
1886 *
1887 * Supported Feature: 11k
1888 *
1889 * Usage: Internal/External
1890 *
1891 * </ioctl>
1892 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893#define WE_NEIGHBOR_REPORT_REQUEST 3
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301894/*
1895 * <ioctl>
1896 * set_ap_wps_ie - Set the P2P IE of the probe response
1897 *
1898 * @INPUT: string
1899 *
1900 * @OUTPUT: None
1901 *
1902 * This IOCTL sets the P2P IE of the probe response
1903 *
1904 * @E.g: iwpriv wlan0 set_ap_wps_ie abcd
1905 *
1906 * Supported Feature: STA
1907 *
1908 * Usage: Internal/External
1909 *
1910 * </ioctl>
1911 */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07001912#define WE_SET_AP_WPS_IE 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913#define WE_SET_CONFIG 5
1914
1915/* Private ioctls and their sub-ioctls */
1916#define WLAN_PRIV_SET_THREE_INT_GET_NONE (SIOCIWFIRSTPRIV + 4)
1917#define WE_SET_WLAN_DBG 1
1918#define WE_SET_DP_TRACE 2
1919#define WE_SET_SAP_CHANNELS 3
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05301920#define WE_SET_FW_TEST 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921
1922/* Private ioctls and their sub-ioctls */
1923#define WLAN_PRIV_GET_CHAR_SET_NONE (SIOCIWFIRSTPRIV + 5)
1924#define WE_WLAN_VERSION 1
1925#define WE_GET_STATS 2
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301926/*
1927 * <ioctl>
1928 * getConfig - gets the values of all configurations listed in WCNSS
1929 *
1930 * @INPUT: None
1931 *
1932 * @OUTPUT: Current configuration to the sys log
1933 * wlan0 getConfig: WLAN configuration written to system log
1934 *
1935 * This IOCTL gets the values of all configurations listed in WCNSS
1936 *
1937 * @E.g: iwpriv wlan0 getConfig
1938 *
1939 * Supported Feature: STA
1940 *
1941 * Usage: Internal/External
1942 *
1943 * </ioctl>
1944 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945#define WE_GET_CFG 3
1946#define WE_GET_WMM_STATUS 4
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301947/*
1948 * <ioctl>
1949 * getChannelList - Get the available channel list while in QCMobileAP
1950 *
1951 * @INPUT: None
1952 *
1953 * @OUTPUT: Channel list
1954 * wlan0 getChannelList:36 US 1..165
1955 *
1956 * This IOCTL gets the available channel list while in QCMobileAP
1957 *
1958 * @E.g: iwpriv wlan0 getChannelList
1959 *
1960 * Supported Feature: STA
1961 *
1962 * Usage: Internal/External
1963 *
1964 * </ioctl>
1965 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966#define WE_GET_CHANNEL_LIST 5
Sen, Devendra9ca8c432017-02-23 15:10:26 +05301967/*
1968 * <ioctl>
1969 * getRSSI - Get the Received Signal Strength Indicator
1970 *
1971 * @INPUT: None
1972 *
1973 * @OUTPUT: RSSI
1974 * wlan0 getRSSI:rsssi=-32
1975 *
1976 * This IOCTL gets the Received Signal Strength Indicator (RSSI)
1977 *
1978 * @E.g: iwpriv wlan0 getRSSI
1979 *
1980 * Supported Feature: STA
1981 *
1982 * Usage: Internal/External
1983 *
1984 * </ioctl>
1985 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986#define WE_GET_RSSI 6
Dustin Brownd9322482017-01-09 12:46:03 -08001987
1988/*
1989 * <ioctl>
1990 * getSuspendStats - Get suspend/resume stats
1991 *
1992 * @INPUT: None
1993 *
1994 * @OUTPUT: character string containing formatted suspend/resume stats
1995 *
1996 * This ioctl is used to get suspend/resume stats formatted for display.
1997 * Currently it includes suspend/resume counts, wow wake up reasons, and
1998 * suspend fail reasons.
1999 *
2000 * @E.g: iwpriv wlan0 getSuspendStats
2001 * iwpriv wlan0 getSuspendStats
2002 *
2003 * Supported Feature: suspend/resume
2004 *
2005 * Usage: Internal
2006 *
2007 * </ioctl>
2008 */
2009#define WE_GET_SUSPEND_RESUME_STATS 7
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302011/*
2012 * <ioctl>
2013 * getTdlsPeers - Get all TDLS peers.
2014 *
2015 * @INPUT: None
2016 *
2017 * @OUTPUT: Returns the MAC address of all the TDLS peers
2018 * wlan0 getTdlsPeers:
2019 * MAC Id cap up RSSI
2020 * ---------------------------------
2021 * 00:0a:f5:0e:bd:18 2 Y Y -44
2022 * 00:0a:f5:bf:0e:12 0 N N 0
2023 *
2024 * This IOCTL is used to get all TDLS peers.
2025 *
2026 * @E.g: iwpriv wlan0 getTdlsPeers
2027 *
2028 * Supported Feature: TDLS
2029 *
2030 * Usage: Internal/External
2031 *
2032 * </ioctl>
2033 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034#define WE_GET_TDLS_PEERS 8
2035#endif
2036#ifdef WLAN_FEATURE_11W
Abhishek Singh2f810492016-12-01 11:39:39 +05302037/*
2038 * <ioctl>
2039 * getPMFInfo - get the PMF info of the connected session
2040 *
2041 * @INPUT: None
2042 *
2043 * @OUTPUT:
2044 * wlan0 getPMFInfo:
2045 * BSSID E4:F4:C6:0A:E0:36, Is PMF Assoc? 0
2046 * Number of Unprotected Disassocs 0
2047 * Number of Unprotected Deauths 0
2048 *
2049 * This IOCTL is used to get the PMF stats/status of the current
2050 * connection.
2051 *
2052 * @e.g:iwpriv wlan0 getPMFInfo
2053 *
2054 * Supported Feature: PMF
2055 *
2056 * Usage: Internal/External
2057 *
2058 * </ioctl>
2059 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060#define WE_GET_11W_INFO 9
2061#endif
2062#define WE_GET_STATES 10
Abhishek Singh49b654e2016-12-01 16:11:17 +05302063/*
2064 * <ioctl>
2065 * getIbssSTAs - get ibss sta info
2066 *
2067 * @INPUT: None
2068 *
2069 * @OUTPUT: Give the MAC of the IBSS STA
2070 * wlan0 getIbssSTAs:
2071 * 1 .8c:fd:f0:01:9c:bf
2072 *
2073 * This IOCTL is used to get ibss sta info
2074 *
2075 * @E.g: iwpriv wlan0 getIbssSTAs
2076 *
2077 * Supported Feature: IBSS
2078 *
2079 * Usage: Internal/External
2080 *
2081 * </ioctl>
2082 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002083#define WE_GET_IBSS_STA_INFO 11
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302084/*
2085 * <ioctl>
2086 * getphymode - Get the current phymode.
2087 *
2088 * @INPUT: None
2089 *
2090 * @OUTPUT: In phymode
2091 * wlan0 getphymode:AUTO MODE
2092 *
2093 * This IOCTL used to gets the current phymode.
2094 *
2095 * @E.g: iwpriv wlan0 getphymode
2096 *
2097 * Supported Feature: STA
2098 *
2099 * Usage: Internal/External
2100 *
2101 * </ioctl>
2102 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103#define WE_GET_PHYMODE 12
Naveen Rawat910726a2017-03-06 11:42:51 -08002104
2105/*
2106 * <ioctl>
2107 * getOemDataCap - Get the oem data caps.
2108 *
2109 * @INPUT: None
2110 *
2111 * @OUTPUT: oem data capability
2112 *
2113 * This IOCTL used to gets the current oem data cap.
2114 *
2115 * @E.g: iwpriv wlan0 getOemDataCap
2116 *
2117 * Usage: Internal/External
2118 *
2119 * </ioctl>
2120 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121#define WE_GET_OEM_DATA_CAP 13
Naveen Rawat910726a2017-03-06 11:42:51 -08002122
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302123/*
2124 * <ioctl>
2125 * getSNR - Enable SNR Monitoring
2126 *
2127 * @INPUT: None
2128 *
2129 * @OUTPUT: Signal strength/ratio
2130 * wlan0 getSNR:1
2131 *
2132 * This IOCTL is used to get ibss sta info
2133 *
2134 * @E.g: iwpriv wlan0 getSNR
2135 *
2136 * Supported Feature: STA
2137 *
2138 * Usage: Internal/External
2139 *
2140 * </ioctl>
2141 */
Naveen Rawat910726a2017-03-06 11:42:51 -08002142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143#define WE_GET_SNR 14
Govind Singha471e5e2015-10-12 17:11:14 +05302144#define WE_LIST_FW_PROFILE 15
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145
2146/* Private ioctls and their sub-ioctls */
2147#define WLAN_PRIV_SET_NONE_GET_NONE (SIOCIWFIRSTPRIV + 6)
Selvaraj, Sridharf7939832017-03-25 16:59:50 +05302148
2149/*
2150 * <ioctl>
2151 * reassoc - Trigger STA re-association to the connected AP
2152 *
2153 * @INPUT: None
2154 *
2155 * @OUTPUT: None
2156 *
2157 * This IOCTL is used to trigger STA reassociation to the connected AP.
2158 *
2159 * @E.g: iwpriv wlan0 reassoc
2160 *
2161 * Supported Feature: Roaming
2162 *
2163 * Usage: Internal
2164 *
2165 * </ioctl>
2166 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167#define WE_SET_REASSOC_TRIGGER 8
Abhishek Singh49b654e2016-12-01 16:11:17 +05302168/*
2169 * <ioctl>
2170 * ibssPeerInfoAll - Print the ibss peers's MAC, rate and RSSI
2171 *
2172 * @INPUT: None
2173 *
2174 * @OUTPUT: print ibss peer in info logs
2175 * pPeerInfo->numIBSSPeers = 1
2176 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2177 *
2178 * This IOCTL is used to rint the ibss peers's MAC, rate and RSSI
2179 * in info logs
2180 *
2181 * @E.g: iwpriv wlan0 ibssPeerInfoAll
2182 *
2183 * Supported Feature: IBSS
2184 *
2185 * Usage: Internal/External
2186 *
2187 * </ioctl>
2188 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002189#define WE_IBSS_GET_PEER_INFO_ALL 10
Rajeev Kumarf4390fa2016-12-22 13:17:33 -08002190/* Sub ioctls 11 to 16 are not used */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002191#define WE_GET_RECOVERY_STAT 17
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002192#define WE_GET_FW_PROFILE_DATA 18
yeshwanth sriram guntukabdfe4352017-02-16 14:44:31 +05302193/*
2194 * <ioctl>
2195 * stop_obss_scan - Stop obss scan
2196 *
2197 * @INPUT: None
2198 *
2199 * @OUTPUT: None
2200 *
2201 * This IOCTL is used to stop obss scan
2202 *
2203 * @E.g: iwpriv wlan0 stop_obss_scan
2204 *
2205 * Supported Feature: Scan
2206 *
2207 * Usage: Internal/External
2208 *
2209 * </ioctl>
2210 */
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -08002211#define WE_STOP_OBSS_SCAN 19
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212
2213/* Private ioctls and their sub-ioctls */
2214#define WLAN_PRIV_SET_VAR_INT_GET_NONE (SIOCIWFIRSTPRIV + 7)
2215
2216#define WE_P2P_NOA_CMD 2
Manjeet Singhf82ed072016-07-08 11:40:00 +05302217/* subcommands 3 is unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218
Manjeet Singhf82ed072016-07-08 11:40:00 +05302219#define WE_MAC_PWR_DEBUG_CMD 4
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220
2221#ifdef FEATURE_WLAN_TDLS
Nitesh Shah5dfb99e2016-12-10 14:19:46 +05302222/*
2223 * <ioctl>
2224 * setTdlsConfig - Set TDLS configuration parameters.
2225 *
2226 * @INPUT: 11 TDLS configuration parameters
2227 * @args[0]: tdls: [0..2]
2228 * @args[1]: tx_period_t: [1000..4294967295UL]
2229 * @args[2]: tx_packet_n: [0..4294967295UL]
2230 * @args[3]: [discovery_period is not used anymore]
2231 * @args[4]: discovery_tries_n: [1..100]
2232 * @args[5]: [idle_timeout is not used anymore]
2233 * @args[6]: idle_packet_n: [0..40000]
2234 * @args[7]: [rssi_hysteresis is not used anymore]
2235 * @args[8]: rssi_trigger_threshold: [-120..0]
2236 * @args[9]: rssi_teardown_threshold: [-120..0]
2237 * @args[10]: rssi_delta: [-30..0]
2238 *
2239 * @OUTPUT: None
2240 *
2241 * This IOCTL is used to set the TDLS configuration parameters.
2242 *
2243 * @E.g: iwpriv wlan0 setTdlsConfig tdls tx_period_t tx_packet_n
2244 * discovery_period discovery_tries_n idle_timeout
2245 * idle_packet_n rssi_hysteresis rssi_trigger_threshold
2246 * rssi_teardown_threshold rssi_delta
2247 * iwpriv wlan0 setTdlsConfig 1 1500 40 1 5 1 5 0 -70 -70 -10
2248 *
2249 * Supported Feature: TDLS
2250 *
2251 * Usage: Internal/External
2252 *
2253 * </ioctl>
2254 */
2255
2256
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257#define WE_TDLS_CONFIG_PARAMS 5
2258#endif
Abhishek Singh49b654e2016-12-01 16:11:17 +05302259/*
2260 * <ioctl>
2261 * ibssPeerInfo - Print the ibss peers's MAC, rate and RSSI
2262 *
2263 * @INPUT: staid
2264 *
2265 * @OUTPUT: print ibss peer corresponding to staid in info logs
2266 * PEER ADDR : 8c:fd:f0:01:9c:bf TxRate: 1 Mbps RSSI: -35
2267 *
2268 * This IOCTL is used to print the specific ibss peers's MAC,
2269 * rate and RSSI in info logs
2270 *
2271 * @E.g: iwpriv wlan0 ibssPeerInfo <sta_id>
2272 * iwpriv wlan0 ibssPeerInfo 0
2273 *
2274 * Supported Feature: IBSS
2275 *
2276 * Usage: Internal/External
2277 *
2278 * </ioctl>
2279 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002280#define WE_IBSS_GET_PEER_INFO 6
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281#define WE_UNIT_TEST_CMD 7
2282
2283#define WE_MTRACE_DUMP_CMD 8
2284#define WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD 9
2285
2286
2287#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
2288#define WE_LED_FLASHING_PARAM 10
2289#endif
2290
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302291/*
2292 * <ioctl>
2293 * pm_clist - Increments the index value of the concurrent connection list
2294 * and update with the input parameters provided.
2295 *
2296 * @INPUT: Following 8 arguments:
2297 * @vdev_id: vdev id
2298 * @tx_streams: TX streams
2299 * @rx_streams: RX streams
2300 * @chain_mask: Chain mask
2301 * @type: vdev_type
2302 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2303 * @sub_type: vdev_subtype
2304 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2305 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2306 * @channel: Channel
2307 * @mac: Mac id
2308 *
2309 * @OUTPUT: None
2310 *
2311 * This IOCTL is used to increments the index value of the concurrent connection
2312 * list and update with the input parameters provided.
2313 *
2314 * @E.g: iwpriv wlan0 pm_clist vdev_id tx_streams rx_streams chain_mask type
2315 * sub_type channel mac
2316 * iwpriv wlan0 pm_clist 1 2 2 1 2 3 10 1
2317 *
2318 * Supported Feature: DBS
2319 *
2320 * Usage: Internal/External
2321 *
2322 * </ioctl>
2323 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324#define WE_POLICY_MANAGER_CLIST_CMD 11
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302325
2326/*
2327 * <ioctl>
2328 * pm_dlist - Delete the index from the concurrent connection list that is
2329 * present in the given vdev_id.
2330 *
2331 * @INPUT: delete_all, vdev_id
2332 * @delete_all: delete all indices
2333 * @vdev_id: vdev id
2334 *
2335 * @OUTPUT: None
2336 *
2337 * This IOCTL is used to delete the index from the concurrent connection list
2338 * that is present in the given vdev_id.
2339 *
2340 * @E.g: iwpriv wlan0 pm_dlist delete_all vdev_id
2341 * iwpriv wlan0 pm_dlist 0 1
2342 *
2343 * Supported Feature: DBS
2344 *
2345 * Usage: Internal/External
2346 *
2347 * </ioctl>
2348 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002349#define WE_POLICY_MANAGER_DLIST_CMD 12
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302350
2351/*
2352 * <ioctl>
2353 * pm_dbs - Set dbs capability and system preference
2354 *
2355 * @INPUT: dbs, system_pref
2356 * @dbs: Value of DBS capability to be set
2357 * @system_pref: System preference
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002358 * 0:PM_THROUGHPUT 1: PM_POWERSAVE 2: PM_LATENCY
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302359 *
2360 * @OUTPUT: None
2361 *
2362 * This IOCTL is used to set dbs capability and system preference.
2363 *
2364 * @E.g: iwpriv wlan0 pm_dbs dbs system_pref
2365 * iwpriv wlan0 pm_dbs 1 0
2366 *
2367 * Supported Feature: DBS
2368 *
2369 * Usage: Internal/External
2370 *
2371 * </ioctl>
2372 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373#define WE_POLICY_MANAGER_DBS_CMD 13
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302374
2375/*
2376 * <ioctl>
2377 * pm_pcl - Set pcl for concurrency mode.
2378 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002379 * @INPUT: policy_mgr_con_mode
2380 * @policy_mgr_con_mode: concurrency mode for PCL table
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302381 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2382 *
2383 * @OUTPUT: None
2384 *
2385 * This IOCTL is used to set pcl for concurrency mode.
2386 *
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08002387 * @E.g: iwpriv wlan0 pm_pcl policy_mgr_con_mode
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302388 * iwpriv wlan0 pm_pcl 0
2389 *
2390 * Supported Feature: DBS
2391 *
2392 * Usage: Internal/External
2393 *
2394 * </ioctl>
2395 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396#define WE_POLICY_MANAGER_PCL_CMD 14
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302397
2398/*
2399 * <ioctl>
2400 * pm_cinfo - Shows the concurrent connection list.
2401 *
2402 * @INPUT: None
2403 *
2404 * @OUTPUT: None
2405 *
2406 * This IOCTL is used to show the concurrent connection list.
2407 *
2408 * @E.g: iwpriv wlan0 pm_cinfo
2409 *
2410 * Supported Feature: DBS
2411 *
2412 * Usage: Internal/External
2413 *
2414 * </ioctl>
2415 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416#define WE_POLICY_MANAGER_CINFO_CMD 15
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302417
2418/*
2419 * <ioctl>
2420 * pm_ulist - Updates the index value of the concurrent connection list
2421 * with the input parameters provided.
2422 *
2423 * @INPUT: Following 8 arguments:
2424 * @vdev_id: vdev id
2425 * @tx_streams: TX streams
2426 * @rx_streams: RX streams
2427 * @chain_mask: Chain mask
2428 * @type: vdev_type
2429 * AP:1 STA:2 IBSS:3 Monitor:4 NAN:5 OCB:6 NDI:7
2430 * @sub_type: vdev_subtype
2431 * P2P_Device:1 P2P_Client:2 P2P_GO:3
2432 * Proxy_STA:4 Mesh:5 Mesh_11s:6
2433 * @channel: Channel
2434 * @mac: Mac id
2435 *
2436 * @OUTPUT: None
2437 *
2438 * This IOCTL is used to updates the index value of the concurrent
2439 * connection list with the input parameters provided.
2440 *
2441 * @E.g: iwpriv wlan0 pm_ulist vdev_id tx_streams rx_streams chain_mask type
2442 * sub_type channel mac
2443 * iwpriv wlan0 pm_ulist 1 2 2 1 2 3 10 1
2444 *
2445 * Supported Feature: DBS
2446 *
2447 * Usage: Internal/External
2448 *
2449 * </ioctl>
2450 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451#define WE_POLICY_MANAGER_ULIST_CMD 16
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302452
2453/*
2454 * <ioctl>
2455 * pm_query_action - Initiate actions needed on current connections as
2456 * per the channel provided.
2457 *
2458 * @INPUT: channel
2459 * @channel: Channel on which new connection will be.
2460 *
2461 * @OUTPUT: None
2462 *
2463 * This IOCTL is used to initiate actions needed on current connections
2464 * as per the channel provided.
2465 *
2466 * @E.g: iwpriv wlan0 pm_query_action channel
2467 * iwpriv wlan0 pm_query_action 6
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_QUERY_ACTION_CMD 17
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302476
2477/*
2478 * <ioctl>
2479 * pm_query_allow - Checks for allowed concurrency combination
2480 *
2481 * @INPUT: mode, channel, bandwidth
2482 * @mode: new connection mode
2483 * 0:STA 1:SAP 2:P2P_Client 3:P2P_GO 4:IBSS
2484 * @channel: channel on which new connection is coming up
2485 * @bandwidth: Bandwidth requested by the connection
2486 * 0:None 1:5MHz 2:10MHz 3:20MHz
2487 * 4:40MHz 5:80MHz 6:80+80MHz 7:160MHz
2488 *
2489 * @OUTPUT: None
2490 *
2491 * This IOCTL is used to checks for allowed concurrency combination.
2492 *
2493 * @E.g: iwpriv wlan0 pm_query_allow mode channel bandwidth
2494 * iwpriv wlan0 pm_query_allow 0 6 4
2495 *
2496 * Supported Feature: DBS
2497 *
2498 * Usage: Internal/External
2499 *
2500 * </ioctl>
2501 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502#define WE_POLICY_MANAGER_QUERY_ALLOW_CMD 18
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302503
2504/*
2505 * <ioctl>
2506 * pm_run_scenario - Create scenario with number of connections provided.
2507 *
2508 * @INPUT: num_of_conn
2509 * @num_of_conn: the number of connections (values: 1~3)
2510 *
2511 * @OUTPUT: None
2512 *
2513 * This IOCTL is used to create scenario with the number of connections
2514 * provided.
2515 *
2516 * @E.g: iwpriv wlan0 pm_run_scenario num_of_conn
2517 * iwpriv wlan0 pm_run_scenario 1
2518 *
2519 * Supported Feature: DBS
2520 *
2521 * Usage: Internal/External
2522 *
2523 * </ioctl>
2524 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525#define WE_POLICY_MANAGER_SCENARIO_CMD 19
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302526
2527/*
2528 * <ioctl>
2529 * pm_set_hw_mode - Set hardware for single/dual mac.
2530 *
2531 * @INPUT: hw_mode
2532 * 0:single mac 1:dual mac
2533 *
2534 * @OUTPUT: None
2535 *
2536 * This IOCTL is used to set hardware for single/dual mac.
2537 *
2538 * @E.g: iwpriv wlan0 pm_set_hw_mode hw_mode
2539 * iwpriv wlan0 pm_set_hw_mode 1
2540 *
2541 * Supported Feature: DBS
2542 *
2543 * Usage: Internal/External
2544 *
2545 * </ioctl>
2546 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547#define WE_POLICY_SET_HW_MODE_CMD 20
2548
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302549/*
2550 * <ioctl>
2551 * set_scan_cfg - Set dual MAC scan config parameters.
2552 *
2553 * @INPUT: dbs, dbs_plus_agile_scan, single_mac_scan_with_dbs
2554 * @dbs: Value of DBS bit
2555 * @dbs_plus_agile_scan: Value of DBS plus agile scan bit
2556 * @single_mac_scan_with_dbs: Value of Single MAC scan with DBS
2557 *
2558 * @OUTPUT: None
2559 *
2560 * This IOCTL is used to set the dual MAC scan config.
2561 *
2562 * @E.g: iwpriv wlan0 set_scan_cfg dbs dbs_plus_agile_scan
2563 * single_mac_scan_with_dbs
2564 * iwpriv wlan0 set_scan_cfg 1 0 1
2565 *
2566 * Supported Feature: DBS
2567 *
2568 * Usage: Internal/External
2569 *
2570 * </ioctl>
2571 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572#define WE_SET_DUAL_MAC_SCAN_CONFIG 21
Nitesh Shahf9503dd2016-12-15 20:26:07 +05302573
2574/*
2575 * <ioctl>
2576 * set_fw_mode_cfg - Sets the dual mac FW mode config
2577 *
2578 * @INPUT: dbs, dfs
2579 * @dbs: DBS bit
2580 * @dfs: Agile DFS bit
2581 *
2582 * @OUTPUT: None
2583 *
2584 * This IOCTL is used to set the dual mac FW mode config.
2585 *
2586 * @E.g: iwpriv wlan0 set_fw_mode_cfg dbs dfs
2587 * iwpriv wlan0 set_fw_mode_cfg 1 1
2588 *
2589 * Supported Feature: DBS
2590 *
2591 * Usage: Internal/External
2592 *
2593 * </ioctl>
2594 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595#define WE_SET_DUAL_MAC_FW_MODE_CONFIG 22
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -07002596#define WE_SET_MON_MODE_CHAN 23
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597
2598#ifdef FEATURE_WLAN_TDLS
2599#undef MAX_VAR_ARGS
2600#define MAX_VAR_ARGS 11
2601#else
2602#undef MAX_VAR_ARGS
2603#define MAX_VAR_ARGS 9
2604#endif
2605
Jeff Johnson6fa1e012017-04-05 06:40:53 -07002606/*
2607 * <ioctl>
2608 * fips_test - Perform a FIPS test
2609 *
2610 * @INPUT: Binary representation of the following packed structure
2611 *
2612 * @OUTPUT: Binary representation of the following packed structure
2613 *
2614 * This IOCTL is used to perform FIPS certification testing
2615 *
2616 * @E.g: iwpriv wlan0 fips_test <test vector>
2617 *
2618 * iwpriv wlan0 fips_test <tbd>
2619 *
2620 * Supported Feature: FIPS
2621 *
2622 * Usage: Internal
2623 *
2624 * </ioctl>
2625 */
2626#define WLAN_PRIV_FIPS_TEST (SIOCIWFIRSTPRIV + 8)
2627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628/* Private ioctls (with no sub-ioctls) */
2629/* note that they must be odd so that they have "get" semantics */
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302630/*
2631 * <ioctl>
2632 * addTspec - Add TSPEC for each AC
2633 *
2634 * @INPUT: 19 TSPEC params
2635 * @[arg0]: handle
2636 * @[arg1]: tid
2637 * @[arg2]: dir
2638 * @[arg3]: psb
2639 * @[arg4]: up
2640 * @[arg5]: nomMsduSize
2641 * @[arg6]: maxMsduSize
2642 * @[arg7]: minDataRate
2643 * @[arg8]: meanDataRate
2644 * @[arg9]: peakDataRate
2645 * @[arg10]: maxBurstSize
2646 * @[arg11]: minPhyRate
2647 * @[arg12]: sba
2648 * @[arg13]: minServiceIntv
2649 * @[arg14]: suspendIntv
2650 * @[arg15]: burstSizeDefn
2651 * @[arg16]: ackPolicy
2652 * @[arg17]: inactivityPeriod
2653 * @[arg18]: maxServiceIntv
2654 *
2655 * @OUTPUT: Success/Failure
2656 *
2657 * This IOCTL is used to add TSPEC for each AC.
2658 *
2659 * @E.g: iwpriv wlan0 addTspec <handle> <tid> <dir> <psb> <up> <nomMsduSize>
2660 * <maxMsduSize> <minDataRate> <meanDataRate>
2661 * <peakDataRate> <maxBurstSize> <minPhyRate>
2662 * <sba> <minServiceIntv> <suspendIntv>
2663 * <burstSizeDefn> <ackPolicy> <inactivityPeriod>
2664 * <maxServiceIntv>
2665 * iwpriv wlan0 addTspec 7001 6 2 1 6 0x80D0 0x80D0 0x14500 0x14500 0x14500
2666 * 0 0x5B8D80 0x2001 20 2000 0 0 0 2000
2667 * wlan0 addTspec:3
2668 *
2669 * Supported Feature: WMM
2670 *
2671 * Usage: Internal/External
2672 *
2673 * </ioctl>
2674 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675#define WLAN_PRIV_ADD_TSPEC (SIOCIWFIRSTPRIV + 9)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302676/*
2677 * <ioctl>
2678 * delTspec - Delete TSPEC entry for each AC
2679 *
2680 * @INPUT: 1 TSPEC param
2681 * @[arg0]: handle
2682 *
2683 * @OUTPUT: Success/Failure
2684 *
2685 * This IOCTL is used to delete TSPEC entry for each AC.
2686 *
2687 * @E.g: iwpriv wlan0 delTspec <handle>
2688 * iwpriv wlan0 delTspec 7001
2689 * wlan0 delTspec:16
2690 *
2691 * Supported Feature: WMM
2692 *
2693 * Usage: Internal/External
2694 *
2695 * </ioctl>
2696 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697#define WLAN_PRIV_DEL_TSPEC (SIOCIWFIRSTPRIV + 11)
Sreelakshmi Konamki9be8d412017-03-01 10:29:08 +05302698/*
2699 * <ioctl>
2700 * getTspec - Get TSPEC entry for each AC
2701 *
2702 * @INPUT: 1 TSPEC param
2703 * @[arg0]: handle
2704 *
2705 * @OUTPUT: Success/Failure
2706 *
2707 * This IOCTL is used to get TSPEC entry for each AC.
2708 *
2709 * @E.g: iwpriv wlan0 getTspec <handle>
2710 * iwpriv wlan0 getTspec 7001
2711 * wlan0 delTspec:18
2712 *
2713 * Supported Feature: WMM
2714 *
2715 * Usage: Internal/External
2716 *
2717 * </ioctl>
2718 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719#define WLAN_PRIV_GET_TSPEC (SIOCIWFIRSTPRIV + 13)
2720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721/* (SIOCIWFIRSTPRIV + 10) is currently unused */
2722/* (SIOCIWFIRSTPRIV + 12) is currently unused */
2723/* (SIOCIWFIRSTPRIV + 14) is currently unused */
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002724#define WLAN_PRIV_SET_NONE_GET_THREE_INT (SIOCIWFIRSTPRIV + 15)
2725#define WE_GET_TSF 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726/* (SIOCIWFIRSTPRIV + 16) is currently unused */
2727/* (SIOCIWFIRSTPRIV + 17) is currently unused */
2728/* (SIOCIWFIRSTPRIV + 19) is currently unused */
2729
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730#define WLAN_PRIV_SET_FTIES (SIOCIWFIRSTPRIV + 20)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731
2732/* Private ioctl for setting the host offload feature */
2733#define WLAN_PRIV_SET_HOST_OFFLOAD (SIOCIWFIRSTPRIV + 18)
2734
2735/* Private ioctl to get the statistics */
2736#define WLAN_GET_WLAN_STATISTICS (SIOCIWFIRSTPRIV + 21)
2737
2738/* Private ioctl to set the Keep Alive Params */
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302739/*
2740 * <ioctl>
2741 * setKeepAlive - Set the keep alive feature
2742 *
2743 * @INPUT: 28 bytes of information in the order of packet type, time period
2744 * host IPv4 address, destination IPv4 address, destination MAC address, bssID
2745 *
2746 * @OUTPUT: None
2747 *
2748 * This IOCTL sets the keep alive feature to send either NULL
2749 * or unsolicited ARP response packets
2750 *
2751 * @E.g: iwpriv wlan0 setKeepAlive
2752 *
2753 * Supported Feature: STA
2754 *
2755 * Usage: Internal/External
2756 *
2757 * </ioctl>
2758 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759#define WLAN_SET_KEEPALIVE_PARAMS (SIOCIWFIRSTPRIV + 22)
2760
2761#ifdef WLAN_FEATURE_PACKET_FILTERING
2762/* Private ioctl to set the packet filtering params */
2763#define WLAN_SET_PACKET_FILTER_PARAMS (SIOCIWFIRSTPRIV + 23)
2764#endif
2765
2766
2767#ifdef FEATURE_WLAN_SCAN_PNO
2768/* Private ioctl to get the statistics */
2769#define WLAN_SET_PNO (SIOCIWFIRSTPRIV + 24)
2770#endif
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302771/*
2772 * <ioctl>
2773 * SETBAND - Set the operational band
2774 *
2775 * @INPUT: 0 to Auto, 1 to 5 GHz and 2 to 2.4 GHz
2776 *
2777 * @OUTPUT: None
2778 *
2779 * This IOCTL Set the operational band If the new band is different from the
2780 * current operational band, it aborts the pending scan requests, flushes
2781 * the existing scan results, and then change * the band capability
2782 *
2783 * @E.g: iwpriv wlan0 SETBAND <value>
2784 *
2785 * Supported Feature: STA
2786 *
2787 * Usage: Internal/External
2788 *
2789 * </ioctl>
2790 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791#define WLAN_SET_BAND_CONFIG (SIOCIWFIRSTPRIV + 25)
2792
Dustin Brown0cbc7572016-12-16 13:54:40 -08002793#define WLAN_PRIV_SET_MCBC_FILTER (SIOCIWFIRSTPRIV + 26)
Dustin Brown860566f2017-01-31 15:24:43 -08002794/* (SIOCIWFIRSTPRIV + 27) is currently unused */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795
2796/* Private ioctls and their sub-ioctls */
2797#define WLAN_PRIV_SET_TWO_INT_GET_NONE (SIOCIWFIRSTPRIV + 28)
2798#define WE_SET_SMPS_PARAM 1
Srinivas Girigowda6147c582016-10-18 12:26:15 -07002799#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800#define WE_SET_FW_CRASH_INJECT 2
2801#endif
2802#define WE_DUMP_DP_TRACE_LEVEL 3
Govind Singha471e5e2015-10-12 17:11:14 +05302803/* Private sub ioctl for enabling and setting histogram interval of profiling */
2804#define WE_ENABLE_FW_PROFILE 4
2805#define WE_SET_FW_PROFILE_HIST_INTVL 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806
Rajeev Kumar9bb2e852016-09-24 12:29:25 -07002807/* Private sub-ioctl for initiating WoW suspend without Apps suspend */
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002808#define WE_SET_WLAN_SUSPEND 6
2809#define WE_SET_WLAN_RESUME 7
Rajeev Kumara78a0a42016-07-13 19:28:20 -07002810
Dustin Brown8d2d0f52017-04-03 17:02:08 -07002811/*
2812 * <ioctl>
2813 * log_buffer - prints host/target related communication logs via dmesg
2814 *
2815 * @INPUT: Log Id, Count
2816 *
2817 * Log Id:
2818 * 0) HTC_CREDIT_HISTORY_LOG
2819 * 1) COMMAND_LOG,
2820 * 2) COMMAND_TX_CMP_LOG,
2821 * 3) MGMT_COMMAND_LOG,
2822 * 4) MGMT_COMMAND_TX_CMP_LOG,
2823 * 5) EVENT_LOG,
2824 * 6) RX_EVENT_LOG,
2825 * 7) MGMT_EVENT_LOG
2826 *
2827 * @OUTPUT: None
2828 *
2829 * @E.g:
2830 * # print up to 10 of the most recent records from HTC Credit History
2831 * iwpriv wlan0 log_buffer 0 10
2832 * # print up to 3 of the most recent records from Event Log
2833 * iwpriv wlan0 log_buffer 5 3
2834 *
2835 * Supported Feature: WLAN Trace
2836 *
2837 * Usage: Internal/External
2838 *
2839 * </ioctl>
2840 */
2841#define WE_LOG_BUFFER 8
2842
2843enum host_target_comm_log {
2844 HTC_CREDIT_HISTORY_LOG = 0,
2845 COMMAND_LOG,
2846 COMMAND_TX_CMP_LOG,
2847 MGMT_COMMAND_LOG,
2848 MGMT_COMMAND_TX_CMP_LOG,
2849 EVENT_LOG,
2850 RX_EVENT_LOG,
2851 MGMT_EVENT_LOG
2852};
2853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854/* (SIOCIWFIRSTPRIV + 29) is currently unused */
2855
2856/* 802.11p IOCTL */
2857#define WLAN_SET_DOT11P_CHANNEL_SCHED (SIOCIWFIRSTPRIV + 30)
2858
Sen, Devendra9ca8c432017-02-23 15:10:26 +05302859/*
2860 * <ioctl>
2861 * getLinkSpeed - Gets the current link speed in Mbps
2862 *
2863 * @INPUT: None
2864 *
2865 * @OUTPUT: linkspeed in mbps
2866 * wlan0 getLinkSpeed:7
2867 *
2868 * This IOCTL is used get the current link speed in Mbps
2869 *
2870 * @E.g: iwpriv wlan0 getLinkSpeed
2871 *
2872 * Supported Feature: STA
2873 *
2874 * Usage: Internal/External
2875 *
2876 * </ioctl>
2877 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878#define WLAN_GET_LINK_SPEED (SIOCIWFIRSTPRIV + 31)
2879
2880#define WLAN_STATS_INVALID 0
2881#define WLAN_STATS_RETRY_CNT 1
2882#define WLAN_STATS_MUL_RETRY_CNT 2
2883#define WLAN_STATS_TX_FRM_CNT 3
2884#define WLAN_STATS_RX_FRM_CNT 4
2885#define WLAN_STATS_FRM_DUP_CNT 5
2886#define WLAN_STATS_FAIL_CNT 6
2887#define WLAN_STATS_RTS_FAIL_CNT 7
2888#define WLAN_STATS_ACK_FAIL_CNT 8
2889#define WLAN_STATS_RTS_SUC_CNT 9
2890#define WLAN_STATS_RX_DISCARD_CNT 10
2891#define WLAN_STATS_RX_ERROR_CNT 11
2892#define WLAN_STATS_TX_BYTE_CNT 12
2893
2894#define WLAN_STATS_RX_BYTE_CNT 13
2895#define WLAN_STATS_RX_RATE 14
2896#define WLAN_STATS_TX_RATE 15
2897
2898#define WLAN_STATS_RX_UC_BYTE_CNT 16
2899#define WLAN_STATS_RX_MC_BYTE_CNT 17
2900#define WLAN_STATS_RX_BC_BYTE_CNT 18
2901#define WLAN_STATS_TX_UC_BYTE_CNT 19
2902#define WLAN_STATS_TX_MC_BYTE_CNT 20
2903#define WLAN_STATS_TX_BC_BYTE_CNT 21
2904
2905#define FILL_TLV(__p, __type, __size, __val, __tlen) do { \
2906 if ((__tlen + __size + 2) < WE_MAX_STR_LEN) { \
2907 *__p++ = __type; \
2908 *__p++ = __size; \
2909 memcpy(__p, __val, __size); \
2910 __p += __size; \
2911 __tlen += __size + 2; \
2912 } else { \
Jeff Johnson99bac312016-06-28 10:38:18 -07002913 hdd_err("FILL_TLV Failed!!!"); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 } \
2915 } while (0)
2916
2917#define VERSION_VALUE_MAX_LEN 32
2918
2919#define TX_PER_TRACKING_DEFAULT_RATIO 5
2920#define TX_PER_TRACKING_MAX_RATIO 10
2921#define TX_PER_TRACKING_DEFAULT_WATERMARK 5
2922
2923#define WLAN_ADAPTER 0
2924#define P2P_ADAPTER 1
2925
2926/**
2927 * mem_alloc_copy_from_user_helper - copy from user helper
2928 * @wrqu_data: wireless extensions request data
2929 * @len: length of @wrqu_data
2930 *
2931 * Helper function to allocate buffer and copy user data.
2932 *
2933 * Return: On success return a pointer to a kernel buffer containing a
2934 * copy of the userspace data (with an additional NUL character
2935 * appended for safety). On failure return %NULL.
2936 */
2937void *mem_alloc_copy_from_user_helper(const __user void *wrqu_data, size_t len)
2938{
2939 u8 *ptr = NULL;
2940
2941 /* in order to protect the code, an extra byte is post
2942 * appended to the buffer and the null termination is added.
2943 * However, when allocating (len+1) byte of memory, we need to
2944 * make sure that there is no uint overflow when doing
2945 * addition. In theory check len < UINT_MAX protects the uint
2946 * overflow. For wlan private ioctl, the buffer size is much
2947 * less than UINT_MAX, as a good guess, now, it is assumed
2948 * that the private command buffer size is no greater than 4K
2949 * (4096 bytes). So we use 4096 as the upper boundary for now.
2950 */
2951 if (len > MAX_USER_COMMAND_SIZE) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08002952 hdd_err("Invalid length: %zu max: %u",
2953 len, MAX_USER_COMMAND_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 return NULL;
2955 }
2956
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002957 ptr = qdf_mem_malloc(len + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 if (NULL == ptr) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002959 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 return NULL;
2961 }
2962
2963 if (copy_from_user(ptr, wrqu_data, len)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07002964 hdd_err("failed to copy data to user buffer");
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002965 qdf_mem_free(ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 return NULL;
2967 }
2968 ptr[len] = '\0';
2969 return ptr;
2970}
2971
2972/**
2973 * hdd_priv_get_data() - Get pointer to ioctl private data
2974 * @p_priv_data: pointer to iw_point struct to be filled
2975 * @wrqu: Pointer to IOCTL Data received from userspace
2976 *
2977 * Helper function to get compatible struct iw_point passed to ioctl
2978 *
2979 * Return - 0 if p_priv_data successfully filled, error otherwise
2980 */
2981int hdd_priv_get_data(struct iw_point *p_priv_data, union iwreq_data *wrqu)
2982{
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002983 if ((NULL == p_priv_data) || (NULL == wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002984 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07002985
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986#ifdef CONFIG_COMPAT
2987 if (is_compat_task()) {
2988 struct compat_iw_point *p_compat_priv_data;
2989
2990 /* Compat task:
2991 * typecast to compat structure and copy the members.
2992 */
2993 p_compat_priv_data = (struct compat_iw_point *)&wrqu->data;
2994
2995 p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
2996 p_priv_data->length = p_compat_priv_data->length;
2997 p_priv_data->flags = p_compat_priv_data->flags;
2998 } else {
2999#endif /* #ifdef CONFIG_COMPAT */
3000
3001 /* Non compat task: directly copy the structure. */
3002 memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
3003
3004#ifdef CONFIG_COMPAT
3005 }
3006#endif /* #ifdef CONFIG_COMPAT */
3007
3008 return 0;
3009}
3010
Jeff Johnson441e1f72017-02-07 08:50:49 -08003011static int hdd_check_wext_control(enum hdd_wext_control wext_control,
3012 struct iw_request_info *info)
3013{
3014 switch (wext_control) {
3015 default:
3016 case hdd_wext_disabled:
3017 hdd_err("Rejecting disabled ioctl %x", info->cmd);
3018 return -ENOTSUPP;
3019 case hdd_wext_deprecated:
3020 hdd_warn("Using deprecated ioctl %x", info->cmd);
3021 return 0;
3022 case hdd_wext_enabled:
3023 return 0;
3024 }
3025}
3026
Jeff Johnson82797b62017-08-11 15:31:27 -07003027int hdd_check_standard_wext_control(struct hdd_context *hdd_ctx,
Jeff Johnson441e1f72017-02-07 08:50:49 -08003028 struct iw_request_info *info)
3029{
3030 return hdd_check_wext_control(hdd_ctx->config->standard_wext_control,
3031 info);
3032}
3033
Jeff Johnson82797b62017-08-11 15:31:27 -07003034int hdd_check_private_wext_control(struct hdd_context *hdd_ctx,
Jeff Johnson441e1f72017-02-07 08:50:49 -08003035 struct iw_request_info *info)
3036{
3037 return hdd_check_wext_control(hdd_ctx->config->private_wext_control,
3038 info);
3039}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040
3041/**
3042 * hdd_wlan_get_stats() - Get txrx stats in SAP mode
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003043 * @adapter: Pointer to the hdd adapter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 * @length: Size of the data copied
3045 * @buffer: Pointer to char buffer.
3046 * @buf_len: Length of the char buffer.
3047 *
3048 * This function called when the "iwpriv wlan0 get_stats" command is given.
3049 * It used to collect the txrx stats when the device is configured in SAP mode.
3050 *
3051 * Return - none
3052 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003053void hdd_wlan_get_stats(struct hdd_adapter *adapter, uint16_t *length,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 char *buffer, uint16_t buf_len)
3055{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003056 struct hdd_tx_rx_stats *pStats = &adapter->hdd_stats.hddTxRxStats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057 uint32_t len = 0;
3058 uint32_t total_rx_pkt = 0, total_rx_dropped = 0;
3059 uint32_t total_rx_delv = 0, total_rx_refused = 0;
3060 int i = 0;
3061
3062 for (; i < NUM_CPUS; i++) {
3063 total_rx_pkt += pStats->rxPackets[i];
3064 total_rx_dropped += pStats->rxDropped[i];
3065 total_rx_delv += pStats->rxDelivered[i];
3066 total_rx_refused += pStats->rxRefused[i];
3067 }
3068
3069 len = scnprintf(buffer, buf_len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003070 "\nTransmit[%lu] - "
Mohit Khannad0b63f52017-02-18 18:05:52 -08003071 "called %u, dropped %u orphan %u,"
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003072 "\n[dropped] BK %u, BE %u, VI %u, VO %u"
3073 "\n[classified] BK %u, BE %u, VI %u, VO %u"
3074 "\n\nReceive[%lu] - "
3075 "packets %u, dropped %u, delivered %u, refused %u"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 "\n",
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003077 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 pStats->txXmitCalled,
3079 pStats->txXmitDropped,
Mohit Khannad0b63f52017-02-18 18:05:52 -08003080 pStats->txXmitOrphaned,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081
3082 pStats->txXmitDroppedAC[SME_AC_BK],
3083 pStats->txXmitDroppedAC[SME_AC_BE],
3084 pStats->txXmitDroppedAC[SME_AC_VI],
3085 pStats->txXmitDroppedAC[SME_AC_VO],
3086
3087 pStats->txXmitClassifiedAC[SME_AC_BK],
3088 pStats->txXmitClassifiedAC[SME_AC_BE],
3089 pStats->txXmitClassifiedAC[SME_AC_VI],
3090 pStats->txXmitClassifiedAC[SME_AC_VO],
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003091 qdf_system_ticks(),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused
3093 );
3094
3095 for (i = 0; i < NUM_CPUS; i++) {
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003096 if (pStats->rxPackets[i] == 0)
3097 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003099 "Rx CPU[%d]:"
3100 "packets %u, dropped %u, delivered %u, refused %u\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101 i, pStats->rxPackets[i], pStats->rxDropped[i],
3102 pStats->rxDelivered[i], pStats->rxRefused[i]);
3103 }
3104
3105 len += scnprintf(buffer + len, buf_len - len,
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003106 "\nTX_FLOW"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 "\nCurrent status: %s"
3108 "\ntx-flow timer start count %u"
3109 "\npause count %u, unpause count %u",
3110 (pStats->is_txflow_paused == true ? "PAUSED" : "UNPAUSED"),
3111 pStats->txflow_timer_cnt,
3112 pStats->txflow_pause_cnt,
3113 pStats->txflow_unpause_cnt);
3114
Leo Changfdb45c32016-10-28 11:09:23 -07003115 len += cdp_stats(cds_get_context(QDF_MODULE_ID_SOC),
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003116 adapter->sessionId, &buffer[len], (buf_len - len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 *length = len + 1;
3118}
3119
3120/**
Dustin Brownd9322482017-01-09 12:46:03 -08003121 * wlan_hdd_write_suspend_resume_stats() - Writes suspend/resume stats to buffer
3122 * @hdd_ctx: The Hdd context owning the stats to be written
3123 * @buffer: The char buffer to write to
3124 * @max_len: The maximum number of chars to write
3125 *
3126 * This assumes hdd_ctx has already been validated, and buffer is not NULL.
3127 *
3128 * Return - length of written content, negative number on error
3129 */
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003130static int wlan_hdd_write_suspend_resume_stats(struct hdd_context *hdd_ctx,
Dustin Brownd9322482017-01-09 12:46:03 -08003131 char *buffer, uint16_t max_len)
3132{
3133 QDF_STATUS status;
3134 struct suspend_resume_stats *sr_stats;
3135 struct sir_wake_lock_stats wow_stats;
3136
3137 sr_stats = &hdd_ctx->suspend_resume_stats;
3138
3139 status = wma_get_wakelock_stats(&wow_stats);
3140 if (QDF_IS_STATUS_ERROR(status)) {
3141 hdd_err("Failed to get WoW stats");
3142 return qdf_status_to_os_return(status);
3143 }
3144
3145 return scnprintf(buffer, max_len,
3146 "\n"
3147 "Suspends: %u\n"
3148 "Resumes: %u\n"
3149 "\n"
3150 "Suspend Fail Reasons\n"
3151 "\tIPA: %u\n"
3152 "\tRadar: %u\n"
3153 "\tRoam: %u\n"
3154 "\tScan: %u\n"
3155 "\tInitial Wakeup: %u\n"
3156 "\n"
3157 "WoW Wake Reasons\n"
3158 "\tunicast: %u\n"
3159 "\tbroadcast: %u\n"
3160 "\tIPv4 multicast: %u\n"
3161 "\tIPv6 multicast: %u\n"
3162 "\tIPv6 multicast RA: %u\n"
3163 "\tIPv6 multicast NS: %u\n"
3164 "\tIPv6 multicast NA: %u\n"
3165 "\tICMPv4: %u\n"
3166 "\tICMPv6: %u\n"
3167 "\tRSSI Breach: %u\n"
3168 "\tLow RSSI: %u\n"
3169 "\tG-Scan: %u\n"
3170 "\tPNO Complete: %u\n"
3171 "\tPNO Match: %u\n",
3172 sr_stats->suspends,
3173 sr_stats->resumes,
3174 sr_stats->suspend_fail[SUSPEND_FAIL_IPA],
3175 sr_stats->suspend_fail[SUSPEND_FAIL_RADAR],
3176 sr_stats->suspend_fail[SUSPEND_FAIL_ROAM],
3177 sr_stats->suspend_fail[SUSPEND_FAIL_SCAN],
3178 sr_stats->suspend_fail[SUSPEND_FAIL_INITIAL_WAKEUP],
3179 wow_stats.wow_ucast_wake_up_count,
3180 wow_stats.wow_bcast_wake_up_count,
3181 wow_stats.wow_ipv4_mcast_wake_up_count,
3182 wow_stats.wow_ipv6_mcast_wake_up_count,
3183 wow_stats.wow_ipv6_mcast_ra_stats,
3184 wow_stats.wow_ipv6_mcast_ns_stats,
3185 wow_stats.wow_ipv6_mcast_na_stats,
3186 wow_stats.wow_icmpv4_count,
3187 wow_stats.wow_icmpv6_count,
3188 wow_stats.wow_rssi_breach_wake_up_count,
3189 wow_stats.wow_low_rssi_wake_up_count,
3190 wow_stats.wow_gscan_wake_up_count,
3191 wow_stats.wow_pno_complete_wake_up_count,
3192 wow_stats.wow_pno_match_wake_up_count);
3193}
3194
3195/**
Govind Singha471e5e2015-10-12 17:11:14 +05303196 * hdd_wlan_list_fw_profile() - Get fw profiling points
3197 * @length: Size of the data copied
3198 * @buffer: Pointer to char buffer.
3199 * @buf_len: Length of the char buffer.
3200 *
3201 * This function called when the "iwpriv wlan0 listProfile" command is given.
3202 * It is used to get the supported profiling points in FW.
3203 *
3204 * Return - none
3205 */
3206void hdd_wlan_list_fw_profile(uint16_t *length,
3207 char *buffer, uint16_t buf_len)
3208{
3209 uint32_t len = 0;
3210
3211 len = scnprintf(buffer, buf_len,
3212 "PROF_CPU_IDLE: %u\n"
3213 "PROF_PPDU_PROC: %u\n"
3214 "PROF_PPDU_POST: %u\n"
3215 "PROF_HTT_TX_INPUT: %u\n"
3216 "PROF_MSDU_ENQ: %u\n"
3217 "PROF_PPDU_POST_HAL: %u\n"
3218 "PROF_COMPUTE_TX_TIME: %u\n",
3219 PROF_CPU_IDLE,
3220 PROF_PPDU_PROC,
3221 PROF_PPDU_POST,
3222 PROF_HTT_TX_INPUT,
3223 PROF_MSDU_ENQ,
3224 PROF_PPDU_POST_HAL,
3225 PROF_COMPUTE_TX_TIME);
3226
3227 *length = len + 1;
3228}
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003229/**
3230 * hdd_display_stats_help() - print statistics help
3231 *
3232 * Return: none
3233 */
3234void hdd_display_stats_help(void)
3235{
3236 hdd_err("iwpriv wlan0 dumpStats [option] - dump statistics");
3237 hdd_err("iwpriv wlan0 clearStats [option] - clear statistics");
3238 hdd_err("options:");
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003239 hdd_err(" 1 -- TXRX PATH statistics");
3240 hdd_err(" 2 -- TXRX HIST statistics");
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003241 hdd_err(" 3 -- TSO statistics");
3242 hdd_err(" 4 -- Network queue statistics");
3243 hdd_err(" 5 -- Flow control statistics");
3244 hdd_err(" 6 -- Per Layer statistics");
3245 hdd_err(" 7 -- Copy engine interrupt statistics");
3246 hdd_err(" 8 -- LRO statistics");
3247 hdd_err(" 9 -- NAPI statistics");
3248}
Govind Singha471e5e2015-10-12 17:11:14 +05303249
3250/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 * hdd_wlan_dump_stats() - display dump Stats
3252 * @adapter: adapter handle
3253 * @value: value from user
3254 *
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003255 * Return: 0 => success, error code on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07003257int hdd_wlan_dump_stats(struct hdd_adapter *adapter, int value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258{
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003259 int ret = 0;
3260 QDF_STATUS status;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003261 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262
3263 switch (value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003264 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 wlan_hdd_display_tx_rx_histogram(hdd_ctx);
3266 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003267 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 wlan_hdd_display_netif_queue_history(hdd_ctx);
3269 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003270 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05303271 hdd_display_hif_stats();
3272 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003273 case CDP_LRO_STATS:
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003274 hdd_lro_display_stats(hdd_ctx);
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07003275 case CDP_NAPI_STATS:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003276 if (hdd_display_napi_stats()) {
3277 hdd_err("error displaying napi stats");
3278 ret = EFAULT;
3279 }
Dhanashri Atree7d442a2016-07-14 18:20:29 -07003280 break;
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +05303281 case CDP_DISCONNECT_STATS:
3282 sme_display_disconnect_stats(WLAN_HDD_GET_HAL_CTX(adapter),
3283 adapter->sessionId);
3284 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 default:
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003286 status = cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC),
3287 value);
3288 if (status == QDF_STATUS_E_INVAL) {
3289 hdd_display_stats_help();
3290 ret = EINVAL;
3291 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 break;
3293 }
Mohit Khanna3e2115b2016-10-11 13:18:29 -07003294 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295}
3296
3297/**
3298 * hdd_wlan_get_version() - Get driver version information
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303299 * @hdd_ctx: Global HDD context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 * @wrqu: Pointer to IOCTL REQUEST Data.
3301 * @extra: Pointer to destination buffer
3302 *
3303 * This function is used to get Wlan Driver, Firmware, & Hardware
3304 * Version information. If @wrqu and @extra are specified, then the
3305 * version string is returned. Otherwise it is simply printed to the
3306 * kernel log.
3307 *
3308 * Return: none
3309 */
Jeff Johnson6d38ab82017-08-28 11:36:27 -07003310void hdd_wlan_get_version(struct hdd_context *hdd_ctx, union iwreq_data *wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311 char *extra)
3312{
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303313 tSirVersionString wcnss_sw_version;
3314 const char *swversion;
3315 const char *hwversion;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003316 uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303318 if (!hdd_ctx) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003319 hdd_err("Invalid context, HDD context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 goto error;
3321 }
3322
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303323 snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x",
3324 hdd_ctx->target_fw_version);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303326 swversion = wcnss_sw_version;
3327 msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28;
3328 mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24;
3329 siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20;
3330 crmid = hdd_ctx->target_fw_version & 0x7fff;
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003331 sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332
Arun Khandavallia96c2c02016-05-17 19:15:34 +05303333 hwversion = hdd_ctx->target_hw_name;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334
3335 if (wrqu && extra) {
3336 wrqu->data.length =
3337 scnprintf(extra, WE_MAX_STR_LEN,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003338 "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003340 msp_id, mspid, siid, crmid,
3341 sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 } else {
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003343 pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 QWLAN_VERSIONSTR,
Sandeep Puligilla3d6a8e22016-10-11 18:57:14 -07003345 msp_id, mspid, siid, crmid, sub_id, hwversion);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346 }
3347error:
3348 return;
3349}
3350
3351/**
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003352 * hdd_wlan_get_ibss_mac_addr_from_staid() - Get IBSS MAC address
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003353 * @adapter: Adapter upon which the IBSS client is active
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003354 * @staIdx: Station index of the IBSS peer
3355 *
3356 * Return: a pointer to the MAC address of the IBSS peer if the peer is
3357 * found, otherwise %NULL.
3358 */
3359struct qdf_mac_addr *
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003360hdd_wlan_get_ibss_mac_addr_from_staid(struct hdd_adapter *adapter,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003361 uint8_t staIdx)
3362{
3363 uint8_t idx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003364 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003365
Naveen Rawatc45d1622016-07-05 12:20:09 -07003366 for (idx = 0; idx < MAX_PEERS; idx++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003367 if (HDD_WLAN_INVALID_STA_ID !=
Jeff Johnsond377dce2017-10-04 10:32:42 -07003368 sta_ctx->conn_info.staId[idx] &&
3369 staIdx == sta_ctx->conn_info.staId[idx]) {
3370 return &sta_ctx->conn_info.peerMacAddress[idx];
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003371 }
3372 }
3373 return NULL;
3374}
3375
3376/**
3377 * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003378 * @adapter: Adapter upon which the IBSS client is active
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003379 * @staIdx: Station index of the IBSS peer
3380 *
3381 * Return: QDF_STATUS_STATUS if the peer was found and displayed,
3382 * otherwise an appropriate QDF_STATUS_E_* failure code.
3383 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003384static QDF_STATUS hdd_wlan_get_ibss_peer_info(struct hdd_adapter *adapter,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07003385 uint8_t staIdx)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003386{
3387 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003388 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
3389 struct hdd_station_ctx *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003390 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003391
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003392 INIT_COMPLETION(adapter->ibss_peer_info_comp);
3393 status = sme_request_ibss_peer_info(hHal, adapter,
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003394 hdd_get_ibss_peer_info_cb,
3395 false, staIdx);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003396
3397 if (QDF_STATUS_SUCCESS == status) {
3398 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003399
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003400 rc = wait_for_completion_timeout
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003401 (&adapter->ibss_peer_info_comp,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003402 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3403 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003404 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003405 return QDF_STATUS_E_FAILURE;
3406 }
3407
3408 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003409 hdd_debug("pPeerInfo->numIBSSPeers = %d ", pPeerInfo->numPeers);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003410 {
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003411 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3412 uint32_t tx_rate = pPeerInfo->peerInfoParams[0].txRate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003413
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003414 qdf_mem_copy(mac_addr, pPeerInfo->peerInfoParams[0].
3415 mac_addr, sizeof(mac_addr));
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[0].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/**
3428 * hdd_wlan_get_ibss_peer_info_all() - Print all IBSS peers
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003429 * @adapter: Adapter upon which the IBSS clients are active
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003430 *
3431 * Return: QDF_STATUS_STATUS if the peer information was retrieved and
3432 * displayed, otherwise an appropriate QDF_STATUS_E_* failure code.
3433 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003434static QDF_STATUS hdd_wlan_get_ibss_peer_info_all(struct hdd_adapter *adapter)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003435{
3436 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003437 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
3438 struct hdd_station_ctx *pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003439 tSirPeerInfoRspParams *pPeerInfo = &pStaCtx->ibss_peer_info;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003440 int i;
3441
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003442 INIT_COMPLETION(adapter->ibss_peer_info_comp);
3443 status = sme_request_ibss_peer_info(hHal, adapter,
Prakash Dhavali4c2a9fe2016-12-02 16:01:08 -08003444 hdd_get_ibss_peer_info_cb,
3445 true, 0xFF);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003446
3447 if (QDF_STATUS_SUCCESS == status) {
3448 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003449
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003450 rc = wait_for_completion_timeout
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003451 (&adapter->ibss_peer_info_comp,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003452 msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT));
3453 if (!rc) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003454 hdd_err("failed wait on ibss_peer_info_comp");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003455 return QDF_STATUS_E_FAILURE;
3456 }
3457
3458 /** Print the peer info */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003459 hdd_debug("pPeerInfo->numIBSSPeers = %d ",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003460 (int)pPeerInfo->numPeers);
3461 for (i = 0; i < pPeerInfo->numPeers; i++) {
3462 uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
3463 uint32_t tx_rate;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003464
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003465 tx_rate = pPeerInfo->peerInfoParams[i].txRate;
3466 qdf_mem_copy(mac_addr,
3467 pPeerInfo->peerInfoParams[i].mac_addr,
3468 sizeof(mac_addr));
3469
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003470 hdd_debug(" PEER ADDR : %pM TxRate: %d Mbps RSSI: %d",
Rajeev Kumar94c9b452016-03-24 12:58:47 -07003471 mac_addr, (int)tx_rate,
3472 (int)pPeerInfo->peerInfoParams[i].rssi);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003473 }
3474 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07003475 hdd_warn("Warning: sme_request_ibss_peer_info Request failed");
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08003476 }
3477
3478 return status;
3479}
3480
3481/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 * hdd_wlan_get_freq() - Convert channel to frequency
3483 * @channel: channel to be converted
3484 * @pfreq: where to store the frequency
3485 *
3486 * Return: 1 on success, otherwise a negative errno
3487 */
3488int hdd_wlan_get_freq(uint32_t channel, uint32_t *pfreq)
3489{
3490 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07003491
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 if (channel > 0) {
3493 for (i = 0; i < FREQ_CHAN_MAP_TABLE_SIZE; i++) {
3494 if (channel == freq_chan_map[i].chan) {
3495 *pfreq = freq_chan_map[i].freq;
3496 return 1;
3497 }
3498 }
3499 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003500 hdd_err("Invalid channel no=%d!!", channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 return -EINVAL;
3502}
3503
3504/**
3505 * hdd_is_auth_type_rsn() - RSN authentication type check
3506 * @authType: authentication type to be checked
3507 *
3508 * Return: true if @authType is an RSN authentication type,
3509 * false if it is not
3510 */
3511static bool hdd_is_auth_type_rsn(eCsrAuthType authType)
3512{
3513 bool rsnType = false;
3514 /* is the authType supported? */
3515 switch (authType) {
3516 case eCSR_AUTH_TYPE_NONE: /* never used */
3517 rsnType = false;
3518 break;
3519 /* MAC layer authentication types */
3520 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3521 rsnType = false;
3522 break;
3523 case eCSR_AUTH_TYPE_SHARED_KEY:
3524 rsnType = false;
3525 break;
3526 case eCSR_AUTH_TYPE_AUTOSWITCH:
3527 rsnType = false;
3528 break;
3529
3530 /* Upper layer authentication types */
3531 case eCSR_AUTH_TYPE_WPA:
3532 rsnType = true;
3533 break;
3534 case eCSR_AUTH_TYPE_WPA_PSK:
3535 rsnType = true;
3536 break;
3537 case eCSR_AUTH_TYPE_WPA_NONE:
3538 rsnType = true;
3539 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541 case eCSR_AUTH_TYPE_RSN:
3542 rsnType = true;
3543 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545 case eCSR_AUTH_TYPE_RSN_PSK:
3546#ifdef WLAN_FEATURE_11W
3547 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3548 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
3549#endif
3550 rsnType = true;
3551 break;
3552 /* case eCSR_AUTH_TYPE_FAILED: */
3553 case eCSR_AUTH_TYPE_UNKNOWN:
3554 rsnType = false;
3555 break;
3556 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07003557 hdd_err("unknown authType %d, treat as open",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 authType);
3559 rsnType = false;
3560 break;
3561 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003562 hdd_debug("called with authType: %d, returned: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 authType, rsnType);
3564 return rsnType;
3565}
3566
Jeff Johnsona5444942017-01-23 13:11:08 -08003567struct rssi_priv {
3568 int8_t rssi;
3569};
3570
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571/**
3572 * hdd_get_rssi_cb() - "Get RSSI" callback function
3573 * @rssi: Current RSSI of the station
Jeff Johnsona5444942017-01-23 13:11:08 -08003574 * @sta_id: ID of the station
3575 * @context: opaque context originally passed to SME. HDD always passes
3576 * a cookie for the request context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577 *
3578 * Return: None
3579 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003580static void hdd_get_rssi_cb(int8_t rssi, uint32_t sta_id, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581{
Jeff Johnsona5444942017-01-23 13:11:08 -08003582 struct hdd_request *request;
3583 struct rssi_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584
Jeff Johnsona5444942017-01-23 13:11:08 -08003585 request = hdd_request_get(context);
3586 if (!request) {
3587 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 return;
3589 }
3590
Jeff Johnsona5444942017-01-23 13:11:08 -08003591 priv = hdd_request_priv(request);
3592 priv->rssi = rssi;
3593 hdd_request_complete(request);
3594 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595}
3596
3597/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 * wlan_hdd_get_rssi() - Get the current RSSI
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003599 * @adapter: adapter upon which the measurement is requested
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 * @rssi_value: pointer to where the RSSI should be returned
3601 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303602 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003604QDF_STATUS wlan_hdd_get_rssi(struct hdd_adapter *adapter, int8_t *rssi_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605{
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003606 struct hdd_context *hdd_ctx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003607 struct hdd_station_ctx *sta_ctx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303608 QDF_STATUS hstatus;
Jeff Johnsona5444942017-01-23 13:11:08 -08003609 int ret;
3610 void *cookie;
3611 struct hdd_request *request;
3612 struct rssi_priv *priv;
3613 static const struct hdd_request_params params = {
3614 .priv_size = sizeof(*priv),
3615 .timeout_ms = WLAN_WAIT_TIME_STATS,
3616 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003618 if (NULL == adapter) {
3619 hdd_err("Invalid context, adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303620 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 }
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +05303622 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Prashanth Bhatta9e143052015-12-04 11:56:47 -08003623 hdd_err("Recovery in Progress. State: 0x%x Ignore!!!",
3624 cds_get_driver_state());
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 /* return a cached value */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003626 *rssi_value = adapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303627 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 }
3629
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003630 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003631 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632
Jeff Johnsond377dce2017-10-04 10:32:42 -07003633 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003634 hdd_debug("Not associated!, rssi on disconnect %d",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003635 adapter->rssi_on_disconnect);
3636 *rssi_value = adapter->rssi_on_disconnect;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303637 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 }
3639
Jeff Johnsond377dce2017-10-04 10:32:42 -07003640 if (sta_ctx->hdd_ReassocScenario) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08003641 hdd_debug("Roaming in progress, return cached RSSI");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003642 *rssi_value = adapter->rssi;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303643 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 }
3645
Jeff Johnsona5444942017-01-23 13:11:08 -08003646 request = hdd_request_alloc(&params);
3647 if (!request) {
3648 hdd_err("Request allocation failure, return cached RSSI");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003649 *rssi_value = adapter->rssi;
Jeff Johnsona5444942017-01-23 13:11:08 -08003650 return QDF_STATUS_SUCCESS;
3651 }
3652 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003654 hstatus = sme_get_rssi(hdd_ctx->hHal, hdd_get_rssi_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003655 sta_ctx->conn_info.staId[0],
3656 sta_ctx->conn_info.bssId, adapter->rssi,
Jeff Johnson8bd23352017-09-26 11:39:24 -07003657 cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303658 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003659 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 /* we'll returned a cached value below */
3661 } else {
3662 /* request was sent -- wait for the response */
Jeff Johnsona5444942017-01-23 13:11:08 -08003663 ret = hdd_request_wait_for_response(request);
3664 if (ret) {
3665 hdd_warn("SME timed out while retrieving RSSI");
3666 /* we'll returned a cached value below */
3667 } else {
3668 /* update the adapter with the fresh results */
3669 priv = hdd_request_priv(request);
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +05303670 /*
3671 * update rssi only if its valid else return previous
3672 * valid rssi.
3673 */
3674 if (priv->rssi)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003675 adapter->rssi = priv->rssi;
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +05303676
3677 /*
3678 * for new connection there might be no valid previous
3679 * RSSI.
3680 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003681 if (!adapter->rssi) {
3682 hdd_get_rssi_snr_by_bssid(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003683 sta_ctx->conn_info.bssId.bytes,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003684 &adapter->rssi, NULL);
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +05303685 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686 }
3687 }
3688
Jeff Johnsona5444942017-01-23 13:11:08 -08003689 /*
3690 * either we never sent a request, we sent a request and
3691 * received a response or we sent a request and timed out.
3692 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693 */
Jeff Johnsona5444942017-01-23 13:11:08 -08003694 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003696 *rssi_value = adapter->rssi;
Rajeev Kumar Sirasanagandla5bacf7f2017-05-10 15:31:40 +05303697 hdd_debug("RSSI = %d", *rssi_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303699 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700}
3701
Jeff Johnson002cb972017-01-23 14:59:07 -08003702struct snr_priv {
3703 int8_t snr;
3704};
3705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706/**
Jeff Johnson8eaff302017-01-23 11:03:31 -08003707 * hdd_get_snr_cb() - "Get SNR" callback function
3708 * @snr: Current SNR of the station
Jeff Johnson002cb972017-01-23 14:59:07 -08003709 * @sta_id: ID of the station
3710 * @context: opaque context originally passed to SME. HDD always passes
3711 * a cookie for the request context
Jeff Johnson8eaff302017-01-23 11:03:31 -08003712 *
3713 * Return: None
3714 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003715static void hdd_get_snr_cb(int8_t snr, uint32_t sta_id, void *context)
Jeff Johnson8eaff302017-01-23 11:03:31 -08003716{
Jeff Johnson002cb972017-01-23 14:59:07 -08003717 struct hdd_request *request;
3718 struct snr_priv *priv;
Jeff Johnson8eaff302017-01-23 11:03:31 -08003719
Jeff Johnson002cb972017-01-23 14:59:07 -08003720 request = hdd_request_get(context);
3721 if (!request) {
3722 hdd_err("Obsolete request");
Jeff Johnson8eaff302017-01-23 11:03:31 -08003723 return;
3724 }
3725
Jeff Johnson002cb972017-01-23 14:59:07 -08003726 /* propagate response back to requesting thread */
3727 priv = hdd_request_priv(request);
3728 priv->snr = snr;
3729 hdd_request_complete(request);
3730 hdd_request_put(request);
Jeff Johnson8eaff302017-01-23 11:03:31 -08003731}
3732
3733/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734 * wlan_hdd_get_snr() - Get the current SNR
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003735 * @adapter: adapter upon which the measurement is requested
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736 * @snr: pointer to where the SNR should be returned
3737 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303738 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003740QDF_STATUS wlan_hdd_get_snr(struct hdd_adapter *adapter, int8_t *snr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003741{
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003742 struct hdd_context *hdd_ctx;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003743 struct hdd_station_ctx *sta_ctx;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303744 QDF_STATUS hstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 int valid;
Jeff Johnson002cb972017-01-23 14:59:07 -08003746 int ret;
3747 void *cookie;
3748 struct hdd_request *request;
3749 struct snr_priv *priv;
3750 static const struct hdd_request_params params = {
3751 .priv_size = sizeof(*priv),
3752 .timeout_ms = WLAN_WAIT_TIME_STATS,
3753 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003754
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303755 ENTER();
3756
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003757 if (NULL == adapter) {
3758 hdd_err("Invalid context, adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303759 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003760 }
3761
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003762 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003763
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003764 valid = wlan_hdd_validate_context(hdd_ctx);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303765 if (0 != valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303766 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767
Jeff Johnsond377dce2017-10-04 10:32:42 -07003768 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003769
Jeff Johnson002cb972017-01-23 14:59:07 -08003770 request = hdd_request_alloc(&params);
3771 if (!request) {
3772 hdd_err("Request allocation failure");
3773 return QDF_STATUS_E_FAULT;
3774 }
3775 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003776
Jeff Johnsonce2ee982017-09-03 09:27:35 -07003777 hstatus = sme_get_snr(hdd_ctx->hHal, hdd_get_snr_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003778 sta_ctx->conn_info.staId[0],
3779 sta_ctx->conn_info.bssId, cookie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303780 if (QDF_STATUS_SUCCESS != hstatus) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003781 hdd_err("Unable to retrieve RSSI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782 /* we'll returned a cached value below */
3783 } else {
3784 /* request was sent -- wait for the response */
Jeff Johnson002cb972017-01-23 14:59:07 -08003785 ret = hdd_request_wait_for_response(request);
3786 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003787 hdd_err("SME timed out while retrieving SNR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 /* we'll now returned a cached value below */
Jeff Johnson002cb972017-01-23 14:59:07 -08003789 } else {
3790 /* update the adapter with the fresh results */
3791 priv = hdd_request_priv(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003792 adapter->snr = priv->snr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793 }
3794 }
3795
Jeff Johnson002cb972017-01-23 14:59:07 -08003796 /*
3797 * either we never sent a request, we sent a request and
3798 * received a response or we sent a request and timed out.
3799 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 */
Jeff Johnson002cb972017-01-23 14:59:07 -08003801 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07003803 *snr = adapter->snr;
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05303804 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303805 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806}
3807
Jeff Johnsone50427c2017-01-26 10:54:49 -08003808struct linkspeed_priv {
3809 tSirLinkSpeedInfo linkspeed_info;
3810};
3811
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812static void
Jeff Johnsone50427c2017-01-26 10:54:49 -08003813hdd_get_link_speed_cb(tSirLinkSpeedInfo *linkspeed_info, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814{
Jeff Johnsone50427c2017-01-26 10:54:49 -08003815 struct hdd_request *request;
3816 struct linkspeed_priv *priv;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817
Jeff Johnsone50427c2017-01-26 10:54:49 -08003818 if (!linkspeed_info) {
3819 hdd_err("NULL linkspeed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 return;
3821 }
3822
Jeff Johnsone50427c2017-01-26 10:54:49 -08003823 request = hdd_request_get(context);
3824 if (!request) {
3825 hdd_err("Obsolete request");
3826 return;
3827 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828
Jeff Johnsone50427c2017-01-26 10:54:49 -08003829 priv = hdd_request_priv(request);
3830 priv->linkspeed_info = *linkspeed_info;
3831 hdd_request_complete(request);
3832 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833}
3834
Jeff Johnson3d278b02017-08-29 14:17:47 -07003835int wlan_hdd_get_linkspeed_for_peermac(struct hdd_adapter *adapter,
Jeff Johnsone50427c2017-01-26 10:54:49 -08003836 struct qdf_mac_addr *mac_address,
3837 uint32_t *linkspeed)
3838{
3839 int ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303840 QDF_STATUS status;
Jeff Johnsone50427c2017-01-26 10:54:49 -08003841 void *cookie;
3842 tSirLinkSpeedInfo *linkspeed_info;
3843 struct hdd_request *request;
3844 struct linkspeed_priv *priv;
3845 static const struct hdd_request_params params = {
3846 .priv_size = sizeof(*priv),
3847 .timeout_ms = WLAN_WAIT_TIME_STATS,
3848 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849
Jeff Johnsone50427c2017-01-26 10:54:49 -08003850 if ((!adapter) || (!linkspeed)) {
3851 hdd_err("NULL argument");
3852 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854
Jeff Johnsone50427c2017-01-26 10:54:49 -08003855 request = hdd_request_alloc(&params);
3856 if (!request) {
3857 hdd_err("Request allocation failure");
3858 ret = -ENOMEM;
3859 goto return_cached_value;
3860 }
3861
3862 cookie = hdd_request_cookie(request);
3863 priv = hdd_request_priv(request);
3864
3865 linkspeed_info = &priv->linkspeed_info;
3866 qdf_copy_macaddr(&linkspeed_info->peer_macaddr, mac_address);
3867 status = sme_get_link_speed(WLAN_HDD_GET_HAL_CTX(adapter),
3868 linkspeed_info,
3869 cookie, hdd_get_link_speed_cb);
3870 if (QDF_IS_STATUS_ERROR(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003871 hdd_err("Unable to retrieve statistics for link speed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003872 ret = qdf_status_to_os_return(status);
3873 goto cleanup;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 }
Jeff Johnsone50427c2017-01-26 10:54:49 -08003875 ret = hdd_request_wait_for_response(request);
3876 if (ret) {
3877 hdd_err("SME timed out while retrieving link speed");
3878 goto cleanup;
3879 }
3880 adapter->estimated_linkspeed = linkspeed_info->estLinkSpeed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881
Jeff Johnsone50427c2017-01-26 10:54:49 -08003882cleanup:
3883 /*
3884 * either we never sent a request, we sent a request and
3885 * received a response or we sent a request and timed out.
3886 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 */
Jeff Johnsone50427c2017-01-26 10:54:49 -08003888 hdd_request_put(request);
3889
3890return_cached_value:
3891 *linkspeed = adapter->estimated_linkspeed;
3892
3893 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894}
3895
Jeff Johnson4e632672017-10-03 11:40:51 -07003896int wlan_hdd_get_link_speed(struct hdd_adapter *adapter, uint32_t *link_speed)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897{
Jeff Johnson4e632672017-10-03 11:40:51 -07003898 struct hdd_context *hddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003899 struct hdd_station_ctx *hdd_stactx =
Jeff Johnson4e632672017-10-03 11:40:51 -07003900 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 int ret;
3902
3903 ret = wlan_hdd_validate_context(hddctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05303904 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003906
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303907 /* Linkspeed is allowed only for P2P mode */
Jeff Johnson4e632672017-10-03 11:40:51 -07003908 if (adapter->device_mode != QDF_P2P_CLIENT_MODE) {
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303909 hdd_err("Link Speed is not allowed in Device mode %s(%d)",
Jeff Johnson4e632672017-10-03 11:40:51 -07003910 hdd_device_mode_to_string(adapter->device_mode),
3911 adapter->device_mode);
Nitesh Shah4e2d5eb2016-09-06 19:45:13 +05303912 return -ENOTSUPP;
3913 }
3914
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 if (eConnectionState_Associated != hdd_stactx->conn_info.connState) {
3916 /* we are not connected so we don't have a classAstats */
3917 *link_speed = 0;
3918 } else {
Anurag Chouhan6d760662016-02-20 16:05:43 +05303919 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003920
Anurag Chouhanc5548422016-02-24 18:33:27 +05303921 qdf_copy_macaddr(&bssid, &hdd_stactx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922
Jeff Johnson4e632672017-10-03 11:40:51 -07003923 ret = wlan_hdd_get_linkspeed_for_peermac(adapter, &bssid,
Jeff Johnsone50427c2017-01-26 10:54:49 -08003924 link_speed);
3925 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07003926 hdd_err("Unable to retrieve SME linkspeed");
Jeff Johnsone50427c2017-01-26 10:54:49 -08003927 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 /* linkspeed in units of 500 kbps */
3930 *link_speed = (*link_speed) / 500;
3931 }
3932 return 0;
3933}
3934
Will Huang496b36c2017-07-11 16:38:50 +08003935struct peer_rssi_priv {
3936 struct sir_peer_sta_info peer_sta_info;
3937};
3938
3939/**
3940 * hdd_get_peer_rssi_cb() - get peer station's rssi callback
3941 * @sta_rssi: pointer of peer information
3942 * @context: get rssi callback context
3943 *
3944 * This function will fill rssi information to rssi priv
3945 * adapter
3946 *
3947 */
3948static void hdd_get_peer_rssi_cb(struct sir_peer_info_resp *sta_rssi,
3949 void *context)
3950{
3951 struct hdd_request *request;
3952 struct peer_rssi_priv *priv;
3953 struct sir_peer_info *rssi_info;
3954 uint8_t peer_num;
3955
3956 if ((!sta_rssi) || (!context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07003957 hdd_err("Bad param, sta_rssi [%pK] context [%pK]",
Will Huang496b36c2017-07-11 16:38:50 +08003958 sta_rssi, context);
3959 return;
3960 }
3961
3962 request = hdd_request_get(context);
3963 if (!request) {
3964 hdd_err("Obsolete request");
3965 return;
3966 }
3967
3968 priv = hdd_request_priv(request);
3969
3970 peer_num = sta_rssi->count;
3971 rssi_info = sta_rssi->info;
3972
3973 hdd_debug("%d peers", peer_num);
3974
3975 if (peer_num > MAX_PEER_STA) {
3976 hdd_warn("Exceed max peer sta to handle one time %d", peer_num);
3977 peer_num = MAX_PEER_STA;
3978 }
3979
3980 qdf_mem_copy(priv->peer_sta_info.info, rssi_info,
3981 peer_num * sizeof(*rssi_info));
3982 priv->peer_sta_info.sta_num = peer_num;
3983
3984 hdd_request_complete(request);
3985 hdd_request_put(request);
3986}
3987
Jeff Johnson3d278b02017-08-29 14:17:47 -07003988int wlan_hdd_get_peer_rssi(struct hdd_adapter *adapter,
Will Huang496b36c2017-07-11 16:38:50 +08003989 struct qdf_mac_addr *macaddress,
3990 struct sir_peer_sta_info *peer_sta_info)
3991{
3992 QDF_STATUS status;
3993 void *cookie;
3994 int ret;
3995 struct sir_peer_info_req rssi_req;
3996 struct hdd_request *request;
3997 struct peer_rssi_priv *priv;
3998 static const struct hdd_request_params params = {
3999 .priv_size = sizeof(*priv),
4000 .timeout_ms = WLAN_WAIT_TIME_STATS,
4001 };
4002
4003 if (!adapter || !macaddress || !peer_sta_info) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004004 hdd_err("adapter [%pK], macaddress [%pK], peer_sta_info[%pK]",
Will Huang496b36c2017-07-11 16:38:50 +08004005 adapter, macaddress, peer_sta_info);
4006 return -EFAULT;
4007 }
4008
4009 request = hdd_request_alloc(&params);
4010 if (!request) {
4011 hdd_err("Request allocation failure");
4012 return -ENOMEM;
4013 }
4014
4015 cookie = hdd_request_cookie(request);
4016 priv = hdd_request_priv(request);
4017
4018 qdf_mem_copy(&rssi_req.peer_macaddr, macaddress,
4019 QDF_MAC_ADDR_SIZE);
4020 rssi_req.sessionid = adapter->sessionId;
4021 status = sme_get_peer_info(WLAN_HDD_GET_HAL_CTX(adapter),
4022 rssi_req,
4023 cookie,
4024 hdd_get_peer_rssi_cb);
4025 if (status != QDF_STATUS_SUCCESS) {
4026 hdd_err("Unable to retrieve statistics for rssi");
4027 ret = -EFAULT;
4028 } else {
4029 ret = hdd_request_wait_for_response(request);
4030 if (ret) {
4031 hdd_err("SME timed out while retrieving rssi");
4032 ret = -EFAULT;
4033 } else {
4034 *peer_sta_info = priv->peer_sta_info;
4035 ret = 0;
4036 }
4037 }
4038
4039 hdd_request_put(request);
4040
4041 return ret;
4042}
4043
4044struct peer_info_priv {
4045 struct sir_peer_sta_ext_info peer_sta_ext_info;
4046};
4047
4048/**
4049 * wlan_hdd_get_peer_info_cb() - get peer info callback
4050 * @sta_info: pointer of peer information
4051 * @context: get peer info callback context
4052 *
4053 * This function will fill stats info to peer info priv
4054 *
4055 */
4056static void wlan_hdd_get_peer_info_cb(struct sir_peer_info_ext_resp *sta_info,
4057 void *context)
4058{
4059 struct hdd_request *request;
4060 struct peer_info_priv *priv;
4061 uint8_t sta_num;
4062
4063 if ((!sta_info) || (!context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07004064 hdd_err("Bad param, sta_info [%pK] context [%pK]",
Will Huang496b36c2017-07-11 16:38:50 +08004065 sta_info, context);
4066 return;
4067 }
4068
4069 if (!sta_info->count) {
4070 hdd_err("Fail to get remote peer info");
4071 return;
4072 }
4073
4074 if (sta_info->count > MAX_PEER_STA) {
4075 hdd_warn("Exceed max peer number %d", sta_info->count);
4076 sta_num = MAX_PEER_STA;
4077 } else {
4078 sta_num = sta_info->count;
4079 }
4080
4081 request = hdd_request_get(context);
4082 if (!request) {
4083 hdd_err("Obsolete request");
4084 return;
4085 }
4086
4087 priv = hdd_request_priv(request);
4088
4089 priv->peer_sta_ext_info.sta_num = sta_num;
4090 qdf_mem_copy(&priv->peer_sta_ext_info.info,
4091 sta_info->info,
4092 sta_num * sizeof(sta_info->info[0]));
4093
4094 hdd_request_complete(request);
4095 hdd_request_put(request);
4096}
4097
Jeff Johnson3d278b02017-08-29 14:17:47 -07004098int wlan_hdd_get_peer_info(struct hdd_adapter *adapter,
Will Huang496b36c2017-07-11 16:38:50 +08004099 struct qdf_mac_addr macaddress,
4100 struct sir_peer_info_ext *peer_info_ext)
4101{
4102 QDF_STATUS status;
4103 void *cookie;
4104 int ret;
4105 struct sir_peer_info_ext_req peer_info_req;
4106 struct hdd_request *request;
4107 struct peer_info_priv *priv;
4108 static const struct hdd_request_params params = {
4109 .priv_size = sizeof(*priv),
4110 .timeout_ms = WLAN_WAIT_TIME_STATS,
4111 };
4112
4113 if (!adapter) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004114 hdd_err("adapter is NULL");
Will Huang496b36c2017-07-11 16:38:50 +08004115 return -EFAULT;
4116 }
4117
4118 request = hdd_request_alloc(&params);
4119 if (!request) {
4120 hdd_err("Request allocation failure");
4121 return -ENOMEM;
4122 }
4123
4124 cookie = hdd_request_cookie(request);
4125 priv = hdd_request_priv(request);
4126
4127 qdf_mem_copy(&peer_info_req.peer_macaddr, &macaddress,
4128 QDF_MAC_ADDR_SIZE);
4129 peer_info_req.sessionid = adapter->sessionId;
4130 peer_info_req.reset_after_request = 0;
4131 status = sme_get_peer_info_ext(WLAN_HDD_GET_HAL_CTX(adapter),
4132 &peer_info_req,
4133 cookie,
4134 wlan_hdd_get_peer_info_cb);
4135 if (status != QDF_STATUS_SUCCESS) {
4136 hdd_err("Unable to retrieve statistics for peer info");
4137 ret = -EFAULT;
4138 } else {
4139 ret = hdd_request_wait_for_response(request);
4140 if (ret) {
4141 hdd_err("SME timed out while retrieving peer info");
4142 ret = -EFAULT;
4143 } else {
4144 /* only support one peer by now */
4145 *peer_info_ext = priv->peer_sta_ext_info.info[0];
4146 ret = 0;
4147 }
4148 }
4149
4150 hdd_request_put(request);
4151
4152 return ret;
4153}
4154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155/**
4156 * hdd_statistics_cb() - "Get statistics" callback function
4157 * @pStats: statistics payload
4158 * @pContext: opaque context originally passed to SME. HDD always passes
4159 * a pointer to an adapter
4160 *
4161 * Return: None
4162 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004163static void hdd_statistics_cb(void *pStats, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004165 struct hdd_adapter *adapter = (struct hdd_adapter *) pContext;
Jeff Johnson07f94742017-08-14 15:55:40 -07004166 struct hdd_stats *pStatsCache = NULL;
Jeff Johnson2a722002017-09-30 20:02:35 -07004167 struct hdd_wext_state *pWextState;
Anurag Chouhance0dc992016-02-16 18:18:03 +05304168 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169
4170 tCsrSummaryStatsInfo *pSummaryStats = NULL;
4171 tCsrGlobalClassAStatsInfo *pClassAStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 tCsrGlobalClassDStatsInfo *pClassDStats = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004174 if (adapter != NULL)
4175 pStatsCache = &adapter->hdd_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176
4177 pSummaryStats = (tCsrSummaryStatsInfo *) pStats;
4178 pClassAStats = (tCsrGlobalClassAStatsInfo *) (pSummaryStats + 1);
Jeff Johnsonf2dac4f2017-03-16 11:41:31 -07004179 pClassDStats = (tCsrGlobalClassDStatsInfo *) (pClassAStats + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180
4181 if (pStatsCache != NULL) {
4182 /* copy the stats into the cache we keep in the
4183 * adapter instance structure
4184 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304185 qdf_mem_copy(&pStatsCache->summary_stat, pSummaryStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 sizeof(pStatsCache->summary_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304187 qdf_mem_copy(&pStatsCache->ClassA_stat, pClassAStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004188 sizeof(pStatsCache->ClassA_stat));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304189 qdf_mem_copy(&pStatsCache->ClassD_stat, pClassDStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190 sizeof(pStatsCache->ClassD_stat));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191 }
4192
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004193 if (adapter) {
4194 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304195 qdf_status = qdf_event_set(&pWextState->hdd_qdf_event);
Anurag Chouhance0dc992016-02-16 18:18:03 +05304196 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07004197 hdd_err("qdf_event_set failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198 return;
4199 }
4200 }
4201}
4202
4203/**
4204 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004205 * @adapter: adapter who's IEs are to be cleared
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 *
4207 * Return: None
4208 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004209void hdd_clear_roam_profile_ie(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210{
Jeff Johnson731bc322017-10-14 19:53:44 -07004211 struct hdd_station_ctx *sta_ctx;
Jeff Johnson2a722002017-09-30 20:02:35 -07004212 struct hdd_wext_state *pWextState =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004213 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004214
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004215 ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216
4217 /* clear WPA/RSN/WSC IE information in the profile */
4218 pWextState->roamProfile.nWPAReqIELength = 0;
4219 pWextState->roamProfile.pWPAReqIE = (uint8_t *) NULL;
4220 pWextState->roamProfile.nRSNReqIELength = 0;
4221 pWextState->roamProfile.pRSNReqIE = (uint8_t *) NULL;
4222
4223#ifdef FEATURE_WLAN_WAPI
4224 pWextState->roamProfile.nWAPIReqIELength = 0;
4225 pWextState->roamProfile.pWAPIReqIE = (uint8_t *) NULL;
4226#endif
4227
4228 pWextState->roamProfile.bWPSAssociation = false;
4229 pWextState->roamProfile.bOSENAssociation = false;
4230 pWextState->roamProfile.pAddIEScan = (uint8_t *) NULL;
4231 pWextState->roamProfile.nAddIEScanLength = 0;
4232 pWextState->roamProfile.pAddIEAssoc = (uint8_t *) NULL;
4233 pWextState->roamProfile.nAddIEAssocLength = 0;
4234
4235 pWextState->roamProfile.EncryptionType.numEntries = 1;
4236 pWextState->roamProfile.EncryptionType.encryptionType[0]
4237 = eCSR_ENCRYPT_TYPE_NONE;
4238
4239 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4240 pWextState->roamProfile.mcEncryptionType.encryptionType[0]
4241 = eCSR_ENCRYPT_TYPE_NONE;
4242
4243 pWextState->roamProfile.AuthType.numEntries = 1;
4244 pWextState->roamProfile.AuthType.authType[0] =
4245 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4246
Abhishek Singh3c9910e2017-01-06 17:56:47 +05304247 qdf_mem_zero(pWextState->roamProfile.bssid_hint.bytes,
4248 QDF_MAC_ADDR_SIZE);
4249
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250#ifdef WLAN_FEATURE_11W
4251 pWextState->roamProfile.MFPEnabled = false;
4252 pWextState->roamProfile.MFPRequired = 0;
4253 pWextState->roamProfile.MFPCapable = 0;
4254#endif
4255
4256 pWextState->authKeyMgmt = 0;
4257
Yingying Tang3cc6b792016-10-20 17:00:37 +08004258 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength, CSR_MAX_NUM_KEY);
4259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260#ifdef FEATURE_WLAN_WAPI
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004261 adapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_OPEN;
4262 adapter->wapi_info.nWapiMode = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263#endif
4264
Jeff Johnson731bc322017-10-14 19:53:44 -07004265 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
4266 qdf_zero_macaddr(&sta_ctx->requested_bssid);
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -07004267 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268}
4269
4270/**
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304271 * hdd_get_ldpc() - Get adapter LDPC
4272 * @adapter: adapter being queried
4273 * @value: where to store the value
4274 *
4275 * Return: 0 on success, negative errno on failure
4276 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004277int hdd_get_ldpc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304278{
4279 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4280 int ret;
4281
4282 ENTER();
4283 ret = sme_get_ht_config(hal, adapter->sessionId,
4284 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING);
4285 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004286 hdd_err("Failed to get LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304287 } else {
4288 *value = ret;
4289 ret = 0;
4290 }
4291 return ret;
4292}
4293
4294/**
4295 * hdd_set_ldpc() - Set adapter LDPC
4296 * @adapter: adapter being modified
4297 * @value: new LDPC value
4298 *
4299 * Return: 0 on success, negative errno on failure
4300 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004301int hdd_set_ldpc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304302{
4303 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4304 int ret;
4305
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004306 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304307 if (value) {
4308 /* make sure HT capabilities allow this */
4309 QDF_STATUS status;
4310 uint32_t cfg_value;
4311 union {
4312 uint16_t cfg_value16;
4313 tSirMacHTCapabilityInfo ht_cap_info;
4314 } u;
4315
4316 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4317 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004318 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304319 return -EIO;
4320 }
4321 u.cfg_value16 = cfg_value & 0xFFFF;
4322 if (!u.ht_cap_info.advCodingCap) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004323 hdd_err("LDCP not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304324 return -EINVAL;
4325 }
4326 }
4327
4328 ret = sme_update_ht_config(hal, adapter->sessionId,
4329 WNI_CFG_HT_CAP_INFO_ADVANCE_CODING,
4330 value);
4331 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004332 hdd_err("Failed to set LDPC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304333
4334 return ret;
4335}
4336
4337/**
4338 * hdd_get_tx_stbc() - Get adapter TX STBC
4339 * @adapter: adapter being queried
4340 * @value: where to store the value
4341 *
4342 * Return: 0 on success, negative errno on failure
4343 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004344int hdd_get_tx_stbc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304345{
4346 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4347 int ret;
4348
4349 ENTER();
4350 ret = sme_get_ht_config(hal, adapter->sessionId,
4351 WNI_CFG_HT_CAP_INFO_TX_STBC);
4352 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004353 hdd_err("Failed to get TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304354 } else {
4355 *value = ret;
4356 ret = 0;
4357 }
4358
4359 return ret;
4360}
4361
4362/**
4363 * hdd_set_tx_stbc() - Set adapter TX STBC
4364 * @adapter: adapter being modified
4365 * @value: new TX STBC value
4366 *
4367 * Return: 0 on success, negative errno on failure
4368 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004369int hdd_set_tx_stbc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304370{
4371 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4372 int ret;
4373
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004374 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304375 if (value) {
4376 /* make sure HT capabilities allow this */
4377 QDF_STATUS status;
4378 uint32_t cfg_value;
4379 union {
4380 uint16_t cfg_value16;
4381 tSirMacHTCapabilityInfo ht_cap_info;
4382 } u;
4383
4384 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4385 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004386 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304387 return -EIO;
4388 }
4389 u.cfg_value16 = cfg_value & 0xFFFF;
4390 if (!u.ht_cap_info.txSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004391 hdd_err("TX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304392 return -EINVAL;
4393 }
4394 }
4395 ret = sme_update_ht_config(hal, adapter->sessionId,
4396 WNI_CFG_HT_CAP_INFO_TX_STBC,
4397 value);
4398 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004399 hdd_err("Failed to set TX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304400
4401 return ret;
4402}
4403
4404/**
4405 * hdd_get_rx_stbc() - Get adapter RX STBC
4406 * @adapter: adapter being queried
4407 * @value: where to store the value
4408 *
4409 * Return: 0 on success, negative errno on failure
4410 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004411int hdd_get_rx_stbc(struct hdd_adapter *adapter, int *value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304412{
4413 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4414 int ret;
4415
4416 ENTER();
4417 ret = sme_get_ht_config(hal, adapter->sessionId,
4418 WNI_CFG_HT_CAP_INFO_RX_STBC);
4419 if (ret < 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004420 hdd_err("Failed to get RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304421 } else {
4422 *value = ret;
4423 ret = 0;
4424 }
4425
4426 return ret;
4427}
4428
4429/**
4430 * hdd_set_rx_stbc() - Set adapter RX STBC
4431 * @adapter: adapter being modified
4432 * @value: new RX STBC value
4433 *
4434 * Return: 0 on success, negative errno on failure
4435 */
Jeff Johnson3d278b02017-08-29 14:17:47 -07004436int hdd_set_rx_stbc(struct hdd_adapter *adapter, int value)
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304437{
4438 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
4439 int ret;
4440
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004441 hdd_debug("%d", value);
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304442 if (value) {
4443 /* make sure HT capabilities allow this */
4444 QDF_STATUS status;
4445 uint32_t cfg_value;
4446 union {
4447 uint16_t cfg_value16;
4448 tSirMacHTCapabilityInfo ht_cap_info;
4449 } u;
4450
4451 status = sme_cfg_get_int(hal, WNI_CFG_HT_CAP_INFO, &cfg_value);
4452 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004453 hdd_err("Failed to get HT capability info");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304454 return -EIO;
4455 }
4456 u.cfg_value16 = cfg_value & 0xFFFF;
4457 if (!u.ht_cap_info.rxSTBC) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004458 hdd_warn("RX STBC not supported");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304459 return -EINVAL;
4460 }
4461 }
4462 ret = sme_update_ht_config(hal, adapter->sessionId,
4463 WNI_CFG_HT_CAP_INFO_RX_STBC,
4464 value);
4465 if (ret)
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004466 hdd_err("Failed to set RX STBC value");
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304467
4468 return ret;
4469}
4470
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004471int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate)
4472{
4473 int set_value;
4474
4475 if (sme_is_feature_supported_by_fw(DOT11AX))
4476 set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble);
4477 else
4478 set_value = (preamble << 6) | (nss << 4) | rate;
4479
4480 return set_value;
4481}
4482
Jeff Johnson3d278b02017-08-29 14:17:47 -07004483int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004484 struct sap_Config *sap_config)
4485{
4486 uint8_t preamble = 0, nss = 0, rix = 0;
4487 int ret;
4488
4489 if (!sap_config) {
4490 if (!sme_is_feature_supported_by_fw(DOT11AX)) {
4491 hdd_err("Target does not support 11ax");
4492 return -EIO;
4493 }
4494 } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax &&
4495 sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07004496 hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d",
4497 sap_config->SapHw_mode, sap_config->channel);
4498 return -EIO;
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08004499 }
4500
4501 if (set_value != 0xff) {
4502 rix = RC_2_RATE_IDX_11AX(set_value);
4503 preamble = WMI_RATE_PREAMBLE_HE;
4504 nss = HT_RC_2_STREAMS_11AX(set_value);
4505
4506 set_value = hdd_assemble_rate_code(preamble, nss, rix);
4507 }
4508
4509 hdd_notice("SET_11AX_RATE val %d rix %d preamble %x nss %d",
4510 set_value, rix, preamble, nss);
4511
4512 ret = wma_cli_set_command(adapter->sessionId,
4513 WMI_VDEV_PARAM_FIXED_RATE,
4514 set_value, VDEV_CMD);
4515
4516 return ret;
4517}
4518
Manjeet Singhe80d6d82016-09-02 19:04:41 +05304519/**
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004520 * hdd_get_aid_rc() - Get AID and rate code passed from user
4521 * @aid: pointer to AID
4522 * @rc: pointer to rate code
4523 * @set_value: value passed from user
4524 *
4525 * If target is 11ax capable, set_value will have AID left shifted 16 bits
4526 * and 16 bits for rate code. If the target is not 11ax capable, rate code
4527 * will only be 8 bits.
4528 *
4529 * Return: None
4530 */
4531static void hdd_get_aid_rc(uint8_t *aid, uint16_t *rc, int set_value)
4532{
4533 uint8_t rc_bits;
4534
4535 if (sme_is_feature_supported_by_fw(DOT11AX))
4536 rc_bits = 16;
4537 else
4538 rc_bits = 8;
4539
4540 *aid = set_value >> rc_bits;
4541 *rc = set_value & ((1 << (rc_bits + 1)) - 1);
4542}
4543
Jeff Johnson3d278b02017-08-29 14:17:47 -07004544int hdd_set_peer_rate(struct hdd_adapter *adapter, int set_value)
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -08004545{
4546 uint8_t aid, *peer_mac;
4547 uint16_t rc;
4548 QDF_STATUS status;
4549
4550 if (adapter->device_mode != QDF_SAP_MODE) {
4551 hdd_err("Invalid devicde mode - %d", adapter->device_mode);
4552 return -EINVAL;
4553 }
4554
4555 hdd_get_aid_rc(&aid, &rc, set_value);
4556
4557 if ((adapter->aStaInfo[aid].isUsed) &&
4558 (OL_TXRX_PEER_STATE_CONN == adapter->aStaInfo[aid].tlSTAState)) {
4559 peer_mac =
4560 (uint8_t *)&(adapter->aStaInfo[aid].macAddrSTA.bytes[0]);
4561 hdd_info("Peer AID: %d MAC_ADDR: "MAC_ADDRESS_STR,
4562 aid, MAC_ADDR_ARRAY(peer_mac));
4563 } else {
4564 hdd_err("No matching peer found for AID: %d", aid);
4565 return -EINVAL;
4566 }
4567
4568 status = sme_set_peer_param(peer_mac, WMI_PEER_PARAM_FIXED_RATE,
4569 rc, adapter->sessionId);
4570 if (status != QDF_STATUS_SUCCESS) {
4571 hdd_err("Failed to set peer fixed rate - status: %d", status);
4572 return -EIO;
4573 }
4574
4575 return 0;
4576}
4577
4578/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 * __iw_set_commit() - SIOCSIWCOMMIT ioctl handler
4580 * @dev: device upon which the ioctl was received
4581 * @info: ioctl request information
4582 * @wrqu: ioctl request data
4583 * @extra: ioctl extra data
4584 *
4585 * Return: 0 on success, non-zero on error
4586 */
4587static int __iw_set_commit(struct net_device *dev, struct iw_request_info *info,
4588 union iwreq_data *wrqu, char *extra)
4589{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004590 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004591 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 int ret;
4593
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004594 ENTER_DEV(dev);
4595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4597 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4598 ret = wlan_hdd_validate_context(hdd_ctx);
4599 if (0 != ret)
4600 return ret;
4601
Jeff Johnson441e1f72017-02-07 08:50:49 -08004602 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4603 if (0 != ret)
4604 return ret;
4605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 /* Do nothing for now */
4607 return 0;
4608}
4609
4610/**
4611 * iw_set_commit() - SSR wrapper function for __iw_set_commit
4612 * @dev: pointer to net_device
4613 * @info: pointer to iw_request_info
4614 * @wrqu: pointer to iwreq_data
4615 * @extra: extra
4616 *
4617 * Return: 0 on success, error number otherwise
4618 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07004619static int iw_set_commit(struct net_device *dev, struct iw_request_info *info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 union iwreq_data *wrqu, char *extra)
4621{
4622 int ret;
4623
4624 cds_ssr_protect(__func__);
4625 ret = __iw_set_commit(dev, info, wrqu, extra);
4626 cds_ssr_unprotect(__func__);
4627
4628 return ret;
4629}
4630
4631/**
4632 * __iw_get_name() - SIOCGIWNAME ioctl handler
4633 * @dev: device upon which the ioctl was received
4634 * @info: ioctl request information
4635 * @wrqu: ioctl request data
4636 * @extra: ioctl extra data
4637 *
4638 * Return: 0 on success, non-zero on error
4639 */
4640static int __iw_get_name(struct net_device *dev,
4641 struct iw_request_info *info, char *wrqu, char *extra)
4642{
Jeff Johnson3d278b02017-08-29 14:17:47 -07004643 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004644 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 int ret;
4646
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004647 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648
4649 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
4650 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
4651 ret = wlan_hdd_validate_context(hdd_ctx);
4652 if (0 != ret)
4653 return ret;
4654
Jeff Johnson441e1f72017-02-07 08:50:49 -08004655 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4656 if (0 != ret)
4657 return ret;
4658
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659 strlcpy(wrqu, "Qcom:802.11n", IFNAMSIZ);
4660 EXIT();
4661 return 0;
4662}
4663
4664/**
4665 * __iw_get_name() - SSR wrapper for __iw_get_name
4666 * @dev: pointer to net_device
4667 * @info: pointer to iw_request_info
4668 * @wrqu: pointer to iwreq_data
4669 * @extra: extra
4670 *
4671 * Return: 0 on success, error number otherwise
4672 */
4673static int iw_get_name(struct net_device *dev,
4674 struct iw_request_info *info,
4675 char *wrqu, char *extra)
4676{
4677 int ret;
4678
4679 cds_ssr_protect(__func__);
4680 ret = __iw_get_name(dev, info, wrqu, extra);
4681 cds_ssr_unprotect(__func__);
4682
4683 return ret;
4684}
4685
4686/**
4687 * __iw_set_mode() - ioctl handler
4688 * @dev: device upon which the ioctl was received
4689 * @info: ioctl request information
4690 * @wrqu: ioctl request data
4691 * @extra: ioctl extra data
4692 *
4693 * Return: 0 on success, non-zero on error
4694 */
4695static int __iw_set_mode(struct net_device *dev,
4696 struct iw_request_info *info,
4697 union iwreq_data *wrqu, char *extra)
4698{
Jeff Johnson2a722002017-09-30 20:02:35 -07004699 struct hdd_wext_state *pWextState;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004700 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004701 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004702 tCsrRoamProfile *pRoamProfile;
4703 eCsrRoamBssType LastBSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 struct hdd_config *pConfig;
4705 struct wireless_dev *wdev;
4706 int ret;
4707
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004708 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004710 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711 ret = wlan_hdd_validate_context(hdd_ctx);
4712 if (0 != ret)
4713 return ret;
4714
Jeff Johnson441e1f72017-02-07 08:50:49 -08004715 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4716 if (0 != ret)
4717 return ret;
4718
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004719 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720 wdev = dev->ieee80211_ptr;
4721 pRoamProfile = &pWextState->roamProfile;
4722 LastBSSType = pRoamProfile->BSSType;
4723
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004724 hdd_debug("Old Bss type = %d", LastBSSType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725
4726 switch (wrqu->mode) {
4727 case IW_MODE_ADHOC:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004728 hdd_debug("Setting AP Mode as IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
4730 /* Set the phymode correctly for IBSS. */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004731 pConfig = (WLAN_HDD_GET_CTX(adapter))->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732 pWextState->roamProfile.phyMode =
4733 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004734 adapter->device_mode = QDF_IBSS_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004735 wdev->iftype = NL80211_IFTYPE_ADHOC;
4736 break;
4737 case IW_MODE_INFRA:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004738 hdd_debug("Setting AP Mode as IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004739 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
4740 wdev->iftype = NL80211_IFTYPE_STATION;
4741 break;
4742 case IW_MODE_AUTO:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004743 hdd_debug("Setting AP Mode as IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004744 pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
4745 break;
4746 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07004747 hdd_err("Unknown AP Mode value %d", wrqu->mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 return -EOPNOTSUPP;
4749 }
4750
4751 if (LastBSSType != pRoamProfile->BSSType) {
4752 /* the BSS mode changed. We need to issue disconnect
4753 * if connected or in IBSS disconnect state
4754 */
Jeff Johnson9eeed0a2016-10-03 15:04:57 -07004755 if (hdd_conn_is_connected
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004756 (WLAN_HDD_GET_STATION_CTX_PTR(adapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757 || (eCSR_BSS_TYPE_START_IBSS == LastBSSType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304758 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759 /* need to issue a disconnect to CSR. */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004760 INIT_COMPLETION(adapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304761 qdf_status =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004762 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(adapter),
4763 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304765 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004767
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004768 rc = wait_for_completion_timeout(&adapter->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004769 disconnect_comp_var,
4770 msecs_to_jiffies
4771 (WLAN_WAIT_TIME_DISCONNECT));
4772 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004773 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004774 }
4775 }
4776 }
4777
4778 EXIT();
4779 return 0;
4780}
4781
4782/**
4783 * iw_set_mode() - SSR wrapper for __iw_set_mode()
4784 * @dev: pointer to net_device
4785 * @info: pointer to iw_request_info
4786 * @wrqu: pointer to iwreq_data
4787 * @extra: pointer to extra ioctl payload
4788 *
4789 * Return: 0 on success, error number otherwise
4790 */
4791static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
4792 union iwreq_data *wrqu, char *extra)
4793{
4794 int ret;
4795
4796 cds_ssr_protect(__func__);
4797 ret = __iw_set_mode(dev, info, wrqu, extra);
4798 cds_ssr_unprotect(__func__);
4799
4800 return ret;
4801}
4802
4803/**
4804 * __iw_get_mode() - SIOCGIWMODE ioctl handler
4805 * @dev: device upon which the ioctl was received
4806 * @info: ioctl request information
4807 * @wrqu: ioctl request data
4808 * @extra: ioctl extra data
4809 *
4810 * Return: 0 on success, non-zero on error
4811 */
4812static int
4813__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4814 union iwreq_data *wrqu, char *extra)
4815{
Jeff Johnson2a722002017-09-30 20:02:35 -07004816 struct hdd_wext_state *pWextState;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004817 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004818 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004819 int ret;
4820
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004821 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004823 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004824 ret = wlan_hdd_validate_context(hdd_ctx);
4825 if (0 != ret)
4826 return ret;
4827
Jeff Johnson441e1f72017-02-07 08:50:49 -08004828 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4829 if (0 != ret)
4830 return ret;
4831
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004832 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004833
4834 switch (pWextState->roamProfile.BSSType) {
4835 case eCSR_BSS_TYPE_INFRASTRUCTURE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004836 hdd_debug("returns IW_MODE_INFRA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837 wrqu->mode = IW_MODE_INFRA;
4838 break;
4839 case eCSR_BSS_TYPE_IBSS:
4840 case eCSR_BSS_TYPE_START_IBSS:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004841 hdd_debug("returns IW_MODE_ADHOC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 wrqu->mode = IW_MODE_ADHOC;
4843 break;
4844 case eCSR_BSS_TYPE_ANY:
4845 default:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004846 hdd_debug("returns IW_MODE_AUTO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847 wrqu->mode = IW_MODE_AUTO;
4848 break;
4849 }
4850
4851 EXIT();
4852 return 0;
4853}
4854
4855/**
4856 * iw_get_mode() - SSR wrapper for __iw_get_mode()
4857 * @dev: pointer to net_device
4858 * @info: pointer to iw_request_info
4859 * @wrqu: pointer to iwreq_data
4860 * @extra: pointer to extra ioctl payload
4861 *
4862 * Return: 0 on success, error number otherwise
4863 */
4864static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
4865 union iwreq_data *wrqu, char *extra)
4866{
4867 int ret;
4868
4869 cds_ssr_protect(__func__);
4870 ret = __iw_get_mode(dev, info, wrqu, extra);
4871 cds_ssr_unprotect(__func__);
4872
4873 return ret;
4874}
4875
4876/**
4877 * __iw_set_freq() - SIOCSIWFREQ ioctl handler
4878 * @dev: device upon which the ioctl was received
4879 * @info: ioctl request information
4880 * @wrqu: ioctl request data
4881 * @extra: ioctl extra data
4882 *
4883 * Return: 0 on success, non-zero on error
4884 */
4885static int __iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4886 union iwreq_data *wrqu, char *extra)
4887{
4888 uint32_t numChans = 0;
4889 uint8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4890 uint32_t indx = 0;
4891 int ret;
Jeff Johnson2a722002017-09-30 20:02:35 -07004892 struct hdd_wext_state *pWextState;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004893 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07004894 struct hdd_context *hdd_ctx;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004895 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004896 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004897 tCsrRoamProfile *pRoamProfile;
4898
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004899 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004901 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004902 ret = wlan_hdd_validate_context(hdd_ctx);
4903 if (0 != ret)
4904 return ret;
4905
Jeff Johnson441e1f72017-02-07 08:50:49 -08004906 ret = hdd_check_standard_wext_control(hdd_ctx, info);
4907 if (0 != ret)
4908 return ret;
4909
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07004910 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911
4912 pRoamProfile = &pWextState->roamProfile;
4913
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 /* Link is up then return cant set channel */
Jeff Johnsond377dce2017-10-04 10:32:42 -07004915 if (eConnectionState_IbssConnected == sta_ctx->conn_info.connState ||
4916 eConnectionState_Associated == sta_ctx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004917 hdd_debug("IBSS Associated");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918 return -EOPNOTSUPP;
4919 }
4920
4921 /* Settings by Frequency as input */
4922 if ((wrqu->freq.e == 1) && (wrqu->freq.m >= (uint32_t) 2.412e8) &&
4923 (wrqu->freq.m <= (uint32_t) 5.825e8)) {
4924 uint32_t freq = wrqu->freq.m / 100000;
4925
4926 while ((indx < FREQ_CHAN_MAP_TABLE_SIZE)
4927 && (freq != freq_chan_map[indx].freq))
4928 indx++;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004929 if (indx >= FREQ_CHAN_MAP_TABLE_SIZE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004930 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004931
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932 wrqu->freq.e = 0;
4933 wrqu->freq.m = freq_chan_map[indx].chan;
4934
4935 }
4936
4937 if (wrqu->freq.e == 0) {
4938 if ((wrqu->freq.m < WNI_CFG_CURRENT_CHANNEL_STAMIN) ||
4939 (wrqu->freq.m > WNI_CFG_CURRENT_CHANNEL_STAMAX)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004940 hdd_debug("Channel %d is not in range[%d to %d]",
Jeff Johnson99bac312016-06-28 10:38:18 -07004941 wrqu->freq.m,
4942 WNI_CFG_CURRENT_CHANNEL_STAMIN,
4943 WNI_CFG_CURRENT_CHANNEL_STAMAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 return -EINVAL;
4945 }
4946
4947 numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4948
4949 if (sme_cfg_get_str(hHal, WNI_CFG_VALID_CHANNEL_LIST,
4950 validChan, &numChans) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304951 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004952 hdd_err("WNI_CFG_VALID_CHANNEL_LIST failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 return -EIO;
4954 }
4955
4956 for (indx = 0; indx < numChans; indx++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004957 if (wrqu->freq.m == validChan[indx])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959 }
4960 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 return -EINVAL;
4962 }
4963
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07004964 if (indx >= numChans)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004965 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004966
4967 /* Set the Operational Channel */
4968 numChans = pRoamProfile->ChannelInfo.numOfChannels = 1;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004969 sta_ctx->conn_info.operationChannel = wrqu->freq.m;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 pRoamProfile->ChannelInfo.ChannelList =
Jeff Johnsond377dce2017-10-04 10:32:42 -07004971 &sta_ctx->conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004972
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08004973 hdd_debug("pRoamProfile->operationChannel = %d", wrqu->freq.m);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974
4975 EXIT();
4976
4977 return ret;
4978}
4979
4980/**
4981 * iw_set_freq() - SSR wrapper for __iw_set_freq()
4982 * @dev: pointer to net_device
4983 * @info: pointer to iw_request_info
4984 * @wrqu: pointer to iwreq_data
4985 * @extra: pointer to extra ioctl payload
4986 *
4987 * Return: 0 on success, error number otherwise
4988 */
4989static int iw_set_freq(struct net_device *dev, struct iw_request_info *info,
4990 union iwreq_data *wrqu, char *extra)
4991{
4992 int ret;
4993
4994 cds_ssr_protect(__func__);
4995 ret = __iw_set_freq(dev, info, wrqu, extra);
4996 cds_ssr_unprotect(__func__);
4997
4998 return ret;
4999}
5000
5001/**
5002 * __iw_get_freq() - SIOCGIWFREQ ioctl handler
5003 * @dev: device upon which the ioctl was received
5004 * @info: ioctl request information
5005 * @wrqu: ioctl request data
5006 * @extra: ioctl extra data
5007 *
5008 * Return: 0 on success, non-zero on error
5009 */
5010static int __iw_get_freq(struct net_device *dev, struct iw_request_info *info,
5011 struct iw_freq *fwrq, char *extra)
5012{
5013 uint32_t status = false, channel = 0, freq = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005014 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015 tHalHandle hHal;
Jeff Johnson2a722002017-09-30 20:02:35 -07005016 struct hdd_wext_state *pWextState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 tCsrRoamProfile *pRoamProfile;
Jeff Johnsond377dce2017-10-04 10:32:42 -07005018 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005019 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005020 int ret;
5021
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005022 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005023
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005024 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005025 ret = wlan_hdd_validate_context(hdd_ctx);
5026 if (0 != ret)
5027 return ret;
5028
Jeff Johnson441e1f72017-02-07 08:50:49 -08005029 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5030 if (0 != ret)
5031 return ret;
5032
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005033 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
5034 hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035
5036 pRoamProfile = &pWextState->roamProfile;
5037
Jeff Johnsond377dce2017-10-04 10:32:42 -07005038 if (sta_ctx->conn_info.connState == eConnectionState_Associated) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005039 if (sme_get_operation_channel(hHal, &channel,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005040 adapter->sessionId) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005041 hdd_err("failed to get operating channel %u",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005042 adapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005043 return -EIO;
Jeff Johnson68755312017-02-10 11:46:55 -08005044 }
Jeff Johnson68755312017-02-10 11:46:55 -08005045 status = hdd_wlan_get_freq(channel, &freq);
5046 if (true == status) {
5047 /* Set Exponent parameter as 6 (MHZ)
5048 * in struct iw_freq iwlist & iwconfig
5049 * command shows frequency into proper
5050 * format (2.412 GHz instead of 246.2
5051 * MHz)
5052 */
5053 fwrq->m = freq;
5054 fwrq->e = MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055 }
5056 } else {
5057 /* Set Exponent parameter as 6 (MHZ) in struct iw_freq
5058 * iwlist & iwconfig command shows frequency into proper
5059 * format (2.412 GHz instead of 246.2 MHz)
5060 */
5061 fwrq->m = 0;
5062 fwrq->e = MHZ;
5063 }
5064 return 0;
5065}
5066
5067/**
5068 * iw_get_freq() - SSR wrapper for __iw_get_freq()
5069 * @dev: pointer to net_device
5070 * @info: pointer to iw_request_info
5071 * @fwrq: pointer to frequency data
5072 * @extra: pointer to extra ioctl payload
5073 *
5074 * Return: 0 on success, error number otherwise
5075 */
5076static int iw_get_freq(struct net_device *dev, struct iw_request_info *info,
5077 struct iw_freq *fwrq, char *extra)
5078{
5079 int ret;
5080
5081 cds_ssr_protect(__func__);
5082 ret = __iw_get_freq(dev, info, fwrq, extra);
5083 cds_ssr_unprotect(__func__);
5084
5085 return ret;
5086}
5087
5088/**
5089 * __iw_get_tx_power() - SIOCGIWTXPOW ioctl handler
5090 * @dev: device upon which the ioctl was received
5091 * @info: ioctl request information
5092 * @wrqu: ioctl request data
5093 * @extra: ioctl extra data
5094 *
5095 * Return: 0 on success, non-zero on error
5096 */
5097static int __iw_get_tx_power(struct net_device *dev,
5098 struct iw_request_info *info,
5099 union iwreq_data *wrqu, char *extra)
5100{
5101
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005102 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5103 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005104 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105 int ret;
5106
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005107 ENTER_DEV(dev);
5108
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 ret = wlan_hdd_validate_context(hdd_ctx);
5110 if (0 != ret)
5111 return ret;
5112
Jeff Johnson441e1f72017-02-07 08:50:49 -08005113 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5114 if (0 != ret)
5115 return ret;
5116
Jeff Johnsond377dce2017-10-04 10:32:42 -07005117 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005118 wrqu->txpower.value = 0;
5119 return 0;
5120 }
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005121 wlan_hdd_get_class_astats(adapter);
5122 wrqu->txpower.value = adapter->hdd_stats.ClassA_stat.max_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123
5124 return 0;
5125}
5126
5127/**
5128 * iw_get_tx_power() - SSR wrapper for __iw_get_tx_power()
5129 * @dev: pointer to net_device
5130 * @info: pointer to iw_request_info
5131 * @wrqu: pointer to iwreq_data
5132 * @extra: pointer to extra ioctl payload
5133 *
5134 * Return: 0 on success, error number otherwise
5135 */
5136static int iw_get_tx_power(struct net_device *dev,
5137 struct iw_request_info *info,
5138 union iwreq_data *wrqu, char *extra)
5139{
5140 int ret;
5141
5142 cds_ssr_protect(__func__);
5143 ret = __iw_get_tx_power(dev, info, wrqu, extra);
5144 cds_ssr_unprotect(__func__);
5145
5146 return ret;
5147}
5148
5149/**
5150 * __iw_set_tx_power() - SIOCSIWTXPOW ioctl handler
5151 * @dev: device upon which the ioctl was received
5152 * @info: ioctl request information
5153 * @wrqu: ioctl request data
5154 * @extra: ioctl extra data
5155 *
5156 * Return: 0 on success, non-zero on error
5157 */
5158static int __iw_set_tx_power(struct net_device *dev,
5159 struct iw_request_info *info,
5160 union iwreq_data *wrqu, char *extra)
5161{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005162 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5163 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005164 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165 int ret;
5166
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005167 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005168
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005169 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005170 ret = wlan_hdd_validate_context(hdd_ctx);
5171 if (0 != ret)
5172 return ret;
5173
Jeff Johnson441e1f72017-02-07 08:50:49 -08005174 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5175 if (0 != ret)
5176 return ret;
5177
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005178 if (sme_cfg_set_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305179 wrqu->txpower.value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005180 hdd_err("WNI_CFG_CURRENT_TX_POWER_LEVEL failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005181 return -EIO;
5182 }
5183
5184 EXIT();
5185
5186 return 0;
5187}
5188
5189/**
5190 * iw_set_tx_power() - SSR wrapper for __iw_set_tx_power()
5191 * @dev: pointer to net_device
5192 * @info: pointer to iw_request_info
5193 * @wrqu: pointer to iwreq_data
5194 * @extra: pointer to extra ioctl payload
5195 *
5196 * Return: 0 on success, error number otherwise
5197 */
5198static int iw_set_tx_power(struct net_device *dev,
5199 struct iw_request_info *info,
5200 union iwreq_data *wrqu, char *extra)
5201{
5202 int ret;
5203
5204 cds_ssr_protect(__func__);
5205 ret = __iw_set_tx_power(dev, info, wrqu, extra);
5206 cds_ssr_unprotect(__func__);
5207
5208 return ret;
5209}
5210
5211/**
5212 * __iw_get_bitrate() - SIOCGIWRATE ioctl handler
5213 * @dev: device upon which the ioctl was received
5214 * @info: ioctl request information
5215 * @wrqu: ioctl request data
5216 * @extra: ioctl extra data
5217 *
5218 * Return: 0 on success, non-zero on error
5219 */
5220static int __iw_get_bitrate(struct net_device *dev,
5221 struct iw_request_info *info,
5222 union iwreq_data *wrqu, char *extra)
5223{
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005224 QDF_STATUS status;
Jeff Johnson2a722002017-09-30 20:02:35 -07005225 struct hdd_wext_state *pWextState;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005226 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005227 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005228 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229 int ret;
5230
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005231 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005232
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005233 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234 ret = wlan_hdd_validate_context(hdd_ctx);
5235 if (0 != ret)
5236 return ret;
5237
Jeff Johnson441e1f72017-02-07 08:50:49 -08005238 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5239 if (0 != ret)
5240 return ret;
5241
Jeff Johnsond377dce2017-10-04 10:32:42 -07005242 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005243 wrqu->bitrate.value = 0;
5244 } else {
5245 status =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005246 sme_get_statistics(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247 eCSR_HDD,
5248 SME_SUMMARY_STATS |
5249 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -08005250 SME_GLOBAL_CLASSD_STATS,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07005251 hdd_statistics_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07005252 sta_ctx->conn_info.staId[0],
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005253 adapter, adapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005254
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305255 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005256 hdd_err("Unable to retrieve statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005257 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005258 }
5259
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005260 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005261
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005262 status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305263 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005264 WLAN_WAIT_TIME_STATS);
5265
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005266 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005267 hdd_err("SME timeout while retrieving statistics");
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005268 return qdf_status_to_os_return(status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005269 }
5270
5271 wrqu->bitrate.value =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005272 adapter->hdd_stats.ClassA_stat.tx_rate * 500 * 1000;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005273 }
5274
5275 EXIT();
5276
Jeff Johnsonf25ac102017-02-07 09:16:02 -08005277 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278}
5279
5280/**
5281 * iw_get_bitrate() - SSR wrapper for __iw_get_bitrate()
5282 * @dev: pointer to net_device
5283 * @info: pointer to iw_request_info
5284 * @wrqu: pointer to iwreq_data
5285 * @extra: pointer to extra ioctl payload
5286 *
5287 * Return: 0 on success, error number otherwise
5288 */
5289static int iw_get_bitrate(struct net_device *dev,
5290 struct iw_request_info *info,
5291 union iwreq_data *wrqu, char *extra)
5292{
5293 int ret;
5294
5295 cds_ssr_protect(__func__);
5296 ret = __iw_get_bitrate(dev, info, wrqu, extra);
5297 cds_ssr_unprotect(__func__);
5298
5299 return ret;
5300}
5301
5302/**
5303 * __iw_set_bitrate() - SIOCSIWRATE ioctl handler
5304 * @dev: device upon which the ioctl was received
5305 * @info: ioctl request information
5306 * @wrqu: ioctl request data
5307 * @extra: ioctl extra data
5308 *
5309 * Return: 0 on success, non-zero on error
5310 */
5311static int __iw_set_bitrate(struct net_device *dev,
5312 struct iw_request_info *info,
5313 union iwreq_data *wrqu, char *extra)
5314{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005315 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson2a722002017-09-30 20:02:35 -07005316 struct hdd_wext_state *pWextState;
Jeff Johnsond377dce2017-10-04 10:32:42 -07005317 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
5319 uint32_t a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
5320 uint32_t b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
5321 uint32_t i, rate;
5322 uint32_t valid_rate = false, active_phy_mode = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005323 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324 int ret;
5325
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005326 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005328 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005329 ret = wlan_hdd_validate_context(hdd_ctx);
5330 if (0 != ret)
5331 return ret;
5332
Jeff Johnson441e1f72017-02-07 08:50:49 -08005333 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5334 if (0 != ret)
5335 return ret;
5336
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005337 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338
Jeff Johnsond377dce2017-10-04 10:32:42 -07005339 if (eConnectionState_Associated != sta_ctx->conn_info.connState)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341
5342 rate = wrqu->bitrate.value;
5343
5344 if (rate == -1) {
5345 rate = WNI_CFG_FIXED_RATE_AUTO;
5346 valid_rate = true;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005347 } else if (sme_cfg_get_int(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005348 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305349 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005350 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
5351 || active_phy_mode == WNI_CFG_DOT11_MODE_11G
5352 || active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005353 if ((sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354 WNI_CFG_SUPPORTED_RATES_11A, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305355 &a_len) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356 &&
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005357 (sme_cfg_get_str(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005358 WNI_CFG_SUPPORTED_RATES_11B, supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305359 &b_len) == QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360 for (i = 0; i < (b_len + a_len); ++i) {
5361 /* supported rates returned is double
5362 * the actual rate so we divide it by 2
5363 */
5364 if ((supp_rates[i] & 0x7F) / 2 ==
5365 rate) {
5366 valid_rate = true;
5367 rate = i +
5368 WNI_CFG_FIXED_RATE_1MBPS;
5369 break;
5370 }
5371 }
5372 }
5373 }
5374 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005375 if (valid_rate != true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005377
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005378 if (sme_cfg_set_int(WLAN_HDD_GET_HAL_CTX(adapter),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305379 WNI_CFG_FIXED_RATE, rate) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005380 hdd_err("failed to set ini parameter, WNI_CFG_FIXED_RATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381 return -EIO;
5382 }
5383 return 0;
5384}
5385
5386/**
5387 * iw_set_bitrate() - SSR wrapper for __iw_set_bitrate()
5388 * @dev: pointer to net_device
5389 * @info: pointer to iw_request_info
5390 * @wrqu: pointer to iwreq_data
5391 * @extra: pointer to extra ioctl payload
5392 *
5393 * Return: 0 on success, error number otherwise
5394 */
5395static int iw_set_bitrate(struct net_device *dev,
5396 struct iw_request_info *info,
5397 union iwreq_data *wrqu, char *extra)
5398{
5399 int ret;
5400
5401 cds_ssr_protect(__func__);
5402 ret = __iw_set_bitrate(dev, info, wrqu, extra);
5403 cds_ssr_unprotect(__func__);
5404
5405 return ret;
5406}
5407
5408/**
5409 * __iw_set_genie() - SIOCSIWGENIE ioctl handler
5410 * @dev: device upon which the ioctl was received
5411 * @info: ioctl request information
5412 * @wrqu: ioctl request data
5413 * @extra: ioctl extra data
5414 *
5415 * Return: 0 on success, non-zero on error
5416 */
5417static int __iw_set_genie(struct net_device *dev,
5418 struct iw_request_info *info,
5419 union iwreq_data *wrqu, char *extra)
5420{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005421 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson2a722002017-09-30 20:02:35 -07005422 struct hdd_wext_state *pWextState =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005423 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424 uint8_t *genie = NULL;
5425 uint8_t *base_genie = NULL;
5426 uint16_t remLen;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005427 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 int ret;
5429
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005430 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005431
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005432 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 ret = wlan_hdd_validate_context(hdd_ctx);
5434 if (0 != ret)
5435 return ret;
5436
Jeff Johnson441e1f72017-02-07 08:50:49 -08005437 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5438 if (0 != ret)
5439 return ret;
5440
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441 if (!wrqu->data.length) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005442 hdd_clear_roam_profile_ie(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443 EXIT();
5444 return 0;
5445 }
5446
5447 base_genie = mem_alloc_copy_from_user_helper(wrqu->data.pointer,
5448 wrqu->data.length);
5449 if (NULL == base_genie) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005450 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 return -ENOMEM;
5452 }
5453
5454 genie = base_genie;
5455
5456 remLen = wrqu->data.length;
5457
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005458 hdd_debug("iw_set_genie ioctl IE[0x%X], LEN[%d]", genie[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005459 genie[1]);
5460
5461 /* clear any previous genIE before this call */
5462 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5463
5464 while (remLen >= 2) {
5465 uint16_t eLen = 0;
5466 uint8_t elementId;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005467
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468 elementId = *genie++;
5469 eLen = *genie++;
5470 remLen -= 2;
5471
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005472 hdd_debug("IE[0x%X], LEN[%d]", elementId, eLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005473
Srinivas Girigowda9eb807b2017-01-06 11:08:28 -08005474 if (remLen < eLen) {
5475 hdd_err("Remaining len: %u less than ie len: %u",
5476 remLen, eLen);
5477 ret = -EINVAL;
5478 goto exit;
5479 }
5480
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005481 switch (elementId) {
5482 case IE_EID_VENDOR:
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005483 /* should have at least OUI */
5484 if ((IE_LEN_SIZE + IE_EID_SIZE + IE_VENDOR_OUI_SIZE) > eLen) {
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305485 ret = -EINVAL;
5486 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487 }
5488
5489 if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) {
5490 uint16_t curGenIELen = pWextState->genIE.length;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005491
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005492 hdd_debug("Set WPS OUI(%02x %02x %02x %02x) IE(len %d)",
Jeff Johnson99bac312016-06-28 10:38:18 -07005493 genie[0], genie[1], genie[2],
5494 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495
5496 if (SIR_MAC_MAX_IE_LENGTH <
5497 (pWextState->genIE.length + eLen)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005498 hdd_err("genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305499 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305500 ret = -ENOMEM;
5501 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005503 /* save to Additional IE; it should be
5504 * accumulated to handle WPS IE + other IE
5505 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506 memcpy(pWextState->genIE.addIEdata +
5507 curGenIELen, genie - 2, eLen + 2);
5508 pWextState->genIE.length += eLen + 2;
5509 } else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005510 hdd_debug("Set WPA IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305511 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005512 hdd_err("genIE, Need bigger buffer space");
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305513 ret = -EINVAL;
5514 QDF_ASSERT(0);
5515 goto exit;
5516 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 memset(pWextState->WPARSNIE, 0,
5518 MAX_WPA_RSN_IE_LEN);
5519 memcpy(pWextState->WPARSNIE, genie - 2,
5520 (eLen + 2));
5521 pWextState->roamProfile.pWPAReqIE =
5522 pWextState->WPARSNIE;
5523 pWextState->roamProfile.nWPAReqIELength =
5524 eLen + 2;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005525 } else {
5526 /* any vendorId except WPA IE should
5527 * be accumulated to genIE
5528 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005529 uint16_t curGenIELen = pWextState->genIE.length;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005530
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005531 hdd_debug("Set OUI(%02x %02x %02x %02x) IE(len %d)",
Jeff Johnson99bac312016-06-28 10:38:18 -07005532 genie[0], genie[1], genie[2],
5533 genie[3], eLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005534
5535 if (SIR_MAC_MAX_IE_LENGTH <
5536 (pWextState->genIE.length + eLen)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005537 hdd_err("genIE. Need bigger buffer space");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305538 QDF_ASSERT(0);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305539 ret = -ENOMEM;
5540 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005542 /* save to Additional IE; it should be
5543 * accumulated to handle WPS IE + other IE
5544 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005545 memcpy(pWextState->genIE.addIEdata +
5546 curGenIELen, genie - 2, eLen + 2);
5547 pWextState->genIE.length += eLen + 2;
5548 }
5549 break;
5550 case DOT11F_EID_RSN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005551 hdd_debug("Set RSN IE (len %d)", eLen + 2);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305552 if ((eLen + 2) > (sizeof(pWextState->WPARSNIE))) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005553 hdd_err("genIE, Need bigger buffer space");
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305554 ret = -EINVAL;
5555 QDF_ASSERT(0);
5556 goto exit;
5557 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 memset(pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN);
5559 memcpy(pWextState->WPARSNIE, genie - 2, (eLen + 2));
5560 pWextState->roamProfile.pRSNReqIE =
5561 pWextState->WPARSNIE;
5562 pWextState->roamProfile.nRSNReqIELength = eLen + 2;
5563 break;
5564
5565 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07005566 hdd_err("Set UNKNOWN IE %X", elementId);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305567 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569 remLen -= eLen;
Srinivas Girigowda9eb807b2017-01-06 11:08:28 -08005570
5571 /* Move genie only if next element is present */
5572 if (remLen >= 2)
5573 genie += eLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 }
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305575exit:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 EXIT();
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07005577 qdf_mem_free(base_genie);
Mahesh A Saptasagard639dde2015-11-06 12:39:13 +05305578 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005579}
5580
5581/**
5582 * iw_set_genie() - SSR wrapper for __iw_set_genie()
5583 * @dev: pointer to net_device
5584 * @info: pointer to iw_request_info
5585 * @wrqu: pointer to iwreq_data
5586 * @extra: pointer to extra ioctl payload
5587 *
5588 * Return: 0 on success, error number otherwise
5589 */
5590static int iw_set_genie(struct net_device *dev,
5591 struct iw_request_info *info,
5592 union iwreq_data *wrqu, char *extra)
5593{
5594 int ret;
5595
5596 cds_ssr_protect(__func__);
5597 ret = __iw_set_genie(dev, info, wrqu, extra);
5598 cds_ssr_unprotect(__func__);
5599
5600 return ret;
5601}
5602
5603/**
5604 * __iw_get_genie() - SIOCGIWGENIE ioctl handler
5605 * @dev: device upon which the ioctl was received
5606 * @info: ioctl request information
5607 * @wrqu: ioctl request data
5608 * @extra: ioctl extra data
5609 *
5610 * Return: 0 on success, non-zero on error
5611 */
5612static int __iw_get_genie(struct net_device *dev,
5613 struct iw_request_info *info,
5614 union iwreq_data *wrqu, char *extra)
5615{
Jeff Johnson2a722002017-09-30 20:02:35 -07005616 struct hdd_wext_state *pWextState;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005617 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005618 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305619 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620 uint32_t length = DOT11F_IE_RSN_MAX_LEN;
5621 uint8_t genIeBytes[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005622 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 int ret;
5624
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005625 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005627 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005628 ret = wlan_hdd_validate_context(hdd_ctx);
5629 if (0 != ret)
5630 return ret;
5631
Jeff Johnson441e1f72017-02-07 08:50:49 -08005632 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5633 if (0 != ret)
5634 return ret;
5635
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005636 hdd_debug("getGEN_IE ioctl");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005638 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639
Jeff Johnsond377dce2017-10-04 10:32:42 -07005640 if (sta_ctx->conn_info.connState == eConnectionState_NotConnected)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005641 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642
5643 /* Return something ONLY if we are associated with an RSN or
5644 * WPA network
5645 */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005646 if (!hdd_is_auth_type_rsn(pWextState->roamProfile.negotiatedAuthType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647 return -ENXIO;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648
5649 /* Actually retrieve the RSN IE from CSR. (We previously sent
5650 * it down in the CSR Roam Profile.)
5651 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005652 status = csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX(adapter),
5653 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 &length, genIeBytes);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305655 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005656 hdd_err("Failed to get WPA-RSN IE data status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 return -EFAULT;
5658 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659 wrqu->data.length = length;
Manjeet Singhfde0c042016-09-03 12:08:09 +05305660 if (length > DOT11F_IE_RSN_MAX_LEN) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005661 hdd_err("Invalid buffer length: %d", length);
Manjeet Singhfde0c042016-09-03 12:08:09 +05305662 return -E2BIG;
5663 }
5664 qdf_mem_copy(extra, (void *)genIeBytes, length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005666 hdd_debug("RSN IE of %d bytes returned",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 wrqu->data.length);
5668
5669 EXIT();
5670
5671 return 0;
5672}
5673
5674/**
5675 * iw_get_genie() - SSR wrapper for __iw_get_genie()
5676 * @dev: pointer to net_device
5677 * @info: pointer to iw_request_info
5678 * @wrqu: pointer to iwreq_data
5679 * @extra: pointer to extra ioctl payload
5680 *
5681 * Return: 0 on success, error number otherwise
5682 */
5683static int iw_get_genie(struct net_device *dev,
5684 struct iw_request_info *info,
5685 union iwreq_data *wrqu, char *extra)
5686{
5687 int ret;
5688
5689 cds_ssr_protect(__func__);
5690 ret = __iw_get_genie(dev, info, wrqu, extra);
5691 cds_ssr_unprotect(__func__);
5692
5693 return ret;
5694}
5695
5696/**
5697 * __iw_get_encode() - SIOCGIWENCODE ioctl handler
5698 * @dev: device upon which the ioctl was received
5699 * @info: ioctl request information
5700 * @wrqu: ioctl request data
5701 * @extra: ioctl extra data
5702 *
5703 * Return: 0 on success, non-zero on error
5704 */
5705static int __iw_get_encode(struct net_device *dev,
5706 struct iw_request_info *info,
5707 struct iw_point *dwrq, char *extra)
5708{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005709 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson2a722002017-09-30 20:02:35 -07005710 struct hdd_wext_state *pWextState =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005711 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005712 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5713 int keyId;
5714 eCsrAuthType authType = eCSR_AUTH_TYPE_NONE;
5715 int i;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005716 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005717 int ret;
5718
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005719 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005721 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005722 ret = wlan_hdd_validate_context(hdd_ctx);
5723 if (0 != ret)
5724 return ret;
5725
Jeff Johnson441e1f72017-02-07 08:50:49 -08005726 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5727 if (0 != ret)
5728 return ret;
5729
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005730 keyId = pRoamProfile->Keys.defaultIndex;
5731
5732 if (keyId < 0 || keyId >= MAX_WEP_KEYS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08005733 hdd_err("Invalid keyId: %d", keyId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734 return -EINVAL;
5735 }
5736
5737 if (pRoamProfile->Keys.KeyLength[keyId] > 0) {
5738 dwrq->flags |= IW_ENCODE_ENABLED;
5739 dwrq->length = pRoamProfile->Keys.KeyLength[keyId];
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305740 qdf_mem_copy(extra, &(pRoamProfile->Keys.KeyMaterial[keyId][0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005741 pRoamProfile->Keys.KeyLength[keyId]);
5742
5743 dwrq->flags |= (keyId + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005744 } else {
5745 dwrq->flags |= IW_ENCODE_DISABLED;
5746 }
5747
5748 for (i = 0; i < MAX_WEP_KEYS; i++) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005749 if (pRoamProfile->Keys.KeyLength[i] == 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750 continue;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005751 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753 }
5754
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005755 if (MAX_WEP_KEYS == i)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005756 dwrq->flags |= IW_ENCODE_NOKEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005757
5758 authType =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005759 ((struct hdd_station_ctx *) WLAN_HDD_GET_STATION_CTX_PTR(adapter))->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005760 conn_info.authType;
5761
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005762 if (eCSR_AUTH_TYPE_OPEN_SYSTEM == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005763 dwrq->flags |= IW_ENCODE_OPEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005764 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005765 dwrq->flags |= IW_ENCODE_RESTRICTED;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07005766
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005767 EXIT();
5768 return 0;
5769}
5770
5771/**
5772 * iw_get_encode() - SSR wrapper for __iw_get_encode()
5773 * @dev: pointer to net_device
5774 * @info: pointer to iw_request_info
5775 * @dwrq: pointer to encoding information
5776 * @extra: pointer to extra ioctl payload
5777 *
5778 * Return: 0 on success, error number otherwise
5779 */
5780static int iw_get_encode(struct net_device *dev, struct iw_request_info *info,
5781 struct iw_point *dwrq, char *extra)
5782{
5783 int ret;
5784
5785 cds_ssr_protect(__func__);
5786 ret = __iw_get_encode(dev, info, dwrq, extra);
5787 cds_ssr_unprotect(__func__);
5788
5789 return ret;
5790}
5791
5792/**
5793 * __iw_get_rts_threshold() - SIOCGIWRTS ioctl handler
5794 * @dev: device upon which the ioctl was received
5795 * @info: ioctl request information
5796 * @wrqu: ioctl request data
5797 * @extra: ioctl extra data
5798 *
5799 * Return: 0 on success, non-zero on error
5800 */
5801static int __iw_get_rts_threshold(struct net_device *dev,
5802 struct iw_request_info *info,
5803 union iwreq_data *wrqu, char *extra)
5804{
Jeff Johnson3d278b02017-08-29 14:17:47 -07005805 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson5b907622017-02-07 10:00:37 -08005806 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5807 uint32_t threshold = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005808 struct hdd_context *hdd_ctx;
Jeff Johnson5b907622017-02-07 10:00:37 -08005809 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005810
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005811 ENTER_DEV(dev);
5812
Jeff Johnson5b907622017-02-07 10:00:37 -08005813 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5814 ret = wlan_hdd_validate_context(hdd_ctx);
5815 if (0 != ret)
5816 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005817
Jeff Johnson441e1f72017-02-07 08:50:49 -08005818 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5819 if (0 != ret)
5820 return ret;
5821
Jeff Johnson5b907622017-02-07 10:00:37 -08005822 if (QDF_STATUS_SUCCESS !=
5823 sme_cfg_get_int(hal, WNI_CFG_RTS_THRESHOLD, &threshold)) {
5824 hdd_warn("failed to get ini parameter, WNI_CFG_RTS_THRESHOLD");
5825 return -EIO;
5826 }
5827 wrqu->rts.value = threshold;
5828
5829 hdd_notice("Rts-Threshold=%d!!", wrqu->rts.value);
5830
5831 EXIT();
5832
5833 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005834}
5835
5836/**
5837 * __iw_set_rts_threshold() - SIOCSIWRTS ioctl handler
5838 * @dev: device upon which the ioctl was received
5839 * @info: ioctl request information
5840 * @wrqu: ioctl request data
5841 * @extra: ioctl extra data
5842 *
5843 * Return: 0 on success, non-zero on error
5844 */
5845static int __iw_set_rts_threshold(struct net_device *dev,
5846 struct iw_request_info *info,
5847 union iwreq_data *wrqu, char *extra)
5848{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005849 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5850 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005851 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 int ret;
5853
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005854 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005855
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07005856 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857 ret = wlan_hdd_validate_context(hdd_ctx);
5858 if (0 != ret)
5859 return ret;
5860
Jeff Johnson441e1f72017-02-07 08:50:49 -08005861 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5862 if (0 != ret)
5863 return ret;
5864
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005865 if (wrqu->rts.value < WNI_CFG_RTS_THRESHOLD_STAMIN
5866 || wrqu->rts.value > WNI_CFG_RTS_THRESHOLD_STAMAX) {
5867 return -EINVAL;
5868 }
5869
5870 if (sme_cfg_set_int(hHal, WNI_CFG_RTS_THRESHOLD, wrqu->rts.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305871 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07005872 hdd_err("failed to set ini parameter, WNI_CFG_RTS_THRESHOLD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005873 return -EIO;
5874 }
5875
5876 EXIT();
5877
5878 return 0;
5879}
5880
5881/**
5882 * iw_get_rts_threshold() - SSR wrapper for __iw_get_rts_threshold()
5883 * @dev: pointer to net_device
5884 * @info: pointer to iw_request_info
5885 * @wrqu: pointer to iwreq_data
5886 * @extra: pointer to extra ioctl payload
5887 *
5888 * Return: 0 on success, error number otherwise
5889 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005890int iw_get_rts_threshold(struct net_device *dev,
5891 struct iw_request_info *info,
5892 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005893{
5894 int ret;
5895
5896 cds_ssr_protect(__func__);
5897 ret = __iw_get_rts_threshold(dev, info, wrqu, extra);
5898 cds_ssr_unprotect(__func__);
5899
5900 return ret;
5901}
5902
5903/**
5904 * iw_set_rts_threshold() - SSR wrapper for __iw_set_rts_threshold()
5905 * @dev: pointer to net_device
5906 * @info: pointer to iw_request_info
5907 * @wrqu: pointer to iwreq_data
5908 * @extra: pointer to extra ioctl payload
5909 *
5910 * Return: 0 on success, error number otherwise
5911 */
5912static int iw_set_rts_threshold(struct net_device *dev,
5913 struct iw_request_info *info,
5914 union iwreq_data *wrqu, char *extra)
5915{
5916 int ret;
5917
5918 cds_ssr_protect(__func__);
5919 ret = __iw_set_rts_threshold(dev, info, wrqu, extra);
5920 cds_ssr_unprotect(__func__);
5921
5922 return ret;
5923}
5924
5925/**
5926 * __iw_get_frag_threshold() - SIOCGIWFRAG ioctl handler
5927 * @dev: device upon which the ioctl was received
5928 * @info: ioctl request information
5929 * @wrqu: ioctl request data
5930 * @extra: ioctl extra data
5931 *
5932 * Return: 0 on success, non-zero on error
5933 */
5934static int __iw_get_frag_threshold(struct net_device *dev,
5935 struct iw_request_info *info,
5936 union iwreq_data *wrqu, char *extra)
5937{
Jeff Johnson3d278b02017-08-29 14:17:47 -07005938 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson5b907622017-02-07 10:00:37 -08005939 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
5940 uint32_t threshold = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07005941 struct hdd_context *hdd_ctx;
Jeff Johnson5b907622017-02-07 10:00:37 -08005942 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005943
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005944 ENTER_DEV(dev);
5945
Jeff Johnson5b907622017-02-07 10:00:37 -08005946 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5947 ret = wlan_hdd_validate_context(hdd_ctx);
5948 if (0 != ret)
5949 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005950
Jeff Johnson441e1f72017-02-07 08:50:49 -08005951 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5952 if (0 != ret)
5953 return ret;
5954
Jeff Johnson5b907622017-02-07 10:00:37 -08005955 if (sme_cfg_get_int(hal, WNI_CFG_FRAGMENTATION_THRESHOLD, &threshold)
5956 != QDF_STATUS_SUCCESS) {
5957 hdd_warn("failed to get ini parameter, WNI_CFG_FRAGMENTATION_THRESHOLD");
5958 return -EIO;
5959 }
5960 wrqu->frag.value = threshold;
5961
5962 hdd_notice("Frag-Threshold=%d!!", wrqu->frag.value);
5963
5964 EXIT();
5965
5966 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005967}
5968
5969/**
5970 * iw_get_frag_threshold() - SSR wrapper for __iw_get_frag_threshold()
5971 * @dev: pointer to net_device
5972 * @info: pointer to iw_request_info
5973 * @wrqu: pointer to iwreq_data
5974 * @extra: pointer to extra ioctl payload
5975 *
5976 * Return: 0 on success, error number otherwise
5977 */
Jeff Johnson5b907622017-02-07 10:00:37 -08005978int iw_get_frag_threshold(struct net_device *dev,
5979 struct iw_request_info *info,
5980 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005981{
5982 int ret;
5983
5984 cds_ssr_protect(__func__);
5985 ret = __iw_get_frag_threshold(dev, info, wrqu, extra);
5986 cds_ssr_unprotect(__func__);
5987
5988 return ret;
5989}
5990
5991/**
5992 * __iw_set_frag_threshold() - SIOCSIWFRAG ioctl handler
5993 * @dev: device upon which the ioctl was received
5994 * @info: ioctl request information
5995 * @wrqu: ioctl request data
5996 * @extra: ioctl extra data
5997 *
5998 * Return: 0 on success, non-zero on error
5999 */
6000static int __iw_set_frag_threshold(struct net_device *dev,
6001 struct iw_request_info *info,
6002 union iwreq_data *wrqu, char *extra)
6003{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006004 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6005 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006006 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 int ret;
6008
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006009 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006011 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012 ret = wlan_hdd_validate_context(hdd_ctx);
6013 if (0 != ret)
6014 return ret;
6015
Jeff Johnson441e1f72017-02-07 08:50:49 -08006016 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6017 if (0 != ret)
6018 return ret;
6019
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006020 if (wrqu->frag.value < WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN
6021 || wrqu->frag.value > WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX) {
6022 return -EINVAL;
6023 }
6024
6025 if (sme_cfg_set_int
6026 (hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, wrqu->frag.value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306027 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006028 hdd_err("WNI_CFG_FRAGMENTATION_THRESHOLD failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006029 return -EIO;
6030 }
6031
6032 EXIT();
6033
6034 return 0;
6035}
6036
6037/**
6038 * iw_set_frag_threshold() - SSR wrapper for __iw_set_frag_threshold()
6039 * @dev: pointer to net_device
6040 * @info: pointer to iw_request_info
6041 * @wrqu: pointer to iwreq_data
6042 * @extra: pointer to extra ioctl payload
6043 *
6044 * Return: 0 on success, error number otherwise
6045 */
6046static int iw_set_frag_threshold(struct net_device *dev,
6047 struct iw_request_info *info,
6048 union iwreq_data *wrqu, char *extra)
6049{
6050 int ret;
6051
6052 cds_ssr_protect(__func__);
6053 ret = __iw_set_frag_threshold(dev, info, wrqu, extra);
6054 cds_ssr_unprotect(__func__);
6055
6056 return ret;
6057}
6058
6059/**
6060 * __iw_get_power_mode() - SIOCGIWPOWER ioctl handler
6061 * @dev: device upon which the ioctl was received
6062 * @info: ioctl request information
6063 * @wrqu: ioctl request data
6064 * @extra: ioctl extra data
6065 *
6066 * Return: 0 on success, non-zero on error
6067 */
6068static int __iw_get_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07006069 struct iw_request_info *info,
6070 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006072 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006073 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074 int ret;
6075
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006076 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077
6078 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6079 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6080 ret = wlan_hdd_validate_context(hdd_ctx);
6081 if (0 != ret)
6082 return ret;
6083
Jeff Johnson441e1f72017-02-07 08:50:49 -08006084 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6085 if (0 != ret)
6086 return ret;
6087
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006088 return -EOPNOTSUPP;
6089}
6090
6091/**
6092 * iw_get_power_mode() - SSR wrapper function for __iw_get_power_mode
6093 * @dev: pointer to net_device
6094 * @info: pointer to iw_request_info
6095 * @wrqu: pointer to iwreq_data
6096 * @extra: extra
6097 *
6098 * Return: 0 on success, error number otherwise
6099 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07006100static int iw_get_power_mode(struct net_device *dev,
6101 struct iw_request_info *info,
6102 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006103{
6104 int ret;
6105
6106 cds_ssr_protect(__func__);
6107 ret = __iw_get_power_mode(dev, info, wrqu, extra);
6108 cds_ssr_unprotect(__func__);
6109
6110 return ret;
6111}
6112
6113/**
6114 * __iw_set_power_mode() - SIOCSIWPOWER ioctl handler
6115 * @dev: device upon which the ioctl was received
6116 * @info: ioctl request information
6117 * @wrqu: ioctl request data
6118 * @extra: ioctl extra data
6119 *
6120 * Return: 0 on success, non-zero on error
6121 */
6122static int __iw_set_power_mode(struct net_device *dev,
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07006123 struct iw_request_info *info,
6124 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006125{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006126 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006127 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006128 int ret;
6129
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006130 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131
6132 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6133 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6134 ret = wlan_hdd_validate_context(hdd_ctx);
6135 if (0 != ret)
6136 return ret;
6137
Jeff Johnson441e1f72017-02-07 08:50:49 -08006138 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6139 if (0 != ret)
6140 return ret;
6141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006142 return -EOPNOTSUPP;
6143}
6144
6145/**
6146 * iw_set_power_mode() - SSR wrapper function for __iw_set_power_mode
6147 * @dev: pointer to net_device
6148 * @info: pointer to iw_request_info
6149 * @wrqu: pointer to iwreq_data
6150 * @extra: extra
6151 *
6152 * Return: 0 on success, error number otherwise
6153 */
Jeff Johnsonaf2a0932016-10-05 14:52:57 -07006154static int iw_set_power_mode(struct net_device *dev,
6155 struct iw_request_info *info,
6156 union iwreq_data *wrqu, char *extra)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157{
6158 int ret;
6159
6160 cds_ssr_protect(__func__);
6161 ret = __iw_set_power_mode(dev, info, wrqu, extra);
6162 cds_ssr_unprotect(__func__);
6163
6164 return ret;
6165}
6166
6167/**
6168 * __iw_get_range() - SIOCGIWRANGE ioctl handler
6169 * @dev: device upon which the ioctl was received
6170 * @info: ioctl request information
6171 * @wrqu: ioctl request data
6172 * @extra: ioctl extra data
6173 *
6174 * Return: 0 on success, non-zero on error
6175 */
6176static int __iw_get_range(struct net_device *dev, struct iw_request_info *info,
6177 union iwreq_data *wrqu, char *extra)
6178{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006179 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6180 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006181 struct iw_range *range = (struct iw_range *)extra;
6182
6183 uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6184
6185 uint32_t num_channels = sizeof(channels);
6186 uint8_t supp_rates[WNI_CFG_SUPPORTED_RATES_11A_LEN];
6187 uint32_t a_len;
6188 uint32_t b_len;
6189 uint32_t active_phy_mode = 0;
6190 uint8_t index = 0, i;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006191 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006192 int ret;
6193
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006194 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006195
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006196 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006197 ret = wlan_hdd_validate_context(hdd_ctx);
6198 if (0 != ret)
6199 return ret;
6200
Jeff Johnson441e1f72017-02-07 08:50:49 -08006201 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6202 if (0 != ret)
6203 return ret;
6204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006205 wrqu->data.length = sizeof(struct iw_range);
6206 memset(range, 0, sizeof(struct iw_range));
6207
6208
6209 /*Get the phy mode */
6210 if (sme_cfg_get_int(hHal,
6211 WNI_CFG_DOT11_MODE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306212 &active_phy_mode) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006213 hdd_debug("active_phy_mode = %d", active_phy_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006214
6215 if (active_phy_mode == WNI_CFG_DOT11_MODE_11A
6216 || active_phy_mode == WNI_CFG_DOT11_MODE_11G) {
6217 /*Get the supported rates for 11G band */
6218 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
6219 if (sme_cfg_get_str(hHal,
6220 WNI_CFG_SUPPORTED_RATES_11A,
6221 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306222 &a_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006223 if (a_len > WNI_CFG_SUPPORTED_RATES_11A_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006224 a_len = WNI_CFG_SUPPORTED_RATES_11A_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006225
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006226 for (i = 0; i < a_len; i++) {
6227 range->bitrate[i] =
6228 ((supp_rates[i] & 0x7F) / 2) *
6229 1000000;
6230 }
6231 range->num_bitrates = a_len;
6232 } else {
6233 return -EIO;
6234 }
6235 } else if (active_phy_mode == WNI_CFG_DOT11_MODE_11B) {
6236 /*Get the supported rates for 11B band */
6237 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
6238 if (sme_cfg_get_str(hHal,
6239 WNI_CFG_SUPPORTED_RATES_11B,
6240 supp_rates,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306241 &b_len) == QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006242 if (b_len > WNI_CFG_SUPPORTED_RATES_11B_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006243 b_len = WNI_CFG_SUPPORTED_RATES_11B_LEN;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006244
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006245 for (i = 0; i < b_len; i++) {
6246 range->bitrate[i] =
6247 ((supp_rates[i] & 0x7F) / 2) *
6248 1000000;
6249 }
6250 range->num_bitrates = b_len;
6251 } else {
6252 return -EIO;
6253 }
6254 }
6255 }
6256
6257 range->max_rts = WNI_CFG_RTS_THRESHOLD_STAMAX;
6258 range->min_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN;
6259 range->max_frag = WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX;
6260
6261 range->encoding_size[0] = 5;
6262 range->encoding_size[1] = 13;
6263 range->num_encoding_sizes = 2;
6264 range->max_encoding_tokens = MAX_WEP_KEYS;
6265
6266 /* we support through Wireless Extensions 22 */
6267 range->we_version_compiled = WIRELESS_EXT;
6268 range->we_version_source = 22;
6269
6270 /*Supported Channels and Frequencies */
6271 if (sme_cfg_get_str
6272 ((hHal), WNI_CFG_VALID_CHANNEL_LIST, channels,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306273 &num_channels) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006274 hdd_err("Failed to get ini parameter, WNI_CFG_VALID_CHANNEL_LIST");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006275 return -EIO;
6276 }
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006277 if (num_channels > IW_MAX_FREQUENCIES)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006278 num_channels = IW_MAX_FREQUENCIES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006279
6280 range->num_channels = num_channels;
6281 range->num_frequency = num_channels;
6282
6283 for (index = 0; index < num_channels; index++) {
6284 uint32_t frq_indx = 0;
6285
6286 range->freq[index].i = channels[index];
6287 while (frq_indx < FREQ_CHAN_MAP_TABLE_SIZE) {
6288 if (channels[index] == freq_chan_map[frq_indx].chan) {
6289 range->freq[index].m =
6290 freq_chan_map[frq_indx].freq * 100000;
6291 range->freq[index].e = 1;
6292 break;
6293 }
6294 frq_indx++;
6295 }
6296 }
6297
6298 /* Event capability (kernel + driver) */
6299 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
6300 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
6301 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
6302 range->event_capa[1] = IW_EVENT_CAPA_K_1;
6303
6304 /*Encryption capability */
6305 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
6306 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
6307
6308 /* Txpower capability */
6309 range->txpower_capa = IW_TXPOW_MWATT;
6310
6311 /*Scanning capability */
6312#if WIRELESS_EXT >= 22
6313 range->scan_capa =
6314 IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_CHANNEL;
6315#endif
6316
6317 EXIT();
6318 return 0;
6319}
6320
6321/**
6322 * iw_get_range() - SSR wrapper for __iw_get_range()
6323 * @dev: pointer to net_device
6324 * @info: pointer to iw_request_info
6325 * @wrqu: pointer to iwreq_data
6326 * @extra: pointer to extra ioctl payload
6327 *
6328 * Return: 0 on success, error number otherwise
6329 */
6330static int iw_get_range(struct net_device *dev, struct iw_request_info *info,
6331 union iwreq_data *wrqu, char *extra)
6332{
6333 int ret;
6334
6335 cds_ssr_protect(__func__);
6336 ret = __iw_get_range(dev, info, wrqu, extra);
6337 cds_ssr_unprotect(__func__);
6338
6339 return ret;
6340}
6341
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006342struct class_a_stats {
6343 tCsrGlobalClassAStatsInfo class_a_stats;
6344};
6345
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006346/**
6347 * hdd_get_class_a_statistics_cb() - Get Class A stats callback function
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006348 * @stats: pointer to Class A stats
6349 * @context: user context originally registered with SME (always the
6350 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006351 *
6352 * Return: None
6353 */
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006354static void hdd_get_class_a_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006355{
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006356 struct hdd_request *request;
6357 struct class_a_stats *priv;
6358 tCsrGlobalClassAStatsInfo *returned_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006359
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006360 ENTER();
6361 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07006362 hdd_err("Bad param, stats [%pK] context [%pK]",
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006363 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006364 return;
6365 }
6366
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006367 request = hdd_request_get(context);
6368 if (!request) {
6369 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006370 return;
6371 }
6372
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006373 returned_stats = stats;
6374 priv = hdd_request_priv(request);
6375 priv->class_a_stats = *returned_stats;
6376 hdd_request_complete(request);
6377 hdd_request_put(request);
6378 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006379}
6380
6381/**
6382 * wlan_hdd_get_class_astats() - Get Class A statistics
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006383 * @adapter: adapter for which statistics are desired
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006384 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306385 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006386 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006387QDF_STATUS wlan_hdd_get_class_astats(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006388{
Jeff Johnsond377dce2017-10-04 10:32:42 -07006389 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306390 QDF_STATUS hstatus;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006391 int ret;
6392 void *cookie;
6393 struct hdd_request *request;
6394 struct class_a_stats *priv;
6395 static const struct hdd_request_params params = {
6396 .priv_size = sizeof(*priv),
6397 .timeout_ms = WLAN_WAIT_TIME_STATS,
6398 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006399
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006400 if (NULL == adapter) {
6401 hdd_err("adapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306402 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006403 }
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +05306404 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006405 hdd_debug("Recovery in Progress. State: 0x%x Ignore!!!",
Prashanth Bhatta9e143052015-12-04 11:56:47 -08006406 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306407 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006408 }
6409
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006410 request = hdd_request_alloc(&params);
6411 if (!request) {
6412 hdd_err("Request allocation failure");
6413 return QDF_STATUS_E_NOMEM;
6414 }
6415 cookie = hdd_request_cookie(request);
6416
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006417 /* query only for Class A statistics (which include link speed) */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006418 hstatus = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006419 eCSR_HDD, SME_GLOBAL_CLASSA_STATS,
6420 hdd_get_class_a_statistics_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07006421 sta_ctx->conn_info.staId[0],
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006422 cookie, adapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306423 if (QDF_STATUS_SUCCESS != hstatus) {
Archana Ramachandran31b5b652016-09-21 15:37:58 -07006424 hdd_warn("Unable to retrieve Class A statistics");
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006425 goto return_cached_results;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006426 }
6427
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006428 /* request was sent -- wait for the response */
6429 ret = hdd_request_wait_for_response(request);
6430 if (ret) {
6431 hdd_warn("SME timed out while retrieving Class A statistics");
6432 goto return_cached_results;
6433 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006434
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006435 /* update the adapter with the fresh results */
6436 priv = hdd_request_priv(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006437 adapter->hdd_stats.ClassA_stat = priv->class_a_stats;
Jeff Johnsona6ace5b2017-01-23 07:11:02 -08006438
6439return_cached_results:
6440 /*
6441 * either we never sent a request, we sent a request and
6442 * received a response or we sent a request and timed out.
6443 * regardless we are done with the request.
6444 */
6445 hdd_request_put(request);
6446
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306447 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006448}
6449
Jeff Johnsondda167c2017-01-23 10:37:57 -08006450struct station_stats {
6451 tCsrSummaryStatsInfo summary_stats;
6452 tCsrGlobalClassAStatsInfo class_a_stats;
6453 struct csr_per_chain_rssi_stats_info per_chain_rssi_stats;
6454};
6455
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006456/**
6457 * hdd_get_station_statistics_cb() - Get stats callback function
Jeff Johnsondda167c2017-01-23 10:37:57 -08006458 * @stats: pointer to combined station stats
6459 * @context: user context originally registered with SME (always the
6460 * cookie from the request context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006461 *
6462 * Return: None
6463 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006464static void hdd_get_station_statistics_cb(void *stats, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006465{
Jeff Johnsondda167c2017-01-23 10:37:57 -08006466 struct hdd_request *request;
6467 struct station_stats *priv;
6468 tCsrSummaryStatsInfo *summary_stats;
6469 tCsrGlobalClassAStatsInfo *class_a_stats;
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306470 struct csr_per_chain_rssi_stats_info *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006471
Jeff Johnsondda167c2017-01-23 10:37:57 -08006472 if ((NULL == stats) || (NULL == context)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -07006473 hdd_err("Bad param, pStats [%pK] pContext [%pK]",
Jeff Johnsondda167c2017-01-23 10:37:57 -08006474 stats, context);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006475 return;
6476 }
6477
Jeff Johnsondda167c2017-01-23 10:37:57 -08006478 request = hdd_request_get(context);
6479 if (!request) {
6480 hdd_err("Obsolete request");
6481 return;
6482 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006483
Jeff Johnsondda167c2017-01-23 10:37:57 -08006484 summary_stats = (tCsrSummaryStatsInfo *) stats;
6485 class_a_stats = (tCsrGlobalClassAStatsInfo *) (summary_stats + 1);
Himanshu Agarwal37e42412016-07-21 14:35:09 +05306486 per_chain_rssi_stats = (struct csr_per_chain_rssi_stats_info *)
Jeff Johnsondda167c2017-01-23 10:37:57 -08006487 (class_a_stats + 1);
6488 priv = hdd_request_priv(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489
6490 /* copy over the stats. do so as a struct copy */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006491 priv->summary_stats = *summary_stats;
6492 priv->class_a_stats = *class_a_stats;
6493 priv->per_chain_rssi_stats = *per_chain_rssi_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006494
Jeff Johnsondda167c2017-01-23 10:37:57 -08006495 hdd_request_complete(request);
6496 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006497}
6498
6499/**
6500 * wlan_hdd_get_station_stats() - Get station statistics
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006501 * @adapter: adapter for which statistics are desired
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006502 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306503 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006504 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006505QDF_STATUS wlan_hdd_get_station_stats(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006506{
Jeff Johnsond377dce2017-10-04 10:32:42 -07006507 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dustin Brown0f5260d2017-06-12 16:17:38 -07006508 QDF_STATUS status;
6509 int errno;
Jeff Johnsondda167c2017-01-23 10:37:57 -08006510 void *cookie;
6511 struct hdd_request *request;
6512 struct station_stats *priv;
6513 static const struct hdd_request_params params = {
6514 .priv_size = sizeof(*priv),
6515 .timeout_ms = WLAN_WAIT_TIME_STATS,
6516 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006517
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006518 if (NULL == adapter) {
6519 hdd_err("adapter is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306520 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006521 }
6522
Jeff Johnsondda167c2017-01-23 10:37:57 -08006523 request = hdd_request_alloc(&params);
6524 if (!request) {
6525 hdd_err("Request allocation failure");
6526 return QDF_STATUS_E_NOMEM;
6527 }
6528 cookie = hdd_request_cookie(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006529
6530 /* query only for Summary & Class A statistics */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006531 status = sme_get_statistics(WLAN_HDD_GET_HAL_CTX(adapter),
Dustin Brown0f5260d2017-06-12 16:17:38 -07006532 eCSR_HDD,
6533 SME_SUMMARY_STATS |
6534 SME_GLOBAL_CLASSA_STATS |
6535 SME_PER_CHAIN_RSSI_STATS,
6536 hdd_get_station_statistics_cb,
Jeff Johnsond377dce2017-10-04 10:32:42 -07006537 sta_ctx->conn_info.staId[0],
Dustin Brown0f5260d2017-06-12 16:17:38 -07006538 cookie,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006539 adapter->sessionId);
Dustin Brown0f5260d2017-06-12 16:17:38 -07006540 if (QDF_IS_STATUS_ERROR(status)) {
6541 hdd_err("Failed to retrieve statistics, status %d", status);
6542 goto put_request;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006543 }
6544
Dustin Brown0f5260d2017-06-12 16:17:38 -07006545 /* request was sent -- wait for the response */
6546 errno = hdd_request_wait_for_response(request);
6547 if (errno) {
6548 hdd_err("Failed to wait for statistics, errno %d", errno);
6549 goto put_request;
6550 }
6551
6552 /* update the adapter with the fresh results */
6553 priv = hdd_request_priv(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006554 adapter->hdd_stats.summary_stat = priv->summary_stats;
6555 adapter->hdd_stats.ClassA_stat = priv->class_a_stats;
6556 adapter->hdd_stats.per_chain_rssi_stats = priv->per_chain_rssi_stats;
Dustin Brown0f5260d2017-06-12 16:17:38 -07006557
6558put_request:
Jeff Johnsondda167c2017-01-23 10:37:57 -08006559 /*
6560 * either we never sent a request, we sent a request and
6561 * received a response or we sent a request and timed out.
6562 * regardless we are done with the request.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006563 */
Jeff Johnsondda167c2017-01-23 10:37:57 -08006564 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006565
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006566 /* either callback updated adapter stats or it has cached data */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306567 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006568}
6569
6570/**
6571 * iw_get_linkspeed() - Get current link speed ioctl
6572 * @dev: device upon which the ioctl was received
6573 * @info: ioctl request information
6574 * @wrqu: ioctl request data
6575 * @extra: extra ioctl buffer
6576 *
6577 * Return: 0 on success, non-zero on error
6578 */
6579static int __iw_get_linkspeed(struct net_device *dev,
6580 struct iw_request_info *info,
6581 union iwreq_data *wrqu, char *extra)
6582{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006583 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006584 char *pLinkSpeed = (char *)extra;
6585 int len = sizeof(uint32_t) + 1;
6586 uint32_t link_speed = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006587 struct hdd_context *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -08006588 int ret;
6589 int rc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006590
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08006591 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306592
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006593 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson441e1f72017-02-07 08:50:49 -08006594 ret = wlan_hdd_validate_context(hdd_ctx);
6595 if (0 != ret)
6596 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006597
Jeff Johnson441e1f72017-02-07 08:50:49 -08006598 ret = hdd_check_private_wext_control(hdd_ctx, info);
6599 if (0 != ret)
6600 return ret;
6601
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006602 ret = wlan_hdd_get_link_speed(adapter, &link_speed);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006603 if (0 != ret)
Jeff Johnson441e1f72017-02-07 08:50:49 -08006604 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006605
6606 wrqu->data.length = len;
6607 /* return the linkspeed as a string */
6608 rc = snprintf(pLinkSpeed, len, "%u", link_speed);
6609 if ((rc < 0) || (rc >= len)) {
6610 /* encoding or length error? */
Jeff Johnson99bac312016-06-28 10:38:18 -07006611 hdd_err("Unable to encode link speed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006612 return -EIO;
6613 }
6614
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05306615 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006616 /* a value is being successfully returned */
6617 return 0;
6618}
6619
6620static int iw_get_linkspeed(struct net_device *dev,
6621 struct iw_request_info *info,
6622 union iwreq_data *wrqu, char *extra)
6623{
6624 int ret;
6625
6626 cds_ssr_protect(__func__);
6627 ret = __iw_get_linkspeed(dev, info, wrqu, extra);
6628 cds_ssr_unprotect(__func__);
6629
6630 return ret;
6631}
6632
6633/**
6634 * wlan_hdd_change_country_code_callback() - Change country code callback
6635 * @context: opaque context originally passed to SME. All functions
6636 * which use this callback pass the adapter upon which the country
6637 * code change is active
6638 *
6639 * This function is registered as the callback function when
6640 * sme_change_country_code() is invoked. Callers of
6641 * sme_change_country_code() subsequently wait for the adapter's
6642 * @change_country_code completion variable, so all this function
6643 * needs to do is set that completion variable so that execution can
6644 * continue.
6645 *
6646 * Return: none
6647 */
6648void wlan_hdd_change_country_code_callback(void *context)
6649{
6650
Jeff Johnson3d278b02017-08-29 14:17:47 -07006651 struct hdd_adapter *adapter = context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006652
6653 if (adapter && (WLAN_HDD_ADAPTER_MAGIC == adapter->magic))
6654 complete(&adapter->change_country_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006655}
6656
6657/**
6658 * __iw_set_nick() - SIOCSIWNICKN ioctl handler
6659 * @dev: device upon which the ioctl was received
6660 * @info: ioctl request information
6661 * @wrqu: ioctl request data
6662 * @extra: ioctl extra data
6663 *
6664 * Return: 0 on success, non-zero on error
6665 */
6666static int __iw_set_nick(struct net_device *dev,
6667 struct iw_request_info *info,
6668 union iwreq_data *wrqu, char *extra)
6669{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006670 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006671 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006672 int ret;
6673
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006674 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006675
6676 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6677 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6678 ret = wlan_hdd_validate_context(hdd_ctx);
6679 if (0 != ret)
6680 return ret;
6681
Jeff Johnson441e1f72017-02-07 08:50:49 -08006682 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6683 if (0 != ret)
6684 return ret;
6685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006686 return 0;
6687}
6688
6689/**
6690 * iw_set_nick() - SSR wrapper for __iw_set_nick
6691 * @dev: pointer to net_device
6692 * @info: pointer to iw_request_info
6693 * @wrqu: pointer to iwreq_data
6694 * @extra: extra
6695 *
6696 * Return: 0 on success, error number otherwise
6697 */
6698static int iw_set_nick(struct net_device *dev,
6699 struct iw_request_info *info,
6700 union iwreq_data *wrqu, char *extra)
6701{
6702 int ret;
6703
6704 cds_ssr_protect(__func__);
6705 ret = __iw_set_nick(dev, info, wrqu, extra);
6706 cds_ssr_unprotect(__func__);
6707
6708 return ret;
6709}
6710
6711/**
6712 * __iw_get_nick() - SIOCGIWNICKN ioctl handler
6713 * @dev: device upon which the ioctl was received
6714 * @info: ioctl request information
6715 * @wrqu: ioctl request data
6716 * @extra: ioctl extra data
6717 *
6718 * Return: 0 on success, non-zero on error
6719 */
6720static int __iw_get_nick(struct net_device *dev,
6721 struct iw_request_info *info,
6722 union iwreq_data *wrqu, char *extra)
6723{
Jeff Johnson3d278b02017-08-29 14:17:47 -07006724 struct hdd_adapter *adapter;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006725 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006726 int ret;
6727
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006728 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006729
6730 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6731 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6732 ret = wlan_hdd_validate_context(hdd_ctx);
6733 if (0 != ret)
6734 return ret;
6735
Jeff Johnson441e1f72017-02-07 08:50:49 -08006736 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6737 if (0 != ret)
6738 return ret;
6739
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006740 return 0;
6741}
6742
6743/**
6744 * iw_get_nick() - SSR wrapper for __iw_get_nick
6745 * @dev: pointer to net_device
6746 * @info: pointer to iw_request_info
6747 * @wrqu: pointer to iwreq_data
6748 * @extra: extra
6749 *
6750 * Return: 0 on success, error number otherwise
6751 */
6752static int iw_get_nick(struct net_device *dev,
6753 struct iw_request_info *info,
6754 union iwreq_data *wrqu, char *extra)
6755{
6756 int ret;
6757
6758 cds_ssr_protect(__func__);
6759 ret = __iw_get_nick(dev, info, wrqu, extra);
6760 cds_ssr_unprotect(__func__);
6761
6762 return ret;
6763}
6764
6765/**
6766 * __iw_set_encode() - SIOCSIWENCODE ioctl handler
6767 * @dev: device upon which the ioctl was received
6768 * @info: ioctl request information
6769 * @wrqu: ioctl request data
6770 * @extra: ioctl extra data
6771 *
6772 * Return: 0 on success, non-zero on error
6773 */
6774static int __iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6775 union iwreq_data *wrqu, char *extra)
6776{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006777 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -07006778 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006779 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson2a722002017-09-30 20:02:35 -07006780 struct hdd_wext_state *pWextState =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006781 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006782 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006783 struct iw_point *encoderq = &(wrqu->encoding);
6784 uint32_t keyId;
6785 uint8_t key_length;
6786 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6787 bool fKeyPresent = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306788 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006789 int ret;
6790
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006791 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006792
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006793 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006794 ret = wlan_hdd_validate_context(hdd_ctx);
6795 if (0 != ret)
6796 return ret;
6797
Jeff Johnson441e1f72017-02-07 08:50:49 -08006798 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6799 if (0 != ret)
6800 return ret;
6801
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006802 keyId = encoderq->flags & IW_ENCODE_INDEX;
6803
6804 if (keyId) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006805 if (keyId > MAX_WEP_KEYS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006806 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006807
6808 fKeyPresent = 1;
6809 keyId--;
6810 } else {
6811 fKeyPresent = 0;
6812 }
6813
6814 if (wrqu->data.flags & IW_ENCODE_DISABLED) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006815 hdd_debug("****iwconfig wlan0 key off*****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006816 if (!fKeyPresent) {
Yingying Tang3cc6b792016-10-20 17:00:37 +08006817 qdf_mem_zero(pWextState->roamProfile.Keys.KeyLength,
6818 CSR_MAX_NUM_KEY);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006819 }
Jeff Johnsond377dce2017-10-04 10:32:42 -07006820 sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnsonce4a8342017-10-14 13:12:22 -07006821 sta_ctx->wpa_versions = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006822 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6823 eCSR_ENCRYPT_TYPE_NONE;
6824 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6825 eCSR_ENCRYPT_TYPE_NONE;
6826
Jeff Johnsond377dce2017-10-04 10:32:42 -07006827 sta_ctx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6828 sta_ctx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006829
6830 if (eConnectionState_Associated ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07006831 sta_ctx->conn_info.connState) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006832 INIT_COMPLETION(adapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006833 status =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006834 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(adapter),
6835 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006836 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306837 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006838 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006839
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006840 rc = wait_for_completion_timeout(&adapter->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006841 disconnect_comp_var,
6842 msecs_to_jiffies
6843 (WLAN_WAIT_TIME_DISCONNECT));
6844 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006845 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006846 }
6847 }
6848
6849 return status;
6850
6851 }
6852
6853 if (wrqu->data.flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006854 hdd_debug("iwconfig wlan0 key on");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006855
Jeff Johnsond377dce2017-10-04 10:32:42 -07006856 sta_ctx->conn_info.authType =
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006857 (encoderq->flags & IW_ENCODE_RESTRICTED) ?
6858 eCSR_AUTH_TYPE_SHARED_KEY :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006859 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6860
6861 }
6862
6863 if (wrqu->data.length > 0) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006864 hdd_debug("wrqu->data.length : %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006865
6866 key_length = wrqu->data.length;
6867
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006868 /* IW_ENCODING_TOKEN_MAX is the value that is set
6869 * for wrqu->data.length by iwconfig.c
6870 * when 'iwconfig wlan0 key on' is issued.
6871 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006872
6873 if (5 == key_length) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006874 hdd_debug("Call with WEP40,key_len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006875 key_length);
6876
6877 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6878 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07006879 sta_ctx->conn_info.authType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006880 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
6881 } else {
6882 encryptionType =
6883 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6884 }
6885 } else if (13 == key_length) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006886 hdd_debug("Call with WEP104,key_len:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006887 key_length);
6888
6889 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt)
6890 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07006891 sta_ctx->conn_info.authType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006892 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
6893 } else {
6894 encryptionType =
6895 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6896 }
6897 } else {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08006898 hdd_err("Invalid WEP key length :%d", key_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899 return -EINVAL;
6900 }
6901
Jeff Johnsond377dce2017-10-04 10:32:42 -07006902 sta_ctx->conn_info.ucEncryptionType = encryptionType;
6903 sta_ctx->conn_info.mcEncryptionType = encryptionType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006904 pWextState->roamProfile.EncryptionType.numEntries = 1;
6905 pWextState->roamProfile.EncryptionType.encryptionType[0] =
6906 encryptionType;
6907 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
6908 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
6909 encryptionType;
6910
6911 if ((eConnectionState_NotConnected ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07006912 sta_ctx->conn_info.connState)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006913 &&
6914 ((eCSR_AUTH_TYPE_OPEN_SYSTEM ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07006915 sta_ctx->conn_info.authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006916 || (eCSR_AUTH_TYPE_SHARED_KEY ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07006917 sta_ctx->conn_info.authType))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006918
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306919 qdf_mem_copy(&pWextState->roamProfile.Keys.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006920 KeyMaterial[keyId][0], extra, key_length);
6921
6922 pWextState->roamProfile.Keys.KeyLength[keyId] =
6923 (uint8_t) key_length;
6924 pWextState->roamProfile.Keys.defaultIndex =
6925 (uint8_t) keyId;
6926
6927 return status;
6928 }
6929 }
6930
6931 return 0;
6932}
6933
6934/**
6935 * iw_set_encode() - SSR wrapper for __iw_set_encode()
6936 * @dev: pointer to net_device
6937 * @info: pointer to iw_request_info
6938 * @wrqu: pointer to iwreq_data
6939 * @extra: pointer to extra ioctl payload
6940 *
6941 * Return: 0 on success, error number otherwise
6942 */
6943static int iw_set_encode(struct net_device *dev, struct iw_request_info *info,
6944 union iwreq_data *wrqu, char *extra)
6945{
6946 int ret;
6947
6948 cds_ssr_protect(__func__);
6949 ret = __iw_set_encode(dev, info, wrqu, extra);
6950 cds_ssr_unprotect(__func__);
6951
6952 return ret;
6953}
6954
6955/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006956 * __iw_set_retry() - SIOCSIWRETRY ioctl handler
6957 * @dev: device upon which the ioctl was received
6958 * @info: ioctl request information
6959 * @wrqu: ioctl request data
6960 * @extra: ioctl extra data
6961 *
6962 * Return: 0 on success, non-zero on error
6963 */
6964static int __iw_set_retry(struct net_device *dev, struct iw_request_info *info,
6965 union iwreq_data *wrqu, char *extra)
6966{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006967 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6968 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07006969 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006970 int ret;
6971
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006972 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006973
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07006974 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006975 ret = wlan_hdd_validate_context(hdd_ctx);
6976 if (0 != ret)
6977 return ret;
6978
Jeff Johnson441e1f72017-02-07 08:50:49 -08006979 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6980 if (0 != ret)
6981 return ret;
6982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006983 if (wrqu->retry.value < WNI_CFG_LONG_RETRY_LIMIT_STAMIN ||
6984 wrqu->retry.value > WNI_CFG_LONG_RETRY_LIMIT_STAMAX) {
6985
Jeff Johnson99bac312016-06-28 10:38:18 -07006986 hdd_err("Invalid Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006987
6988 return -EINVAL;
6989 }
6990
6991 if (wrqu->retry.flags & IW_RETRY_LIMIT) {
6992
6993 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
6994 if (sme_cfg_set_int (hHal, WNI_CFG_LONG_RETRY_LIMIT,
6995 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306996 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07006997 hdd_err("WNI_CFG_LONG_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006998 return -EIO;
6999 }
7000 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
7001 if (sme_cfg_set_int (hHal, WNI_CFG_SHORT_RETRY_LIMIT,
7002 wrqu->retry.value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307003 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007004 hdd_err("WNI_CFG_SHORT_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007005 return -EIO;
7006 }
7007 }
7008 } else {
7009 return -EOPNOTSUPP;
7010 }
7011
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007012 hdd_debug("Set Retry-Limit=%d!!", wrqu->retry.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007013
7014 EXIT();
7015
7016 return 0;
7017
7018}
7019
7020/**
7021 * iw_set_retry() - SSR wrapper for __iw_set_retry()
7022 * @dev: pointer to net_device
7023 * @info: pointer to iw_request_info
7024 * @wrqu: pointer to iwreq_data
7025 * @extra: pointer to extra ioctl payload
7026 *
7027 * Return: 0 on success, error number otherwise
7028 */
7029static int iw_set_retry(struct net_device *dev, struct iw_request_info *info,
7030 union iwreq_data *wrqu, char *extra)
7031{
7032 int ret;
7033
7034 cds_ssr_protect(__func__);
7035 ret = __iw_set_retry(dev, info, wrqu, extra);
7036 cds_ssr_unprotect(__func__);
7037
7038 return ret;
7039}
7040
7041/**
7042 * __iw_get_retry() - SIOCGIWRETRY ioctl handler
7043 * @dev: device upon which the ioctl was received
7044 * @info: ioctl request information
7045 * @wrqu: ioctl request data
7046 * @extra: ioctl extra data
7047 *
7048 * Return: 0 on success, non-zero on error
7049 */
7050static int __iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7051 union iwreq_data *wrqu, char *extra)
7052{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007053 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7054 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007055 uint32_t retry = 0;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007056 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007057 int ret;
7058
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007059 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007060
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007061 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007062 ret = wlan_hdd_validate_context(hdd_ctx);
7063 if (0 != ret)
7064 return ret;
7065
Jeff Johnson441e1f72017-02-07 08:50:49 -08007066 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7067 if (0 != ret)
7068 return ret;
7069
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007070 if ((wrqu->retry.flags & IW_RETRY_LONG)) {
7071 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
7072
7073 if (sme_cfg_get_int(hHal, WNI_CFG_LONG_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307074 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007075 hdd_err("WNI_CFG_LONG_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007076 return -EIO;
7077 }
7078
7079 wrqu->retry.value = retry;
7080 } else if ((wrqu->retry.flags & IW_RETRY_SHORT)) {
7081 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
7082
7083 if (sme_cfg_get_int(hHal, WNI_CFG_SHORT_RETRY_LIMIT, &retry) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307084 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007085 hdd_err("WNI_CFG_SHORT_RETRY_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007086 return -EIO;
7087 }
7088
7089 wrqu->retry.value = retry;
7090 } else {
7091 return -EOPNOTSUPP;
7092 }
7093
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007094 hdd_debug("Retry-Limit=%d!!", retry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007095
7096 EXIT();
7097
7098 return 0;
7099}
7100
7101/**
7102 * iw_get_retry() - SSR wrapper for __iw_get_retry()
7103 * @dev: pointer to net_device
7104 * @info: pointer to iw_request_info
7105 * @wrqu: pointer to iwreq_data
7106 * @extra: pointer to extra ioctl payload
7107 *
7108 * Return: 0 on success, error number otherwise
7109 */
7110static int iw_get_retry(struct net_device *dev, struct iw_request_info *info,
7111 union iwreq_data *wrqu, char *extra)
7112{
7113 int ret;
7114
7115 cds_ssr_protect(__func__);
7116 ret = __iw_get_retry(dev, info, wrqu, extra);
7117 cds_ssr_unprotect(__func__);
7118
7119 return ret;
7120}
7121
7122/**
7123 * __iw_set_mlme() - SIOCSIWMLME ioctl handler
7124 * @dev: device upon which the ioctl was received
7125 * @info: ioctl request information
7126 * @wrqu: ioctl request data
7127 * @extra: ioctl extra data
7128 *
7129 * Return: 0 on success, non-zero on error
7130 */
7131static int __iw_set_mlme(struct net_device *dev,
7132 struct iw_request_info *info,
7133 union iwreq_data *wrqu, char *extra)
7134{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007135 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -07007136 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007137 struct iw_mlme *mlme = (struct iw_mlme *)extra;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307138 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007139 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007140 int ret;
7141
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08007142 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007143
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007144 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007145 ret = wlan_hdd_validate_context(hdd_ctx);
7146 if (0 != ret)
7147 return ret;
7148
Jeff Johnson441e1f72017-02-07 08:50:49 -08007149 ret = hdd_check_standard_wext_control(hdd_ctx, info);
7150 if (0 != ret)
7151 return ret;
7152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007153 /* reason_code is unused. By default it is set to
7154 * eCSR_DISCONNECT_REASON_UNSPECIFIED
7155 */
7156 switch (mlme->cmd) {
7157 case IW_MLME_DISASSOC:
7158 case IW_MLME_DEAUTH:
7159
Jeff Johnsond377dce2017-10-04 10:32:42 -07007160 if (sta_ctx->conn_info.connState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007161 eConnectionState_Associated) {
7162 eCsrRoamDisconnectReason reason =
7163 eCSR_DISCONNECT_REASON_UNSPECIFIED;
7164
7165 if (mlme->reason_code == HDD_REASON_MICHAEL_MIC_FAILURE)
7166 reason = eCSR_DISCONNECT_REASON_MIC_ERROR;
7167
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007168 INIT_COMPLETION(adapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007169 status =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007170 sme_roam_disconnect(WLAN_HDD_GET_HAL_CTX(adapter),
7171 adapter->sessionId, reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007172
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307173 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007174 unsigned long rc;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007175
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007176 rc = wait_for_completion_timeout(&adapter->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007177 disconnect_comp_var,
7178 msecs_to_jiffies
7179 (WLAN_WAIT_TIME_DISCONNECT));
7180 if (!rc)
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007181 hdd_err("disconnect_comp_var failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007182 } else
Jeff Johnson99bac312016-06-28 10:38:18 -07007183 hdd_err("%d Command Disassociate/Deauthenticate : csr_roam_disconnect failure returned %d",
7184 (int)mlme->cmd, (int)status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007185
7186 /* Resetting authKeyMgmt */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007187 (WLAN_HDD_GET_WEXT_STATE_PTR(adapter))->authKeyMgmt =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007188 0;
7189
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07007190 hdd_debug("Disabling queues");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007191 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05307192 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007193 WLAN_CONTROL_PATH);
7194
7195 } else {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007196 hdd_warn("%d Command Disassociate/Deauthenticate called but station is not in associated state",
Jeff Johnson99bac312016-06-28 10:38:18 -07007197 (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007198 }
7199 break;
7200 default:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007201 hdd_err("Unexpected cmd: %d", (int)mlme->cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007202 return -EINVAL;
7203 } /* end of switch */
7204
7205 EXIT();
7206
7207 return status;
7208
7209}
7210
7211/**
7212 * iw_set_mlme() - SSR wrapper for __iw_set_mlme()
7213 * @dev: pointer to net_device
7214 * @info: pointer to iw_request_info
7215 * @wrqu: pointer to iwreq_data
7216 * @extra: pointer to extra ioctl payload
7217 *
7218 * Return: 0 on success, error number otherwise
7219 */
7220static int iw_set_mlme(struct net_device *dev, struct iw_request_info *info,
7221 union iwreq_data *wrqu, char *extra)
7222{
7223 int ret;
7224
7225 cds_ssr_protect(__func__);
7226 ret = __iw_set_mlme(dev, info, wrqu, extra);
7227 cds_ssr_unprotect(__func__);
7228
7229 return ret;
7230}
7231
7232/**
7233 * wlan_hdd_update_phymode() - handle change in PHY mode
7234 * @net: device upon which PHY mode change was received
7235 * @hal: umac handle for the driver
7236 * @new_phymode: new PHY mode for the device
7237 * @phddctx: pointer to the HDD context
7238 *
7239 * This function is called when the device is set to a new PHY mode.
7240 * It takes a holistic look at the desired PHY mode along with the
7241 * configured capabilities of the driver and the reported capabilities
7242 * of the hardware in order to correctly configure all PHY-related
7243 * parameters.
7244 *
7245 * Return: 0 on success, negative errno value on error
7246 */
7247int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal,
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007248 int new_phymode, struct hdd_context *phddctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007249{
7250#ifdef QCA_HT_2040_COEX
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007251 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(net);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307252 QDF_STATUS halStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007253#endif
7254 bool band_24 = false, band_5g = false;
7255 bool ch_bond24 = false, ch_bond5g = false;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307256 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007257 uint32_t chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007258 uint32_t vhtchanwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007259 eCsrPhyMode phymode = -EIO, old_phymode;
Srinivas Girigowda2fb677c2017-03-25 15:35:34 -07007260 enum hdd_dot11_mode hdd_dot11mode = phddctx->config->dot11Mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007261 eCsrBand curr_band = eCSR_BAND_ALL;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307262 int retval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007263
7264 old_phymode = sme_get_phy_mode(hal);
7265
7266 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7267 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7268 nChannelBondingMode24GHz))
7269 ch_bond24 = true;
7270
7271 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
7272 sme_get_cb_phy_state_from_cb_ini_value(phddctx->config->
7273 nChannelBondingMode5GHz))
7274 ch_bond5g = true;
7275
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007276 if (phddctx->config->nBandCapability == eCSR_BAND_ALL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007277 band_24 = band_5g = true;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007278 else if (phddctx->config->nBandCapability == eCSR_BAND_24)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007279 band_24 = true;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007280 else if (phddctx->config->nBandCapability == eCSR_BAND_5G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007281 band_5g = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007282
7283 vhtchanwidth = phddctx->config->vhtChannelWidth;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007284 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 -08007285 ch_bond24, ch_bond5g, band_24, band_5g, vhtchanwidth);
7286
7287 switch (new_phymode) {
7288 case IEEE80211_MODE_AUTO:
7289 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007290 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007291 phymode = eCSR_DOT11_MODE_AUTO;
7292 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7293 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7294 curr_band = eCSR_BAND_ALL;
7295 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7296 } else {
7297 sme_set_phy_mode(hal, old_phymode);
7298 return -EIO;
7299 }
7300 break;
7301 case IEEE80211_MODE_11A:
7302 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11a);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007303 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007304 phymode = eCSR_DOT11_MODE_11a;
7305 hdd_dot11mode = eHDD_DOT11_MODE_11a;
7306 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7307 curr_band = eCSR_BAND_5G;
7308 } else {
7309 sme_set_phy_mode(hal, old_phymode);
7310 return -EIO;
7311 }
7312 break;
7313 case IEEE80211_MODE_11B:
7314 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11b);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007315 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007316 phymode = eCSR_DOT11_MODE_11b;
7317 hdd_dot11mode = eHDD_DOT11_MODE_11b;
7318 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7319 curr_band = eCSR_BAND_24;
7320 } else {
7321 sme_set_phy_mode(hal, old_phymode);
7322 return -EIO;
7323 }
7324 break;
7325 case IEEE80211_MODE_11G:
7326 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11g);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007327 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007328 phymode = eCSR_DOT11_MODE_11g;
7329 hdd_dot11mode = eHDD_DOT11_MODE_11g;
7330 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7331 curr_band = eCSR_BAND_24;
7332 } else {
7333 sme_set_phy_mode(hal, old_phymode);
7334 return -EIO;
7335 }
7336 break;
7337 /* UMAC doesnt have option to set MODE_11NA/MODE_11NG as phymode
7338 * so setting phymode as eCSR_DOT11_MODE_11n and updating the band
7339 * and channel bonding in configuration to reflect MODE_11NA/MODE_11NG
7340 */
7341 case IEEE80211_MODE_11NA_HT20:
7342 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007343 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007344 phymode = eCSR_DOT11_MODE_11n;
7345 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7346 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7347 curr_band = eCSR_BAND_5G;
7348 } else {
7349 sme_set_phy_mode(hal, old_phymode);
7350 return -EIO;
7351 }
7352 break;
7353 case IEEE80211_MODE_11NA_HT40:
7354 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007355 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007356 phymode = eCSR_DOT11_MODE_11n;
7357 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7358 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7359 curr_band = eCSR_BAND_5G;
7360 } else {
7361 sme_set_phy_mode(hal, old_phymode);
7362 return -EIO;
7363 }
7364 break;
7365 case IEEE80211_MODE_11NG_HT20:
7366 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007367 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007368 phymode = eCSR_DOT11_MODE_11n;
7369 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7370 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7371 curr_band = eCSR_BAND_24;
7372 } else {
7373 sme_set_phy_mode(hal, old_phymode);
7374 return -EIO;
7375 }
7376 break;
7377 case IEEE80211_MODE_11NG_HT40:
7378 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007379 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007380 phymode = eCSR_DOT11_MODE_11n;
7381 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7382 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7383 curr_band = eCSR_BAND_24;
7384 } else {
7385 sme_set_phy_mode(hal, old_phymode);
7386 return -EIO;
7387 }
7388 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007389 case IEEE80211_MODE_11AC_VHT20:
7390 case IEEE80211_MODE_11AC_VHT40:
7391 case IEEE80211_MODE_11AC_VHT80:
7392 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11ac);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007393 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007394 phymode = eCSR_DOT11_MODE_11ac;
7395 hdd_dot11mode = eHDD_DOT11_MODE_11ac;
7396 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7397 curr_band = eCSR_BAND_5G;
7398 } else {
7399 sme_set_phy_mode(hal, old_phymode);
7400 return -EIO;
7401 }
7402 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007403 case IEEE80211_MODE_2G_AUTO:
7404 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007405 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_2_4_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007406 phymode = eCSR_DOT11_MODE_AUTO;
7407 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7408 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7409 curr_band = eCSR_BAND_24;
7410 } else {
7411 sme_set_phy_mode(hal, old_phymode);
7412 return -EIO;
7413 }
7414 break;
7415 case IEEE80211_MODE_5G_AUTO:
7416 sme_set_phy_mode(hal, eCSR_DOT11_MODE_AUTO);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007417 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_5_GHZ) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007418 phymode = eCSR_DOT11_MODE_AUTO;
7419 hdd_dot11mode = eHDD_DOT11_MODE_AUTO;
7420 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7421 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7422 curr_band = eCSR_BAND_5G;
7423 } else {
7424 sme_set_phy_mode(hal, old_phymode);
7425 return -EIO;
7426 }
7427 break;
7428 case IEEE80211_MODE_11AGN:
7429 sme_set_phy_mode(hal, eCSR_DOT11_MODE_11n);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07007430 if (hdd_reg_set_band(net, WLAN_HDD_UI_BAND_AUTO) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007431 phymode = eCSR_DOT11_MODE_11n;
7432 hdd_dot11mode = eHDD_DOT11_MODE_11n;
7433 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
7434 curr_band = eCSR_BAND_ALL;
7435 } else {
7436 sme_set_phy_mode(hal, old_phymode);
7437 return -EIO;
7438 }
7439 break;
7440 default:
7441 return -EIO;
7442 }
7443
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007444 switch (new_phymode) {
7445 case IEEE80211_MODE_11AC_VHT20:
7446 chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
7447 vhtchanwidth = eHT_CHANNEL_WIDTH_20MHZ;
7448 break;
7449 case IEEE80211_MODE_11AC_VHT40:
7450 vhtchanwidth = eHT_CHANNEL_WIDTH_40MHZ;
7451 break;
7452 case IEEE80211_MODE_11AC_VHT80:
7453 vhtchanwidth = eHT_CHANNEL_WIDTH_80MHZ;
7454 break;
7455 default:
7456 vhtchanwidth = phddctx->config->vhtChannelWidth;
7457 break;
7458 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007459
7460 if (phymode != -EIO) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307461 sme_config = qdf_mem_malloc(sizeof(*sme_config));
7462 if (!sme_config) {
7463 hdd_err("Failed to allocate memory for sme_config");
7464 return -ENOMEM;
7465 }
7466 qdf_mem_zero(sme_config, sizeof(*sme_config));
7467 sme_get_config_param(hal, sme_config);
7468 sme_config->csrConfig.phyMode = phymode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007469#ifdef QCA_HT_2040_COEX
7470 if (phymode == eCSR_DOT11_MODE_11n &&
7471 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_DISABLE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307472 sme_config->csrConfig.obssEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007473 halStatus = sme_set_ht2040_mode(hal,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007474 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007475 eHT_CHAN_HT20, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307476 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007477 hdd_err("Failed to disable OBSS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307478 retval = -EIO;
7479 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007480 }
7481 } else if (phymode == eCSR_DOT11_MODE_11n &&
7482 chwidth == WNI_CFG_CHANNEL_BONDING_MODE_ENABLE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307483 sme_config->csrConfig.obssEnabled = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007484 halStatus = sme_set_ht2040_mode(hal,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007485 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007486 eHT_CHAN_HT20, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307487 if (halStatus == QDF_STATUS_E_FAILURE) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007488 hdd_err("Failed to enable OBSS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307489 retval = -EIO;
7490 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007491 }
7492 }
7493#endif
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307494 sme_config->csrConfig.eBand = curr_band;
7495 sme_config->csrConfig.bandCapability = curr_band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007496 if (curr_band == eCSR_BAND_24)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307497 sme_config->csrConfig.Is11hSupportEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007498 else
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307499 sme_config->csrConfig.Is11hSupportEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007500 phddctx->config->Is11hSupportEnabled;
7501 if (curr_band == eCSR_BAND_24)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307502 sme_config->csrConfig.channelBondingMode24GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007503 else if (curr_band == eCSR_BAND_24)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307504 sme_config->csrConfig.channelBondingMode5GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007505 else {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307506 sme_config->csrConfig.channelBondingMode24GHz = chwidth;
7507 sme_config->csrConfig.channelBondingMode5GHz = chwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007508 }
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307509 sme_config->csrConfig.nVhtChannelWidth = vhtchanwidth;
7510 sme_update_config(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007511
7512 phddctx->config->dot11Mode = hdd_dot11mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007513 phddctx->config->nChannelBondingMode24GHz =
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307514 sme_config->csrConfig.channelBondingMode24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007515 phddctx->config->nChannelBondingMode5GHz =
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307516 sme_config->csrConfig.channelBondingMode5GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007517 phddctx->config->vhtChannelWidth = vhtchanwidth;
Krunal Sonidf0f8742016-09-26 14:56:31 -07007518 if (hdd_update_config_cfg(phddctx) == false) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007519 hdd_err("could not update config_dat");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307520 retval = -EIO;
7521 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007522 }
Rajeev Kumar Sirasanagandla4c9b6752017-07-25 20:35:20 +05307523
7524 if (band_5g) {
7525 struct ieee80211_supported_band *band;
7526
7527 band = phddctx->wiphy->bands[HDD_NL80211_BAND_5GHZ];
7528 if (phddctx->config->nChannelBondingMode5GHz)
7529 band->ht_cap.cap |=
7530 IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7531 else
7532 band->ht_cap.cap &=
7533 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
7534 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007535
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007536 hdd_debug("New_Phymode= %d ch_bonding=%d band=%d VHT_ch_width=%u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007537 phymode, chwidth, curr_band, vhtchanwidth);
7538 }
7539
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307540free:
7541 if (sme_config)
7542 qdf_mem_free(sme_config);
7543 return retval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007544}
7545
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007546struct temperature_priv {
7547 int temperature;
7548};
7549
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007550/**
7551 * hdd_get_temperature_cb() - "Get Temperature" callback function
7552 * @temperature: measured temperature
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007553 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007554 *
7555 * This function is passed to sme_get_temperature() as the callback
7556 * function to be invoked when the temperature measurement is
7557 * available.
7558 *
7559 * Return: None
7560 */
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007561static void hdd_get_temperature_cb(int temperature, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007562{
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007563 struct hdd_request *request;
7564 struct temperature_priv *priv;
7565
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007566 ENTER();
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007567
7568 request = hdd_request_get(context);
7569 if (!request) {
7570 hdd_err("Obsolete request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007571 return;
7572 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007573
7574 priv = hdd_request_priv(request);
7575 priv->temperature = temperature;
7576 hdd_request_complete(request);
7577 hdd_request_put(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007578 EXIT();
7579}
7580
7581/**
7582 * wlan_hdd_get_temperature() - get current device temperature
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007583 * @adapter: device upon which the request was made
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007584 * @temperature: pointer to where the temperature is to be returned
7585 *
7586 * Return: 0 if a temperature value (either current or cached) was
7587 * returned, otherwise a negative errno is returned.
7588 *
7589 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007590int wlan_hdd_get_temperature(struct hdd_adapter *adapter, int *temperature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007591{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307592 QDF_STATUS status;
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007593 int ret;
7594 void *cookie;
7595 struct hdd_request *request;
7596 struct temperature_priv *priv;
7597 static const struct hdd_request_params params = {
7598 .priv_size = sizeof(*priv),
7599 .timeout_ms = WLAN_WAIT_TIME_STATS,
7600 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007601
7602 ENTER();
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007603 if (NULL == adapter) {
7604 hdd_err("adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007605 return -EPERM;
7606 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007607
7608 request = hdd_request_alloc(&params);
7609 if (!request) {
7610 hdd_err("Request allocation failure");
7611 return -ENOMEM;
7612 }
7613 cookie = hdd_request_cookie(request);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007614 status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007615 cookie, hdd_get_temperature_cb);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307616 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007617 hdd_err("Unable to retrieve temperature");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007618 } else {
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007619 ret = hdd_request_wait_for_response(request);
7620 if (ret) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007621 hdd_err("SME timed out while retrieving temperature");
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007622 } else {
7623 /* update the adapter with the fresh results */
7624 priv = hdd_request_priv(request);
7625 if (priv->temperature)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007626 adapter->temperature = priv->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007627 }
7628 }
Jeff Johnson0c5a2ba2017-01-23 16:36:43 -08007629
7630 /*
7631 * either we never sent a request, we sent a request and
7632 * received a response or we sent a request and timed out.
7633 * regardless we are done with the request.
7634 */
7635 hdd_request_put(request);
7636
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007637 *temperature = adapter->temperature;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007638 EXIT();
7639 return 0;
7640}
7641
Jeff Johnson011c4502017-10-05 15:25:56 -07007642static int hdd_validate_pdev_reset(int value)
7643{
7644 if ((value < 1) || (value > 5)) {
7645 hdd_warn(" Invalid value %d: Use any one of the below values\n"
7646 " TX_FLUSH = 1\n"
7647 " WARM_RESET = 2\n"
7648 " COLD_RESET = 3\n"
7649 " WARM_RESET_RESTORE_CAL = 4\n"
7650 " COLD_RESET_RESTORE_CAL = 5", value);
7651
7652 return -EINVAL;
7653 }
7654
7655 return 0;
7656}
7657
7658static int hdd_handle_pdev_reset(struct hdd_adapter *adapter, int value)
7659{
7660 int ret;
7661
7662 hdd_debug("%d", value);
7663
7664 ret = hdd_validate_pdev_reset(value);
7665 if (ret)
7666 return ret;
7667
7668 ret = wma_cli_set_command(adapter->sessionId,
7669 WMI_PDEV_PARAM_PDEV_RESET,
7670 value, PDEV_CMD);
7671
7672 return ret;
7673}
7674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007675/**
7676 * iw_setint_getnone() - Generic "set integer" private ioctl handler
7677 * @dev: device upon which the ioctl was received
7678 * @info: ioctl request information
7679 * @wrqu: ioctl request data
7680 * @extra: ioctl extra data
7681 *
7682 * Return: 0 on success, non-zero on error
7683 */
7684static int __iw_setint_getnone(struct net_device *dev,
7685 struct iw_request_info *info,
7686 union iwreq_data *wrqu, char *extra)
7687{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007688 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
7689 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07007690 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07007691 struct hdd_context *hdd_ctx;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307692 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007693 int *value = (int *)extra;
7694 int sub_cmd = value[0];
7695 int set_value = value[1];
7696 int ret;
7697 int enable_pbm, enable_mp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307698 QDF_STATUS status;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08007699 void *soc = NULL;
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08007700 struct cdp_pdev *pdev = NULL;
7701 struct cdp_vdev *vdev = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007702
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08007703 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05307704
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007705 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007706 ret = wlan_hdd_validate_context(hdd_ctx);
7707 if (0 != ret)
7708 return ret;
7709
Jeff Johnson441e1f72017-02-07 08:50:49 -08007710 ret = hdd_check_private_wext_control(hdd_ctx, info);
7711 if (0 != ret)
7712 return ret;
7713
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307714 sme_config = qdf_mem_malloc(sizeof(*sme_config));
7715 if (!sme_config) {
7716 hdd_err("failed to allocate memory for sme_config");
7717 return -ENOMEM;
7718 }
7719 qdf_mem_zero(sme_config, sizeof(*sme_config));
Jeff Johnson441e1f72017-02-07 08:50:49 -08007720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007721 switch (sub_cmd) {
7722 case WE_SET_11D_STATE:
7723 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307724 if (((ENABLE_11D == set_value)
7725 || (DISABLE_11D == set_value)) && hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007726
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307727 sme_get_config_param(hHal, sme_config);
7728 sme_config->csrConfig.Is11dSupportEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007729 (bool) set_value;
7730
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007731 hdd_debug("11D state=%d!!",
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307732 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007733 Is11dSupportEnabled);
7734
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307735 sme_update_config(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007736 } else {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307737 ret = -EINVAL;
7738 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007739 }
7740 break;
7741 }
7742
7743 case WE_WOWL:
7744 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307745 if (!hHal)
7746 return -EINVAL;
7747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007748 switch (set_value) {
7749 case 0x00:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007750 hdd_exit_wowl(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007751 break;
7752 case 0x01:
7753 case 0x02:
7754 case 0x03:
7755 enable_mp = (set_value & 0x01) ? 1 : 0;
7756 enable_pbm = (set_value & 0x02) ? 1 : 0;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007757 hdd_debug("magic packet ? = %s pattern byte matching ? = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007758 (enable_mp ? "YES" : "NO"),
7759 (enable_pbm ? "YES" : "NO"));
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007760 hdd_enter_wowl(adapter, enable_mp, enable_pbm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007761 break;
7762 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007763 hdd_err("Invalid arg %d in WE_WOWL IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007764 set_value);
7765 ret = -EINVAL;
7766 break;
7767 }
7768
7769 break;
7770 }
7771 case WE_SET_POWER:
7772 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307773 if (!hHal)
7774 return -EINVAL;
7775
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007776 switch (set_value) {
7777 case 1:
7778 /* Enable PowerSave */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007779 sme_ps_enable_disable(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007780 SME_PS_ENABLE);
7781 break;
7782 case 2:
7783 /* Disable PowerSave */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007784 sme_ps_enable_disable(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007785 SME_PS_DISABLE);
7786 break;
7787 case 3: /* Enable UASPD */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007788 sme_ps_uapsd_enable(hHal, adapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007789 break;
7790 case 4: /* Disable UASPD */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007791 sme_ps_uapsd_disable(hHal, adapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007792 break;
7793 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07007794 hdd_err("Invalid arg %d in WE_SET_POWER IOCTL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007795 set_value);
7796 ret = -EINVAL;
7797 break;
7798 }
7799 break;
7800 }
7801
7802 case WE_SET_MAX_ASSOC:
7803 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307804 if (!hHal)
7805 return -EINVAL;
7806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007807 if ((WNI_CFG_ASSOC_STA_LIMIT_STAMIN > set_value) ||
7808 (WNI_CFG_ASSOC_STA_LIMIT_STAMAX < set_value)) {
7809 ret = -EINVAL;
7810 } else if (sme_cfg_set_int(hHal, WNI_CFG_ASSOC_STA_LIMIT,
7811 set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307812 != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007813 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007814 ret = -EIO;
7815 }
7816 break;
7817 }
7818
7819 case WE_SET_SAP_AUTO_CHANNEL_SELECTION:
7820 if (set_value == 0 || set_value == 1)
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007821 (WLAN_HDD_GET_CTX(adapter))->config->force_sap_acs =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007822 set_value;
7823 else
7824 ret = -EINVAL;
7825 break;
7826
7827 case WE_SET_DATA_INACTIVITY_TO:
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307828 if (!hHal)
7829 return -EINVAL;
7830
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007831 if ((set_value < CFG_DATA_INACTIVITY_TIMEOUT_MIN) ||
7832 (set_value > CFG_DATA_INACTIVITY_TIMEOUT_MAX) ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007833 (sme_cfg_set_int((WLAN_HDD_GET_CTX(adapter))->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007834 WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307835 set_value) == QDF_STATUS_E_FAILURE)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007836 hdd_err("WNI_CFG_PS_DATA_INACTIVITY_TIMEOUT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007837 ret = -EINVAL;
7838 }
7839 break;
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05307840 case WE_SET_WOW_DATA_INACTIVITY_TO:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307841 if (!hHal) {
7842 ret = -EINVAL;
7843 goto free;
7844 }
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05307845
7846 if ((set_value < CFG_WOW_DATA_INACTIVITY_TIMEOUT_MIN) ||
7847 (set_value > CFG_WOW_DATA_INACTIVITY_TIMEOUT_MAX) ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007848 (sme_cfg_set_int((WLAN_HDD_GET_CTX(adapter))->hHal,
Mukul Sharmaed92f2f2017-04-20 00:06:28 +05307849 WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT,
7850 set_value) == QDF_STATUS_E_FAILURE)) {
7851 hdd_err("WNI_CFG_PS_WOW_DATA_INACTIVITY_TIMEOUT fail");
7852 ret = -EINVAL;
7853 }
7854 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007855 case WE_SET_MC_RATE:
7856 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307857 if (!hHal)
7858 return -EINVAL;
7859
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007860 ret = wlan_hdd_set_mc_rate(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007861 break;
7862 }
7863 case WE_SET_TX_POWER:
7864 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307865 struct qdf_mac_addr bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007866
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307867 if (!hHal)
7868 return -EINVAL;
7869
Jeff Johnsond377dce2017-10-04 10:32:42 -07007870 qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007871 if (sme_set_tx_power
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007872 (hHal, adapter->sessionId, bssid,
7873 adapter->device_mode,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307874 set_value) != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007875 hdd_err("Setting tx power failed");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307876 ret = -EIO;
7877 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007878 }
7879 break;
7880 }
7881 case WE_SET_MAX_TX_POWER:
7882 {
Anurag Chouhan6d760662016-02-20 16:05:43 +05307883 struct qdf_mac_addr bssid;
7884 struct qdf_mac_addr selfMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007885
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307886 if (!hHal)
7887 return -EINVAL;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007888
7889 hdd_debug("Setting maximum tx power %d dBm",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007890 set_value);
Jeff Johnsond377dce2017-10-04 10:32:42 -07007891 qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssId);
7892 qdf_copy_macaddr(&selfMac, &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007893
7894 if (sme_set_max_tx_power(hHal, bssid, selfMac, set_value)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307895 != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007896 hdd_err("Setting maximum tx power failed");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307897 ret = -EIO;
7898 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007899 }
7900
7901 break;
7902 }
7903 case WE_SET_MAX_TX_POWER_2_4:
7904 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007905 hdd_debug("Setting maximum tx power %d dBm for 2.4 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07007906 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007907 if (sme_set_max_tx_power_per_band(eCSR_BAND_24, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307908 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007909 hdd_err("Setting max tx power failed for 2.4 GHz band");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307910 ret = -EIO;
7911 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007912 }
7913
7914 break;
7915 }
7916 case WE_SET_MAX_TX_POWER_5_0:
7917 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007918 hdd_debug("Setting maximum tx power %d dBm for 5.0 GHz band",
Jeff Johnson99bac312016-06-28 10:38:18 -07007919 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007920 if (sme_set_max_tx_power_per_band(eCSR_BAND_5G, set_value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307921 QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07007922 hdd_err("Setting max tx power failed for 5.0 GHz band");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05307923 ret = -EIO;
7924 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007925 }
7926
7927 break;
7928 }
7929 case WE_SET_HIGHER_DTIM_TRANSITION:
7930 {
7931 if (!((set_value == false) || (set_value == true))) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007932 hdd_err("Dynamic DTIM Incorrect data:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007933 set_value);
7934 ret = -EINVAL;
7935 } else {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007936 if (adapter->higherDtimTransition != set_value) {
7937 adapter->higherDtimTransition =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007938 set_value;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007939 hdd_debug("higherDtimTransition set to :%d",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007940 adapter->higherDtimTransition);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007941 }
7942 }
7943
7944 break;
7945 }
7946
7947 case WE_SET_TM_LEVEL:
7948 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307949 if (!hHal)
7950 return -EINVAL;
7951
7952 hdd_notice("Set Thermal Mitigation Level %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007953 (void)sme_set_thermal_level(hHal, set_value);
7954 break;
7955 }
7956
7957 case WE_SET_PHYMODE:
7958 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007959 struct hdd_context *phddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07007960
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307961 if (!hHal)
7962 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963
7964 ret =
7965 wlan_hdd_update_phymode(dev, hHal, set_value,
7966 phddctx);
7967 break;
7968 }
7969
7970 case WE_SET_NSS:
7971 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05307972 if (!hHal)
7973 return -EINVAL;
7974
7975 hdd_notice("Set NSS = %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007976 if ((set_value > 2) || (set_value <= 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07007977 hdd_err("NSS greater than 2 not supported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007978 ret = -EINVAL;
7979 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307980 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007981 hdd_update_nss(WLAN_HDD_GET_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007982 set_value))
7983 ret = -EINVAL;
7984 }
7985 break;
7986 }
7987
7988 case WE_SET_GTX_HT_MCS:
7989 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007990 hdd_debug("WMI_VDEV_PARAM_GTX_HT_MCS %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07007991 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007992 WMI_VDEV_PARAM_GTX_HT_MCS,
7993 set_value, GTX_CMD);
7994 break;
7995 }
7996
7997 case WE_SET_GTX_VHT_MCS:
7998 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08007999 hdd_debug("WMI_VDEV_PARAM_GTX_VHT_MCS %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008000 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008001 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008002 WMI_VDEV_PARAM_GTX_VHT_MCS,
8003 set_value, GTX_CMD);
8004 break;
8005 }
8006
8007 case WE_SET_GTX_USRCFG:
8008 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008009 hdd_debug("WMI_VDEV_PARAM_GTX_USR_CFG %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008010 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008011 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008012 WMI_VDEV_PARAM_GTX_USR_CFG,
8013 set_value, GTX_CMD);
8014 break;
8015 }
8016
8017 case WE_SET_GTX_THRE:
8018 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008019 hdd_debug("WMI_VDEV_PARAM_GTX_THRE %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008020 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008021 WMI_VDEV_PARAM_GTX_THRE,
8022 set_value, GTX_CMD);
8023 break;
8024 }
8025
8026 case WE_SET_GTX_MARGIN:
8027 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008028 hdd_debug("WMI_VDEV_PARAM_GTX_MARGIN %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008029 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008030 WMI_VDEV_PARAM_GTX_MARGIN,
8031 set_value, GTX_CMD);
8032 break;
8033 }
8034
8035 case WE_SET_GTX_STEP:
8036 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008037 hdd_debug("WMI_VDEV_PARAM_GTX_STEP %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008038 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008039 WMI_VDEV_PARAM_GTX_STEP,
8040 set_value, GTX_CMD);
8041 break;
8042 }
8043
8044 case WE_SET_GTX_MINTPC:
8045 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008046 hdd_debug("WMI_VDEV_PARAM_GTX_MINTPC %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008047 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008048 WMI_VDEV_PARAM_GTX_MINTPC,
8049 set_value, GTX_CMD);
8050 break;
8051 }
8052
8053 case WE_SET_GTX_BWMASK:
8054 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008055 hdd_debug("WMI_VDEV_PARAM_GTX_BWMASK %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008056 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008057 WMI_VDEV_PARAM_GTX_BW_MASK,
8058 set_value, GTX_CMD);
8059 break;
8060 }
8061
8062 case WE_SET_LDPC:
8063 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05308064 if (!hHal)
8065 return -EINVAL;
8066
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008067 ret = hdd_set_ldpc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008068 break;
8069 }
8070
8071 case WE_SET_TX_STBC:
8072 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05308073 if (!hHal)
8074 return -EINVAL;
8075
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008076 ret = hdd_set_tx_stbc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008077 break;
8078 }
8079
8080 case WE_SET_RX_STBC:
8081 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05308082 if (!hHal)
8083 return -EINVAL;
8084
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008085 ret = hdd_set_rx_stbc(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008086 break;
8087 }
8088
8089 case WE_SET_SHORT_GI:
8090 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05308091 if (!hHal)
8092 return -EINVAL;
8093
8094 hdd_notice("WMI_VDEV_PARAM_SGI val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008095 ret = sme_update_ht_config(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008096 WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ,
8097 set_value);
8098 if (ret)
Jeff Johnson99bac312016-06-28 10:38:18 -07008099 hdd_err("Failed to set ShortGI value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008100 break;
8101 }
8102
8103 case WE_SET_RTSCTS:
8104 {
8105 uint32_t value;
8106
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05308107 if (!hHal)
8108 return -EINVAL;
8109
8110 hdd_notice("WMI_VDEV_PARAM_ENABLE_RTSCTS val 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008111 set_value);
8112
8113 if ((set_value & HDD_RTSCTS_EN_MASK) ==
8114 HDD_RTSCTS_ENABLE)
8115 value =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008116 (WLAN_HDD_GET_CTX(adapter))->config->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008117 RTSThreshold;
8118 else if (((set_value & HDD_RTSCTS_EN_MASK) == 0)
8119 || ((set_value & HDD_RTSCTS_EN_MASK) ==
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308120 HDD_CTS_ENABLE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008121 value = WNI_CFG_RTS_THRESHOLD_STAMAX;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308122 } else {
8123 ret = -EIO;
8124 goto free;
8125 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008126
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008127 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008128 WMI_VDEV_PARAM_ENABLE_RTSCTS,
8129 set_value, VDEV_CMD);
8130 if (!ret) {
8131 if (sme_cfg_set_int
8132 (hHal, WNI_CFG_RTS_THRESHOLD, value) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308133 QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008134 hdd_err("FAILED TO SET RTSCTS");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308135 ret = -EIO;
8136 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008137 }
8138 }
8139
8140 break;
8141 }
8142
8143 case WE_SET_CHWIDTH:
8144 {
8145 bool chwidth = false;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008146 struct hdd_context *phddctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07008147
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05308148 if (!hHal)
8149 return -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008151 /*updating channel bonding only on 5Ghz */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008152 hdd_debug("WMI_VDEV_PARAM_CHWIDTH val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008153 set_value);
8154 if (set_value > eHT_CHANNEL_WIDTH_80MHZ) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008155 hdd_err("Invalid channel width 0->20 1->40 2->80");
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308156 ret = -EINVAL;
8157 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008158 }
8159
8160 if ((WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
8161 csr_convert_cb_ini_value_to_phy_cb_state(phddctx->config->
8162 nChannelBondingMode5GHz)))
8163 chwidth = true;
8164
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308165 sme_get_config_param(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008166 switch (set_value) {
8167 case eHT_CHANNEL_WIDTH_20MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308168 sme_config->csrConfig.channelBondingMode5GHz =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008169 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
8170 break;
8171 case eHT_CHANNEL_WIDTH_40MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308172 if (chwidth) {
8173 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008174 channelBondingMode5GHz =
8175 phddctx->config->
8176 nChannelBondingMode5GHz;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308177 } else {
8178 ret = -EINVAL;
8179 goto free;
8180 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008181
8182 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008183 case eHT_CHANNEL_WIDTH_80MHZ:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308184 if (chwidth) {
8185 sme_config->csrConfig.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008186 channelBondingMode5GHz =
8187 phddctx->config->
8188 nChannelBondingMode5GHz;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308189 } else {
8190 ret = -EINVAL;
8191 goto free;
8192 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008193
8194 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008195
8196 default:
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308197 ret = -EINVAL;
8198 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008199 }
8200
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008201 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008202 WMI_VDEV_PARAM_CHWIDTH,
8203 set_value, VDEV_CMD);
8204 if (!ret)
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308205 sme_update_config(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008206
8207 break;
8208 }
8209
8210 case WE_SET_ANI_EN_DIS:
8211 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008212 hdd_debug("WMI_PDEV_PARAM_ANI_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008213 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008214 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008215 WMI_PDEV_PARAM_ANI_ENABLE,
8216 set_value, PDEV_CMD);
8217 break;
8218 }
8219
8220 case WE_SET_ANI_POLL_PERIOD:
8221 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008222 hdd_debug("WMI_PDEV_PARAM_ANI_POLL_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008223 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008224 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008225 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
8226 set_value, PDEV_CMD);
8227 break;
8228 }
8229
8230 case WE_SET_ANI_LISTEN_PERIOD:
8231 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008232 hdd_debug("WMI_PDEV_PARAM_ANI_LISTEN_PERIOD val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008233 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008234 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008235 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
8236 set_value, PDEV_CMD);
8237 break;
8238 }
8239
8240 case WE_SET_ANI_OFDM_LEVEL:
8241 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008242 hdd_debug("WMI_PDEV_PARAM_ANI_OFDM_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008243 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008244 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008245 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
8246 set_value, PDEV_CMD);
8247 break;
8248 }
8249
8250 case WE_SET_ANI_CCK_LEVEL:
8251 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008252 hdd_debug("WMI_PDEV_PARAM_ANI_CCK_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008253 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008254 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008255 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
8256 set_value, PDEV_CMD);
8257 break;
8258 }
8259
8260 case WE_SET_DYNAMIC_BW:
8261 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008262 hdd_debug("WMI_PDEV_PARAM_DYNAMIC_BW val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008263 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008264 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008265 WMI_PDEV_PARAM_DYNAMIC_BW,
8266 set_value, PDEV_CMD);
8267 break;
8268 }
8269
8270 case WE_SET_CTS_CBW:
8271 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008272 hdd_debug("WE_SET_CTS_CBW val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008273 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008274 WMI_PDEV_PARAM_CTS_CBW,
8275 set_value, PDEV_CMD);
8276 break;
8277 }
8278
8279 case WE_SET_11N_RATE:
8280 {
8281 uint8_t preamble = 0, nss = 0, rix = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07008282
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008283 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008284 set_value);
8285
8286 if (set_value != 0xff) {
8287 rix = RC_2_RATE_IDX(set_value);
8288 if (set_value & 0x80) {
8289 preamble = WMI_RATE_PREAMBLE_HT;
8290 nss = HT_RC_2_STREAMS(set_value) - 1;
8291 } else {
8292 nss = 0;
8293 rix = RC_2_RATE_IDX(set_value);
8294 if (set_value & 0x10) {
8295 preamble =
8296 WMI_RATE_PREAMBLE_CCK;
8297 if (rix != 0x3)
8298 /* Enable Short
8299 * preamble always for
8300 * CCK except 1mbps
8301 */
8302 rix |= 0x4;
8303 } else {
8304 preamble =
8305 WMI_RATE_PREAMBLE_OFDM;
8306 }
8307 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008308 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008309 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008310 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008311 set_value, rix, preamble, nss);
8312
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008313 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008314 WMI_VDEV_PARAM_FIXED_RATE,
8315 set_value, VDEV_CMD);
8316 break;
8317 }
8318
8319 case WE_SET_VHT_RATE:
8320 {
8321 uint8_t preamble = 0, nss = 0, rix = 0;
8322
8323 if (set_value != 0xff) {
8324 rix = RC_2_RATE_IDX_11AC(set_value);
8325 preamble = WMI_RATE_PREAMBLE_VHT;
8326 nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
8327
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008328 set_value = hdd_assemble_rate_code(preamble, nss, rix);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008329 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008330 hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008331 set_value, rix, preamble, nss);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008332 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008333 WMI_VDEV_PARAM_FIXED_RATE,
8334 set_value, VDEV_CMD);
8335 break;
8336 }
8337
8338 case WE_SET_AMPDU:
8339 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008340 hdd_debug("SET AMPDU val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008341 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008342 GEN_VDEV_PARAM_AMPDU,
8343 set_value, GEN_CMD);
8344 break;
8345 }
8346
8347 case WE_SET_AMSDU:
8348 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008349 hdd_debug("SET AMSDU val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008350 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008351 GEN_VDEV_PARAM_AMSDU,
8352 set_value, GEN_CMD);
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07008353 /* Update the stored ini value */
8354 if (!ret)
8355 hdd_ctx->config->max_amsdu_num = set_value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008356 break;
8357 }
8358
8359 case WE_SET_BURST_ENABLE:
8360 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008361 hdd_debug("SET Burst enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008362 if ((set_value == 0) || (set_value == 1)) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008363 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008364 WMI_PDEV_PARAM_BURST_ENABLE,
8365 set_value, PDEV_CMD);
8366 } else
8367 ret = -EINVAL;
8368 break;
8369 }
8370 case WE_SET_BURST_DUR:
8371 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008372 hdd_debug("SET Burst duration val %d", set_value);
Jeff Johnsonda5ee772016-08-04 17:18:47 -07008373 if ((set_value > 0) && (set_value <= 102400))
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008374 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008375 WMI_PDEV_PARAM_BURST_DUR,
8376 set_value, PDEV_CMD);
8377 else
8378 ret = -EINVAL;
8379 break;
8380 }
8381
8382 case WE_SET_TX_CHAINMASK:
8383 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008384 hdd_debug("WMI_PDEV_PARAM_TX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008385 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008386 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008387 WMI_PDEV_PARAM_TX_CHAIN_MASK,
8388 set_value, PDEV_CMD);
8389 break;
8390 }
8391
8392 case WE_SET_RX_CHAINMASK:
8393 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008394 hdd_debug("WMI_PDEV_PARAM_RX_CHAIN_MASK val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008395 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008396 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008397 WMI_PDEV_PARAM_RX_CHAIN_MASK,
8398 set_value, PDEV_CMD);
8399 break;
8400 }
8401
8402 case WE_SET_TXPOW_2G:
8403 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008404 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT2G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008405 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008406 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008407 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
8408 set_value, PDEV_CMD);
8409 break;
8410 }
8411
8412 case WE_SET_TXPOW_5G:
8413 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008414 hdd_debug("WMI_PDEV_PARAM_TXPOWER_LIMIT5G val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008415 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008416 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008417 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
8418 set_value, PDEV_CMD);
8419 break;
8420 }
8421
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008422 /* Firmware debug log */
8423 case WE_DBGLOG_LOG_LEVEL:
8424 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008425 hdd_debug("WE_DBGLOG_LOG_LEVEL val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008426 hdd_ctx->fw_log_settings.dl_loglevel = set_value;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008427 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008428 WMI_DBGLOG_LOG_LEVEL,
8429 set_value, DBG_CMD);
8430 break;
8431 }
8432
8433 case WE_DBGLOG_VAP_ENABLE:
8434 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008435 hdd_debug("WE_DBGLOG_VAP_ENABLE val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008436 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008437 WMI_DBGLOG_VAP_ENABLE,
8438 set_value, DBG_CMD);
8439 break;
8440 }
8441
8442 case WE_DBGLOG_VAP_DISABLE:
8443 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008444 hdd_debug("WE_DBGLOG_VAP_DISABLE val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008445 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446 WMI_DBGLOG_VAP_DISABLE,
8447 set_value, DBG_CMD);
8448 break;
8449 }
8450
8451 case WE_DBGLOG_MODULE_ENABLE:
8452 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008453 hdd_debug("WE_DBGLOG_MODULE_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008454 set_value);
8455 hdd_ctx->fw_log_settings.enable = set_value;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008456 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008457 WMI_DBGLOG_MODULE_ENABLE,
8458 set_value, DBG_CMD);
8459 break;
8460 }
8461
8462 case WE_DBGLOG_MODULE_DISABLE:
8463 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008464 hdd_debug("WE_DBGLOG_MODULE_DISABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008465 set_value);
8466 hdd_ctx->fw_log_settings.enable = set_value;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008467 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008468 WMI_DBGLOG_MODULE_DISABLE,
8469 set_value, DBG_CMD);
8470 break;
8471 }
8472 case WE_DBGLOG_MOD_LOG_LEVEL:
8473 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008474 hdd_debug("WE_DBGLOG_MOD_LOG_LEVEL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008475 set_value);
8476
8477 if (hdd_ctx->fw_log_settings.index >= MAX_MOD_LOGLEVEL)
8478 hdd_ctx->fw_log_settings.index = 0;
8479
8480 hdd_ctx->fw_log_settings.
8481 dl_mod_loglevel[hdd_ctx->fw_log_settings.index] =
8482 set_value;
8483 hdd_ctx->fw_log_settings.index++;
8484
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008485 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008486 WMI_DBGLOG_MOD_LOG_LEVEL,
8487 set_value, DBG_CMD);
8488 break;
8489 }
8490
8491 case WE_DBGLOG_TYPE:
8492 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008493 hdd_debug("WE_DBGLOG_TYPE val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008494 hdd_ctx->fw_log_settings.dl_type = set_value;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008495 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008496 WMI_DBGLOG_TYPE,
8497 set_value, DBG_CMD);
8498 break;
8499 }
8500 case WE_DBGLOG_REPORT_ENABLE:
8501 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008502 hdd_debug("WE_DBGLOG_REPORT_ENABLE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008503 set_value);
8504 hdd_ctx->fw_log_settings.dl_report = set_value;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008505 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008506 WMI_DBGLOG_REPORT_ENABLE,
8507 set_value, DBG_CMD);
8508 break;
8509 }
8510
8511 case WE_SET_TXRX_FWSTATS:
8512 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008513 hdd_debug("WE_SET_TXRX_FWSTATS val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008514 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008515 WMA_VDEV_TXRX_FWSTATS_ENABLE_CMDID,
8516 set_value, VDEV_CMD);
8517 break;
8518 }
8519
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008520 case WE_SET_TXRX_STATS:
8521 {
8522 hdd_notice("WE_SET_TXRX_STATS val %d", set_value);
8523 ret = cds_get_datapath_handles(&soc, &pdev, &vdev,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008524 adapter->sessionId);
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008525
Venkata Sharath Chandra Manchalabcdfdb12017-03-29 19:25:45 -07008526 if (ret != 0) {
8527 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
8528 "Invalid handles");
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008529 break;
Venkata Sharath Chandra Manchalabcdfdb12017-03-29 19:25:45 -07008530 }
8531 ret = cdp_txrx_stats(soc, vdev, set_value);
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -08008532 break;
8533 }
8534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008535 case WE_TXRX_FWSTATS_RESET:
8536 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008537 hdd_debug("WE_TXRX_FWSTATS_RESET val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008538 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008539 WMA_VDEV_TXRX_FWSTATS_RESET_CMDID,
8540 set_value, VDEV_CMD);
8541 break;
8542 }
8543
8544 case WE_DUMP_STATS:
8545 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008546 hdd_debug("WE_DUMP_STATS val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008547 ret = hdd_wlan_dump_stats(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008548 break;
8549 }
8550
8551 case WE_CLEAR_STATS:
8552 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008553 hdd_debug("WE_CLEAR_STATS val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008554 switch (set_value) {
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008555 case CDP_HDD_STATS:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008556 memset(&adapter->stats, 0, sizeof(adapter->stats));
8557 memset(&adapter->hdd_stats, 0,
8558 sizeof(adapter->hdd_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008559 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008560 case CDP_TXRX_HIST_STATS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008561 wlan_hdd_clear_tx_rx_histogram(hdd_ctx);
8562 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008563 case CDP_HDD_NETIF_OPER_HISTORY:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008564 wlan_hdd_clear_netif_queue_history(hdd_ctx);
8565 break;
Venkata Sharath Chandra Manchala71032b62017-03-29 12:30:45 -07008566 case CDP_HIF_STATS:
Nirav Shahbf1b0332016-05-25 14:27:39 +05308567 hdd_clear_hif_stats();
8568 break;
Yun Park1027e8c2017-10-13 15:17:37 -07008569 case CDP_NAPI_STATS:
8570 hdd_clear_napi_stats();
8571 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008572 default:
Leo Changfdb45c32016-10-28 11:09:23 -07008573 cdp_clear_stats(cds_get_context(QDF_MODULE_ID_SOC),
8574 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008575 }
8576 break;
8577 }
8578
8579 case WE_PPS_PAID_MATCH:
8580 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008581 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308582 ret = -EINVAL;
8583 goto free;
8584 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008585
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008586 hdd_debug("WMI_VDEV_PPS_PAID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008587 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008588 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008589 WMI_VDEV_PPS_PAID_MATCH,
8590 set_value, PPS_CMD);
8591 break;
8592 }
8593
8594 case WE_PPS_GID_MATCH:
8595 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008596 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308597 ret = -EINVAL;
8598 goto free;
8599 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008600 hdd_debug("WMI_VDEV_PPS_GID_MATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008601 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008602 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008603 WMI_VDEV_PPS_GID_MATCH,
8604 set_value, PPS_CMD);
8605 break;
8606 }
8607
8608 case WE_PPS_EARLY_TIM_CLEAR:
8609 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008610 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308611 ret = -EINVAL;
8612 goto free;
8613 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008614 hdd_debug(" WMI_VDEV_PPS_EARLY_TIM_CLEAR val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008615 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008616 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008617 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
8618 set_value, PPS_CMD);
8619 break;
8620 }
8621
8622 case WE_PPS_EARLY_DTIM_CLEAR:
8623 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008624 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308625 ret = -EINVAL;
8626 goto free;
8627 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008628 hdd_debug("WMI_VDEV_PPS_EARLY_DTIM_CLEAR val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008629 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008630 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008631 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
8632 set_value, PPS_CMD);
8633 break;
8634 }
8635
8636 case WE_PPS_EOF_PAD_DELIM:
8637 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008638 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308639 ret = -EINVAL;
8640 goto free;
8641 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008642 hdd_debug("WMI_VDEV_PPS_EOF_PAD_DELIM val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008643 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008644 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008645 WMI_VDEV_PPS_EOF_PAD_DELIM,
8646 set_value, PPS_CMD);
8647 break;
8648 }
8649
8650 case WE_PPS_MACADDR_MISMATCH:
8651 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008652 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308653 ret = -EINVAL;
8654 goto free;
8655 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008656 hdd_debug("WMI_VDEV_PPS_MACADDR_MISMATCH val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008657 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008658 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008659 WMI_VDEV_PPS_MACADDR_MISMATCH,
8660 set_value, PPS_CMD);
8661 break;
8662 }
8663
8664 case WE_PPS_DELIM_CRC_FAIL:
8665 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008666 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308667 ret = -EINVAL;
8668 goto free;
8669 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008670 hdd_debug("WMI_VDEV_PPS_DELIM_CRC_FAIL val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008671 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008672 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008673 WMI_VDEV_PPS_DELIM_CRC_FAIL,
8674 set_value, PPS_CMD);
8675 break;
8676 }
8677
8678 case WE_PPS_GID_NSTS_ZERO:
8679 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008680 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308681 ret = -EINVAL;
8682 goto free;
8683 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008684 hdd_debug("WMI_VDEV_PPS_GID_NSTS_ZERO val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008685 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008686 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008687 WMI_VDEV_PPS_GID_NSTS_ZERO,
8688 set_value, PPS_CMD);
8689 break;
8690 }
8691
8692 case WE_PPS_RSSI_CHECK:
8693 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008694 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308695 ret = -EINVAL;
8696 goto free;
8697 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008698 hdd_debug("WMI_VDEV_PPS_RSSI_CHECK val %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008699 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008700 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008701 WMI_VDEV_PPS_RSSI_CHECK,
8702 set_value, PPS_CMD);
8703 break;
8704 }
8705
8706 case WE_PPS_5G_EBT:
8707 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008708 if (adapter->device_mode != QDF_STA_MODE) {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308709 ret = -EINVAL;
8710 goto free;
8711 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008712
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008713 hdd_debug("WMI_VDEV_PPS_5G_EBT val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008714 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008715 WMI_VDEV_PPS_5G_EBT,
8716 set_value, PPS_CMD);
8717 break;
8718 }
8719
8720 case WE_SET_HTSMPS:
8721 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008722 hdd_debug("WE_SET_HTSMPS val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008723 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008724 WMI_STA_SMPS_FORCE_MODE_CMDID,
8725 set_value, VDEV_CMD);
8726 break;
8727 }
8728
8729 case WE_SET_QPOWER_MAX_PSPOLL_COUNT:
8730 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008731 hdd_debug("WE_SET_QPOWER_MAX_PSPOLL_COUNT val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008732 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008733 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008734 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
8735 set_value, QPOWER_CMD);
8736 break;
8737 }
8738
8739 case WE_SET_QPOWER_MAX_TX_BEFORE_WAKE:
8740 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008741 hdd_debug("WE_SET_QPOWER_MAX_TX_BEFORE_WAKE val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008742 set_value);
8743 ret = wma_cli_set_command(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008744 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008745 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
8746 set_value, QPOWER_CMD);
8747 break;
8748 }
8749
8750 case WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
8751 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008752 hdd_debug("WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008753 set_value);
8754 ret = wma_cli_set_command(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008755 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008756 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
8757 set_value, QPOWER_CMD);
8758 break;
8759 }
8760
8761 case WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
8762 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008763 hdd_debug("WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008764 set_value);
8765 ret = wma_cli_set_command(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008766 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008767 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
8768 set_value, QPOWER_CMD);
8769 break;
8770 }
8771
8772 case WE_MCC_CONFIG_LATENCY:
8773 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008774 wlan_hdd_set_mcc_latency(adapter, set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008775 break;
8776 }
8777
8778 case WE_MCC_CONFIG_QUOTA:
8779 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008780 hdd_debug("iwpriv cmd to set MCC quota with val %dms",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008781 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008782 ret = wlan_hdd_set_mcc_p2p_quota(adapter,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08008783 set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008784 break;
8785 }
8786 case WE_SET_DEBUG_LOG:
8787 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008788 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07008789
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05308790 if (!hHal)
8791 return -EINVAL;
8792
Nirav Shah1da77682016-05-03 20:16:39 +05308793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008794 hdd_ctx->config->gEnableDebugLog = set_value;
8795 sme_update_connect_debug(hdd_ctx->hHal, set_value);
8796 break;
8797 }
8798 case WE_SET_EARLY_RX_ADJUST_ENABLE:
8799 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008800 hdd_debug("SET early_rx enable val %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008801 if ((set_value == 0) || (set_value == 1))
8802 ret = wma_cli_set_command(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008803 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008804 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE,
8805 set_value, VDEV_CMD);
8806 else
8807 ret = -EINVAL;
8808 break;
8809 }
8810 case WE_SET_EARLY_RX_TGT_BMISS_NUM:
8811 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008812 hdd_debug("SET early_rx bmiss val %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008813 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008814 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM,
8815 set_value, VDEV_CMD);
8816 break;
8817 }
8818 case WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE:
8819 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008820 hdd_debug("SET early_rx bmiss sample cycle %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008821 set_value);
8822 ret = wma_cli_set_command(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008823 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008824 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE,
8825 set_value, VDEV_CMD);
8826 break;
8827 }
8828 case WE_SET_EARLY_RX_SLOP_STEP:
8829 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008830 hdd_debug("SET early_rx bmiss slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008831 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008832 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008833 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP,
8834 set_value, VDEV_CMD);
8835 break;
8836 }
8837 case WE_SET_EARLY_RX_INIT_SLOP:
8838 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008839 hdd_debug("SET early_rx init slop step val %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008840 set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008841 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008842 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP,
8843 set_value, VDEV_CMD);
8844 break;
8845 }
8846 case WE_SET_EARLY_RX_ADJUST_PAUSE:
8847 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008848 hdd_debug("SET early_rx adjust pause %d", set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008849 if ((set_value == 0) || (set_value == 1))
8850 ret = wma_cli_set_command(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008851 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008852 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE,
8853 set_value, VDEV_CMD);
8854 else
8855 ret = -EINVAL;
8856 break;
8857 }
8858 case WE_SET_EARLY_RX_DRIFT_SAMPLE:
8859 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008860 hdd_debug("SET early_rx drift sample %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008861 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008862 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE,
8863 set_value, VDEV_CMD);
8864 break;
8865 }
8866 case WE_SET_SCAN_DISABLE:
8867 {
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05308868 if (!hHal)
8869 return -EINVAL;
8870
8871 hdd_notice("SET SCAN DISABLE %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008872 sme_set_scan_disable(WLAN_HDD_GET_HAL_CTX(adapter), set_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008873 break;
8874 }
Govind Singha471e5e2015-10-12 17:11:14 +05308875 case WE_START_FW_PROFILE:
8876 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008877 hdd_debug("WE_START_FW_PROFILE %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008878 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +05308879 WMI_WLAN_PROFILE_TRIGGER_CMDID,
8880 set_value, DBG_CMD);
8881 break;
8882 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308883 case WE_SET_CHANNEL:
8884 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008885 hdd_debug("Set Channel %d Session ID %d mode %d", set_value,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008886 adapter->sessionId, adapter->device_mode);
SaidiReddy Yenuga8cbd9212017-02-15 15:35:29 +05308887 if (!hHal)
8888 return -EINVAL;
8889
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308890
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008891 if ((QDF_STA_MODE == adapter->device_mode) ||
8892 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308893
8894 status = sme_ext_change_channel(hHal,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008895 set_value, adapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308896 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson99bac312016-06-28 10:38:18 -07008897 hdd_err("Error in change channel status %d",
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308898 status);
8899 ret = -EINVAL;
8900 }
8901 } else {
Jeff Johnson99bac312016-06-28 10:38:18 -07008902 hdd_err("change channel not supported for device mode %d",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008903 adapter->device_mode);
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308904 ret = -EINVAL;
8905 }
8906 break;
8907 }
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308908 case WE_SET_CONC_SYSTEM_PREF:
8909 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08008910 hdd_debug("New preference: %d", set_value);
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308911 if (!((set_value >= CFG_CONC_SYSTEM_PREF_MIN) &&
8912 (set_value <= CFG_CONC_SYSTEM_PREF_MAX))) {
8913 hdd_err("Invalid system preference %d", set_value);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308914 ret = -EINVAL;
8915 goto free;
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308916 }
Abhishek Singh1bdb1572015-10-16 16:24:19 +05308917
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +05308918 /* hdd_ctx, hdd_ctx->config are already checked for null */
8919 hdd_ctx->config->conc_system_pref = set_value;
8920 break;
8921 }
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008922 case WE_SET_11AX_RATE:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008923 ret = hdd_set_11ax_rate(adapter, set_value, NULL);
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -08008924 break;
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07008925 case WE_SET_DCM:
8926 hdd_notice("Set WMI_VDEV_PARAM_HE_DCM: %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008927 ret = wma_cli_set_command(adapter->sessionId,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07008928 WMI_VDEV_PARAM_HE_DCM, set_value,
8929 VDEV_CMD);
8930 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07008931 case WE_SET_RANGE_EXT:
8932 hdd_notice("Set WMI_VDEV_PARAM_HE_RANGE_EXT: %d", set_value);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07008933 ret = wma_cli_set_command(adapter->sessionId,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07008934 WMI_VDEV_PARAM_HE_RANGE_EXT,
8935 set_value, VDEV_CMD);
8936 break;
Jeff Johnson011c4502017-10-05 15:25:56 -07008937 case WE_SET_PDEV_RESET:
8938 ret = hdd_handle_pdev_reset(adapter, set_value);
8939 break;
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +05308940 case WE_SET_MODULATED_DTIM:
8941 {
8942 if ((set_value < CFG_ENABLE_MODULATED_DTIM_MIN) ||
8943 (set_value > CFG_ENABLE_MODULATED_DTIM_MAX)) {
8944 hdd_err("Invalid gEnableModuleDTIM value %d",
8945 set_value);
8946 return -EINVAL;
8947 } else {
8948 hdd_ctx->config->enableModulatedDTIM = set_value;
8949 }
8950 break;
8951 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008952 default:
Jeff Johnson011c4502017-10-05 15:25:56 -07008953 hdd_err("Invalid sub command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008954 ret = -EINVAL;
8955 break;
8956 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05308957 EXIT();
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05308958free:
8959 qdf_mem_free(sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008960 return ret;
8961}
8962
8963static int iw_setint_getnone(struct net_device *dev,
8964 struct iw_request_info *info,
8965 union iwreq_data *wrqu,
8966 char *extra)
8967{
8968 int ret;
8969
8970 cds_ssr_protect(__func__);
8971 ret = __iw_setint_getnone(dev, info, wrqu, extra);
8972 cds_ssr_unprotect(__func__);
8973
8974 return ret;
8975}
8976
8977/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008978 * __iw_setnone_get_threeint() - return three value to up layer.
8979 *
8980 * @dev: pointer of net_device of this wireless card
8981 * @info: meta data about Request sent
8982 * @wrqu: include request info
8983 * @extra: buf used for in/Output
8984 *
8985 * Return: execute result
8986 */
8987static int __iw_setnone_get_threeint(struct net_device *dev,
8988 struct iw_request_info *info,
8989 union iwreq_data *wrqu, char *extra)
8990{
8991 int ret = 0; /* success */
8992 uint32_t *value = (int *)extra;
Jeff Johnson3d278b02017-08-29 14:17:47 -07008993 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07008994 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07008995
8996 ENTER_DEV(dev);
8997 ret = wlan_hdd_validate_context(hdd_ctx);
8998 if (0 != ret)
8999 return ret;
9000
Jeff Johnson441e1f72017-02-07 08:50:49 -08009001 ret = hdd_check_private_wext_control(hdd_ctx, info);
9002 if (0 != ret)
9003 return ret;
9004
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009005 hdd_debug("param = %d", value[0]);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009006 switch (value[0]) {
9007 case WE_GET_TSF:
9008 ret = hdd_indicate_tsf(adapter, value, 3);
9009 break;
9010 default:
9011 hdd_err("Invalid IOCTL get_value command %d", value[0]);
9012 break;
9013 }
9014 return ret;
9015}
9016
9017/**
9018 * iw_setnone_get_threeint() - return three value to up layer.
9019 *
9020 * @dev: pointer of net_device of this wireless card
9021 * @info: meta data about Request sent
9022 * @wrqu: include request info
9023 * @extra: buf used for in/Output
9024 *
9025 * Return: execute result
9026 */
9027static int iw_setnone_get_threeint(struct net_device *dev,
9028 struct iw_request_info *info,
9029 union iwreq_data *wrqu, char *extra)
9030{
9031 int ret;
9032
9033 cds_ssr_protect(__func__);
9034 ret = __iw_setnone_get_threeint(dev, info, wrqu, extra);
9035 cds_ssr_unprotect(__func__);
9036
9037 return ret;
9038}
9039
9040/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009041 * iw_setchar_getnone() - Generic "set string" private ioctl handler
9042 * @dev: device upon which the ioctl was received
9043 * @info: ioctl request information
9044 * @wrqu: ioctl request data
9045 * @extra: ioctl extra data
9046 *
9047 * Return: 0 on success, non-zero on error
9048 */
9049static int __iw_setchar_getnone(struct net_device *dev,
9050 struct iw_request_info *info,
9051 union iwreq_data *wrqu, char *extra)
9052{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309053 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009054 int sub_cmd;
9055 int ret;
9056 char *pBuffer = NULL;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009057 struct hdd_adapter *adapter = (netdev_priv(dev));
9058 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009059 struct hdd_config *pConfig = hdd_ctx->config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009060 struct iw_point s_priv_data;
9061
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009062 ENTER_DEV(dev);
9063
Mukul Sharma34777c62015-11-02 20:22:30 +05309064 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009065 hdd_err("permission check failed");
Mukul Sharma34777c62015-11-02 20:22:30 +05309066 return -EPERM;
9067 }
9068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009069 ret = wlan_hdd_validate_context(hdd_ctx);
9070 if (0 != ret)
9071 return ret;
9072
Jeff Johnson441e1f72017-02-07 08:50:49 -08009073 ret = hdd_check_private_wext_control(hdd_ctx, info);
9074 if (0 != ret)
9075 return ret;
9076
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009077 /* helper function to get iwreq_data with compat handling. */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009078 if (hdd_priv_get_data(&s_priv_data, wrqu))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009079 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009080
9081 /* make sure all params are correctly passed to function */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009082 if ((NULL == s_priv_data.pointer) || (0 == s_priv_data.length))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009083 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009084
9085 sub_cmd = s_priv_data.flags;
9086
9087 /* ODD number is used for set, copy data using copy_from_user */
9088 pBuffer = mem_alloc_copy_from_user_helper(s_priv_data.pointer,
9089 s_priv_data.length);
9090 if (NULL == pBuffer) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009091 hdd_err("mem_alloc_copy_from_user_helper fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009092 return -ENOMEM;
9093 }
9094
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009095 hdd_debug("Received length: %d data: %s",
9096 s_priv_data.length, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009097
9098 switch (sub_cmd) {
9099 case WE_WOWL_ADD_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009100 hdd_debug("ADD_PTRN");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009101 hdd_add_wowl_ptrn(adapter, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009102 break;
9103 case WE_WOWL_DEL_PTRN:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009104 hdd_debug("DEL_PTRN");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009105 hdd_del_wowl_ptrn(adapter, pBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009106 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009107 case WE_NEIGHBOR_REPORT_REQUEST:
9108 {
9109 tRrmNeighborReq neighborReq;
9110 tRrmNeighborRspCallbackInfo callbackInfo;
9111
9112 if (pConfig->fRrmEnable) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009113 hdd_debug("Neighbor Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009114 neighborReq.no_ssid =
9115 (s_priv_data.length - 1) ? false : true;
9116 if (!neighborReq.no_ssid) {
9117 neighborReq.ssid.length =
9118 (s_priv_data.length - 1) >
9119 32 ? 32 : (s_priv_data.length - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309120 qdf_mem_copy(neighborReq.ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009121 pBuffer,
9122 neighborReq.ssid.length);
9123 }
9124
9125 callbackInfo.neighborRspCallback = NULL;
9126 callbackInfo.neighborRspCallbackContext = NULL;
9127 callbackInfo.timeout = 5000; /* 5 seconds */
9128 sme_neighbor_report_request(WLAN_HDD_GET_HAL_CTX
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009129 (adapter),
9130 adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009131 &neighborReq,
9132 &callbackInfo);
9133 } else {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009134 hdd_err("Ignoring neighbor request as RRM not enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009135 ret = -EINVAL;
9136 }
9137 }
9138 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009139 case WE_SET_AP_WPS_IE:
Wu Gao02bd75b2017-10-13 18:34:02 +08009140 hdd_debug("Received WE_SET_AP_WPS_IE, won't process");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009141 break;
9142 case WE_SET_CONFIG:
9143 vstatus = hdd_execute_global_config_command(hdd_ctx, pBuffer);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009144 if (QDF_STATUS_SUCCESS != vstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009145 ret = -EINVAL;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009147 break;
9148 default:
9149 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009150 hdd_err("Invalid sub command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009151 sub_cmd);
9152 ret = -EINVAL;
9153 break;
9154 }
9155 }
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07009156 qdf_mem_free(pBuffer);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309157 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009158 return ret;
9159}
9160
9161static int iw_setchar_getnone(struct net_device *dev,
9162 struct iw_request_info *info,
9163 union iwreq_data *wrqu, char *extra)
9164{
9165 int ret;
9166
9167 cds_ssr_protect(__func__);
9168 ret = __iw_setchar_getnone(dev, info, wrqu, extra);
9169 cds_ssr_unprotect(__func__);
9170
9171 return ret;
9172}
9173
9174/**
9175 * iw_setnone_getint() - Generic "get integer" private ioctl handler
9176 * @dev: device upon which the ioctl was received
9177 * @info: ioctl request information
9178 * @wrqu: ioctl request data
9179 * @extra: ioctl extra data
9180 *
9181 * Return: 0 on success, non-zero on error
9182 */
9183static int __iw_setnone_getint(struct net_device *dev,
9184 struct iw_request_info *info,
9185 union iwreq_data *wrqu, char *extra)
9186{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009187 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
9188 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009189 int *value = (int *)extra;
9190 int ret;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309191 tSmeConfigParams *sme_config;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009192 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009193
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309194 sme_config = qdf_mem_malloc(sizeof(*sme_config));
9195 if (!sme_config) {
9196 hdd_err("failed to allocate memory for sme_config");
9197 return -ENOMEM;
9198 }
9199 qdf_mem_zero(sme_config, sizeof(*sme_config));
9200
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009201 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309202
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009203 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009204 ret = wlan_hdd_validate_context(hdd_ctx);
9205 if (0 != ret)
9206 return ret;
9207
Jeff Johnson441e1f72017-02-07 08:50:49 -08009208 ret = hdd_check_private_wext_control(hdd_ctx, info);
9209 if (0 != ret)
9210 return ret;
9211
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009212 switch (value[0]) {
9213 case WE_GET_11D_STATE:
9214 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309215 sme_get_config_param(hHal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009216
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309217 *value = sme_config->csrConfig.Is11dSupportEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009218
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009219 hdd_debug("11D state=%d!!", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009220
9221 break;
9222 }
9223
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009224 case WE_GET_WLAN_DBG:
9225 {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309226 qdf_trace_display();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009227 *value = 0;
9228 break;
9229 }
9230 case WE_GET_MAX_ASSOC:
9231 {
9232 if (sme_cfg_get_int
9233 (hHal, WNI_CFG_ASSOC_STA_LIMIT,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309234 (uint32_t *) value) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009235 hdd_err("WNI_CFG_ASSOC_STA_LIMIT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009236 ret = -EIO;
9237 }
9238 break;
9239 }
9240 case WE_GET_SAP_AUTO_CHANNEL_SELECTION:
9241 *value = (WLAN_HDD_GET_CTX(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009242 adapter))->config->force_sap_acs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009243 break;
9244
9245 case WE_GET_CONCURRENCY_MODE:
9246 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08009247 *value = policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009248
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009249 hdd_debug("concurrency mode=%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009250 break;
9251 }
9252
9253 case WE_GET_NSS:
9254 {
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309255 sme_get_config_param(hHal, sme_config);
9256 *value = (sme_config->csrConfig.enable2x2 == 0) ? 1 : 2;
Srinivas Girigowda576b2352017-08-25 14:44:26 -07009257 if (policy_mgr_is_current_hwmode_dbs(hdd_ctx->hdd_psoc))
9258 *value = *value - 1;
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009259 hdd_debug("GET_NSS: Current NSS:%d", *value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009260 break;
9261 }
9262
9263 case WE_GET_GTX_HT_MCS:
9264 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009265 hdd_debug("GET WMI_VDEV_PARAM_GTX_HT_MCS");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009266 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009267 WMI_VDEV_PARAM_GTX_HT_MCS,
9268 GTX_CMD);
9269 break;
9270 }
9271
9272 case WE_GET_GTX_VHT_MCS:
9273 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009274 hdd_debug("GET WMI_VDEV_PARAM_GTX_VHT_MCS");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009275 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009276 WMI_VDEV_PARAM_GTX_VHT_MCS,
9277 GTX_CMD);
9278 break;
9279 }
9280
9281 case WE_GET_GTX_USRCFG:
9282 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009283 hdd_debug("GET WMI_VDEV_PARAM_GTX_USR_CFG");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009284 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009285 WMI_VDEV_PARAM_GTX_USR_CFG,
9286 GTX_CMD);
9287 break;
9288 }
9289
9290 case WE_GET_GTX_THRE:
9291 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009292 hdd_debug("GET WMI_VDEV_PARAM_GTX_THRE");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009293 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009294 WMI_VDEV_PARAM_GTX_THRE,
9295 GTX_CMD);
9296 break;
9297 }
9298
9299 case WE_GET_GTX_MARGIN:
9300 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009301 hdd_debug("GET WMI_VDEV_PARAM_GTX_MARGIN");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009302 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009303 WMI_VDEV_PARAM_GTX_MARGIN,
9304 GTX_CMD);
9305 break;
9306 }
9307
9308 case WE_GET_GTX_STEP:
9309 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009310 hdd_debug("GET WMI_VDEV_PARAM_GTX_STEP");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009311 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009312 WMI_VDEV_PARAM_GTX_STEP,
9313 GTX_CMD);
9314 break;
9315 }
9316
9317 case WE_GET_GTX_MINTPC:
9318 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009319 hdd_debug("GET WMI_VDEV_PARAM_GTX_MINTPC");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009320 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009321 WMI_VDEV_PARAM_GTX_MINTPC,
9322 GTX_CMD);
9323 break;
9324 }
9325
9326 case WE_GET_GTX_BWMASK:
9327 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009328 hdd_debug("GET WMI_VDEV_PARAM_GTX_BW_MASK");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009329 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009330 WMI_VDEV_PARAM_GTX_BW_MASK,
9331 GTX_CMD);
9332 break;
9333 }
9334
9335 case WE_GET_LDPC:
9336 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009337 ret = hdd_get_ldpc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009338 break;
9339 }
9340
9341 case WE_GET_TX_STBC:
9342 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009343 ret = hdd_get_tx_stbc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009344 break;
9345 }
9346
9347 case WE_GET_RX_STBC:
9348 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009349 ret = hdd_get_rx_stbc(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009350 break;
9351 }
9352
9353 case WE_GET_SHORT_GI:
9354 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009355 hdd_debug("GET WMI_VDEV_PARAM_SGI");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009356 *value = wma_cli_get_command(adapter->sessionId,
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009357 WMI_VDEV_PARAM_SGI,
9358 VDEV_CMD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009359 break;
9360 }
9361
9362 case WE_GET_RTSCTS:
9363 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009364 hdd_debug("GET WMI_VDEV_PARAM_ENABLE_RTSCTS");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009365 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009366 WMI_VDEV_PARAM_ENABLE_RTSCTS,
9367 VDEV_CMD);
9368 break;
9369 }
9370
9371 case WE_GET_CHWIDTH:
9372 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009373 hdd_debug("GET WMI_VDEV_PARAM_CHWIDTH");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009374 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009375 WMI_VDEV_PARAM_CHWIDTH,
9376 VDEV_CMD);
9377 break;
9378 }
9379
9380 case WE_GET_ANI_EN_DIS:
9381 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009382 hdd_debug("GET WMI_PDEV_PARAM_ANI_ENABLE");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009383 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009384 WMI_PDEV_PARAM_ANI_ENABLE,
9385 PDEV_CMD);
9386 break;
9387 }
9388
9389 case WE_GET_ANI_POLL_PERIOD:
9390 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009391 hdd_debug("GET WMI_PDEV_PARAM_ANI_POLL_PERIOD");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009392 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009393 WMI_PDEV_PARAM_ANI_POLL_PERIOD,
9394 PDEV_CMD);
9395 break;
9396 }
9397
9398 case WE_GET_ANI_LISTEN_PERIOD:
9399 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009400 hdd_debug("GET WMI_PDEV_PARAM_ANI_LISTEN_PERIOD");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009401 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009402 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD,
9403 PDEV_CMD);
9404 break;
9405 }
9406
9407 case WE_GET_ANI_OFDM_LEVEL:
9408 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009409 hdd_debug("GET WMI_PDEV_PARAM_ANI_OFDM_LEVEL");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009410 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009411 WMI_PDEV_PARAM_ANI_OFDM_LEVEL,
9412 PDEV_CMD);
9413 break;
9414 }
9415
9416 case WE_GET_ANI_CCK_LEVEL:
9417 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009418 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009419 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009420 WMI_PDEV_PARAM_ANI_CCK_LEVEL,
9421 PDEV_CMD);
9422 break;
9423 }
9424
9425 case WE_GET_DYNAMIC_BW:
9426 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009427 hdd_debug("GET WMI_PDEV_PARAM_ANI_CCK_LEVEL");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009428 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009429 WMI_PDEV_PARAM_DYNAMIC_BW,
9430 PDEV_CMD);
9431 break;
9432 }
9433
9434 case WE_GET_11N_RATE:
9435 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009436 hdd_debug("GET WMI_VDEV_PARAM_FIXED_RATE");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009437 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009438 WMI_VDEV_PARAM_FIXED_RATE,
9439 VDEV_CMD);
9440 break;
9441 }
9442
9443 case WE_GET_AMPDU:
9444 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009445 hdd_debug("GET AMPDU");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009446 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009447 GEN_VDEV_PARAM_AMPDU,
9448 GEN_CMD);
9449 break;
9450 }
9451
9452 case WE_GET_AMSDU:
9453 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009454 hdd_debug("GET AMSDU");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009455 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009456 GEN_VDEV_PARAM_AMSDU,
9457 GEN_CMD);
9458 break;
9459 }
9460
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009461 case WE_GET_ROAM_SYNCH_DELAY:
9462 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009463 hdd_debug("GET ROAM SYNCH DELAY");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009464 *value = wma_cli_get_command(adapter->sessionId,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -07009465 GEN_VDEV_ROAM_SYNCH_DELAY,
9466 GEN_CMD);
9467 break;
9468 }
9469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009470 case WE_GET_BURST_ENABLE:
9471 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009472 hdd_debug("GET Burst enable value");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009473 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009474 WMI_PDEV_PARAM_BURST_ENABLE,
9475 PDEV_CMD);
9476 break;
9477 }
9478 case WE_GET_BURST_DUR:
9479 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009480 hdd_debug("GET Burst Duration value");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009481 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009482 WMI_PDEV_PARAM_BURST_DUR,
9483 PDEV_CMD);
9484 break;
9485 }
9486
9487 case WE_GET_TX_CHAINMASK:
9488 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009489 hdd_debug("GET WMI_PDEV_PARAM_TX_CHAIN_MASK");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009490 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009491 WMI_PDEV_PARAM_TX_CHAIN_MASK,
9492 PDEV_CMD);
9493 break;
9494 }
9495
9496 case WE_GET_RX_CHAINMASK:
9497 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009498 hdd_debug("GET WMI_PDEV_PARAM_RX_CHAIN_MASK");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009499 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009500 WMI_PDEV_PARAM_RX_CHAIN_MASK,
9501 PDEV_CMD);
9502 break;
9503 }
9504
9505 case WE_GET_TXPOW_2G:
9506 {
9507 uint32_t txpow2g = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009508 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009509
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009510 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT2G");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009511 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009512 WMI_PDEV_PARAM_TXPOWER_LIMIT2G,
9513 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309514 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009515 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9516 &txpow2g)) {
9517 return -EIO;
9518 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009519 hdd_debug("2G tx_power %d", txpow2g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009520 break;
9521 }
9522
9523 case WE_GET_TXPOW_5G:
9524 {
9525 uint32_t txpow5g = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009526 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -07009527
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009528 hdd_debug("GET WMI_PDEV_PARAM_TXPOWER_LIMIT5G");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009529 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009530 WMI_PDEV_PARAM_TXPOWER_LIMIT5G,
9531 PDEV_CMD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309532 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009533 sme_cfg_get_int(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
9534 &txpow5g)) {
9535 return -EIO;
9536 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009537 hdd_debug("5G tx_power %d", txpow5g);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009538 break;
9539 }
9540
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009541 case WE_GET_PPS_PAID_MATCH:
9542 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009543 hdd_debug("GET WMI_VDEV_PPS_PAID_MATCH");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009544 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009545 WMI_VDEV_PPS_PAID_MATCH,
9546 PPS_CMD);
9547 break;
9548 }
9549
9550 case WE_GET_PPS_GID_MATCH:
9551 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009552 hdd_debug("GET WMI_VDEV_PPS_GID_MATCH");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009553 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009554 WMI_VDEV_PPS_GID_MATCH,
9555 PPS_CMD);
9556 break;
9557 }
9558
9559 case WE_GET_PPS_EARLY_TIM_CLEAR:
9560 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009561 hdd_debug("GET WMI_VDEV_PPS_EARLY_TIM_CLEAR");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009562 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009563 WMI_VDEV_PPS_EARLY_TIM_CLEAR,
9564 PPS_CMD);
9565 break;
9566 }
9567
9568 case WE_GET_PPS_EARLY_DTIM_CLEAR:
9569 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009570 hdd_debug("GET WMI_VDEV_PPS_EARLY_DTIM_CLEAR");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009571 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009572 WMI_VDEV_PPS_EARLY_DTIM_CLEAR,
9573 PPS_CMD);
9574 break;
9575 }
9576
9577 case WE_GET_PPS_EOF_PAD_DELIM:
9578 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009579 hdd_debug("GET WMI_VDEV_PPS_EOF_PAD_DELIM");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009580 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009581 WMI_VDEV_PPS_EOF_PAD_DELIM,
9582 PPS_CMD);
9583 break;
9584 }
9585
9586 case WE_GET_PPS_MACADDR_MISMATCH:
9587 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009588 hdd_debug("GET WMI_VDEV_PPS_MACADDR_MISMATCH");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009589 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009590 WMI_VDEV_PPS_MACADDR_MISMATCH,
9591 PPS_CMD);
9592 break;
9593 }
9594
9595 case WE_GET_PPS_DELIM_CRC_FAIL:
9596 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009597 hdd_debug("GET WMI_VDEV_PPS_DELIM_CRC_FAIL");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009598 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009599 WMI_VDEV_PPS_DELIM_CRC_FAIL,
9600 PPS_CMD);
9601 break;
9602 }
9603
9604 case WE_GET_PPS_GID_NSTS_ZERO:
9605 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009606 hdd_debug("GET WMI_VDEV_PPS_GID_NSTS_ZERO");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009607 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009608 WMI_VDEV_PPS_GID_NSTS_ZERO,
9609 PPS_CMD);
9610 break;
9611 }
9612
9613 case WE_GET_PPS_RSSI_CHECK:
9614 {
9615
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009616 hdd_debug("GET WMI_VDEV_PPS_RSSI_CHECK");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009617 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009618 WMI_VDEV_PPS_RSSI_CHECK,
9619 PPS_CMD);
9620 break;
9621 }
9622
9623 case WE_GET_QPOWER_MAX_PSPOLL_COUNT:
9624 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009625 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009626 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009627 WMI_STA_PS_PARAM_QPOWER_PSPOLL_COUNT,
9628 QPOWER_CMD);
9629 break;
9630 }
9631
9632 case WE_GET_QPOWER_MAX_TX_BEFORE_WAKE:
9633 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009634 hdd_debug("WE_GET_QPOWER_MAX_TX_BEFORE_WAKE");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009635 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009636 WMI_STA_PS_PARAM_QPOWER_MAX_TX_BEFORE_WAKE,
9637 QPOWER_CMD);
9638 break;
9639 }
9640
9641 case WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL:
9642 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009643 hdd_debug("WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009644 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009645 WMI_STA_PS_PARAM_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
9646 QPOWER_CMD);
9647 break;
9648 }
9649
9650 case WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL:
9651 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009652 hdd_debug("WE_GET_QPOWER_MAX_PSPOLL_COUNT");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009653 *value = wma_cli_get_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009654 WMI_STA_PS_PARAM_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
9655 QPOWER_CMD);
9656 break;
9657 }
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009658 case WE_CAP_TSF:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009659 ret = hdd_capture_tsf(adapter, (uint32_t *)value, 1);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07009660 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009661 case WE_GET_TEMPERATURE:
9662 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -08009663 hdd_debug("WE_GET_TEMPERATURE");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009664 ret = wlan_hdd_get_temperature(adapter, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009665 break;
9666 }
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07009667 case WE_GET_DCM:
9668 hdd_notice("GET WMI_VDEV_PARAM_HE_DCM");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009669 *value = wma_cli_get_command(adapter->sessionId,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -07009670 WMI_VDEV_PARAM_HE_DCM,
9671 VDEV_CMD);
9672 break;
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07009673 case WE_GET_RANGE_EXT:
9674 hdd_notice("GET WMI_VDEV_PARAM_HE_RANGE_EXT");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009675 *value = wma_cli_get_command(adapter->sessionId,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -07009676 WMI_VDEV_PARAM_HE_RANGE_EXT,
9677 VDEV_CMD);
9678 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009679 default:
9680 {
Jeff Johnson99bac312016-06-28 10:38:18 -07009681 hdd_err("Invalid IOCTL get_value command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009682 value[0]);
9683 break;
9684 }
9685 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309686 EXIT();
Sridhar Selvaraj48c47092017-07-31 18:18:14 +05309687 qdf_mem_free(sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009688 return ret;
9689}
9690
9691static int iw_setnone_getint(struct net_device *dev,
9692 struct iw_request_info *info,
9693 union iwreq_data *wrqu, char *extra)
9694{
9695 int ret;
9696
9697 cds_ssr_protect(__func__);
9698 ret = __iw_setnone_getint(dev, info, wrqu, extra);
9699 cds_ssr_unprotect(__func__);
9700
9701 return ret;
9702}
9703
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309704static int hdd_set_fwtest(int argc, int cmd, int value)
9705{
9706 struct set_fwtest_params *fw_test;
9707
9708 /* check for max number of arguments */
9709 if (argc > (WMA_MAX_NUM_ARGS) ||
9710 argc != HDD_FWTEST_PARAMS) {
9711 hdd_err("Too Many args %d", argc);
9712 return -EINVAL;
9713 }
9714 /*
9715 * check if number of arguments are 3 then, check
9716 * then set the default value for sounding interval.
9717 */
9718 if (HDD_FWTEST_PARAMS == argc) {
9719 if (HDD_FWTEST_SU_PARAM_ID == cmd && 0 == value)
9720 value = HDD_FWTEST_SU_DEFAULT_VALUE;
9721 if (HDD_FWTEST_MU_PARAM_ID == cmd && 0 == value)
9722 value = HDD_FWTEST_MU_DEFAULT_VALUE;
9723 }
9724 /* check sounding interval value should not exceed to max */
9725 if (value > HDD_FWTEST_MAX_VALUE) {
9726 hdd_err("Invalid arguments value should not exceed max: %d",
9727 value);
9728 return -EINVAL;
9729 }
9730 fw_test = qdf_mem_malloc(sizeof(*fw_test));
9731 if (NULL == fw_test) {
9732 hdd_err("qdf_mem_malloc failed for fw_test");
9733 return -ENOMEM;
9734 }
9735 fw_test->arg = cmd;
9736 fw_test->value = value;
9737 if (QDF_STATUS_SUCCESS != sme_set_fw_test(fw_test)) {
9738 qdf_mem_free(fw_test);
9739 hdd_err("Not able to post FW_TEST_CMD message to WMA");
9740 return -EINVAL;
9741 }
9742 return 0;
9743}
9744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009745/**
9746 * iw_set_three_ints_getnone() - Generic "set 3 params" private ioctl handler
9747 * @dev: device upon which the ioctl was received
9748 * @info: ioctl request information
9749 * @wrqu: ioctl request data
9750 * @extra: ioctl extra data
9751 *
9752 * Return: 0 on success, non-zero on error
9753 */
9754static int __iw_set_three_ints_getnone(struct net_device *dev,
9755 struct iw_request_info *info,
9756 union iwreq_data *wrqu, char *extra)
9757{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009758 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009759 int *value = (int *)extra;
9760 int sub_cmd = value[0];
9761 int ret;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009762 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009763
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009764 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309765
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009766 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -07009767 hdd_err("permission check failed");
Rajeev Kumar2cce8a82016-04-14 15:10:41 -07009768 return -EPERM;
9769 }
9770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009771 ret = wlan_hdd_validate_context(hdd_ctx);
9772 if (0 != ret)
9773 return ret;
9774
Jeff Johnson441e1f72017-02-07 08:50:49 -08009775 ret = hdd_check_private_wext_control(hdd_ctx, info);
9776 if (0 != ret)
9777 return ret;
9778
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009779 switch (sub_cmd) {
9780
9781 case WE_SET_WLAN_DBG:
Dustin Brown36e2e5c2017-05-16 15:41:37 -07009782 qdf_print_set_category_verbose(qdf_get_pidx(), value[1],
9783 value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009784 break;
9785 case WE_SET_DP_TRACE:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309786 qdf_dp_trace_set_value(value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009787 break;
9788
9789 /* value[3] the acs band is not required as start and end channels are
9790 * enough but this cmd is maintained under set three ints for historic
9791 * reasons.
9792 */
9793 case WE_SET_SAP_CHANNELS:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009794 if (wlan_hdd_validate_operation_channel(adapter, value[1]) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309795 QDF_STATUS_SUCCESS ||
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009796 wlan_hdd_validate_operation_channel(adapter,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309797 value[2]) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009798 ret = -EINVAL;
9799 } else {
9800 hdd_ctx->config->force_sap_acs_st_ch = value[1];
9801 hdd_ctx->config->force_sap_acs_end_ch = value[2];
9802 }
9803 break;
9804 case WE_SET_DUAL_MAC_SCAN_CONFIG:
9805 hdd_debug("Ioctl to set dual mac scan config");
Tushnim Bhattacharyya49ed8ab2017-05-26 18:20:10 -07009806 if (hdd_ctx->config->dual_mac_feature_disable ==
9807 DISABLE_DBS_CXN_AND_SCAN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009808 hdd_err("Dual mac feature is disabled from INI");
9809 return -EPERM;
9810 }
9811 hdd_debug("%d %d %d", value[1], value[2], value[3]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -08009812 policy_mgr_set_dual_mac_scan_config(hdd_ctx->hdd_psoc,
9813 value[1], value[2], value[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009814 break;
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +05309815 case WE_SET_FW_TEST:
9816 {
9817 ret = hdd_set_fwtest(value[1], value[2], value[3]);
9818 if (ret) {
9819 hdd_err("Not able to set fwtest %d", ret);
9820 return ret;
9821 }
9822 }
9823 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009824 default:
Jeff Johnson99bac312016-06-28 10:38:18 -07009825 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009826 break;
9827
9828 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309829 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009830 return ret;
9831}
9832
9833int iw_set_three_ints_getnone(struct net_device *dev,
9834 struct iw_request_info *info,
9835 union iwreq_data *wrqu, char *extra)
9836{
9837 int ret;
9838
9839 cds_ssr_protect(__func__);
9840 ret = __iw_set_three_ints_getnone(dev, info, wrqu, extra);
9841 cds_ssr_unprotect(__func__);
9842
9843 return ret;
9844}
9845
9846/**
9847 * hdd_connection_state_string() - Get connection state string
9848 * @connection_state: enum to be converted to a string
9849 *
9850 * Return: the string equivalent of @connection_state
9851 */
9852static const char *
9853hdd_connection_state_string(eConnectionState connection_state)
9854{
9855 switch (connection_state) {
9856 CASE_RETURN_STRING(eConnectionState_NotConnected);
9857 CASE_RETURN_STRING(eConnectionState_Connecting);
9858 CASE_RETURN_STRING(eConnectionState_Associated);
9859 CASE_RETURN_STRING(eConnectionState_IbssDisconnected);
9860 CASE_RETURN_STRING(eConnectionState_IbssConnected);
9861 CASE_RETURN_STRING(eConnectionState_Disconnecting);
9862 default:
9863 return "UNKNOWN";
9864 }
9865}
9866
Naveen Rawat910726a2017-03-06 11:42:51 -08009867#if defined(FEATURE_OEM_DATA_SUPPORT)
9868/**
9869 * iw_get_oem_data_cap_wrapper() - wrapper function to call legacy or new
9870 * wifi_pos api to get oem data caps
9871 * @dev: net device upon which the request was received
9872 * @info: ioctl request information
9873 * @wrqu: ioctl request data
9874 * @extra: ioctl data payload
9875 *
9876 * Return: 0 for success, negative errno value on failure
9877 */
9878static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9879 struct iw_request_info *info,
9880 union iwreq_data *wrqu, char *extra)
9881{
9882 return iw_get_oem_data_cap(dev, info, wrqu, extra);
9883}
9884#elif defined(WIFI_POS_CONVERGED)
9885static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9886 struct iw_request_info *info,
9887 union iwreq_data *wrqu, char *extra)
9888{
Jeff Johnson3d278b02017-08-29 14:17:47 -07009889 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009890 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Naveen Rawat910726a2017-03-06 11:42:51 -08009891
9892 return os_if_wifi_pos_populate_caps(hdd_ctx->hdd_psoc,
9893 (struct wifi_pos_driver_caps *)extra);
9894}
9895#else
9896static inline int iw_get_oem_data_cap_wrapper(struct net_device *dev,
9897 struct iw_request_info *info,
9898 union iwreq_data *wrqu, char *extra)
9899{
9900 return -ENOTSUPP;
9901}
9902#endif
9903
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009904/**
9905 * iw_get_char_setnone() - Generic "get string" private ioctl handler
9906 * @dev: device upon which the ioctl was received
9907 * @info: ioctl request information
9908 * @wrqu: ioctl request data
9909 * @extra: ioctl extra data
9910 *
9911 * Return: 0 on success, non-zero on error
9912 */
9913static int __iw_get_char_setnone(struct net_device *dev,
9914 struct iw_request_info *info,
9915 union iwreq_data *wrqu, char *extra)
9916{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009917 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009918 int sub_cmd = wrqu->data.flags;
Jeff Johnson6d38ab82017-08-28 11:36:27 -07009919 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009920 int ret;
9921#ifdef WLAN_FEATURE_11W
Jeff Johnson2a722002017-09-30 20:02:35 -07009922 struct hdd_wext_state *pWextState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009923#endif
9924
9925#ifdef WLAN_FEATURE_11W
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009926 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009927#endif
9928
Jeff Johnson6ee91ee2016-02-11 18:55:30 -08009929 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +05309930
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009931 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009932 ret = wlan_hdd_validate_context(hdd_ctx);
9933 if (0 != ret)
9934 return ret;
9935
Jeff Johnson441e1f72017-02-07 08:50:49 -08009936 ret = hdd_check_private_wext_control(hdd_ctx, info);
9937 if (0 != ret)
9938 return ret;
9939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009940 switch (sub_cmd) {
9941 case WE_WLAN_VERSION:
9942 {
Arun Khandavallia96c2c02016-05-17 19:15:34 +05309943 hdd_wlan_get_version(hdd_ctx, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009944 break;
9945 }
9946
9947 case WE_GET_STATS:
9948 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009949 hdd_wlan_get_stats(adapter, &(wrqu->data.length),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009950 extra, WE_MAX_STR_LEN);
9951 break;
9952 }
9953
Dustin Brownd9322482017-01-09 12:46:03 -08009954 case WE_GET_SUSPEND_RESUME_STATS:
9955 {
9956 ret = wlan_hdd_write_suspend_resume_stats(hdd_ctx, extra,
9957 WE_MAX_STR_LEN);
9958 if (ret >= 0) {
9959 wrqu->data.length = ret;
9960 ret = 0;
9961 }
9962
9963 break;
9964 }
9965
Govind Singha471e5e2015-10-12 17:11:14 +05309966 case WE_LIST_FW_PROFILE:
9967 hdd_wlan_list_fw_profile(&(wrqu->data.length),
9968 extra, WE_MAX_STR_LEN);
9969 break;
9970
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009971 /* The case prints the current state of the HDD, SME, CSR, PE,
9972 * TL it can be extended for WDI Global State as well. And
9973 * currently it only checks P2P_CLIENT adapter. P2P_DEVICE
9974 * and P2P_GO have not been added as of now.
9975 */
9976 case WE_GET_STATES:
9977 {
9978 int buf = 0, len = 0;
9979 int adapter_num = 0;
9980 int count = 0, check = 1;
9981
9982 tHalHandle hHal = NULL;
9983 tpAniSirGlobal pMac = NULL;
Jeff Johnsond377dce2017-10-04 10:32:42 -07009984 struct hdd_station_ctx *sta_ctx = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009985
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009986 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson3d278b02017-08-29 14:17:47 -07009987 struct hdd_adapter *useAdapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009988
9989 /* Print wlan0 or p2p0 states based on the adapter_num
9990 * by using the correct adapter
9991 */
9992 while (adapter_num < 2) {
9993 if (WLAN_ADAPTER == adapter_num) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -07009994 useAdapter = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009995 buf =
9996 scnprintf(extra + len,
9997 WE_MAX_STR_LEN - len,
9998 "\n\n wlan0 States:-");
9999 len += buf;
10000 } else if (P2P_ADAPTER == adapter_num) {
10001 buf =
10002 scnprintf(extra + len,
10003 WE_MAX_STR_LEN - len,
10004 "\n\n p2p0 States:-");
10005 len += buf;
10006
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010007 if (!hdd_ctx) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010008 buf =
10009 scnprintf(extra + len,
10010 WE_MAX_STR_LEN -
10011 len,
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010012 "\n hdd_ctx is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010013 len += buf;
10014 break;
10015 }
10016
10017 /* Printing p2p0 states only in the
10018 * case when the device is configured
10019 * as a p2p_client
10020 */
10021 useAdapter =
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010022 hdd_get_adapter(hdd_ctx,
Krunal Sonif07bb382016-03-10 13:02:11 -080010023 QDF_P2P_CLIENT_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010024 if (!useAdapter) {
10025 buf =
10026 scnprintf(extra + len,
10027 WE_MAX_STR_LEN -
10028 len,
10029 "\n Device not configured as P2P_CLIENT.");
10030 len += buf;
10031 break;
10032 }
10033 }
10034
10035 hHal = WLAN_HDD_GET_HAL_CTX(useAdapter);
10036 if (!hHal) {
10037 buf =
10038 scnprintf(extra + len,
10039 WE_MAX_STR_LEN - len,
10040 "\n pMac is NULL");
10041 len += buf;
10042 break;
10043 }
10044 pMac = PMAC_STRUCT(hHal);
10045 if (!pMac) {
10046 buf =
10047 scnprintf(extra + len,
10048 WE_MAX_STR_LEN - len,
10049 "\n pMac is NULL");
10050 len += buf;
10051 break;
10052 }
Jeff Johnsond377dce2017-10-04 10:32:42 -070010053 sta_ctx =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010054 WLAN_HDD_GET_STATION_CTX_PTR(useAdapter);
10055
10056
10057 buf =
10058 scnprintf(extra + len, WE_MAX_STR_LEN - len,
10059 "\n HDD Conn State - %s "
10060 "\n \n SME State:"
10061 "\n Neighbour Roam State - %s"
10062 "\n CSR State - %s"
10063 "\n CSR Substate - %s",
10064 hdd_connection_state_string
Jeff Johnsond377dce2017-10-04 10:32:42 -070010065 (sta_ctx->conn_info.connState),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010066 mac_trace_get_neighbour_roam_state
10067 (sme_get_neighbor_roam_state
10068 (hHal, useAdapter->sessionId)),
10069 mac_trace_getcsr_roam_state
10070 (sme_get_current_roam_state
10071 (hHal, useAdapter->sessionId)),
10072 mac_trace_getcsr_roam_sub_state
10073 (sme_get_current_roam_sub_state
10074 (hHal, useAdapter->sessionId))
10075 );
10076 len += buf;
10077 adapter_num++;
10078 }
10079
Mukul Sharma81661ae2015-10-30 20:26:02 +053010080 if (hHal) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010081 /* Printing Lim State starting with global lim states */
10082 buf =
10083 scnprintf(extra + len, WE_MAX_STR_LEN - len,
10084 "\n \n LIM STATES:-"
10085 "\n Global Sme State - %s "
10086 "\n Global mlm State - %s " "\n",
10087 mac_trace_get_lim_sme_state
10088 (sme_get_lim_sme_state(hHal)),
10089 mac_trace_get_lim_mlm_state
10090 (sme_get_lim_sme_state(hHal))
10091 );
10092 len += buf;
10093
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010094 while (check < 3 && count < 255) {
10095 if (sme_is_lim_session_valid(hHal, count)) {
10096 buf =
10097 scnprintf(extra + len,
10098 WE_MAX_STR_LEN -
10099 len,
10100 "\n Lim Valid Session %d:-"
10101 "\n PE Sme State - %s "
10102 "\n PE Mlm State - %s "
10103 "\n", check,
10104 mac_trace_get_lim_sme_state
10105 (sme_get_lim_sme_session_state
10106 (hHal, count)),
10107 mac_trace_get_lim_mlm_state
10108 (sme_get_lim_mlm_session_state
10109 (hHal, count))
10110 );
10111
10112 len += buf;
10113 check++;
10114 }
10115 count++;
10116 }
10117 }
10118
10119 wrqu->data.length = strlen(extra) + 1;
10120 break;
10121 }
10122
10123 case WE_GET_CFG:
10124 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010125 hdd_debug("Printing CLD global INI Config");
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010126 hdd_cfg_get_global_config(WLAN_HDD_GET_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010127 extra,
10128 QCSAP_IOCTL_MAX_STR_LEN);
10129 wrqu->data.length = strlen(extra) + 1;
10130 break;
10131 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010132 case WE_GET_RSSI:
10133 {
10134 int8_t s7Rssi = 0;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010135
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010136 wlan_hdd_get_rssi(adapter, &s7Rssi);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010137 snprintf(extra, WE_MAX_STR_LEN, "rssi=%d", s7Rssi);
10138 wrqu->data.length = strlen(extra) + 1;
10139 break;
10140 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010141
10142 case WE_GET_WMM_STATUS:
10143 {
10144 snprintf(extra, WE_MAX_STR_LEN,
10145 "\nDir: 0=up, 1=down, 3=both\n"
10146 "|------------------------|\n"
10147 "|AC | ACM |Admitted| Dir |\n"
10148 "|------------------------|\n"
10149 "|VO | %d | %3s | %d |\n"
10150 "|VI | %d | %3s | %d |\n"
10151 "|BE | %d | %3s | %d |\n"
10152 "|BK | %d | %3s | %d |\n"
10153 "|------------------------|\n",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010154 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010155 wmmAcStatus[SME_AC_VO].wmmAcAccessRequired,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010156 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010157 wmmAcStatus[SME_AC_VO].
10158 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010159 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010160 wmmAcStatus[SME_AC_VO].wmmAcTspecInfo.
10161 ts_info.direction,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010162 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010163 wmmAcStatus[SME_AC_VI].wmmAcAccessRequired,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010164 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010165 wmmAcStatus[SME_AC_VI].
10166 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010167 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010168 wmmAcStatus[SME_AC_VI].wmmAcTspecInfo.
10169 ts_info.direction,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010170 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010171 wmmAcStatus[SME_AC_BE].wmmAcAccessRequired,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010172 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010173 wmmAcStatus[SME_AC_BE].
10174 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010175 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010176 wmmAcStatus[SME_AC_BE].wmmAcTspecInfo.
10177 ts_info.direction,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010178 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010179 wmmAcStatus[SME_AC_BK].wmmAcAccessRequired,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010180 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010181 wmmAcStatus[SME_AC_BK].
10182 wmmAcAccessAllowed ? "YES" : "NO",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010183 adapter->hddWmmStatus.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010184 wmmAcStatus[SME_AC_BK].wmmAcTspecInfo.
10185 ts_info.direction);
10186
10187 wrqu->data.length = strlen(extra) + 1;
10188 break;
10189 }
10190 case WE_GET_CHANNEL_LIST:
10191 {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010192 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010193 uint8_t i, len;
10194 char *buf;
10195 uint8_t ubuf[WNI_CFG_COUNTRY_CODE_LEN];
10196 uint8_t ubuf_len = WNI_CFG_COUNTRY_CODE_LEN;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010197 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010198
Srinivas Girigowdac231df62017-03-24 18:27:57 -070010199 struct channel_list_info channel_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010200
10201 memset(&channel_list, 0, sizeof(channel_list));
Agrawal Ashish6c9bca72016-09-04 13:37:59 +053010202 status = iw_get_channel_list(dev, info, wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010203 (char *)&channel_list);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010204 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010205 hdd_err("GetChannelList Failed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010206 return -EINVAL;
10207 }
10208 buf = extra;
10209 /*
10210 * Maximum channels = WNI_CFG_VALID_CHANNEL_LIST_LEN.
10211 * Maximum buffer needed = 5 * number of channels.
10212 * Check ifsufficient buffer is available and then
10213 * proceed to fill the buffer.
10214 */
10215 if (WE_MAX_STR_LEN <
10216 (5 * WNI_CFG_VALID_CHANNEL_LIST_LEN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010217 hdd_err("Insufficient Buffer to populate channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010218 return -EINVAL;
10219 }
10220 len = scnprintf(buf, WE_MAX_STR_LEN, "%u ",
10221 channel_list.num_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010222 if (QDF_STATUS_SUCCESS == sme_get_country_code(hdd_ctx->hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010223 ubuf, &ubuf_len)) {
10224 /* Printing Country code in getChannelList */
10225 for (i = 0; i < (ubuf_len - 1); i++)
10226 len += scnprintf(buf + len,
10227 WE_MAX_STR_LEN - len,
10228 "%c", ubuf[i]);
10229 }
10230 for (i = 0; i < channel_list.num_channels; i++) {
10231 len +=
10232 scnprintf(buf + len, WE_MAX_STR_LEN - len,
10233 " %u", channel_list.channels[i]);
10234 }
10235 wrqu->data.length = strlen(extra) + 1;
10236
10237 break;
10238 }
10239#ifdef FEATURE_WLAN_TDLS
10240 case WE_GET_TDLS_PEERS:
10241 {
10242 wrqu->data.length =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010243 wlan_hdd_tdls_get_all_peers(adapter, extra,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010244 WE_MAX_STR_LEN) + 1;
10245 break;
10246 }
10247#endif
10248#ifdef WLAN_FEATURE_11W
10249 case WE_GET_11W_INFO:
10250 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010251 hdd_debug("WE_GET_11W_ENABLED = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010252 pWextState->roamProfile.MFPEnabled);
10253
10254 snprintf(extra, WE_MAX_STR_LEN,
10255 "\n BSSID %02X:%02X:%02X:%02X:%02X:%02X, Is PMF Assoc? %d"
10256 "\n Number of Unprotected Disassocs %d"
10257 "\n Number of Unprotected Deauths %d",
10258 pWextState->roamProfile.BSSIDs.bssid->bytes[0],
10259 pWextState->roamProfile.BSSIDs.bssid->bytes[1],
10260 pWextState->roamProfile.BSSIDs.bssid->bytes[2],
10261 pWextState->roamProfile.BSSIDs.bssid->bytes[3],
10262 pWextState->roamProfile.BSSIDs.bssid->bytes[4],
10263 pWextState->roamProfile.BSSIDs.bssid->bytes[5],
10264 pWextState->roamProfile.MFPEnabled,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010265 adapter->hdd_stats.hddPmfStats.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010266 numUnprotDisassocRx,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010267 adapter->hdd_stats.hddPmfStats.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010268 numUnprotDeauthRx);
10269
10270 wrqu->data.length = strlen(extra) + 1;
10271 break;
10272 }
10273#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010274 case WE_GET_IBSS_STA_INFO:
10275 {
Jeff Johnsond377dce2017-10-04 10:32:42 -070010276 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010277 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010278 int idx = 0;
10279 int length = 0, buf = 0;
10280
Naveen Rawatc45d1622016-07-05 12:20:09 -070010281 for (idx = 0; idx < MAX_PEERS; idx++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -070010282 if (HDD_WLAN_INVALID_STA_ID !=
Jeff Johnsond377dce2017-10-04 10:32:42 -070010283 sta_ctx->conn_info.staId[idx]) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010284 buf = snprintf
10285 ((extra + length),
10286 WE_MAX_STR_LEN - length,
10287 "\n%d .%02x:%02x:%02x:%02x:%02x:%02x\n",
Jeff Johnsond377dce2017-10-04 10:32:42 -070010288 sta_ctx->conn_info.staId[idx],
10289 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010290 peerMacAddress[idx].bytes[0],
Jeff Johnsond377dce2017-10-04 10:32:42 -070010291 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010292 peerMacAddress[idx].bytes[1],
Jeff Johnsond377dce2017-10-04 10:32:42 -070010293 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010294 peerMacAddress[idx].bytes[2],
Jeff Johnsond377dce2017-10-04 10:32:42 -070010295 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010296 peerMacAddress[idx].bytes[3],
Jeff Johnsond377dce2017-10-04 10:32:42 -070010297 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010298 peerMacAddress[idx].bytes[4],
Jeff Johnsond377dce2017-10-04 10:32:42 -070010299 sta_ctx->conn_info.
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010300 peerMacAddress[idx].bytes[5]
10301 );
10302 length += buf;
10303 }
10304 }
10305 wrqu->data.length = strlen(extra) + 1;
10306 break;
10307 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010308 case WE_GET_PHYMODE:
10309 {
10310 bool ch_bond24 = false, ch_bond5g = false;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010311 struct hdd_context *hddctx = WLAN_HDD_GET_CTX(adapter);
10312 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010313 eCsrPhyMode phymode;
10314 eCsrBand currBand;
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010315 tSmeConfigParams *sme_config;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010316
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010317 sme_config = qdf_mem_malloc(sizeof(*sme_config));
10318 if (!sme_config) {
10319 hdd_err("Out of memory");
10320 ret = -ENOMEM;
10321 break;
10322 }
10323
10324 sme_get_config_param(hal, sme_config);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010325 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010326 sme_config->csrConfig.channelBondingMode24GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010327 ch_bond24 = true;
10328
10329 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE !=
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010330 sme_config->csrConfig.channelBondingMode5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010331 ch_bond5g = true;
10332
Dustin Browne9c6b3a2017-01-23 17:17:32 -080010333 qdf_mem_free(sme_config);
10334
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010335 phymode = sme_get_phy_mode(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010336 if ((QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010337 sme_get_freq_band(hal, &currBand))) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010338 hdd_err("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010339 return -EIO;
10340 }
10341
10342 switch (phymode) {
10343 case eCSR_DOT11_MODE_AUTO:
10344 snprintf(extra, WE_MAX_STR_LEN, "AUTO MODE");
10345 break;
10346 case eCSR_DOT11_MODE_11n:
10347 case eCSR_DOT11_MODE_11n_ONLY:
10348 if (currBand == eCSR_BAND_24) {
10349 if (ch_bond24)
10350 snprintf(extra, WE_MAX_STR_LEN,
10351 "11NGHT40");
10352 else
10353 snprintf(extra, WE_MAX_STR_LEN,
10354 "11NGHT20");
10355 } else if (currBand == eCSR_BAND_5G) {
10356 if (ch_bond5g)
10357 snprintf(extra, WE_MAX_STR_LEN,
10358 "11NAHT40");
10359 else
10360 snprintf(extra, WE_MAX_STR_LEN,
10361 "11NAHT20");
10362 } else {
10363 snprintf(extra, WE_MAX_STR_LEN, "11N");
10364 }
10365 break;
10366 case eCSR_DOT11_MODE_abg:
10367 snprintf(extra, WE_MAX_STR_LEN, "11ABG");
10368 break;
10369 case eCSR_DOT11_MODE_11a:
10370 snprintf(extra, WE_MAX_STR_LEN, "11A");
10371 break;
10372 case eCSR_DOT11_MODE_11b:
10373 case eCSR_DOT11_MODE_11b_ONLY:
10374 snprintf(extra, WE_MAX_STR_LEN, "11B");
10375 break;
10376 case eCSR_DOT11_MODE_11g:
10377 case eCSR_DOT11_MODE_11g_ONLY:
10378 snprintf(extra, WE_MAX_STR_LEN, "11G");
10379 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010380 case eCSR_DOT11_MODE_11ac:
10381 case eCSR_DOT11_MODE_11ac_ONLY:
10382 if (hddctx->config->vhtChannelWidth ==
10383 eHT_CHANNEL_WIDTH_20MHZ)
10384 snprintf(extra, WE_MAX_STR_LEN,
10385 "11ACVHT20");
10386 else if (hddctx->config->vhtChannelWidth ==
10387 eHT_CHANNEL_WIDTH_40MHZ)
10388 snprintf(extra, WE_MAX_STR_LEN,
10389 "11ACVHT40");
10390 else if (hddctx->config->vhtChannelWidth ==
10391 eHT_CHANNEL_WIDTH_80MHZ)
10392 snprintf(extra, WE_MAX_STR_LEN,
10393 "11ACVHT80");
10394 else if (hddctx->config->vhtChannelWidth ==
10395 eHT_CHANNEL_WIDTH_160MHZ)
10396 snprintf(extra, WE_MAX_STR_LEN,
10397 "11ACVHT160");
10398 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080010399 case eCSR_DOT11_MODE_11ax:
10400 case eCSR_DOT11_MODE_11ax_ONLY:
10401 /* currently using vhtChannelWidth */
10402 if (hddctx->config->vhtChannelWidth ==
10403 eHT_CHANNEL_WIDTH_20MHZ)
10404 snprintf(extra, WE_MAX_STR_LEN,
10405 "11AX_HE_20");
10406 else if (hddctx->config->vhtChannelWidth ==
10407 eHT_CHANNEL_WIDTH_40MHZ)
10408 snprintf(extra, WE_MAX_STR_LEN,
10409 "11AX_HE_40");
10410 else if (hddctx->config->vhtChannelWidth ==
10411 eHT_CHANNEL_WIDTH_80MHZ)
10412 snprintf(extra, WE_MAX_STR_LEN,
10413 "11AX_HE_80");
10414 else if (hddctx->config->vhtChannelWidth ==
10415 eHT_CHANNEL_WIDTH_160MHZ)
10416 snprintf(extra, WE_MAX_STR_LEN,
10417 "11AX_HE_160");
10418 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010419 }
10420
10421 wrqu->data.length = strlen(extra) + 1;
10422 break;
10423 }
10424
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010425 case WE_GET_OEM_DATA_CAP:
Naveen Rawat910726a2017-03-06 11:42:51 -080010426 return iw_get_oem_data_cap_wrapper(dev, info, wrqu, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010427 case WE_GET_SNR:
10428 {
10429 int8_t s7snr = 0;
10430 int status = 0;
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010431 struct hdd_context *hdd_ctx;
Jeff Johnsond377dce2017-10-04 10:32:42 -070010432 struct hdd_station_ctx *sta_ctx;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010433
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010434 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010435 status = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010436 if (status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010437 return status;
Abhishek Singh23edd1c2016-05-05 11:56:06 +053010438
Jeff Johnsond377dce2017-10-04 10:32:42 -070010439 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010440 if (0 == hdd_ctx->config->fEnableSNRMonitoring ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010441 eConnectionState_Associated !=
Jeff Johnsond377dce2017-10-04 10:32:42 -070010442 sta_ctx->conn_info.connState) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010443 hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
Jeff Johnsonce2ee982017-09-03 09:27:35 -070010444 hdd_ctx->config->fEnableSNRMonitoring,
Jeff Johnsond377dce2017-10-04 10:32:42 -070010445 sta_ctx->conn_info.connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010446 return -ENONET;
10447 }
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010448 wlan_hdd_get_snr(adapter, &s7snr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010449 snprintf(extra, WE_MAX_STR_LEN, "snr=%d", s7snr);
10450 wrqu->data.length = strlen(extra) + 1;
10451 break;
10452 }
10453 default:
10454 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010455 hdd_err("Invalid IOCTL command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010456 sub_cmd);
10457 break;
10458 }
10459 }
Dustin Brownd9322482017-01-09 12:46:03 -080010460
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010461 EXIT();
Dustin Brownd9322482017-01-09 12:46:03 -080010462 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010463}
10464
10465static int iw_get_char_setnone(struct net_device *dev,
10466 struct iw_request_info *info,
10467 union iwreq_data *wrqu, char *extra)
10468{
10469 int ret;
10470
10471 cds_ssr_protect(__func__);
10472 ret = __iw_get_char_setnone(dev, info, wrqu, extra);
10473 cds_ssr_unprotect(__func__);
10474
10475 return ret;
10476}
10477
10478/**
10479 * iw_setnone_getnone() - Generic "action" private ioctl handler
10480 * @dev: device upon which the ioctl was received
10481 * @info: ioctl request information
10482 * @wrqu: ioctl request data
10483 * @extra: ioctl extra data
10484 *
10485 * Return: 0 on success, non-zero on error
10486 */
10487static int __iw_setnone_getnone(struct net_device *dev,
10488 struct iw_request_info *info,
10489 union iwreq_data *wrqu, char *extra)
10490{
Jeff Johnson3d278b02017-08-29 14:17:47 -070010491 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010492 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010493 int ret;
10494 int sub_cmd;
10495
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010496 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010497
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010498 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010499 ret = wlan_hdd_validate_context(hdd_ctx);
10500 if (0 != ret)
10501 return ret;
10502
Jeff Johnson441e1f72017-02-07 08:50:49 -080010503 ret = hdd_check_private_wext_control(hdd_ctx, info);
10504 if (0 != ret)
10505 return ret;
10506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010507#ifdef CONFIG_COMPAT
10508 /* this ioctl is a special case where a sub-ioctl is used and both
10509 * the number of get and set args is 0. in this specific case the
10510 * logic in iwpriv places the sub_cmd in the data.flags portion of
10511 * the iwreq. unfortunately the location of this field will be
10512 * different between 32-bit and 64-bit userspace, and the standard
10513 * compat support in the kernel does not handle this case. so we
10514 * need to explicitly handle it here.
10515 */
10516 if (is_compat_task()) {
10517 struct compat_iw_point *compat_iw_point =
10518 (struct compat_iw_point *)&wrqu->data;
10519 sub_cmd = compat_iw_point->flags;
10520 } else {
10521 sub_cmd = wrqu->data.flags;
10522 }
10523#else
10524 sub_cmd = wrqu->data.flags;
10525#endif
10526
10527 switch (sub_cmd) {
10528 case WE_GET_RECOVERY_STAT:
10529 {
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010530 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010531
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010532 sme_get_recovery_stats(hal);
10533 break;
10534 }
10535
Govind Singha471e5e2015-10-12 17:11:14 +053010536 case WE_GET_FW_PROFILE_DATA:
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010537 ret = wma_cli_set_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +053010538 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
10539 0, DBG_CMD);
10540 break;
10541
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010542 case WE_IBSS_GET_PEER_INFO_ALL:
10543 {
10544 hdd_wlan_get_ibss_peer_info_all(adapter);
10545 break;
10546 }
10547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010548 case WE_SET_REASSOC_TRIGGER:
10549 {
Jeff Johnson3d278b02017-08-29 14:17:47 -070010550 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010551
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010552 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010553 tSirMacAddr bssid;
Krunal Sonibfd05492017-10-03 15:48:37 -070010554 uint32_t roamId = INVALID_ROAM_ID;
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010555 uint8_t operating_ch =
10556 adapter->sessionCtx.station.conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010557 tCsrRoamModifyProfileFields modProfileFields;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010558
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010559 sme_get_modify_profile_fields(hHal, adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010560 &modProfileFields);
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010561 if (roaming_offload_enabled(hdd_ctx)) {
10562 qdf_mem_copy(bssid,
10563 &adapter->sessionCtx.station.conn_info.bssId,
10564 sizeof(bssid));
Naveen Rawat664a7cb2017-01-19 17:58:14 -080010565 hdd_wma_send_fastreassoc_cmd(adapter,
Deepak Dhamdhere5fda0e42016-06-24 18:30:02 +053010566 bssid, operating_ch);
10567 } else {
10568 sme_roam_reassoc(hdd_ctx->hHal, adapter->sessionId,
10569 NULL, modProfileFields, &roamId, 1);
10570 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010571 return 0;
10572 }
10573
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080010574 case WE_STOP_OBSS_SCAN:
10575 {
10576 /*
10577 * 1.OBSS Scan is mandatory while operating in 2.4GHz
10578 * 2.OBSS scan is stopped by Firmware during the disassociation
10579 * 3.OBSS stop comamnd is added for debugging purpose
10580 */
10581 tHalHandle hal;
10582
10583 hal = WLAN_HDD_GET_HAL_CTX(adapter);
10584 if (hal == NULL) {
10585 hdd_err("hal context is NULL");
10586 return -EINVAL;
10587 }
10588 sme_ht40_stop_obss_scan(hal, adapter->sessionId);
10589 }
10590 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010591 default:
10592 {
Jeff Johnson99bac312016-06-28 10:38:18 -070010593 hdd_err("unknown ioctl %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010594 break;
10595 }
10596 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010597 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010598 return ret;
10599}
10600
10601static int iw_setnone_getnone(struct net_device *dev,
10602 struct iw_request_info *info,
10603 union iwreq_data *wrqu, char *extra)
10604{
10605 int ret;
10606
10607 cds_ssr_protect(__func__);
10608 ret = __iw_setnone_getnone(dev, info, wrqu, extra);
10609 cds_ssr_unprotect(__func__);
10610
10611 return ret;
10612}
10613
Krunal Sonia6e505b2017-01-12 12:25:18 -080010614#ifdef MPC_UT_FRAMEWORK
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010615static int iw_get_policy_manager_ut_ops(struct hdd_context *hdd_ctx,
Jeff Johnson3d278b02017-08-29 14:17:47 -070010616 struct hdd_adapter *adapter, int sub_cmd, int *apps_args)
Krunal Sonia6e505b2017-01-12 12:25:18 -080010617{
Jeff Johnsonac8b0de2017-02-10 09:22:22 -080010618 switch (sub_cmd) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010619 case WE_POLICY_MANAGER_CLIST_CMD:
10620 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010621 hdd_debug("<iwpriv wlan0 pm_clist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010622 policy_mgr_incr_connection_count_utfw(hdd_ctx->hdd_psoc,
10623 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
10624 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010625 }
10626 break;
10627
10628 case WE_POLICY_MANAGER_DLIST_CMD:
10629 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010630 hdd_debug("<iwpriv wlan0 pm_dlist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010631 policy_mgr_decr_connection_count_utfw(hdd_ctx->hdd_psoc,
10632 apps_args[0], apps_args[1]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010633 }
10634 break;
10635
10636 case WE_POLICY_MANAGER_ULIST_CMD:
10637 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010638 hdd_debug("<iwpriv wlan0 pm_ulist> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010639 policy_mgr_update_connection_info_utfw(hdd_ctx->hdd_psoc,
10640 apps_args[0], apps_args[1], apps_args[2], apps_args[3],
10641 apps_args[4], apps_args[5], apps_args[6], apps_args[7]);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010642 }
10643 break;
10644
10645 case WE_POLICY_MANAGER_DBS_CMD:
10646 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010647 hdd_debug("<iwpriv wlan0 pm_dbs> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -080010648 if (apps_args[0] == 0)
10649 wma_set_dbs_capability_ut(0);
10650 else
10651 wma_set_dbs_capability_ut(1);
10652
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010653 if (apps_args[1] >= PM_THROUGHPUT &&
10654 apps_args[1] <= PM_LATENCY) {
Krunal Sonia6e505b2017-01-12 12:25:18 -080010655 pr_info("setting system pref to [%d]\n", apps_args[1]);
10656 hdd_ctx->config->conc_system_pref = apps_args[1];
10657 }
10658 }
10659 break;
10660
10661 case WE_POLICY_MANAGER_PCL_CMD:
10662 {
10663 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0};
10664 uint8_t weight_list[QDF_MAX_NUM_CHAN] = {0};
10665 uint32_t pcl_len = 0, i = 0;
10666
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -070010667 hdd_debug("<iwpriv wlan0 pm_pcl> is called");
Krunal Sonia6e505b2017-01-12 12:25:18 -080010668
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010669 policy_mgr_get_pcl(hdd_ctx->hdd_psoc, apps_args[0],
Krunal Sonia6e505b2017-01-12 12:25:18 -080010670 pcl, &pcl_len,
10671 weight_list, QDF_ARRAY_SIZE(weight_list));
10672 pr_info("PCL list for role[%d] is {", apps_args[0]);
10673 for (i = 0 ; i < pcl_len; i++)
10674 pr_info(" %d, ", pcl[i]);
10675 pr_info("}--------->\n");
10676 }
10677 break;
10678
10679 case WE_POLICY_SET_HW_MODE_CMD:
10680 {
10681 if (apps_args[0] == 0) {
10682 hdd_err("set hw mode for single mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010683 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010684 adapter->sessionId,
10685 HW_MODE_SS_2x2,
10686 HW_MODE_80_MHZ,
10687 HW_MODE_SS_0x0, HW_MODE_BW_NONE,
10688 HW_MODE_DBS_NONE,
10689 HW_MODE_AGILE_DFS_NONE,
10690 HW_MODE_SBS_NONE,
10691 SIR_UPDATE_REASON_UT);
10692 } else if (apps_args[0] == 1) {
10693 hdd_err("set hw mode for dual mac");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010694 policy_mgr_pdev_set_hw_mode(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010695 adapter->sessionId,
10696 HW_MODE_SS_1x1,
10697 HW_MODE_80_MHZ,
10698 HW_MODE_SS_1x1, HW_MODE_40_MHZ,
10699 HW_MODE_DBS,
10700 HW_MODE_AGILE_DFS_NONE,
10701 HW_MODE_SBS_NONE,
10702 SIR_UPDATE_REASON_UT);
10703 }
10704 }
10705 break;
10706
10707 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
10708 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010709 enum policy_mgr_conc_next_action action;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010710
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -070010711 hdd_debug("<iwpriv wlan0 pm_query_action> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010712 action = policy_mgr_current_connections_update(
10713 hdd_ctx->hdd_psoc,
10714 adapter->sessionId, apps_args[0],
10715 SIR_UPDATE_REASON_UT);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010716 pr_info("next action is %d {HDD_NOP = 0, HDD_DBS, HDD_DBS_DOWNGRADE, HDD_MCC, HDD_MCC_UPGRADE}", action);
10717 }
10718 break;
10719
10720 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
10721 {
10722 bool allow;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010723
10724 hdd_notice("<iwpriv wlan0 pm_query_allow> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010725 allow = policy_mgr_allow_concurrency(hdd_ctx->hdd_psoc,
Krunal Sonia6e505b2017-01-12 12:25:18 -080010726 apps_args[0], apps_args[1], apps_args[2]);
10727 pr_info("allow %d {0 = don't allow, 1 = allow}", allow);
10728 }
10729 break;
10730
10731 case WE_POLICY_MANAGER_SCENARIO_CMD:
10732 {
10733 clean_report(hdd_ctx);
10734 if (apps_args[0] == 1) {
10735 wlan_hdd_one_connection_scenario(hdd_ctx);
10736 } else if (apps_args[0] == 2) {
10737 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010738 6, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010739 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010740 36, POLICY_MGR_TWO_TWO);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010741 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010742 6, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010743 wlan_hdd_two_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010744 36, POLICY_MGR_ONE_ONE);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010745 } else if (apps_args[0] == 3) {
10746 /* MCC on same band with 2x2 same mac*/
10747 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010748 6, 11, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010749 /* MCC on diff band with 2x2 same mac*/
10750 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010751 6, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010752 /* MCC on diff band with 1x1 diff mac */
10753 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010754 36, 6, POLICY_MGR_ONE_ONE, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010755 /* MCC on diff band with 1x1 same mac */
10756 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010757 36, 6, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010758 /* SCC on same band with 2x2 same mac */
10759 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010760 36, 36, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010761 /* SCC on same band with 1x1 same mac */
10762 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010763 36, 36, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010764 /* MCC on same band with 2x2 same mac */
10765 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010766 36, 149, POLICY_MGR_TWO_TWO, 0);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010767 /* MCC on same band with 1x1 same mac */
10768 wlan_hdd_three_connections_scenario(hdd_ctx,
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010769 36, 149, POLICY_MGR_ONE_ONE, 1);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010770 }
10771 print_report(hdd_ctx);
10772 }
10773 break;
10774 }
10775 return 0;
10776}
10777#else
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010778static int iw_get_policy_manager_ut_ops(struct hdd_context *hdd_ctx,
Jeff Johnson3d278b02017-08-29 14:17:47 -070010779 struct hdd_adapter *adapter, int sub_cmd, int *apps_args)
Krunal Sonia6e505b2017-01-12 12:25:18 -080010780{
10781 return 0;
10782}
10783#endif
10784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010785/**
10786 * __iw_set_var_ints_getnone - Generic "set many" private ioctl handler
10787 * @dev: device upon which the ioctl was received
10788 * @info: ioctl request information
10789 * @wrqu: ioctl request data
10790 * @extra: ioctl extra data
10791 *
10792 * This is an SSR-protected generic handler for private ioctls which
10793 * take multiple arguments. Note that this implementation is also
10794 * somewhat unique in that it is shared by both STA-mode and SAP-mode
10795 * interfaces.
10796 *
10797 * Return: 0 on success, non-zero on error
10798 */
10799static int __iw_set_var_ints_getnone(struct net_device *dev,
10800 struct iw_request_info *info,
10801 union iwreq_data *wrqu, char *extra)
10802{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010803 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
10804 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010805 int sub_cmd;
10806 int *apps_args = (int *) extra;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070010807 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010808 int ret, num_args;
10809
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080010810 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053010811
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010812 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010813 ret = wlan_hdd_validate_context(hdd_ctx);
10814 if (0 != ret)
10815 return ret;
10816
Jeff Johnson441e1f72017-02-07 08:50:49 -080010817 ret = hdd_check_private_wext_control(hdd_ctx, info);
10818 if (0 != ret)
10819 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010820
10821 sub_cmd = wrqu->data.flags;
10822 num_args = wrqu->data.length;
10823
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010824 hdd_debug("Received length %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010825
10826 switch (sub_cmd) {
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010827 case WE_IBSS_GET_PEER_INFO:
10828 {
10829 pr_info("Station ID = %d\n", apps_args[0]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010830 hdd_wlan_get_ibss_peer_info(adapter, apps_args[0]);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080010831 }
10832 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010833
10834 case WE_P2P_NOA_CMD:
10835 {
Srinivas Girigowda5d5fdc52017-03-24 22:30:57 -070010836 struct p2p_app_set_ps p2pNoA;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010837
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010838 if (adapter->device_mode != QDF_P2P_GO_MODE) {
Rajeev Kumar274034c2015-11-23 11:28:58 -080010839 hdd_err("Setting NoA is not allowed in Device mode %s(%d)",
10840 hdd_device_mode_to_string(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010841 adapter->device_mode),
10842 adapter->device_mode);
Rajeev Kumar274034c2015-11-23 11:28:58 -080010843 return -EINVAL;
10844 }
10845
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010846 p2pNoA.opp_ps = apps_args[0];
10847 p2pNoA.ctWindow = apps_args[1];
10848 p2pNoA.duration = apps_args[2];
10849 p2pNoA.interval = apps_args[3];
10850 p2pNoA.count = apps_args[4];
10851 p2pNoA.single_noa_duration = apps_args[5];
10852 p2pNoA.psSelection = apps_args[6];
10853
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010854 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 -070010855 apps_args[0], apps_args[1], apps_args[2],
10856 apps_args[3], apps_args[4],
10857 apps_args[5], apps_args[6]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010858
10859 hdd_set_p2p_ps(dev, &p2pNoA);
10860
10861 }
10862 break;
10863
10864 case WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD:
10865 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010866 hdd_debug("SELECTIVE_MODULE_LOG %d arg1 %d arg2",
Jeff Johnson99bac312016-06-28 10:38:18 -070010867 apps_args[0], apps_args[1]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010868 qdf_trace_enable(apps_args[0], apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010869 }
10870 break;
10871
10872 case WE_MTRACE_DUMP_CMD:
10873 {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080010874 hdd_debug("MTRACE_DUMP code %d session %d count %d bitmask_of_module %d ",
Jeff Johnson99bac312016-06-28 10:38:18 -070010875 apps_args[0], apps_args[1],
10876 apps_args[2], apps_args[3]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010877 qdf_trace_dump_all((void *)hHal, apps_args[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010878 apps_args[1], apps_args[2],
10879 apps_args[3]);
10880
10881 }
10882 break;
10883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010884 case WE_POLICY_MANAGER_CINFO_CMD:
10885 {
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010886 struct policy_mgr_conc_connection_info *conn_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010887 uint32_t i = 0, len = 0;
10888
Krunal Sonia6e505b2017-01-12 12:25:18 -080010889 hdd_info("<iwpriv wlan0 pm_cinfo> is called");
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080010890 conn_info = policy_mgr_get_conn_info(&len);
Krunal Sonia6e505b2017-01-12 12:25:18 -080010891 pr_info("+--------------------------+\n");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010892 for (i = 0; i < len; i++) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -070010893 pr_info("|table_index[%d]\t\t\n", i);
10894 pr_info("|\t|vdev_id - %-10d|\n", conn_info->vdev_id);
10895 pr_info("|\t|chan - %-10d|\n", conn_info->chan);
10896 pr_info("|\t|bw - %-10d|\n", conn_info->bw);
10897 pr_info("|\t|mode - %-10d|\n", conn_info->mode);
10898 pr_info("|\t|mac - %-10d|\n", conn_info->mac);
10899 pr_info("|\t|in_use - %-10d|\n", conn_info->in_use);
10900 pr_info("+--------------------------+\n");
10901 conn_info++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010902 }
10903 }
10904 break;
10905
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010906
10907#ifdef FEATURE_WLAN_TDLS
10908 case WE_TDLS_CONFIG_PARAMS:
10909 {
Jeff Johnsona0ce1022017-10-01 20:09:16 -070010910 struct hdd_tdls_config_params tdlsParams;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010911
10912 tdlsParams.tdls = apps_args[0];
10913 tdlsParams.tx_period_t = apps_args[1];
10914 tdlsParams.tx_packet_n = apps_args[2];
10915 /* ignore args[3] as discovery_period is not used anymore */
10916 tdlsParams.discovery_tries_n = apps_args[4];
10917 /* ignore args[5] as idle_timeout is not used anymore */
10918 tdlsParams.idle_packet_n = apps_args[6];
10919 /* ignore args[7] as rssi_hysteresis is not used anymore */
10920 tdlsParams.rssi_trigger_threshold = apps_args[8];
10921 tdlsParams.rssi_teardown_threshold = apps_args[9];
10922 tdlsParams.rssi_delta = apps_args[10];
10923
10924 wlan_hdd_tdls_set_params(dev, &tdlsParams);
10925 }
10926 break;
10927#endif
10928 case WE_UNIT_TEST_CMD:
10929 {
Krunal Soniaadaa272017-10-04 16:42:55 -070010930 QDF_STATUS status;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010931
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010932 if ((apps_args[0] < WLAN_MODULE_ID_MIN) ||
10933 (apps_args[0] >= WLAN_MODULE_ID_MAX)) {
Krunal Soniaadaa272017-10-04 16:42:55 -070010934 hdd_err("Invalid MODULE ID %d", apps_args[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010935 return -EINVAL;
10936 }
Krunal Soniaadaa272017-10-04 16:42:55 -070010937 if ((apps_args[1] >= (WMA_MAX_NUM_ARGS)) ||
Anurag Chouhan77564182016-09-03 16:38:01 +053010938 (apps_args[1] < 0)) {
Krunal Soniaadaa272017-10-04 16:42:55 -070010939 hdd_err("Too Many/Few args %d", apps_args[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010940 return -EINVAL;
10941 }
Krunal Soniaadaa272017-10-04 16:42:55 -070010942 status = sme_send_unit_test_cmd(adapter->sessionId,
10943 apps_args[0],
10944 apps_args[1],
10945 &apps_args[2]);
10946 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson21d63bb2017-10-07 17:45:33 -070010947 hdd_err("sme_send_unit_test_cmd returned %d", status);
10948 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010949 }
10950 }
10951 break;
10952#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
10953 case WE_LED_FLASHING_PARAM:
10954 {
10955 int i;
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070010956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010957 if (num_args != 4) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010958 hdd_err("gpio_control: 4 parameters are required");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010959 return -EINVAL;
10960 }
10961 for (i = 0; i < num_args; i++) {
10962 if (apps_args[i] >= 0x7fffffff) {
Jeff Johnson99bac312016-06-28 10:38:18 -070010963 hdd_err("gpio_control: parameter should be less than 0x7fffffff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010964 return -EINVAL;
10965 }
10966 }
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010967 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010968 0, apps_args[0], apps_args[1]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010969 sme_set_led_flashing(WLAN_HDD_GET_HAL_CTX(adapter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010970 1, apps_args[2], apps_args[3]);
10971 }
10972 break;
10973#endif
Poddar, Siddarth176c4362016-10-03 12:25:00 +053010974 case WE_SET_PKTLOG:
10975 {
10976 int ret;
10977
10978 if (num_args < 1 || num_args > 2) {
10979 hdd_err("pktlog: either 1 or 2 parameters are required");
10980 return -EINVAL;
10981 }
10982
10983 ret = hdd_process_pktlog_command(hdd_ctx, apps_args[0],
10984 apps_args[1]);
10985 if (ret)
10986 return ret;
10987 break;
10988 }
10989
Manjeet Singhf82ed072016-07-08 11:40:00 +053010990 case WE_MAC_PWR_DEBUG_CMD:
10991 {
10992 struct sir_mac_pwr_dbg_cmd mac_pwr_dbg_args;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070010993 tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter);
Manjeet Singhf82ed072016-07-08 11:40:00 +053010994 int i, j;
10995
10996 if (num_args < 3) {
10997 hdd_err("number of arguments can't be null %d",
10998 num_args);
10999 return -EINVAL;
11000 }
11001 if (num_args - 3 != apps_args[2]) {
11002 hdd_err("arg list of size %d doesn't match num_args %d",
11003 num_args-3, apps_args[2]);
11004 return -EINVAL;
11005 }
11006 if ((apps_args[1] < WLAN_MODULE_ID_MIN) ||
11007 (apps_args[1] >= WLAN_MODULE_ID_MAX)) {
11008 hdd_err("Invalid MODULE ID %d", apps_args[1]);
11009 return -EINVAL;
11010 }
11011 if (apps_args[2] > (MAX_POWER_DBG_ARGS_SUPPORTED)) {
11012 hdd_err("Too Many args %d", apps_args[2]);
11013 return -EINVAL;
11014 }
11015 mac_pwr_dbg_args.pdev_id = apps_args[0];
11016 mac_pwr_dbg_args.module_id = apps_args[1];
11017 mac_pwr_dbg_args.num_args = apps_args[2];
11018
11019 for (i = 0, j = 3; i < mac_pwr_dbg_args.num_args; i++, j++)
11020 mac_pwr_dbg_args.args[i] = apps_args[j];
11021
11022 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011023 sme_process_mac_pwr_dbg_cmd(hal, adapter->sessionId,
Manjeet Singhf82ed072016-07-08 11:40:00 +053011024 &mac_pwr_dbg_args)) {
11025 return -EINVAL;
11026 }
11027 }
11028 break;
Krunal Sonia6e505b2017-01-12 12:25:18 -080011029 case WE_POLICY_MANAGER_CLIST_CMD:
11030 case WE_POLICY_MANAGER_DLIST_CMD:
11031 case WE_POLICY_MANAGER_ULIST_CMD:
11032 case WE_POLICY_MANAGER_DBS_CMD:
11033 case WE_POLICY_MANAGER_PCL_CMD:
11034 case WE_POLICY_SET_HW_MODE_CMD:
11035 case WE_POLICY_MANAGER_QUERY_ACTION_CMD:
11036 case WE_POLICY_MANAGER_QUERY_ALLOW_CMD:
11037 case WE_POLICY_MANAGER_SCENARIO_CMD:
11038 {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011039 iw_get_policy_manager_ut_ops(hdd_ctx, adapter,
Krunal Sonia6e505b2017-01-12 12:25:18 -080011040 sub_cmd, apps_args);
11041 }
11042 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011043 default:
11044 {
Jeff Johnson99bac312016-06-28 10:38:18 -070011045 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011046 }
11047 break;
11048 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011049 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011050 return 0;
11051}
11052
11053/**
11054 * iw_hdd_set_var_ints_getnone() - set var ints getnone callback
11055 * @dev: pointer to net_device structure
11056 * @info: pointer to iw_request_info structure
11057 * @wrqu: pointer to iwreq_data
11058 * @extra; extra
11059 *
11060 * Return: 0 on success, error number otherwise
11061 *
11062 */
11063static int iw_hdd_set_var_ints_getnone(struct net_device *dev,
11064 struct iw_request_info *info,
11065 union iwreq_data *wrqu, char *extra)
11066{
11067 union iwreq_data u_priv_wrqu;
11068 int apps_args[MAX_VAR_ARGS] = {0};
11069 int ret, num_args;
11070
Mukul Sharma64a70e82015-11-02 20:05:09 +053011071 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011072 hdd_err("permission check failed");
Mukul Sharma64a70e82015-11-02 20:05:09 +053011073 return -EPERM;
11074 }
11075
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011076 /* Helper function to get iwreq_data with compat handling. */
11077 if (hdd_priv_get_data(&u_priv_wrqu.data, wrqu))
11078 return -EINVAL;
11079
11080 if (NULL == u_priv_wrqu.data.pointer) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011081 hdd_err("NULL data pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011082 return -EINVAL;
11083 }
11084
11085 num_args = u_priv_wrqu.data.length;
11086 if (num_args > MAX_VAR_ARGS)
11087 num_args = MAX_VAR_ARGS;
11088
11089 if (copy_from_user(apps_args, u_priv_wrqu.data.pointer,
11090 (sizeof(int)) * num_args)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011091 hdd_err("failed to copy data from user buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011092 return -EFAULT;
11093 }
11094
11095 cds_ssr_protect(__func__);
11096 ret = __iw_set_var_ints_getnone(dev, info, &u_priv_wrqu,
11097 (char *)&apps_args);
11098 cds_ssr_unprotect(__func__);
11099 return ret;
11100}
11101
11102/**
11103 * iw_set_var_ints_getnone - Generic "set many" private ioctl handler
11104 * @dev: device upon which the ioctl was received
11105 * @info: ioctl request information
11106 * @wrqu: ioctl request data
11107 * @extra: ioctl extra data
11108 *
11109 * This is a generic handler for private ioctls which take multiple
11110 * arguments. Note that this implementation is also somewhat unique
11111 * in that it is shared by both STA-mode and SAP-mode interfaces.
11112 *
11113 * Return: 0 on success, non-zero on error
11114 */
11115int iw_set_var_ints_getnone(struct net_device *dev,
11116 struct iw_request_info *info,
11117 union iwreq_data *wrqu, char *extra)
11118{
11119 int ret;
11120
11121 cds_ssr_protect(__func__);
11122 ret = __iw_set_var_ints_getnone(dev, info, wrqu, extra);
11123 cds_ssr_unprotect(__func__);
11124 return ret;
11125}
11126
11127/**
11128 * iw_add_tspec - Add TSpec private ioctl handler
11129 * @dev: device upon which the ioctl was received
11130 * @info: ioctl request information
11131 * @wrqu: ioctl request data
11132 * @extra: ioctl extra data
11133 *
11134 * Return: 0 on success, non-zero on error
11135 */
11136static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
11137 union iwreq_data *wrqu, char *extra)
11138{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011139 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -070011140 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011141 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11142 int params[HDD_WLAN_WMM_PARAM_COUNT];
Abhishek Singh12be60f2017-08-11 13:52:42 +053011143 struct sme_qos_wmmtspecinfo tSpec;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011144 uint32_t handle;
11145 struct iw_point s_priv_data;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011146 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011147 int ret;
11148
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011149 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011150
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011151 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011152 ret = wlan_hdd_validate_context(hdd_ctx);
11153 if (0 != ret)
11154 return ret;
11155
Jeff Johnson441e1f72017-02-07 08:50:49 -080011156 ret = hdd_check_private_wext_control(hdd_ctx, info);
11157 if (0 != ret)
11158 return ret;
11159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011160 /* make sure the application is sufficiently priviledged */
11161 /* note that the kernel will do this for "set" ioctls, but since */
11162 /* this ioctl wants to return status to user space it must be */
11163 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011164 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011165 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011166
11167 /* we must be associated in order to add a tspec */
Jeff Johnsond377dce2017-10-04 10:32:42 -070011168 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011169 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11170 return 0;
11171 }
11172 /* since we are defined to be a "get" ioctl, and since the number */
11173 /* of params exceeds the number of params that wireless extensions */
11174 /* will pass down in the iwreq_data, we must copy the "set" params. */
11175 /* We must handle the compat for iwreq_data in 32U/64K environment. */
11176
11177 /* helper function to get iwreq_data with compat handling. */
11178 if (hdd_priv_get_data(&s_priv_data, wrqu)) {
11179 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11180 return 0;
11181 }
11182 /* make sure all params are correctly passed to function */
11183 if ((NULL == s_priv_data.pointer) ||
11184 (HDD_WLAN_WMM_PARAM_COUNT != s_priv_data.length)) {
11185 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11186 return 0;
11187 }
11188 /* from user space ourselves */
11189 if (copy_from_user(&params, s_priv_data.pointer, sizeof(params))) {
11190 /* hmmm, can't get them */
11191 return -EIO;
11192 }
11193 /* clear the tspec */
11194 memset(&tSpec, 0, sizeof(tSpec));
11195
11196 /* validate the handle */
11197 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11198 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11199 /* that one is reserved */
11200 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11201 return 0;
11202 }
11203 /* validate the TID */
11204 if (params[HDD_WLAN_WMM_PARAM_TID] > 7) {
11205 /* out of range */
11206 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11207 return 0;
11208 }
11209 tSpec.ts_info.tid = params[HDD_WLAN_WMM_PARAM_TID];
11210
11211 /* validate the direction */
11212 switch (params[HDD_WLAN_WMM_PARAM_DIRECTION]) {
11213 case HDD_WLAN_WMM_DIRECTION_UPSTREAM:
11214 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_UPLINK;
11215 break;
11216
11217 case HDD_WLAN_WMM_DIRECTION_DOWNSTREAM:
11218 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_DOWNLINK;
11219 break;
11220
11221 case HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL:
11222 tSpec.ts_info.direction = SME_QOS_WMM_TS_DIR_BOTH;
11223 break;
11224
11225 default:
11226 /* unknown */
11227 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11228 return 0;
11229 }
11230
11231 tSpec.ts_info.psb = params[HDD_WLAN_WMM_PARAM_APSD];
11232
11233 /* validate the user priority */
11234 if (params[HDD_WLAN_WMM_PARAM_USER_PRIORITY] >= SME_QOS_WMM_UP_MAX) {
11235 /* out of range */
11236 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11237 return 0;
11238 }
11239 tSpec.ts_info.up = params[HDD_WLAN_WMM_PARAM_USER_PRIORITY];
11240 if (0 > tSpec.ts_info.up || SME_QOS_WMM_UP_MAX < tSpec.ts_info.up) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011241 hdd_err("***ts_info.up out of bounds***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011242 return 0;
11243 }
11244
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011245 hdd_debug("TS_INFO PSB %d UP %d !!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011246 tSpec.ts_info.psb, tSpec.ts_info.up);
11247
11248 tSpec.nominal_msdu_size = params[HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE];
11249 tSpec.maximum_msdu_size = params[HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE];
11250 tSpec.min_data_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE];
11251 tSpec.mean_data_rate = params[HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE];
11252 tSpec.peak_data_rate = params[HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE];
11253 tSpec.max_burst_size = params[HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE];
11254 tSpec.min_phy_rate = params[HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE];
11255 tSpec.surplus_bw_allowance =
11256 params[HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE];
11257 tSpec.min_service_interval =
11258 params[HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL];
11259 tSpec.max_service_interval =
11260 params[HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL];
11261 tSpec.suspension_interval =
11262 params[HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL];
11263 tSpec.inactivity_interval =
11264 params[HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL];
11265
11266 tSpec.ts_info.burst_size_defn =
11267 params[HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN];
11268
11269 /* validate the ts info ack policy */
11270 switch (params[HDD_WLAN_WMM_PARAM_ACK_POLICY]) {
11271 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
11272 tSpec.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
11273 break;
11274
11275 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
11276 tSpec.ts_info.ack_policy =
11277 SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
11278 break;
11279
11280 default:
11281 /* unknown */
11282 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11283 return 0;
11284 }
11285
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011286 *pStatus = hdd_wmm_addts(adapter, handle, &tSpec);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011287 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011288 return 0;
11289}
11290
11291static int iw_add_tspec(struct net_device *dev,
11292 struct iw_request_info *info,
11293 union iwreq_data *wrqu, char *extra)
11294{
11295 int ret;
11296
11297 cds_ssr_protect(__func__);
11298 ret = __iw_add_tspec(dev, info, wrqu, extra);
11299 cds_ssr_unprotect(__func__);
11300
11301 return ret;
11302}
11303
11304/**
11305 * iw_del_tspec - Delete TSpec private ioctl handler
11306 * @dev: device upon which the ioctl was received
11307 * @info: ioctl request information
11308 * @wrqu: ioctl request data
11309 * @extra: ioctl extra data
11310 *
11311 * Return: 0 on success, non-zero on error
11312 */
11313static int __iw_del_tspec(struct net_device *dev, struct iw_request_info *info,
11314 union iwreq_data *wrqu, char *extra)
11315{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011316 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011317 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011318 int *params = (int *)extra;
11319 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11320 uint32_t handle;
11321 int ret;
11322
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011323 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011324
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011325 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011326 ret = wlan_hdd_validate_context(hdd_ctx);
11327 if (0 != ret)
11328 return ret;
11329
Jeff Johnson441e1f72017-02-07 08:50:49 -080011330 ret = hdd_check_private_wext_control(hdd_ctx, info);
11331 if (0 != ret)
11332 return ret;
11333
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011334 /* make sure the application is sufficiently priviledged */
11335 /* note that the kernel will do this for "set" ioctls, but since */
11336 /* this ioctl wants to return status to user space it must be */
11337 /* defined as a "get" ioctl */
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070011338 if (!capable(CAP_NET_ADMIN))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011339 return -EPERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011340
11341 /* although we are defined to be a "get" ioctl, the params we require */
11342 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11343 /* is no need to copy the params from user space */
11344
11345 /* validate the handle */
11346 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11347 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11348 /* that one is reserved */
11349 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11350 return 0;
11351 }
11352
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011353 *pStatus = hdd_wmm_delts(adapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011354 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011355 return 0;
11356}
11357
11358static int iw_del_tspec(struct net_device *dev,
11359 struct iw_request_info *info,
11360 union iwreq_data *wrqu, char *extra)
11361{
11362 int ret;
11363
11364 cds_ssr_protect(__func__);
11365 ret = __iw_del_tspec(dev, info, wrqu, extra);
11366 cds_ssr_unprotect(__func__);
11367
11368 return ret;
11369}
11370
11371/**
11372 * iw_get_tspec - Get TSpec private ioctl handler
11373 * @dev: device upon which the ioctl was received
11374 * @info: ioctl request information
11375 * @wrqu: ioctl request data
11376 * @extra: ioctl extra data
11377 *
11378 * Return: 0 on success, non-zero on error
11379 */
11380static int __iw_get_tspec(struct net_device *dev, struct iw_request_info *info,
11381 union iwreq_data *wrqu, char *extra)
11382{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011383 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011384 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011385 int *params = (int *)extra;
11386 hdd_wlan_wmm_status_e *pStatus = (hdd_wlan_wmm_status_e *) extra;
11387 uint32_t handle;
11388 int ret;
11389
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011390 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011391
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011392 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011393 ret = wlan_hdd_validate_context(hdd_ctx);
11394 if (0 != ret)
11395 return ret;
11396
Jeff Johnson441e1f72017-02-07 08:50:49 -080011397 ret = hdd_check_private_wext_control(hdd_ctx, info);
11398 if (0 != ret)
11399 return ret;
11400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011401 /* although we are defined to be a "get" ioctl, the params we require */
11402 /* will fit in the iwreq_data, therefore unlike iw_add_tspec() there */
11403 /* is no need to copy the params from user space */
11404
11405 /* validate the handle */
11406 handle = params[HDD_WLAN_WMM_PARAM_HANDLE];
11407 if (HDD_WMM_HANDLE_IMPLICIT == handle) {
11408 /* that one is reserved */
11409 *pStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
11410 return 0;
11411 }
11412
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011413 *pStatus = hdd_wmm_checkts(adapter, handle);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011414 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011415 return 0;
11416}
11417
11418static int iw_get_tspec(struct net_device *dev,
11419 struct iw_request_info *info,
11420 union iwreq_data *wrqu, char *extra)
11421{
11422 int ret;
11423
11424 cds_ssr_protect(__func__);
11425 ret = __iw_get_tspec(dev, info, wrqu, extra);
11426 cds_ssr_unprotect(__func__);
11427
11428 return ret;
11429}
11430
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011431/**
11432 * iw_set_fties - Set FT IEs private ioctl handler
11433 * @dev: device upon which the ioctl was received
11434 * @info: ioctl request information
11435 * @wrqu: ioctl request data
11436 * @extra: ioctl extra data
11437 *
11438 * Each time the supplicant has the auth_request or reassoc request
11439 * IEs ready they are pushed to the driver. The driver will in turn
11440 * use it to send out the auth req and reassoc req for 11r FT Assoc.
11441 *
11442 * Return: 0 on success, non-zero on error
11443 */
11444static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
11445 union iwreq_data *wrqu, char *extra)
11446{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011447 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsond377dce2017-10-04 10:32:42 -070011448 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011449 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011450 int ret;
11451
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011452 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011453
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011454 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011455 ret = wlan_hdd_validate_context(hdd_ctx);
11456 if (0 != ret)
11457 return ret;
11458
Jeff Johnson441e1f72017-02-07 08:50:49 -080011459 ret = hdd_check_private_wext_control(hdd_ctx, info);
11460 if (0 != ret)
11461 return ret;
11462
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011463 if (!wrqu->data.length) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011464 hdd_err("called with 0 length IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011465 return -EINVAL;
11466 }
11467 if (wrqu->data.pointer == NULL) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011468 hdd_err("called with NULL IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011469 return -EINVAL;
11470 }
11471 /* Added for debug on reception of Re-assoc Req. */
Jeff Johnsond377dce2017-10-04 10:32:42 -070011472 if (eConnectionState_Associated != sta_ctx->conn_info.connState) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011473 hdd_debug("Called with Ie of length = %d when not associated",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011474 wrqu->data.length);
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011475 hdd_debug("Should be Re-assoc Req IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011476 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011477 hdd_debug("called with Ie of length = %d", wrqu->data.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011478
11479 /* Pass the received FT IEs to SME */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011480 sme_set_ft_ies(WLAN_HDD_GET_HAL_CTX(adapter), adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011481 extra, wrqu->data.length);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011482 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011483 return 0;
11484}
11485
11486static int iw_set_fties(struct net_device *dev,
11487 struct iw_request_info *info,
11488 union iwreq_data *wrqu, char *extra)
11489{
11490 int ret;
11491
11492 cds_ssr_protect(__func__);
11493 ret = __iw_set_fties(dev, info, wrqu, extra);
11494 cds_ssr_unprotect(__func__);
11495
11496 return ret;
11497}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011498
Dustin Brown0cbc7572016-12-16 13:54:40 -080011499/**
11500 * iw_set_dynamic_mcbc_filter() - Set Dynamic MCBC Filter ioctl handler
11501 * @dev: device upon which the ioctl was received
11502 * @info: ioctl request information
11503 * @wrqu: ioctl request data
11504 * @extra: ioctl extra data
11505 *
Dustin Brown860566f2017-01-31 15:24:43 -080011506 * This IOCTL is OBSOLETE as of Jan 30, 2017. We are leaving it here for the
11507 * time being to provide guidance in migrating to standard APIs.
11508 *
Dustin Brown0cbc7572016-12-16 13:54:40 -080011509 * Return: 0 on success, non-zero on error
11510 */
11511static int iw_set_dynamic_mcbc_filter(struct net_device *dev,
11512 struct iw_request_info *info,
11513 union iwreq_data *wrqu,
11514 char *extra)
11515{
Dustin Brown860566f2017-01-31 15:24:43 -080011516 hdd_err("\n"
11517 "setMCBCFilter is obsolete. Use the following instead:\n"
11518 "Configure multicast filtering via the ‘ip’ command.\n"
11519 "\tip maddr add 11:22:33:44:55:66 dev wlan0 # allow traffic to address\n"
11520 "\tip maddr del 11:22:33:44:55:66 dev wlan0 # undo allow\n"
11521 "Configure broadcast filtering via ini item, 'g_enable_non_arp_bc_hw_filter.'\n"
11522 "\tg_enable_non_arp_bc_hw_filter=1 # drop all non-ARP broadcast traffic\n"
11523 "\tg_enable_non_arp_bc_hw_filter=0 # allow all broadcast traffic");
Jeff Johnson59eb5fd2017-10-05 09:42:39 -070011524 return -EINVAL;
Dustin Brown0cbc7572016-12-16 13:54:40 -080011525}
11526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011527/**
11528 * iw_set_host_offload - Set host offload ioctl handler
11529 * @dev: device upon which the ioctl was received
11530 * @info: ioctl request information
11531 * @wrqu: ioctl request data
11532 * @extra: ioctl extra data
11533 *
11534 * Return: 0 on success, non-zero on error
11535 */
11536static int __iw_set_host_offload(struct net_device *dev,
11537 struct iw_request_info *info,
11538 union iwreq_data *wrqu, char *extra)
11539{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011540 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Srinivas Girigowda077143e2017-03-25 10:47:27 -070011541 struct host_offload_req *pRequest = (struct host_offload_req *) extra;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011542 tSirHostOffloadReq offloadRequest;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011543 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011544 int ret;
11545
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011546 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011547
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011548 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011549 ret = wlan_hdd_validate_context(hdd_ctx);
11550 if (0 != ret)
11551 return ret;
11552
Jeff Johnson441e1f72017-02-07 08:50:49 -080011553 ret = hdd_check_private_wext_control(hdd_ctx, info);
11554 if (0 != ret)
11555 return ret;
11556
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011557 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011558 hdd_err("dev is not in CONNECTED state, ignore!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011559 return -EINVAL;
11560 }
11561
11562 /* Debug display of request components. */
11563 switch (pRequest->offloadType) {
11564 case WLAN_IPV4_ARP_REPLY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011565 hdd_debug("Host offload request: ARP reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011566 switch (pRequest->enableOrDisable) {
11567 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011568 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011569 break;
11570 case WLAN_OFFLOAD_ARP_AND_BC_FILTER_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011571 hdd_debug(" BC Filtering enable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011572 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011573 hdd_debug(" ARP offload enable");
11574 hdd_debug(" IP address: %d.%d.%d.%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011575 pRequest->params.hostIpv4Addr[0],
11576 pRequest->params.hostIpv4Addr[1],
11577 pRequest->params.hostIpv4Addr[2],
11578 pRequest->params.hostIpv4Addr[3]);
11579 }
11580 break;
11581
11582 case WLAN_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011583 hdd_debug("Host offload request: neighbor discovery");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011584 switch (pRequest->enableOrDisable) {
11585 case WLAN_OFFLOAD_DISABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011586 hdd_debug(" disable");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011587 break;
11588 case WLAN_OFFLOAD_ENABLE:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011589 hdd_debug(" enable");
11590 hdd_debug(" IP address: %x:%x:%x:%x:%x:%x:%x:%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011591 *(uint16_t *) (pRequest->params.hostIpv6Addr),
11592 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11593 2),
11594 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11595 4),
11596 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11597 6),
11598 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11599 8),
11600 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11601 10),
11602 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11603 12),
11604 *(uint16_t *) (pRequest->params.hostIpv6Addr +
11605 14));
11606 }
11607 }
11608
11609 /* Execute offload request. The reason that we can copy the
11610 * request information from the ioctl structure to the SME
11611 * structure is that they are laid out exactly the same.
11612 * Otherwise, each piece of information would have to be
11613 * copied individually.
11614 */
11615 memcpy(&offloadRequest, pRequest, wrqu->data.length);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011616 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011617 sme_set_host_offload(WLAN_HDD_GET_HAL_CTX(adapter),
11618 adapter->sessionId, &offloadRequest)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011619 hdd_err("Failure to execute host offload request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011620 return -EINVAL;
11621 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011622 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011623 return 0;
11624}
11625
11626static int iw_set_host_offload(struct net_device *dev,
11627 struct iw_request_info *info,
11628 union iwreq_data *wrqu, char *extra)
11629{
11630 int ret;
11631
11632 cds_ssr_protect(__func__);
11633 ret = __iw_set_host_offload(dev, info, wrqu, extra);
11634 cds_ssr_unprotect(__func__);
11635
11636 return ret;
11637}
11638
11639/**
11640 * iw_set_keepalive_params - Set keepalive params ioctl handler
11641 * @dev: device upon which the ioctl was received
11642 * @info: ioctl request information
11643 * @wrqu: ioctl request data
11644 * @extra: ioctl extra data
11645 *
11646 * Return: 0 on success, non-zero on error
11647 */
11648static int __iw_set_keepalive_params(struct net_device *dev,
11649 struct iw_request_info *info,
11650 union iwreq_data *wrqu, char *extra)
11651{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011652 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011653 tpSirKeepAliveReq request = (tpSirKeepAliveReq) extra;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011654 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011655 int ret;
11656
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011657 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011658
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011659 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011660 ret = wlan_hdd_validate_context(hdd_ctx);
11661 if (0 != ret)
11662 return ret;
11663
Jeff Johnson441e1f72017-02-07 08:50:49 -080011664 ret = hdd_check_private_wext_control(hdd_ctx, info);
11665 if (0 != ret)
11666 return ret;
11667
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011668 if (wrqu->data.length != sizeof(*request)) {
11669 hdd_err("Invalid length %d", wrqu->data.length);
11670 return -EINVAL;
11671 }
11672
11673 if (request->timePeriod > WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX) {
11674 hdd_err("Value of timePeriod %d exceed Max limit %d",
11675 request->timePeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011676 WNI_CFG_INFRA_STA_KEEP_ALIVE_PERIOD_STAMAX);
11677 return -EINVAL;
11678 }
11679
11680 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011681 hdd_debug("Set Keep Alive Request : TimePeriod %d size %zu",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011682 request->timePeriod, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011683
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011684 switch (request->packetType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011685 case WLAN_KEEP_ALIVE_NULL_PKT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011686 hdd_debug("Keep Alive Request: Tx NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011687 break;
11688
11689 case WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011690 hdd_debug("Keep Alive Request: Tx UnSolicited ARP RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011691
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011692 hdd_debug("Host IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011693 request->hostIpv4Addr[0], request->hostIpv4Addr[1],
11694 request->hostIpv4Addr[2], request->hostIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011695
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011696 hdd_debug("Dest IP address: %d.%d.%d.%d",
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011697 request->destIpv4Addr[0], request->destIpv4Addr[1],
11698 request->destIpv4Addr[2], request->destIpv4Addr[3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011699
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011700 hdd_debug("Dest MAC address: "MAC_ADDRESS_STR,
Srinivas Girigowda9c330a92015-11-24 12:28:25 -080011701 MAC_ADDR_ARRAY(request->dest_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011702 break;
11703 }
11704
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011705 hdd_debug("Keep alive period %d", request->timePeriod);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011706
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011707 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070011708 sme_set_keep_alive(WLAN_HDD_GET_HAL_CTX(adapter),
11709 adapter->sessionId, request)) {
Rajeev Kumar3ddf1c62015-11-03 14:10:13 -080011710 hdd_err("Failure to execute Keep Alive");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011711 return -EINVAL;
11712 }
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011713 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011714 return 0;
11715}
11716
11717static int iw_set_keepalive_params(struct net_device *dev,
11718 struct iw_request_info *info,
11719 union iwreq_data *wrqu,
11720 char *extra)
11721{
11722 int ret;
11723
11724 cds_ssr_protect(__func__);
11725 ret = __iw_set_keepalive_params(dev, info, wrqu, extra);
11726 cds_ssr_unprotect(__func__);
11727
11728 return ret;
11729}
11730
11731#ifdef WLAN_FEATURE_PACKET_FILTERING
11732/**
11733 * wlan_hdd_set_filter() - Set packet filter
11734 * @hdd_ctx: Global HDD context
11735 * @request: Packet filter request struct
11736 * @sessionId: Target session for the request
11737 *
11738 * Return: 0 on success, non-zero on error
11739 */
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +053011740int wlan_hdd_set_filter(struct hdd_context *hdd_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011741 struct pkt_filter_cfg *request,
11742 uint8_t sessionId)
11743{
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011744 struct pmo_rcv_pkt_fltr_cfg *pmo_set_pkt_fltr_req = NULL;
11745 struct pmo_rcv_pkt_fltr_clear_param *pmo_clr_pkt_fltr_param = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011746 int i = 0;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011747 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011748
11749 if (hdd_ctx->config->disablePacketFilter) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011750 hdd_warn("Packet filtering disabled in ini");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011751 return 0;
11752 }
11753
11754 /* Debug display of request components. */
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011755 hdd_debug("Packet Filter Request : FA %d params %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011756 request->filter_action, request->num_params);
11757
11758 switch (request->filter_action) {
11759 case HDD_RCV_FILTER_SET:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011760 hdd_debug("Set Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011761 request->filter_id);
11762
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011763 pmo_set_pkt_fltr_req =
11764 qdf_mem_malloc(sizeof(*pmo_set_pkt_fltr_req));
11765 if (!pmo_set_pkt_fltr_req) {
Mukul Sharmad75a6672017-06-22 15:40:53 +053011766 hdd_err("unable to allocate pmo_set_pkt_fltr_req");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011767 return QDF_STATUS_E_NOMEM;
11768 }
11769
11770 pmo_set_pkt_fltr_req->filter_id = request->filter_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011771 if (request->num_params >= HDD_MAX_CMP_PER_PACKET_FILTER) {
11772 hdd_err("Number of Params exceed Max limit %d",
11773 request->num_params);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011774 status = QDF_STATUS_E_INVAL;
11775 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011776 }
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011777 pmo_set_pkt_fltr_req->num_params = request->num_params;
11778 pmo_set_pkt_fltr_req->coalesce_time = 0;
Srinivas Girigowdabbbecad2017-06-28 16:01:48 -070011779 pmo_set_pkt_fltr_req->filter_type = PMO_RCV_FILTER_TYPE_FILTER_PKT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011780 for (i = 0; i < request->num_params; i++) {
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011781 pmo_set_pkt_fltr_req->params_data[i].protocol_layer =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011782 request->params_data[i].protocol_layer;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011783 pmo_set_pkt_fltr_req->params_data[i].compare_flag =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011784 request->params_data[i].compare_flag;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011785 pmo_set_pkt_fltr_req->params_data[i].data_offset =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011786 request->params_data[i].data_offset;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011787 pmo_set_pkt_fltr_req->params_data[i].data_length =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011788 request->params_data[i].data_length;
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011789 pmo_set_pkt_fltr_req->params_data[i].reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011790
Dustin Brown4d1e8462016-12-14 12:12:24 -080011791 if (request->params_data[i].data_offset >
11792 SIR_MAX_FILTER_TEST_DATA_OFFSET) {
11793 hdd_err("Invalid data offset %u for param %d (max = %d)",
11794 request->params_data[i].data_offset,
11795 i,
11796 SIR_MAX_FILTER_TEST_DATA_OFFSET);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011797 status = QDF_STATUS_E_INVAL;
11798 goto out;
Dustin Brown4d1e8462016-12-14 12:12:24 -080011799 }
11800
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011801 if (request->params_data[i].data_length >
11802 SIR_MAX_FILTER_TEST_DATA_LEN) {
11803 hdd_err("Error invalid data length %d",
11804 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011805 status = QDF_STATUS_E_INVAL;
11806 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011807 }
11808
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011809 hdd_debug("Proto %d Comp Flag %d Filter Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011810 request->params_data[i].protocol_layer,
11811 request->params_data[i].compare_flag,
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011812 pmo_set_pkt_fltr_req->filter_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011813
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011814 hdd_debug("Data Offset %d Data Len %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011815 request->params_data[i].data_offset,
11816 request->params_data[i].data_length);
11817
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011818 if (sizeof(
11819 pmo_set_pkt_fltr_req->params_data[i].compare_data)
Rajeev Kumarf5b6da22016-04-15 13:24:03 -070011820 < (request->params_data[i].data_length)) {
11821 hdd_err("Error invalid data length %d",
11822 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011823 status = QDF_STATUS_E_INVAL;
11824 goto out;
Rajeev Kumarf5b6da22016-04-15 13:24:03 -070011825 }
11826
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011827 memcpy(
11828 &pmo_set_pkt_fltr_req->params_data[i].compare_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011829 request->params_data[i].compare_data,
11830 request->params_data[i].data_length);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011831 memcpy(&pmo_set_pkt_fltr_req->params_data[i].data_mask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011832 request->params_data[i].data_mask,
11833 request->params_data[i].data_length);
11834
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011835 hdd_debug("CData %d CData %d CData %d CData %d CData %d CData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011836 request->params_data[i].compare_data[0],
11837 request->params_data[i].compare_data[1],
11838 request->params_data[i].compare_data[2],
11839 request->params_data[i].compare_data[3],
11840 request->params_data[i].compare_data[4],
11841 request->params_data[i].compare_data[5]);
11842
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011843 hdd_debug("MData %d MData %d MData %d MData %d MData %d MData %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011844 request->params_data[i].data_mask[0],
11845 request->params_data[i].data_mask[1],
11846 request->params_data[i].data_mask[2],
11847 request->params_data[i].data_mask[3],
11848 request->params_data[i].data_mask[4],
11849 request->params_data[i].data_mask[5]);
11850 }
11851
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011852 if (QDF_STATUS_SUCCESS !=
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011853 pmo_ucfg_set_pkt_filter(hdd_ctx->hdd_psoc,
11854 pmo_set_pkt_fltr_req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011855 sessionId)) {
11856 hdd_err("Failure to execute Set Filter");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011857 status = QDF_STATUS_E_INVAL;
11858 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011859 }
11860
11861 break;
11862
11863 case HDD_RCV_FILTER_CLEAR:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080011864 hdd_debug("Clear Packet Filter Request for Id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011865 request->filter_id);
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011866
11867 pmo_clr_pkt_fltr_param = qdf_mem_malloc(
11868 sizeof(*pmo_clr_pkt_fltr_param));
11869 if (!pmo_clr_pkt_fltr_param) {
11870 hdd_err("unable to allocate pmo_clr_pkt_fltr_param");
11871 return QDF_STATUS_E_NOMEM;
11872 }
11873
11874 pmo_clr_pkt_fltr_param->filter_id = request->filter_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011875 if (QDF_STATUS_SUCCESS !=
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011876 pmo_ucfg_clear_pkt_filter(hdd_ctx->hdd_psoc,
11877 pmo_clr_pkt_fltr_param,
11878 sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011879 hdd_err("Failure to execute Clear Filter");
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011880 status = QDF_STATUS_E_INVAL;
11881 goto out;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011882 }
11883 break;
11884
11885 default:
11886 hdd_err("Packet Filter Request: Invalid %d",
11887 request->filter_action);
11888 return -EINVAL;
11889 }
Ravi Kumar Bokka4bd571d2017-04-17 14:21:10 +053011890
11891out:
11892 if (pmo_set_pkt_fltr_req)
11893 qdf_mem_free(pmo_set_pkt_fltr_req);
11894 if (pmo_clr_pkt_fltr_param)
11895 qdf_mem_free(pmo_clr_pkt_fltr_param);
11896
11897 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011898}
11899
11900/**
11901 * __iw_set_packet_filter_params() - set packet filter parameters in target
11902 * @dev: Pointer to netdev
11903 * @info: Pointer to iw request info
11904 * @wrqu: Pointer to data
11905 * @extra: Pointer to extra data
11906 *
11907 * Return: 0 on success, non-zero on error
11908 */
11909static int __iw_set_packet_filter_params(struct net_device *dev,
11910 struct iw_request_info *info,
11911 union iwreq_data *wrqu, char *extra)
11912{
11913 int ret;
Jeff Johnson6d38ab82017-08-28 11:36:27 -070011914 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011915 struct iw_point priv_data;
Jeff Johnson3d278b02017-08-29 14:17:47 -070011916 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011917 struct pkt_filter_cfg *request = NULL;
11918
Mukul Sharma472382f2015-11-02 20:16:31 +053011919 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070011920 hdd_err("permission check failed");
Mukul Sharma472382f2015-11-02 20:16:31 +053011921 return -EPERM;
11922 }
11923
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080011924 ENTER_DEV(dev);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011925
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011926 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
11927 ret = wlan_hdd_validate_context(hdd_ctx);
11928 if (0 != ret)
11929 return ret;
11930
Jeff Johnson441e1f72017-02-07 08:50:49 -080011931 ret = hdd_check_private_wext_control(hdd_ctx, info);
11932 if (0 != ret)
11933 return ret;
11934
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011935 if (hdd_priv_get_data(&priv_data, wrqu)) {
11936 hdd_err("failed to get priv data");
11937 return -EINVAL;
11938 }
11939
11940 if ((NULL == priv_data.pointer) || (0 == priv_data.length)) {
Jeff Johnson36e74c42017-09-18 08:15:42 -070011941 hdd_err("invalid priv data %pK or invalid priv data length %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011942 priv_data.pointer, priv_data.length);
11943 return -EINVAL;
11944 }
11945
Arun Khandavalli75d246b2017-08-07 19:46:06 +053011946 if (adapter->device_mode != QDF_STA_MODE) {
11947 hdd_err("Packet filter not supported for this mode :%d",
11948 adapter->device_mode);
11949 return -ENOTSUPP;
11950 }
11951
Mukul Sharmabe846bb2017-05-09 17:41:52 +053011952 if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) {
11953 hdd_err("Packet filter not supported in disconnected state");
11954 return -ENOTSUPP;
11955 }
11956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011957 /* copy data using copy_from_user */
11958 request = mem_alloc_copy_from_user_helper(priv_data.pointer,
11959 priv_data.length);
11960 if (NULL == request) {
11961 hdd_err("mem_alloc_copy_from_user_helper fail");
11962 return -ENOMEM;
11963 }
11964
Hanumanth Reddy Pothula3def8942017-10-05 16:19:36 +053011965 if (request->filter_action == HDD_RCV_FILTER_SET)
11966 hdd_ctx->user_configured_pkt_filter_rules |=
11967 1 << request->filter_id;
11968 else if (request->filter_action == HDD_RCV_FILTER_CLEAR)
11969 hdd_ctx->user_configured_pkt_filter_rules &=
11970 ~(1 << request->filter_id);
11971
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011972 ret = wlan_hdd_set_filter(hdd_ctx, request, adapter->sessionId);
11973
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -070011974 qdf_mem_free(request);
Hanumantha Reddy Pothula2db50ed2015-11-23 10:48:33 +053011975 EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011976 return ret;
11977}
11978
11979/**
11980 * iw_set_packet_filter_params() - set packet filter parameters in target
11981 * @dev: Pointer to netdev
11982 * @info: Pointer to iw request info
11983 * @wrqu: Pointer to data
11984 * @extra: Pointer to extra data
11985 *
11986 * Return: 0 on success, non-zero on error
11987 */
11988static int iw_set_packet_filter_params(struct net_device *dev,
11989 struct iw_request_info *info,
11990 union iwreq_data *wrqu, char *extra)
11991{
11992 int ret;
11993
11994 cds_ssr_protect(__func__);
11995 ret = __iw_set_packet_filter_params(dev, info, wrqu, extra);
11996 cds_ssr_unprotect(__func__);
11997
11998 return ret;
11999}
12000#endif
12001
12002
12003static int __iw_get_statistics(struct net_device *dev,
12004 struct iw_request_info *info,
12005 union iwreq_data *wrqu, char *extra)
12006{
12007
Anurag Chouhance0dc992016-02-16 18:18:03 +053012008 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012009 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson2a722002017-09-30 20:02:35 -070012010 struct hdd_wext_state *pWextState;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012011 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12012 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012013 char *p = extra;
12014 int tlen = 0;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012015 tCsrSummaryStatsInfo *pStats = &(adapter->hdd_stats.summary_stat);
12016 tCsrGlobalClassAStatsInfo *aStats = &(adapter->hdd_stats.ClassA_stat);
12017 tCsrGlobalClassDStatsInfo *dStats = &(adapter->hdd_stats.ClassD_stat);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012018 int ret;
12019
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012020 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012021
12022 ret = wlan_hdd_validate_context(hdd_ctx);
12023 if (0 != ret)
12024 return ret;
12025
Jeff Johnson441e1f72017-02-07 08:50:49 -080012026 ret = hdd_check_private_wext_control(hdd_ctx, info);
12027 if (0 != ret)
12028 return ret;
12029
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012030 if (eConnectionState_Associated !=
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012031 (WLAN_HDD_GET_STATION_CTX_PTR(adapter))->conn_info.connState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012032
12033 wrqu->txpower.value = 0;
12034 } else {
12035 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
12036 SME_SUMMARY_STATS |
12037 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080012038 SME_GLOBAL_CLASSD_STATS,
Naveen Rawatd0ca4412017-06-16 14:19:19 -070012039 hdd_statistics_cb,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012040 (WLAN_HDD_GET_STATION_CTX_PTR
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012041 (adapter))->conn_info.staId[0],
12042 adapter, adapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012043
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012044 if (QDF_STATUS_SUCCESS != status) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012045 hdd_err("Unable to retrieve SME statistics");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012046 return -EINVAL;
12047 }
12048
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012049 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012050
Anurag Chouhance0dc992016-02-16 18:18:03 +053012051 qdf_status =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053012052 qdf_wait_single_event(&pWextState->hdd_qdf_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012053 WLAN_WAIT_TIME_STATS);
Anurag Chouhance0dc992016-02-16 18:18:03 +053012054 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012055 hdd_err("SME timeout while retrieving statistics");
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012056 /* Remove the SME statistics list by
12057 * passing NULL in callback argument
12058 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012059 status = sme_get_statistics(hdd_ctx->hHal, eCSR_HDD,
12060 SME_SUMMARY_STATS |
12061 SME_GLOBAL_CLASSA_STATS |
Jeff Johnsondfe89512017-03-10 15:50:00 -080012062 SME_GLOBAL_CLASSD_STATS,
Naveen Rawatd0ca4412017-06-16 14:19:19 -070012063 NULL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012064 (WLAN_HDD_GET_STATION_CTX_PTR
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012065 (adapter))->conn_info.
12066 staId[0], adapter,
12067 adapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012068
12069 return -EINVAL;
12070 }
12071 FILL_TLV(p, (uint8_t) WLAN_STATS_RETRY_CNT,
12072 (uint8_t) sizeof(pStats->retry_cnt),
12073 (char *)&(pStats->retry_cnt[0]), tlen);
12074
12075 FILL_TLV(p, (uint8_t) WLAN_STATS_MUL_RETRY_CNT,
12076 (uint8_t) sizeof(pStats->multiple_retry_cnt),
12077 (char *)&(pStats->multiple_retry_cnt[0]), tlen);
12078
12079 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_FRM_CNT,
12080 (uint8_t) sizeof(pStats->tx_frm_cnt),
12081 (char *)&(pStats->tx_frm_cnt[0]), tlen);
12082
12083 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_FRM_CNT,
12084 (uint8_t) sizeof(pStats->rx_frm_cnt),
12085 (char *)&(pStats->rx_frm_cnt), tlen);
12086
12087 FILL_TLV(p, (uint8_t) WLAN_STATS_FRM_DUP_CNT,
12088 (uint8_t) sizeof(pStats->frm_dup_cnt),
12089 (char *)&(pStats->frm_dup_cnt), tlen);
12090
12091 FILL_TLV(p, (uint8_t) WLAN_STATS_FAIL_CNT,
12092 (uint8_t) sizeof(pStats->fail_cnt),
12093 (char *)&(pStats->fail_cnt[0]), tlen);
12094
12095 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_FAIL_CNT,
12096 (uint8_t) sizeof(pStats->rts_fail_cnt),
12097 (char *)&(pStats->rts_fail_cnt), tlen);
12098
12099 FILL_TLV(p, (uint8_t) WLAN_STATS_ACK_FAIL_CNT,
12100 (uint8_t) sizeof(pStats->ack_fail_cnt),
12101 (char *)&(pStats->ack_fail_cnt), tlen);
12102
12103 FILL_TLV(p, (uint8_t) WLAN_STATS_RTS_SUC_CNT,
12104 (uint8_t) sizeof(pStats->rts_succ_cnt),
12105 (char *)&(pStats->rts_succ_cnt), tlen);
12106
12107 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_DISCARD_CNT,
12108 (uint8_t) sizeof(pStats->rx_discard_cnt),
12109 (char *)&(pStats->rx_discard_cnt), tlen);
12110
12111 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_ERROR_CNT,
12112 (uint8_t) sizeof(pStats->rx_error_cnt),
12113 (char *)&(pStats->rx_error_cnt), tlen);
12114
12115 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BYTE_CNT,
12116 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
12117 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
12118
12119 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BYTE_CNT,
12120 (uint8_t) sizeof(dStats->rx_byte_cnt),
12121 (char *)&(dStats->rx_byte_cnt), tlen);
12122
12123 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_RATE,
12124 (uint8_t) sizeof(dStats->rx_rate),
12125 (char *)&(dStats->rx_rate), tlen);
12126
12127 /* Transmit rate, in units of 500 kbit/sec */
12128 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_RATE,
12129 (uint8_t) sizeof(aStats->tx_rate),
12130 (char *)&(aStats->tx_rate), tlen);
12131
12132 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_UC_BYTE_CNT,
12133 (uint8_t) sizeof(dStats->rx_uc_byte_cnt[0]),
12134 (char *)&(dStats->rx_uc_byte_cnt[0]), tlen);
12135 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_MC_BYTE_CNT,
12136 (uint8_t) sizeof(dStats->rx_mc_byte_cnt),
12137 (char *)&(dStats->rx_mc_byte_cnt), tlen);
12138 FILL_TLV(p, (uint8_t) WLAN_STATS_RX_BC_BYTE_CNT,
12139 (uint8_t) sizeof(dStats->rx_bc_byte_cnt),
12140 (char *)&(dStats->rx_bc_byte_cnt), tlen);
12141 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_UC_BYTE_CNT,
12142 (uint8_t) sizeof(dStats->tx_uc_byte_cnt[0]),
12143 (char *)&(dStats->tx_uc_byte_cnt[0]), tlen);
12144 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_MC_BYTE_CNT,
12145 (uint8_t) sizeof(dStats->tx_mc_byte_cnt),
12146 (char *)&(dStats->tx_mc_byte_cnt), tlen);
12147 FILL_TLV(p, (uint8_t) WLAN_STATS_TX_BC_BYTE_CNT,
12148 (uint8_t) sizeof(dStats->tx_bc_byte_cnt),
12149 (char *)&(dStats->tx_bc_byte_cnt), tlen);
12150
12151 wrqu->data.length = tlen;
12152
12153 }
12154
12155 EXIT();
12156
12157 return 0;
12158}
12159
12160static int iw_get_statistics(struct net_device *dev,
12161 struct iw_request_info *info,
12162 union iwreq_data *wrqu, char *extra)
12163{
12164 int ret;
12165
12166 cds_ssr_protect(__func__);
12167 ret = __iw_get_statistics(dev, info, wrqu, extra);
12168 cds_ssr_unprotect(__func__);
12169
12170 return ret;
12171}
12172
12173#ifdef FEATURE_WLAN_SCAN_PNO
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012174/*Max Len for PNO notification*/
12175#define MAX_PNO_NOTIFY_LEN 100
Abhishek Singh0481d662017-04-11 18:20:11 +053012176static void found_pref_network_cb(struct wlan_objmgr_vdev *vdev,
12177 struct scan_event *event, void *args)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012178{
Abhishek Singh0481d662017-04-11 18:20:11 +053012179 struct vdev_osif_priv *osif_priv;
12180 struct wireless_dev *wdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012181 union iwreq_data wrqu;
12182 char buf[MAX_PNO_NOTIFY_LEN + 1];
12183
Abhishek Singh0481d662017-04-11 18:20:11 +053012184 wlan_vdev_obj_lock(vdev);
12185 osif_priv = wlan_vdev_get_ospriv(vdev);
12186 wlan_vdev_obj_unlock(vdev);
12187 if (!osif_priv) {
12188 hdd_err("osif_priv is null");
12189 return;
12190 }
12191
12192 wdev = osif_priv->wdev;
12193 if (!wdev) {
12194 hdd_err("wdev is null");
12195 return;
12196 }
12197
12198 hdd_debug("A preferred network was found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012199
12200 /* create the event */
Abhishek Singh0481d662017-04-11 18:20:11 +053012201 qdf_mem_zero(&wrqu, sizeof(wrqu));
12202 qdf_mem_zero(buf, sizeof(buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012203
12204 snprintf(buf, MAX_PNO_NOTIFY_LEN,
Abhishek Singh0481d662017-04-11 18:20:11 +053012205 "QCOM: Found preferred network:");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012206
12207 wrqu.data.pointer = buf;
12208 wrqu.data.length = strlen(buf);
12209
12210 /* send the event */
12211
Abhishek Singh0481d662017-04-11 18:20:11 +053012212 wireless_send_event(wdev->netdev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012213}
12214
12215/**
12216 * __iw_set_pno() - Preferred Network Offload ioctl handler
12217 * @dev: device upon which the ioctl was received
12218 * @info: ioctl request information
12219 * @wrqu: ioctl request data
12220 * @extra: ioctl extra data
12221 *
12222 * This function parses a Preferred Network Offload command
12223 * Input is string based and expected to be of the form:
12224 *
12225 * <enable(1) | disable(0)>
12226 * when enabling:
12227 * <number of networks>
12228 * for each network:
12229 * <ssid_len> <ssid> <authentication> <encryption>
12230 * <ch_num> <channel_list optional> <bcast_type> <rssi_threshold>
Dustin Brown43e87292016-10-10 10:38:25 -070012231 * <scan_time (seconds)>
12232 * <scan_repeat_count (0 means indefinite)>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012233 * <suspend mode>
12234 *
12235 * e.g:
Dustin Brown43e87292016-10-10 10:38:25 -070012236 * 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 -080012237 *
12238 * this translates into:
12239 * -----------------------------
12240 * enable PNO
12241 * 2 networks
12242 * Network 1:
12243 * test - with authentication type 0 and encryption type 0,
12244 * search on 3 channels: 1 6 and 11,
12245 * SSID bcast type is unknown (directed probe will be sent if
12246 * AP not found) and must meet -40dBm RSSI
12247 * Network 2:
12248 * test2 - with authentication type 4 and encryption type 4,
12249 * search on 6 channels 1, 2, 3, 4, 5 and 6
12250 * bcast type is non-bcast (directed probe will be sent)
12251 * and must not meet any RSSI threshold
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012252 * scan every 5 seconds 2 times
Dustin Brown43e87292016-10-10 10:38:25 -070012253 * enable on suspend
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012254 */
12255static int __iw_set_pno(struct net_device *dev,
12256 struct iw_request_info *info,
12257 union iwreq_data *wrqu, char *extra)
12258{
Jeff Johnson3d278b02017-08-29 14:17:47 -070012259 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070012260 struct hdd_context *hdd_ctx;
Abhishek Singh0481d662017-04-11 18:20:11 +053012261 uint8_t value;
12262 struct wlan_objmgr_vdev *vdev;
12263 struct wlan_objmgr_psoc *psoc;
12264 int ret = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012265 int offset;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012266 char *ptr, *data;
Abhishek Singh0481d662017-04-11 18:20:11 +053012267 uint8_t i, j, params;
12268 QDF_STATUS status;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012269 size_t len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012270
12271 /* request is a large struct, so we make it static to avoid
12272 * stack overflow. This API is only invoked via ioctl, so it
12273 * is serialized by the kernel rtnl_lock and hence does not
12274 * need to be reentrant
12275 */
Abhishek Singh0481d662017-04-11 18:20:11 +053012276 static struct pno_scan_req_params req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012277
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012278 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012279
12280 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12281 ret = wlan_hdd_validate_context(hdd_ctx);
12282 if (ret)
12283 return ret;
12284
Jeff Johnson441e1f72017-02-07 08:50:49 -080012285 ret = hdd_check_private_wext_control(hdd_ctx, info);
12286 if (0 != ret)
12287 return ret;
12288
Abhishek Singh0481d662017-04-11 18:20:11 +053012289 vdev = wlan_objmgr_get_vdev_by_macaddr_from_pdev(hdd_ctx->hdd_pdev,
12290 dev->dev_addr, WLAN_LEGACY_MAC_ID);
12291 if (!vdev) {
12292 hdd_err("vdev object is NULL");
12293 return -EIO;
12294 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012295
Abhishek Singh0481d662017-04-11 18:20:11 +053012296 hdd_debug("PNO data len %d data %s", wrqu->data.length, extra);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012297
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012298 /* making sure argument string ends with '\0' */
12299 len = (wrqu->data.length + 1);
12300 data = qdf_mem_malloc(len);
12301 if (!data) {
12302 hdd_err("fail to allocate memory %zu", len);
12303 return -EINVAL;
12304 }
12305 qdf_mem_copy(data, extra, (len-1));
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012306 ptr = data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012307
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012308 if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012309 hdd_err("PNO enable input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012310 ret = -EINVAL;
12311 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012312 }
12313
Abhishek Singh0481d662017-04-11 18:20:11 +053012314 if (!value) {
12315 status = ucfg_scan_pno_stop(vdev);
12316 if (QDF_IS_STATUS_ERROR(status)) {
12317 hdd_err("Failed to disabled PNO");
12318 ret = -EINVAL;
12319 } else {
12320 hdd_debug("PNO scan disabled");
12321 }
12322 goto exit;
12323 }
12324
12325 if (ucfg_scan_get_pno_in_progress(vdev)) {
12326 hdd_debug("pno is already in progress");
12327 ret = -EBUSY;
12328 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012329 }
12330
12331 ptr += offset;
12332
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012333 if (1 != sscanf(ptr, " %hhu %n", &value, &offset)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012334 hdd_err("PNO count input not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012335 ret = -EINVAL;
12336 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012337 }
Abhishek Singh0481d662017-04-11 18:20:11 +053012338 req.networks_cnt = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012339
Abhishek Singh0481d662017-04-11 18:20:11 +053012340 hdd_debug("PNO enable networks count %d offset %d",
12341 req.networks_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012342
Abhishek Singh0481d662017-04-11 18:20:11 +053012343 if ((0 == req.networks_cnt) ||
12344 (req.networks_cnt > SCAN_PNO_MAX_SUPP_NETWORKS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012345 hdd_err("Network count %d invalid",
Abhishek Singh0481d662017-04-11 18:20:11 +053012346 req.networks_cnt);
12347 ret = -EINVAL;
12348 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012349 }
12350
12351 ptr += offset;
12352
Abhishek Singh0481d662017-04-11 18:20:11 +053012353 for (i = 0; i < req.networks_cnt; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012354
Abhishek Singh0481d662017-04-11 18:20:11 +053012355 req.networks_list[i].ssid.length = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012356
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012357 params = sscanf(ptr, " %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012358 &(req.networks_list[i].ssid.length),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012359 &offset);
12360
12361 if (1 != params) {
12362 hdd_err("PNO ssid length input is not valid %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012363 ret = -EINVAL;
12364 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012365 }
12366
Abhishek Singh0481d662017-04-11 18:20:11 +053012367 if ((0 == req.networks_list[i].ssid.length) ||
12368 (req.networks_list[i].ssid.length > 32)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012369 hdd_err("SSID Len %d is not correct for network %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012370 req.networks_list[i].ssid.length, i);
12371 ret = -EINVAL;
12372 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012373 }
12374
12375 /* Advance to SSID */
12376 ptr += offset;
12377
Abhishek Singh0481d662017-04-11 18:20:11 +053012378 memcpy(req.networks_list[i].ssid.ssid, ptr,
12379 req.networks_list[i].ssid.length);
12380 ptr += req.networks_list[i].ssid.length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012381
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012382 params = sscanf(ptr, " %u %u %hhu %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012383 &(req.networks_list[i].authentication),
12384 &(req.networks_list[i].encryption),
12385 &(req.networks_list[i].channel_cnt),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012386 &offset);
12387
12388 if (3 != params) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012389 hdd_err("Incorrect cmd %s", ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012390 ret = -EINVAL;
12391 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012392 }
12393
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012394 hdd_debug("PNO len %d ssid %.*s auth %d encry %d channel count %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012395 req.networks_list[i].ssid.length,
12396 req.networks_list[i].ssid.length,
12397 req.networks_list[i].ssid.ssid,
12398 req.networks_list[i].authentication,
12399 req.networks_list[i].encryption,
12400 req.networks_list[i].channel_cnt, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012401
12402 /* Advance to channel list */
12403 ptr += offset;
12404
Abhishek Singh0481d662017-04-11 18:20:11 +053012405 if (SCAN_PNO_MAX_NETW_CHANNELS_EX <
12406 req.networks_list[i].channel_cnt) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012407 hdd_err("Incorrect number of channels");
Abhishek Singh0481d662017-04-11 18:20:11 +053012408 ret = -EINVAL;
12409 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012410 }
12411
Abhishek Singh0481d662017-04-11 18:20:11 +053012412 if (0 != req.networks_list[i].channel_cnt) {
12413 for (j = 0; j < req.networks_list[i].channel_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012414 j++) {
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012415 if (1 != sscanf(ptr, " %hhu %n", &value,
Abhishek Singh0481d662017-04-11 18:20:11 +053012416 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012417 hdd_err("PNO network channel is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012418 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012419 ret = -EINVAL;
12420 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012421 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012422 if (!IS_CHANNEL_VALID(value)) {
12423 hdd_err("invalid channel: %hhu", value);
12424 ret = -EINVAL;
12425 goto exit;
12426 }
Abhishek Singh0481d662017-04-11 18:20:11 +053012427 req.networks_list[i].channels[j] =
12428 cds_chan_to_freq(value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012429 /* Advance to next channel number */
12430 ptr += offset;
12431 }
12432 }
12433
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012434 if (1 != sscanf(ptr, " %u %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012435 &(req.networks_list[i].bc_new_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012436 &offset)) {
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012437 hdd_err("PNO broadcast network type is not valid %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012438 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012439 ret = -EINVAL;
12440 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012441 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012442 if (req.networks_list[i].bc_new_type > 2) {
12443 hdd_err("invalid bcast nw type: %u",
12444 req.networks_list[i].bc_new_type);
12445 ret = -EINVAL;
12446 goto exit;
12447 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012448
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012449 hdd_debug("PNO bcastNetwType %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012450 req.networks_list[i].bc_new_type, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012451
12452 /* Advance to rssi Threshold */
12453 ptr += offset;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012454 if (1 != sscanf(ptr, " %d %n",
Abhishek Singh0481d662017-04-11 18:20:11 +053012455 &(req.networks_list[i].rssi_thresh),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012456 &offset)) {
12457 hdd_err("PNO rssi threshold input is not valid %s",
12458 ptr);
Abhishek Singh0481d662017-04-11 18:20:11 +053012459 ret = -EINVAL;
12460 goto exit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012461 }
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012462 hdd_debug("PNO rssi %d offset %d",
Abhishek Singh0481d662017-04-11 18:20:11 +053012463 req.networks_list[i].rssi_thresh, offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012464 /* Advance to next network */
12465 ptr += offset;
12466 } /* For ucNetworkCount */
12467
Abhishek Singh0481d662017-04-11 18:20:11 +053012468 req.fast_scan_period = 0;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012469 if (sscanf(ptr, " %u %n", &(req.fast_scan_period), &offset) > 0) {
Abhishek Singh0481d662017-04-11 18:20:11 +053012470 req.fast_scan_period *= MSEC_PER_SEC;
Dustin Brown43e87292016-10-10 10:38:25 -070012471 ptr += offset;
12472 }
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012473 if (req.fast_scan_period == 0) {
12474 hdd_err("invalid fast scan period %u",
12475 req.fast_scan_period);
12476 ret = -EINVAL;
12477 goto exit;
12478 }
Dustin Brown43e87292016-10-10 10:38:25 -070012479
Abhishek Singh0481d662017-04-11 18:20:11 +053012480 req.fast_scan_max_cycles = 0;
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012481 if (sscanf(ptr, " %hhu %n", &value,
Dustin Brown43e87292016-10-10 10:38:25 -070012482 &offset) > 0)
12483 ptr += offset;
Abhishek Singh0481d662017-04-11 18:20:11 +053012484 req.fast_scan_max_cycles = value;
Dustin Brown43e87292016-10-10 10:38:25 -070012485
Abhishek Singh0481d662017-04-11 18:20:11 +053012486 wlan_pdev_obj_lock(hdd_ctx->hdd_pdev);
12487 psoc = wlan_pdev_get_psoc(hdd_ctx->hdd_pdev);
12488 wlan_pdev_obj_unlock(hdd_ctx->hdd_pdev);
12489 ucfg_scan_register_pno_cb(psoc,
12490 found_pref_network_cb, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012491
Abhishek Singh0481d662017-04-11 18:20:11 +053012492 ucfg_scan_get_pno_def_params(vdev, &req);
12493 status = ucfg_scan_pno_start(vdev, &req);
12494 if (QDF_IS_STATUS_ERROR(status)) {
12495 hdd_err("Failed to enable PNO");
12496 ret = -EINVAL;
12497 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012498
Abhishek Singh0481d662017-04-11 18:20:11 +053012499exit:
12500 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012501
Hanumanth Reddy Pothula6310c772017-01-16 14:19:21 +053012502 qdf_mem_free(data);
Abhishek Singh0481d662017-04-11 18:20:11 +053012503 return ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012504}
12505
12506static int iw_set_pno(struct net_device *dev,
12507 struct iw_request_info *info,
12508 union iwreq_data *wrqu, char *extra)
12509{
12510 int ret;
12511
12512 cds_ssr_protect(__func__);
12513 ret = __iw_set_pno(dev, info, wrqu, extra);
12514 cds_ssr_unprotect(__func__);
12515
12516 return ret;
12517}
12518#endif /* FEATURE_WLAN_SCAN_PNO */
12519
12520/* Common function to SetBand */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012521int hdd_reg_set_band(struct net_device *dev, u8 ui_band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012522{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012523 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
12524 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012525 enum band_info band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012526
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012527 QDF_STATUS status;
Jeff Johnsonce2ee982017-09-03 09:27:35 -070012528 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012529 hdd_adapter_list_node_t *pAdapterNode, *pNext;
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012530 enum band_info currBand;
12531 enum band_info connectedBand;
12532 long lrc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012533
12534 pAdapterNode = NULL;
12535 pNext = NULL;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012536 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012537
12538 switch (ui_band) {
12539 case WLAN_HDD_UI_BAND_AUTO:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012540 band = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012541 break;
12542 case WLAN_HDD_UI_BAND_5_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012543 band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012544 break;
12545 case WLAN_HDD_UI_BAND_2_4_GHZ:
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012546 band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012547 break;
12548 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070012549 hdd_err("Invalid band value %u", ui_band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012550 return -EINVAL;
12551 }
12552
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012553 hdd_debug("change band to %u", band);
12554
Jeff Johnsonce2ee982017-09-03 09:27:35 -070012555 if ((band == BAND_2G && hdd_ctx->config->nBandCapability == 2) ||
Rajeev Kumar Sirasanagandla4c9b6752017-07-25 20:35:20 +053012556 (band == BAND_5G && hdd_ctx->config->nBandCapability == 1) ||
12557 (band == BAND_ALL && hdd_ctx->config->nBandCapability != 0)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012558 hdd_err("band value %u violate INI settings %u",
Jeff Johnsonce2ee982017-09-03 09:27:35 -070012559 band, hdd_ctx->config->nBandCapability);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012560 return -EIO;
12561 }
12562
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012563 if (band == BAND_ALL) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012564 hdd_debug("Auto band received. Setting band same as ini value %d",
Jeff Johnsonce2ee982017-09-03 09:27:35 -070012565 hdd_ctx->config->nBandCapability);
12566 band = hdd_ctx->config->nBandCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012567 }
12568
Jeff Johnsonce2ee982017-09-03 09:27:35 -070012569 if (QDF_STATUS_SUCCESS != ucfg_reg_get_curr_band(hdd_ctx->hdd_pdev,
Amar Singhal58b45ef2017-08-01 13:43:54 -070012570 &currBand)) {
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012571 hdd_debug("Failed to get current band config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012572 return -EIO;
12573 }
12574
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012575 if (currBand == band)
12576 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012577
Jeff Johnsonce2ee982017-09-03 09:27:35 -070012578 hdd_ctx->curr_band = band;
Amar Singhal58b45ef2017-08-01 13:43:54 -070012579
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012580 /* Change band request received.
12581 * Abort pending scan requests, flush the existing scan results,
12582 * and change the band capability
12583 */
12584 hdd_debug("Current band value = %u, new setting %u ",
12585 currBand, band);
12586
Jeff Johnsonce2ee982017-09-03 09:27:35 -070012587 status = hdd_get_front_adapter(hdd_ctx, &pAdapterNode);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012588 while (NULL != pAdapterNode && QDF_STATUS_SUCCESS == status) {
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012589 adapter = pAdapterNode->adapter;
12590 hHal = WLAN_HDD_GET_HAL_CTX(adapter);
Jeff Johnsonce2ee982017-09-03 09:27:35 -070012591 wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID,
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012592 adapter->sessionId, INVALID_SCAN_ID, false);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012593 connectedBand = hdd_conn_get_connected_band(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012594 WLAN_HDD_GET_STATION_CTX_PTR(adapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012595
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012596 /* Handling is done only for STA and P2P */
12597 if (band != BAND_ALL &&
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012598 ((adapter->device_mode == QDF_STA_MODE) ||
12599 (adapter->device_mode == QDF_P2P_CLIENT_MODE)) &&
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012600 (hdd_conn_is_connected(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012601 WLAN_HDD_GET_STATION_CTX_PTR(adapter)))
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012602 && (connectedBand != band)) {
12603 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012604
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012605 /* STA already connected on current
12606 * band, So issue disconnect first,
12607 * then change the band
12608 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012609
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012610 hdd_debug("STA (Device mode %s(%d)) connected in band %u, Changing band to %u, Issuing Disconnect",
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012611 hdd_device_mode_to_string(adapter->device_mode),
12612 adapter->device_mode, currBand, band);
12613 INIT_COMPLETION(adapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012614
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012615 status = sme_roam_disconnect(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012616 WLAN_HDD_GET_HAL_CTX(adapter),
12617 adapter->sessionId,
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012618 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012619
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012620 if (QDF_STATUS_SUCCESS != status) {
12621 hdd_err("sme_roam_disconnect failure, status: %d",
Jeff Johnson99bac312016-06-28 10:38:18 -070012622 (int)status);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012623 return -EINVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012624 }
12625
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012626 lrc = wait_for_completion_timeout(
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012627 &adapter->disconnect_comp_var,
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012628 msecs_to_jiffies(
12629 WLAN_WAIT_TIME_DISCONNECT));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012630
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012631 if (lrc == 0) {
12632 hdd_err("Timeout while waiting for csr_roam_disconnect");
12633 return -ETIMEDOUT;
12634 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012635 }
12636
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012637 sme_scan_flush_result(hHal);
12638
Jeff Johnsonce2ee982017-09-03 09:27:35 -070012639 status = hdd_get_next_adapter(hdd_ctx, pAdapterNode, &pNext);
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012640 pAdapterNode = pNext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012641 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012642
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012643 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonce2ee982017-09-03 09:27:35 -070012644 ucfg_reg_set_band(hdd_ctx->hdd_pdev, band)) {
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012645 hdd_err("Failed to set the band value to %u",
12646 band);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012647 return -EINVAL;
12648 }
12649
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012650 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012651}
12652
12653static int __iw_set_band_config(struct net_device *dev,
12654 struct iw_request_info *info,
12655 union iwreq_data *wrqu, char *extra)
12656{
Jeff Johnson3d278b02017-08-29 14:17:47 -070012657 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnson6d38ab82017-08-28 11:36:27 -070012658 struct hdd_context *hdd_ctx;
Jeff Johnson441e1f72017-02-07 08:50:49 -080012659 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012660 int *value = (int *)extra;
12661
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012662 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012663
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012664 if (!capable(CAP_NET_ADMIN)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070012665 hdd_err("permission check failed");
Mukul Sharmaa5fe1982015-11-02 19:28:14 +053012666 return -EPERM;
12667 }
12668
Jeff Johnson441e1f72017-02-07 08:50:49 -080012669 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
12670 ret = hdd_check_private_wext_control(hdd_ctx, info);
12671 if (0 != ret)
12672 return ret;
12673
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070012674 return hdd_reg_set_band(dev, value[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012675}
12676
12677static int iw_set_band_config(struct net_device *dev,
12678 struct iw_request_info *info,
12679 union iwreq_data *wrqu, char *extra)
12680{
12681 int ret;
12682
12683 cds_ssr_protect(__func__);
12684 ret = __iw_set_band_config(dev, info, wrqu, extra);
12685 cds_ssr_unprotect(__func__);
12686
12687 return ret;
12688}
12689
Arunk Khandavalli062fb032017-10-04 12:18:15 +053012690int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012691 uint32_t bandwidth)
12692{
Jeff Johnson6d38ab82017-08-28 11:36:27 -070012693 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson40dae4e2017-08-29 14:00:25 -070012694 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012695 struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info;
12696 QDF_STATUS status;
12697 tHalHandle hal_hdl = hdd_ctx->hHal;
12698 struct qdf_mac_addr bssid;
12699 tCsrRoamProfile roam_profile;
Amar Singhal5cccafe2017-02-15 12:42:58 -080012700 struct ch_params ch_params;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012701
12702 if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) {
12703 hdd_err("Not supported, device is not in monitor mode");
12704 return -EINVAL;
12705 }
12706
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012707 hdd_debug("Set monitor mode Channel %d", chan);
Hong Shie531d1f2016-11-14 14:08:03 +080012708 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012709 roam_profile.ChannelInfo.ChannelList = &ch_info->channel;
12710 roam_profile.ChannelInfo.numOfChannels = 1;
12711 roam_profile.phyMode = ch_info->phy_mode;
12712 roam_profile.ch_params.ch_width = bandwidth;
Naveen Rawatc77e6e72016-08-05 15:19:03 -070012713 hdd_select_cbmode(adapter, chan, &roam_profile.ch_params);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012714
12715 qdf_mem_copy(bssid.bytes, adapter->macAddressCurrent.bytes,
12716 QDF_MAC_ADDR_SIZE);
12717
12718 ch_params.ch_width = bandwidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012719 wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params);
Manjunathappa Prakashc4dc9382017-03-07 18:50:33 -080012720 if (ch_params.ch_width == CH_WIDTH_INVALID) {
12721 hdd_err("Invalid capture channel or bandwidth for a country");
12722 return -EINVAL;
12723 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012724
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012725 status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params,
12726 &roam_profile);
12727 if (status) {
12728 hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode",
12729 status);
12730 }
12731
Arunk Khandavalli062fb032017-10-04 12:18:15 +053012732 adapter->mon_chan = chan;
12733 adapter->mon_bandwidth = bandwidth;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012734 return qdf_status_to_os_return(status);
12735}
12736
Dustin Brown8d2d0f52017-04-03 17:02:08 -070012737static int printk_adapter(void *priv, const char *fmt, ...)
12738{
12739 int ret;
12740 va_list args;
12741
12742 va_start(args, fmt);
12743 ret = vprintk(fmt, args);
12744 ret += printk("\n");
12745 va_end(args);
12746
12747 return ret;
12748}
12749
12750#ifdef WMI_INTERFACE_EVENT_LOGGING
12751static void hdd_ioctl_log_buffer(int log_id, uint32_t count)
12752{
12753 qdf_abstract_print *print = &printk_adapter;
12754
12755 switch (log_id) {
12756 case HTC_CREDIT_HISTORY_LOG:
12757 print(NULL, "HTC Credit History (count %u)", count);
12758 cds_print_htc_credit_history(count, print, NULL);
12759 break;
12760 case COMMAND_LOG:
12761 print(NULL, "Command Log (count %u)", count);
12762 wma_print_wmi_cmd_log(count, print, NULL);
12763 break;
12764 case COMMAND_TX_CMP_LOG:
12765 print(NULL, "Command Tx Complete Log (count %u)", count);
12766 wma_print_wmi_cmd_tx_cmp_log(count, print, NULL);
12767 break;
12768 case MGMT_COMMAND_LOG:
12769 print(NULL, "Management Command Log (count %u)", count);
12770 wma_print_wmi_mgmt_cmd_log(count, print, NULL);
12771 break;
12772 case MGMT_COMMAND_TX_CMP_LOG:
12773 print(NULL, "Management Command Tx Complete Log (count %u)",
12774 count);
12775 wma_print_wmi_mgmt_cmd_tx_cmp_log(count, print, NULL);
12776 break;
12777 case EVENT_LOG:
12778 print(NULL, "Event Log (count %u)", count);
12779 wma_print_wmi_event_log(count, print, NULL);
12780 break;
12781 case RX_EVENT_LOG:
12782 print(NULL, "Rx Event Log (count %u)", count);
12783 wma_print_wmi_rx_event_log(count, print, NULL);
12784 break;
12785 case MGMT_EVENT_LOG:
12786 print(NULL, "Management Event Log (count %u)", count);
12787 wma_print_wmi_mgmt_event_log(count, print, NULL);
12788 break;
12789 default:
12790 print(NULL, "Invalid Log Id %d", log_id);
12791 break;
12792 }
12793}
12794#else
12795static inline void hdd_ioctl_log_buffer(int log_id, uint32_t count)
12796{
12797}
12798#endif /* WMI_INTERFACE_EVENT_LOGGING */
12799
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012800static int __iw_set_two_ints_getnone(struct net_device *dev,
12801 struct iw_request_info *info,
12802 union iwreq_data *wrqu, char *extra)
12803{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012804 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012805 int *value = (int *)extra;
12806 int sub_cmd = value[0];
12807 int ret;
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012808 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012809
Jeff Johnson6ee91ee2016-02-11 18:55:30 -080012810 ENTER_DEV(dev);
12811
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012812 ret = wlan_hdd_validate_context(hdd_ctx);
12813 if (0 != ret)
12814 return ret;
12815
Jeff Johnson441e1f72017-02-07 08:50:49 -080012816 ret = hdd_check_private_wext_control(hdd_ctx, info);
12817 if (0 != ret)
12818 return ret;
12819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012820 switch (sub_cmd) {
12821 case WE_SET_SMPS_PARAM:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012822 hdd_debug("WE_SET_SMPS_PARAM val %d %d", value[1], value[2]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012823 ret = wma_cli_set_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012824 WMI_STA_SMPS_PARAM_CMDID,
12825 value[1] << WMA_SMPS_PARAM_VALUE_S
12826 | value[2],
12827 VDEV_CMD);
12828 break;
Srinivas Girigowda6147c582016-10-18 12:26:15 -070012829#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012830 case WE_SET_FW_CRASH_INJECT:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012831 hdd_debug("WE_SET_FW_CRASH_INJECT: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012832 value[1], value[2]);
DARAM SUDHA7e7e91b2015-05-29 11:38:47 +053012833 pr_err("SSR is triggered by iwpriv CRASH_INJECT: %d %d\n",
12834 value[1], value[2]);
SaidiReddy Yenugacc733af2016-11-09 17:45:42 +053012835 if (!hdd_ctx->config->crash_inject_enabled) {
12836 hdd_err("Crash Inject ini disabled, Ignore Crash Inject");
12837 return 0;
12838 }
Yue Ma06152352017-06-20 18:08:58 -070012839 if (value[1] == 3) {
Anurag Chouhan4085ff72017-10-05 18:09:56 +053012840 cds_trigger_recovery(QDF_REASON_UNSPECIFIED);
Yue Ma06152352017-06-20 18:08:58 -070012841 return 0;
12842 }
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012843 ret = wma_cli_set2_command(adapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012844 GEN_PARAM_CRASH_INJECT,
12845 value[1], value[2], GEN_CMD);
12846 break;
12847#endif
Govind Singha471e5e2015-10-12 17:11:14 +053012848 case WE_ENABLE_FW_PROFILE:
Jeff Johnson99bac312016-06-28 10:38:18 -070012849 hdd_err("WE_ENABLE_FW_PROFILE: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012850 value[1], value[2]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012851 ret = wma_cli_set2_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +053012852 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
12853 value[1], value[2], DBG_CMD);
12854 break;
12855 case WE_SET_FW_PROFILE_HIST_INTVL:
Jeff Johnson99bac312016-06-28 10:38:18 -070012856 hdd_err("WE_SET_FW_PROFILE_HIST_INTVL: %d %d",
Govind Singha471e5e2015-10-12 17:11:14 +053012857 value[1], value[2]);
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012858 ret = wma_cli_set2_command(adapter->sessionId,
Govind Singha471e5e2015-10-12 17:11:14 +053012859 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
12860 value[1], value[2], DBG_CMD);
12861 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012862 case WE_SET_DUAL_MAC_FW_MODE_CONFIG:
12863 hdd_debug("Ioctl to set dual fw mode config");
Tushnim Bhattacharyya49ed8ab2017-05-26 18:20:10 -070012864 if (hdd_ctx->config->dual_mac_feature_disable ==
12865 DISABLE_DBS_CXN_AND_SCAN) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012866 hdd_err("Dual mac feature is disabled from INI");
12867 return -EPERM;
12868 }
12869 hdd_debug("%d %d", value[1], value[2]);
Tushnim Bhattacharyyade1070d2017-03-09 13:23:55 -080012870 policy_mgr_set_dual_mac_fw_mode_config(hdd_ctx->hdd_psoc,
12871 value[1], value[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012872 break;
12873 case WE_DUMP_DP_TRACE_LEVEL:
Srinivas Girigowdaaf2bfa42017-03-06 18:45:13 -080012874 hdd_debug("WE_DUMP_DP_TRACE_LEVEL: %d %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012875 value[1], value[2]);
12876 if (value[1] == DUMP_DP_TRACE)
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -070012877 qdf_dp_trace_dump_all(value[2],
12878 QDF_TRACE_DEFAULT_PDEV_ID);
Nirav Shah0d58a7e2016-04-26 22:54:12 +053012879 else if (value[1] == ENABLE_DP_TRACE_LIVE_MODE)
12880 qdf_dp_trace_enable_live_mode();
Nirav Shahda008342016-05-17 18:50:40 +053012881 else if (value[1] == CLEAR_DP_TRACE_BUFFER)
12882 qdf_dp_trace_clear_buffer();
Mohit Khannaf8f96822017-05-17 17:11:59 -070012883 else if (value[1] == DISABLE_DP_TRACE_LIVE_MODE)
12884 qdf_dp_trace_disable_live_mode();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012885 break;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012886 case WE_SET_MON_MODE_CHAN:
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070012887 ret = wlan_hdd_set_mon_chan(adapter, value[1], value[2]);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070012888 break;
Dustin Brown54096432017-02-23 13:00:44 -080012889 case WE_SET_WLAN_SUSPEND: {
Dustin Brown3ed3e9b2017-03-23 12:57:58 -070012890 hdd_info("STA unit-test suspend(%d, %d)", value[1], value[2]);
Dustin Brown54096432017-02-23 13:00:44 -080012891 ret = hdd_wlan_fake_apps_suspend(hdd_ctx->wiphy, dev,
12892 value[1], value[2]);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012893 break;
Dustin Brown54096432017-02-23 13:00:44 -080012894 }
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012895 case WE_SET_WLAN_RESUME:
Dustin Brownbc81a472016-10-26 16:56:59 -070012896 ret = hdd_wlan_fake_apps_resume(hdd_ctx->wiphy, dev);
Rajeev Kumara78a0a42016-07-13 19:28:20 -070012897 break;
Dustin Brown8d2d0f52017-04-03 17:02:08 -070012898 case WE_LOG_BUFFER: {
12899 int log_id = value[1];
12900 uint32_t count = value[2] < 0 ? 0 : value[2];
12901
12902 hdd_ioctl_log_buffer(log_id, count);
12903
12904 break;
12905 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012906 default:
Jeff Johnson99bac312016-06-28 10:38:18 -070012907 hdd_err("Invalid IOCTL command %d", sub_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012908 break;
12909 }
12910
12911 return ret;
12912}
12913
12914static int iw_set_two_ints_getnone(struct net_device *dev,
12915 struct iw_request_info *info,
12916 union iwreq_data *wrqu, char *extra)
12917{
12918 int ret;
12919
12920 cds_ssr_protect(__func__);
12921 ret = __iw_set_two_ints_getnone(dev, info, wrqu, extra);
12922 cds_ssr_unprotect(__func__);
12923
12924 return ret;
12925}
12926
12927/* Define the Wireless Extensions to the Linux Network Device structure */
12928/* A number of these routines are NULL (meaning they are not implemented.) */
12929
12930static const iw_handler we_handler[] = {
12931 (iw_handler) iw_set_commit, /* SIOCSIWCOMMIT */
12932 (iw_handler) iw_get_name, /* SIOCGIWNAME */
12933 (iw_handler) NULL, /* SIOCSIWNWID */
12934 (iw_handler) NULL, /* SIOCGIWNWID */
12935 (iw_handler) iw_set_freq, /* SIOCSIWFREQ */
12936 (iw_handler) iw_get_freq, /* SIOCGIWFREQ */
12937 (iw_handler) iw_set_mode, /* SIOCSIWMODE */
12938 (iw_handler) iw_get_mode, /* SIOCGIWMODE */
12939 (iw_handler) NULL, /* SIOCSIWSENS */
12940 (iw_handler) NULL, /* SIOCGIWSENS */
12941 (iw_handler) NULL, /* SIOCSIWRANGE */
12942 (iw_handler) iw_get_range, /* SIOCGIWRANGE */
12943 (iw_handler) NULL, /* SIOCSIWPRIV */
12944 (iw_handler) NULL, /* SIOCGIWPRIV */
12945 (iw_handler) NULL, /* SIOCSIWSTATS */
12946 (iw_handler) NULL, /* SIOCGIWSTATS */
12947 (iw_handler) NULL, /* SIOCSIWSPY */
12948 (iw_handler) NULL, /* SIOCGIWSPY */
12949 (iw_handler) NULL, /* SIOCSIWTHRSPY */
12950 (iw_handler) NULL, /* SIOCGIWTHRSPY */
12951 (iw_handler) iw_set_ap_address, /* SIOCSIWAP */
12952 (iw_handler) iw_get_ap_address, /* SIOCGIWAP */
12953 (iw_handler) iw_set_mlme, /* SIOCSIWMLME */
12954 (iw_handler) NULL, /* SIOCGIWAPLIST */
Sandeep Puligillad0004212017-02-26 18:34:56 -080012955 (iw_handler) NULL, /* SIOCSIWSCAN */
12956 (iw_handler) NULL, /* SIOCGIWSCAN */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012957 (iw_handler) iw_set_essid, /* SIOCSIWESSID */
12958 (iw_handler) iw_get_essid, /* SIOCGIWESSID */
12959 (iw_handler) iw_set_nick, /* SIOCSIWNICKN */
12960 (iw_handler) iw_get_nick, /* SIOCGIWNICKN */
12961 (iw_handler) NULL, /* -- hole -- */
12962 (iw_handler) NULL, /* -- hole -- */
12963 (iw_handler) iw_set_bitrate, /* SIOCSIWRATE */
12964 (iw_handler) iw_get_bitrate, /* SIOCGIWRATE */
12965 (iw_handler) iw_set_rts_threshold, /* SIOCSIWRTS */
12966 (iw_handler) iw_get_rts_threshold, /* SIOCGIWRTS */
12967 (iw_handler) iw_set_frag_threshold, /* SIOCSIWFRAG */
12968 (iw_handler) iw_get_frag_threshold, /* SIOCGIWFRAG */
12969 (iw_handler) iw_set_tx_power, /* SIOCSIWTXPOW */
12970 (iw_handler) iw_get_tx_power, /* SIOCGIWTXPOW */
12971 (iw_handler) iw_set_retry, /* SIOCSIWRETRY */
12972 (iw_handler) iw_get_retry, /* SIOCGIWRETRY */
12973 (iw_handler) iw_set_encode, /* SIOCSIWENCODE */
12974 (iw_handler) iw_get_encode, /* SIOCGIWENCODE */
12975 (iw_handler) iw_set_power_mode, /* SIOCSIWPOWER */
12976 (iw_handler) iw_get_power_mode, /* SIOCGIWPOWER */
12977 (iw_handler) NULL, /* -- hole -- */
12978 (iw_handler) NULL, /* -- hole -- */
12979 (iw_handler) iw_set_genie, /* SIOCSIWGENIE */
12980 (iw_handler) iw_get_genie, /* SIOCGIWGENIE */
12981 (iw_handler) iw_set_auth, /* SIOCSIWAUTH */
Jeff Johnson4139b822017-10-15 10:55:03 -070012982 (iw_handler) NULL, /* SIOCGIWAUTH */
Jeff Johnson5b300822017-10-15 10:44:40 -070012983 (iw_handler) NULL, /* SIOCSIWENCODEEXT */
Jeff Johnson6b747052017-10-15 10:29:04 -070012984 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012985 (iw_handler) NULL, /* SIOCSIWPMKSA */
12986};
12987
12988static const iw_handler we_private[] = {
12989
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012990 [WLAN_PRIV_SET_INT_GET_NONE - SIOCIWFIRSTPRIV] = iw_setint_getnone,
12991 [WLAN_PRIV_SET_NONE_GET_INT - SIOCIWFIRSTPRIV] = iw_setnone_getint,
12992 [WLAN_PRIV_SET_CHAR_GET_NONE - SIOCIWFIRSTPRIV] = iw_setchar_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012993 [WLAN_PRIV_SET_THREE_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12994 iw_set_three_ints_getnone,
12995 [WLAN_PRIV_GET_CHAR_SET_NONE - SIOCIWFIRSTPRIV] = iw_get_char_setnone,
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070012996 [WLAN_PRIV_SET_NONE_GET_NONE - SIOCIWFIRSTPRIV] = iw_setnone_getnone,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012997 [WLAN_PRIV_SET_VAR_INT_GET_NONE - SIOCIWFIRSTPRIV] =
12998 iw_hdd_set_var_ints_getnone,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070012999 [WLAN_PRIV_SET_NONE_GET_THREE_INT - SIOCIWFIRSTPRIV] =
13000 iw_setnone_get_threeint,
Jeff Johnson6fa1e012017-04-05 06:40:53 -070013001 [WLAN_PRIV_FIPS_TEST - SIOCIWFIRSTPRIV] = hdd_fips_test,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013002 [WLAN_PRIV_ADD_TSPEC - SIOCIWFIRSTPRIV] = iw_add_tspec,
13003 [WLAN_PRIV_DEL_TSPEC - SIOCIWFIRSTPRIV] = iw_del_tspec,
13004 [WLAN_PRIV_GET_TSPEC - SIOCIWFIRSTPRIV] = iw_get_tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013005 [WLAN_PRIV_SET_FTIES - SIOCIWFIRSTPRIV] = iw_set_fties,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013006 [WLAN_PRIV_SET_HOST_OFFLOAD - SIOCIWFIRSTPRIV] = iw_set_host_offload,
13007 [WLAN_GET_WLAN_STATISTICS - SIOCIWFIRSTPRIV] = iw_get_statistics,
13008 [WLAN_SET_KEEPALIVE_PARAMS - SIOCIWFIRSTPRIV] =
13009 iw_set_keepalive_params,
13010#ifdef WLAN_FEATURE_PACKET_FILTERING
13011 [WLAN_SET_PACKET_FILTER_PARAMS - SIOCIWFIRSTPRIV] =
13012 iw_set_packet_filter_params,
13013#endif
13014#ifdef FEATURE_WLAN_SCAN_PNO
13015 [WLAN_SET_PNO - SIOCIWFIRSTPRIV] = iw_set_pno,
13016#endif
13017 [WLAN_SET_BAND_CONFIG - SIOCIWFIRSTPRIV] = iw_set_band_config,
Dustin Brown0cbc7572016-12-16 13:54:40 -080013018 [WLAN_PRIV_SET_MCBC_FILTER - SIOCIWFIRSTPRIV] =
13019 iw_set_dynamic_mcbc_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013020 [WLAN_GET_LINK_SPEED - SIOCIWFIRSTPRIV] = iw_get_linkspeed,
13021 [WLAN_PRIV_SET_TWO_INT_GET_NONE - SIOCIWFIRSTPRIV] =
13022 iw_set_two_ints_getnone,
13023 [WLAN_SET_DOT11P_CHANNEL_SCHED - SIOCIWFIRSTPRIV] =
13024 iw_set_dot11p_channel_sched,
13025};
13026
13027/*Maximum command length can be only 15 */
13028static const struct iw_priv_args we_private_args[] = {
13029
13030 /* handlers for main ioctl */
13031 {WLAN_PRIV_SET_INT_GET_NONE,
13032 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13033 0,
13034 ""},
13035
13036 /* handlers for sub-ioctl */
13037 {WE_SET_11D_STATE,
13038 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13039 0,
13040 "set11Dstate"},
13041
13042 {WE_WOWL,
13043 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13044 0,
13045 "wowl"},
13046
13047 {WE_SET_POWER,
13048 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13049 0,
13050 "setPower"},
13051
13052 {WE_SET_MAX_ASSOC,
13053 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13054 0,
13055 "setMaxAssoc"},
13056
13057 {WE_SET_SAP_AUTO_CHANNEL_SELECTION,
13058 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
13059 "setAutoChannel" },
13060
13061 {WE_SET_SCAN_DISABLE,
13062 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13063 0,
13064 "scan_disable"},
13065
13066 {WE_SET_DATA_INACTIVITY_TO,
13067 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13068 0,
13069 "inactivityTO"},
13070
Mukul Sharmaed92f2f2017-04-20 00:06:28 +053013071 {WE_SET_WOW_DATA_INACTIVITY_TO,
13072 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13073 0,
13074 "wow_ito"},
13075
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013076 {WE_SET_MAX_TX_POWER,
13077 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13078 0,
13079 "setMaxTxPower"},
13080
13081 {WE_SET_TX_POWER,
13082 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13083 0,
13084 "setTxPower"},
13085
13086 {WE_SET_MC_RATE,
13087 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13088 0,
13089 "setMcRate"},
13090
13091 {WE_SET_MAX_TX_POWER_2_4,
13092 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13093 0,
13094 "setTxMaxPower2G"},
13095
13096 {WE_SET_MAX_TX_POWER_5_0,
13097 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13098 0,
13099 "setTxMaxPower5G"},
13100
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080013101 {WE_SET_PKTLOG,
Poddar, Siddarth176c4362016-10-03 12:25:00 +053013102 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080013103 0,
13104 "pktlog"},
13105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013106 /* SAP has TxMax whereas STA has MaxTx, adding TxMax for STA
13107 * as well to keep same syntax as in SAP. Now onwards, STA
Jeff Johnson3bb7c732017-01-12 08:40:17 -080013108 * will support both
13109 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013110 {WE_SET_MAX_TX_POWER,
13111 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13112 0,
13113 "setTxMaxPower"},
13114
13115 /* set Higher DTIM Transition (DTIM1 to DTIM3)
Jeff Johnson3bb7c732017-01-12 08:40:17 -080013116 * 1 = enable and 0 = disable
13117 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013118 {
13119 WE_SET_HIGHER_DTIM_TRANSITION,
13120 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13121 0,
13122 "setHDtimTransn"
13123 },
13124
13125 {WE_SET_TM_LEVEL,
13126 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13127 0,
13128 "setTmLevel"},
13129
13130 {WE_SET_PHYMODE,
13131 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13132 0,
13133 "setphymode"},
13134
13135 {WE_SET_NSS,
13136 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13137 0,
13138 "nss"},
13139
13140 {WE_SET_LDPC,
13141 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13142 0,
13143 "ldpc"},
13144
13145 {WE_SET_TX_STBC,
13146 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13147 0,
13148 "tx_stbc"},
13149
13150 {WE_SET_RX_STBC,
13151 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13152 0,
13153 "rx_stbc"},
13154
13155 {WE_SET_SHORT_GI,
13156 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13157 0,
13158 "shortgi"},
13159
13160 {WE_SET_RTSCTS,
13161 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13162 0,
13163 "enablertscts"},
13164
13165 {WE_SET_CHWIDTH,
13166 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13167 0,
13168 "chwidth"},
13169
13170 {WE_SET_ANI_EN_DIS,
13171 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13172 0,
13173 "anienable"},
13174
13175 {WE_SET_ANI_POLL_PERIOD,
13176 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13177 0,
13178 "aniplen"},
13179
13180 {WE_SET_ANI_LISTEN_PERIOD,
13181 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13182 0,
13183 "anilislen"},
13184
13185 {WE_SET_ANI_OFDM_LEVEL,
13186 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13187 0,
13188 "aniofdmlvl"},
13189
13190 {WE_SET_ANI_CCK_LEVEL,
13191 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13192 0,
13193 "aniccklvl"},
13194
13195 {WE_SET_DYNAMIC_BW,
13196 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13197 0,
13198 "cwmenable"},
13199
13200 {WE_SET_CTS_CBW,
13201 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13202 0,
13203 "cts_cbw" },
13204
13205 {WE_SET_GTX_HT_MCS,
13206 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13207 0,
13208 "gtxHTMcs"},
13209
13210 {WE_SET_GTX_VHT_MCS,
13211 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13212 0,
13213 "gtxVHTMcs"},
13214
13215 {WE_SET_GTX_USRCFG,
13216 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13217 0,
13218 "gtxUsrCfg"},
13219
13220 {WE_SET_GTX_THRE,
13221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13222 0,
13223 "gtxThre"},
13224
13225 {WE_SET_GTX_MARGIN,
13226 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13227 0,
13228 "gtxMargin"},
13229
13230 {WE_SET_GTX_STEP,
13231 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13232 0,
13233 "gtxStep"},
13234
13235 {WE_SET_GTX_MINTPC,
13236 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13237 0,
13238 "gtxMinTpc"},
13239
13240 {WE_SET_GTX_BWMASK,
13241 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13242 0,
13243 "gtxBWMask"},
13244
13245 {WE_SET_TX_CHAINMASK,
13246 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13247 0,
13248 "txchainmask"},
13249
13250 {WE_SET_RX_CHAINMASK,
13251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13252 0,
13253 "rxchainmask"},
13254
13255 {WE_SET_11N_RATE,
13256 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13257 0,
13258 "set11NRates"},
13259
13260 {WE_SET_VHT_RATE,
13261 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13262 0,
13263 "set11ACRates"},
13264
13265 {WE_SET_AMPDU,
13266 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13267 0,
13268 "ampdu"},
13269
13270 {WE_SET_AMSDU,
13271 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13272 0,
13273 "amsdu"},
13274
13275 {WE_SET_BURST_ENABLE,
13276 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13277 0,
13278 "burst_enable"},
13279
13280 {WE_SET_BURST_DUR,
13281 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13282 0,
13283 "burst_dur"},
13284
13285 {WE_SET_TXPOW_2G,
13286 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13287 0,
13288 "txpow2g"},
13289
13290 {WE_SET_TXPOW_5G,
13291 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13292 0,
13293 "txpow5g"},
13294
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013295 /* Sub-cmds DBGLOG specific commands */
13296 {WE_DBGLOG_LOG_LEVEL,
13297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13298 0,
13299 "dl_loglevel"},
13300
13301 {WE_DBGLOG_VAP_ENABLE,
13302 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13303 0,
13304 "dl_vapon"},
13305
13306 {WE_DBGLOG_VAP_DISABLE,
13307 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13308 0,
13309 "dl_vapoff"},
13310
13311 {WE_DBGLOG_MODULE_ENABLE,
13312 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13313 0,
13314 "dl_modon"},
13315
13316 {WE_DBGLOG_MODULE_DISABLE,
13317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13318 0,
13319 "dl_modoff"},
13320
13321 {WE_DBGLOG_MOD_LOG_LEVEL,
13322 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13323 0,
13324 "dl_mod_loglevel"},
13325
13326 {WE_DBGLOG_TYPE,
13327 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13328 0,
13329 "dl_type"},
13330 {WE_DBGLOG_REPORT_ENABLE,
13331 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13332 0,
13333 "dl_report"},
13334
13335 {WE_SET_TXRX_FWSTATS,
13336 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13337 0,
13338 "txrx_fw_stats"},
13339
Venkata Sharath Chandra Manchala83985632017-02-28 14:16:22 -080013340 {WE_SET_TXRX_STATS,
13341 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13342 0,
13343 "txrx_stats"},
13344
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013345 {WE_TXRX_FWSTATS_RESET,
13346 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13347 0,
13348 "txrx_fw_st_rst"},
13349
13350 {WE_PPS_PAID_MATCH,
13351 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13352 0, "paid_match"},
13353
13354 {WE_PPS_GID_MATCH,
13355 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13356 0, "gid_match"},
13357
13358 {WE_PPS_EARLY_TIM_CLEAR,
13359 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13360 0, "tim_clear"},
13361
13362 {WE_PPS_EARLY_DTIM_CLEAR,
13363 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13364 0, "dtim_clear"},
13365
13366 {WE_PPS_EOF_PAD_DELIM,
13367 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13368 0, "eof_delim"},
13369
13370 {WE_PPS_MACADDR_MISMATCH,
13371 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13372 0, "mac_match"},
13373
13374 {WE_PPS_DELIM_CRC_FAIL,
13375 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13376 0, "delim_fail"},
13377
13378 {WE_PPS_GID_NSTS_ZERO,
13379 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13380 0, "nsts_zero"},
13381
13382 {WE_PPS_RSSI_CHECK,
13383 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13384 0, "rssi_chk"},
13385
13386 {WE_PPS_5G_EBT,
13387 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13388 0, "5g_ebt"},
13389
13390 {WE_SET_HTSMPS,
13391 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13392 0, "htsmps"},
13393
13394 {WE_SET_QPOWER_MAX_PSPOLL_COUNT,
13395 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13396 0, "set_qpspollcnt"},
13397
13398 {WE_SET_QPOWER_MAX_TX_BEFORE_WAKE,
13399 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13400 0, "set_qtxwake"},
13401
13402 {WE_SET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13403 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13404 0, "set_qwakeintv"},
13405
13406 {WE_SET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13407 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13408 0, "set_qnodatapoll"},
13409
13410 /* handlers for MCC time quota and latency sub ioctls */
13411 {WE_MCC_CONFIG_LATENCY,
13412 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13413 0, "setMccLatency"},
13414
13415 {WE_MCC_CONFIG_QUOTA,
13416 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13417 0, "setMccQuota"},
13418
13419 {WE_SET_DEBUG_LOG,
13420 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13421 0, "setDbgLvl"},
13422
13423 /* handlers for early_rx power save */
13424 {WE_SET_EARLY_RX_ADJUST_ENABLE,
13425 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13426 0, "erx_enable"},
13427
13428 {WE_SET_EARLY_RX_TGT_BMISS_NUM,
13429 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13430 0, "erx_bmiss_val"},
13431
13432 {WE_SET_EARLY_RX_BMISS_SAMPLE_CYCLE,
13433 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13434 0, "erx_bmiss_smpl"},
13435
13436 {WE_SET_EARLY_RX_SLOP_STEP,
13437 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13438 0, "erx_slop_step"},
13439
13440 {WE_SET_EARLY_RX_INIT_SLOP,
13441 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13442 0, "erx_init_slop"},
13443
13444 {WE_SET_EARLY_RX_ADJUST_PAUSE,
13445 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13446 0, "erx_adj_pause"},
13447
13448 {WE_SET_EARLY_RX_DRIFT_SAMPLE,
13449 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13450 0, "erx_dri_sample"},
13451
13452 {WE_DUMP_STATS,
13453 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13454 0, "dumpStats"},
13455
13456 {WE_CLEAR_STATS,
13457 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13458 0, "clearStats"},
13459
Govind Singha471e5e2015-10-12 17:11:14 +053013460 {WE_START_FW_PROFILE,
13461 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13462 0, "startProfile"},
13463
Abhishek Singh1bdb1572015-10-16 16:24:19 +053013464 {WE_SET_CHANNEL,
13465 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13466 0, "setChanChange" },
13467
Manishekar Chandrasekaran97e077d2016-03-23 17:10:31 +053013468 {WE_SET_CONC_SYSTEM_PREF,
13469 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13470 0, "setConcSysPref" },
13471
Jeff Johnson011c4502017-10-05 15:25:56 -070013472 {WE_SET_PDEV_RESET,
13473 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13474 0, "pdev_reset" },
13475
SaidiReddy Yenugaa92f8cc2017-03-24 15:15:03 +053013476 {WE_SET_MODULATED_DTIM,
13477 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13478 0, "setModDTIM" },
13479
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013480 {WLAN_PRIV_SET_NONE_GET_INT,
13481 0,
13482 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13483 ""},
13484
13485 /* handlers for sub-ioctl */
13486 {WE_GET_11D_STATE,
13487 0,
13488 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13489 "get11Dstate"},
13490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013491 {WE_GET_WLAN_DBG,
13492 0,
13493 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13494 "getwlandbg"},
13495
13496 {WE_GET_MAX_ASSOC,
13497 0,
13498 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13499 "getMaxAssoc"},
13500
13501 {WE_GET_SAP_AUTO_CHANNEL_SELECTION,
13502 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13503 "getAutoChannel" },
13504
13505 {WE_GET_CONCURRENCY_MODE,
13506 0,
13507 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13508 "getconcurrency"},
13509
13510 {WE_GET_NSS,
13511 0,
13512 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13513 "get_nss"},
13514
13515 {WE_GET_LDPC,
13516 0,
13517 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13518 "get_ldpc"},
13519
13520 {WE_GET_TX_STBC,
13521 0,
13522 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13523 "get_tx_stbc"},
13524
13525 {WE_GET_RX_STBC,
13526 0,
13527 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13528 "get_rx_stbc"},
13529
13530 {WE_GET_SHORT_GI,
13531 0,
13532 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13533 "get_shortgi"},
13534
13535 {WE_GET_RTSCTS,
13536 0,
13537 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13538 "get_rtscts"},
13539
13540 {WE_GET_CHWIDTH,
13541 0,
13542 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13543 "get_chwidth"},
13544
13545 {WE_GET_ANI_EN_DIS,
13546 0,
13547 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13548 "get_anienable"},
13549
13550 {WE_GET_ANI_POLL_PERIOD,
13551 0,
13552 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13553 "get_aniplen"},
13554
13555 {WE_GET_ANI_LISTEN_PERIOD,
13556 0,
13557 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13558 "get_anilislen"},
13559
13560 {WE_GET_ANI_OFDM_LEVEL,
13561 0,
13562 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13563 "get_aniofdmlvl"},
13564
13565 {WE_GET_ANI_CCK_LEVEL,
13566 0,
13567 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13568 "get_aniccklvl"},
13569
13570 {WE_GET_DYNAMIC_BW,
13571 0,
13572 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13573 "get_cwmenable"},
13574
13575 {WE_GET_GTX_HT_MCS,
13576 0,
13577 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13578 "get_gtxHTMcs"},
13579
13580 {WE_GET_GTX_VHT_MCS,
13581 0,
13582 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13583 "get_gtxVHTMcs"},
13584
13585 {WE_GET_GTX_USRCFG,
13586 0,
13587 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13588 "get_gtxUsrCfg"},
13589
13590 {WE_GET_GTX_THRE,
13591 0,
13592 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13593 "get_gtxThre"},
13594
13595 {WE_GET_GTX_MARGIN,
13596 0,
13597 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13598 "get_gtxMargin"},
13599
13600 {WE_GET_GTX_STEP,
13601 0,
13602 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13603 "get_gtxStep"},
13604
13605 {WE_GET_GTX_MINTPC,
13606 0,
13607 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13608 "get_gtxMinTpc"},
13609
13610 {WE_GET_GTX_BWMASK,
13611 0,
13612 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13613 "get_gtxBWMask"},
13614
13615 {WE_GET_TX_CHAINMASK,
13616 0,
13617 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13618 "get_txchainmask"},
13619
13620 {WE_GET_RX_CHAINMASK,
13621 0,
13622 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13623 "get_rxchainmask"},
13624
13625 {WE_GET_11N_RATE,
13626 0,
13627 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13628 "get_11nrate"},
13629
13630 {WE_GET_AMPDU,
13631 0,
13632 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13633 "get_ampdu"},
13634
13635 {WE_GET_AMSDU,
13636 0,
13637 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13638 "get_amsdu"},
13639
13640 {WE_GET_BURST_ENABLE,
13641 0,
13642 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13643 "get_burst_en"},
13644
13645 {WE_GET_BURST_DUR,
13646 0,
13647 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13648 "get_burst_dur"},
13649
13650 {WE_GET_TXPOW_2G,
13651 0,
13652 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13653 "get_txpow2g"},
13654
13655 {WE_GET_TXPOW_5G,
13656 0,
13657 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13658 "get_txpow5g"},
13659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013660 {WE_GET_PPS_PAID_MATCH,
13661 0,
13662 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13663 "get_paid_match"},
13664
13665 {WE_GET_PPS_GID_MATCH,
13666 0,
13667 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13668 "get_gid_match"},
13669
13670 {WE_GET_PPS_EARLY_TIM_CLEAR,
13671 0,
13672 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13673 "get_tim_clear"},
13674
13675 {WE_GET_PPS_EARLY_DTIM_CLEAR,
13676 0,
13677 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13678 "get_dtim_clear"},
13679
13680 {WE_GET_PPS_EOF_PAD_DELIM,
13681 0,
13682 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13683 "get_eof_delim"},
13684
13685 {WE_GET_PPS_MACADDR_MISMATCH,
13686 0,
13687 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13688 "get_mac_match"},
13689
13690 {WE_GET_PPS_DELIM_CRC_FAIL,
13691 0,
13692 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13693 "get_delim_fail"},
13694
13695 {WE_GET_PPS_GID_NSTS_ZERO,
13696 0,
13697 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13698 "get_nsts_zero"},
13699
13700 {WE_GET_PPS_RSSI_CHECK,
13701 0,
13702 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13703 "get_rssi_chk"},
13704
13705 {WE_GET_QPOWER_MAX_PSPOLL_COUNT,
13706 0,
13707 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13708 "get_qpspollcnt"},
13709
13710 {WE_GET_QPOWER_MAX_TX_BEFORE_WAKE,
13711 0,
13712 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13713 "get_qtxwake"},
13714
13715 {WE_GET_QPOWER_SPEC_PSPOLL_WAKE_INTERVAL,
13716 0,
13717 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13718 "get_qwakeintv"},
13719
13720 {WE_GET_QPOWER_SPEC_MAX_SPEC_NODATA_PSPOLL,
13721 0,
13722 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13723 "get_qnodatapoll"},
13724
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013725 {WE_CAP_TSF,
13726 0,
13727 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13728 "cap_tsf"},
13729
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013730 {WE_GET_TEMPERATURE,
13731 0,
13732 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13733 "get_temp"},
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070013734 {WE_GET_DCM,
13735 0,
13736 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13737 "get_dcm"},
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070013738 {WE_GET_RANGE_EXT,
13739 0,
13740 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
13741 "get_range_ext"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013742 /* handlers for main ioctl */
13743 {WLAN_PRIV_SET_CHAR_GET_NONE,
13744 IW_PRIV_TYPE_CHAR | 512,
13745 0,
13746 ""},
13747
13748 /* handlers for sub-ioctl */
13749 {WE_WOWL_ADD_PTRN,
13750 IW_PRIV_TYPE_CHAR | 512,
13751 0,
13752 "wowlAddPtrn"},
13753
13754 {WE_WOWL_DEL_PTRN,
13755 IW_PRIV_TYPE_CHAR | 512,
13756 0,
13757 "wowlDelPtrn"},
13758
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013759 /* handlers for sub-ioctl */
13760 {WE_NEIGHBOR_REPORT_REQUEST,
13761 IW_PRIV_TYPE_CHAR | 512,
13762 0,
13763 "neighbor"},
Deepak Dhamdhere641bf322016-01-06 15:19:03 -080013764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013765 {WE_SET_AP_WPS_IE,
13766 IW_PRIV_TYPE_CHAR | 512,
13767 0,
13768 "set_ap_wps_ie"},
13769
13770 {WE_SET_CONFIG,
13771 IW_PRIV_TYPE_CHAR | 512,
13772 0,
13773 "setConfig"},
13774
13775 /* handlers for main ioctl */
13776 {WLAN_PRIV_SET_THREE_INT_GET_NONE,
13777 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13778 0,
13779 ""},
13780
13781 /* handlers for sub-ioctl */
13782 {WE_SET_WLAN_DBG,
13783 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13784 0,
13785 "setwlandbg"},
13786
13787 /* handlers for sub-ioctl */
13788 {WE_SET_DP_TRACE,
13789 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13790 0,
13791 "set_dp_trace"},
13792
13793 {WE_SET_SAP_CHANNELS,
13794 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13795 0,
13796 "setsapchannels"},
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013797
13798 {WE_SET_FW_TEST,
13799 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13800 0, "fw_test"},
13801
Manikandan Mohandcc21ba2016-03-15 14:31:56 -070013802 /* handlers for main ioctl */
13803 {WLAN_PRIV_SET_NONE_GET_THREE_INT,
13804 0,
13805 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13806 "" },
13807 {WE_GET_TSF,
13808 0,
13809 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13810 "get_tsf" },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013811
13812 {WE_SET_DUAL_MAC_SCAN_CONFIG,
13813 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3,
13814 0,
13815 "set_scan_cfg"},
13816
13817 /* handlers for main ioctl */
13818 {WLAN_PRIV_GET_CHAR_SET_NONE,
13819 0,
13820 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13821 ""},
13822
13823 /* handlers for sub-ioctl */
13824 {WE_WLAN_VERSION,
13825 0,
13826 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13827 "version"},
13828 {WE_GET_STATS,
13829 0,
13830 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13831 "getStats"},
Dustin Brownd9322482017-01-09 12:46:03 -080013832 {WE_GET_SUSPEND_RESUME_STATS,
13833 0,
13834 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13835 "getSuspendStats"},
Govind Singha471e5e2015-10-12 17:11:14 +053013836 {WE_LIST_FW_PROFILE,
13837 0,
13838 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13839 "listProfile"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013840 {WE_GET_STATES,
13841 0,
13842 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13843 "getHostStates"},
13844 {WE_GET_CFG,
13845 0,
13846 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13847 "getConfig"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013848 {WE_GET_RSSI,
13849 0,
13850 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13851 "getRSSI"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013852 {WE_GET_WMM_STATUS,
13853 0,
13854 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13855 "getWmmStatus"},
13856 {
13857 WE_GET_CHANNEL_LIST,
13858 0,
13859 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13860 "getChannelList"
13861 },
13862#ifdef FEATURE_WLAN_TDLS
13863 {
13864 WE_GET_TDLS_PEERS,
13865 0,
13866 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13867 "getTdlsPeers"
13868 },
13869#endif
13870#ifdef WLAN_FEATURE_11W
13871 {
13872 WE_GET_11W_INFO,
13873 0,
13874 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13875 "getPMFInfo"
13876 },
13877#endif
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013878 {
13879 WE_GET_IBSS_STA_INFO,
13880 0,
13881 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13882 "getIbssSTAs"
13883 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013884 {WE_GET_PHYMODE,
13885 0,
13886 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13887 "getphymode"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013888#if defined(FEATURE_OEM_DATA_SUPPORT) || defined(WIFI_POS_CONVERGED)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013889 {WE_GET_OEM_DATA_CAP,
13890 0,
13891 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13892 "getOemDataCap"},
Naveen Rawat910726a2017-03-06 11:42:51 -080013893#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013894 {WE_GET_SNR,
13895 0,
13896 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
13897 "getSNR"},
13898
13899 /* handlers for main ioctl */
13900 {WLAN_PRIV_SET_NONE_GET_NONE,
13901 0,
13902 0,
13903 ""},
13904
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013905 /* handlers for sub-ioctl */
13906 {
13907 WE_IBSS_GET_PEER_INFO_ALL,
13908 0,
13909 0,
13910 "ibssPeerInfoAll"
13911 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013912 {WE_GET_RECOVERY_STAT,
13913 0,
13914 0,
13915 "getRecoverStat"},
Govind Singha471e5e2015-10-12 17:11:14 +053013916
13917 {WE_GET_FW_PROFILE_DATA,
13918 0,
13919 0,
13920 "getProfileData"},
13921
13922 {WE_SET_REASSOC_TRIGGER,
13923 0,
13924 0,
13925 "reassoc"},
13926
Sandeep Puligilla93a29ec2016-02-12 16:10:56 -080013927 {WE_STOP_OBSS_SCAN,
13928 0,
13929 0,
13930 "stop_obss_scan"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013931 /* handlers for main ioctl */
13932 {WLAN_PRIV_SET_VAR_INT_GET_NONE,
13933 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13934 0,
13935 ""},
13936
13937 /* handlers for sub-ioctl */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080013938 {WE_IBSS_GET_PEER_INFO,
13939 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13940 0,
13941 "ibssPeerInfo"},
13942
13943 /* handlers for sub-ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013944 {WE_MTRACE_SELECTIVE_MODULE_LOG_ENABLE_CMD,
13945 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13946 0,
13947 "setdumplog"},
13948
13949 {WE_MTRACE_DUMP_CMD,
13950 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13951 0,
13952 "dumplog"},
Krunal Sonia6e505b2017-01-12 12:25:18 -080013953
13954 {WE_POLICY_MANAGER_CINFO_CMD,
13955 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13956 0,
13957 "pm_cinfo"},
13958
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013959#ifdef MPC_UT_FRAMEWORK
13960 {WE_POLICY_MANAGER_CLIST_CMD,
13961 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13962 0,
13963 "pm_clist"},
13964
13965 {WE_POLICY_MANAGER_DLIST_CMD,
13966 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13967 0,
13968 "pm_dlist"},
13969
13970 {WE_POLICY_MANAGER_DBS_CMD,
13971 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13972 0,
13973 "pm_dbs"},
13974
13975 {WE_POLICY_MANAGER_PCL_CMD,
13976 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13977 0,
13978 "pm_pcl"},
13979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013980 {WE_POLICY_MANAGER_ULIST_CMD,
13981 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13982 0,
13983 "pm_ulist"},
13984
13985 {WE_POLICY_MANAGER_QUERY_ACTION_CMD,
13986 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13987 0,
13988 "pm_query_action"},
13989
13990 {WE_POLICY_MANAGER_QUERY_ALLOW_CMD,
13991 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13992 0,
13993 "pm_query_allow"},
13994
13995 {WE_POLICY_MANAGER_SCENARIO_CMD,
13996 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
13997 0,
13998 "pm_run_scenario"},
13999
14000 {WE_POLICY_SET_HW_MODE_CMD,
14001 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14002 0,
14003 "pm_set_hw_mode"},
14004#endif
14005#ifdef FEATURE_WLAN_TDLS
14006 /* handlers for sub ioctl */
14007 {
14008 WE_TDLS_CONFIG_PARAMS,
14009 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14010 0,
14011 "setTdlsConfig"
14012 },
14013#endif
14014 {
14015 WE_UNIT_TEST_CMD,
14016 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14017 0,
14018 "setUnitTestCmd"
14019 },
Manjeet Singhf82ed072016-07-08 11:40:00 +053014020 {
14021 WE_MAC_PWR_DEBUG_CMD,
14022 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14023 0,
14024 "halPwrDebug"
14025 },
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014026
14027#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
14028 {WE_LED_FLASHING_PARAM,
14029 IW_PRIV_TYPE_INT | MAX_VAR_ARGS,
14030 0,
14031 "gpio_control"},
14032#endif
14033 /* handlers for main ioctl */
Jeff Johnson6fa1e012017-04-05 06:40:53 -070014034 {WLAN_PRIV_FIPS_TEST,
14035 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
14036 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
14037 "fips_test"},
14038
14039 /* handlers for main ioctl */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014040 {WLAN_PRIV_ADD_TSPEC,
14041 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | HDD_WLAN_WMM_PARAM_COUNT,
14042 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14043 "addTspec"},
14044
14045 /* handlers for main ioctl */
14046 {WLAN_PRIV_DEL_TSPEC,
14047 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14048 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14049 "delTspec"},
14050
14051 /* handlers for main ioctl */
14052 {WLAN_PRIV_GET_TSPEC,
14053 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14054 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14055 "getTspec"},
14056
14057 /* handlers for main ioctl - host offload */
14058 {
14059 WLAN_PRIV_SET_HOST_OFFLOAD,
Srinivas Girigowda077143e2017-03-25 10:47:27 -070014060 IW_PRIV_TYPE_BYTE | sizeof(struct host_offload_req),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014061 0,
14062 "setHostOffload"
14063 }
14064 ,
14065
14066 {
14067 WLAN_GET_WLAN_STATISTICS,
14068 0,
14069 IW_PRIV_TYPE_BYTE | WE_MAX_STR_LEN,
14070 "getWlanStats"
14071 }
14072 ,
14073
14074 {
14075 WLAN_SET_KEEPALIVE_PARAMS,
Mahesh A Saptasagar72d2e4b2016-04-20 12:44:17 +053014076 IW_PRIV_TYPE_BYTE | sizeof(tSirKeepAliveReq) |
14077 IW_PRIV_SIZE_FIXED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014078 0,
14079 "setKeepAlive"
14080 }
14081 ,
14082#ifdef WLAN_FEATURE_PACKET_FILTERING
14083 {
14084 WLAN_SET_PACKET_FILTER_PARAMS,
Hanumanth Reddy Pothulab3ef4162016-10-25 15:13:26 +053014085 IW_PRIV_TYPE_BYTE |
14086 sizeof(struct pkt_filter_cfg),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014087 0,
14088 "setPktFilter"
14089 }
14090 ,
14091#endif
14092#ifdef FEATURE_WLAN_SCAN_PNO
14093 {
14094 WLAN_SET_PNO,
14095 IW_PRIV_TYPE_CHAR | WE_MAX_STR_LEN,
14096 0,
14097 "setpno"
14098 }
14099 ,
14100#endif
14101 {
14102 WLAN_SET_BAND_CONFIG,
14103 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14104 0,
14105 "SETBAND"
14106 }
14107 ,
14108 {
Dustin Brown0cbc7572016-12-16 13:54:40 -080014109 WLAN_PRIV_SET_MCBC_FILTER,
Dustin Brown860566f2017-01-31 15:24:43 -080014110 0,
Dustin Brown0cbc7572016-12-16 13:54:40 -080014111 0,
14112 "setMCBCFilter"
14113 }
14114 ,
Dustin Brown0cbc7572016-12-16 13:54:40 -080014115
14116 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014117 WLAN_GET_LINK_SPEED,
14118 IW_PRIV_TYPE_CHAR | 18,
14119 IW_PRIV_TYPE_CHAR | 5, "getLinkSpeed"
14120 }
14121 ,
14122
14123 /* handlers for main ioctl */
14124 {WLAN_PRIV_SET_TWO_INT_GET_NONE,
14125 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14126 0,
14127 ""}
14128 ,
14129 {WE_SET_SMPS_PARAM,
14130 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14131 0, "set_smps_param"}
14132 ,
14133 {WLAN_SET_DOT11P_CHANNEL_SCHED,
14134 IW_PRIV_TYPE_BYTE | sizeof(struct dot11p_channel_sched),
14135 0, "set_dot11p" }
14136 ,
Srinivas Girigowda6147c582016-10-18 12:26:15 -070014137#ifdef WLAN_DEBUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014138 {WE_SET_FW_CRASH_INJECT,
14139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14140 0, "crash_inject"}
14141 ,
Dustin Brown8d2d0f52017-04-03 17:02:08 -070014142 {WE_LOG_BUFFER,
14143 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14144 0, "log_buffer"}
14145 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014146#endif
Rajeev Kumara78a0a42016-07-13 19:28:20 -070014147#ifdef WLAN_SUSPEND_RESUME_TEST
14148 {WE_SET_WLAN_SUSPEND,
14149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14150 0, "wlan_suspend"}
14151 ,
14152 {WE_SET_WLAN_RESUME,
14153 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14154 0, "wlan_resume"}
14155 ,
14156#endif
Govind Singha471e5e2015-10-12 17:11:14 +053014157 {WE_ENABLE_FW_PROFILE,
14158 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14159 0, "enableProfile"}
14160 ,
14161 {WE_SET_FW_PROFILE_HIST_INTVL,
14162 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14163 0, "set_hist_intvl"}
14164 ,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014165 {WE_SET_DUAL_MAC_FW_MODE_CONFIG,
14166 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14167 0, "set_fw_mode_cfg"}
14168 ,
14169 {WE_DUMP_DP_TRACE_LEVEL,
14170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14171 0, "dump_dp_trace"}
14172 ,
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014173 {WE_SET_MON_MODE_CHAN,
14174 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2,
14175 0, "setMonChan"}
14176 ,
Varun Reddy Yeturu5ab47462016-05-08 18:08:11 -070014177
14178 {WE_GET_ROAM_SYNCH_DELAY,
14179 0,
14180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14181 "hostroamdelay"}
14182 ,
Krishna Kumaar Natarajan9e5339d2016-12-05 14:12:13 -080014183 {WE_SET_11AX_RATE,
14184 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14185 0,
14186 "set_11ax_rate"}
14187 ,
Krishna Kumaar Natarajan1a71ec72017-03-23 12:26:31 -070014188 {WE_SET_DCM,
14189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14190 0,
14191 "enable_dcm"}
14192 ,
Krishna Kumaar Natarajan150cd012017-03-23 12:29:10 -070014193 {WE_SET_RANGE_EXT,
14194 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
14195 0,
14196 "enable_range_ext"}
14197 ,
Naveen Rawatc921c7b2017-06-13 17:29:51 -070014198
14199 {WLAN_PRIV_SET_FTIES,
14200 IW_PRIV_TYPE_CHAR | MAX_FTIE_SIZE,
14201 0,
14202 "set_ft_ies"},
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014203};
14204
14205const struct iw_handler_def we_handler_def = {
Anurag Chouhan6d760662016-02-20 16:05:43 +053014206 .num_standard = QDF_ARRAY_SIZE(we_handler),
14207 .num_private = QDF_ARRAY_SIZE(we_private),
14208 .num_private_args = QDF_ARRAY_SIZE(we_private_args),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014209
14210 .standard = (iw_handler *) we_handler,
14211 .private = (iw_handler *) we_private,
14212 .private_args = we_private_args,
14213 .get_wireless_stats = NULL,
14214};
14215
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014216/* hdd_set_wext() - configures bss parameters
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070014217 * @adapter: handle to adapter context
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014218 *
14219 * Returns: none
14220 */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070014221static int hdd_set_wext(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014222{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070014223 struct hdd_wext_state *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -070014224 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014225
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014226 ENTER();
14227
14228 if (!pwextBuf) {
14229 hdd_err("ERROR: pwextBuf is NULL");
14230 return QDF_STATUS_E_FAILURE;
14231 }
14232
Jeff Johnsond377dce2017-10-04 10:32:42 -070014233 if (!sta_ctx) {
14234 hdd_err("ERROR: sta_ctx is NULL");
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014235 return QDF_STATUS_E_FAILURE;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070014236 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014237
14238 /* Now configure the roaming profile links. To SSID and bssid. */
14239 pwextBuf->roamProfile.SSIDs.numOfSSIDs = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -070014240 pwextBuf->roamProfile.SSIDs.SSIDList = &sta_ctx->conn_info.SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014241
14242 pwextBuf->roamProfile.BSSIDs.numOfBSSIDs = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -070014243 pwextBuf->roamProfile.BSSIDs.bssid = &sta_ctx->conn_info.bssId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014244
14245 /*Set the numOfChannels to zero to scan all the channels */
14246 pwextBuf->roamProfile.ChannelInfo.numOfChannels = 0;
14247 pwextBuf->roamProfile.ChannelInfo.ChannelList = NULL;
14248
14249 /* Default is no encryption */
14250 pwextBuf->roamProfile.EncryptionType.numEntries = 1;
14251 pwextBuf->roamProfile.EncryptionType.encryptionType[0] =
14252 eCSR_ENCRYPT_TYPE_NONE;
14253
14254 pwextBuf->roamProfile.mcEncryptionType.numEntries = 1;
14255 pwextBuf->roamProfile.mcEncryptionType.encryptionType[0] =
14256 eCSR_ENCRYPT_TYPE_NONE;
14257
14258 pwextBuf->roamProfile.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
14259
14260 /* Default is no authentication */
14261 pwextBuf->roamProfile.AuthType.numEntries = 1;
14262 pwextBuf->roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
14263
14264 pwextBuf->roamProfile.phyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnsonce4a8342017-10-14 13:12:22 -070014265 sta_ctx->wpa_versions = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014266
14267 /*Set the default scan mode */
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070014268 adapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014269
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070014270 hdd_clear_roam_profile_ie(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014271
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014272 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014273 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014274
14275}
14276
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014277#ifdef WLAN_FEATURE_FILS_SK
Jeff Johnson2a722002017-09-30 20:02:35 -070014278static void hdd_initialize_fils_info(struct hdd_wext_state *pwextBuf)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014279{
14280 pwextBuf->roamProfile.fils_con_info = NULL;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053014281 pwextBuf->roamProfile.hlp_ie = NULL;
14282 pwextBuf->roamProfile.hlp_ie_len = 0;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014283}
14284#else
Jeff Johnson2a722002017-09-30 20:02:35 -070014285static void hdd_initialize_fils_info(struct hdd_wext_state *pwextBuf)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014286{ }
14287#endif
14288
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070014289/**
14290 * hdd_register_wext() - register wext context
14291 * @dev: net device handle
14292 *
14293 * Registers wext interface context for a given net device
14294 *
14295 * Returns: 0 on success, errno on failure
14296 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014297int hdd_register_wext(struct net_device *dev)
14298{
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070014299 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
14300 struct hdd_wext_state *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Anurag Chouhance0dc992016-02-16 18:18:03 +053014301 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014302
14303 ENTER();
14304
Deepak Dhamdhere8360d4c2016-06-01 13:24:31 -070014305 if (!pwextBuf) {
14306 hdd_err(FL("ERROR: pwextBuf is NULL"));
14307 return QDF_STATUS_E_FAILURE;
14308 }
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -070014309
14310 /* Zero the memory. This zeros the profile structure */
Jeff Johnson2a722002017-09-30 20:02:35 -070014311 memset(pwextBuf, 0, sizeof(struct hdd_wext_state));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014312
Jeff Johnsonf23a89b2017-10-02 13:20:38 -070014313 status = hdd_set_wext(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014314
Anurag Chouhance0dc992016-02-16 18:18:03 +053014315 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070014316 hdd_err("ERROR: hdd_set_wext failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014317 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014318 }
14319
Srinivas Girigowdafba82a02017-03-24 21:26:35 -070014320 status = qdf_event_create(&pwextBuf->hdd_qdf_event);
14321 if (!QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson99bac312016-06-28 10:38:18 -070014322 hdd_err("ERROR: HDD qdf event init failed!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014323 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014324 }
14325
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014326 hdd_initialize_fils_info(pwextBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014327 /* Register as a wireless device */
14328 dev->wireless_handlers = (struct iw_handler_def *)&we_handler_def;
14329
14330 EXIT();
14331 return 0;
14332}
14333
14334int hdd_unregister_wext(struct net_device *dev)
14335{
Jeff Johnson36e74c42017-09-18 08:15:42 -070014336 hdd_debug("dev(%pK)", dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014337
14338 if (dev != NULL) {
14339 rtnl_lock();
14340 dev->wireless_handlers = NULL;
14341 rtnl_unlock();
14342 }
14343
14344 return 0;
14345}