diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2020-06-22 07:39:42 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2020-06-22 07:39:42 +0000 |
commit | 09fc8aaee50d75761e15050410aa23031186858d (patch) | |
tree | e77a254a235636d621e08386c15294e53979e26d /sys | |
parent | 7d600204d1c4777ffa22075cf223a94e2b911eba (diff) |
Enable critical temperature detection in iwx(4) firmware.
The driver will turn the device off and print a message to dmesg if the
firmware signals critical temperature. It looks like the firmware will
also make use of a Tx-backoff mechanism to regulate device temperature.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/if_iwx.c | 46 | ||||
-rw-r--r-- | sys/dev/pci/if_iwxreg.h | 27 |
2 files changed, 71 insertions, 2 deletions
diff --git a/sys/dev/pci/if_iwx.c b/sys/dev/pci/if_iwx.c index a44c0a51ed5..2ef3439ebe5 100644 --- a/sys/dev/pci/if_iwx.c +++ b/sys/dev/pci/if_iwx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwx.c,v 1.32 2020/06/22 07:31:32 stsp Exp $ */ +/* $OpenBSD: if_iwx.c,v 1.33 2020/06/22 07:39:41 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh <info@genua.de> @@ -437,6 +437,7 @@ int iwx_sf_config(struct iwx_softc *, int); int iwx_send_bt_init_conf(struct iwx_softc *); int iwx_send_soc_conf(struct iwx_softc *); int iwx_send_update_mcc_cmd(struct iwx_softc *, const char *); +int iwx_send_temp_report_ths_cmd(struct iwx_softc *); int iwx_init_hw(struct iwx_softc *); int iwx_init(struct ifnet *); void iwx_start(struct ifnet *); @@ -6822,6 +6823,29 @@ out: } int +iwx_send_temp_report_ths_cmd(struct iwx_softc *sc) +{ + struct iwx_temp_report_ths_cmd cmd; + int err; + + /* + * In order to give responsibility for critical-temperature-kill + * and TX backoff to FW we need to send an empty temperature + * reporting command at init time. + */ + memset(&cmd, 0, sizeof(cmd)); + + err = iwx_send_cmd_pdu(sc, + IWX_WIDE_ID(IWX_PHY_OPS_GROUP, IWX_TEMP_REPORTING_THRESHOLDS_CMD), + 0, sizeof(cmd), &cmd); + if (err) + printf("%s: TEMP_REPORT_THS_CMD command failed (error %d)\n", + DEVNAME(sc), err); + + return err; +} + +int iwx_init_hw(struct iwx_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; @@ -6905,6 +6929,12 @@ iwx_init_hw(struct iwx_softc *sc) DEVNAME(sc), err); } + if (isset(sc->sc_enabled_capa, IWX_UCODE_TLV_CAPA_CT_KILL_BY_FW)) { + err = iwx_send_temp_report_ths_cmd(sc); + if (err) + goto err; + } + err = iwx_power_update_device(sc); if (err) { printf("%s: could not send power command (error %d)\n", @@ -7623,8 +7653,22 @@ iwx_rx_pkt(struct iwx_softc *sc, struct iwx_rx_data *data, struct mbuf_list *ml) case IWX_DTS_MEASUREMENT_NOTIFICATION: case IWX_WIDE_ID(IWX_PHY_OPS_GROUP, IWX_DTS_MEASUREMENT_NOTIF_WIDE): + case IWX_WIDE_ID(IWX_PHY_OPS_GROUP, + IWX_TEMP_REPORTING_THRESHOLDS_CMD): break; + case IWX_WIDE_ID(IWX_PHY_OPS_GROUP, + IWX_CT_KILL_NOTIFICATION): { + struct iwx_ct_kill_notif *notif; + SYNC_RESP_STRUCT(notif, pkt); + printf("%s: device at critical temperature (%u degC), " + "stopping device\n", + DEVNAME(sc), le16toh(notif->temperature)); + sc->sc_flags |= IWX_FLAG_HW_ERR; + task_add(systq, &sc->init_task); + break; + } + case IWX_WIDE_ID(IWX_REGULATORY_AND_NVM_GROUP, IWX_NVM_GET_INFO): case IWX_ADD_STA_KEY: diff --git a/sys/dev/pci/if_iwxreg.h b/sys/dev/pci/if_iwxreg.h index 1454092b006..7ecd1f8e0f6 100644 --- a/sys/dev/pci/if_iwxreg.h +++ b/sys/dev/pci/if_iwxreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwxreg.h,v 1.11 2020/06/19 11:12:46 stsp Exp $ */ +/* $OpenBSD: if_iwxreg.h,v 1.12 2020/06/22 07:39:41 stsp Exp $ */ /*- * Based on BSD-licensed source modules in the Linux iwlwifi driver, @@ -1685,6 +1685,31 @@ struct iwx_phy_cfg_cmd { #define IWX_PHY_CFG_RX_CHAIN_B (1 << 13) #define IWX_PHY_CFG_RX_CHAIN_C (1 << 14) +#define IWX_MAX_DTS_TRIPS 8 + +/** + * struct iwx_ct_kill_notif - CT-kill entry notification + * + * @temperature: the current temperature in celsius + * @reserved: reserved + */ +struct iwx_ct_kill_notif { + uint16_t temperature; + uint16_t reserved; +} __packed; /* GRP_PHY_CT_KILL_NTF */ + +/** + * struct iwx_temp_report_ths_cmd - set temperature thresholds + * (IWX_TEMP_REPORTING_THRESHOLDS_CMD) + * + * @num_temps: number of temperature thresholds passed + * @thresholds: array with the thresholds to be configured + */ +struct iwx_temp_report_ths_cmd { + uint32_t num_temps; + uint16_t thresholds[IWX_MAX_DTS_TRIPS]; +} __packed; /* GRP_PHY_TEMP_REPORTING_THRESHOLDS_CMD */ + #define IWX_NVM_VERSION 0 /* 8k family NVM HW-Section offset (in words) definitions */ |