1 /******************************************************************************
2  *
3  * This file is provided under a dual BSD/GPLv2 license.  When using or
4  * redistributing this file, you may do so under either license.
5  *
6  * GPL LICENSE SUMMARY
7  *
8  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
10  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
11  * Copyright (C) 2018 - 2019 Intel Corporation
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of version 2 of the GNU General Public License as
15  * published by the Free Software Foundation.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * General Public License for more details.
21  *
22  * The full GNU General Public License is included in this distribution
23  * in the file called COPYING.
24  *
25  * Contact Information:
26  *  Intel Linux Wireless <linuxwifi@intel.com>
27  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28  *
29  * BSD LICENSE
30  *
31  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
32  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
33  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
34  * Copyright (C) 2018 - 2019 Intel Corporation
35  * All rights reserved.
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  *
41  *  * Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  *  * Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in
45  *    the documentation and/or other materials provided with the
46  *    distribution.
47  *  * Neither the name Intel Corporation nor the names of its
48  *    contributors may be used to endorse or promote products derived
49  *    from this software without specific prior written permission.
50  *
51  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62  *
63  *****************************************************************************/
64 
65 #ifndef __iwl_fw_api_power_h__
66 #define __iwl_fw_api_power_h__
67 
68 /* Power Management Commands, Responses, Notifications */
69 
70 /**
71  * enum iwl_ltr_config_flags - masks for LTR config command flags
72  * @LTR_CFG_FLAG_FEATURE_ENABLE: Feature operational status
73  * @LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS: allow LTR change on shadow
74  *	memory access
75  * @LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH: allow LTR msg send on ANY LTR
76  *	reg change
77  * @LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3: allow LTR msg send on transition from
78  *	D0 to D3
79  * @LTR_CFG_FLAG_SW_SET_SHORT: fixed static short LTR register
80  * @LTR_CFG_FLAG_SW_SET_LONG: fixed static short LONG register
81  * @LTR_CFG_FLAG_DENIE_C10_ON_PD: allow going into C10 on PD
82  * @LTR_CFG_FLAG_UPDATE_VALUES: update config values and short
83  *	idle timeout
84  */
85 enum iwl_ltr_config_flags {
86 	LTR_CFG_FLAG_FEATURE_ENABLE = BIT(0),
87 	LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS = BIT(1),
88 	LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH = BIT(2),
89 	LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3 = BIT(3),
90 	LTR_CFG_FLAG_SW_SET_SHORT = BIT(4),
91 	LTR_CFG_FLAG_SW_SET_LONG = BIT(5),
92 	LTR_CFG_FLAG_DENIE_C10_ON_PD = BIT(6),
93 	LTR_CFG_FLAG_UPDATE_VALUES = BIT(7),
94 };
95 
96 /**
97  * struct iwl_ltr_config_cmd_v1 - configures the LTR
98  * @flags: See &enum iwl_ltr_config_flags
99  * @static_long: static LTR Long register value.
100  * @static_short: static LTR Short register value.
101  */
102 struct iwl_ltr_config_cmd_v1 {
103 	__le32 flags;
104 	__le32 static_long;
105 	__le32 static_short;
106 } __packed; /* LTR_CAPABLE_API_S_VER_1 */
107 
108 #define LTR_VALID_STATES_NUM 4
109 
110 /**
111  * struct iwl_ltr_config_cmd - configures the LTR
112  * @flags: See &enum iwl_ltr_config_flags
113  * @static_long: static LTR Long register value.
114  * @static_short: static LTR Short register value.
115  * @ltr_cfg_values: LTR parameters table values (in usec) in folowing order:
116  *	TX, RX, Short Idle, Long Idle. Used only if %LTR_CFG_FLAG_UPDATE_VALUES
117  *	is set.
118  * @ltr_short_idle_timeout: LTR Short Idle timeout (in usec). Used only if
119  *	%LTR_CFG_FLAG_UPDATE_VALUES is set.
120  */
121 struct iwl_ltr_config_cmd {
122 	__le32 flags;
123 	__le32 static_long;
124 	__le32 static_short;
125 	__le32 ltr_cfg_values[LTR_VALID_STATES_NUM];
126 	__le32 ltr_short_idle_timeout;
127 } __packed; /* LTR_CAPABLE_API_S_VER_2 */
128 
129 /* Radio LP RX Energy Threshold measured in dBm */
130 #define POWER_LPRX_RSSI_THRESHOLD	75
131 #define POWER_LPRX_RSSI_THRESHOLD_MAX	94
132 #define POWER_LPRX_RSSI_THRESHOLD_MIN	30
133 
134 /**
135  * enum iwl_power_flags - masks for power table command flags
136  * @POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
137  *		receiver and transmitter. '0' - does not allow.
138  * @POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management,
139  *		'1' Driver enables PM (use rest of parameters)
140  * @POWER_FLAGS_SKIP_OVER_DTIM_MSK: '0' PM have to walk up every DTIM,
141  *		'1' PM could sleep over DTIM till listen Interval.
142  * @POWER_FLAGS_SNOOZE_ENA_MSK: Enable snoozing only if uAPSD is enabled and all
143  *		access categories are both delivery and trigger enabled.
144  * @POWER_FLAGS_BT_SCO_ENA: Enable BT SCO coex only if uAPSD and
145  *		PBW Snoozing enabled
146  * @POWER_FLAGS_ADVANCE_PM_ENA_MSK: Advanced PM (uAPSD) enable mask
147  * @POWER_FLAGS_LPRX_ENA_MSK: Low Power RX enable.
148  * @POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK: AP/GO's uAPSD misbehaving
149  *		detection enablement
150 */
151 enum iwl_power_flags {
152 	POWER_FLAGS_POWER_SAVE_ENA_MSK		= BIT(0),
153 	POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK	= BIT(1),
154 	POWER_FLAGS_SKIP_OVER_DTIM_MSK		= BIT(2),
155 	POWER_FLAGS_SNOOZE_ENA_MSK		= BIT(5),
156 	POWER_FLAGS_BT_SCO_ENA			= BIT(8),
157 	POWER_FLAGS_ADVANCE_PM_ENA_MSK		= BIT(9),
158 	POWER_FLAGS_LPRX_ENA_MSK		= BIT(11),
159 	POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK	= BIT(12),
160 };
161 
162 #define IWL_POWER_VEC_SIZE 5
163 
164 /**
165  * struct iwl_powertable_cmd - legacy power command. Beside old API support this
166  *	is used also with a new	power API for device wide power settings.
167  * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
168  *
169  * @flags:		Power table command flags from POWER_FLAGS_*
170  * @keep_alive_seconds: Keep alive period in seconds. Default - 25 sec.
171  *			Minimum allowed:- 3 * DTIM. Keep alive period must be
172  *			set regardless of power scheme or current power state.
173  *			FW use this value also when PM is disabled.
174  * @debug_flags:	debug flags
175  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
176  *			PSM transition - legacy PM
177  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
178  *			PSM transition - legacy PM
179  * @sleep_interval:	not in use
180  * @skip_dtim_periods:	Number of DTIM periods to skip if Skip over DTIM flag
181  *			is set. For example, if it is required to skip over
182  *			one DTIM, this value need to be set to 2 (DTIM periods).
183  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
184  *			Default: 80dbm
185  */
186 struct iwl_powertable_cmd {
187 	/* PM_POWER_TABLE_CMD_API_S_VER_6 */
188 	__le16 flags;
189 	u8 keep_alive_seconds;
190 	u8 debug_flags;
191 	__le32 rx_data_timeout;
192 	__le32 tx_data_timeout;
193 	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
194 	__le32 skip_dtim_periods;
195 	__le32 lprx_rssi_threshold;
196 } __packed;
197 
198 /**
199  * enum iwl_device_power_flags - masks for device power command flags
200  * @DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK:
201  *	'1' Allow to save power by turning off
202  *	receiver and transmitter. '0' - does not allow.
203  * @DEVICE_POWER_FLAGS_ALLOW_MEM_RETENTION_MSK:
204  *	Device Retention indication, '1' indicate retention is enabled.
205  * @DEVICE_POWER_FLAGS_32K_CLK_VALID_MSK:
206  *	32Khz external slow clock valid indication, '1' indicate cloack is
207  *	valid.
208 */
209 enum iwl_device_power_flags {
210 	DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK		= BIT(0),
211 	DEVICE_POWER_FLAGS_ALLOW_MEM_RETENTION_MSK	= BIT(1),
212 	DEVICE_POWER_FLAGS_32K_CLK_VALID_MSK		= BIT(12),
213 };
214 
215 /**
216  * struct iwl_device_power_cmd - device wide power command.
217  * DEVICE_POWER_CMD = 0x77 (command, has simple generic response)
218  *
219  * @flags:	Power table command flags from &enum iwl_device_power_flags
220  * @reserved: reserved (padding)
221  */
222 struct iwl_device_power_cmd {
223 	/* PM_POWER_TABLE_CMD_API_S_VER_6 */
224 	__le16 flags;
225 	__le16 reserved;
226 } __packed;
227 
228 /**
229  * struct iwl_mac_power_cmd - New power command containing uAPSD support
230  * MAC_PM_POWER_TABLE = 0xA9 (command, has simple generic response)
231  * @id_and_color:	MAC contex identifier, &enum iwl_ctxt_id_and_color
232  * @flags:		Power table command flags from POWER_FLAGS_*
233  * @keep_alive_seconds:	Keep alive period in seconds. Default - 25 sec.
234  *			Minimum allowed:- 3 * DTIM. Keep alive period must be
235  *			set regardless of power scheme or current power state.
236  *			FW use this value also when PM is disabled.
237  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
238  *			PSM transition - legacy PM
239  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
240  *			PSM transition - legacy PM
241  * @skip_dtim_periods:	Number of DTIM periods to skip if Skip over DTIM flag
242  *			is set. For example, if it is required to skip over
243  *			one DTIM, this value need to be set to 2 (DTIM periods).
244  * @rx_data_timeout_uapsd: Minimum time (usec) from last Rx packet for AM to
245  *			PSM transition - uAPSD
246  * @tx_data_timeout_uapsd: Minimum time (usec) from last Tx packet for AM to
247  *			PSM transition - uAPSD
248  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
249  *			Default: 80dbm
250  * @snooze_interval:	Maximum time between attempts to retrieve buffered data
251  *			from the AP [msec]
252  * @snooze_window:	A window of time in which PBW snoozing insures that all
253  *			packets received. It is also the minimum time from last
254  *			received unicast RX packet, before client stops snoozing
255  *			for data. [msec]
256  * @snooze_step:	TBD
257  * @qndp_tid:		TID client shall use for uAPSD QNDP triggers
258  * @uapsd_ac_flags:	Set trigger-enabled and delivery-enabled indication for
259  *			each corresponding AC.
260  *			Use IEEE80211_WMM_IE_STA_QOSINFO_AC* for correct values.
261  * @uapsd_max_sp:	Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct
262  *			values.
263  * @heavy_tx_thld_packets:	TX threshold measured in number of packets
264  * @heavy_rx_thld_packets:	RX threshold measured in number of packets
265  * @heavy_tx_thld_percentage:	TX threshold measured in load's percentage
266  * @heavy_rx_thld_percentage:	RX threshold measured in load's percentage
267  * @limited_ps_threshold: (unused)
268  * @reserved: reserved (padding)
269  */
270 struct iwl_mac_power_cmd {
271 	/* CONTEXT_DESC_API_T_VER_1 */
272 	__le32 id_and_color;
273 
274 	/* CLIENT_PM_POWER_TABLE_S_VER_1 */
275 	__le16 flags;
276 	__le16 keep_alive_seconds;
277 	__le32 rx_data_timeout;
278 	__le32 tx_data_timeout;
279 	__le32 rx_data_timeout_uapsd;
280 	__le32 tx_data_timeout_uapsd;
281 	u8 lprx_rssi_threshold;
282 	u8 skip_dtim_periods;
283 	__le16 snooze_interval;
284 	__le16 snooze_window;
285 	u8 snooze_step;
286 	u8 qndp_tid;
287 	u8 uapsd_ac_flags;
288 	u8 uapsd_max_sp;
289 	u8 heavy_tx_thld_packets;
290 	u8 heavy_rx_thld_packets;
291 	u8 heavy_tx_thld_percentage;
292 	u8 heavy_rx_thld_percentage;
293 	u8 limited_ps_threshold;
294 	u8 reserved;
295 } __packed;
296 
297 /*
298  * struct iwl_uapsd_misbehaving_ap_notif - FW sends this notification when
299  * associated AP is identified as improperly implementing uAPSD protocol.
300  * PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78
301  * @sta_id: index of station in uCode's station table - associated AP ID in
302  *	    this context.
303  */
304 struct iwl_uapsd_misbehaving_ap_notif {
305 	__le32 sta_id;
306 	u8 mac_id;
307 	u8 reserved[3];
308 } __packed;
309 
310 /**
311  * struct iwl_reduce_tx_power_cmd - TX power reduction command
312  * REDUCE_TX_POWER_CMD = 0x9f
313  * @flags: (reserved for future implementation)
314  * @mac_context_id: id of the mac ctx for which we are reducing TX power.
315  * @pwr_restriction: TX power restriction in dBms.
316  */
317 struct iwl_reduce_tx_power_cmd {
318 	u8 flags;
319 	u8 mac_context_id;
320 	__le16 pwr_restriction;
321 } __packed; /* TX_REDUCED_POWER_API_S_VER_1 */
322 
323 enum iwl_dev_tx_power_cmd_mode {
324 	IWL_TX_POWER_MODE_SET_MAC = 0,
325 	IWL_TX_POWER_MODE_SET_DEVICE = 1,
326 	IWL_TX_POWER_MODE_SET_CHAINS = 2,
327 	IWL_TX_POWER_MODE_SET_ACK = 3,
328 	IWL_TX_POWER_MODE_SET_SAR_TIMER = 4,
329 	IWL_TX_POWER_MODE_SET_SAR_TIMER_DEFAULT_TABLE = 5,
330 }; /* TX_POWER_REDUCED_FLAGS_TYPE_API_E_VER_5 */;
331 
332 #define IWL_NUM_CHAIN_LIMITS	2
333 #define IWL_NUM_SUB_BANDS	5
334 
335 /**
336  * struct iwl_dev_tx_power_cmd - TX power reduction command
337  * @set_mode: see &enum iwl_dev_tx_power_cmd_mode
338  * @mac_context_id: id of the mac ctx for which we are reducing TX power.
339  * @pwr_restriction: TX power restriction in 1/8 dBms.
340  * @dev_24: device TX power restriction in 1/8 dBms
341  * @dev_52_low: device TX power restriction upper band - low
342  * @dev_52_high: device TX power restriction upper band - high
343  * @per_chain_restriction: per chain restrictions
344  */
345 struct iwl_dev_tx_power_cmd_v3 {
346 	__le32 set_mode;
347 	__le32 mac_context_id;
348 	__le16 pwr_restriction;
349 	__le16 dev_24;
350 	__le16 dev_52_low;
351 	__le16 dev_52_high;
352 	__le16 per_chain_restriction[IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS];
353 } __packed; /* TX_REDUCED_POWER_API_S_VER_3 */
354 
355 #define IWL_DEV_MAX_TX_POWER 0x7FFF
356 
357 /**
358  * struct iwl_dev_tx_power_cmd - TX power reduction command
359  * @v3: version 3 of the command, embedded here for easier software handling
360  * @enable_ack_reduction: enable or disable close range ack TX power
361  *	reduction.
362  * @reserved: reserved (padding)
363  */
364 struct iwl_dev_tx_power_cmd_v4 {
365 	/* v4 is just an extension of v3 - keep this here */
366 	struct iwl_dev_tx_power_cmd_v3 v3;
367 	u8 enable_ack_reduction;
368 	u8 reserved[3];
369 } __packed; /* TX_REDUCED_POWER_API_S_VER_4 */
370 
371 /**
372  * struct iwl_dev_tx_power_cmd - TX power reduction command
373  * @v3: version 3 of the command, embedded here for easier software handling
374  * @enable_ack_reduction: enable or disable close range ack TX power
375  *	reduction.
376  * @per_chain_restriction_changed: is per_chain_restriction has changed
377  *	from last command. used if set_mode is
378  *	IWL_TX_POWER_MODE_SET_SAR_TIMER.
379  *	note: if not changed, the command is used for keep alive only.
380  * @reserved: reserved (padding)
381  * @timer_period: timer in milliseconds. if expires FW will change to default
382  *	BIOS values. relevant if setMode is IWL_TX_POWER_MODE_SET_SAR_TIMER
383  */
384 struct iwl_dev_tx_power_cmd {
385 	/* v5 is just an extension of v3 - keep this here */
386 	struct iwl_dev_tx_power_cmd_v3 v3;
387 	u8 enable_ack_reduction;
388 	u8 per_chain_restriction_changed;
389 	u8 reserved[2];
390 	__le32 timer_period;
391 } __packed; /* TX_REDUCED_POWER_API_S_VER_5 */
392 
393 #define IWL_NUM_GEO_PROFILES   3
394 
395 /**
396  * enum iwl_geo_per_chain_offset_operation - type of operation
397  * @IWL_PER_CHAIN_OFFSET_SET_TABLES: send the tables from the host to the FW.
398  * @IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE: retrieve the last configured table.
399  */
400 enum iwl_geo_per_chain_offset_operation {
401 	IWL_PER_CHAIN_OFFSET_SET_TABLES,
402 	IWL_PER_CHAIN_OFFSET_GET_CURRENT_TABLE,
403 };  /* GEO_TX_POWER_LIMIT FLAGS TYPE */
404 
405 /**
406  * struct iwl_per_chain_offset - embedded struct for GEO_TX_POWER_LIMIT.
407  * @max_tx_power: maximum allowed tx power.
408  * @chain_a: tx power offset for chain a.
409  * @chain_b: tx power offset for chain b.
410  */
411 struct iwl_per_chain_offset {
412 	__le16 max_tx_power;
413 	u8 chain_a;
414 	u8 chain_b;
415 } __packed; /* PER_CHAIN_LIMIT_OFFSET_PER_CHAIN_S_VER_1 */
416 
417 struct iwl_per_chain_offset_group {
418 	struct iwl_per_chain_offset lb;
419 	struct iwl_per_chain_offset hb;
420 } __packed; /* PER_CHAIN_LIMIT_OFFSET_GROUP_S_VER_1 */
421 
422 /**
423  * struct iwl_geo_tx_power_profile_cmd_v1 - struct for GEO_TX_POWER_LIMIT cmd.
424  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
425  * @table: offset profile per band.
426  */
427 struct iwl_geo_tx_power_profiles_cmd_v1 {
428 	__le32 ops;
429 	struct iwl_per_chain_offset_group table[IWL_NUM_GEO_PROFILES];
430 } __packed; /* GEO_TX_POWER_LIMIT_VER_1 */
431 
432 /**
433  * struct iwl_geo_tx_power_profile_cmd - struct for GEO_TX_POWER_LIMIT cmd.
434  * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation
435  * @table: offset profile per band.
436  * @table_revision: BIOS table revision.
437  */
438 struct iwl_geo_tx_power_profiles_cmd {
439 	__le32 ops;
440 	struct iwl_per_chain_offset_group table[IWL_NUM_GEO_PROFILES];
441 	__le32 table_revision;
442 } __packed; /* GEO_TX_POWER_LIMIT */
443 
444 /**
445  * struct iwl_geo_tx_power_profiles_resp -  response to GEO_TX_POWER_LIMIT cmd
446  * @profile_idx: current geo profile in use
447  */
448 struct iwl_geo_tx_power_profiles_resp {
449 	__le32 profile_idx;
450 } __packed; /* GEO_TX_POWER_LIMIT_RESP */
451 
452 /**
453  * struct iwl_beacon_filter_cmd
454  * REPLY_BEACON_FILTERING_CMD = 0xd2 (command)
455  * @bf_energy_delta: Used for RSSI filtering, if in 'normal' state. Send beacon
456  *      to driver if delta in Energy values calculated for this and last
457  *      passed beacon is greater than this threshold. Zero value means that
458  *      the Energy change is ignored for beacon filtering, and beacon will
459  *      not be forced to be sent to driver regardless of this delta. Typical
460  *      energy delta 5dB.
461  * @bf_roaming_energy_delta: Used for RSSI filtering, if in 'roaming' state.
462  *      Send beacon to driver if delta in Energy values calculated for this
463  *      and last passed beacon is greater than this threshold. Zero value
464  *      means that the Energy change is ignored for beacon filtering while in
465  *      Roaming state, typical energy delta 1dB.
466  * @bf_roaming_state: Used for RSSI filtering. If absolute Energy values
467  *      calculated for current beacon is less than the threshold, use
468  *      Roaming Energy Delta Threshold, otherwise use normal Energy Delta
469  *      Threshold. Typical energy threshold is -72dBm.
470  * @bf_temp_threshold: This threshold determines the type of temperature
471  *	filtering (Slow or Fast) that is selected (Units are in Celsuis):
472  *	If the current temperature is above this threshold - Fast filter
473  *	will be used, If the current temperature is below this threshold -
474  *	Slow filter will be used.
475  * @bf_temp_fast_filter: Send Beacon to driver if delta in temperature values
476  *      calculated for this and the last passed beacon is greater than this
477  *      threshold. Zero value means that the temperature change is ignored for
478  *      beacon filtering; beacons will not be  forced to be sent to driver
479  *      regardless of whether its temerature has been changed.
480  * @bf_temp_slow_filter: Send Beacon to driver if delta in temperature values
481  *      calculated for this and the last passed beacon is greater than this
482  *      threshold. Zero value means that the temperature change is ignored for
483  *      beacon filtering; beacons will not be forced to be sent to driver
484  *      regardless of whether its temerature has been changed.
485  * @bf_enable_beacon_filter: 1, beacon filtering is enabled; 0, disabled.
486  * @bf_debug_flag: beacon filtering debug configuration
487  * @bf_escape_timer: Send beacons to to driver if no beacons were passed
488  *      for a specific period of time. Units: Beacons.
489  * @ba_escape_timer: Fully receive and parse beacon if no beacons were passed
490  *      for a longer period of time then this escape-timeout. Units: Beacons.
491  * @ba_enable_beacon_abort: 1, beacon abort is enabled; 0, disabled.
492  * @bf_threshold_absolute_low: See below.
493  * @bf_threshold_absolute_high: Send Beacon to driver if Energy value calculated
494  *      for this beacon crossed this absolute threshold. For the 'Increase'
495  *      direction the bf_energy_absolute_low[i] is used. For the 'Decrease'
496  *      direction the bf_energy_absolute_high[i] is used. Zero value means
497  *      that this specific threshold is ignored for beacon filtering, and
498  *      beacon will not be forced to be sent to driver due to this setting.
499  */
500 struct iwl_beacon_filter_cmd {
501 	__le32 bf_energy_delta;
502 	__le32 bf_roaming_energy_delta;
503 	__le32 bf_roaming_state;
504 	__le32 bf_temp_threshold;
505 	__le32 bf_temp_fast_filter;
506 	__le32 bf_temp_slow_filter;
507 	__le32 bf_enable_beacon_filter;
508 	__le32 bf_debug_flag;
509 	__le32 bf_escape_timer;
510 	__le32 ba_escape_timer;
511 	__le32 ba_enable_beacon_abort;
512 	__le32 bf_threshold_absolute_low[2];
513 	__le32 bf_threshold_absolute_high[2];
514 } __packed; /* BEACON_FILTER_CONFIG_API_S_VER_4 */
515 
516 /* Beacon filtering and beacon abort */
517 #define IWL_BF_ENERGY_DELTA_DEFAULT 5
518 #define IWL_BF_ENERGY_DELTA_D0I3 20
519 #define IWL_BF_ENERGY_DELTA_MAX 255
520 #define IWL_BF_ENERGY_DELTA_MIN 0
521 
522 #define IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT 1
523 #define IWL_BF_ROAMING_ENERGY_DELTA_D0I3 20
524 #define IWL_BF_ROAMING_ENERGY_DELTA_MAX 255
525 #define IWL_BF_ROAMING_ENERGY_DELTA_MIN 0
526 
527 #define IWL_BF_ROAMING_STATE_DEFAULT 72
528 #define IWL_BF_ROAMING_STATE_D0I3 72
529 #define IWL_BF_ROAMING_STATE_MAX 255
530 #define IWL_BF_ROAMING_STATE_MIN 0
531 
532 #define IWL_BF_TEMP_THRESHOLD_DEFAULT 112
533 #define IWL_BF_TEMP_THRESHOLD_D0I3 112
534 #define IWL_BF_TEMP_THRESHOLD_MAX 255
535 #define IWL_BF_TEMP_THRESHOLD_MIN 0
536 
537 #define IWL_BF_TEMP_FAST_FILTER_DEFAULT 1
538 #define IWL_BF_TEMP_FAST_FILTER_D0I3 1
539 #define IWL_BF_TEMP_FAST_FILTER_MAX 255
540 #define IWL_BF_TEMP_FAST_FILTER_MIN 0
541 
542 #define IWL_BF_TEMP_SLOW_FILTER_DEFAULT 5
543 #define IWL_BF_TEMP_SLOW_FILTER_D0I3 20
544 #define IWL_BF_TEMP_SLOW_FILTER_MAX 255
545 #define IWL_BF_TEMP_SLOW_FILTER_MIN 0
546 
547 #define IWL_BF_ENABLE_BEACON_FILTER_DEFAULT 1
548 
549 #define IWL_BF_DEBUG_FLAG_DEFAULT 0
550 #define IWL_BF_DEBUG_FLAG_D0I3 0
551 
552 #define IWL_BF_ESCAPE_TIMER_DEFAULT 0
553 #define IWL_BF_ESCAPE_TIMER_D0I3 0
554 #define IWL_BF_ESCAPE_TIMER_MAX 1024
555 #define IWL_BF_ESCAPE_TIMER_MIN 0
556 
557 #define IWL_BA_ESCAPE_TIMER_DEFAULT 6
558 #define IWL_BA_ESCAPE_TIMER_D0I3 6
559 #define IWL_BA_ESCAPE_TIMER_D3 9
560 #define IWL_BA_ESCAPE_TIMER_MAX 1024
561 #define IWL_BA_ESCAPE_TIMER_MIN 0
562 
563 #define IWL_BA_ENABLE_BEACON_ABORT_DEFAULT 1
564 
565 #define IWL_BF_CMD_CONFIG(mode)					     \
566 	.bf_energy_delta = cpu_to_le32(IWL_BF_ENERGY_DELTA ## mode),	      \
567 	.bf_roaming_energy_delta =					      \
568 		cpu_to_le32(IWL_BF_ROAMING_ENERGY_DELTA ## mode),	      \
569 	.bf_roaming_state = cpu_to_le32(IWL_BF_ROAMING_STATE ## mode),	      \
570 	.bf_temp_threshold = cpu_to_le32(IWL_BF_TEMP_THRESHOLD ## mode),      \
571 	.bf_temp_fast_filter = cpu_to_le32(IWL_BF_TEMP_FAST_FILTER ## mode),  \
572 	.bf_temp_slow_filter = cpu_to_le32(IWL_BF_TEMP_SLOW_FILTER ## mode),  \
573 	.bf_debug_flag = cpu_to_le32(IWL_BF_DEBUG_FLAG ## mode),	      \
574 	.bf_escape_timer = cpu_to_le32(IWL_BF_ESCAPE_TIMER ## mode),	      \
575 	.ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER ## mode)
576 
577 #define IWL_BF_CMD_CONFIG_DEFAULTS IWL_BF_CMD_CONFIG(_DEFAULT)
578 #define IWL_BF_CMD_CONFIG_D0I3 IWL_BF_CMD_CONFIG(_D0I3)
579 #endif /* __iwl_fw_api_power_h__ */
580