xref: /linux/drivers/net/wireless/intel/iwlwifi/fw/api/power.h (revision 0a7a30fce30e566a462b30994fcf69cea01934ed)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2012-2014, 2018-2025 Intel Corporation
4  * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
5  * Copyright (C) 2015-2017 Intel Deutschland GmbH
6  */
7 #ifndef __iwl_fw_api_power_h__
8 #define __iwl_fw_api_power_h__
9 
10 /* Power Management Commands, Responses, Notifications */
11 
12 /**
13  * enum iwl_ltr_config_flags - masks for LTR config command flags
14  * @LTR_CFG_FLAG_FEATURE_ENABLE: Feature operational status
15  * @LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS: allow LTR change on shadow
16  *	memory access
17  * @LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH: allow LTR msg send on ANY LTR
18  *	reg change
19  * @LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3: allow LTR msg send on transition from
20  *	D0 to D3
21  * @LTR_CFG_FLAG_SW_SET_SHORT: fixed static short LTR register
22  * @LTR_CFG_FLAG_SW_SET_LONG: fixed static short LONG register
23  * @LTR_CFG_FLAG_DENIE_C10_ON_PD: allow going into C10 on PD
24  * @LTR_CFG_FLAG_UPDATE_VALUES: update config values and short
25  *	idle timeout
26  */
27 enum iwl_ltr_config_flags {
28 	LTR_CFG_FLAG_FEATURE_ENABLE = BIT(0),
29 	LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS = BIT(1),
30 	LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH = BIT(2),
31 	LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3 = BIT(3),
32 	LTR_CFG_FLAG_SW_SET_SHORT = BIT(4),
33 	LTR_CFG_FLAG_SW_SET_LONG = BIT(5),
34 	LTR_CFG_FLAG_DENIE_C10_ON_PD = BIT(6),
35 	LTR_CFG_FLAG_UPDATE_VALUES = BIT(7),
36 };
37 
38 /**
39  * struct iwl_ltr_config_cmd_v1 - configures the LTR
40  * @flags: See &enum iwl_ltr_config_flags
41  * @static_long: static LTR Long register value.
42  * @static_short: static LTR Short register value.
43  */
44 struct iwl_ltr_config_cmd_v1 {
45 	__le32 flags;
46 	__le32 static_long;
47 	__le32 static_short;
48 } __packed; /* LTR_CAPABLE_API_S_VER_1 */
49 
50 #define LTR_VALID_STATES_NUM 4
51 
52 /**
53  * struct iwl_ltr_config_cmd - configures the LTR
54  * @flags: See &enum iwl_ltr_config_flags
55  * @static_long: static LTR Long register value.
56  * @static_short: static LTR Short register value.
57  * @ltr_cfg_values: LTR parameters table values (in usec) in following order:
58  *	TX, RX, Short Idle, Long Idle. Used only if %LTR_CFG_FLAG_UPDATE_VALUES
59  *	is set.
60  * @ltr_short_idle_timeout: LTR Short Idle timeout (in usec). Used only if
61  *	%LTR_CFG_FLAG_UPDATE_VALUES is set.
62  */
63 struct iwl_ltr_config_cmd {
64 	__le32 flags;
65 	__le32 static_long;
66 	__le32 static_short;
67 	__le32 ltr_cfg_values[LTR_VALID_STATES_NUM];
68 	__le32 ltr_short_idle_timeout;
69 } __packed; /* LTR_CAPABLE_API_S_VER_2 */
70 
71 /* Radio LP RX Energy Threshold measured in dBm */
72 #define POWER_LPRX_RSSI_THRESHOLD	75
73 #define POWER_LPRX_RSSI_THRESHOLD_MAX	94
74 #define POWER_LPRX_RSSI_THRESHOLD_MIN	30
75 
76 /**
77  * enum iwl_power_flags - masks for power table command flags
78  * @POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
79  *		receiver and transmitter. '0' - does not allow.
80  * @POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management,
81  *		'1' Driver enables PM (use rest of parameters)
82  * @POWER_FLAGS_SKIP_OVER_DTIM_MSK: '0' PM have to walk up every DTIM,
83  *		'1' PM could sleep over DTIM till listen Interval.
84  * @POWER_FLAGS_SNOOZE_ENA_MSK: Enable snoozing only if uAPSD is enabled and all
85  *		access categories are both delivery and trigger enabled.
86  * @POWER_FLAGS_BT_SCO_ENA: Enable BT SCO coex only if uAPSD and
87  *		PBW Snoozing enabled
88  * @POWER_FLAGS_ADVANCE_PM_ENA_MSK: Advanced PM (uAPSD) enable mask
89  * @POWER_FLAGS_LPRX_ENA_MSK: Low Power RX enable.
90  * @POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK: AP/GO's uAPSD misbehaving
91  *		detection enablement
92  * @POWER_FLAGS_ENABLE_SMPS_MSK: SMPS is allowed for this vif
93 */
94 enum iwl_power_flags {
95 	POWER_FLAGS_POWER_SAVE_ENA_MSK		= BIT(0),
96 	POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK	= BIT(1),
97 	POWER_FLAGS_SKIP_OVER_DTIM_MSK		= BIT(2),
98 	POWER_FLAGS_SNOOZE_ENA_MSK		= BIT(5),
99 	POWER_FLAGS_BT_SCO_ENA			= BIT(8),
100 	POWER_FLAGS_ADVANCE_PM_ENA_MSK		= BIT(9),
101 	POWER_FLAGS_LPRX_ENA_MSK		= BIT(11),
102 	POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK	= BIT(12),
103 	POWER_FLAGS_ENABLE_SMPS_MSK		= BIT(14),
104 };
105 
106 #define IWL_POWER_VEC_SIZE 5
107 
108 /**
109  * struct iwl_powertable_cmd - legacy power command. Beside old API support this
110  *	is used also with a new	power API for device wide power settings.
111  * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
112  *
113  * @flags:		Power table command flags from POWER_FLAGS_*
114  * @keep_alive_seconds: Keep alive period in seconds. Default - 25 sec.
115  *			Minimum allowed:- 3 * DTIM. Keep alive period must be
116  *			set regardless of power scheme or current power state.
117  *			FW use this value also when PM is disabled.
118  * @debug_flags:	debug flags
119  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
120  *			PSM transition - legacy PM
121  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
122  *			PSM transition - legacy PM
123  * @sleep_interval:	not in use
124  * @skip_dtim_periods:	Number of DTIM periods to skip if Skip over DTIM flag
125  *			is set. For example, if it is required to skip over
126  *			one DTIM, this value need to be set to 2 (DTIM periods).
127  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
128  *			Default: 80dbm
129  */
130 struct iwl_powertable_cmd {
131 	/* PM_POWER_TABLE_CMD_API_S_VER_6 */
132 	__le16 flags;
133 	u8 keep_alive_seconds;
134 	u8 debug_flags;
135 	__le32 rx_data_timeout;
136 	__le32 tx_data_timeout;
137 	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
138 	__le32 skip_dtim_periods;
139 	__le32 lprx_rssi_threshold;
140 } __packed;
141 
142 /**
143  * enum iwl_device_power_flags - masks for device power command flags
144  * @DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK:
145  *	'1' Allow to save power by turning off
146  *	receiver and transmitter. '0' - does not allow.
147  * @DEVICE_POWER_FLAGS_ALLOW_MEM_RETENTION_MSK:
148  *	Device Retention indication, '1' indicate retention is enabled.
149  * @DEVICE_POWER_FLAGS_NO_SLEEP_TILL_D3_MSK:
150  *	Prevent power save until entering d3 is completed.
151  * @DEVICE_POWER_FLAGS_32K_CLK_VALID_MSK:
152  *	32Khz external slow clock valid indication, '1' indicate cloack is
153  *	valid.
154 */
155 enum iwl_device_power_flags {
156 	DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK		= BIT(0),
157 	DEVICE_POWER_FLAGS_ALLOW_MEM_RETENTION_MSK	= BIT(1),
158 	DEVICE_POWER_FLAGS_NO_SLEEP_TILL_D3_MSK		= BIT(7),
159 	DEVICE_POWER_FLAGS_32K_CLK_VALID_MSK		= BIT(12),
160 };
161 
162 /**
163  * struct iwl_device_power_cmd - device wide power command.
164  * DEVICE_POWER_CMD = 0x77 (command, has simple generic response)
165  *
166  * @flags:	Power table command flags from &enum iwl_device_power_flags
167  * @reserved: reserved (padding)
168  */
169 struct iwl_device_power_cmd {
170 	/* PM_POWER_TABLE_CMD_API_S_VER_7 */
171 	__le16 flags;
172 	__le16 reserved;
173 } __packed;
174 
175 /**
176  * struct iwl_mac_power_cmd - New power command containing uAPSD support
177  * MAC_PM_POWER_TABLE = 0xA9 (command, has simple generic response)
178  * @id_and_color:	MAC contex identifier, &enum iwl_ctxt_id_and_color
179  * @flags:		Power table command flags from POWER_FLAGS_*
180  * @keep_alive_seconds:	Keep alive period in seconds. Default - 25 sec.
181  *			Minimum allowed:- 3 * DTIM. Keep alive period must be
182  *			set regardless of power scheme or current power state.
183  *			FW use this value also when PM is disabled.
184  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
185  *			PSM transition - legacy PM
186  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
187  *			PSM transition - legacy PM
188  * @skip_dtim_periods:	Number of DTIM periods to skip if Skip over DTIM flag
189  *			is set. For example, if it is required to skip over
190  *			one DTIM, this value need to be set to 2 (DTIM periods).
191  * @rx_data_timeout_uapsd: Minimum time (usec) from last Rx packet for AM to
192  *			PSM transition - uAPSD
193  * @tx_data_timeout_uapsd: Minimum time (usec) from last Tx packet for AM to
194  *			PSM transition - uAPSD
195  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
196  *			Default: 80dbm
197  * @snooze_interval:	Maximum time between attempts to retrieve buffered data
198  *			from the AP [msec]
199  * @snooze_window:	A window of time in which PBW snoozing insures that all
200  *			packets received. It is also the minimum time from last
201  *			received unicast RX packet, before client stops snoozing
202  *			for data. [msec]
203  * @snooze_step:	TBD
204  * @qndp_tid:		TID client shall use for uAPSD QNDP triggers
205  * @uapsd_ac_flags:	Set trigger-enabled and delivery-enabled indication for
206  *			each corresponding AC.
207  *			Use IEEE80211_WMM_IE_STA_QOSINFO_AC* for correct values.
208  * @uapsd_max_sp:	Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct
209  *			values.
210  * @heavy_tx_thld_packets:	TX threshold measured in number of packets
211  * @heavy_rx_thld_packets:	RX threshold measured in number of packets
212  * @heavy_tx_thld_percentage:	TX threshold measured in load's percentage
213  * @heavy_rx_thld_percentage:	RX threshold measured in load's percentage
214  * @limited_ps_threshold: (unused)
215  * @reserved: reserved (padding)
216  */
217 struct iwl_mac_power_cmd {
218 	/* CONTEXT_DESC_API_T_VER_1 */
219 	__le32 id_and_color;
220 
221 	__le16 flags;
222 	__le16 keep_alive_seconds;
223 	__le32 rx_data_timeout;
224 	__le32 tx_data_timeout;
225 	__le32 rx_data_timeout_uapsd;
226 	__le32 tx_data_timeout_uapsd;
227 	u8 lprx_rssi_threshold;
228 	u8 skip_dtim_periods;
229 	__le16 snooze_interval;
230 	__le16 snooze_window;
231 	u8 snooze_step;
232 	u8 qndp_tid;
233 	u8 uapsd_ac_flags;
234 	u8 uapsd_max_sp;
235 	u8 heavy_tx_thld_packets;
236 	u8 heavy_rx_thld_packets;
237 	u8 heavy_tx_thld_percentage;
238 	u8 heavy_rx_thld_percentage;
239 	u8 limited_ps_threshold;
240 	u8 reserved;
241 } __packed; /* CLIENT_PM_POWER_TABLE_S_VER_1, VER_2 */
242 
243 /*
244  * struct iwl_uapsd_misbehaving_ap_notif - FW sends this notification when
245  * associated AP is identified as improperly implementing uAPSD protocol.
246  * PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78
247  * @sta_id: index of station in uCode's station table - associated AP ID in
248  *	    this context.
249  */
250 struct iwl_uapsd_misbehaving_ap_notif {
251 	__le32 sta_id;
252 	u8 mac_id;
253 	u8 reserved[3];
254 } __packed;
255 
256 /**
257  * struct iwl_reduce_tx_power_cmd - TX power reduction command
258  * REDUCE_TX_POWER_CMD = 0x9f
259  * @flags: (reserved for future implementation)
260  * @mac_context_id: id of the mac ctx for which we are reducing TX power.
261  * @pwr_restriction: TX power restriction in dBms.
262  */
263 struct iwl_reduce_tx_power_cmd {
264 	u8 flags;
265 	u8 mac_context_id;
266 	__le16 pwr_restriction;
267 } __packed; /* TX_REDUCED_POWER_API_S_VER_1 */
268 
269 enum iwl_dev_tx_power_cmd_mode {
270 	IWL_TX_POWER_MODE_SET_LINK = 0,
271 	IWL_TX_POWER_MODE_SET_DEVICE = 1,
272 	IWL_TX_POWER_MODE_SET_CHAINS = 2,
273 	IWL_TX_POWER_MODE_SET_ACK = 3,
274 	IWL_TX_POWER_MODE_SET_SAR_TIMER = 4,
275 	IWL_TX_POWER_MODE_SET_SAR_TIMER_DEFAULT_TABLE = 5,
276 }; /* TX_POWER_REDUCED_FLAGS_TYPE_API_E_VER_5 */;
277 
278 #define IWL_NUM_CHAIN_TABLES	1
279 #define IWL_NUM_CHAIN_TABLES_V2	2
280 #define IWL_NUM_CHAIN_LIMITS	2
281 #define IWL_NUM_SUB_BANDS_V1	5
282 #define IWL_NUM_SUB_BANDS_V2	11
283 
284 /**
285  * struct iwl_dev_tx_power_common - Common part of the TX power reduction cmd
286  * @set_mode: see &enum iwl_dev_tx_power_cmd_mode
287  * @link_id: id of the link ctx for which we are reducing TX power.
288  *	For version 9 / 10, this is the link id. For earlier versions, it is
289  *	the mac id.
290  * @pwr_restriction: TX power restriction in 1/8 dBms.
291  */
292 struct iwl_dev_tx_power_common {
293 	__le32 set_mode;
294 	__le32 link_id;
295 	__le16 pwr_restriction;
296 } __packed;
297 
298 /**
299  * struct iwl_dev_tx_power_cmd_v3 - TX power reduction command version 3
300  * @per_chain: per chain restrictions
301  */
302 struct iwl_dev_tx_power_cmd_v3 {
303 	__le16 per_chain[IWL_NUM_CHAIN_TABLES][IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V1];
304 } __packed; /* TX_REDUCED_POWER_API_S_VER_3 */
305 
306 #define IWL_DEV_MAX_TX_POWER 0x7FFF
307 
308 /**
309  * struct iwl_dev_tx_power_cmd_v4 - TX power reduction command version 4
310  * @per_chain: per chain restrictions
311  * @enable_ack_reduction: enable or disable close range ack TX power
312  *	reduction.
313  * @reserved: reserved (padding)
314  */
315 struct iwl_dev_tx_power_cmd_v4 {
316 	__le16 per_chain[IWL_NUM_CHAIN_TABLES][IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V1];
317 	u8 enable_ack_reduction;
318 	u8 reserved[3];
319 } __packed; /* TX_REDUCED_POWER_API_S_VER_4 */
320 
321 /**
322  * struct iwl_dev_tx_power_cmd_v5 - TX power reduction command version 5
323  * @per_chain: per chain restrictions
324  * @enable_ack_reduction: enable or disable close range ack TX power
325  *	reduction.
326  * @per_chain_restriction_changed: is per_chain_restriction has changed
327  *	from last command. used if set_mode is
328  *	IWL_TX_POWER_MODE_SET_SAR_TIMER.
329  *	note: if not changed, the command is used for keep alive only.
330  * @reserved: reserved (padding)
331  * @timer_period: timer in milliseconds. if expires FW will change to default
332  *	BIOS values. relevant if setMode is IWL_TX_POWER_MODE_SET_SAR_TIMER
333  */
334 struct iwl_dev_tx_power_cmd_v5 {
335 	__le16 per_chain[IWL_NUM_CHAIN_TABLES][IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V1];
336 	u8 enable_ack_reduction;
337 	u8 per_chain_restriction_changed;
338 	u8 reserved[2];
339 	__le32 timer_period;
340 } __packed; /* TX_REDUCED_POWER_API_S_VER_5 */
341 
342 /**
343  * struct iwl_dev_tx_power_cmd_v6 - TX power reduction command version 6
344  * @per_chain: per chain restrictions
345  * @enable_ack_reduction: enable or disable close range ack TX power
346  *	reduction.
347  * @per_chain_restriction_changed: is per_chain_restriction has changed
348  *	from last command. used if set_mode is
349  *	IWL_TX_POWER_MODE_SET_SAR_TIMER.
350  *	note: if not changed, the command is used for keep alive only.
351  * @reserved: reserved (padding)
352  * @timer_period: timer in milliseconds. if expires FW will change to default
353  *	BIOS values. relevant if setMode is IWL_TX_POWER_MODE_SET_SAR_TIMER
354  */
355 struct iwl_dev_tx_power_cmd_v6 {
356 	__le16 per_chain[IWL_NUM_CHAIN_TABLES_V2][IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V2];
357 	u8 enable_ack_reduction;
358 	u8 per_chain_restriction_changed;
359 	u8 reserved[2];
360 	__le32 timer_period;
361 } __packed; /* TX_REDUCED_POWER_API_S_VER_6 */
362 
363 /**
364  * struct iwl_dev_tx_power_cmd_v7 - TX power reduction command version 7
365  * @per_chain: per chain restrictions
366  * @enable_ack_reduction: enable or disable close range ack TX power
367  *	reduction.
368  * @per_chain_restriction_changed: is per_chain_restriction has changed
369  *	from last command. used if set_mode is
370  *	IWL_TX_POWER_MODE_SET_SAR_TIMER.
371  *	note: if not changed, the command is used for keep alive only.
372  * @reserved: reserved (padding)
373  * @timer_period: timer in milliseconds. if expires FW will change to default
374  *	BIOS values. relevant if setMode is IWL_TX_POWER_MODE_SET_SAR_TIMER
375  * @flags: reduce power flags.
376  */
377 struct iwl_dev_tx_power_cmd_v7 {
378 	__le16 per_chain[IWL_NUM_CHAIN_TABLES_V2][IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V2];
379 	u8 enable_ack_reduction;
380 	u8 per_chain_restriction_changed;
381 	u8 reserved[2];
382 	__le32 timer_period;
383 	__le32 flags;
384 } __packed; /* TX_REDUCED_POWER_API_S_VER_7 */
385 
386 /**
387  * struct iwl_dev_tx_power_cmd_v8 - TX power reduction command version 8
388  * @per_chain: per chain restrictions
389  * @enable_ack_reduction: enable or disable close range ack TX power
390  *	reduction.
391  * @per_chain_restriction_changed: is per_chain_restriction has changed
392  *	from last command. used if set_mode is
393  *	IWL_TX_POWER_MODE_SET_SAR_TIMER.
394  *	note: if not changed, the command is used for keep alive only.
395  * @reserved: reserved (padding)
396  * @timer_period: timer in milliseconds. if expires FW will change to default
397  *	BIOS values. relevant if setMode is IWL_TX_POWER_MODE_SET_SAR_TIMER
398  * @flags: reduce power flags.
399  * @tpc_vlp_backoff_level: user backoff of UNII5,7 VLP channels in USA.
400  *	Not in use.
401  */
402 struct iwl_dev_tx_power_cmd_v8 {
403 	__le16 per_chain[IWL_NUM_CHAIN_TABLES_V2][IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V2];
404 	u8 enable_ack_reduction;
405 	u8 per_chain_restriction_changed;
406 	u8 reserved[2];
407 	__le32 timer_period;
408 	__le32 flags;
409 	__le32 tpc_vlp_backoff_level;
410 } __packed; /* TX_REDUCED_POWER_API_S_VER_8 */
411 
412 /*
413  * @dev_24: device TX power restriction in 1/8 dBms
414  * @dev_52_low: device TX power restriction upper band - low
415  * @dev_52_high: device TX power restriction upper band - high
416  */
417 struct iwl_dev_tx_power_cmd_per_band {
418 	__le16 dev_24;
419 	__le16 dev_52_low;
420 	__le16 dev_52_high;
421 } __packed;
422 
423 /**
424  * struct iwl_dev_tx_power_cmd_v3_v8 - TX power reduction command (multiversion)
425  * @per_band: per band restrictions
426  * @common: common part of the command
427  * @v3: version 3 part of the command
428  * @v4: version 4 part of the command
429  * @v5: version 5 part of the command
430  * @v6: version 6 part of the command
431  * @v7: version 7 part of the command
432  * @v8: version 8 part of the command
433  */
434 struct iwl_dev_tx_power_cmd_v3_v8 {
435 	struct iwl_dev_tx_power_common common;
436 	struct iwl_dev_tx_power_cmd_per_band per_band;
437 	union {
438 		struct iwl_dev_tx_power_cmd_v3 v3;
439 		struct iwl_dev_tx_power_cmd_v4 v4;
440 		struct iwl_dev_tx_power_cmd_v5 v5;
441 		struct iwl_dev_tx_power_cmd_v6 v6;
442 		struct iwl_dev_tx_power_cmd_v7 v7;
443 		struct iwl_dev_tx_power_cmd_v8 v8;
444 	};
445 };
446 
447 /**
448  * struct iwl_dev_tx_power_cmd_v9 - TX power reduction cmd
449  * @reserved: reserved (padding)
450  * @per_chain: per chain restrictions
451  * @per_chain_restriction_changed: is per_chain_restriction has changed
452  *	from last command. used if set_mode is
453  *	IWL_TX_POWER_MODE_SET_SAR_TIMER.
454  *	note: if not changed, the command is used for keep alive only.
455  * @reserved1: reserved (padding)
456  * @timer_period: timer in milliseconds. if expires FW will change to default
457  *	BIOS values. relevant if setMode is IWL_TX_POWER_MODE_SET_SAR_TIMER
458  */
459 struct iwl_dev_tx_power_cmd_v9 {
460 	__le16 reserved;
461 	__le16 per_chain[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V1];
462 	u8 per_chain_restriction_changed;
463 	u8 reserved1[3];
464 	__le32 timer_period;
465 } __packed; /* TX_REDUCED_POWER_API_S_VER_9 */
466 
467 /**
468  * struct iwl_dev_tx_power_cmd_v10 - TX power reduction cmd
469  * @per_chain: per chain restrictions
470  * @per_chain_restriction_changed: is per_chain_restriction has changed
471  *	from last command. used if set_mode is
472  *	IWL_TX_POWER_MODE_SET_SAR_TIMER.
473  *	note: if not changed, the command is used for keep alive only.
474  * @reserved: reserved (padding)
475  * @timer_period: timer in milliseconds. if expires FW will change to default
476  *	BIOS values. relevant if setMode is IWL_TX_POWER_MODE_SET_SAR_TIMER
477  * @flags: reduce power flags.
478  */
479 struct iwl_dev_tx_power_cmd_v10 {
480 	__le16 per_chain[IWL_NUM_CHAIN_TABLES_V2][IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V2];
481 	u8 per_chain_restriction_changed;
482 	u8 reserved;
483 	__le32 timer_period;
484 	__le32 flags;
485 } __packed; /* TX_REDUCED_POWER_API_S_VER_10 */
486 
487 /*
488  * struct iwl_dev_tx_power_cmd - TX power reduction command (multiversion)
489  * @common: common part of the command
490  * @v9: version 9 part of the command
491  * @v10: version 10 part of the command
492  */
493 struct iwl_dev_tx_power_cmd {
494 	struct iwl_dev_tx_power_common common;
495 	union {
496 		struct iwl_dev_tx_power_cmd_v9 v9;
497 		struct iwl_dev_tx_power_cmd_v10 v10;
498 	};
499 } __packed; /* TX_REDUCED_POWER_API_S_VER_9_VER10 */
500 
501 #define IWL_NUM_GEO_PROFILES		3
502 #define IWL_NUM_GEO_PROFILES_V3		8
503 #define IWL_NUM_BANDS_PER_CHAIN_V1	2
504 #define IWL_NUM_BANDS_PER_CHAIN_V2	3
505 
506 /**
507  * enum iwl_geo_per_chain_offset_operation - type of operation
508  * @IWL_PER_CHAIN_OFFSET_SET_TABLES: send the tables from the host to the FW.
509  * @IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE: retrieve the last configured table.
510  */
511 enum iwl_geo_per_chain_offset_operation {
512 	IWL_PER_CHAIN_OFFSET_SET_TABLES,
513 	IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE,
514 };  /* PER_CHAIN_OFFSET_OPERATION_E */
515 
516 /**
517  * struct iwl_per_chain_offset - embedded struct for PER_CHAIN_LIMIT_OFFSET_CMD.
518  * @max_tx_power: maximum allowed tx power.
519  * @chain_a: tx power offset for chain a.
520  * @chain_b: tx power offset for chain b.
521  */
522 struct iwl_per_chain_offset {
523 	__le16 max_tx_power;
524 	u8 chain_a;
525 	u8 chain_b;
526 } __packed; /* PER_CHAIN_LIMIT_OFFSET_PER_CHAIN_S_VER_1 */
527 
528 /**
529  * struct iwl_geo_tx_power_profiles_cmd_v1 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd.
530  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
531  * @table: offset profile per band.
532  */
533 struct iwl_geo_tx_power_profiles_cmd_v1 {
534 	__le32 ops;
535 	struct iwl_per_chain_offset table[IWL_NUM_GEO_PROFILES][IWL_NUM_BANDS_PER_CHAIN_V1];
536 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_1 */
537 
538 /**
539  * struct iwl_geo_tx_power_profiles_cmd_v2 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd.
540  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
541  * @table: offset profile per band.
542  * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading)
543  */
544 struct iwl_geo_tx_power_profiles_cmd_v2 {
545 	__le32 ops;
546 	struct iwl_per_chain_offset table[IWL_NUM_GEO_PROFILES][IWL_NUM_BANDS_PER_CHAIN_V1];
547 	__le32 table_revision;
548 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_2 */
549 
550 /**
551  * struct iwl_geo_tx_power_profiles_cmd_v3 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd.
552  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
553  * @table: offset profile per band.
554  * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading)
555  */
556 struct iwl_geo_tx_power_profiles_cmd_v3 {
557 	__le32 ops;
558 	struct iwl_per_chain_offset table[IWL_NUM_GEO_PROFILES][IWL_NUM_BANDS_PER_CHAIN_V2];
559 	__le32 table_revision;
560 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_3 */
561 
562 /**
563  * struct iwl_geo_tx_power_profiles_cmd_v4 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd.
564  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
565  * @table: offset profile per band.
566  * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading)
567  */
568 struct iwl_geo_tx_power_profiles_cmd_v4 {
569 	__le32 ops;
570 	struct iwl_per_chain_offset table[IWL_NUM_GEO_PROFILES_V3][IWL_NUM_BANDS_PER_CHAIN_V1];
571 	__le32 table_revision;
572 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_4 */
573 
574 /**
575  * struct iwl_geo_tx_power_profiles_cmd_v5 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd.
576  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
577  * @table: offset profile per band.
578  * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading)
579  */
580 struct iwl_geo_tx_power_profiles_cmd_v5 {
581 	__le32 ops;
582 	struct iwl_per_chain_offset table[IWL_NUM_GEO_PROFILES_V3][IWL_NUM_BANDS_PER_CHAIN_V2];
583 	__le32 table_revision;
584 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_5 */
585 
586 union iwl_geo_tx_power_profiles_cmd {
587 	struct iwl_geo_tx_power_profiles_cmd_v1 v1;
588 	struct iwl_geo_tx_power_profiles_cmd_v2 v2;
589 	struct iwl_geo_tx_power_profiles_cmd_v3 v3;
590 	struct iwl_geo_tx_power_profiles_cmd_v4 v4;
591 	struct iwl_geo_tx_power_profiles_cmd_v5 v5;
592 };
593 
594 /**
595  * struct iwl_geo_tx_power_profiles_resp -  response to PER_CHAIN_LIMIT_OFFSET_CMD cmd
596  * @profile_idx: current geo profile in use
597  */
598 struct iwl_geo_tx_power_profiles_resp {
599 	__le32 profile_idx;
600 } __packed; /* PER_CHAIN_LIMIT_OFFSET_RSP */
601 
602 /**
603  * enum iwl_ppag_flags - PPAG enable masks
604  * @IWL_PPAG_ETSI_MASK: enable PPAG in ETSI
605  * @IWL_PPAG_CHINA_MASK: enable PPAG in China
606  * @IWL_PPAG_ETSI_LPI_UHB_MASK: enable LPI in ETSI for UHB
607  * @IWL_PPAG_ETSI_VLP_UHB_MASK: enable VLP in ETSI for UHB
608  * @IWL_PPAG_ETSI_SP_UHB_MASK: enable SP in ETSI for UHB
609  * @IWL_PPAG_USA_LPI_UHB_MASK: enable LPI in USA for UHB
610  * @IWL_PPAG_USA_VLP_UHB_MASK: enable VLP in USA for UHB
611  * @IWL_PPAG_USA_SP_UHB_MASK: enable SP in USA for UHB
612  * @IWL_PPAG_CANADA_LPI_UHB_MASK: enable LPI in CANADA for UHB
613  * @IWL_PPAG_CANADA_VLP_UHB_MASK: enable VLP in CANADA for UHB
614  * @IWL_PPAG_CANADA_SP_UHB_MASK: enable SP in CANADA for UHB
615  */
616 enum iwl_ppag_flags {
617 	IWL_PPAG_ETSI_MASK = BIT(0),
618 	IWL_PPAG_CHINA_MASK = BIT(1),
619 	IWL_PPAG_ETSI_LPI_UHB_MASK = BIT(2),
620 	IWL_PPAG_ETSI_VLP_UHB_MASK = BIT(3),
621 	IWL_PPAG_ETSI_SP_UHB_MASK = BIT(4),
622 	IWL_PPAG_USA_LPI_UHB_MASK = BIT(5),
623 	IWL_PPAG_USA_VLP_UHB_MASK = BIT(6),
624 	IWL_PPAG_USA_SP_UHB_MASK = BIT(7),
625 	IWL_PPAG_CANADA_LPI_UHB_MASK = BIT(8),
626 	IWL_PPAG_CANADA_VLP_UHB_MASK = BIT(9),
627 	IWL_PPAG_CANADA_SP_UHB_MASK = BIT(10),
628 };
629 
630 /**
631  * union iwl_ppag_table_cmd - union for all versions of PPAG command
632  * @v1: version 1
633  * @v2: version 2
634  * version 3, 4, 5 and 6 are the same structure as v2,
635  *	but has a different format of the flags bitmap
636  * @v1.flags: values from &enum iwl_ppag_flags
637  * @v1.gain: table of antenna gain values per chain and sub-band
638  * @v1.reserved: reserved
639  * @v2.flags: values from &enum iwl_ppag_flags
640  * @v2.gain: table of antenna gain values per chain and sub-band
641  * @v2.reserved: reserved
642  */
643 union iwl_ppag_table_cmd {
644 	struct {
645 		__le32 flags;
646 		s8 gain[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V1];
647 		s8 reserved[2];
648 	} v1;
649 	struct {
650 		__le32 flags;
651 		s8 gain[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V2];
652 		s8 reserved[2];
653 	} v2;
654 } __packed;
655 
656 #define IWL_PPAG_CMD_V4_MASK (IWL_PPAG_ETSI_MASK | IWL_PPAG_CHINA_MASK)
657 #define IWL_PPAG_CMD_V5_MASK (IWL_PPAG_CMD_V4_MASK | \
658 			      IWL_PPAG_ETSI_LPI_UHB_MASK | \
659 			      IWL_PPAG_USA_LPI_UHB_MASK)
660 
661 #define MCC_TO_SAR_OFFSET_TABLE_ROW_SIZE	26
662 #define MCC_TO_SAR_OFFSET_TABLE_COL_SIZE	13
663 
664 /**
665  * struct iwl_sar_offset_mapping_cmd - struct for SAR_OFFSET_MAPPING_TABLE_CMD
666  * @offset_map: mapping a mcc to a geo sar group
667  * @reserved: reserved
668  */
669 struct iwl_sar_offset_mapping_cmd {
670 	u8 offset_map[MCC_TO_SAR_OFFSET_TABLE_ROW_SIZE]
671 		[MCC_TO_SAR_OFFSET_TABLE_COL_SIZE];
672 	__le16 reserved;
673 } __packed; /*SAR_OFFSET_MAPPING_TABLE_CMD_API_S*/
674 
675 /**
676  * struct iwl_beacon_filter_cmd
677  * REPLY_BEACON_FILTERING_CMD = 0xd2 (command)
678  * @bf_energy_delta: Used for RSSI filtering, if in 'normal' state. Send beacon
679  *      to driver if delta in Energy values calculated for this and last
680  *      passed beacon is greater than this threshold. Zero value means that
681  *      the Energy change is ignored for beacon filtering, and beacon will
682  *      not be forced to be sent to driver regardless of this delta. Typical
683  *      energy delta 5dB.
684  * @bf_roaming_energy_delta: Used for RSSI filtering, if in 'roaming' state.
685  *      Send beacon to driver if delta in Energy values calculated for this
686  *      and last passed beacon is greater than this threshold. Zero value
687  *      means that the Energy change is ignored for beacon filtering while in
688  *      Roaming state, typical energy delta 1dB.
689  * @bf_roaming_state: Used for RSSI filtering. If absolute Energy values
690  *      calculated for current beacon is less than the threshold, use
691  *      Roaming Energy Delta Threshold, otherwise use normal Energy Delta
692  *      Threshold. Typical energy threshold is -72dBm.
693  * @bf_temp_threshold: This threshold determines the type of temperature
694  *	filtering (Slow or Fast) that is selected (Units are in Celsius):
695  *	If the current temperature is above this threshold - Fast filter
696  *	will be used, If the current temperature is below this threshold -
697  *	Slow filter will be used.
698  * @bf_temp_fast_filter: Send Beacon to driver if delta in temperature values
699  *      calculated for this and the last passed beacon is greater than this
700  *      threshold. Zero value means that the temperature change is ignored for
701  *      beacon filtering; beacons will not be  forced to be sent to driver
702  *      regardless of whether its temperature has been changed.
703  * @bf_temp_slow_filter: Send Beacon to driver if delta in temperature values
704  *      calculated for this and the last passed beacon is greater than this
705  *      threshold. Zero value means that the temperature change is ignored for
706  *      beacon filtering; beacons will not be forced to be sent to driver
707  *      regardless of whether its temperature has been changed.
708  * @bf_enable_beacon_filter: 1, beacon filtering is enabled; 0, disabled.
709  * @bf_debug_flag: beacon filtering debug configuration
710  * @bf_escape_timer: Send beacons to to driver if no beacons were passed
711  *      for a specific period of time. Units: Beacons.
712  * @ba_escape_timer: Fully receive and parse beacon if no beacons were passed
713  *      for a longer period of time then this escape-timeout. Units: Beacons.
714  * @ba_enable_beacon_abort: 1, beacon abort is enabled; 0, disabled.
715  * @bf_threshold_absolute_low: See below.
716  * @bf_threshold_absolute_high: Send Beacon to driver if Energy value calculated
717  *      for this beacon crossed this absolute threshold. For the 'Increase'
718  *      direction the bf_energy_absolute_low[i] is used. For the 'Decrease'
719  *      direction the bf_energy_absolute_high[i] is used. Zero value means
720  *      that this specific threshold is ignored for beacon filtering, and
721  *      beacon will not be forced to be sent to driver due to this setting.
722  */
723 struct iwl_beacon_filter_cmd {
724 	__le32 bf_energy_delta;
725 	__le32 bf_roaming_energy_delta;
726 	__le32 bf_roaming_state;
727 	__le32 bf_temp_threshold;
728 	__le32 bf_temp_fast_filter;
729 	__le32 bf_temp_slow_filter;
730 	__le32 bf_enable_beacon_filter;
731 	__le32 bf_debug_flag;
732 	__le32 bf_escape_timer;
733 	__le32 ba_escape_timer;
734 	__le32 ba_enable_beacon_abort;
735 	__le32 bf_threshold_absolute_low[2];
736 	__le32 bf_threshold_absolute_high[2];
737 } __packed; /* BEACON_FILTER_CONFIG_API_S_VER_4 */
738 
739 /* Beacon filtering and beacon abort */
740 #define IWL_BF_ENERGY_DELTA_DEFAULT 5
741 #define IWL_BF_ENERGY_DELTA_D0I3 20
742 #define IWL_BF_ENERGY_DELTA_MAX 255
743 #define IWL_BF_ENERGY_DELTA_MIN 0
744 
745 #define IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT 1
746 #define IWL_BF_ROAMING_ENERGY_DELTA_D0I3 20
747 #define IWL_BF_ROAMING_ENERGY_DELTA_MAX 255
748 #define IWL_BF_ROAMING_ENERGY_DELTA_MIN 0
749 
750 #define IWL_BF_ROAMING_STATE_DEFAULT 72
751 #define IWL_BF_ROAMING_STATE_D0I3 72
752 #define IWL_BF_ROAMING_STATE_MAX 255
753 #define IWL_BF_ROAMING_STATE_MIN 0
754 
755 #define IWL_BF_TEMP_THRESHOLD_DEFAULT 112
756 #define IWL_BF_TEMP_THRESHOLD_D0I3 112
757 #define IWL_BF_TEMP_THRESHOLD_MAX 255
758 #define IWL_BF_TEMP_THRESHOLD_MIN 0
759 
760 #define IWL_BF_TEMP_FAST_FILTER_DEFAULT 1
761 #define IWL_BF_TEMP_FAST_FILTER_D0I3 1
762 #define IWL_BF_TEMP_FAST_FILTER_MAX 255
763 #define IWL_BF_TEMP_FAST_FILTER_MIN 0
764 
765 #define IWL_BF_TEMP_SLOW_FILTER_DEFAULT 5
766 #define IWL_BF_TEMP_SLOW_FILTER_D0I3 20
767 #define IWL_BF_TEMP_SLOW_FILTER_MAX 255
768 #define IWL_BF_TEMP_SLOW_FILTER_MIN 0
769 
770 #define IWL_BF_ENABLE_BEACON_FILTER_DEFAULT 1
771 
772 #define IWL_BF_DEBUG_FLAG_DEFAULT 0
773 #define IWL_BF_DEBUG_FLAG_D0I3 0
774 
775 #define IWL_BF_ESCAPE_TIMER_DEFAULT 0
776 #define IWL_BF_ESCAPE_TIMER_D0I3 0
777 #define IWL_BF_ESCAPE_TIMER_MAX 1024
778 #define IWL_BF_ESCAPE_TIMER_MIN 0
779 
780 #define IWL_BA_ESCAPE_TIMER_DEFAULT 6
781 #define IWL_BA_ESCAPE_TIMER_D0I3 6
782 #define IWL_BA_ESCAPE_TIMER_D3 9
783 #define IWL_BA_ESCAPE_TIMER_MAX 1024
784 #define IWL_BA_ESCAPE_TIMER_MIN 0
785 
786 #define IWL_BA_ENABLE_BEACON_ABORT_DEFAULT 1
787 
788 #define IWL_BF_CMD_CONFIG(mode)					     \
789 	.bf_energy_delta = cpu_to_le32(IWL_BF_ENERGY_DELTA ## mode),	      \
790 	.bf_roaming_energy_delta =					      \
791 		cpu_to_le32(IWL_BF_ROAMING_ENERGY_DELTA ## mode),	      \
792 	.bf_roaming_state = cpu_to_le32(IWL_BF_ROAMING_STATE ## mode),	      \
793 	.bf_temp_threshold = cpu_to_le32(IWL_BF_TEMP_THRESHOLD ## mode),      \
794 	.bf_temp_fast_filter = cpu_to_le32(IWL_BF_TEMP_FAST_FILTER ## mode),  \
795 	.bf_temp_slow_filter = cpu_to_le32(IWL_BF_TEMP_SLOW_FILTER ## mode),  \
796 	.bf_debug_flag = cpu_to_le32(IWL_BF_DEBUG_FLAG ## mode),	      \
797 	.bf_escape_timer = cpu_to_le32(IWL_BF_ESCAPE_TIMER ## mode),	      \
798 	.ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER ## mode)
799 
800 #define IWL_BF_CMD_CONFIG_DEFAULTS IWL_BF_CMD_CONFIG(_DEFAULT)
801 #define IWL_BF_CMD_CONFIG_D0I3 IWL_BF_CMD_CONFIG(_D0I3)
802 
803 #define DEFAULT_TPE_TX_POWER 0x7F
804 
805 /*
806  *  Bandwidth: 20/40/80/(160/80+80)/320
807  */
808 #define IWL_MAX_TX_EIRP_PWR_MAX_SIZE 5
809 #define IWL_MAX_TX_EIRP_PSD_PWR_MAX_SIZE 16
810 
811 enum iwl_6ghz_ap_type {
812 	IWL_6GHZ_AP_TYPE_LPI,
813 	IWL_6GHZ_AP_TYPE_SP,
814 	IWL_6GHZ_AP_TYPE_VLP,
815 }; /* PHY_AP_TYPE_API_E_VER_1 */
816 
817 /**
818  * struct iwl_txpower_constraints_cmd
819  * AP_TX_POWER_CONSTRAINTS_CMD
820  * Used for VLP/LPI/AFC Access Point power constraints for 6GHz channels
821  * @link_id: linkId
822  * @ap_type: see &enum iwl_ap_type
823  * @eirp_pwr: 8-bit 2s complement signed integer in the range
824  *	-64 dBm to 63 dBm with a 0.5 dB step
825  *	default &DEFAULT_TPE_TX_POWER (no maximum limit)
826  * @psd_pwr: 8-bit 2s complement signed integer in the range
827  *	-63.5 to +63 dBm/MHz with a 0.5 step
828  *	value - 128 indicates that the corresponding 20
829  *	MHz channel cannot be used for transmission.
830  *	value +127 indicates that no maximum PSD limit
831  *	is specified for the corresponding 20 MHz channel
832  *	default &DEFAULT_TPE_TX_POWER (no maximum limit)
833  * @reserved: reserved (padding)
834  */
835 struct iwl_txpower_constraints_cmd {
836 	__le16 link_id;
837 	__le16 ap_type;
838 	__s8 eirp_pwr[IWL_MAX_TX_EIRP_PWR_MAX_SIZE];
839 	__s8 psd_pwr[IWL_MAX_TX_EIRP_PSD_PWR_MAX_SIZE];
840 	u8 reserved[3];
841 } __packed; /* PHY_AP_TX_POWER_CONSTRAINTS_CMD_API_S_VER_1 */
842 #endif /* __iwl_fw_api_power_h__ */
843