diff --git a/core/hdd/inc/hdd_config.h b/core/hdd/inc/hdd_config.h
index e7d2bbd5ebf0..c5dde815b54e 100644
--- a/core/hdd/inc/hdd_config.h
+++ b/core/hdd/inc/hdd_config.h
@@ -23,6 +23,8 @@
#ifndef __HDD_CONFIG_H
#define __HDD_CONFIG_H
+#include "hdd_sar_safety_config.h"
+
#if defined(CONFIG_HL_SUPPORT)
#include "wlan_tgt_def_config_hl.h"
#else
@@ -1509,5 +1511,6 @@ enum host_log_level {
CFG(CFG_ENABLE_DISABLE_CHANNEL) \
CFG(CFG_SAR_CONVERSION) \
CFG(CFG_WOW_DISABLE) \
- CFG(CFG_ENABLE_HOST_MODULE_LOG_LEVEL)
+ CFG(CFG_ENABLE_HOST_MODULE_LOG_LEVEL) \
+ SAR_SAFETY_FEATURE_ALL
#endif
diff --git a/core/hdd/inc/hdd_sar_safety_config.h b/core/hdd/inc/hdd_sar_safety_config.h
new file mode 100644
index 000000000000..316037b2c0d1
--- /dev/null
+++ b/core/hdd/inc/hdd_sar_safety_config.h
@@ -0,0 +1,261 @@
+/*
+ * 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: This file contains centralized definitions of converged configuration.
+ */
+
+#ifndef __HDD_SAR_SAFETY_CONFIG_H
+#define __HDD_SAR_SAFETY_CONFIG_H
+
+#ifdef SAR_SAFETY_FEATURE
+
+/*
+ *
+ * gSarSafetyTimeout - Specify SAR safety timeout value in milliseconds
+ *
+ * @Min: 120000
+ * @Max: 600000
+ * Default: 300000
+ *
+ * This ini is used to define SAR safety timeout value in milliseconds.
+ * This timer is started when the QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS
+ * is received first time.
+ * SAR safety timer will wait for the gSarSafetyTimeout for
+ * QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS vendor command and if
+ * SAR safety timer timeouts host will configure the gSarSafetyIndex
+ * to the FW.
+ *
+ * Usage: External
+ *
+ *
+ */
+
+#define CFG_SAR_SAFETY_TIMEOUT CFG_INI_UINT( \
+ "gSarSafetyTimeout", \
+ 120000, \
+ 600000, \
+ 300000, \
+ CFG_VALUE_OR_DEFAULT, \
+ "Timeout value for SAR safety timer")
+
+/*
+ *
+ * gSarSafetyUnsolicitedTimeout - Specify SAR safety unsolicited timeout value
+ * in milliseconds
+ *
+ * @Min: 5000
+ * @Max: 30000
+ * Default: 15000
+ *
+ * This ini is used to define SAR safety unsolicited timeout value in
+ * milliseconds. This timer is started on first data tx.
+ * SAR unsolicited timer will wait for the
+ * gSarSafetyUnsolicitedTimeout for QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS
+ * vendor command and if SAR unsolicited timer timeouts host will indicate
+ * user space with QCA_NL80211_VENDOR_SUBCMD_REQUEST_SAR_LIMITS_EVENT to send
+ * QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS vendor command.
+ *
+ * Usage: External
+ *
+ *
+ */
+
+#define CFG_SAR_SAFETY_UNSOLICITED_TIMEOUT CFG_INI_UINT( \
+ "gSarSafetyUnsolicitedTimeout", \
+ 5000, \
+ 30000, \
+ 15000, \
+ CFG_VALUE_OR_DEFAULT, \
+ "Timeout value for SAR Unsolicited timer")
+
+/*
+ *
+ * gSarSafetyReqRespTimeout - Specify SAR safety request response timeout value
+ * in milliseconds
+ *
+ * @Min: 500
+ * @Max: 3000
+ * Default: 1000
+ *
+ * This ini is used to define SAR request-response timeout value
+ * in milliseconds. SAR request-response timer will wait for the
+ * gSarSafetyReqRespTimeout for QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS
+ * vendor command and if SAR request-response timer timeouts host will
+ * indicate user space with QCA_NL80211_VENDOR_SUBCMD_REQUEST_SAR_LIMITS_EVENT
+ * for gSarSafetyReqRespRetry number of times to send
+ * QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS vendor command and still if host
+ * does not get QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS vendor command, host
+ * will configure the gSarSafetyIndex to the FW.
+ *
+ * Usage: External
+ *
+ *
+ */
+
+#define CFG_SAR_SAFETY_REQ_RESP_TIMEOUT CFG_INI_UINT( \
+ "gSarSafetyReqRespTimeout", \
+ 500, \
+ 3000, \
+ 1000, \
+ CFG_VALUE_OR_DEFAULT, \
+ "Timeout value for SAR safety request response timer")
+
+/*
+ *
+ * gSarSafetyReqRespRetry - Specify SAR request response retries value
+ *
+ * @Min: 1
+ * @Max: 10
+ * Default: 5
+ *
+ * This ini is used to define SAR request-response retries value.
+ * SAR request-response timer will wait for the gSarReqRespTimeout for
+ * QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS vendor command and if
+ * SAR request-response timer timeouts host will indicate user space
+ * for gSarSafetyReqRespRetry number of times to send
+ * QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS vendor command and still if
+ * host does not get QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS vendor
+ * command, host will configure the gSarSafetyIndex to the FW.
+ *
+ * Usage: External
+ *
+ *
+ */
+
+#define CFG_SAR_SAFETY_REQ_RESP_RETRIES CFG_INI_UINT( \
+ "gSarSafetyReqRespRetry", \
+ 1, \
+ 10, \
+ 5, \
+ CFG_VALUE_OR_DEFAULT, \
+ "Max Number of SAR Request Response Retries")
+
+/*
+ *
+ * gSarSafetyIndex - Specify SAR safety index
+ *
+ * @Min: 0
+ * @Max: 11
+ * Default: 11
+ *
+ * This ini is used to define SAR safety index, when sar safety timer
+ * timeouts or sar request response timer timeouts for gSarSafetyReqRespRetry
+ * number of times, host will configure gSarSafetyIndex value to the FW.
+ *
+ * Usage: External
+ *
+ *
+ */
+
+#define CFG_SAR_SAFETY_INDEX CFG_INI_UINT( \
+ "gSarSafetyIndex", \
+ 0, \
+ 11, \
+ 11, \
+ CFG_VALUE_OR_DEFAULT, \
+ "SAR safety index value")
+/*
+ *
+ * gSarSafetySleepIndex - Specify SAR Safety sleep index
+ *
+ * @Min: 0
+ * @Max: 11
+ * Default: 11
+ *
+ * This ini is used to define SAR sleep index, when device goes into the
+ * sleep mode, before going into the sleep mode host configures
+ * gSarSafetySleepIndex value to the FW.
+ *
+ * Usage: External
+ *
+ *
+ */
+
+#define CFG_SAR_SAFETY_SLEEP_INDEX CFG_INI_UINT( \
+ "gSarSafetySleepIndex", \
+ 0, \
+ 11, \
+ 11, \
+ CFG_VALUE_OR_DEFAULT, \
+ "SAR safety sleep index value")
+
+/*
+ *
+ * gEnableSarSafety - Enable/Disable SAR safety feature
+ *
+ * @Min: 0
+ * @Max: 1
+ * Default: 0
+ *
+ * This ini is used to enable/disable SAR safety feature
+ * Value 1 of this ini enables SAR safety feature and
+ * value 0 of this ini disables SAR safety feature
+ *
+ * Usage: External
+ *
+ *
+ */
+
+#define CFG_ENABLE_SAR_SAFETY_FEATURE CFG_INI_BOOL( \
+ "gEnableSarSafety", \
+ 0, \
+ "Enable/Disable SAR safety feature")
+
+/*
+ *
+ * gConfigSarSafetySleepIndex - Enable/Disable SAR Safety sleep index
+ *
+ * @Min: 0
+ * @Max: 1
+ * Default: 0
+ *
+ * This Configuration is to decide that before going to
+ * sleep mode whether to maintain high RF power
+ * (SAR disable) or to configure SAR sleep mode index
+ *
+ * Value 0 for this ini indicates to maintain high
+ * RF power (SAR disable)
+ * Value 1 for this ini indicates to configure SAR
+ * sleep mode index.
+ *
+ * Usage: External
+ *
+ *
+ */
+
+#define CFG_CONFIG_SAR_SAFETY_SLEEP_MODE_INDEX CFG_INI_BOOL( \
+ "gConfigSarSafetySleepIndex", \
+ 0, \
+ "Config SAR sleep Index")
+
+#define SAR_SAFETY_FEATURE_ALL \
+ CFG(CFG_SAR_SAFETY_TIMEOUT) \
+ CFG(CFG_SAR_SAFETY_UNSOLICITED_TIMEOUT) \
+ CFG(CFG_SAR_SAFETY_REQ_RESP_TIMEOUT) \
+ CFG(CFG_SAR_SAFETY_REQ_RESP_RETRIES) \
+ CFG(CFG_SAR_SAFETY_INDEX) \
+ CFG(CFG_SAR_SAFETY_SLEEP_INDEX) \
+ CFG(CFG_ENABLE_SAR_SAFETY_FEATURE) \
+ CFG(CFG_CONFIG_SAR_SAFETY_SLEEP_MODE_INDEX) \
+
+#else
+#define SAR_SAFETY_FEATURE_ALL
+#endif
+
+#endif
diff --git a/core/hdd/inc/wlan_hdd_cfg.h b/core/hdd/inc/wlan_hdd_cfg.h
index 43247fb1329d..a8330c775b58 100644
--- a/core/hdd/inc/wlan_hdd_cfg.h
+++ b/core/hdd/inc/wlan_hdd_cfg.h
@@ -233,6 +233,18 @@ struct hdd_config {
uint16_t pkt_bundle_size;
#endif
uint32_t dp_proto_event_bitmap;
+
+#ifdef SAR_SAFETY_FEATURE
+ uint32_t sar_safety_timeout;
+ uint32_t sar_safety_unsolicited_timeout;
+ uint32_t sar_safety_req_resp_timeout;
+ uint32_t sar_safety_req_resp_retry;
+ uint32_t sar_safety_index;
+ uint32_t sar_safety_sleep_index;
+ bool enable_sar_safety;
+ bool config_sar_safety_sleep_index;
+#endif
+
};
/**
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index d334d0352bab..1cc0375b7365 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -10444,6 +10444,32 @@ hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx)
}
#endif
+#ifdef SAR_SAFETY_FEATURE
+static void hdd_sar_cfg_update(struct hdd_config *config,
+ struct wlan_objmgr_psoc *psoc)
+{
+ config->sar_safety_timeout = cfg_get(psoc, CFG_SAR_SAFETY_TIMEOUT);
+ config->sar_safety_unsolicited_timeout =
+ cfg_get(psoc, CFG_SAR_SAFETY_UNSOLICITED_TIMEOUT);
+ config->sar_safety_req_resp_timeout =
+ cfg_get(psoc, CFG_SAR_SAFETY_REQ_RESP_TIMEOUT);
+ config->sar_safety_req_resp_retry =
+ cfg_get(psoc, CFG_SAR_SAFETY_REQ_RESP_RETRIES);
+ config->sar_safety_index = cfg_get(psoc, CFG_SAR_SAFETY_INDEX);
+ config->sar_safety_sleep_index =
+ cfg_get(psoc, CFG_SAR_SAFETY_SLEEP_INDEX);
+ config->enable_sar_safety =
+ cfg_get(psoc, CFG_ENABLE_SAR_SAFETY_FEATURE);
+ config->config_sar_safety_sleep_index =
+ cfg_get(psoc, CFG_CONFIG_SAR_SAFETY_SLEEP_MODE_INDEX);
+}
+#else
+static void hdd_sar_cfg_update(struct hdd_config *config,
+ struct wlan_objmgr_psoc *psoc)
+{
+}
+#endif
+
/**
* hdd_cfg_params_init() - Initialize hdd params in hdd_config strucuture
* @hdd_ctx - Pointer to HDD context
@@ -10542,6 +10568,7 @@ static void hdd_cfg_params_init(struct hdd_context *hdd_ctx)
hdd_init_mtrace_log(config, psoc);
hdd_init_dhcp_server_ip(hdd_ctx);
hdd_dp_cfg_update(psoc, hdd_ctx);
+ hdd_sar_cfg_update(config, psoc);
}
struct hdd_context *hdd_context_create(struct device *dev)