1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2012-2014, 2018-2022 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 folowing 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 */
93 enum iwl_power_flags {
94 	POWER_FLAGS_POWER_SAVE_ENA_MSK		= BIT(0),
95 	POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK	= BIT(1),
96 	POWER_FLAGS_SKIP_OVER_DTIM_MSK		= BIT(2),
97 	POWER_FLAGS_SNOOZE_ENA_MSK		= BIT(5),
98 	POWER_FLAGS_BT_SCO_ENA			= BIT(8),
99 	POWER_FLAGS_ADVANCE_PM_ENA_MSK		= BIT(9),
100 	POWER_FLAGS_LPRX_ENA_MSK		= BIT(11),
101 	POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK	= BIT(12),
102 };
103 
104 #define IWL_POWER_VEC_SIZE 5
105 
106 /**
107  * struct iwl_powertable_cmd - legacy power command. Beside old API support this
108  *	is used also with a new	power API for device wide power settings.
109  * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
110  *
111  * @flags:		Power table command flags from POWER_FLAGS_*
112  * @keep_alive_seconds: Keep alive period in seconds. Default - 25 sec.
113  *			Minimum allowed:- 3 * DTIM. Keep alive period must be
114  *			set regardless of power scheme or current power state.
115  *			FW use this value also when PM is disabled.
116  * @debug_flags:	debug flags
117  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
118  *			PSM transition - legacy PM
119  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
120  *			PSM transition - legacy PM
121  * @sleep_interval:	not in use
122  * @skip_dtim_periods:	Number of DTIM periods to skip if Skip over DTIM flag
123  *			is set. For example, if it is required to skip over
124  *			one DTIM, this value need to be set to 2 (DTIM periods).
125  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
126  *			Default: 80dbm
127  */
128 struct iwl_powertable_cmd {
129 	/* PM_POWER_TABLE_CMD_API_S_VER_6 */
130 	__le16 flags;
131 	u8 keep_alive_seconds;
132 	u8 debug_flags;
133 	__le32 rx_data_timeout;
134 	__le32 tx_data_timeout;
135 	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
136 	__le32 skip_dtim_periods;
137 	__le32 lprx_rssi_threshold;
138 } __packed;
139 
140 /**
141  * enum iwl_device_power_flags - masks for device power command flags
142  * @DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK:
143  *	'1' Allow to save power by turning off
144  *	receiver and transmitter. '0' - does not allow.
145  * @DEVICE_POWER_FLAGS_ALLOW_MEM_RETENTION_MSK:
146  *	Device Retention indication, '1' indicate retention is enabled.
147  * @DEVICE_POWER_FLAGS_32K_CLK_VALID_MSK:
148  *	32Khz external slow clock valid indication, '1' indicate cloack is
149  *	valid.
150 */
151 enum iwl_device_power_flags {
152 	DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK		= BIT(0),
153 	DEVICE_POWER_FLAGS_ALLOW_MEM_RETENTION_MSK	= BIT(1),
154 	DEVICE_POWER_FLAGS_32K_CLK_VALID_MSK		= BIT(12),
155 };
156 
157 /**
158  * struct iwl_device_power_cmd - device wide power command.
159  * DEVICE_POWER_CMD = 0x77 (command, has simple generic response)
160  *
161  * @flags:	Power table command flags from &enum iwl_device_power_flags
162  * @reserved: reserved (padding)
163  */
164 struct iwl_device_power_cmd {
165 	/* PM_POWER_TABLE_CMD_API_S_VER_6 */
166 	__le16 flags;
167 	__le16 reserved;
168 } __packed;
169 
170 /**
171  * struct iwl_mac_power_cmd - New power command containing uAPSD support
172  * MAC_PM_POWER_TABLE = 0xA9 (command, has simple generic response)
173  * @id_and_color:	MAC contex identifier, &enum iwl_ctxt_id_and_color
174  * @flags:		Power table command flags from POWER_FLAGS_*
175  * @keep_alive_seconds:	Keep alive period in seconds. Default - 25 sec.
176  *			Minimum allowed:- 3 * DTIM. Keep alive period must be
177  *			set regardless of power scheme or current power state.
178  *			FW use this value also when PM is disabled.
179  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
180  *			PSM transition - legacy PM
181  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
182  *			PSM transition - legacy PM
183  * @skip_dtim_periods:	Number of DTIM periods to skip if Skip over DTIM flag
184  *			is set. For example, if it is required to skip over
185  *			one DTIM, this value need to be set to 2 (DTIM periods).
186  * @rx_data_timeout_uapsd: Minimum time (usec) from last Rx packet for AM to
187  *			PSM transition - uAPSD
188  * @tx_data_timeout_uapsd: Minimum time (usec) from last Tx packet for AM to
189  *			PSM transition - uAPSD
190  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
191  *			Default: 80dbm
192  * @snooze_interval:	Maximum time between attempts to retrieve buffered data
193  *			from the AP [msec]
194  * @snooze_window:	A window of time in which PBW snoozing insures that all
195  *			packets received. It is also the minimum time from last
196  *			received unicast RX packet, before client stops snoozing
197  *			for data. [msec]
198  * @snooze_step:	TBD
199  * @qndp_tid:		TID client shall use for uAPSD QNDP triggers
200  * @uapsd_ac_flags:	Set trigger-enabled and delivery-enabled indication for
201  *			each corresponding AC.
202  *			Use IEEE80211_WMM_IE_STA_QOSINFO_AC* for correct values.
203  * @uapsd_max_sp:	Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct
204  *			values.
205  * @heavy_tx_thld_packets:	TX threshold measured in number of packets
206  * @heavy_rx_thld_packets:	RX threshold measured in number of packets
207  * @heavy_tx_thld_percentage:	TX threshold measured in load's percentage
208  * @heavy_rx_thld_percentage:	RX threshold measured in load's percentage
209  * @limited_ps_threshold: (unused)
210  * @reserved: reserved (padding)
211  */
212 struct iwl_mac_power_cmd {
213 	/* CONTEXT_DESC_API_T_VER_1 */
214 	__le32 id_and_color;
215 
216 	/* CLIENT_PM_POWER_TABLE_S_VER_1 */
217 	__le16 flags;
218 	__le16 keep_alive_seconds;
219 	__le32 rx_data_timeout;
220 	__le32 tx_data_timeout;
221 	__le32 rx_data_timeout_uapsd;
222 	__le32 tx_data_timeout_uapsd;
223 	u8 lprx_rssi_threshold;
224 	u8 skip_dtim_periods;
225 	__le16 snooze_interval;
226 	__le16 snooze_window;
227 	u8 snooze_step;
228 	u8 qndp_tid;
229 	u8 uapsd_ac_flags;
230 	u8 uapsd_max_sp;
231 	u8 heavy_tx_thld_packets;
232 	u8 heavy_rx_thld_packets;
233 	u8 heavy_tx_thld_percentage;
234 	u8 heavy_rx_thld_percentage;
235 	u8 limited_ps_threshold;
236 	u8 reserved;
237 } __packed;
238 
239 /*
240  * struct iwl_uapsd_misbehaving_ap_notif - FW sends this notification when
241  * associated AP is identified as improperly implementing uAPSD protocol.
242  * PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78
243  * @sta_id: index of station in uCode's station table - associated AP ID in
244  *	    this context.
245  */
246 struct iwl_uapsd_misbehaving_ap_notif {
247 	__le32 sta_id;
248 	u8 mac_id;
249 	u8 reserved[3];
250 } __packed;
251 
252 /**
253  * struct iwl_reduce_tx_power_cmd - TX power reduction command
254  * REDUCE_TX_POWER_CMD = 0x9f
255  * @flags: (reserved for future implementation)
256  * @mac_context_id: id of the mac ctx for which we are reducing TX power.
257  * @pwr_restriction: TX power restriction in dBms.
258  */
259 struct iwl_reduce_tx_power_cmd {
260 	u8 flags;
261 	u8 mac_context_id;
262 	__le16 pwr_restriction;
263 } __packed; /* TX_REDUCED_POWER_API_S_VER_1 */
264 
265 enum iwl_dev_tx_power_cmd_mode {
266 	IWL_TX_POWER_MODE_SET_MAC = 0,
267 	IWL_TX_POWER_MODE_SET_DEVICE = 1,
268 	IWL_TX_POWER_MODE_SET_CHAINS = 2,
269 	IWL_TX_POWER_MODE_SET_ACK = 3,
270 	IWL_TX_POWER_MODE_SET_SAR_TIMER = 4,
271 	IWL_TX_POWER_MODE_SET_SAR_TIMER_DEFAULT_TABLE = 5,
272 }; /* TX_POWER_REDUCED_FLAGS_TYPE_API_E_VER_5 */;
273 
274 #define IWL_NUM_CHAIN_TABLES	1
275 #define IWL_NUM_CHAIN_TABLES_V2	2
276 #define IWL_NUM_CHAIN_LIMITS	2
277 #define IWL_NUM_SUB_BANDS_V1	5
278 #define IWL_NUM_SUB_BANDS_V2	11
279 
280 /**
281  * struct iwl_dev_tx_power_common - Common part of the TX power reduction cmd
282  * @set_mode: see &enum iwl_dev_tx_power_cmd_mode
283  * @mac_context_id: id of the mac ctx for which we are reducing TX power.
284  * @pwr_restriction: TX power restriction in 1/8 dBms.
285  * @dev_24: device TX power restriction in 1/8 dBms
286  * @dev_52_low: device TX power restriction upper band - low
287  * @dev_52_high: device TX power restriction upper band - high
288  */
289 struct iwl_dev_tx_power_common {
290 	__le32 set_mode;
291 	__le32 mac_context_id;
292 	__le16 pwr_restriction;
293 	__le16 dev_24;
294 	__le16 dev_52_low;
295 	__le16 dev_52_high;
296 };
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  * struct iwl_dev_tx_power_cmd - TX power reduction command (multiversion)
387  * @common: common part of the command
388  * @v3: version 3 part of the command
389  * @v4: version 4 part of the command
390  * @v5: version 5 part of the command
391  * @v6: version 6 part of the command
392  */
393 struct iwl_dev_tx_power_cmd {
394 	struct iwl_dev_tx_power_common common;
395 	union {
396 		struct iwl_dev_tx_power_cmd_v3 v3;
397 		struct iwl_dev_tx_power_cmd_v4 v4;
398 		struct iwl_dev_tx_power_cmd_v5 v5;
399 		struct iwl_dev_tx_power_cmd_v6 v6;
400 		struct iwl_dev_tx_power_cmd_v7 v7;
401 	};
402 };
403 
404 #define IWL_NUM_GEO_PROFILES		3
405 #define IWL_NUM_GEO_PROFILES_V3		8
406 #define IWL_NUM_BANDS_PER_CHAIN_V1	2
407 #define IWL_NUM_BANDS_PER_CHAIN_V2	3
408 
409 /**
410  * enum iwl_geo_per_chain_offset_operation - type of operation
411  * @IWL_PER_CHAIN_OFFSET_SET_TABLES: send the tables from the host to the FW.
412  * @IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE: retrieve the last configured table.
413  */
414 enum iwl_geo_per_chain_offset_operation {
415 	IWL_PER_CHAIN_OFFSET_SET_TABLES,
416 	IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE,
417 };  /* PER_CHAIN_OFFSET_OPERATION_E */
418 
419 /**
420  * struct iwl_per_chain_offset - embedded struct for PER_CHAIN_LIMIT_OFFSET_CMD.
421  * @max_tx_power: maximum allowed tx power.
422  * @chain_a: tx power offset for chain a.
423  * @chain_b: tx power offset for chain b.
424  */
425 struct iwl_per_chain_offset {
426 	__le16 max_tx_power;
427 	u8 chain_a;
428 	u8 chain_b;
429 } __packed; /* PER_CHAIN_LIMIT_OFFSET_PER_CHAIN_S_VER_1 */
430 
431 /**
432  * struct iwl_geo_tx_power_profile_cmd_v1 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd.
433  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
434  * @table: offset profile per band.
435  */
436 struct iwl_geo_tx_power_profiles_cmd_v1 {
437 	__le32 ops;
438 	struct iwl_per_chain_offset table[IWL_NUM_GEO_PROFILES][IWL_NUM_BANDS_PER_CHAIN_V1];
439 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_1 */
440 
441 /**
442  * struct iwl_geo_tx_power_profile_cmd_v2 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd.
443  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
444  * @table: offset profile per band.
445  * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading)
446  */
447 struct iwl_geo_tx_power_profiles_cmd_v2 {
448 	__le32 ops;
449 	struct iwl_per_chain_offset table[IWL_NUM_GEO_PROFILES][IWL_NUM_BANDS_PER_CHAIN_V1];
450 	__le32 table_revision;
451 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_2 */
452 
453 /**
454  * struct iwl_geo_tx_power_profile_cmd_v3 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd.
455  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
456  * @table: offset profile per band.
457  * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading)
458  */
459 struct iwl_geo_tx_power_profiles_cmd_v3 {
460 	__le32 ops;
461 	struct iwl_per_chain_offset table[IWL_NUM_GEO_PROFILES][IWL_NUM_BANDS_PER_CHAIN_V2];
462 	__le32 table_revision;
463 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_3 */
464 
465 /**
466  * struct iwl_geo_tx_power_profile_cmd_v4 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd.
467  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
468  * @table: offset profile per band.
469  * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading)
470  */
471 struct iwl_geo_tx_power_profiles_cmd_v4 {
472 	__le32 ops;
473 	struct iwl_per_chain_offset table[IWL_NUM_GEO_PROFILES_V3][IWL_NUM_BANDS_PER_CHAIN_V1];
474 	__le32 table_revision;
475 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_4 */
476 
477 /**
478  * struct iwl_geo_tx_power_profile_cmd_v5 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd.
479  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
480  * @table: offset profile per band.
481  * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading)
482  */
483 struct iwl_geo_tx_power_profiles_cmd_v5 {
484 	__le32 ops;
485 	struct iwl_per_chain_offset table[IWL_NUM_GEO_PROFILES_V3][IWL_NUM_BANDS_PER_CHAIN_V2];
486 	__le32 table_revision;
487 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_5 */
488 
489 union iwl_geo_tx_power_profiles_cmd {
490 	struct iwl_geo_tx_power_profiles_cmd_v1 v1;
491 	struct iwl_geo_tx_power_profiles_cmd_v2 v2;
492 	struct iwl_geo_tx_power_profiles_cmd_v3 v3;
493 	struct iwl_geo_tx_power_profiles_cmd_v4 v4;
494 	struct iwl_geo_tx_power_profiles_cmd_v5 v5;
495 };
496 
497 /**
498  * struct iwl_geo_tx_power_profiles_resp -  response to PER_CHAIN_LIMIT_OFFSET_CMD cmd
499  * @profile_idx: current geo profile in use
500  */
501 struct iwl_geo_tx_power_profiles_resp {
502 	__le32 profile_idx;
503 } __packed; /* PER_CHAIN_LIMIT_OFFSET_RSP */
504 
505 /**
506  * union iwl_ppag_table_cmd - union for all versions of PPAG command
507  * @v1: version 1
508  * @v2: version 2
509  *
510  * @flags: bit 0 - indicates enablement of PPAG for ETSI
511  *         bit 1 - indicates enablement of PPAG for CHINA BIOS
512  *         bit 1 can be used only in v3 (identical to v2)
513  * @gain: table of antenna gain values per chain and sub-band
514  * @reserved: reserved
515  */
516 union iwl_ppag_table_cmd {
517 	struct {
518 		__le32 flags;
519 		s8 gain[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V1];
520 		s8 reserved[2];
521 	} v1;
522 	struct {
523 		__le32 flags;
524 		s8 gain[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V2];
525 		s8 reserved[2];
526 	} v2;
527 } __packed;
528 
529 #define MCC_TO_SAR_OFFSET_TABLE_ROW_SIZE	26
530 #define MCC_TO_SAR_OFFSET_TABLE_COL_SIZE	13
531 
532 /**
533  * struct iwl_sar_offset_mapping_cmd - struct for SAR_OFFSET_MAPPING_TABLE_CMD
534  * @offset_map: mapping a mcc to a geo sar group
535  * @reserved: reserved
536  */
537 struct iwl_sar_offset_mapping_cmd {
538 	u8 offset_map[MCC_TO_SAR_OFFSET_TABLE_ROW_SIZE]
539 		[MCC_TO_SAR_OFFSET_TABLE_COL_SIZE];
540 	__le16 reserved;
541 } __packed; /*SAR_OFFSET_MAPPING_TABLE_CMD_API_S*/
542 
543 /**
544  * struct iwl_beacon_filter_cmd
545  * REPLY_BEACON_FILTERING_CMD = 0xd2 (command)
546  * @bf_energy_delta: Used for RSSI filtering, if in 'normal' state. Send beacon
547  *      to driver if delta in Energy values calculated for this and last
548  *      passed beacon is greater than this threshold. Zero value means that
549  *      the Energy change is ignored for beacon filtering, and beacon will
550  *      not be forced to be sent to driver regardless of this delta. Typical
551  *      energy delta 5dB.
552  * @bf_roaming_energy_delta: Used for RSSI filtering, if in 'roaming' state.
553  *      Send beacon to driver if delta in Energy values calculated for this
554  *      and last passed beacon is greater than this threshold. Zero value
555  *      means that the Energy change is ignored for beacon filtering while in
556  *      Roaming state, typical energy delta 1dB.
557  * @bf_roaming_state: Used for RSSI filtering. If absolute Energy values
558  *      calculated for current beacon is less than the threshold, use
559  *      Roaming Energy Delta Threshold, otherwise use normal Energy Delta
560  *      Threshold. Typical energy threshold is -72dBm.
561  * @bf_temp_threshold: This threshold determines the type of temperature
562  *	filtering (Slow or Fast) that is selected (Units are in Celsuis):
563  *	If the current temperature is above this threshold - Fast filter
564  *	will be used, If the current temperature is below this threshold -
565  *	Slow filter will be used.
566  * @bf_temp_fast_filter: Send Beacon to driver if delta in temperature values
567  *      calculated for this and the last passed beacon is greater than this
568  *      threshold. Zero value means that the temperature change is ignored for
569  *      beacon filtering; beacons will not be  forced to be sent to driver
570  *      regardless of whether its temerature has been changed.
571  * @bf_temp_slow_filter: Send Beacon to driver if delta in temperature values
572  *      calculated for this and the last passed beacon is greater than this
573  *      threshold. Zero value means that the temperature change is ignored for
574  *      beacon filtering; beacons will not be forced to be sent to driver
575  *      regardless of whether its temerature has been changed.
576  * @bf_enable_beacon_filter: 1, beacon filtering is enabled; 0, disabled.
577  * @bf_debug_flag: beacon filtering debug configuration
578  * @bf_escape_timer: Send beacons to to driver if no beacons were passed
579  *      for a specific period of time. Units: Beacons.
580  * @ba_escape_timer: Fully receive and parse beacon if no beacons were passed
581  *      for a longer period of time then this escape-timeout. Units: Beacons.
582  * @ba_enable_beacon_abort: 1, beacon abort is enabled; 0, disabled.
583  * @bf_threshold_absolute_low: See below.
584  * @bf_threshold_absolute_high: Send Beacon to driver if Energy value calculated
585  *      for this beacon crossed this absolute threshold. For the 'Increase'
586  *      direction the bf_energy_absolute_low[i] is used. For the 'Decrease'
587  *      direction the bf_energy_absolute_high[i] is used. Zero value means
588  *      that this specific threshold is ignored for beacon filtering, and
589  *      beacon will not be forced to be sent to driver due to this setting.
590  */
591 struct iwl_beacon_filter_cmd {
592 	__le32 bf_energy_delta;
593 	__le32 bf_roaming_energy_delta;
594 	__le32 bf_roaming_state;
595 	__le32 bf_temp_threshold;
596 	__le32 bf_temp_fast_filter;
597 	__le32 bf_temp_slow_filter;
598 	__le32 bf_enable_beacon_filter;
599 	__le32 bf_debug_flag;
600 	__le32 bf_escape_timer;
601 	__le32 ba_escape_timer;
602 	__le32 ba_enable_beacon_abort;
603 	__le32 bf_threshold_absolute_low[2];
604 	__le32 bf_threshold_absolute_high[2];
605 } __packed; /* BEACON_FILTER_CONFIG_API_S_VER_4 */
606 
607 /* Beacon filtering and beacon abort */
608 #define IWL_BF_ENERGY_DELTA_DEFAULT 5
609 #define IWL_BF_ENERGY_DELTA_D0I3 20
610 #define IWL_BF_ENERGY_DELTA_MAX 255
611 #define IWL_BF_ENERGY_DELTA_MIN 0
612 
613 #define IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT 1
614 #define IWL_BF_ROAMING_ENERGY_DELTA_D0I3 20
615 #define IWL_BF_ROAMING_ENERGY_DELTA_MAX 255
616 #define IWL_BF_ROAMING_ENERGY_DELTA_MIN 0
617 
618 #define IWL_BF_ROAMING_STATE_DEFAULT 72
619 #define IWL_BF_ROAMING_STATE_D0I3 72
620 #define IWL_BF_ROAMING_STATE_MAX 255
621 #define IWL_BF_ROAMING_STATE_MIN 0
622 
623 #define IWL_BF_TEMP_THRESHOLD_DEFAULT 112
624 #define IWL_BF_TEMP_THRESHOLD_D0I3 112
625 #define IWL_BF_TEMP_THRESHOLD_MAX 255
626 #define IWL_BF_TEMP_THRESHOLD_MIN 0
627 
628 #define IWL_BF_TEMP_FAST_FILTER_DEFAULT 1
629 #define IWL_BF_TEMP_FAST_FILTER_D0I3 1
630 #define IWL_BF_TEMP_FAST_FILTER_MAX 255
631 #define IWL_BF_TEMP_FAST_FILTER_MIN 0
632 
633 #define IWL_BF_TEMP_SLOW_FILTER_DEFAULT 5
634 #define IWL_BF_TEMP_SLOW_FILTER_D0I3 20
635 #define IWL_BF_TEMP_SLOW_FILTER_MAX 255
636 #define IWL_BF_TEMP_SLOW_FILTER_MIN 0
637 
638 #define IWL_BF_ENABLE_BEACON_FILTER_DEFAULT 1
639 
640 #define IWL_BF_DEBUG_FLAG_DEFAULT 0
641 #define IWL_BF_DEBUG_FLAG_D0I3 0
642 
643 #define IWL_BF_ESCAPE_TIMER_DEFAULT 0
644 #define IWL_BF_ESCAPE_TIMER_D0I3 0
645 #define IWL_BF_ESCAPE_TIMER_MAX 1024
646 #define IWL_BF_ESCAPE_TIMER_MIN 0
647 
648 #define IWL_BA_ESCAPE_TIMER_DEFAULT 6
649 #define IWL_BA_ESCAPE_TIMER_D0I3 6
650 #define IWL_BA_ESCAPE_TIMER_D3 9
651 #define IWL_BA_ESCAPE_TIMER_MAX 1024
652 #define IWL_BA_ESCAPE_TIMER_MIN 0
653 
654 #define IWL_BA_ENABLE_BEACON_ABORT_DEFAULT 1
655 
656 #define IWL_BF_CMD_CONFIG(mode)					     \
657 	.bf_energy_delta = cpu_to_le32(IWL_BF_ENERGY_DELTA ## mode),	      \
658 	.bf_roaming_energy_delta =					      \
659 		cpu_to_le32(IWL_BF_ROAMING_ENERGY_DELTA ## mode),	      \
660 	.bf_roaming_state = cpu_to_le32(IWL_BF_ROAMING_STATE ## mode),	      \
661 	.bf_temp_threshold = cpu_to_le32(IWL_BF_TEMP_THRESHOLD ## mode),      \
662 	.bf_temp_fast_filter = cpu_to_le32(IWL_BF_TEMP_FAST_FILTER ## mode),  \
663 	.bf_temp_slow_filter = cpu_to_le32(IWL_BF_TEMP_SLOW_FILTER ## mode),  \
664 	.bf_debug_flag = cpu_to_le32(IWL_BF_DEBUG_FLAG ## mode),	      \
665 	.bf_escape_timer = cpu_to_le32(IWL_BF_ESCAPE_TIMER ## mode),	      \
666 	.ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER ## mode)
667 
668 #define IWL_BF_CMD_CONFIG_DEFAULTS IWL_BF_CMD_CONFIG(_DEFAULT)
669 #define IWL_BF_CMD_CONFIG_D0I3 IWL_BF_CMD_CONFIG(_D0I3)
670 #endif /* __iwl_fw_api_power_h__ */
671