From db60bc797a70d2192052ea89bce47e86c7b80e25 Mon Sep 17 00:00:00 2001 From: Liangwei Dong Date: Fri, 25 Sep 2020 12:13:19 +0800 Subject: [PATCH] qcacmn: Add host definition for target thermal throttle level Convert target thermal throttle level to host definition - enum thermal_throttle_level. Change-Id: I9914aaf56b781533565cd6a3f8b279ee67215c23 CRs-Fixed: 2786660 --- .../inc/wlan_thermal_public_struct.h | 36 +++++++++++++++++++ wmi/inc/wmi_unified_api.h | 6 ++-- wmi/inc/wmi_unified_priv.h | 2 +- wmi/src/wmi_unified_api.c | 3 +- wmi/src/wmi_unified_tlv.c | 30 +++++++++++++--- 5 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 umac/thermal/dispatcher/inc/wlan_thermal_public_struct.h diff --git a/umac/thermal/dispatcher/inc/wlan_thermal_public_struct.h b/umac/thermal/dispatcher/inc/wlan_thermal_public_struct.h new file mode 100644 index 000000000000..1e31dd4163ef --- /dev/null +++ b/umac/thermal/dispatcher/inc/wlan_thermal_public_struct.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2020, The Linux Foundation. All rights reserved. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * DOC: declare the thermal public structure + */ +#ifndef _WLAN_THERMAL_PUBLIC_STRUCT_H_ +#define _WLAN_THERMAL_PUBLIC_STRUCT_H_ + +/** + * enum thermal_throttle_level - firmware offload throttle level + * @THERMAL_FULLPERF: no any throtting + * @THERMAL_MITIGATION: throtting tx to do mitigation + * @THERMAL_SHUTOFF: shut down the tx completely + * @THERMAL_UNKNOWN: unknown level from target. + */ +enum thermal_throttle_level { + THERMAL_FULLPERF, + THERMAL_MITIGATION, + THERMAL_SHUTOFF, + THERMAL_UNKNOWN, +}; + +#endif /* _WLAN_THERMAL_PUBLIC_STRUCT_H_ */ diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index e77a24aff90a..f709a9c2a057 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -32,6 +32,7 @@ #include "wlan_mgmt_txrx_utils_api.h" #include #include +#include "wlan_thermal_public_struct.h" #ifdef WLAN_POWER_MANAGEMENT_OFFLOAD #include "wmi_unified_pmo_api.h" #endif @@ -2965,13 +2966,14 @@ wmi_extract_chan_stats(wmi_unified_t wmi_handle, void *evt_buf, * @wmi_handle: wmi handle * @evt_buf: Pointer to event buffer * @temp: Pointer to hold extracted temperature - * @level: Pointer to hold extracted level + * @level: Pointer to hold extracted level in host enum * @pdev_id: Pointer to hold extracted pdev_id * * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure */ QDF_STATUS wmi_extract_thermal_stats(wmi_unified_t wmi_handle, void *evt_buf, - uint32_t *temp, uint32_t *level, + uint32_t *temp, + enum thermal_throttle_level *level, uint32_t *pdev_id); /** diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 22140bf64ead..3155c553c0c5 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -1796,7 +1796,7 @@ QDF_STATUS (*extract_mib_stats)(wmi_unified_t wmi_handle, void *evt_buf, #endif QDF_STATUS (*extract_thermal_stats)(wmi_unified_t wmi_handle, void *evt_buf, - uint32_t *temp, uint32_t *level, uint32_t *pdev_id); + uint32_t *temp, enum thermal_throttle_level *level, uint32_t *pdev_id); QDF_STATUS (*extract_thermal_level_stats)(wmi_unified_t wmi_handle, void *evt_buf, uint8_t idx, uint32_t *levelcount, diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index c6057c075eea..471f836789de 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -2225,7 +2225,8 @@ wmi_extract_chan_stats(wmi_unified_t wmi_handle, void *evt_buf, } QDF_STATUS wmi_extract_thermal_stats(wmi_unified_t wmi_handle, void *evt_buf, - uint32_t *temp, uint32_t *level, + uint32_t *temp, + enum thermal_throttle_level *level, uint32_t *pdev_id) { if (wmi_handle->ops->extract_thermal_stats) diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 350162cb2ebf..5be9d8979694 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -11457,19 +11457,40 @@ static QDF_STATUS extract_scan_radio_cap_service_ready_ext2_tlv( return QDF_STATUS_SUCCESS; } +/** + * wmi_tgt_thermal_level_to_host() - Convert target thermal level to host enum + * @level: target thermal level from WMI_THERM_THROT_STATS_EVENTID event + * + * Return: host thermal throt level + */ +static enum thermal_throttle_level +wmi_tgt_thermal_level_to_host(uint32_t level) +{ + switch (level) { + case WMI_THERMAL_FULLPERF: + return THERMAL_FULLPERF; + case WMI_THERMAL_MITIGATION: + return THERMAL_MITIGATION; + case WMI_THERMAL_SHUTOFF: + return THERMAL_SHUTOFF; + default: + return THERMAL_UNKNOWN; + } +} + /** * extract_thermal_stats_tlv() - extract thermal stats from event * @wmi_handle: wmi handle * @param evt_buf: Pointer to event buffer * @param temp: Pointer to hold extracted temperature - * @param level: Pointer to hold extracted level + * @param level: Pointer to hold extracted level in host enum * * Return: 0 for success or error code */ static QDF_STATUS extract_thermal_stats_tlv(wmi_unified_t wmi_handle, void *evt_buf, uint32_t *temp, - uint32_t *level, uint32_t *pdev_id) + enum thermal_throttle_level *level, uint32_t *pdev_id) { WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf; wmi_therm_throt_stats_event_fixed_param *tt_stats_event; @@ -11480,12 +11501,13 @@ extract_thermal_stats_tlv(wmi_unified_t wmi_handle, return QDF_STATUS_E_INVAL; tt_stats_event = param_buf->fixed_param; - + wmi_debug("thermal temperature %d level %d", + tt_stats_event->temp, tt_stats_event->level); *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host( wmi_handle, tt_stats_event->pdev_id); *temp = tt_stats_event->temp; - *level = tt_stats_event->level; + *level = wmi_tgt_thermal_level_to_host(tt_stats_event->level); return QDF_STATUS_SUCCESS; }