From 3d5a742d5cd996ad4d4b93109e5dd1f9a90ce49e Mon Sep 17 00:00:00 2001 From: Ashish Kumar Dhanotiya Date: Mon, 20 Jan 2020 14:42:02 +0530 Subject: [PATCH] qcacld-3.0: Add SAR unsolicited timer Add SAR unsolicited timer to the driver. This timer starts on every data tx (if not already running) and stops on command QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS. If this timer expires, a vendor event QCA_NL80211_VENDOR_SUBCMD_GET_SAR_LIMITS_EVENT is sent to the user space to issue the QCA_NL80211_VENDOR_SUBCMD_SET_SAR_LIMITS command. Change-Id: Ic30e5ac606d2b6b0cbc9209174adcd5213eac08e CRs-Fixed: 2615510 --- core/hdd/inc/wlan_hdd_main.h | 2 + core/hdd/src/wlan_hdd_cfg80211.c | 5 +++ core/hdd/src/wlan_hdd_sar_limits.c | 64 ++++++++++++++++++++++++++++ core/hdd/src/wlan_hdd_sar_limits.h | 15 +++++++ core/hdd/src/wlan_hdd_softap_tx_rx.c | 3 ++ core/hdd/src/wlan_hdd_tx_rx.c | 3 ++ 6 files changed, 92 insertions(+) diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index 27470f3ee0b4..e3f1df40c77a 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -1885,7 +1885,9 @@ struct hdd_context { struct sar_limit_cmd_params *sar_cmd_params; #ifdef SAR_SAFETY_FEATURE qdf_mc_timer_t sar_safety_timer; + qdf_mc_timer_t sar_safety_unsolicited_timer; #endif + qdf_time_t runtime_resume_start_time_stamp; qdf_time_t runtime_suspend_done_time_stamp; #if defined(CLD_PM_QOS) && \ diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 63dce137a037..6f74c7c1ec66 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -1580,6 +1580,11 @@ static const struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] = .vendor_id = QCA_NL80211_VENDOR_ID, .subcmd = QCA_NL80211_VENDOR_SUBCMD_OEM_DATA, }, + [QCA_NL80211_VENDOR_SUBCMD_REQUEST_SAR_LIMITS_INDEX] = { + .vendor_id = QCA_NL80211_VENDOR_ID, + .subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SAR_LIMITS_EVENT, + }, + }; /** diff --git a/core/hdd/src/wlan_hdd_sar_limits.c b/core/hdd/src/wlan_hdd_sar_limits.c index 0e98a1288b74..43813e5dd21e 100644 --- a/core/hdd/src/wlan_hdd_sar_limits.c +++ b/core/hdd/src/wlan_hdd_sar_limits.c @@ -384,6 +384,40 @@ config_sar_failed: } } +static void hdd_send_sar_unsolicited_event(struct hdd_context *hdd_ctx) +{ + struct sk_buff *vendor_event; + uint32_t len; + + if (!hdd_ctx) { + hdd_err_rl("hdd context is null"); + return; + } + + len = NLMSG_HDRLEN; + vendor_event = + cfg80211_vendor_event_alloc( + hdd_ctx->wiphy, NULL, len, + QCA_NL80211_VENDOR_SUBCMD_REQUEST_SAR_LIMITS_INDEX, + GFP_KERNEL); + + if (!vendor_event) { + hdd_err("cfg80211_vendor_event_alloc failed"); + return; + } + + cfg80211_vendor_event(vendor_event, GFP_KERNEL); +} + +static void hdd_sar_unsolicited_timer_cb(void *user_data) +{ + struct hdd_context *hdd_ctx = (struct hdd_context *)user_data; + + hdd_nofl_debug("Sar unsolicited timer expired"); + + hdd_send_sar_unsolicited_event(hdd_ctx); +} + static void hdd_sar_safety_timer_cb(void *user_data) { struct hdd_context *hdd_ctx = (struct hdd_context *)user_data; @@ -392,6 +426,19 @@ static void hdd_sar_safety_timer_cb(void *user_data) hdd_configure_sar_index(hdd_ctx, hdd_ctx->config->sar_safety_index); } +void wlan_hdd_sar_unsolicited_timer_start(struct hdd_context *hdd_ctx) +{ + if (!hdd_ctx->config->enable_sar_safety) + return; + + if (QDF_TIMER_STATE_RUNNING != + qdf_mc_timer_get_current_state( + &hdd_ctx->sar_safety_unsolicited_timer)) + qdf_mc_timer_start( + &hdd_ctx->sar_safety_unsolicited_timer, + hdd_ctx->config->sar_safety_unsolicited_timeout); +} + void wlan_hdd_sar_timers_reset(struct hdd_context *hdd_ctx) { if (!hdd_ctx->config->enable_sar_safety) @@ -406,6 +453,11 @@ void wlan_hdd_sar_timers_reset(struct hdd_context *hdd_ctx) qdf_mc_timer_start(&hdd_ctx->sar_safety_timer, hdd_ctx->config->sar_safety_timeout); + + if (QDF_TIMER_STATE_RUNNING == + qdf_mc_timer_get_current_state( + &hdd_ctx->sar_safety_unsolicited_timer)) + qdf_mc_timer_stop(&hdd_ctx->sar_safety_unsolicited_timer); } void wlan_hdd_sar_timers_init(struct hdd_context *hdd_ctx) @@ -415,6 +467,10 @@ void wlan_hdd_sar_timers_init(struct hdd_context *hdd_ctx) qdf_mc_timer_init(&hdd_ctx->sar_safety_timer, QDF_TIMER_TYPE_SW, hdd_sar_safety_timer_cb, hdd_ctx); + + qdf_mc_timer_init(&hdd_ctx->sar_safety_unsolicited_timer, + QDF_TIMER_TYPE_SW, + hdd_sar_unsolicited_timer_cb, hdd_ctx); } void wlan_hdd_sar_timers_deinit(struct hdd_context *hdd_ctx) @@ -427,6 +483,14 @@ void wlan_hdd_sar_timers_deinit(struct hdd_context *hdd_ctx) qdf_mc_timer_stop(&hdd_ctx->sar_safety_timer); qdf_mc_timer_destroy(&hdd_ctx->sar_safety_timer); + + if (QDF_TIMER_STATE_RUNNING == + qdf_mc_timer_get_current_state( + &hdd_ctx->sar_safety_unsolicited_timer)) + qdf_mc_timer_stop(&hdd_ctx->sar_safety_unsolicited_timer); + + qdf_mc_timer_destroy(&hdd_ctx->sar_safety_unsolicited_timer); + } #endif diff --git a/core/hdd/src/wlan_hdd_sar_limits.h b/core/hdd/src/wlan_hdd_sar_limits.h index 9777a1a2c84e..b04c21f1bd2c 100644 --- a/core/hdd/src/wlan_hdd_sar_limits.h +++ b/core/hdd/src/wlan_hdd_sar_limits.h @@ -28,6 +28,16 @@ #ifdef FEATURE_SAR_LIMITS #ifdef SAR_SAFETY_FEATURE +/** + * wlan_hdd_sar_unsolicited_timer_start() - Start SAR unsolicited timer + * @hdd_ctx: Pointer to HDD context + * + * This function checks the state of the sar unsolicited timer, if the + * sar_unsolicited_timer is not runnig, it starts the timer. + * + * Return: None + */ +void wlan_hdd_sar_unsolicited_timer_start(struct hdd_context *hdd_ctx); /** * wlan_hdd_sar_safety_timer_reset() - Reset SAR sefety timer @@ -72,6 +82,11 @@ void wlan_hdd_sar_timers_deinit(struct hdd_context *hdd_ctx); void hdd_configure_sar_index(struct hdd_context *hdd_ctx, uint32_t sar_index); #else +static inline void wlan_hdd_sar_unsolicited_timer_start( + struct hdd_context *hdd_ctx) +{ +} + static inline void wlan_hdd_sar_timers_reset(struct hdd_context *hdd_ctx) { } diff --git a/core/hdd/src/wlan_hdd_softap_tx_rx.c b/core/hdd/src/wlan_hdd_softap_tx_rx.c index 83cc93d0ca97..9c9f7e3dca71 100644 --- a/core/hdd/src/wlan_hdd_softap_tx_rx.c +++ b/core/hdd/src/wlan_hdd_softap_tx_rx.c @@ -46,6 +46,7 @@ #include #include "wlan_hdd_sta_info.h" #include "ol_defines.h" +#include /* Preprocessor definitions and constants */ #undef QCA_HDD_SAP_DUMP_SK_BUFF @@ -606,6 +607,8 @@ static void __hdd_softap_hard_start_xmit(struct sk_buff *skb, } netif_trans_update(dev); + wlan_hdd_sar_unsolicited_timer_start(hdd_ctx); + return; drop_pkt_and_release_skb: diff --git a/core/hdd/src/wlan_hdd_tx_rx.c b/core/hdd/src/wlan_hdd_tx_rx.c index 5a464e5e063b..5c029883924d 100644 --- a/core/hdd/src/wlan_hdd_tx_rx.c +++ b/core/hdd/src/wlan_hdd_tx_rx.c @@ -67,6 +67,7 @@ #include "wlan_hdd_object_manager.h" #include "nan_public_structs.h" #include "nan_ucfg_api.h" +#include #if defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(QCA_LL_PDEV_TX_FLOW_CONTROL) /* @@ -1143,6 +1144,8 @@ static void __hdd_hard_start_xmit(struct sk_buff *skb, netif_trans_update(dev); + wlan_hdd_sar_unsolicited_timer_start(hdd_ctx); + return; drop_pkt_and_release_skb: