xref: /freebsd/sys/contrib/dev/iwlwifi/iwl-modparams.h (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2005-2014, 2018-2022 Intel Corporation
4  */
5 #ifndef __iwl_modparams_h__
6 #define __iwl_modparams_h__
7 
8 #include <linux/types.h>
9 #include <linux/spinlock.h>
10 #include <linux/gfp.h>
11 #ifdef CONFIG_IWLWIFI_DEBUG
12 #include "iwl-debug.h"
13 #endif
14 
15 extern struct iwl_mod_params iwlwifi_mod_params;
16 
17 enum iwl_power_level {
18 	IWL_POWER_INDEX_1,
19 	IWL_POWER_INDEX_2,
20 	IWL_POWER_INDEX_3,
21 	IWL_POWER_INDEX_4,
22 	IWL_POWER_INDEX_5,
23 	IWL_POWER_NUM
24 };
25 
26 enum iwl_disable_11n {
27 	IWL_DISABLE_HT_ALL	 = BIT(0),
28 	IWL_DISABLE_HT_TXAGG	 = BIT(1),
29 	IWL_DISABLE_HT_RXAGG	 = BIT(2),
30 	IWL_ENABLE_HT_TXAGG	 = BIT(3),
31 };
32 
33 enum iwl_amsdu_size {
34 	IWL_AMSDU_DEF = 0,
35 	IWL_AMSDU_4K = 1,
36 	IWL_AMSDU_8K = 2,
37 	IWL_AMSDU_12K = 3,
38 	/* Add 2K at the end to avoid breaking current API */
39 	IWL_AMSDU_2K = 4,
40 };
41 
42 enum iwl_uapsd_disable {
43 	IWL_DISABLE_UAPSD_BSS		= BIT(0),
44 	IWL_DISABLE_UAPSD_P2P_CLIENT	= BIT(1),
45 };
46 
47 /**
48  * struct iwl_mod_params
49  *
50  * Holds the module parameters
51  *
52  * @swcrypto: using hardware encryption, default = 0
53  * @disable_11n: disable 11n capabilities, default = 0,
54  *	use IWL_[DIS,EN]ABLE_HT_* constants
55  * @amsdu_size: See &enum iwl_amsdu_size.
56  * @fw_restart: restart firmware, default = 1
57  * @bt_coex_active: enable bt coex, default = true
58  * @led_mode: system default, default = 0
59  * @power_save: enable power save, default = false
60  * @power_level: power level, default = 1
61  * @debug_level: levels are IWL_DL_*
62  * @nvm_file: specifies a external NVM file
63  * @uapsd_disable: disable U-APSD, see &enum iwl_uapsd_disable, default =
64  *	IWL_DISABLE_UAPSD_BSS | IWL_DISABLE_UAPSD_P2P_CLIENT
65  * @disable_11ac: disable VHT capabilities, default = false.
66  * @remove_when_gone: remove an inaccessible device from the PCIe bus.
67  * @enable_ini: enable new FW debug infratructure (INI TLVs)
68  */
69 struct iwl_mod_params {
70 	int swcrypto;
71 	unsigned int disable_11n;
72 	int amsdu_size;
73 	bool fw_restart;
74 	bool bt_coex_active;
75 	int led_mode;
76 	bool power_save;
77 	int power_level;
78 #ifdef CONFIG_IWLWIFI_DEBUG
79 #if defined(__linux__)
80 	u32 debug_level;
81 #elif defined(__FreeBSD__)
82 	enum iwl_dl debug_level;
83 #endif
84 #endif
85 	char *nvm_file;
86 	u32 uapsd_disable;
87 	bool disable_11ac;
88 	/**
89 	 * @disable_11ax: disable HE capabilities, default = false
90 	 */
91 	bool disable_11ax;
92 	bool remove_when_gone;
93 	u32 enable_ini;
94 	bool disable_11be;
95 };
96 
97 static inline bool iwl_enable_rx_ampdu(void)
98 {
99 	if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG)
100 		return false;
101 	return true;
102 }
103 
104 static inline bool iwl_enable_tx_ampdu(void)
105 {
106 	if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG)
107 		return false;
108 	if (iwlwifi_mod_params.disable_11n & IWL_ENABLE_HT_TXAGG)
109 		return true;
110 
111 	/* enabled by default */
112 	return true;
113 }
114 
115 #endif /* #__iwl_modparams_h__ */
116