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