diff --git a/components/fw_offload/core/inc/wlan_fw_offload_main.h b/components/fw_offload/core/inc/wlan_fw_offload_main.h
index cb247ae38a..5533392a75 100644
--- a/components/fw_offload/core/inc/wlan_fw_offload_main.h
+++ b/components/fw_offload/core/inc/wlan_fw_offload_main.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2012 - 2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. 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
@@ -113,7 +113,7 @@ struct wlan_fwol_coex_config {
#endif
};
-#define FWOL_THERMAL_LEVEL_MAX 4
+#define FWOL_THERMAL_LEVEL_MAX 6
#define FWOL_THERMAL_THROTTLE_LEVEL_MAX 6
/**
* struct wlan_fwol_thermal_temp - Thermal temperature config items
diff --git a/components/fw_offload/core/src/wlan_fw_offload_main.c b/components/fw_offload/core/src/wlan_fw_offload_main.c
index 49cc1598a6..10f8d26317 100644
--- a/components/fw_offload/core/src/wlan_fw_offload_main.c
+++ b/components/fw_offload/core/src/wlan_fw_offload_main.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. 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
@@ -152,6 +152,14 @@ fwol_init_thermal_temp_in_cfg(struct wlan_objmgr_psoc *psoc,
cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL3);
thermal_temp->thermal_temp_max_level[3] =
cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL3);
+ thermal_temp->thermal_temp_min_level[4] =
+ cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL4);
+ thermal_temp->thermal_temp_max_level[4] =
+ cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL4);
+ thermal_temp->thermal_temp_min_level[5] =
+ cfg_get(psoc, CFG_THERMAL_TEMP_MIN_LEVEL5);
+ thermal_temp->thermal_temp_max_level[5] =
+ cfg_get(psoc, CFG_THERMAL_TEMP_MAX_LEVEL5);
thermal_temp->thermal_mitigation_enable =
cfg_get(psoc, CFG_THERMAL_MITIGATION_ENABLE);
diff --git a/components/fw_offload/dispatcher/inc/cfg_thermal_temp.h b/components/fw_offload/dispatcher/inc/cfg_thermal_temp.h
index 6cb052b9ad..2e223c6c92 100644
--- a/components/fw_offload/dispatcher/inc/cfg_thermal_temp.h
+++ b/components/fw_offload/dispatcher/inc/cfg_thermal_temp.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2012-2018,2020-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. 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
@@ -176,6 +176,86 @@
CFG_VALUE_OR_DEFAULT, \
"Thermal Temp Max Level3")
+/*
+ *
+ * gThermalTempMinLevel4 - Set Thermal Temp Min Level
+ * for TX OFF
+ * @Min: 0
+ * @Max: 1000
+ * @Default: 116
+ *
+ * Usage: External
+ *
+ *
+ */
+#define CFG_THERMAL_TEMP_MIN_LEVEL4 CFG_INI_UINT( \
+ "gThermalTempMinLevel4", \
+ 0, \
+ 1000, \
+ 116, \
+ CFG_VALUE_OR_DEFAULT, \
+ "Thermal Temp Min Level4")
+
+/*
+ *
+ * gThermalTempMaxLevel4 - Set Thermal Temp Max Level
+ * for TX OFF
+ * @Min: 0
+ * @Max: 1000
+ * @Default: 117
+ *
+ * Usage: External
+ *
+ *
+ */
+#define CFG_THERMAL_TEMP_MAX_LEVEL4 CFG_INI_UINT( \
+ "gThermalTempMaxLevel4", \
+ 0, \
+ 1000, \
+ 117, \
+ CFG_VALUE_OR_DEFAULT, \
+ "Thermal Temp Max Level4")
+
+/*
+ *
+ * gThermalTempMinLevel5 - Set Thermal Temp Min Level
+ * for target shutdown
+ * @Min: 0
+ * @Max: 1000
+ * @Default: 118
+ *
+ * Usage: External
+ *
+ *
+ */
+#define CFG_THERMAL_TEMP_MIN_LEVEL5 CFG_INI_UINT( \
+ "gThermalTempMinLevel5", \
+ 0, \
+ 1000, \
+ 118, \
+ CFG_VALUE_OR_DEFAULT, \
+ "Thermal Temp Min Level5")
+
+/*
+ *
+ * gThermalTempMaxLevel5 - Set Thermal Temp Max Level
+ * for target shutdown
+ * @Min: 0
+ * @Max: 1000
+ * @Default: 120
+ *
+ * Usage: External
+ *
+ *
+ */
+#define CFG_THERMAL_TEMP_MAX_LEVEL5 CFG_INI_UINT( \
+ "gThermalTempMaxLevel5", \
+ 0, \
+ 1000, \
+ 120, \
+ CFG_VALUE_OR_DEFAULT, \
+ "Thermal Temp Max Level5")
+
/*
*
* gThermalMitigationEnable - Set Thermal mitigation feature control
@@ -465,6 +545,10 @@
CFG(CFG_THERMAL_TEMP_MAX_LEVEL2) \
CFG(CFG_THERMAL_TEMP_MIN_LEVEL3) \
CFG(CFG_THERMAL_TEMP_MAX_LEVEL3) \
+ CFG(CFG_THERMAL_TEMP_MIN_LEVEL4) \
+ CFG(CFG_THERMAL_TEMP_MAX_LEVEL4) \
+ CFG(CFG_THERMAL_TEMP_MIN_LEVEL5) \
+ CFG(CFG_THERMAL_TEMP_MAX_LEVEL5) \
CFG(CFG_THERMAL_MITIGATION_ENABLE) \
CFG(CFG_THROTTLE_PERIOD) \
CFG(CFG_THROTTLE_DUTY_CYCLE_LEVEL0) \
diff --git a/components/target_if/fw_offload/inc/target_if_fwol.h b/components/target_if/fw_offload/inc/target_if_fwol.h
index 7a6ab16690..61601f6506 100644
--- a/components/target_if/fw_offload/inc/target_if_fwol.h
+++ b/components/target_if/fw_offload/inc/target_if_fwol.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. 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
@@ -55,4 +56,27 @@ target_if_fwol_unregister_event_handler(struct wlan_objmgr_psoc *psoc,
*/
QDF_STATUS target_if_fwol_register_tx_ops(struct wlan_fwol_tx_ops *tx_ops);
+/**
+ * target_if_fwol_notify_thermal_throttle() - Notify thermal throttle level
+ * to upper layer
+ * @psoc: PSOC object manager
+ * @info: Thermal throttle information from target
+ *
+ * This function is used to notify thermal throttle level to upper layer
+ * when thermal management event receive.
+ *
+ * Return: QDF_STATUS_SUCCESS for success otherwise failure
+ */
+#ifdef FW_THERMAL_THROTTLE_SUPPORT
+QDF_STATUS
+target_if_fwol_notify_thermal_throttle(struct wlan_objmgr_psoc *psoc,
+ struct thermal_throttle_info *info);
+#else
+static inline QDF_STATUS
+target_if_fwol_notify_thermal_throttle(struct wlan_objmgr_psoc *psoc,
+ struct thermal_throttle_info *info)
+{
+ return QDF_STATUS_E_INVAL;
+}
+#endif
#endif /* __TARGET_IF_FWOL_H__ */
diff --git a/components/target_if/fw_offload/src/target_if_fwol.c b/components/target_if/fw_offload/src/target_if_fwol.c
index 9ab9e79297..16b82c4172 100644
--- a/components/target_if/fw_offload/src/target_if_fwol.c
+++ b/components/target_if/fw_offload/src/target_if_fwol.c
@@ -321,6 +321,49 @@ target_if_fwol_is_thermal_stats_enable(struct wlan_fwol_psoc_obj *fwol_obj)
#endif
#if defined FW_THERMAL_THROTTLE_SUPPORT || defined THERMAL_STATS_SUPPORT
+QDF_STATUS
+target_if_fwol_notify_thermal_throttle(struct wlan_objmgr_psoc *psoc,
+ struct thermal_throttle_info *info)
+{
+ struct wlan_fwol_psoc_obj *fwol_obj;
+ struct wlan_fwol_rx_ops *rx_ops;
+ QDF_STATUS status;
+
+ fwol_obj = fwol_get_psoc_obj(psoc);
+ if (!fwol_obj) {
+ target_if_err("Failed to get FWOL Obj");
+ return QDF_STATUS_E_INVAL;
+ }
+
+ rx_ops = &fwol_obj->rx_ops;
+ if (!rx_ops) {
+ target_if_err("rx_ops Null");
+ return QDF_STATUS_E_INVAL;
+ }
+
+ if (!info) {
+ target_if_err("info Null");
+ return QDF_STATUS_E_INVAL;
+ }
+
+ if (rx_ops->notify_thermal_throttle_handler) {
+ if (info->level == THERMAL_UNKNOWN) {
+ target_if_debug("Invalid thermal target lvl");
+ return QDF_STATUS_E_INVAL;
+ }
+ status = rx_ops->notify_thermal_throttle_handler(psoc, info);
+ if (QDF_IS_STATUS_ERROR(status)) {
+ target_if_debug("notify thermal_throttle failed.");
+ return QDF_STATUS_E_INVAL;
+ }
+ } else {
+ target_if_debug("No notify thermal_throttle callback");
+ return QDF_STATUS_E_INVAL;
+ }
+
+ return status;
+}
+
/**
* target_if_fwol_thermal_throttle_event_handler() - handler for thermal
* throttle event
@@ -456,7 +499,6 @@ target_if_fwol_unregister_thermal_throttle_handler(
if (QDF_IS_STATUS_ERROR(status))
target_if_debug("Failed to unregister thermal stats event cb");
}
-
#else
static void
target_if_fwol_register_thermal_throttle_handler(struct wlan_objmgr_psoc *psoc)
diff --git a/configs/qca6174_defconfig b/configs/qca6174_defconfig
index e2ce1d112c..e553d8a261 100644
--- a/configs/qca6174_defconfig
+++ b/configs/qca6174_defconfig
@@ -761,3 +761,6 @@ endif
ifeq ($(CONFIG_CNSS_UTILS), m)
CONFIG_CNSS_UTILS_MODULE := y
endif
+
+#Enable thermal throttle
+CONFIG_FW_THERMAL_THROTTLE := y
diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h
index efc42963d4..7231372dfd 100644
--- a/core/mac/inc/sir_api.h
+++ b/core/mac/inc/sir_api.h
@@ -2365,10 +2365,12 @@ typedef enum {
WLAN_WMA_THERMAL_LEVEL_1,
WLAN_WMA_THERMAL_LEVEL_2,
WLAN_WMA_THERMAL_LEVEL_3,
+ WLAN_WMA_THERMAL_LEVEL_4,
+ WLAN_WMA_THERMAL_LEVEL_5,
WLAN_WMA_MAX_THERMAL_LEVELS
} t_thermal_level;
-#define WLAN_THROTTLE_DUTY_CYCLE_LEVEL_MAX (4)
+#define WLAN_THROTTLE_DUTY_CYCLE_LEVEL_MAX (6)
typedef struct {
/* Array of thermal levels */
diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c
index 8b84530970..4e283c2eb9 100644
--- a/core/sme/src/common/sme_api.c
+++ b/core/sme/src/common/sme_api.c
@@ -8378,6 +8378,10 @@ QDF_STATUS sme_init_thermal_info(mac_handle_t mac_handle)
thermal_temp.throttle_dutycycle_level[2];
pWmaParam->throttle_duty_cycle_tbl[3] =
thermal_temp.throttle_dutycycle_level[3];
+ pWmaParam->throttle_duty_cycle_tbl[4] =
+ thermal_temp.throttle_dutycycle_level[4];
+ pWmaParam->throttle_duty_cycle_tbl[5] =
+ thermal_temp.throttle_dutycycle_level[5];
pWmaParam->thermalLevels[0].minTempThreshold =
thermal_temp.thermal_temp_min_level[0];
@@ -8395,6 +8399,14 @@ QDF_STATUS sme_init_thermal_info(mac_handle_t mac_handle)
thermal_temp.thermal_temp_min_level[3];
pWmaParam->thermalLevels[3].maxTempThreshold =
thermal_temp.thermal_temp_max_level[3];
+ pWmaParam->thermalLevels[4].minTempThreshold =
+ thermal_temp.thermal_temp_min_level[4];
+ pWmaParam->thermalLevels[4].maxTempThreshold =
+ thermal_temp.thermal_temp_max_level[4];
+ pWmaParam->thermalLevels[5].minTempThreshold =
+ thermal_temp.thermal_temp_min_level[5];
+ pWmaParam->thermalLevels[5].maxTempThreshold =
+ thermal_temp.thermal_temp_max_level[5];
pWmaParam->thermal_action = thermal_temp.thermal_action;
if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&mac->sme)) {
msg.type = WMA_INIT_THERMAL_INFO_CMD;
diff --git a/core/wma/src/wma_data.c b/core/wma/src/wma_data.c
index 547b20b95f..5949bfae15 100644
--- a/core/wma/src/wma_data.c
+++ b/core/wma/src/wma_data.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. 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
@@ -84,6 +84,8 @@
#include "wlan_pkt_capture_ucfg_api.h"
#include "wma_eht.h"
#include "wlan_mlo_mgr_sta.h"
+#include "wlan_fw_offload_main.h"
+#include "target_if_fwol.h"
struct wma_search_rate {
int32_t rate;
@@ -1818,11 +1820,15 @@ QDF_STATUS wma_process_init_thermal_info(tp_wma_handle wma,
"0 %d\n"
"1 %d\n"
"2 %d\n"
- "3 %d",
+ "3 %d\n"
+ "4 %d\n"
+ "5 %d",
pThermalParams->throttle_duty_cycle_tbl[0],
pThermalParams->throttle_duty_cycle_tbl[1],
pThermalParams->throttle_duty_cycle_tbl[2],
- pThermalParams->throttle_duty_cycle_tbl[3]);
+ pThermalParams->throttle_duty_cycle_tbl[3],
+ pThermalParams->throttle_duty_cycle_tbl[4],
+ pThermalParams->throttle_duty_cycle_tbl[5]);
wma->thermal_mgmt_info.thermalMgmtEnabled =
pThermalParams->thermalMgmtEnabled;
@@ -1842,13 +1848,23 @@ QDF_STATUS wma_process_init_thermal_info(tp_wma_handle wma,
pThermalParams->thermalLevels[3].minTempThreshold;
wma->thermal_mgmt_info.thermalLevels[3].maxTempThreshold =
pThermalParams->thermalLevels[3].maxTempThreshold;
+ wma->thermal_mgmt_info.thermalLevels[4].minTempThreshold =
+ pThermalParams->thermalLevels[4].minTempThreshold;
+ wma->thermal_mgmt_info.thermalLevels[4].maxTempThreshold =
+ pThermalParams->thermalLevels[4].maxTempThreshold;
+ wma->thermal_mgmt_info.thermalLevels[5].minTempThreshold =
+ pThermalParams->thermalLevels[5].minTempThreshold;
+ wma->thermal_mgmt_info.thermalLevels[5].maxTempThreshold =
+ pThermalParams->thermalLevels[5].maxTempThreshold;
wma->thermal_mgmt_info.thermalCurrLevel = WLAN_WMA_THERMAL_LEVEL_0;
wma->thermal_mgmt_info.thermal_action = pThermalParams->thermal_action;
wma_nofl_debug("TM level min max:\n"
"0 %d %d\n"
"1 %d %d\n"
"2 %d %d\n"
- "3 %d %d",
+ "3 %d %d\n"
+ "4 %d %d\n"
+ "5 %d %d",
wma->thermal_mgmt_info.thermalLevels[0].minTempThreshold,
wma->thermal_mgmt_info.thermalLevels[0].maxTempThreshold,
wma->thermal_mgmt_info.thermalLevels[1].minTempThreshold,
@@ -1856,7 +1872,11 @@ QDF_STATUS wma_process_init_thermal_info(tp_wma_handle wma,
wma->thermal_mgmt_info.thermalLevels[2].minTempThreshold,
wma->thermal_mgmt_info.thermalLevels[2].maxTempThreshold,
wma->thermal_mgmt_info.thermalLevels[3].minTempThreshold,
- wma->thermal_mgmt_info.thermalLevels[3].maxTempThreshold);
+ wma->thermal_mgmt_info.thermalLevels[3].maxTempThreshold,
+ wma->thermal_mgmt_info.thermalLevels[4].minTempThreshold,
+ wma->thermal_mgmt_info.thermalLevels[4].maxTempThreshold,
+ wma->thermal_mgmt_info.thermalLevels[5].minTempThreshold,
+ wma->thermal_mgmt_info.thermalLevels[5].maxTempThreshold);
#ifdef FW_THERMAL_THROTTLE_SUPPORT
for (i = 0; i < THROTTLE_LEVEL_MAX; i++)
@@ -2023,6 +2043,31 @@ static uint8_t wma_thermal_mgmt_get_level(void *handle, uint32_t temp)
return level;
}
+/**
+ * wms_thermal_level_to_host() - Convert wma thermal level to host enum
+ * @level: current thermal throttle level
+ *
+ * Return: host thermal throttle level
+ */
+static enum thermal_throttle_level
+wma_thermal_level_to_host(uint8_t level)
+{
+ switch (level) {
+ case WLAN_WMA_THERMAL_LEVEL_0:
+ return THERMAL_FULLPERF;
+ case WLAN_WMA_THERMAL_LEVEL_1:
+ case WLAN_WMA_THERMAL_LEVEL_2:
+ case WLAN_WMA_THERMAL_LEVEL_3:
+ return THERMAL_MITIGATION;
+ case WLAN_WMA_THERMAL_LEVEL_4:
+ return THERMAL_SHUTOFF;
+ case WLAN_WMA_THERMAL_LEVEL_5:
+ return THERMAL_SHUTDOWN_TARGET;
+ default:
+ return THERMAL_UNKNOWN;
+ }
+}
+
/**
* wma_thermal_mgmt_evt_handler() - thermal mgmt event handler
* @wma_handle: Pointer to WMA handle
@@ -2040,6 +2085,8 @@ int wma_thermal_mgmt_evt_handler(void *handle, uint8_t *event, uint32_t len)
uint8_t thermal_level;
t_thermal_cmd_params thermal_params = {0};
WMI_THERMAL_MGMT_EVENTID_param_tlvs *param_buf;
+ struct wlan_objmgr_psoc *psoc;
+ struct thermal_throttle_info info = {0};
if (!event || !handle) {
wma_err("Invalid thermal mitigation event buffer");
@@ -2051,6 +2098,12 @@ int wma_thermal_mgmt_evt_handler(void *handle, uint8_t *event, uint32_t len)
if (wma_validate_handle(wma))
return -EINVAL;
+ psoc = wma->psoc;
+ if (!psoc) {
+ wma_err("NULL psoc");
+ return -EINVAL;
+ }
+
param_buf = (WMI_THERMAL_MGMT_EVENTID_param_tlvs *) event;
/* Check if thermal mitigation is enabled */
@@ -2075,6 +2128,8 @@ int wma_thermal_mgmt_evt_handler(void *handle, uint8_t *event, uint32_t len)
}
wma->thermal_mgmt_info.thermalCurrLevel = thermal_level;
+ info.level = wma_thermal_level_to_host(thermal_level);
+ target_if_fwol_notify_thermal_throttle(psoc, &info);
if (!wma->fw_therm_throt_support) {
/* Inform txrx */