blob: fe7145c2c98acaa47bb19fe9dbbe4145f07491bd [file] [log] [blame]
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +03001/******************************************************************************
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 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +02008 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8b4139d2014-07-24 14:05:26 +02009 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030010 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
23 * USA
24 *
25 * The full GNU General Public License is included in this distribution
26 * in the file called COPYING.
27 *
28 * Contact Information:
29 * Intel Linux Wireless <ilw@linux.intel.com>
30 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31 *
32 * BSD LICENSE
33 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +020034 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8b4139d2014-07-24 14:05:26 +020035 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
Sara Sharon6eb031d2015-07-13 14:50:47 +030036 * Copyright(c) 2015 Intel Deutschland GmbH
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030037 * All rights reserved.
38 *
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
41 * are met:
42 *
43 * * Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * * Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in
47 * the documentation and/or other materials provided with the
48 * distribution.
49 * * Neither the name Intel Corporation nor the names of its
50 * contributors may be used to endorse or promote products derived
51 * from this software without specific prior written permission.
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 *
65 *****************************************************************************/
66
67#include "mvm.h"
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030068
Luciano Coelhoa0a09242014-09-04 12:29:15 +030069#define IWL_MVM_TEMP_NOTIF_WAIT_TIMEOUT HZ
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030070
71static void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm)
72{
Luciano Coelho19789ab2014-12-15 14:15:15 +020073 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +030074 u32 duration = tt->params.ct_kill_duration;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030075
Luciano Coelhob689fa72014-08-20 17:26:58 +030076 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
77 return;
78
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030079 IWL_ERR(mvm, "Enter CT Kill\n");
80 iwl_mvm_set_hw_ctkill_state(mvm, true);
Luciano Coelhoefc36db2014-08-20 17:58:20 +030081
Luciano Coelho19789ab2014-12-15 14:15:15 +020082 tt->throttle = false;
83 tt->dynamic_smps = false;
84
Luciano Coelhoefc36db2014-08-20 17:58:20 +030085 /* Don't schedule an exit work if we're in test mode, since
86 * the temperature will not change unless we manually set it
87 * again (or disable testing).
88 */
89 if (!mvm->temperature_test)
Luciano Coelho19789ab2014-12-15 14:15:15 +020090 schedule_delayed_work(&tt->ct_kill_exit,
Luciano Coelhoefc36db2014-08-20 17:58:20 +030091 round_jiffies_relative(duration * HZ));
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030092}
93
94static void iwl_mvm_exit_ctkill(struct iwl_mvm *mvm)
95{
Luciano Coelhob689fa72014-08-20 17:26:58 +030096 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
97 return;
98
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030099 IWL_ERR(mvm, "Exit CT Kill\n");
100 iwl_mvm_set_hw_ctkill_state(mvm, false);
101}
102
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200103void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp)
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300104{
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200105 /* ignore the notification if we are in test mode */
106 if (mvm->temperature_test)
107 return;
108
109 if (mvm->temperature == temp)
110 return;
111
112 mvm->temperature = temp;
113 iwl_mvm_tt_handler(mvm);
114}
115
116static int iwl_mvm_temp_notif_parse(struct iwl_mvm *mvm,
117 struct iwl_rx_packet *pkt)
118{
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300119 struct iwl_dts_measurement_notif *notif;
120 int len = iwl_rx_packet_payload_len(pkt);
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200121 int temp;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300122
123 if (WARN_ON_ONCE(len != sizeof(*notif))) {
124 IWL_ERR(mvm, "Invalid DTS_MEASUREMENT_NOTIFICATION\n");
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200125 return -EINVAL;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300126 }
127
128 notif = (void *)pkt->data;
129
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200130 temp = le32_to_cpu(notif->temp);
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300131
132 /* shouldn't be negative, but since it's s32, make sure it isn't */
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200133 if (WARN_ON_ONCE(temp < 0))
134 temp = 0;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300135
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200136 IWL_DEBUG_TEMP(mvm, "DTS_MEASUREMENT_NOTIFICATION - %d\n", temp);
137
138 return temp;
139}
140
141static bool iwl_mvm_temp_notif_wait(struct iwl_notif_wait_data *notif_wait,
142 struct iwl_rx_packet *pkt, void *data)
143{
144 struct iwl_mvm *mvm =
145 container_of(notif_wait, struct iwl_mvm, notif_wait);
146 int *temp = data;
147 int ret;
148
149 ret = iwl_mvm_temp_notif_parse(mvm, pkt);
150 if (ret < 0)
151 return true;
152
153 *temp = ret;
154
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300155 return true;
156}
157
Johannes Berg04168412015-06-23 21:22:09 +0200158void iwl_mvm_temp_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
Luciano Coelhoea9af242014-11-06 10:34:49 +0200159{
160 struct iwl_rx_packet *pkt = rxb_addr(rxb);
161 int temp;
162
163 /* the notification is handled synchronously in ctkill, so skip here */
164 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
Johannes Berg04168412015-06-23 21:22:09 +0200165 return;
Luciano Coelhoea9af242014-11-06 10:34:49 +0200166
167 temp = iwl_mvm_temp_notif_parse(mvm, pkt);
168 if (temp < 0)
Johannes Berg04168412015-06-23 21:22:09 +0200169 return;
Luciano Coelhoea9af242014-11-06 10:34:49 +0200170
171 iwl_mvm_tt_temp_changed(mvm, temp);
Luciano Coelhoea9af242014-11-06 10:34:49 +0200172}
173
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300174static int iwl_mvm_get_temp_cmd(struct iwl_mvm *mvm)
175{
176 struct iwl_dts_measurement_cmd cmd = {
177 .flags = cpu_to_le32(DTS_TRIGGER_CMD_FLAGS_TEMP),
178 };
179
180 return iwl_mvm_send_cmd_pdu(mvm, CMD_DTS_MEASUREMENT_TRIGGER, 0,
181 sizeof(cmd), &cmd);
182}
183
Luciano Coelhoc549e392014-09-04 15:58:47 +0300184int iwl_mvm_get_temp(struct iwl_mvm *mvm)
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300185{
186 struct iwl_notification_wait wait_temp_notif;
Sara Sharon6eb031d2015-07-13 14:50:47 +0300187 static const u16 temp_notif[] = { DTS_MEASUREMENT_NOTIFICATION };
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300188 int ret, temp;
189
190 lockdep_assert_held(&mvm->mutex);
191
192 iwl_init_notification_wait(&mvm->notif_wait, &wait_temp_notif,
193 temp_notif, ARRAY_SIZE(temp_notif),
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200194 iwl_mvm_temp_notif_wait, &temp);
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300195
196 ret = iwl_mvm_get_temp_cmd(mvm);
197 if (ret) {
198 IWL_ERR(mvm, "Failed to get the temperature (err=%d)\n", ret);
199 iwl_remove_notification(&mvm->notif_wait, &wait_temp_notif);
200 return ret;
201 }
202
203 ret = iwl_wait_notification(&mvm->notif_wait, &wait_temp_notif,
204 IWL_MVM_TEMP_NOTIF_WAIT_TIMEOUT);
205 if (ret) {
206 IWL_ERR(mvm, "Getting the temperature timed out\n");
207 return ret;
208 }
209
210 return temp;
211}
212
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300213static void check_exit_ctkill(struct work_struct *work)
214{
215 struct iwl_mvm_tt_mgmt *tt;
216 struct iwl_mvm *mvm;
217 u32 duration;
218 s32 temp;
219
220 tt = container_of(work, struct iwl_mvm_tt_mgmt, ct_kill_exit.work);
221 mvm = container_of(tt, struct iwl_mvm, thermal_throttle);
222
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300223 duration = tt->params.ct_kill_duration;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300224
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300225 mutex_lock(&mvm->mutex);
226
227 if (__iwl_mvm_mac_start(mvm))
Eliad Peller576eeee2014-07-01 18:38:38 +0300228 goto reschedule;
229
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300230 /* make sure the device is available for direct read/writes */
231 if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_CHECK_CTKILL)) {
232 __iwl_mvm_mac_stop(mvm);
233 goto reschedule;
234 }
235
236 temp = iwl_mvm_get_temp(mvm);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300237
Eliad Peller576eeee2014-07-01 18:38:38 +0300238 iwl_mvm_unref(mvm, IWL_MVM_REF_CHECK_CTKILL);
239
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300240 __iwl_mvm_mac_stop(mvm);
241
242 if (temp < 0)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300243 goto reschedule;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300244
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300245 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", temp);
246
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300247 if (temp <= tt->params.ct_kill_exit) {
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300248 mutex_unlock(&mvm->mutex);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300249 iwl_mvm_exit_ctkill(mvm);
250 return;
251 }
252
253reschedule:
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300254 mutex_unlock(&mvm->mutex);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300255 schedule_delayed_work(&mvm->thermal_throttle.ct_kill_exit,
256 round_jiffies(duration * HZ));
257}
258
259static void iwl_mvm_tt_smps_iterator(void *_data, u8 *mac,
260 struct ieee80211_vif *vif)
261{
262 struct iwl_mvm *mvm = _data;
263 enum ieee80211_smps_mode smps_mode;
264
265 lockdep_assert_held(&mvm->mutex);
266
267 if (mvm->thermal_throttle.dynamic_smps)
268 smps_mode = IEEE80211_SMPS_DYNAMIC;
269 else
270 smps_mode = IEEE80211_SMPS_AUTOMATIC;
271
Eytan Lifshitzfded3132013-06-04 12:28:51 +0300272 if (vif->type != NL80211_IFTYPE_STATION)
273 return;
274
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300275 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT, smps_mode);
276}
277
278static void iwl_mvm_tt_tx_protection(struct iwl_mvm *mvm, bool enable)
279{
280 struct ieee80211_sta *sta;
281 struct iwl_mvm_sta *mvmsta;
282 int i, err;
283
284 for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
285 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
286 lockdep_is_held(&mvm->mutex));
287 if (IS_ERR_OR_NULL(sta))
288 continue;
Johannes Berg5b577a92013-11-14 18:20:04 +0100289 mvmsta = iwl_mvm_sta_from_mac80211(sta);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300290 if (enable == mvmsta->tt_tx_protection)
291 continue;
Johannes Berge126b5d2013-06-28 13:39:18 +0200292 err = iwl_mvm_tx_protection(mvm, mvmsta, enable);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300293 if (err) {
294 IWL_ERR(mvm, "Failed to %s Tx protection\n",
295 enable ? "enable" : "disable");
296 } else {
297 IWL_DEBUG_TEMP(mvm, "%s Tx protection\n",
298 enable ? "Enable" : "Disable");
299 mvmsta->tt_tx_protection = enable;
300 }
301 }
302}
303
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500304void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300305{
306 struct iwl_host_cmd cmd = {
307 .id = REPLY_THERMAL_MNG_BACKOFF,
308 .len = { sizeof(u32), },
309 .data = { &backoff, },
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300310 };
311
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500312 backoff = max(backoff, mvm->thermal_throttle.min_backoff);
313
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300314 if (iwl_mvm_send_cmd(mvm, &cmd) == 0) {
315 IWL_DEBUG_TEMP(mvm, "Set Thermal Tx backoff to: %u\n",
316 backoff);
317 mvm->thermal_throttle.tx_backoff = backoff;
318 } else {
319 IWL_ERR(mvm, "Failed to change Thermal Tx backoff\n");
320 }
321}
322
323void iwl_mvm_tt_handler(struct iwl_mvm *mvm)
324{
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300325 struct iwl_tt_params *params = &mvm->thermal_throttle.params;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300326 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
327 s32 temperature = mvm->temperature;
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300328 bool throttle_enable = false;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300329 int i;
330 u32 tx_backoff;
331
332 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", mvm->temperature);
333
334 if (params->support_ct_kill && temperature >= params->ct_kill_entry) {
335 iwl_mvm_enter_ctkill(mvm);
336 return;
337 }
338
Luciano Coelhob689fa72014-08-20 17:26:58 +0300339 if (params->support_ct_kill &&
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300340 temperature <= params->ct_kill_exit) {
Luciano Coelhob689fa72014-08-20 17:26:58 +0300341 iwl_mvm_exit_ctkill(mvm);
342 return;
343 }
344
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300345 if (params->support_dynamic_smps) {
346 if (!tt->dynamic_smps &&
347 temperature >= params->dynamic_smps_entry) {
348 IWL_DEBUG_TEMP(mvm, "Enable dynamic SMPS\n");
349 tt->dynamic_smps = true;
350 ieee80211_iterate_active_interfaces_atomic(
351 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
352 iwl_mvm_tt_smps_iterator, mvm);
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300353 throttle_enable = true;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300354 } else if (tt->dynamic_smps &&
355 temperature <= params->dynamic_smps_exit) {
356 IWL_DEBUG_TEMP(mvm, "Disable dynamic SMPS\n");
357 tt->dynamic_smps = false;
358 ieee80211_iterate_active_interfaces_atomic(
359 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
360 iwl_mvm_tt_smps_iterator, mvm);
361 }
362 }
363
364 if (params->support_tx_protection) {
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300365 if (temperature >= params->tx_protection_entry) {
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300366 iwl_mvm_tt_tx_protection(mvm, true);
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300367 throttle_enable = true;
368 } else if (temperature <= params->tx_protection_exit) {
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300369 iwl_mvm_tt_tx_protection(mvm, false);
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300370 }
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300371 }
372
373 if (params->support_tx_backoff) {
Eytan Lifshitz1b8ebbd2014-04-01 16:44:21 +0300374 tx_backoff = tt->min_backoff;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300375 for (i = 0; i < TT_TX_BACKOFF_SIZE; i++) {
376 if (temperature < params->tx_backoff[i].temperature)
377 break;
Eytan Lifshitz1b8ebbd2014-04-01 16:44:21 +0300378 tx_backoff = max(tt->min_backoff,
379 params->tx_backoff[i].backoff);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300380 }
Eytan Lifshitz1b8ebbd2014-04-01 16:44:21 +0300381 if (tx_backoff != tt->min_backoff)
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300382 throttle_enable = true;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300383 if (tt->tx_backoff != tx_backoff)
384 iwl_mvm_tt_tx_backoff(mvm, tx_backoff);
385 }
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300386
387 if (!tt->throttle && throttle_enable) {
388 IWL_WARN(mvm,
389 "Due to high temperature thermal throttling initiated\n");
390 tt->throttle = true;
Eytan Lifshitz19a04bd2014-04-02 21:37:57 +0300391 } else if (tt->throttle && !tt->dynamic_smps &&
392 tt->tx_backoff == tt->min_backoff &&
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300393 temperature <= params->tx_protection_exit) {
394 IWL_WARN(mvm,
395 "Temperature is back to normal thermal throttling stopped\n");
396 tt->throttle = false;
397 }
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300398}
399
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300400static const struct iwl_tt_params iwl_mvm_default_tt_params = {
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300401 .ct_kill_entry = 118,
402 .ct_kill_exit = 96,
403 .ct_kill_duration = 5,
404 .dynamic_smps_entry = 114,
405 .dynamic_smps_exit = 110,
406 .tx_protection_entry = 114,
407 .tx_protection_exit = 108,
408 .tx_backoff = {
409 {.temperature = 112, .backoff = 200},
410 {.temperature = 113, .backoff = 600},
411 {.temperature = 114, .backoff = 1200},
412 {.temperature = 115, .backoff = 2000},
413 {.temperature = 116, .backoff = 4000},
414 {.temperature = 117, .backoff = 10000},
415 },
416 .support_ct_kill = true,
417 .support_dynamic_smps = true,
418 .support_tx_protection = true,
419 .support_tx_backoff = true,
420};
421
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500422void iwl_mvm_tt_initialize(struct iwl_mvm *mvm, u32 min_backoff)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300423{
424 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
425
426 IWL_DEBUG_TEMP(mvm, "Initialize Thermal Throttling\n");
Eytan Lifshitz6be497f2013-07-24 14:49:18 +0300427
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300428 if (mvm->cfg->thermal_params)
429 tt->params = *mvm->cfg->thermal_params;
Eytan Lifshitz6be497f2013-07-24 14:49:18 +0300430 else
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300431 tt->params = iwl_mvm_default_tt_params;
Eytan Lifshitz6be497f2013-07-24 14:49:18 +0300432
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300433 tt->throttle = false;
Luciano Coelho19789ab2014-12-15 14:15:15 +0200434 tt->dynamic_smps = false;
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500435 tt->min_backoff = min_backoff;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300436 INIT_DELAYED_WORK(&tt->ct_kill_exit, check_exit_ctkill);
437}
438
439void iwl_mvm_tt_exit(struct iwl_mvm *mvm)
440{
441 cancel_delayed_work_sync(&mvm->thermal_throttle.ct_kill_exit);
442 IWL_DEBUG_TEMP(mvm, "Exit Thermal Throttling\n");
443}