Merge tag 'backport/v3.14.24-ltsi-rc1/phy-rcar-gen2-usb-to-v3.15' into backport/v3...
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / net / wireless / iwlwifi / mvm / fw-api-power.h
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  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of version 2 of the GNU General Public License as
12  * published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22  * USA
23  *
24  * The full GNU General Public License is included in this distribution
25  * in the file called COPYING.
26  *
27  * Contact Information:
28  *  Intel Linux Wireless <ilw@linux.intel.com>
29  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30  *
31  * BSD LICENSE
32  *
33  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
34  * All rights reserved.
35  *
36  * Redistribution and use in source and binary forms, with or without
37  * modification, are permitted provided that the following conditions
38  * are met:
39  *
40  *  * Redistributions of source code must retain the above copyright
41  *    notice, this list of conditions and the following disclaimer.
42  *  * Redistributions in binary form must reproduce the above copyright
43  *    notice, this list of conditions and the following disclaimer in
44  *    the documentation and/or other materials provided with the
45  *    distribution.
46  *  * Neither the name Intel Corporation nor the names of its
47  *    contributors may be used to endorse or promote products derived
48  *    from this software without specific prior written permission.
49  *
50  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61  *
62  *****************************************************************************/
63
64 #ifndef __fw_api_power_h__
65 #define __fw_api_power_h__
66
67 /* Power Management Commands, Responses, Notifications */
68
69 /**
70  * enum iwl_ltr_config_flags - masks for LTR config command flags
71  * @LTR_CFG_FLAG_FEATURE_ENABLE: Feature operational status
72  * @LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS: allow LTR change on shadow
73  *      memory access
74  * @LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH: allow LTR msg send on ANY LTR
75  *      reg change
76  * @LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3: allow LTR msg send on transition from
77  *      D0 to D3
78  * @LTR_CFG_FLAG_SW_SET_SHORT: fixed static short LTR register
79  * @LTR_CFG_FLAG_SW_SET_LONG: fixed static short LONG register
80  * @LTR_CFG_FLAG_DENIE_C10_ON_PD: allow going into C10 on PD
81  */
82 enum iwl_ltr_config_flags {
83         LTR_CFG_FLAG_FEATURE_ENABLE = BIT(0),
84         LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS = BIT(1),
85         LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH = BIT(2),
86         LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3 = BIT(3),
87         LTR_CFG_FLAG_SW_SET_SHORT = BIT(4),
88         LTR_CFG_FLAG_SW_SET_LONG = BIT(5),
89         LTR_CFG_FLAG_DENIE_C10_ON_PD = BIT(6),
90 };
91
92 /**
93  * struct iwl_ltr_config_cmd - configures the LTR
94  * @flags: See %enum iwl_ltr_config_flags
95  */
96 struct iwl_ltr_config_cmd {
97         __le32 flags;
98         __le32 static_long;
99         __le32 static_short;
100 } __packed;
101
102 /* Radio LP RX Energy Threshold measured in dBm */
103 #define POWER_LPRX_RSSI_THRESHOLD       75
104 #define POWER_LPRX_RSSI_THRESHOLD_MAX   94
105 #define POWER_LPRX_RSSI_THRESHOLD_MIN   30
106
107 /**
108  * enum iwl_power_flags - masks for power table command flags
109  * @POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
110  *              receiver and transmitter. '0' - does not allow.
111  * @POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management,
112  *              '1' Driver enables PM (use rest of parameters)
113  * @POWER_FLAGS_SKIP_OVER_DTIM_MSK: '0' PM have to walk up every DTIM,
114  *              '1' PM could sleep over DTIM till listen Interval.
115  * @POWER_FLAGS_SNOOZE_ENA_MSK: Enable snoozing only if uAPSD is enabled and all
116  *              access categories are both delivery and trigger enabled.
117  * @POWER_FLAGS_BT_SCO_ENA: Enable BT SCO coex only if uAPSD and
118  *              PBW Snoozing enabled
119  * @POWER_FLAGS_ADVANCE_PM_ENA_MSK: Advanced PM (uAPSD) enable mask
120  * @POWER_FLAGS_LPRX_ENA_MSK: Low Power RX enable.
121  * @POWER_FLAGS_AP_UAPSD_MISBEHAVING_ENA_MSK: AP/GO's uAPSD misbehaving
122  *              detection enablement
123 */
124 enum iwl_power_flags {
125         POWER_FLAGS_POWER_SAVE_ENA_MSK          = BIT(0),
126         POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK    = BIT(1),
127         POWER_FLAGS_SKIP_OVER_DTIM_MSK          = BIT(2),
128         POWER_FLAGS_SNOOZE_ENA_MSK              = BIT(5),
129         POWER_FLAGS_BT_SCO_ENA                  = BIT(8),
130         POWER_FLAGS_ADVANCE_PM_ENA_MSK          = BIT(9),
131         POWER_FLAGS_LPRX_ENA_MSK                = BIT(11),
132         POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK   = BIT(12),
133 };
134
135 #define IWL_POWER_VEC_SIZE 5
136
137 /**
138  * struct iwl_powertable_cmd - legacy power command. Beside old API support this
139  *      is used also with a new power API for device wide power settings.
140  * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
141  *
142  * @flags:              Power table command flags from POWER_FLAGS_*
143  * @keep_alive_seconds: Keep alive period in seconds. Default - 25 sec.
144  *                      Minimum allowed:- 3 * DTIM. Keep alive period must be
145  *                      set regardless of power scheme or current power state.
146  *                      FW use this value also when PM is disabled.
147  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
148  *                      PSM transition - legacy PM
149  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
150  *                      PSM transition - legacy PM
151  * @sleep_interval:     not in use
152  * @skip_dtim_periods:  Number of DTIM periods to skip if Skip over DTIM flag
153  *                      is set. For example, if it is required to skip over
154  *                      one DTIM, this value need to be set to 2 (DTIM periods).
155  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
156  *                      Default: 80dbm
157  */
158 struct iwl_powertable_cmd {
159         /* PM_POWER_TABLE_CMD_API_S_VER_6 */
160         __le16 flags;
161         u8 keep_alive_seconds;
162         u8 debug_flags;
163         __le32 rx_data_timeout;
164         __le32 tx_data_timeout;
165         __le32 sleep_interval[IWL_POWER_VEC_SIZE];
166         __le32 skip_dtim_periods;
167         __le32 lprx_rssi_threshold;
168 } __packed;
169
170 /**
171  * enum iwl_device_power_flags - masks for device power command flags
172  * @DEVIC_POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
173  *      receiver and transmitter. '0' - does not allow. This flag should be
174  *      always set to '1' unless one need to disable actual power down for debug
175  *      purposes.
176  * @DEVICE_POWER_FLAGS_CAM_MSK: '1' CAM (Continuous Active Mode) is set, meaning
177  *      that power management is disabled. '0' Power management is enabled, one
178  *      of power schemes is applied.
179 */
180 enum iwl_device_power_flags {
181         DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK   = BIT(0),
182         DEVICE_POWER_FLAGS_CAM_MSK              = BIT(13),
183 };
184
185 /**
186  * struct iwl_device_power_cmd - device wide power command.
187  * DEVICE_POWER_CMD = 0x77 (command, has simple generic response)
188  *
189  * @flags:      Power table command flags from DEVICE_POWER_FLAGS_*
190  */
191 struct iwl_device_power_cmd {
192         /* PM_POWER_TABLE_CMD_API_S_VER_6 */
193         __le16 flags;
194         __le16 reserved;
195 } __packed;
196
197 /**
198  * struct iwl_mac_power_cmd - New power command containing uAPSD support
199  * MAC_PM_POWER_TABLE = 0xA9 (command, has simple generic response)
200  * @id_and_color:       MAC contex identifier
201  * @flags:              Power table command flags from POWER_FLAGS_*
202  * @keep_alive_seconds: Keep alive period in seconds. Default - 25 sec.
203  *                      Minimum allowed:- 3 * DTIM. Keep alive period must be
204  *                      set regardless of power scheme or current power state.
205  *                      FW use this value also when PM is disabled.
206  * @rx_data_timeout:    Minimum time (usec) from last Rx packet for AM to
207  *                      PSM transition - legacy PM
208  * @tx_data_timeout:    Minimum time (usec) from last Tx packet for AM to
209  *                      PSM transition - legacy PM
210  * @sleep_interval:     not in use
211  * @skip_dtim_periods:  Number of DTIM periods to skip if Skip over DTIM flag
212  *                      is set. For example, if it is required to skip over
213  *                      one DTIM, this value need to be set to 2 (DTIM periods).
214  * @rx_data_timeout_uapsd: Minimum time (usec) from last Rx packet for AM to
215  *                      PSM transition - uAPSD
216  * @tx_data_timeout_uapsd: Minimum time (usec) from last Tx packet for AM to
217  *                      PSM transition - uAPSD
218  * @lprx_rssi_threshold: Signal strength up to which LP RX can be enabled.
219  *                      Default: 80dbm
220  * @num_skip_dtim:      Number of DTIMs to skip if Skip over DTIM flag is set
221  * @snooze_interval:    Maximum time between attempts to retrieve buffered data
222  *                      from the AP [msec]
223  * @snooze_window:      A window of time in which PBW snoozing insures that all
224  *                      packets received. It is also the minimum time from last
225  *                      received unicast RX packet, before client stops snoozing
226  *                      for data. [msec]
227  * @snooze_step:        TBD
228  * @qndp_tid:           TID client shall use for uAPSD QNDP triggers
229  * @uapsd_ac_flags:     Set trigger-enabled and delivery-enabled indication for
230  *                      each corresponding AC.
231  *                      Use IEEE80211_WMM_IE_STA_QOSINFO_AC* for correct values.
232  * @uapsd_max_sp:       Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct
233  *                      values.
234  * @heavy_tx_thld_packets:      TX threshold measured in number of packets
235  * @heavy_rx_thld_packets:      RX threshold measured in number of packets
236  * @heavy_tx_thld_percentage:   TX threshold measured in load's percentage
237  * @heavy_rx_thld_percentage:   RX threshold measured in load's percentage
238  * @limited_ps_threshold:
239 */
240 struct iwl_mac_power_cmd {
241         /* CONTEXT_DESC_API_T_VER_1 */
242         __le32 id_and_color;
243
244         /* CLIENT_PM_POWER_TABLE_S_VER_1 */
245         __le16 flags;
246         __le16 keep_alive_seconds;
247         __le32 rx_data_timeout;
248         __le32 tx_data_timeout;
249         __le32 rx_data_timeout_uapsd;
250         __le32 tx_data_timeout_uapsd;
251         u8 lprx_rssi_threshold;
252         u8 skip_dtim_periods;
253         __le16 snooze_interval;
254         __le16 snooze_window;
255         u8 snooze_step;
256         u8 qndp_tid;
257         u8 uapsd_ac_flags;
258         u8 uapsd_max_sp;
259         u8 heavy_tx_thld_packets;
260         u8 heavy_rx_thld_packets;
261         u8 heavy_tx_thld_percentage;
262         u8 heavy_rx_thld_percentage;
263         u8 limited_ps_threshold;
264         u8 reserved;
265 } __packed;
266
267 /*
268  * struct iwl_uapsd_misbehaving_ap_notif - FW sends this notification when
269  * associated AP is identified as improperly implementing uAPSD protocol.
270  * PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78
271  * @sta_id: index of station in uCode's station table - associated AP ID in
272  *          this context.
273  */
274 struct iwl_uapsd_misbehaving_ap_notif {
275         __le32 sta_id;
276         u8 mac_id;
277         u8 reserved[3];
278 } __packed;
279
280 /**
281  * struct iwl_beacon_filter_cmd
282  * REPLY_BEACON_FILTERING_CMD = 0xd2 (command)
283  * @id_and_color: MAC contex identifier
284  * @bf_energy_delta: Used for RSSI filtering, if in 'normal' state. Send beacon
285  *      to driver if delta in Energy values calculated for this and last
286  *      passed beacon is greater than this threshold. Zero value means that
287  *      the Energy change is ignored for beacon filtering, and beacon will
288  *      not be forced to be sent to driver regardless of this delta. Typical
289  *      energy delta 5dB.
290  * @bf_roaming_energy_delta: Used for RSSI filtering, if in 'roaming' state.
291  *      Send beacon to driver if delta in Energy values calculated for this
292  *      and last passed beacon is greater than this threshold. Zero value
293  *      means that the Energy change is ignored for beacon filtering while in
294  *      Roaming state, typical energy delta 1dB.
295  * @bf_roaming_state: Used for RSSI filtering. If absolute Energy values
296  *      calculated for current beacon is less than the threshold, use
297  *      Roaming Energy Delta Threshold, otherwise use normal Energy Delta
298  *      Threshold. Typical energy threshold is -72dBm.
299  * @bf_temp_threshold: This threshold determines the type of temperature
300  *      filtering (Slow or Fast) that is selected (Units are in Celsuis):
301  *      If the current temperature is above this threshold - Fast filter
302  *      will be used, If the current temperature is below this threshold -
303  *      Slow filter will be used.
304  * @bf_temp_fast_filter: Send Beacon to driver if delta in temperature values
305  *      calculated for this and the last passed beacon is greater than this
306  *      threshold. Zero value means that the temperature change is ignored for
307  *      beacon filtering; beacons will not be  forced to be sent to driver
308  *      regardless of whether its temerature has been changed.
309  * @bf_temp_slow_filter: Send Beacon to driver if delta in temperature values
310  *      calculated for this and the last passed beacon is greater than this
311  *      threshold. Zero value means that the temperature change is ignored for
312  *      beacon filtering; beacons will not be forced to be sent to driver
313  *      regardless of whether its temerature has been changed.
314  * @bf_enable_beacon_filter: 1, beacon filtering is enabled; 0, disabled.
315  * @bf_filter_escape_timer: Send beacons to to driver if no beacons were passed
316  *      for a specific period of time. Units: Beacons.
317  * @ba_escape_timer: Fully receive and parse beacon if no beacons were passed
318  *      for a longer period of time then this escape-timeout. Units: Beacons.
319  * @ba_enable_beacon_abort: 1, beacon abort is enabled; 0, disabled.
320  */
321 struct iwl_beacon_filter_cmd {
322         __le32 bf_energy_delta;
323         __le32 bf_roaming_energy_delta;
324         __le32 bf_roaming_state;
325         __le32 bf_temp_threshold;
326         __le32 bf_temp_fast_filter;
327         __le32 bf_temp_slow_filter;
328         __le32 bf_enable_beacon_filter;
329         __le32 bf_debug_flag;
330         __le32 bf_escape_timer;
331         __le32 ba_escape_timer;
332         __le32 ba_enable_beacon_abort;
333 } __packed;
334
335 /* Beacon filtering and beacon abort */
336 #define IWL_BF_ENERGY_DELTA_DEFAULT 5
337 #define IWL_BF_ENERGY_DELTA_MAX 255
338 #define IWL_BF_ENERGY_DELTA_MIN 0
339
340 #define IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT 1
341 #define IWL_BF_ROAMING_ENERGY_DELTA_MAX 255
342 #define IWL_BF_ROAMING_ENERGY_DELTA_MIN 0
343
344 #define IWL_BF_ROAMING_STATE_DEFAULT 72
345 #define IWL_BF_ROAMING_STATE_MAX 255
346 #define IWL_BF_ROAMING_STATE_MIN 0
347
348 #define IWL_BF_TEMP_THRESHOLD_DEFAULT 112
349 #define IWL_BF_TEMP_THRESHOLD_MAX 255
350 #define IWL_BF_TEMP_THRESHOLD_MIN 0
351
352 #define IWL_BF_TEMP_FAST_FILTER_DEFAULT 1
353 #define IWL_BF_TEMP_FAST_FILTER_MAX 255
354 #define IWL_BF_TEMP_FAST_FILTER_MIN 0
355
356 #define IWL_BF_TEMP_SLOW_FILTER_DEFAULT 5
357 #define IWL_BF_TEMP_SLOW_FILTER_MAX 255
358 #define IWL_BF_TEMP_SLOW_FILTER_MIN 0
359
360 #define IWL_BF_ENABLE_BEACON_FILTER_DEFAULT 1
361
362 #define IWL_BF_DEBUG_FLAG_DEFAULT 0
363
364 #define IWL_BF_ESCAPE_TIMER_DEFAULT 50
365 #define IWL_BF_ESCAPE_TIMER_MAX 1024
366 #define IWL_BF_ESCAPE_TIMER_MIN 0
367
368 #define IWL_BA_ESCAPE_TIMER_DEFAULT 6
369 #define IWL_BA_ESCAPE_TIMER_D3 9
370 #define IWL_BA_ESCAPE_TIMER_MAX 1024
371 #define IWL_BA_ESCAPE_TIMER_MIN 0
372
373 #define IWL_BA_ENABLE_BEACON_ABORT_DEFAULT 1
374
375 #define IWL_BF_CMD_CONFIG_DEFAULTS                                           \
376         .bf_energy_delta = cpu_to_le32(IWL_BF_ENERGY_DELTA_DEFAULT),         \
377         .bf_roaming_energy_delta =                                           \
378                 cpu_to_le32(IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT),            \
379         .bf_roaming_state = cpu_to_le32(IWL_BF_ROAMING_STATE_DEFAULT),       \
380         .bf_temp_threshold = cpu_to_le32(IWL_BF_TEMP_THRESHOLD_DEFAULT),     \
381         .bf_temp_fast_filter = cpu_to_le32(IWL_BF_TEMP_FAST_FILTER_DEFAULT), \
382         .bf_temp_slow_filter = cpu_to_le32(IWL_BF_TEMP_SLOW_FILTER_DEFAULT), \
383         .bf_debug_flag = cpu_to_le32(IWL_BF_DEBUG_FLAG_DEFAULT),             \
384         .bf_escape_timer = cpu_to_le32(IWL_BF_ESCAPE_TIMER_DEFAULT),         \
385         .ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_DEFAULT)
386
387 #endif